@sei-js/create-sei 0.0.3 → 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.
Files changed (180) hide show
  1. package/.yarn/install-state.gz +0 -0
  2. package/CHANGELOG.md +6 -0
  3. package/dist/main.js +1 -52
  4. package/dist/templates/{next-wagmi-template → next-template}/package.json +1 -1
  5. package/{templates/vite-wagmi-template → dist/templates/vite-template}/package.json +1 -1
  6. package/package.json +2 -3
  7. package/src/main.ts +1 -60
  8. package/templates/{next-wagmi-template → next-template}/package.json +1 -1
  9. package/{dist/templates/vite-wagmi-template → templates/vite-template}/package.json +1 -1
  10. package/tsconfig.json +1 -7
  11. package/dist/templates/next-cosmos-template/README.md +0 -60
  12. package/dist/templates/next-cosmos-template/next.config.mjs +0 -14
  13. package/dist/templates/next-cosmos-template/package.json +0 -31
  14. package/dist/templates/next-cosmos-template/public/next.svg +0 -1
  15. package/dist/templates/next-cosmos-template/public/vercel.svg +0 -1
  16. package/dist/templates/next-cosmos-template/src/app/components/Homepage/Examples.tsx +0 -168
  17. package/dist/templates/next-cosmos-template/src/app/components/Homepage/Homepage.css +0 -154
  18. package/dist/templates/next-cosmos-template/src/app/components/Homepage/Homepage.tsx +0 -83
  19. package/dist/templates/next-cosmos-template/src/app/components/WalletConnectButton/WalletConnectButton.tsx +0 -18
  20. package/dist/templates/next-cosmos-template/src/app/components/Web3Provider.tsx +0 -35
  21. package/dist/templates/next-cosmos-template/src/app/components/index.ts +0 -3
  22. package/dist/templates/next-cosmos-template/src/app/constants/chain.ts +0 -16
  23. package/dist/templates/next-cosmos-template/src/app/layout.tsx +0 -21
  24. package/dist/templates/next-cosmos-template/src/app/page.tsx +0 -17
  25. package/dist/templates/next-cosmos-template/yarn.lock +0 -9814
  26. package/dist/templates/vite-cosmos-template/README.md +0 -72
  27. package/dist/templates/vite-cosmos-template/index.html +0 -16
  28. package/dist/templates/vite-cosmos-template/package.json +0 -35
  29. package/dist/templates/vite-cosmos-template/src/App.tsx +0 -15
  30. package/dist/templates/vite-cosmos-template/src/components/Homepage/Examples.tsx +0 -168
  31. package/dist/templates/vite-cosmos-template/src/components/Homepage/Homepage.css +0 -154
  32. package/dist/templates/vite-cosmos-template/src/components/Homepage/Homepage.tsx +0 -77
  33. package/dist/templates/vite-cosmos-template/src/components/WalletConnectButton/WalletConnectButton.tsx +0 -18
  34. package/dist/templates/vite-cosmos-template/src/components/Web3Provider.tsx +0 -41
  35. package/dist/templates/vite-cosmos-template/src/components/index.ts +0 -4
  36. package/dist/templates/vite-cosmos-template/src/constants/chain.ts +0 -16
  37. package/dist/templates/vite-cosmos-template/src/index.css +0 -184
  38. package/dist/templates/vite-cosmos-template/vite.config.ts +0 -7
  39. package/dist/templates/vite-cosmos-template/yarn.lock +0 -9323
  40. package/templates/next-cosmos-template/.eslintrc.json +0 -3
  41. package/templates/next-cosmos-template/README.md +0 -60
  42. package/templates/next-cosmos-template/next-env.d.ts +0 -5
  43. package/templates/next-cosmos-template/next.config.mjs +0 -14
  44. package/templates/next-cosmos-template/package.json +0 -31
  45. package/templates/next-cosmos-template/public/next.svg +0 -1
  46. package/templates/next-cosmos-template/public/sei-logotype.svg +0 -15
  47. package/templates/next-cosmos-template/public/vercel.svg +0 -1
  48. package/templates/next-cosmos-template/src/app/components/Homepage/Examples.tsx +0 -168
  49. package/templates/next-cosmos-template/src/app/components/Homepage/Homepage.css +0 -154
  50. package/templates/next-cosmos-template/src/app/components/Homepage/Homepage.tsx +0 -83
  51. package/templates/next-cosmos-template/src/app/components/WalletConnectButton/WalletConnectButton.tsx +0 -18
  52. package/templates/next-cosmos-template/src/app/components/Web3Provider.tsx +0 -35
  53. package/templates/next-cosmos-template/src/app/components/index.ts +0 -3
  54. package/templates/next-cosmos-template/src/app/constants/chain.ts +0 -16
  55. package/templates/next-cosmos-template/src/app/constants/index.ts +0 -1
  56. package/templates/next-cosmos-template/src/app/favicon.ico +0 -0
  57. package/templates/next-cosmos-template/src/app/index.css +0 -184
  58. package/templates/next-cosmos-template/src/app/layout.tsx +0 -21
  59. package/templates/next-cosmos-template/src/app/page.tsx +0 -17
  60. package/templates/next-cosmos-template/tsconfig.json +0 -26
  61. package/templates/next-cosmos-template/yarn.lock +0 -9814
  62. package/templates/next-wagmi-template/.eslintrc.json +0 -3
  63. package/templates/next-wagmi-template/next-env.d.ts +0 -5
  64. package/templates/next-wagmi-template/public/sei-logotype.svg +0 -15
  65. package/templates/next-wagmi-template/src/app/constants/index.ts +0 -1
  66. package/templates/next-wagmi-template/src/app/favicon.ico +0 -0
  67. package/templates/next-wagmi-template/src/app/index.css +0 -184
  68. package/templates/next-wagmi-template/tsconfig.json +0 -26
  69. package/templates/vite-cosmos-template/.eslintrc.cjs +0 -11
  70. package/templates/vite-cosmos-template/README.md +0 -72
  71. package/templates/vite-cosmos-template/favicon.ico +0 -0
  72. package/templates/vite-cosmos-template/index.html +0 -16
  73. package/templates/vite-cosmos-template/package.json +0 -35
  74. package/templates/vite-cosmos-template/public/sei-logotype.svg +0 -15
  75. package/templates/vite-cosmos-template/src/App.tsx +0 -15
  76. package/templates/vite-cosmos-template/src/assets/react.svg +0 -1
  77. package/templates/vite-cosmos-template/src/components/Homepage/Examples.tsx +0 -168
  78. package/templates/vite-cosmos-template/src/components/Homepage/Homepage.css +0 -154
  79. package/templates/vite-cosmos-template/src/components/Homepage/Homepage.tsx +0 -77
  80. package/templates/vite-cosmos-template/src/components/WalletConnectButton/WalletConnectButton.tsx +0 -18
  81. package/templates/vite-cosmos-template/src/components/Web3Provider.tsx +0 -41
  82. package/templates/vite-cosmos-template/src/components/index.ts +0 -4
  83. package/templates/vite-cosmos-template/src/constants/chain.ts +0 -16
  84. package/templates/vite-cosmos-template/src/constants/index.ts +0 -1
  85. package/templates/vite-cosmos-template/src/index.css +0 -184
  86. package/templates/vite-cosmos-template/src/main.tsx +0 -12
  87. package/templates/vite-cosmos-template/src/vite-env.d.ts +0 -1
  88. package/templates/vite-cosmos-template/tsconfig.app.json +0 -25
  89. package/templates/vite-cosmos-template/tsconfig.json +0 -11
  90. package/templates/vite-cosmos-template/tsconfig.node.json +0 -14
  91. package/templates/vite-cosmos-template/vite.config.ts +0 -7
  92. package/templates/vite-cosmos-template/yarn.lock +0 -9323
  93. package/templates/vite-wagmi-template/.eslintrc.cjs +0 -11
  94. package/templates/vite-wagmi-template/favicon.ico +0 -0
  95. package/templates/vite-wagmi-template/public/sei-logotype.svg +0 -15
  96. package/templates/vite-wagmi-template/src/assets/react.svg +0 -1
  97. package/templates/vite-wagmi-template/src/constants/index.ts +0 -1
  98. package/templates/vite-wagmi-template/src/main.tsx +0 -12
  99. package/templates/vite-wagmi-template/src/vite-env.d.ts +0 -1
  100. package/templates/vite-wagmi-template/tsconfig.app.json +0 -25
  101. package/templates/vite-wagmi-template/tsconfig.json +0 -11
  102. package/templates/vite-wagmi-template/tsconfig.node.json +0 -14
  103. /package/dist/templates/{next-cosmos-template → next-template}/.eslintrc.json +0 -0
  104. /package/dist/templates/{next-wagmi-template → next-template}/README.md +0 -0
  105. /package/dist/templates/{next-cosmos-template → next-template}/next-env.d.ts +0 -0
  106. /package/dist/templates/{next-wagmi-template → next-template}/next.config.mjs +0 -0
  107. /package/dist/templates/{next-cosmos-template → next-template}/public/sei-logotype.svg +0 -0
  108. /package/dist/templates/{next-wagmi-template → next-template}/src/app/components/Homepage/Examples.tsx +0 -0
  109. /package/dist/templates/{next-wagmi-template → next-template}/src/app/components/Homepage/Homepage.css +0 -0
  110. /package/dist/templates/{next-wagmi-template → next-template}/src/app/components/Homepage/Homepage.tsx +0 -0
  111. /package/dist/templates/{next-wagmi-template → next-template}/src/app/components/Web3Provider.tsx +0 -0
  112. /package/dist/templates/{next-wagmi-template → next-template}/src/app/components/index.ts +0 -0
  113. /package/dist/templates/{next-wagmi-template → next-template}/src/app/constants/chain.ts +0 -0
  114. /package/dist/templates/{next-cosmos-template → next-template}/src/app/constants/index.ts +0 -0
  115. /package/dist/templates/{next-cosmos-template → next-template}/src/app/favicon.ico +0 -0
  116. /package/dist/templates/{next-cosmos-template → next-template}/src/app/index.css +0 -0
  117. /package/dist/templates/{next-wagmi-template → next-template}/src/app/layout.tsx +0 -0
  118. /package/dist/templates/{next-wagmi-template → next-template}/src/app/page.tsx +0 -0
  119. /package/dist/templates/{next-cosmos-template → next-template}/tsconfig.json +0 -0
  120. /package/dist/templates/{next-wagmi-template → next-template}/yarn.lock +0 -0
  121. /package/dist/templates/{vite-cosmos-template → vite-template}/.eslintrc.cjs +0 -0
  122. /package/dist/templates/{vite-wagmi-template → vite-template}/README.md +0 -0
  123. /package/dist/templates/{next-wagmi-template/src/app → vite-template}/favicon.ico +0 -0
  124. /package/dist/templates/{vite-wagmi-template → vite-template}/index.html +0 -0
  125. /package/dist/templates/{next-wagmi-template → vite-template}/public/sei-logotype.svg +0 -0
  126. /package/dist/templates/{vite-wagmi-template → vite-template}/src/App.tsx +0 -0
  127. /package/dist/templates/{vite-cosmos-template → vite-template}/src/assets/react.svg +0 -0
  128. /package/dist/templates/{vite-wagmi-template → vite-template}/src/components/Homepage/Examples.tsx +0 -0
  129. /package/dist/templates/{vite-wagmi-template → vite-template}/src/components/Homepage/Homepage.css +0 -0
  130. /package/dist/templates/{vite-wagmi-template → vite-template}/src/components/Homepage/Homepage.tsx +0 -0
  131. /package/dist/templates/{vite-wagmi-template → vite-template}/src/components/Web3Provider.tsx +0 -0
  132. /package/dist/templates/{vite-wagmi-template → vite-template}/src/constants/chain.ts +0 -0
  133. /package/dist/templates/{next-wagmi-template/src/app → vite-template/src}/constants/index.ts +0 -0
  134. /package/dist/templates/{vite-wagmi-template → vite-template}/src/index.css +0 -0
  135. /package/dist/templates/{vite-cosmos-template → vite-template}/src/main.tsx +0 -0
  136. /package/dist/templates/{vite-cosmos-template → vite-template}/src/vite-env.d.ts +0 -0
  137. /package/dist/templates/{vite-cosmos-template → vite-template}/tsconfig.app.json +0 -0
  138. /package/dist/templates/{vite-cosmos-template → vite-template}/tsconfig.json +0 -0
  139. /package/dist/templates/{vite-cosmos-template → vite-template}/tsconfig.node.json +0 -0
  140. /package/dist/templates/{vite-wagmi-template → vite-template}/vite.config.ts +0 -0
  141. /package/dist/templates/{vite-wagmi-template → vite-template}/yarn.lock +0 -0
  142. /package/{dist/templates/next-wagmi-template → templates/next-template}/.eslintrc.json +0 -0
  143. /package/templates/{next-wagmi-template → next-template}/README.md +0 -0
  144. /package/{dist/templates/next-wagmi-template → templates/next-template}/next-env.d.ts +0 -0
  145. /package/templates/{next-wagmi-template → next-template}/next.config.mjs +0 -0
  146. /package/{dist/templates/vite-cosmos-template → templates/next-template}/public/sei-logotype.svg +0 -0
  147. /package/templates/{next-wagmi-template → next-template}/src/app/components/Homepage/Examples.tsx +0 -0
  148. /package/templates/{next-wagmi-template → next-template}/src/app/components/Homepage/Homepage.css +0 -0
  149. /package/templates/{next-wagmi-template → next-template}/src/app/components/Homepage/Homepage.tsx +0 -0
  150. /package/templates/{next-wagmi-template → next-template}/src/app/components/Web3Provider.tsx +0 -0
  151. /package/templates/{next-wagmi-template → next-template}/src/app/components/index.ts +0 -0
  152. /package/templates/{next-wagmi-template → next-template}/src/app/constants/chain.ts +0 -0
  153. /package/{dist/templates/vite-cosmos-template/src → templates/next-template/src/app}/constants/index.ts +0 -0
  154. /package/{dist/templates/vite-cosmos-template → templates/next-template/src/app}/favicon.ico +0 -0
  155. /package/{dist/templates/next-wagmi-template → templates/next-template}/src/app/index.css +0 -0
  156. /package/templates/{next-wagmi-template → next-template}/src/app/layout.tsx +0 -0
  157. /package/templates/{next-wagmi-template → next-template}/src/app/page.tsx +0 -0
  158. /package/{dist/templates/next-wagmi-template → templates/next-template}/tsconfig.json +0 -0
  159. /package/templates/{next-wagmi-template → next-template}/yarn.lock +0 -0
  160. /package/{dist/templates/vite-wagmi-template → templates/vite-template}/.eslintrc.cjs +0 -0
  161. /package/templates/{vite-wagmi-template → vite-template}/README.md +0 -0
  162. /package/{dist/templates/vite-wagmi-template → templates/vite-template}/favicon.ico +0 -0
  163. /package/templates/{vite-wagmi-template → vite-template}/index.html +0 -0
  164. /package/{dist/templates/vite-wagmi-template → templates/vite-template}/public/sei-logotype.svg +0 -0
  165. /package/templates/{vite-wagmi-template → vite-template}/src/App.tsx +0 -0
  166. /package/{dist/templates/vite-wagmi-template → templates/vite-template}/src/assets/react.svg +0 -0
  167. /package/templates/{vite-wagmi-template → vite-template}/src/components/Homepage/Examples.tsx +0 -0
  168. /package/templates/{vite-wagmi-template → vite-template}/src/components/Homepage/Homepage.css +0 -0
  169. /package/templates/{vite-wagmi-template → vite-template}/src/components/Homepage/Homepage.tsx +0 -0
  170. /package/templates/{vite-wagmi-template → vite-template}/src/components/Web3Provider.tsx +0 -0
  171. /package/templates/{vite-wagmi-template → vite-template}/src/constants/chain.ts +0 -0
  172. /package/{dist/templates/vite-wagmi-template → templates/vite-template}/src/constants/index.ts +0 -0
  173. /package/templates/{vite-wagmi-template → vite-template}/src/index.css +0 -0
  174. /package/{dist/templates/vite-wagmi-template → templates/vite-template}/src/main.tsx +0 -0
  175. /package/{dist/templates/vite-wagmi-template → templates/vite-template}/src/vite-env.d.ts +0 -0
  176. /package/{dist/templates/vite-wagmi-template → templates/vite-template}/tsconfig.app.json +0 -0
  177. /package/{dist/templates/vite-wagmi-template → templates/vite-template}/tsconfig.json +0 -0
  178. /package/{dist/templates/vite-wagmi-template → templates/vite-template}/tsconfig.node.json +0 -0
  179. /package/templates/{vite-wagmi-template → vite-template}/vite.config.ts +0 -0
  180. /package/templates/{vite-wagmi-template → vite-template}/yarn.lock +0 -0
