@sei-js/create-sei 0.0.2 → 0.0.4
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 +10 -60
- package/dist/templates/next-template/.eslintrc.json +3 -0
- package/dist/templates/next-template/package.json +30 -0
- package/dist/templates/next-template/src/app/components/Homepage/Examples.tsx +257 -0
- package/dist/templates/next-template/src/app/components/Homepage/Homepage.css +154 -0
- package/dist/templates/{next-wagmi-template → next-template}/src/app/components/Homepage/Homepage.tsx +10 -36
- package/{templates/next-wagmi-template → dist/templates/next-template}/src/app/components/Web3Provider.tsx +29 -28
- package/dist/templates/next-template/src/app/components/index.ts +2 -0
- package/dist/templates/{next-wagmi-template → next-template}/src/app/constants/chain.ts +2 -2
- package/dist/templates/next-template/src/app/constants/index.ts +1 -0
- package/dist/templates/next-template/src/app/index.css +184 -0
- package/dist/templates/next-template/src/app/layout.tsx +21 -0
- package/dist/templates/next-template/src/app/page.tsx +21 -0
- package/dist/templates/next-template/tsconfig.json +26 -0
- package/dist/templates/vite-template/.eslintrc.cjs +11 -0
- package/dist/templates/vite-template/package.json +33 -0
- package/dist/templates/vite-template/src/App.tsx +21 -0
- package/dist/templates/vite-template/src/components/Homepage/Examples.tsx +255 -0
- package/dist/templates/vite-template/src/components/Homepage/Homepage.css +154 -0
- package/dist/templates/vite-template/src/components/Homepage/Homepage.tsx +81 -0
- package/{templates/vite-wagmi-template → dist/templates/vite-template}/src/components/Web3Provider.tsx +29 -28
- package/dist/templates/{vite-wagmi-template → vite-template}/src/constants/chain.ts +1 -1
- package/dist/templates/vite-template/src/constants/index.ts +1 -0
- package/dist/templates/vite-template/src/index.css +183 -0
- package/dist/templates/vite-template/src/main.tsx +12 -0
- package/dist/templates/vite-template/tsconfig.app.json +25 -0
- package/dist/templates/vite-template/tsconfig.json +11 -0
- package/dist/templates/vite-template/tsconfig.node.json +14 -0
- package/dist/templates/vite-template/vite.config.ts +10 -0
- package/package.json +1 -1
- package/src/main.ts +26 -87
- package/templates/next-template/.eslintrc.json +3 -0
- package/templates/next-template/package.json +30 -0
- package/templates/next-template/src/app/components/Homepage/Examples.tsx +257 -0
- package/templates/next-template/src/app/components/Homepage/Homepage.css +154 -0
- package/templates/{next-wagmi-template → next-template}/src/app/components/Homepage/Homepage.tsx +10 -36
- package/{dist/templates/next-wagmi-template → templates/next-template}/src/app/components/Web3Provider.tsx +29 -28
- package/templates/next-template/src/app/components/index.ts +2 -0
- package/templates/{next-wagmi-template → next-template}/src/app/constants/chain.ts +2 -2
- package/templates/next-template/src/app/constants/index.ts +1 -0
- package/templates/next-template/src/app/index.css +184 -0
- package/templates/next-template/src/app/layout.tsx +21 -0
- package/templates/next-template/src/app/page.tsx +21 -0
- package/templates/next-template/tsconfig.json +26 -0
- package/templates/vite-template/.eslintrc.cjs +11 -0
- package/templates/vite-template/package.json +33 -0
- package/templates/vite-template/src/App.tsx +21 -0
- package/templates/vite-template/src/components/Homepage/Examples.tsx +255 -0
- package/templates/vite-template/src/components/Homepage/Homepage.css +154 -0
- package/templates/vite-template/src/components/Homepage/Homepage.tsx +81 -0
- package/{dist/templates/vite-wagmi-template → templates/vite-template}/src/components/Web3Provider.tsx +29 -28
- package/templates/{vite-wagmi-template → vite-template}/src/constants/chain.ts +1 -1
- package/templates/vite-template/src/constants/index.ts +1 -0
- package/templates/vite-template/src/index.css +183 -0
- package/templates/vite-template/src/main.tsx +12 -0
- package/templates/vite-template/tsconfig.app.json +25 -0
- package/templates/vite-template/tsconfig.json +11 -0
- package/templates/vite-template/tsconfig.node.json +14 -0
- package/templates/vite-template/vite.config.ts +10 -0
- package/tsconfig.json +18 -28
- package/dist/templates/next-cosmos-template/.eslintrc.json +0 -3
- package/dist/templates/next-cosmos-template/README.md +0 -60
- package/dist/templates/next-cosmos-template/next.config.mjs +0 -14
- package/dist/templates/next-cosmos-template/package.json +0 -31
- package/dist/templates/next-cosmos-template/public/next.svg +0 -1
- package/dist/templates/next-cosmos-template/public/vercel.svg +0 -1
- package/dist/templates/next-cosmos-template/src/app/components/Homepage/Examples.tsx +0 -177
- package/dist/templates/next-cosmos-template/src/app/components/Homepage/Homepage.css +0 -156
- package/dist/templates/next-cosmos-template/src/app/components/Homepage/Homepage.tsx +0 -110
- package/dist/templates/next-cosmos-template/src/app/components/WalletConnectButton/WalletConnectButton.tsx +0 -26
- package/dist/templates/next-cosmos-template/src/app/components/Web3Provider.tsx +0 -39
- package/dist/templates/next-cosmos-template/src/app/components/index.ts +0 -3
- package/dist/templates/next-cosmos-template/src/app/constants/chain.ts +0 -16
- package/dist/templates/next-cosmos-template/src/app/constants/index.ts +0 -1
- package/dist/templates/next-cosmos-template/src/app/index.css +0 -171
- package/dist/templates/next-cosmos-template/src/app/layout.tsx +0 -21
- package/dist/templates/next-cosmos-template/src/app/page.tsx +0 -17
- package/dist/templates/next-cosmos-template/tsconfig.json +0 -26
- package/dist/templates/next-cosmos-template/yarn.lock +0 -9814
- package/dist/templates/next-wagmi-template/.eslintrc.json +0 -3
- package/dist/templates/next-wagmi-template/package.json +0 -30
- package/dist/templates/next-wagmi-template/src/app/components/Homepage/Examples.tsx +0 -271
- package/dist/templates/next-wagmi-template/src/app/components/Homepage/Homepage.css +0 -156
- package/dist/templates/next-wagmi-template/src/app/components/index.ts +0 -2
- package/dist/templates/next-wagmi-template/src/app/constants/index.ts +0 -1
- package/dist/templates/next-wagmi-template/src/app/index.css +0 -171
- package/dist/templates/next-wagmi-template/src/app/layout.tsx +0 -21
- package/dist/templates/next-wagmi-template/src/app/page.tsx +0 -21
- package/dist/templates/next-wagmi-template/tsconfig.json +0 -26
- package/dist/templates/vite-cosmos-template/.eslintrc.cjs +0 -18
- package/dist/templates/vite-cosmos-template/README.md +0 -72
- package/dist/templates/vite-cosmos-template/index.html +0 -16
- package/dist/templates/vite-cosmos-template/package.json +0 -35
- package/dist/templates/vite-cosmos-template/src/App.tsx +0 -16
- package/dist/templates/vite-cosmos-template/src/components/Homepage/Examples.tsx +0 -177
- package/dist/templates/vite-cosmos-template/src/components/Homepage/Homepage.css +0 -156
- package/dist/templates/vite-cosmos-template/src/components/Homepage/Homepage.tsx +0 -102
- package/dist/templates/vite-cosmos-template/src/components/WalletConnectButton/WalletConnectButton.tsx +0 -26
- package/dist/templates/vite-cosmos-template/src/components/Web3Provider.tsx +0 -45
- package/dist/templates/vite-cosmos-template/src/components/index.ts +0 -4
- package/dist/templates/vite-cosmos-template/src/constants/chain.ts +0 -16
- package/dist/templates/vite-cosmos-template/src/constants/index.ts +0 -1
- package/dist/templates/vite-cosmos-template/src/index.css +0 -171
- package/dist/templates/vite-cosmos-template/src/main.tsx +0 -12
- package/dist/templates/vite-cosmos-template/tsconfig.app.json +0 -27
- package/dist/templates/vite-cosmos-template/tsconfig.json +0 -11
- package/dist/templates/vite-cosmos-template/tsconfig.node.json +0 -14
- package/dist/templates/vite-cosmos-template/vite.config.ts +0 -7
- package/dist/templates/vite-cosmos-template/yarn.lock +0 -9323
- package/dist/templates/vite-wagmi-template/.eslintrc.cjs +0 -18
- package/dist/templates/vite-wagmi-template/package.json +0 -33
- package/dist/templates/vite-wagmi-template/src/App.tsx +0 -22
- package/dist/templates/vite-wagmi-template/src/components/Homepage/Examples.tsx +0 -269
- package/dist/templates/vite-wagmi-template/src/components/Homepage/Homepage.css +0 -156
- package/dist/templates/vite-wagmi-template/src/components/Homepage/Homepage.tsx +0 -106
- package/dist/templates/vite-wagmi-template/src/constants/index.ts +0 -1
- package/dist/templates/vite-wagmi-template/src/index.css +0 -170
- package/dist/templates/vite-wagmi-template/src/main.tsx +0 -12
- package/dist/templates/vite-wagmi-template/tsconfig.app.json +0 -27
- package/dist/templates/vite-wagmi-template/tsconfig.json +0 -11
- package/dist/templates/vite-wagmi-template/tsconfig.node.json +0 -14
- package/dist/templates/vite-wagmi-template/vite.config.ts +0 -10
- package/templates/next-cosmos-template/.eslintrc.json +0 -3
- package/templates/next-cosmos-template/README.md +0 -60
- package/templates/next-cosmos-template/next-env.d.ts +0 -5
- package/templates/next-cosmos-template/next.config.mjs +0 -14
- package/templates/next-cosmos-template/package.json +0 -31
- package/templates/next-cosmos-template/public/next.svg +0 -1
- package/templates/next-cosmos-template/public/sei-logotype.svg +0 -15
- package/templates/next-cosmos-template/public/vercel.svg +0 -1
- package/templates/next-cosmos-template/src/app/components/Homepage/Examples.tsx +0 -177
- package/templates/next-cosmos-template/src/app/components/Homepage/Homepage.css +0 -156
- package/templates/next-cosmos-template/src/app/components/Homepage/Homepage.tsx +0 -110
- package/templates/next-cosmos-template/src/app/components/WalletConnectButton/WalletConnectButton.tsx +0 -26
- package/templates/next-cosmos-template/src/app/components/Web3Provider.tsx +0 -39
- package/templates/next-cosmos-template/src/app/components/index.ts +0 -3
- package/templates/next-cosmos-template/src/app/constants/chain.ts +0 -16
- package/templates/next-cosmos-template/src/app/constants/index.ts +0 -1
- package/templates/next-cosmos-template/src/app/favicon.ico +0 -0
- package/templates/next-cosmos-template/src/app/index.css +0 -171
- package/templates/next-cosmos-template/src/app/layout.tsx +0 -21
- package/templates/next-cosmos-template/src/app/page.tsx +0 -17
- package/templates/next-cosmos-template/tsconfig.json +0 -26
- package/templates/next-cosmos-template/yarn.lock +0 -9814
- package/templates/next-wagmi-template/.eslintrc.json +0 -3
- package/templates/next-wagmi-template/next-env.d.ts +0 -5
- package/templates/next-wagmi-template/package.json +0 -30
- package/templates/next-wagmi-template/public/sei-logotype.svg +0 -15
- package/templates/next-wagmi-template/src/app/components/Homepage/Examples.tsx +0 -271
- package/templates/next-wagmi-template/src/app/components/Homepage/Homepage.css +0 -156
- package/templates/next-wagmi-template/src/app/components/index.ts +0 -2
- package/templates/next-wagmi-template/src/app/constants/index.ts +0 -1
- package/templates/next-wagmi-template/src/app/favicon.ico +0 -0
- package/templates/next-wagmi-template/src/app/index.css +0 -171
- package/templates/next-wagmi-template/src/app/layout.tsx +0 -21
- package/templates/next-wagmi-template/src/app/page.tsx +0 -21
- package/templates/next-wagmi-template/tsconfig.json +0 -26
- package/templates/vite-cosmos-template/.eslintrc.cjs +0 -18
- package/templates/vite-cosmos-template/README.md +0 -72
- package/templates/vite-cosmos-template/favicon.ico +0 -0
- package/templates/vite-cosmos-template/index.html +0 -16
- package/templates/vite-cosmos-template/package.json +0 -35
- package/templates/vite-cosmos-template/public/sei-logotype.svg +0 -15
- package/templates/vite-cosmos-template/src/App.tsx +0 -16
- package/templates/vite-cosmos-template/src/assets/react.svg +0 -1
- package/templates/vite-cosmos-template/src/components/Homepage/Examples.tsx +0 -177
- package/templates/vite-cosmos-template/src/components/Homepage/Homepage.css +0 -156
- package/templates/vite-cosmos-template/src/components/Homepage/Homepage.tsx +0 -102
- package/templates/vite-cosmos-template/src/components/WalletConnectButton/WalletConnectButton.tsx +0 -26
- package/templates/vite-cosmos-template/src/components/Web3Provider.tsx +0 -45
- package/templates/vite-cosmos-template/src/components/index.ts +0 -4
- package/templates/vite-cosmos-template/src/constants/chain.ts +0 -16
- package/templates/vite-cosmos-template/src/constants/index.ts +0 -1
- package/templates/vite-cosmos-template/src/index.css +0 -171
- package/templates/vite-cosmos-template/src/main.tsx +0 -12
- package/templates/vite-cosmos-template/src/vite-env.d.ts +0 -1
- package/templates/vite-cosmos-template/tsconfig.app.json +0 -27
- package/templates/vite-cosmos-template/tsconfig.json +0 -11
- package/templates/vite-cosmos-template/tsconfig.node.json +0 -14
- package/templates/vite-cosmos-template/vite.config.ts +0 -7
- package/templates/vite-cosmos-template/yarn.lock +0 -9323
- package/templates/vite-wagmi-template/.eslintrc.cjs +0 -18
- package/templates/vite-wagmi-template/favicon.ico +0 -0
- package/templates/vite-wagmi-template/package.json +0 -33
- package/templates/vite-wagmi-template/public/sei-logotype.svg +0 -15
- package/templates/vite-wagmi-template/src/App.tsx +0 -22
- package/templates/vite-wagmi-template/src/assets/react.svg +0 -1
- package/templates/vite-wagmi-template/src/components/Homepage/Examples.tsx +0 -269
- package/templates/vite-wagmi-template/src/components/Homepage/Homepage.css +0 -156
- package/templates/vite-wagmi-template/src/components/Homepage/Homepage.tsx +0 -106
- package/templates/vite-wagmi-template/src/constants/index.ts +0 -1
- package/templates/vite-wagmi-template/src/index.css +0 -170
- package/templates/vite-wagmi-template/src/main.tsx +0 -12
- package/templates/vite-wagmi-template/src/vite-env.d.ts +0 -1
- package/templates/vite-wagmi-template/tsconfig.app.json +0 -27
- package/templates/vite-wagmi-template/tsconfig.json +0 -11
- package/templates/vite-wagmi-template/tsconfig.node.json +0 -14
- package/templates/vite-wagmi-template/vite.config.ts +0 -10
- /package/dist/templates/{next-wagmi-template → next-template}/README.md +0 -0
- /package/dist/templates/{next-cosmos-template → next-template}/next-env.d.ts +0 -0
- /package/dist/templates/{next-wagmi-template → next-template}/next.config.mjs +0 -0
- /package/dist/templates/{next-cosmos-template → next-template}/public/sei-logotype.svg +0 -0
- /package/dist/templates/{next-cosmos-template → next-template}/src/app/favicon.ico +0 -0
- /package/dist/templates/{next-wagmi-template → next-template}/yarn.lock +0 -0
- /package/dist/templates/{vite-wagmi-template → vite-template}/README.md +0 -0
- /package/dist/templates/{next-wagmi-template/src/app → vite-template}/favicon.ico +0 -0
- /package/dist/templates/{vite-wagmi-template → vite-template}/index.html +0 -0
- /package/dist/templates/{next-wagmi-template → vite-template}/public/sei-logotype.svg +0 -0
- /package/dist/templates/{vite-cosmos-template → vite-template}/src/assets/react.svg +0 -0
- /package/dist/templates/{vite-cosmos-template → vite-template}/src/vite-env.d.ts +0 -0
- /package/dist/templates/{vite-wagmi-template → vite-template}/yarn.lock +0 -0
- /package/templates/{next-wagmi-template → next-template}/README.md +0 -0
- /package/{dist/templates/next-wagmi-template → templates/next-template}/next-env.d.ts +0 -0
- /package/templates/{next-wagmi-template → next-template}/next.config.mjs +0 -0
- /package/{dist/templates/vite-cosmos-template → templates/next-template}/public/sei-logotype.svg +0 -0
- /package/{dist/templates/vite-cosmos-template → templates/next-template/src/app}/favicon.ico +0 -0
- /package/templates/{next-wagmi-template → next-template}/yarn.lock +0 -0
- /package/templates/{vite-wagmi-template → vite-template}/README.md +0 -0
- /package/{dist/templates/vite-wagmi-template → templates/vite-template}/favicon.ico +0 -0
- /package/templates/{vite-wagmi-template → vite-template}/index.html +0 -0
- /package/{dist/templates/vite-wagmi-template → templates/vite-template}/public/sei-logotype.svg +0 -0
- /package/{dist/templates/vite-wagmi-template → templates/vite-template}/src/assets/react.svg +0 -0
- /package/{dist/templates/vite-wagmi-template → templates/vite-template}/src/vite-env.d.ts +0 -0
- /package/templates/{vite-wagmi-template → vite-template}/yarn.lock +0 -0
|
@@ -0,0 +1,255 @@
|
|
|
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
|
+
|
|
6
|
+
import './Homepage.css';
|
|
7
|
+
|
|
8
|
+
function Examples() {
|
|
9
|
+
const [balance, setBalance] = useState('');
|
|
10
|
+
const [supply, setSupply] = useState('');
|
|
11
|
+
const [count, setCount] = useState(0);
|
|
12
|
+
|
|
13
|
+
const publicClient = usePublicClient();
|
|
14
|
+
const { address } = useAccount();
|
|
15
|
+
const { writeContractAsync } = useWriteContract();
|
|
16
|
+
|
|
17
|
+
const formatLargeSeiNumber = (num: string, decimals: number): string => {
|
|
18
|
+
if (num.length > 10) {
|
|
19
|
+
return (
|
|
20
|
+
(Number(num) / 1000000 / 1000000000).toLocaleString(navigator.language, { minimumFractionDigits: decimals, maximumFractionDigits: decimals }) + ' B'
|
|
21
|
+
);
|
|
22
|
+
} else {
|
|
23
|
+
return (Number(num) / 1000000).toLocaleString(navigator.language);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
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
|
+
};
|
|
36
|
+
|
|
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
|
+
};
|
|
68
|
+
|
|
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
|
+
};
|
|
77
|
+
|
|
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
|
+
};
|
|
102
|
+
|
|
103
|
+
// Example of using precompiles to query native Sei modules.
|
|
104
|
+
const getBankSupply = async () => {
|
|
105
|
+
if (!publicClient) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
|
|
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
|
+
};
|
|
123
|
+
|
|
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
|
+
};
|
|
149
|
+
|
|
150
|
+
// Fetch count of a CosmWasm Contract using WASM Precompile
|
|
151
|
+
const fetchCount = async () => {
|
|
152
|
+
if (!publicClient) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
|
|
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
|
+
};
|
|
174
|
+
|
|
175
|
+
// Fetch count of a CosmWasm Contract using WASM Precompile
|
|
176
|
+
const incrementCounter = async () => {
|
|
177
|
+
if (!address || !publicClient) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
|
|
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
|
+
};
|
|
207
|
+
|
|
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
|
+
};
|
|
235
|
+
|
|
236
|
+
return (
|
|
237
|
+
<div className="container">
|
|
238
|
+
<div className="grid">
|
|
239
|
+
{/* First card */}
|
|
240
|
+
{renderAddressExample()}
|
|
241
|
+
|
|
242
|
+
{/* Second card */}
|
|
243
|
+
{renderBalanceExample()}
|
|
244
|
+
|
|
245
|
+
{/* Third card */}
|
|
246
|
+
{renderBankSupplyExample()}
|
|
247
|
+
|
|
248
|
+
{/* Fourth card */}
|
|
249
|
+
{renderCounterContractExample()}
|
|
250
|
+
</div>
|
|
251
|
+
</div>
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export default Examples;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
#root {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
min-height: 100vh;
|
|
5
|
+
}
|
|
6
|
+
.app {
|
|
7
|
+
width: 100%;
|
|
8
|
+
height: 100%;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.logo {
|
|
12
|
+
width: 20%;
|
|
13
|
+
align-self: center;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.container {
|
|
17
|
+
margin: 0 auto;
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-direction: column;
|
|
20
|
+
gap: 3rem;
|
|
21
|
+
width: 100%;
|
|
22
|
+
padding: 1rem;
|
|
23
|
+
height: -webkit-fill-available;
|
|
24
|
+
flex-grow: 1;
|
|
25
|
+
justify-content: center;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.grid {
|
|
29
|
+
width: 100%;
|
|
30
|
+
display: grid;
|
|
31
|
+
grid-template-columns: repeat(1, 1fr);
|
|
32
|
+
gap: 1rem;
|
|
33
|
+
}
|
|
34
|
+
.grid.docs {
|
|
35
|
+
grid-template-columns: repeat(1, 1fr);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.card {
|
|
39
|
+
width: 100%;
|
|
40
|
+
padding: 1.5em;
|
|
41
|
+
border-radius: 1rem;
|
|
42
|
+
background: var(--card);
|
|
43
|
+
color: var(--card-foreground);
|
|
44
|
+
box-shadow: 0px 4px 6px 0px rgba(0, 0, 0, 0.09);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.card.secondary {
|
|
48
|
+
background: transparent;
|
|
49
|
+
border: 1px solid var(--border);
|
|
50
|
+
box-shadow: none;
|
|
51
|
+
}
|
|
52
|
+
.card.intro {
|
|
53
|
+
display: flex;
|
|
54
|
+
flex-direction: column;
|
|
55
|
+
gap: 1rem;
|
|
56
|
+
justify-content: space-between;
|
|
57
|
+
align-items: flex-start;
|
|
58
|
+
}
|
|
59
|
+
.card-header {
|
|
60
|
+
display: flex;
|
|
61
|
+
flex-direction: column;
|
|
62
|
+
justify-content: space-between;
|
|
63
|
+
gap: 0.25rem;
|
|
64
|
+
}
|
|
65
|
+
.card-body {
|
|
66
|
+
display: flex;
|
|
67
|
+
flex-direction: column;
|
|
68
|
+
justify-content: space-between;
|
|
69
|
+
margin: 1.5rem 0;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.card-footer {
|
|
73
|
+
display: flex;
|
|
74
|
+
flex-direction: row;
|
|
75
|
+
gap: 0.5rem;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.card__title {
|
|
79
|
+
font-size: 1.15rem;
|
|
80
|
+
font-weight: 600;
|
|
81
|
+
}
|
|
82
|
+
.content-background {
|
|
83
|
+
overflow: hidden;
|
|
84
|
+
background: #fafaf9;
|
|
85
|
+
border-radius: 4rem;
|
|
86
|
+
padding: 0 1rem;
|
|
87
|
+
height: 3.5rem;
|
|
88
|
+
display: flex;
|
|
89
|
+
align-items: center;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.wallet-address {
|
|
93
|
+
text-wrap: anywhere;
|
|
94
|
+
line-break: anywhere;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.space-between {
|
|
98
|
+
justify-content: space-between;
|
|
99
|
+
gap: 1rem;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.hide-on-mobile {
|
|
103
|
+
display: none;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.hide-on-desktop {
|
|
107
|
+
display: block;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.external-link {
|
|
111
|
+
display: inline-flex;
|
|
112
|
+
gap: 0.25rem;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.get-started {
|
|
116
|
+
text-align: center;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.wallet-connect {
|
|
120
|
+
display: flex;
|
|
121
|
+
gap: 1rem;
|
|
122
|
+
align-items: center;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
@media (min-width: 768px) {
|
|
126
|
+
.card.intro {
|
|
127
|
+
grid-column: span 2;
|
|
128
|
+
flex-direction: row;
|
|
129
|
+
align-items: center;
|
|
130
|
+
}
|
|
131
|
+
.hide-on-mobile {
|
|
132
|
+
display: block;
|
|
133
|
+
}
|
|
134
|
+
.hide-on-desktop {
|
|
135
|
+
display: none;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.container {
|
|
139
|
+
max-width: 96rem;
|
|
140
|
+
padding: 2rem;
|
|
141
|
+
}
|
|
142
|
+
.grid {
|
|
143
|
+
grid-template-columns: repeat(2, 1fr);
|
|
144
|
+
}
|
|
145
|
+
.grid.docs {
|
|
146
|
+
grid-template-columns: repeat(2, 1fr);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
@media (min-width: 1024px) {
|
|
151
|
+
.container {
|
|
152
|
+
max-width: 80rem;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { ConnectButton } from '@rainbow-me/rainbowkit';
|
|
2
|
+
import Examples from './Examples';
|
|
3
|
+
import './Homepage.css';
|
|
4
|
+
|
|
5
|
+
type HelpItem = {
|
|
6
|
+
title: string;
|
|
7
|
+
description: string;
|
|
8
|
+
link: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const renderHelpItem = ({ title, description, link }: HelpItem) => (
|
|
12
|
+
<div className="card secondary">
|
|
13
|
+
<div className="card-header">
|
|
14
|
+
<p className="card__title">
|
|
15
|
+
<a href={link} target="_blank" rel="noopener noreferrer" className="external-link">
|
|
16
|
+
{title} {externalIcon}
|
|
17
|
+
</a>
|
|
18
|
+
</p>
|
|
19
|
+
<small className="card__description">{description}</small>
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
const helpItems: HelpItem[] = [
|
|
25
|
+
{
|
|
26
|
+
title: 'Sei Docs',
|
|
27
|
+
description: 'Find in-depth information about Sei.',
|
|
28
|
+
link: 'https://docs.sei.io/'
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
title: 'Wagmi',
|
|
32
|
+
description: "Learn about Wagmi and it's hooks for chain interaction.",
|
|
33
|
+
link: 'https://wagmi.sh/'
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
title: 'Viem',
|
|
37
|
+
description: 'Interact with Sei using Viem modules + Wagmi.',
|
|
38
|
+
link: 'https://viem.sh/'
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
title: 'EVM JSON-RPC API',
|
|
42
|
+
description: 'Learn about the EVM api available on Sei.',
|
|
43
|
+
link: 'https://ethereum.org/en/developers/docs/apis/json-rpc/'
|
|
44
|
+
}
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
const externalIcon = (
|
|
48
|
+
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
49
|
+
<path
|
|
50
|
+
d="M12 8.66667V12.6667C12 13.0203 11.8595 13.3594 11.6095 13.6095C11.3594 13.8595 11.0203 14 10.6667 14H3.33333C2.97971 14 2.64057 13.8595 2.39052 13.6095C2.14048 13.3594 2 13.0203 2 12.6667V5.33333C2 4.97971 2.14048 4.64057 2.39052 4.39052C2.64057 4.14048 2.97971 4 3.33333 4H7.33333"
|
|
51
|
+
stroke="#9F1239"
|
|
52
|
+
strokeWidth="1.33333"
|
|
53
|
+
strokeLinecap="round"
|
|
54
|
+
strokeLinejoin="round"
|
|
55
|
+
/>
|
|
56
|
+
<path d="M10 2H14V6" stroke="#9F1239" strokeWidth="1.33333" strokeLinecap="round" strokeLinejoin="round" />
|
|
57
|
+
<path d="M6.66663 9.33333L14 2" stroke="#9F1239" strokeWidth="1.33333" strokeLinecap="round" strokeLinejoin="round" />
|
|
58
|
+
</svg>
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
function Homepage() {
|
|
62
|
+
return (
|
|
63
|
+
<div className="container">
|
|
64
|
+
<img src="sei-logotype.svg" className="logo" alt="SEI logotype" />
|
|
65
|
+
<div className="card intro">
|
|
66
|
+
<div className="card-header">
|
|
67
|
+
<p className="card__title">Wallet address</p>
|
|
68
|
+
<small className="card__description">Connect wallet to see your address and balance</small>
|
|
69
|
+
</div>
|
|
70
|
+
<ConnectButton />
|
|
71
|
+
</div>
|
|
72
|
+
<Examples />
|
|
73
|
+
<div className="get-started">
|
|
74
|
+
Get started by editing <code>src/App.tsx</code>
|
|
75
|
+
</div>
|
|
76
|
+
<div className="grid docs">{helpItems.map((item, _) => renderHelpItem(item))}</div>
|
|
77
|
+
</div>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export default Homepage;
|
|
@@ -15,18 +15,18 @@ interface Web3ProviderProps {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
const connectors = connectorsForWallets(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
18
|
+
[
|
|
19
|
+
{
|
|
20
|
+
groupName: 'Recommended',
|
|
21
|
+
wallets: [metaMaskWallet]
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
{
|
|
25
|
+
appName: '<YOUR_APPNAME_HERE>',
|
|
26
|
+
projectId: '<YOUR_ID_HERE>'
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
|
|
30
30
|
function Web3Provider({ children }: Web3ProviderProps) {
|
|
31
31
|
// Buffer polyfill
|
|
32
32
|
if (typeof window !== 'undefined') {
|
|
@@ -48,22 +48,23 @@ function Web3Provider({ children }: Web3ProviderProps) {
|
|
|
48
48
|
return (
|
|
49
49
|
<WagmiProvider config={config}>
|
|
50
50
|
<QueryClientProvider client={queryClient}>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
51
|
+
<RainbowKitProvider
|
|
52
|
+
theme={lightTheme({
|
|
53
|
+
accentColor: '#7e1914',
|
|
54
|
+
accentColorForeground: 'white',
|
|
55
|
+
borderRadius: 'medium',
|
|
56
|
+
fontStack: 'system'
|
|
57
|
+
})}
|
|
58
|
+
appInfo={{
|
|
59
|
+
appName: '<APP-NAME-HERE>',
|
|
60
|
+
learnMoreUrl: 'https://www.docs.sei.io/user-guides/wallet-setup'
|
|
61
|
+
}}
|
|
62
|
+
modalSize="compact"
|
|
63
|
+
initialChain={chainConfig.id}
|
|
64
|
+
>
|
|
65
|
+
{children}
|
|
66
|
+
</RainbowKitProvider>
|
|
67
|
+
</QueryClientProvider>
|
|
67
68
|
</WagmiProvider>
|
|
68
69
|
);
|
|
69
70
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './chain';
|