create-dubhe 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/template/101/sui-template/.prettierrc +7 -7
- package/template/101/sui-template/README.md +8 -9
- package/template/101/sui-template/contracts/counter/.history/sui_localnet/latest.json +11 -0
- package/template/101/sui-template/contracts/counter/Move.lock +45 -0
- package/template/101/sui-template/dubhe.config.ts +11 -11
- package/template/101/sui-template/eslint.config.mjs +14 -0
- package/template/101/sui-template/next.config.ts +7 -0
- package/template/101/sui-template/package.json +23 -40
- package/template/101/sui-template/pnpm-lock.yaml +8133 -0
- package/template/101/sui-template/postcss.config.mjs +8 -0
- package/template/101/sui-template/src/app/favicon.ico +0 -0
- package/template/101/sui-template/src/app/globals.css +21 -0
- package/template/101/sui-template/src/app/layout.tsx +34 -0
- package/template/101/sui-template/src/app/page.tsx +106 -0
- package/template/101/sui-template/src/app/state/index.tsx +5 -0
- package/template/101/sui-template/src/chain/config.ts +2 -2
- package/template/101/sui-template/tailwind.config.ts +18 -0
- package/template/101/sui-template/tsconfig.json +11 -8
- package/template/contract/sui-template/package.json +1 -1
- package/template/nextjs/sui-template/.prettierrc +7 -7
- package/template/nextjs/sui-template/README.md +8 -8
- package/template/nextjs/sui-template/contracts/counter/.history/sui_localnet/latest.json +11 -0
- package/template/nextjs/sui-template/contracts/counter/Move.lock +52 -0
- package/template/nextjs/sui-template/contracts/counter/Move.toml +1 -1
- package/template/nextjs/sui-template/dubhe.config.ts +11 -11
- package/template/nextjs/sui-template/eslint.config.mjs +14 -0
- package/template/nextjs/sui-template/next.config.mjs +5 -0
- package/template/nextjs/sui-template/package.json +25 -41
- package/template/nextjs/sui-template/pnpm-lock.yaml +9002 -0
- package/template/nextjs/sui-template/postcss.config.mjs +8 -0
- package/template/nextjs/sui-template/src/app/favicon.ico +0 -0
- package/template/nextjs/sui-template/src/app/globals.css +21 -0
- package/template/nextjs/sui-template/src/app/layout.tsx +17 -0
- package/template/nextjs/sui-template/src/app/page.tsx +151 -0
- package/template/nextjs/sui-template/src/{pages/_app.tsx → app/providers.tsx} +6 -12
- package/template/nextjs/sui-template/src/app/state/index.tsx +5 -0
- package/template/nextjs/sui-template/src/chain/config.ts +3 -3
- package/template/nextjs/sui-template/tailwind.config.ts +18 -0
- package/template/nextjs/sui-template/tsconfig.json +13 -15
- package/template/101/sui-template/.dockerignore +0 -7
- package/template/101/sui-template/.eslintrc.json +0 -3
- package/template/101/sui-template/Dockerfile +0 -52
- package/template/101/sui-template/LICENSE +0 -674
- package/template/101/sui-template/jest.config.ts +0 -17
- package/template/101/sui-template/next-env.d.ts +0 -5
- package/template/101/sui-template/next-i18next.config.js +0 -6
- package/template/101/sui-template/next.config.js +0 -15
- package/template/101/sui-template/postcss.config.js +0 -6
- package/template/101/sui-template/public/discord.svg +0 -9
- package/template/101/sui-template/public/fail.svg +0 -12
- package/template/101/sui-template/public/favicon.ico +0 -0
- package/template/101/sui-template/public/locales/de/common.json +0 -8
- package/template/101/sui-template/public/locales/de/footer.json +0 -3
- package/template/101/sui-template/public/locales/de/second-page.json +0 -5
- package/template/101/sui-template/public/locales/en/common.json +0 -8
- package/template/101/sui-template/public/locales/en/footer.json +0 -3
- package/template/101/sui-template/public/locales/en/second-page.json +0 -5
- package/template/101/sui-template/public/locales/zn/common.json +0 -8
- package/template/101/sui-template/public/locales/zn/footer.json +0 -3
- package/template/101/sui-template/public/locales/zn/second-page.json +0 -5
- package/template/101/sui-template/public/logo.svg +0 -1
- package/template/101/sui-template/public/medium.svg +0 -9
- package/template/101/sui-template/public/successful.svg +0 -11
- package/template/101/sui-template/public/telegram.svg +0 -9
- package/template/101/sui-template/public/twitter.svg +0 -9
- package/template/101/sui-template/src/css/font-awesome.css +0 -2337
- package/template/101/sui-template/src/css/font-awesome.min.css +0 -4
- package/template/101/sui-template/src/fonts/FontAwesome.otf +0 -0
- package/template/101/sui-template/src/fonts/fontawesome-webfont.eot +0 -0
- package/template/101/sui-template/src/fonts/fontawesome-webfont.svg +0 -2671
- package/template/101/sui-template/src/fonts/fontawesome-webfont.ttf +0 -0
- package/template/101/sui-template/src/fonts/fontawesome-webfont.woff +0 -0
- package/template/101/sui-template/src/fonts/fontawesome-webfont.woff2 +0 -0
- package/template/101/sui-template/src/jotai/index.tsx +0 -12
- package/template/101/sui-template/src/pages/_app.tsx +0 -15
- package/template/101/sui-template/src/pages/home/index.tsx +0 -117
- package/template/101/sui-template/src/pages/index.tsx +0 -12
- package/template/101/sui-template/tailwind.config.js +0 -56
- package/template/nextjs/sui-template/.dockerignore +0 -7
- package/template/nextjs/sui-template/.eslintrc.json +0 -3
- package/template/nextjs/sui-template/Dockerfile +0 -52
- package/template/nextjs/sui-template/LICENSE +0 -674
- package/template/nextjs/sui-template/jest.config.ts +0 -17
- package/template/nextjs/sui-template/next-env.d.ts +0 -5
- package/template/nextjs/sui-template/next-i18next.config.js +0 -6
- package/template/nextjs/sui-template/next.config.js +0 -15
- package/template/nextjs/sui-template/postcss.config.js +0 -6
- package/template/nextjs/sui-template/public/discord.svg +0 -9
- package/template/nextjs/sui-template/public/fail.svg +0 -12
- package/template/nextjs/sui-template/public/favicon.ico +0 -0
- package/template/nextjs/sui-template/public/locales/de/common.json +0 -8
- package/template/nextjs/sui-template/public/locales/de/footer.json +0 -3
- package/template/nextjs/sui-template/public/locales/de/second-page.json +0 -5
- package/template/nextjs/sui-template/public/locales/en/common.json +0 -8
- package/template/nextjs/sui-template/public/locales/en/footer.json +0 -3
- package/template/nextjs/sui-template/public/locales/en/second-page.json +0 -5
- package/template/nextjs/sui-template/public/locales/zn/common.json +0 -8
- package/template/nextjs/sui-template/public/locales/zn/footer.json +0 -3
- package/template/nextjs/sui-template/public/locales/zn/second-page.json +0 -5
- package/template/nextjs/sui-template/public/logo.svg +0 -1
- package/template/nextjs/sui-template/public/medium.svg +0 -9
- package/template/nextjs/sui-template/public/successful.svg +0 -11
- package/template/nextjs/sui-template/public/telegram.svg +0 -9
- package/template/nextjs/sui-template/public/twitter.svg +0 -9
- package/template/nextjs/sui-template/src/components/Animation.tsx +0 -80
- package/template/nextjs/sui-template/src/components/Container.tsx +0 -11
- package/template/nextjs/sui-template/src/components/footer/index.tsx +0 -138
- package/template/nextjs/sui-template/src/components/head/index.tsx +0 -14
- package/template/nextjs/sui-template/src/components/header/index.tsx +0 -173
- package/template/nextjs/sui-template/src/components/pop_up_box/index.tsx +0 -149
- package/template/nextjs/sui-template/src/css/font-awesome.css +0 -2337
- package/template/nextjs/sui-template/src/css/font-awesome.min.css +0 -4
- package/template/nextjs/sui-template/src/fonts/FontAwesome.otf +0 -0
- package/template/nextjs/sui-template/src/fonts/fontawesome-webfont.eot +0 -0
- package/template/nextjs/sui-template/src/fonts/fontawesome-webfont.svg +0 -2671
- package/template/nextjs/sui-template/src/fonts/fontawesome-webfont.ttf +0 -0
- package/template/nextjs/sui-template/src/fonts/fontawesome-webfont.woff +0 -0
- package/template/nextjs/sui-template/src/fonts/fontawesome-webfont.woff2 +0 -0
- package/template/nextjs/sui-template/src/jotai/index.tsx +0 -13
- package/template/nextjs/sui-template/src/pages/home/index.tsx +0 -172
- package/template/nextjs/sui-template/src/pages/index.tsx +0 -15
- package/template/nextjs/sui-template/tailwind.config.js +0 -56
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import {atom} from "jotai";
|
|
2
|
-
|
|
3
|
-
const SellPopUpBoxState = atom(false)
|
|
4
|
-
const SellState = atom({
|
|
5
|
-
type:"",
|
|
6
|
-
hash:"",
|
|
7
|
-
state:false
|
|
8
|
-
})
|
|
9
|
-
const OpenBoxState = atom(false)
|
|
10
|
-
const Value = atom("")
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export {SellPopUpBoxState,SellState,OpenBoxState,Value}
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import { loadMetadata, Dubhe, Transaction, DevInspectResults, NetworkType } from '@0xobelisk/sui-client';
|
|
2
|
-
import { useEffect, useState } from 'react';
|
|
3
|
-
import { useAtom } from 'jotai';
|
|
4
|
-
import { Value } from '../../jotai';
|
|
5
|
-
import { useRouter } from 'next/router';
|
|
6
|
-
import { SCHEMA_ID, NETWORK, PACKAGE_ID } from '../../chain/config';
|
|
7
|
-
import { ConnectButton, useCurrentWallet, useSignAndExecuteTransaction, useCurrentAccount } from '@mysten/dapp-kit';
|
|
8
|
-
import { toast } from 'sonner';
|
|
9
|
-
|
|
10
|
-
function getExplorerUrl(network: NetworkType, digest: string) {
|
|
11
|
-
switch (network) {
|
|
12
|
-
case 'testnet':
|
|
13
|
-
return `https://explorer.polymedia.app/txblock/${digest}?network=${network}`;
|
|
14
|
-
case 'mainnet':
|
|
15
|
-
return `https://suiscan.xyz/tx/${digest}`;
|
|
16
|
-
case 'devnet':
|
|
17
|
-
return `https://explorer.polymedia.app/txblock/${digest}?network=${network}`;
|
|
18
|
-
case 'localnet':
|
|
19
|
-
return `https://explorer.polymedia.app/txblock/${digest}?network=local`;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Home component for the counter application
|
|
24
|
-
* Manages the counter state, user balance, and interactions with the Sui blockchain
|
|
25
|
-
*/
|
|
26
|
-
const Home: React.FC = () => {
|
|
27
|
-
const router = useRouter();
|
|
28
|
-
const { mutateAsync: signAndExecuteTransaction } = useSignAndExecuteTransaction();
|
|
29
|
-
const { connectionStatus } = useCurrentWallet();
|
|
30
|
-
const address = useCurrentAccount()?.address;
|
|
31
|
-
|
|
32
|
-
const [value, setValue] = useAtom(Value);
|
|
33
|
-
const [loading, setLoading] = useState<boolean>(false);
|
|
34
|
-
const [balance, setBalance] = useState<string>('0');
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Queries the current counter value from the blockchain
|
|
38
|
-
*/
|
|
39
|
-
const queryCounter = async (): Promise<void> => {
|
|
40
|
-
try {
|
|
41
|
-
const metadata = await loadMetadata(NETWORK, PACKAGE_ID);
|
|
42
|
-
const dubhe = new Dubhe({
|
|
43
|
-
networkType: NETWORK,
|
|
44
|
-
packageId: PACKAGE_ID,
|
|
45
|
-
metadata: metadata,
|
|
46
|
-
});
|
|
47
|
-
const tx = new Transaction();
|
|
48
|
-
const queryValue = (await dubhe.query.schema.get_value({
|
|
49
|
-
tx,
|
|
50
|
-
params: [tx.object(SCHEMA_ID)],
|
|
51
|
-
})) as DevInspectResults;
|
|
52
|
-
console.log('Counter value:', dubhe.view(queryValue)[0]);
|
|
53
|
-
setValue(dubhe.view(queryValue)[0]);
|
|
54
|
-
} catch (error) {
|
|
55
|
-
console.error('Failed to query counter:', error);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Fetches the current balance of the connected wallet
|
|
61
|
-
*/
|
|
62
|
-
const getBalance = async (): Promise<void> => {
|
|
63
|
-
if (!address) return;
|
|
64
|
-
try {
|
|
65
|
-
const dubhe = new Dubhe({ networkType: NETWORK });
|
|
66
|
-
const balance = await dubhe.balanceOf(address);
|
|
67
|
-
setBalance((Number(balance.totalBalance) / 1_000_000_000).toFixed(4));
|
|
68
|
-
} catch (error) {
|
|
69
|
-
console.error('Failed to fetch balance:', error);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Increments the counter on the blockchain
|
|
75
|
-
*/
|
|
76
|
-
const incrementCounter = async (): Promise<void> => {
|
|
77
|
-
setLoading(true);
|
|
78
|
-
try {
|
|
79
|
-
const metadata = await loadMetadata(NETWORK, PACKAGE_ID);
|
|
80
|
-
const dubhe = new Dubhe({
|
|
81
|
-
networkType: NETWORK,
|
|
82
|
-
packageId: PACKAGE_ID,
|
|
83
|
-
metadata: metadata,
|
|
84
|
-
});
|
|
85
|
-
const tx = new Transaction();
|
|
86
|
-
await dubhe.tx.counter_system.inc({
|
|
87
|
-
tx,
|
|
88
|
-
params: [tx.object(SCHEMA_ID), tx.pure.u32(1)],
|
|
89
|
-
isRaw: true,
|
|
90
|
-
});
|
|
91
|
-
await signAndExecuteTransaction(
|
|
92
|
-
{
|
|
93
|
-
transaction: tx.serialize(),
|
|
94
|
-
chain: `sui:${NETWORK}`,
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
onSuccess: async result => {
|
|
98
|
-
// Wait for a short period before querying the latest data
|
|
99
|
-
setTimeout(async () => {
|
|
100
|
-
await queryCounter();
|
|
101
|
-
await getBalance();
|
|
102
|
-
toast('Transfer Successful', {
|
|
103
|
-
description: new Date().toUTCString(),
|
|
104
|
-
action: {
|
|
105
|
-
label: 'Check in Explorer',
|
|
106
|
-
onClick: () => window.open(getExplorerUrl(NETWORK, result.digest), '_blank'),
|
|
107
|
-
},
|
|
108
|
-
});
|
|
109
|
-
setLoading(false);
|
|
110
|
-
}, 2000); // Wait for 2 seconds before querying, adjust as needed
|
|
111
|
-
},
|
|
112
|
-
onError: error => {
|
|
113
|
-
console.error('Transaction failed:', error);
|
|
114
|
-
toast.error('Transaction failed. Please try again.');
|
|
115
|
-
setLoading(false);
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
);
|
|
119
|
-
} catch (error) {
|
|
120
|
-
console.error('Transaction error:', error);
|
|
121
|
-
setLoading(false);
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
// Initialize counter and balance when the component mounts and wallet is connected
|
|
126
|
-
useEffect(() => {
|
|
127
|
-
if (router.isReady && address) {
|
|
128
|
-
queryCounter();
|
|
129
|
-
getBalance();
|
|
130
|
-
}
|
|
131
|
-
}, [router.isReady, address]);
|
|
132
|
-
|
|
133
|
-
return (
|
|
134
|
-
<div className="flex justify-between items-start">
|
|
135
|
-
<div className="max-w-7xl mx-auto text-center py-12 px-4 sm:px-6 lg:py-16 lg:px-8 flex-6">
|
|
136
|
-
{connectionStatus !== 'connected' ? (
|
|
137
|
-
<ConnectButton />
|
|
138
|
-
) : (
|
|
139
|
-
<>
|
|
140
|
-
<div>
|
|
141
|
-
<ConnectButton />
|
|
142
|
-
<div className="mt-4 text-lg">
|
|
143
|
-
{Number(balance) === 0 ? (
|
|
144
|
-
<span className="text-red-500">Balance is 0. Please acquire some {NETWORK} tokens first.</span>
|
|
145
|
-
) : (
|
|
146
|
-
<span>Balance: {balance} SUI</span>
|
|
147
|
-
)}
|
|
148
|
-
</div>
|
|
149
|
-
</div>
|
|
150
|
-
<div className="flex flex-col gap-6 mt-12">
|
|
151
|
-
<div className="flex flex-col gap-4">
|
|
152
|
-
<div className="flex flex-col gap-6 text-2xl text-green-600 mt-6">Counter: {value}</div>
|
|
153
|
-
<div className="flex flex-col gap-6">
|
|
154
|
-
<button
|
|
155
|
-
type="button"
|
|
156
|
-
className="mx-auto px-5 py-3 border border-transparent text-base font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 disabled:bg-gray-400"
|
|
157
|
-
onClick={incrementCounter}
|
|
158
|
-
disabled={loading || Number(balance) === 0}
|
|
159
|
-
>
|
|
160
|
-
{loading ? 'Processing...' : 'Increment'}
|
|
161
|
-
</button>
|
|
162
|
-
</div>
|
|
163
|
-
</div>
|
|
164
|
-
</div>
|
|
165
|
-
</>
|
|
166
|
-
)}
|
|
167
|
-
</div>
|
|
168
|
-
</div>
|
|
169
|
-
);
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
export default Home;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
const defaultTheme = require('tailwindcss/defaultTheme')
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
|
|
5
|
-
content: ['./src/**/*.{js,ts,jsx,tsx}'],
|
|
6
|
-
darkMode: 'media', // or 'media' or 'class'
|
|
7
|
-
theme: {
|
|
8
|
-
extend: {
|
|
9
|
-
spacing: {
|
|
10
|
-
"70":"17rem",
|
|
11
|
-
'78':'18rem',
|
|
12
|
-
'82': '20rem',
|
|
13
|
-
'90': '22rem',
|
|
14
|
-
'93': '23rem',
|
|
15
|
-
'97': '25rem',
|
|
16
|
-
'98': '27rem',
|
|
17
|
-
'99': "30rem",
|
|
18
|
-
"new":"34rem",
|
|
19
|
-
"new-1":"39rem",
|
|
20
|
-
"100":"43rem",
|
|
21
|
-
"105":"46rem",
|
|
22
|
-
"106":"48rem",
|
|
23
|
-
},
|
|
24
|
-
colors: {
|
|
25
|
-
transparent: 'transparent',
|
|
26
|
-
current: 'currentColor',
|
|
27
|
-
custom:{
|
|
28
|
-
DEFAULT:'#8861D1',
|
|
29
|
-
light:"#8861D1",
|
|
30
|
-
dark:"#8861D1",
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
},
|
|
34
|
-
screens: {
|
|
35
|
-
'3xl': '1700px',
|
|
36
|
-
},
|
|
37
|
-
fontFamily: {
|
|
38
|
-
sans: ['Inter var', ...defaultTheme.fontFamily.sans],
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
},
|
|
46
|
-
plugins: [
|
|
47
|
-
|
|
48
|
-
require('@tailwindcss/line-clamp'),
|
|
49
|
-
require('tailwind-scrollbar'),
|
|
50
|
-
],
|
|
51
|
-
variants: {
|
|
52
|
-
scrollbar: ['rounded']
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|