@@ -1,72 +0,0 @@
1
- # Vite-Cosmos Sei App Template
2
-
3
- This repo provides a basic framework for an application that interacts with Sei via Cosmos endpoints.
4
-
5
- It is based on the React Typescript Vite template.
6
-
7
- Currently, two official plugins are available:
8
-
9
- - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
10
- - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
11
-
12
- ## Getting Started
13
-
14
- Install dependencies by running
15
- ```bash
16
- npm install
17
- #or
18
- yarn
19
- ```
20
-
21
- Then, run the development server:
22
-
23
- ```bash
24
- npm run dev
25
- # or
26
- yarn dev
27
- ```
28
-
29
- Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
30
-
31
- You can start editing the page by modifying `src/App.tsx`. The page auto-updates as you edit the file.
32
-
33
- ## Repository Basics
34
- This repository includes basic features that allow you to connect to a wallet and use the wallet to interact with the chain.
35
-
36
- Additionally, basic examples and links to documentation are provided on the example homepage in `src/components/Homepage`.
37
-
38
- ### Web3 Provider
39
- This component is a Sei specific wrapper around Wagmi's Provider that should wrap the application. Wrapping the application in this provider will enable it to access hooks in Wagmi. These hooks are enable connection to a wallet and interaction with the chain.
40
-
41
- To change the list of supported wallets, as well as connection configurations you can modify the `src/components/Web3Provider.tsx` component.
42
-
43
- ### Wallet Connect Button
44
- This component utilizies Rainbowkit's pre built wallet connect button, which uses hooks in Wagmi.
45
-
46
- ### Changing the Chain
47
- This application connects to the arctic-1 devnet by default
48
-
49
- To change the chain the app connects to, edit the `selectedChain` variable in the `chain.ts` file in `src/constants`
50
-
51
- ## Expanding the ESLint configuration
52
-
53
- If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
54
-
55
- - Configure the top-level `parserOptions` property like this:
56
-
57
- ```js
58
- export default {
59
- // other rules...
60
- parserOptions: {
61
- ecmaVersion: 'latest',
62
- sourceType: 'module',
63
- project: ['./tsconfig.json', './tsconfig.node.json'],
64
- tsconfigRootDir: __dirname,
65
- },
66
- }
67
- ```
68
-
69
- - Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
70
- - Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
71
- - Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list
72
-
@@ -1,16 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <script type="module">
5
- import { Buffer } from "buffer";
6
- window.Buffer = Buffer;
7
- </script>
8
- <meta charset="UTF-8" />
9
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
10
- <title>Sei Vite App (Cosmos)</title>
11
- </head>
12
- <body>
13
- <div id="root"></div>
14
- <script type="module" src="/src/main.tsx"></script>
15
- </body>
16
- </html>
@@ -1,35 +0,0 @@
1
- {
2
- "name": "template-vite-cosmos-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
- "@cosmos-kit/react": "^2.17.0",
14
- "@esbuild-plugins/node-globals-polyfill": "^0.2.3",
15
- "@interchain-ui/react": "^1.23.22",
16
- "@sei-js/cosmjs": "^1.0.7",
17
- "buffer": "^6.0.3",
18
- "chain-registry": "^1.63.7",
19
- "cosmos-kit": "^2.18.0",
20
- "react": "^18.3.1",
21
- "react-dom": "^18.3.1"
22
- },
23
- "devDependencies": {
24
- "@types/react": "^18.3.3",
25
- "@types/react-dom": "^18.3.0",
26
- "@typescript-eslint/eslint-plugin": "^7.13.1",
27
- "@typescript-eslint/parser": "^7.13.1",
28
- "@vitejs/plugin-react": "^4.3.1",
29
- "eslint": "^8.57.0",
30
- "eslint-plugin-react-hooks": "^4.6.2",
31
- "eslint-plugin-react-refresh": "^0.4.7",
32
- "typescript": "^5.2.2",
33
- "vite": "^5.3.1"
34
- }
35
- }
@@ -1,15 +0,0 @@
1
- import './index.css';
2
- import { WalletConnectButton, Homepage } from './components';
3
-
4
- function App() {
5
- return (
6
- <>
7
- <div className="header">
8
- <WalletConnectButton />
9
- </div>
10
- <Homepage />
11
- </>
12
- );
13
- }
14
-
15
- export default App;
@@ -1,168 +0,0 @@
1
- import { getCosmWasmClient, getQueryClient, getSigningCosmWasmClient, getStargateClient } from '@sei-js/cosmjs';
2
- import { useState } from 'react';
3
- import { defaultUrls, selectedChain } from '../../constants';
4
- import { useChain } from '@cosmos-kit/react';
5
-
6
- import './Homepage.css';
7
- type ExampleProps = {
8
- chainId: string;
9
- };
10
-
11
- function Examples({ chainId }: ExampleProps) {
12
- const [balance, setBalance] = useState(0);
13
- const [pool, setPool] = useState({ bonded_tokens: 0, not_bonded_tokens: 0 });
14
- const [count, setCount] = useState(0);
15
-
16
- const { address, getOfflineSignerAmino } = useChain(selectedChain.chain_name);
17
-
18
- // Example of using the query client to query Sei modules
19
- const getStakingPool = async () => {
20
- const queryClient = await getQueryClient(defaultUrls[chainId].rest);
21
- const result = await queryClient.cosmos.staking.v1beta1.pool({});
22
- setPool(result.pool);
23
- };
24
-
25
- const renderStakingPoolExample = () => {
26
- return (
27
- <div className="card">
28
- <div className="card-header">
29
- <p className="card__title">Staking Pool</p>
30
- <small className="card__description">
31
- <a href="https://sei-protocol.github.io/sei-js/functions/cosmjs.getQueryClient.html" target="_blank">
32
- Sei QueryClient
33
- </a>{' '}
34
- query example
35
- </small>
36
- </div>
37
- <div className="card-body">
38
- <div className="content-background space-between">
39
- <small>Bonded Tokens</small>
40
- <p>{pool ? pool.bonded_tokens : '---'} SEI</p>
41
- </div>
42
- <div className="content-background space-between">
43
- <small>Unbonded Tokens</small>
44
- <p>{pool ? pool.not_bonded_tokens : '---'} SEI</p>
45
- </div>
46
- </div>
47
- <div className="card-footer">
48
- <button onClick={getStakingPool}>Fetch Staking Data</button>
49
- </div>
50
- </div>
51
- );
52
- };
53
-
54
- const getBalanceStargate = async () => {
55
- if (!address) {
56
- return undefined;
57
- }
58
- const queryClient = await getStargateClient(defaultUrls[chainId].rpc);
59
- const useiBalance = await queryClient.getBalance(address, 'usei');
60
- const seiBalance = Number(useiBalance.amount) / 1000000;
61
- setBalance(seiBalance);
62
- };
63
-
64
- const renderBalanceExample = () => {
65
- return (
66
- <div className="card">
67
- <div className="card-header">
68
- <p className="card__title">Wallet Balance</p>
69
- <small className="card__description">
70
- <a href="https://cosmos.github.io/cosmjs/latest/stargate/classes/StargateClient.html" target="_blank">
71
- Stargate Client
72
- </a>{' '}
73
- query example
74
- </small>
75
- </div>
76
- <div className="card-body">
77
- <div className="content-background space-between">
78
- <small>SEI</small>
79
- <p>{balance ? balance : '---'} SEI</p>
80
- </div>
81
- </div>
82
- <div className="card-footer">
83
- <button onClick={getBalanceStargate}>Fetch balance</button>
84
- </div>
85
- </div>
86
- );
87
- };
88
-
89
- const fetchCount = async () => {
90
- const cosmWasmClient = await getCosmWasmClient(defaultUrls[chainId].rpc);
91
- console.log(cosmWasmClient);
92
- const CONTRACT_ADDRESS = 'sei14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sh9m79m';
93
- const response = await cosmWasmClient.queryContractSmart(CONTRACT_ADDRESS, {
94
- get_count: {}
95
- });
96
- const result = response?.count;
97
- if (result) {
98
- setCount(result);
99
- }
100
- };
101
-
102
- const incrementCounter = async () => {
103
- if (!address) {
104
- return;
105
- }
106
- const offlineSigner = await getOfflineSignerAmino();
107
- const signingCosmWasmClient = await getSigningCosmWasmClient(defaultUrls[chainId].rpc, offlineSigner);
108
-
109
- try {
110
- const senderAddress = address;
111
- const CONTRACT_ADDRESS = 'sei14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sh9m79m';
112
-
113
- // Build message content
114
- const msg = { increment: {} };
115
-
116
- // Define gas price and limit
117
- const fee = {
118
- amount: [{ amount: '20000', denom: 'usei' }],
119
- gas: '200000'
120
- };
121
-
122
- // Call smart contract execute msg
123
- await signingCosmWasmClient?.execute(senderAddress, CONTRACT_ADDRESS, msg, fee);
124
-
125
- await fetchCount();
126
- } catch (error) {
127
- console.log(error);
128
- }
129
- };
130
-
131
- const renderCounterContractExample = () => {
132
- return (
133
- <div className="card">
134
- <div className="card-header">
135
- <p className="card__title">Smart contract interaction</p>
136
- <small>
137
- <a href="https://cosmos.github.io/cosmjs/latest/cosmwasm-stargate/classes/SigningCosmWasmClient.html" target="_blank">
138
- CosmWasm Clients
139
- </a>{' '}
140
- example of smart contract interaction
141
- </small>
142
- </div>
143
- <div className="card-body">
144
- <div className="content-background space-between">
145
- <small>Count</small>
146
- <p>{count}</p>
147
- <button className="small outline" onClick={incrementCounter}>
148
- Increase
149
- </button>
150
- </div>
151
- </div>
152
- <div className="card-footer">
153
- <button onClick={fetchCount}>Fetch count</button>
154
- </div>
155
- </div>
156
- );
157
- };
158
-
159
- return (
160
- <div className="grid">
161
- {renderBalanceExample()}
162
- {renderStakingPoolExample()}
163
- {renderCounterContractExample()}
164
- </div>
165
- );
166
- }
167
-
168
- export default Examples;
@@ -1,154 +0,0 @@
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(3, 1fr);
144
- }
145
- .grid.docs {
146
- grid-template-columns: repeat(3, 1fr);
147
- }
148
- }
149
-
150
- @media (min-width: 1024px) {
151
- .container {
152
- max-width: 80rem;
153
- }
154
- }
@@ -1,77 +0,0 @@
1
- import './Homepage.css';
2
- import Examples from './Examples';
3
- import { selectedChain } from '../../constants';
4
- import { WalletConnectButton } from '..';
5
-
6
- type HelpItem = {
7
- title: string;
8
- description: string;
9
- link: string;
10
- };
11
-
12
- const renderHelpItem = ({ title, description, link }: HelpItem) => (
13
- <div className="card secondary">
14
- <div className="card-header">
15
- <p className="card__title">
16
- <a href={link} target="_blank" rel="noopener noreferrer" className="external-link">
17
- {title} {externalIcon}
18
- </a>
19
- </p>
20
- <small className="card__description">{description}</small>
21
- </div>
22
- </div>
23
- );
24
-
25
- const helpItems: HelpItem[] = [
26
- {
27
- title: 'Sei Docs',
28
- description: 'Find in-depth information about Sei.',
29
- link: 'https://docs.sei.io/'
30
- },
31
- {
32
- title: 'CosmosKit',
33
- description: "Learn about CosmosKit and it's hooks for chain interaction.",
34
- link: 'https://hyperweb.io/stack/cosmos-kit'
35
- },
36
- {
37
- title: 'sei-js',
38
- description: 'Interact with Sei using @sei-js/cosmjs.',
39
- link: 'https://sei-protocol.github.io/sei-js/modules/cosmjs.html'
40
- }
41
- ];
42
-
43
- const externalIcon = (
44
- <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
45
- <path
46
- 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"
47
- stroke="#9F1239"
48
- strokeWidth="1.33333"
49
- strokeLinecap="round"
50
- strokeLinejoin="round"
51
- />
52
- <path d="M10 2H14V6" stroke="#9F1239" strokeWidth="1.33333" strokeLinecap="round" strokeLinejoin="round" />
53
- <path d="M6.66663 9.33333L14 2" stroke="#9F1239" strokeWidth="1.33333" strokeLinecap="round" strokeLinejoin="round" />
54
- </svg>
55
- );
56
-
57
- export function Homepage() {
58
- return (
59
- <div className="container">
60
- <img src="sei-logotype.svg" className="logo" alt="SEI logotype" />
61
- <div className="card intro">
62
- <div className="card-header">
63
- <p className="card__title">Wallet address</p>
64
- <small className="card__description">Connect wallet to see your address and balance</small>
65
- </div>
66
- <WalletConnectButton />
67
- </div>
68
- <Examples chainId={selectedChain.chain_id} />
69
- <div className="get-started">
70
- Get started by editing <code>src/App.tsx</code>
71
- </div>
72
- <div className="grid docs">{helpItems.map((item, _) => renderHelpItem(item))}</div>
73
- </div>
74
- );
75
- }
76
-
77
- export default Homepage;
@@ -1,18 +0,0 @@
1
- import { useChain } from '@cosmos-kit/react';
2
-
3
- import '@interchain-ui/react/styles';
4
-
5
- import { truncateSeiAddress } from '@sei-js/cosmjs';
6
- import { selectedChain } from '../../constants';
7
-
8
- export function WalletConnectButton() {
9
- const { isWalletConnected, address, connect, openView } = useChain(selectedChain.chain_name);
10
-
11
- const truncatedSeiAddr = address ? truncateSeiAddress(address) : '';
12
-
13
- return (
14
- <button className="primary" onClick={isWalletConnected ? openView : connect}>
15
- {isWalletConnected ? truncateSeiAddress(truncatedSeiAddr) : 'Connect'}
16
- </button>
17
- );
18
- }
@@ -1,41 +0,0 @@
1
- 'use client';
2
-
3
- import { ReactNode } from 'react';
4
- import { Buffer } from 'buffer';
5
-
6
- import { ChainProvider } from '@cosmos-kit/react';
7
- import { COSMOS_KIT_ASSET_LIST } from '@sei-js/cosmjs';
8
- import { wallets as finWallets } from '@cosmos-kit/fin';
9
- import { wallets as keplrWallets } from '@cosmos-kit/keplr';
10
- import { CompassExtensionWallet, compassExtensionInfo } from '@cosmos-kit/compass-extension';
11
- import { selectedChain } from '../constants';
12
-
13
- interface Web3ProviderProps {
14
- children: ReactNode;
15
- }
16
-
17
- const compassWallet = new CompassExtensionWallet({
18
- ...compassExtensionInfo,
19
- mobileDisabled: false
20
- });
21
-
22
- function Web3Provider({ children }: Web3ProviderProps) {
23
- // Buffer polyfill
24
- if (typeof window !== 'undefined') {
25
- window.Buffer = window.Buffer ?? Buffer;
26
- }
27
-
28
- // Define your supported wallets here
29
- const wallets = [compassWallet, ...finWallets, ...keplrWallets];
30
-
31
- // Define the list of sei chain you would like to connect to here.
32
- const chains = [selectedChain];
33
-
34
- return (
35
- <ChainProvider chains={chains} assetLists={[COSMOS_KIT_ASSET_LIST]} wallets={wallets}>
36
- {children}
37
- </ChainProvider>
38
- );
39
- }
40
-
41
- export default Web3Provider;
@@ -1,4 +0,0 @@
1
- export * from './Homepage/Homepage';
2
- export * from './WalletConnectButton/WalletConnectButton';
3
- export * from './Web3Provider';
4
- export * from './Homepage/Examples';
@@ -1,16 +0,0 @@
1
- import { ARCTIC_1_SEI_COSMOS_KIT_CHAIN, ATLANTIC_2_SEI_COSMOS_KIT_CHAIN, PACIFIC_1_SEI_COSMOS_KIT_CHAIN } from '@sei-js/cosmjs';
2
-
3
- export type Urls = {
4
- rpc: string;
5
- rest: string;
6
- };
7
-
8
- export const defaultUrls: { [chainName: string]: Urls } = {
9
- [PACIFIC_1_SEI_COSMOS_KIT_CHAIN.chain_id]: { rpc: 'https://rpc.sei-apis.com', rest: 'https://rest-arctic-1.sei-apis.com' },
10
- [ATLANTIC_2_SEI_COSMOS_KIT_CHAIN.chain_id]: { rpc: 'https://rpc-testnet.sei-apis.com', rest: 'https://rest-testnet.sei-apis.com' },
11
- [ARCTIC_1_SEI_COSMOS_KIT_CHAIN.chain_id]: { rpc: 'https://rpc-arctic-1.sei-apis.com', rest: 'https://rest-arctic-1.sei-apis.com' }
12
- };
13
-
14
- // Set your selected chain here
15
- // To point to mainnet, use PACIFIC_1_SEI_COSMOS_KIT_CHAIN
16
- export const selectedChain = ARCTIC_1_SEI_COSMOS_KIT_CHAIN;