@sei-js/create-sei 0.0.1 → 0.0.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/.yarn/install-state.gz +0 -0
- package/CHANGELOG.md +12 -0
- package/README.md +16 -25
- package/biome.json +8 -0
- package/dist/main.js +162 -0
- package/dist/templates/next-cosmos-template/.eslintrc.json +3 -0
- package/dist/templates/next-cosmos-template/README.md +60 -0
- package/dist/templates/next-cosmos-template/next-env.d.ts +5 -0
- package/dist/templates/next-cosmos-template/next.config.mjs +14 -0
- package/dist/templates/next-cosmos-template/package.json +31 -0
- package/dist/templates/next-cosmos-template/public/next.svg +1 -0
- package/dist/templates/next-cosmos-template/public/sei-logotype.svg +15 -0
- package/dist/templates/next-cosmos-template/public/vercel.svg +1 -0
- package/dist/templates/next-cosmos-template/src/app/components/Homepage/Examples.tsx +168 -0
- package/dist/templates/next-cosmos-template/src/app/components/Homepage/Homepage.css +154 -0
- package/dist/templates/next-cosmos-template/src/app/components/Homepage/Homepage.tsx +83 -0
- package/dist/templates/next-cosmos-template/src/app/components/WalletConnectButton/WalletConnectButton.tsx +18 -0
- package/dist/templates/next-cosmos-template/src/app/components/Web3Provider.tsx +35 -0
- package/dist/templates/next-cosmos-template/src/app/components/index.ts +3 -0
- package/dist/templates/next-cosmos-template/src/app/constants/chain.ts +16 -0
- package/dist/templates/next-cosmos-template/src/app/constants/index.ts +1 -0
- package/dist/templates/next-cosmos-template/src/app/favicon.ico +0 -0
- package/dist/templates/next-cosmos-template/src/app/index.css +184 -0
- package/dist/templates/next-cosmos-template/src/app/layout.tsx +21 -0
- package/dist/templates/next-cosmos-template/src/app/page.tsx +17 -0
- package/dist/templates/next-cosmos-template/tsconfig.json +26 -0
- package/dist/templates/next-cosmos-template/yarn.lock +9814 -0
- package/dist/templates/next-wagmi-template/.eslintrc.json +3 -0
- package/dist/templates/next-wagmi-template/README.md +58 -0
- package/dist/templates/next-wagmi-template/next-env.d.ts +5 -0
- package/dist/templates/next-wagmi-template/next.config.mjs +4 -0
- package/dist/templates/next-wagmi-template/package.json +30 -0
- package/dist/templates/next-wagmi-template/public/sei-logotype.svg +15 -0
- package/dist/templates/next-wagmi-template/src/app/components/Homepage/Examples.tsx +257 -0
- package/dist/templates/next-wagmi-template/src/app/components/Homepage/Homepage.css +154 -0
- package/dist/templates/next-wagmi-template/src/app/components/Homepage/Homepage.tsx +87 -0
- package/dist/templates/next-wagmi-template/src/app/components/Web3Provider.tsx +74 -0
- package/dist/templates/next-wagmi-template/src/app/components/index.ts +2 -0
- package/dist/templates/next-wagmi-template/src/app/constants/chain.ts +7 -0
- package/dist/templates/next-wagmi-template/src/app/constants/index.ts +1 -0
- package/dist/templates/next-wagmi-template/src/app/favicon.ico +0 -0
- package/dist/templates/next-wagmi-template/src/app/index.css +184 -0
- package/dist/templates/next-wagmi-template/src/app/layout.tsx +21 -0
- package/dist/templates/next-wagmi-template/src/app/page.tsx +21 -0
- package/dist/templates/next-wagmi-template/tsconfig.json +26 -0
- package/dist/templates/next-wagmi-template/yarn.lock +4809 -0
- package/dist/templates/vite-cosmos-template/.eslintrc.cjs +11 -0
- package/dist/templates/vite-cosmos-template/README.md +72 -0
- package/dist/templates/vite-cosmos-template/favicon.ico +0 -0
- package/dist/templates/vite-cosmos-template/index.html +16 -0
- package/dist/templates/vite-cosmos-template/package.json +35 -0
- package/dist/templates/vite-cosmos-template/public/sei-logotype.svg +15 -0
- package/dist/templates/vite-cosmos-template/src/App.tsx +15 -0
- package/dist/templates/vite-cosmos-template/src/assets/react.svg +1 -0
- package/dist/templates/vite-cosmos-template/src/components/Homepage/Examples.tsx +168 -0
- package/dist/templates/vite-cosmos-template/src/components/Homepage/Homepage.css +154 -0
- package/dist/templates/vite-cosmos-template/src/components/Homepage/Homepage.tsx +77 -0
- package/dist/templates/vite-cosmos-template/src/components/WalletConnectButton/WalletConnectButton.tsx +18 -0
- package/dist/templates/vite-cosmos-template/src/components/Web3Provider.tsx +41 -0
- package/dist/templates/vite-cosmos-template/src/components/index.ts +4 -0
- package/dist/templates/vite-cosmos-template/src/constants/chain.ts +16 -0
- package/dist/templates/vite-cosmos-template/src/constants/index.ts +1 -0
- package/dist/templates/vite-cosmos-template/src/index.css +184 -0
- package/dist/templates/vite-cosmos-template/src/main.tsx +12 -0
- package/dist/templates/vite-cosmos-template/src/vite-env.d.ts +1 -0
- package/dist/templates/vite-cosmos-template/tsconfig.app.json +25 -0
- package/dist/templates/vite-cosmos-template/tsconfig.json +11 -0
- package/dist/templates/vite-cosmos-template/tsconfig.node.json +14 -0
- package/dist/templates/vite-cosmos-template/vite.config.ts +7 -0
- package/dist/templates/vite-cosmos-template/yarn.lock +9323 -0
- package/dist/templates/vite-wagmi-template/.eslintrc.cjs +11 -0
- package/dist/templates/vite-wagmi-template/README.md +72 -0
- package/dist/templates/vite-wagmi-template/favicon.ico +0 -0
- package/dist/templates/vite-wagmi-template/index.html +12 -0
- package/dist/templates/vite-wagmi-template/package.json +33 -0
- package/dist/templates/vite-wagmi-template/public/sei-logotype.svg +15 -0
- package/dist/templates/vite-wagmi-template/src/App.tsx +21 -0
- package/dist/templates/vite-wagmi-template/src/assets/react.svg +1 -0
- package/dist/templates/vite-wagmi-template/src/components/Homepage/Examples.tsx +255 -0
- package/dist/templates/vite-wagmi-template/src/components/Homepage/Homepage.css +154 -0
- package/dist/templates/vite-wagmi-template/src/components/Homepage/Homepage.tsx +81 -0
- package/dist/templates/vite-wagmi-template/src/components/Web3Provider.tsx +72 -0
- package/dist/templates/vite-wagmi-template/src/constants/chain.ts +6 -0
- package/dist/templates/vite-wagmi-template/src/constants/index.ts +1 -0
- package/dist/templates/vite-wagmi-template/src/index.css +183 -0
- package/dist/templates/vite-wagmi-template/src/main.tsx +12 -0
- package/dist/templates/vite-wagmi-template/src/vite-env.d.ts +1 -0
- package/dist/templates/vite-wagmi-template/tsconfig.app.json +25 -0
- package/dist/templates/vite-wagmi-template/tsconfig.json +11 -0
- package/dist/templates/vite-wagmi-template/tsconfig.node.json +14 -0
- package/dist/templates/vite-wagmi-template/vite.config.ts +10 -0
- package/dist/templates/vite-wagmi-template/yarn.lock +4603 -0
- package/package.json +3 -2
- package/src/main.ts +31 -33
- package/templates/next-cosmos-template/.eslintrc.json +1 -1
- package/templates/next-cosmos-template/next.config.mjs +9 -9
- package/templates/next-cosmos-template/package.json +29 -29
- package/templates/next-cosmos-template/src/app/components/Homepage/Examples.tsx +162 -171
- package/templates/next-cosmos-template/src/app/components/Homepage/Homepage.css +92 -94
- package/templates/next-cosmos-template/src/app/components/Homepage/Homepage.tsx +22 -49
- package/templates/next-cosmos-template/src/app/components/WalletConnectButton/WalletConnectButton.tsx +11 -19
- package/templates/next-cosmos-template/src/app/components/Web3Provider.tsx +13 -17
- package/templates/next-cosmos-template/src/app/components/index.ts +3 -3
- package/templates/next-cosmos-template/src/app/constants/chain.ts +9 -9
- package/templates/next-cosmos-template/src/app/constants/index.ts +1 -1
- package/templates/next-cosmos-template/src/app/index.css +99 -86
- package/templates/next-cosmos-template/src/app/layout.tsx +12 -12
- package/templates/next-cosmos-template/src/app/page.tsx +13 -13
- package/templates/next-cosmos-template/tsconfig.json +24 -24
- package/templates/next-wagmi-template/.eslintrc.json +1 -1
- package/templates/next-wagmi-template/package.json +28 -28
- package/templates/next-wagmi-template/src/app/components/Homepage/Examples.tsx +223 -237
- package/templates/next-wagmi-template/src/app/components/Homepage/Homepage.css +92 -94
- package/templates/next-wagmi-template/src/app/components/Homepage/Homepage.tsx +10 -36
- package/templates/next-wagmi-template/src/app/components/Web3Provider.tsx +29 -28
- package/templates/next-wagmi-template/src/app/components/index.ts +2 -2
- package/templates/next-wagmi-template/src/app/constants/chain.ts +2 -2
- package/templates/next-wagmi-template/src/app/constants/index.ts +1 -1
- package/templates/next-wagmi-template/src/app/index.css +99 -86
- package/templates/next-wagmi-template/src/app/layout.tsx +12 -12
- package/templates/next-wagmi-template/src/app/page.tsx +17 -17
- package/templates/next-wagmi-template/tsconfig.json +24 -24
- package/templates/vite-cosmos-template/.eslintrc.cjs +10 -17
- package/templates/vite-cosmos-template/package.json +33 -33
- package/templates/vite-cosmos-template/src/App.tsx +11 -12
- package/templates/vite-cosmos-template/src/components/Homepage/Examples.tsx +162 -171
- package/templates/vite-cosmos-template/src/components/Homepage/Homepage.css +92 -94
- package/templates/vite-cosmos-template/src/components/Homepage/Homepage.tsx +20 -45
- package/templates/vite-cosmos-template/src/components/WalletConnectButton/WalletConnectButton.tsx +11 -19
- package/templates/vite-cosmos-template/src/components/Web3Provider.tsx +14 -18
- package/templates/vite-cosmos-template/src/components/index.ts +4 -4
- package/templates/vite-cosmos-template/src/constants/chain.ts +9 -9
- package/templates/vite-cosmos-template/src/constants/index.ts +1 -1
- package/templates/vite-cosmos-template/src/index.css +99 -86
- package/templates/vite-cosmos-template/src/main.tsx +10 -10
- package/templates/vite-cosmos-template/tsconfig.app.json +21 -23
- package/templates/vite-cosmos-template/tsconfig.json +9 -9
- package/templates/vite-cosmos-template/tsconfig.node.json +11 -11
- package/templates/vite-cosmos-template/vite.config.ts +4 -4
- package/templates/vite-wagmi-template/.eslintrc.cjs +10 -17
- package/templates/vite-wagmi-template/package.json +31 -31
- package/templates/vite-wagmi-template/src/App.tsx +12 -13
- package/templates/vite-wagmi-template/src/components/Homepage/Examples.tsx +225 -239
- package/templates/vite-wagmi-template/src/components/Homepage/Homepage.css +92 -94
- package/templates/vite-wagmi-template/src/components/Homepage/Homepage.tsx +28 -53
- package/templates/vite-wagmi-template/src/components/Web3Provider.tsx +29 -28
- package/templates/vite-wagmi-template/src/constants/chain.ts +1 -1
- package/templates/vite-wagmi-template/src/constants/index.ts +1 -1
- package/templates/vite-wagmi-template/src/index.css +98 -85
- package/templates/vite-wagmi-template/src/main.tsx +10 -10
- package/templates/vite-wagmi-template/tsconfig.app.json +21 -23
- package/templates/vite-wagmi-template/tsconfig.json +9 -9
- package/templates/vite-wagmi-template/tsconfig.node.json +11 -11
- package/templates/vite-wagmi-template/vite.config.ts +7 -7
- package/tsconfig.json +24 -28
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
rules: {
|
|
13
|
-
'react-refresh/only-export-components': [
|
|
14
|
-
'warn',
|
|
15
|
-
{ allowConstantExport: true },
|
|
16
|
-
],
|
|
17
|
-
},
|
|
18
|
-
}
|
|
2
|
+
root: true,
|
|
3
|
+
env: { browser: true, es2020: true },
|
|
4
|
+
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:react-hooks/recommended'],
|
|
5
|
+
ignorePatterns: ['dist', '.eslintrc.cjs'],
|
|
6
|
+
parser: '@typescript-eslint/parser',
|
|
7
|
+
plugins: ['react-refresh'],
|
|
8
|
+
rules: {
|
|
9
|
+
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }]
|
|
10
|
+
}
|
|
11
|
+
};
|
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
2
|
+
"name": "template-vite-wagmi-sei-app",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite",
|
|
8
|
+
"build": "tsc -b && vite build",
|
|
9
|
+
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
|
10
|
+
"preview": "vite preview"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@rainbow-me/rainbowkit": "^2.1.2",
|
|
14
|
+
"@sei-js/evm": "^1.2.0",
|
|
15
|
+
"@tanstack/react-query": "^5.45.1",
|
|
16
|
+
"react": "^18.3.1",
|
|
17
|
+
"react-dom": "^18.3.1",
|
|
18
|
+
"viem": "^2.15.1",
|
|
19
|
+
"wagmi": "^2.10.2"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@types/react": "^18.3.3",
|
|
23
|
+
"@types/react-dom": "^18.3.0",
|
|
24
|
+
"@typescript-eslint/eslint-plugin": "^7.13.1",
|
|
25
|
+
"@typescript-eslint/parser": "^7.13.1",
|
|
26
|
+
"@vitejs/plugin-react": "^4.3.1",
|
|
27
|
+
"eslint": "^8.57.0",
|
|
28
|
+
"eslint-plugin-react-hooks": "^4.6.2",
|
|
29
|
+
"eslint-plugin-react-refresh": "^0.4.7",
|
|
30
|
+
"typescript": "^5.2.2",
|
|
31
|
+
"vite": "^5.3.1"
|
|
32
|
+
}
|
|
33
33
|
}
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
import './index.css'
|
|
1
|
+
import './index.css';
|
|
2
2
|
import { ConnectButton } from '@rainbow-me/rainbowkit';
|
|
3
3
|
import Homepage from './components/Homepage/Homepage';
|
|
4
4
|
|
|
5
5
|
function App() {
|
|
6
|
-
|
|
7
6
|
return (
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
<>
|
|
8
|
+
<div className="header">
|
|
9
|
+
<ConnectButton
|
|
10
|
+
showBalance={{
|
|
11
|
+
smallScreen: false,
|
|
12
|
+
largeScreen: true
|
|
13
|
+
}}
|
|
14
|
+
/>
|
|
15
|
+
</div>
|
|
16
|
+
<Homepage />
|
|
17
|
+
</>
|
|
19
18
|
);
|
|
20
19
|
}
|
|
21
20
|
|
|
@@ -1,269 +1,255 @@
|
|
|
1
|
-
import { BANK_PRECOMPILE_ABI, BANK_PRECOMPILE_ADDRESS, WASM_PRECOMPILE_ABI, WASM_PRECOMPILE_ADDRESS } from
|
|
2
|
-
import { useState } from
|
|
3
|
-
import { ReadContractParameters, formatEther, fromHex, parseEther, toHex } from
|
|
4
|
-
import { useAccount, usePublicClient, useWriteContract } from
|
|
1
|
+
import { BANK_PRECOMPILE_ABI, BANK_PRECOMPILE_ADDRESS, WASM_PRECOMPILE_ABI, WASM_PRECOMPILE_ADDRESS } from '@sei-js/evm';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { ReadContractParameters, formatEther, fromHex, parseEther, toHex } from 'viem';
|
|
4
|
+
import { useAccount, usePublicClient, useWriteContract } from 'wagmi';
|
|
5
5
|
|
|
6
|
-
import
|
|
6
|
+
import './Homepage.css';
|
|
7
7
|
|
|
8
8
|
function Examples() {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
const [balance, setBalance] = useState('');
|
|
10
|
+
const [supply, setSupply] = useState('');
|
|
11
|
+
const [count, setCount] = useState(0);
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const publicClient = usePublicClient();
|
|
14
|
+
const { address } = useAccount();
|
|
15
15
|
const { writeContractAsync } = useWriteContract();
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
const formatLargeSeiNumber = (num: string, decimals: number): string => {
|
|
18
18
|
if (num.length > 10) {
|
|
19
|
-
return (
|
|
19
|
+
return (
|
|
20
|
+
(Number(num) / 1000000 / 1000000000).toLocaleString(navigator.language, { minimumFractionDigits: decimals, maximumFractionDigits: decimals }) + ' B'
|
|
21
|
+
);
|
|
20
22
|
} else {
|
|
21
23
|
return (Number(num) / 1000000).toLocaleString(navigator.language);
|
|
22
24
|
}
|
|
23
25
|
};
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const renderAddressExample = () => {
|
|
36
|
-
return (
|
|
37
|
-
<div className="card">
|
|
38
|
-
<div className="card-header">
|
|
39
|
-
<p className="card__title">Wallet address</p>
|
|
40
|
-
<small className="card__description">
|
|
41
|
-
<a
|
|
42
|
-
href="https://viem.sh/docs/clients/public.html"
|
|
43
|
-
target="_blank">Viem Public Client</a> query example
|
|
44
|
-
</small>
|
|
45
|
-
</div>
|
|
46
|
-
<div className="card-body">
|
|
47
|
-
<div className="content-background space-between">
|
|
48
|
-
{
|
|
49
|
-
address ?
|
|
50
|
-
<div>
|
|
51
|
-
<p className="card-footer">
|
|
52
|
-
{address}
|
|
53
|
-
</p>
|
|
54
|
-
</div> :
|
|
55
|
-
<a> --- </a>
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
<button
|
|
59
|
-
className="small outline"
|
|
60
|
-
onClick={() =>
|
|
61
|
-
copyToClipboard(
|
|
62
|
-
address as string
|
|
63
|
-
)
|
|
64
|
-
}
|
|
65
|
-
>
|
|
66
|
-
Copy
|
|
67
|
-
</button>
|
|
68
|
-
</div>
|
|
69
|
-
</div>
|
|
70
|
-
<div className="card-footer">
|
|
71
|
-
</div>
|
|
72
|
-
</div>
|
|
73
|
-
)
|
|
74
|
-
}
|
|
27
|
+
const copyToClipboard = (text: string) => {
|
|
28
|
+
try {
|
|
29
|
+
navigator.clipboard.writeText(text);
|
|
30
|
+
} catch (err) {
|
|
31
|
+
console.error('Failed to copy text: ', err);
|
|
32
|
+
} finally {
|
|
33
|
+
alert('Copied to clipboard!');
|
|
34
|
+
}
|
|
35
|
+
};
|
|
75
36
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// Example of using precompiles to query native Sei modules.
|
|
110
|
-
const getBankSupply = async () => {
|
|
111
|
-
if (!publicClient) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
37
|
+
const renderAddressExample = () => {
|
|
38
|
+
return (
|
|
39
|
+
<div className="card">
|
|
40
|
+
<div className="card-header">
|
|
41
|
+
<p className="card__title">Wallet address</p>
|
|
42
|
+
<small className="card__description">
|
|
43
|
+
<a href="https://viem.sh/docs/clients/public.html" target="_blank">
|
|
44
|
+
Viem Public Client
|
|
45
|
+
</a>{' '}
|
|
46
|
+
query example
|
|
47
|
+
</small>
|
|
48
|
+
</div>
|
|
49
|
+
<div className="card-body">
|
|
50
|
+
<div className="content-background space-between">
|
|
51
|
+
{address ? (
|
|
52
|
+
<div>
|
|
53
|
+
<p className="card-footer">{address}</p>
|
|
54
|
+
</div>
|
|
55
|
+
) : (
|
|
56
|
+
<a> --- </a>
|
|
57
|
+
)}
|
|
58
|
+
|
|
59
|
+
<button className="small outline" onClick={() => copyToClipboard(address as string)}>
|
|
60
|
+
Copy
|
|
61
|
+
</button>
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
<div className="card-footer"></div>
|
|
65
|
+
</div>
|
|
66
|
+
);
|
|
67
|
+
};
|
|
114
68
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
const supply = formatLargeSeiNumber(response.toString(), 1)
|
|
124
|
-
setSupply(supply);
|
|
125
|
-
} catch (e) {
|
|
126
|
-
console.log(e);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
const renderBankSupplyExample = () => {
|
|
131
|
-
return (
|
|
132
|
-
<div className="card">
|
|
133
|
-
<div className="card-header">
|
|
134
|
-
<p className="card__title">Total Sei supply</p>
|
|
135
|
-
<small className="card__description">
|
|
136
|
-
<a
|
|
137
|
-
href="https://www.docs.sei.io/dev-interoperability/precompiles/bank"
|
|
138
|
-
target="_blank"> Bank precompile
|
|
139
|
-
</a> example for querying native Sei
|
|
140
|
-
modules
|
|
141
|
-
</small>
|
|
142
|
-
</div>
|
|
143
|
-
<div className="card-body">
|
|
144
|
-
<div className="content-background space-between">
|
|
145
|
-
<small>SEI</small>
|
|
146
|
-
<p>{supply}</p>
|
|
147
|
-
</div>
|
|
148
|
-
</div>
|
|
149
|
-
<div className="card-footer">
|
|
150
|
-
<button onClick={getBankSupply}>Fetch supply</button>
|
|
151
|
-
</div>
|
|
152
|
-
</div>
|
|
153
|
-
)
|
|
154
|
-
}
|
|
69
|
+
const getBalanceWagmi = async () => {
|
|
70
|
+
if (!address || !publicClient) {
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
const weiBalance = await publicClient.getBalance({ address });
|
|
74
|
+
const seiBalance = formatEther(weiBalance);
|
|
75
|
+
setBalance(seiBalance);
|
|
76
|
+
};
|
|
155
77
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
78
|
+
const renderBalanceExample = () => {
|
|
79
|
+
return (
|
|
80
|
+
<div className="card">
|
|
81
|
+
<div className="card-header">
|
|
82
|
+
<p className="card__title">Wallet balance</p>
|
|
83
|
+
<small className="card__description">
|
|
84
|
+
<a href="https://viem.sh/docs/clients/public.html" target="_blank">
|
|
85
|
+
Viem Public Client
|
|
86
|
+
</a>{' '}
|
|
87
|
+
query example
|
|
88
|
+
</small>
|
|
89
|
+
</div>
|
|
90
|
+
<div className="card-body">
|
|
91
|
+
<div className="content-background space-between">
|
|
92
|
+
<small>SEI</small>
|
|
93
|
+
<p>{balance ? balance : '---'} SEI</p>
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
<div className="card-footer">
|
|
97
|
+
<button onClick={getBalanceWagmi}>Fetch balance</button>
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
);
|
|
101
|
+
};
|
|
161
102
|
|
|
162
|
-
|
|
163
|
-
|
|
103
|
+
// Example of using precompiles to query native Sei modules.
|
|
104
|
+
const getBankSupply = async () => {
|
|
105
|
+
if (!publicClient) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
164
108
|
|
|
165
|
-
|
|
109
|
+
const params: ReadContractParameters = {
|
|
110
|
+
address: BANK_PRECOMPILE_ADDRESS,
|
|
111
|
+
abi: BANK_PRECOMPILE_ABI,
|
|
112
|
+
functionName: 'supply',
|
|
113
|
+
args: ['usei']
|
|
114
|
+
};
|
|
115
|
+
try {
|
|
116
|
+
const response = (await publicClient.readContract(params)) as BigInt;
|
|
117
|
+
const supply = formatLargeSeiNumber(response.toString(), 1);
|
|
118
|
+
setSupply(supply);
|
|
119
|
+
} catch (e) {
|
|
120
|
+
console.log(e);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
166
123
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
124
|
+
const renderBankSupplyExample = () => {
|
|
125
|
+
return (
|
|
126
|
+
<div className="card">
|
|
127
|
+
<div className="card-header">
|
|
128
|
+
<p className="card__title">Total Sei supply</p>
|
|
129
|
+
<small className="card__description">
|
|
130
|
+
<a href="https://www.docs.sei.io/dev-interoperability/precompiles/bank" target="_blank">
|
|
131
|
+
{' '}
|
|
132
|
+
Bank precompile
|
|
133
|
+
</a>{' '}
|
|
134
|
+
example for querying native Sei modules
|
|
135
|
+
</small>
|
|
136
|
+
</div>
|
|
137
|
+
<div className="card-body">
|
|
138
|
+
<div className="content-background space-between">
|
|
139
|
+
<small>SEI</small>
|
|
140
|
+
<p>{supply}</p>
|
|
141
|
+
</div>
|
|
142
|
+
</div>
|
|
143
|
+
<div className="card-footer">
|
|
144
|
+
<button onClick={getBankSupply}>Fetch supply</button>
|
|
145
|
+
</div>
|
|
146
|
+
</div>
|
|
147
|
+
);
|
|
148
|
+
};
|
|
181
149
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
const COUNTER_CONTRACT_ADDRESS =
|
|
189
|
-
"sei14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sh9m79m";
|
|
190
|
-
|
|
191
|
-
const execMsg = toHex(JSON.stringify({ increment: {} }));
|
|
192
|
-
const coins = toHex('[]')
|
|
193
|
-
const params = {
|
|
194
|
-
account: address,
|
|
195
|
-
address: WASM_PRECOMPILE_ADDRESS,
|
|
196
|
-
abi: WASM_PRECOMPILE_ABI,
|
|
197
|
-
functionName: 'execute',
|
|
198
|
-
args: [COUNTER_CONTRACT_ADDRESS, execMsg, coins],
|
|
199
|
-
value: parseEther('0')
|
|
200
|
-
}
|
|
150
|
+
// Fetch count of a CosmWasm Contract using WASM Precompile
|
|
151
|
+
const fetchCount = async () => {
|
|
152
|
+
if (!publicClient) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
201
155
|
|
|
202
|
-
|
|
203
|
-
|
|
156
|
+
const COUNTER_CONTRACT_ADDRESS = 'sei14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sh9m79m';
|
|
157
|
+
|
|
158
|
+
const queryMsg = toHex(JSON.stringify({ get_count: {} }));
|
|
159
|
+
|
|
160
|
+
const params: ReadContractParameters = {
|
|
161
|
+
address: WASM_PRECOMPILE_ADDRESS,
|
|
162
|
+
abi: WASM_PRECOMPILE_ABI,
|
|
163
|
+
functionName: 'query',
|
|
164
|
+
args: [COUNTER_CONTRACT_ADDRESS, queryMsg]
|
|
165
|
+
};
|
|
166
|
+
try {
|
|
167
|
+
const response = (await publicClient?.readContract(params)) as `0x${string}`;
|
|
168
|
+
const { count } = JSON.parse(fromHex(response, 'string'));
|
|
169
|
+
setCount(count);
|
|
170
|
+
} catch (e) {
|
|
171
|
+
console.log(e);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
204
174
|
|
|
205
|
-
|
|
206
|
-
|
|
175
|
+
// Fetch count of a CosmWasm Contract using WASM Precompile
|
|
176
|
+
const incrementCounter = async () => {
|
|
177
|
+
if (!address || !publicClient) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
207
180
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
181
|
+
const COUNTER_CONTRACT_ADDRESS = 'sei14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sh9m79m';
|
|
182
|
+
|
|
183
|
+
const execMsg = toHex(JSON.stringify({ increment: {} }));
|
|
184
|
+
const coins = toHex('[]');
|
|
185
|
+
const params = {
|
|
186
|
+
account: address,
|
|
187
|
+
address: WASM_PRECOMPILE_ADDRESS,
|
|
188
|
+
abi: WASM_PRECOMPILE_ABI,
|
|
189
|
+
functionName: 'execute',
|
|
190
|
+
args: [COUNTER_CONTRACT_ADDRESS, execMsg, coins],
|
|
191
|
+
value: parseEther('0')
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
try {
|
|
195
|
+
const estimatedGas = await publicClient.estimateContractGas(params);
|
|
196
|
+
|
|
197
|
+
// Call smart contract execute msg
|
|
198
|
+
await writeContractAsync({ ...params, gas: estimatedGas });
|
|
199
|
+
|
|
200
|
+
// Wait for 1 block to confirm transaction
|
|
201
|
+
setTimeout(() => {}, 400);
|
|
202
|
+
await fetchCount();
|
|
203
|
+
} catch (error) {
|
|
204
|
+
console.log(error);
|
|
205
|
+
}
|
|
206
|
+
};
|
|
211
207
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
208
|
+
const renderCounterContractExample = () => {
|
|
209
|
+
return (
|
|
210
|
+
<div className="card">
|
|
211
|
+
<div className="card-header">
|
|
212
|
+
<p className="card__title">Smart contract interaction</p>
|
|
213
|
+
<small>
|
|
214
|
+
<a href="https://www.docs.sei.io/dev-interoperability/precompiles/cosmwasm" target="_blank">
|
|
215
|
+
WASM Precompile
|
|
216
|
+
</a>{' '}
|
|
217
|
+
example of CosmWasm smart contract interaction
|
|
218
|
+
</small>
|
|
219
|
+
</div>
|
|
220
|
+
<div className="card-body">
|
|
221
|
+
<div className="content-background space-between">
|
|
222
|
+
<small>Count</small>
|
|
223
|
+
<p>{count}</p>
|
|
224
|
+
<button className="small outline" onClick={incrementCounter}>
|
|
225
|
+
Increase
|
|
226
|
+
</button>
|
|
227
|
+
</div>
|
|
228
|
+
</div>
|
|
229
|
+
<div className="card-footer">
|
|
230
|
+
<button onClick={fetchCount}>Fetch count</button>
|
|
231
|
+
</div>
|
|
232
|
+
</div>
|
|
233
|
+
);
|
|
234
|
+
};
|
|
216
235
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
<small>
|
|
223
|
-
<a
|
|
224
|
-
href="https://www.docs.sei.io/dev-interoperability/precompiles/cosmwasm"
|
|
225
|
-
target="_blank">
|
|
226
|
-
WASM Precompile
|
|
227
|
-
</a> example of CosmWasm smart
|
|
228
|
-
contract interaction
|
|
229
|
-
</small>
|
|
230
|
-
</div>
|
|
231
|
-
<div className="card-body">
|
|
232
|
-
<div className="content-background space-between">
|
|
233
|
-
<small>Count</small>
|
|
234
|
-
<p>{count}</p>
|
|
235
|
-
<button
|
|
236
|
-
className="small outline"
|
|
237
|
-
onClick={incrementCounter}
|
|
238
|
-
>
|
|
239
|
-
Increase
|
|
240
|
-
</button>
|
|
241
|
-
</div>
|
|
242
|
-
</div>
|
|
243
|
-
<div className="card-footer">
|
|
244
|
-
<button onClick={fetchCount}>Fetch count</button>
|
|
245
|
-
</div>
|
|
246
|
-
</div>
|
|
247
|
-
)
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
return (
|
|
251
|
-
<div className="container">
|
|
252
|
-
<div className="grid">
|
|
253
|
-
{/* First card */}
|
|
254
|
-
{renderAddressExample()}
|
|
236
|
+
return (
|
|
237
|
+
<div className="container">
|
|
238
|
+
<div className="grid">
|
|
239
|
+
{/* First card */}
|
|
240
|
+
{renderAddressExample()}
|
|
255
241
|
|
|
256
|
-
|
|
257
|
-
|
|
242
|
+
{/* Second card */}
|
|
243
|
+
{renderBalanceExample()}
|
|
258
244
|
|
|
259
|
-
|
|
260
|
-
|
|
245
|
+
{/* Third card */}
|
|
246
|
+
{renderBankSupplyExample()}
|
|
261
247
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
248
|
+
{/* Fourth card */}
|
|
249
|
+
{renderCounterContractExample()}
|
|
250
|
+
</div>
|
|
251
|
+
</div>
|
|
252
|
+
);
|
|
267
253
|
}
|
|
268
254
|
|
|
269
255
|
export default Examples;
|