@sodax/wallet-sdk-react 0.0.1-rc.2
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/LICENSE +21 -0
- package/README.md +233 -0
- package/dist/index.cjs +1589 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +15970 -0
- package/dist/index.d.ts +15970 -0
- package/dist/index.mjs +1513 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +74 -0
- package/src/SodaxWalletProvider.tsx +55 -0
- package/src/actions/getXChainType.ts +10 -0
- package/src/actions/getXService.ts +25 -0
- package/src/actions/index.ts +2 -0
- package/src/assets/wallets/hana.svg +6 -0
- package/src/assets/wallets/havah.svg +76 -0
- package/src/assets/wallets/keplr.svg +30 -0
- package/src/assets/wallets/metamask.svg +60 -0
- package/src/assets/wallets/phantom.svg +4 -0
- package/src/assets/wallets/sui.svg +20 -0
- package/src/constants/index.ts +1 -0
- package/src/constants/xChains.ts +164 -0
- package/src/core/XConnector.ts +54 -0
- package/src/core/XService.ts +91 -0
- package/src/core/index.ts +2 -0
- package/src/hooks/index.ts +11 -0
- package/src/hooks/useEthereumChainId.ts +36 -0
- package/src/hooks/useEvmSwitchChain.ts +92 -0
- package/src/hooks/useWalletProvider.ts +149 -0
- package/src/hooks/useWalletProviderOptions.ts +51 -0
- package/src/hooks/useXAccount.ts +51 -0
- package/src/hooks/useXAccounts.ts +56 -0
- package/src/hooks/useXBalances.ts +66 -0
- package/src/hooks/useXConnect.ts +119 -0
- package/src/hooks/useXConnection.ts +72 -0
- package/src/hooks/useXConnectors.ts +56 -0
- package/src/hooks/useXDisconnect.ts +65 -0
- package/src/hooks/useXService.ts +8 -0
- package/src/index.ts +18 -0
- package/src/types/index.ts +44 -0
- package/src/useXWagmiStore.tsx +164 -0
- package/src/utils/index.ts +33 -0
- package/src/xchains/evm/EvmXConnector.ts +27 -0
- package/src/xchains/evm/EvmXService.ts +189 -0
- package/src/xchains/evm/index.ts +2 -0
- package/src/xchains/icon/IconHanaXConnector.ts +39 -0
- package/src/xchains/icon/IconXService.ts +115 -0
- package/src/xchains/icon/iconex/index.tsx +46 -0
- package/src/xchains/icon/index.ts +2 -0
- package/src/xchains/injective/InjectiveKelprXConnector.ts +37 -0
- package/src/xchains/injective/InjectiveMetamaskXConnector.ts +40 -0
- package/src/xchains/injective/InjectiveXService.ts +71 -0
- package/src/xchains/injective/index.ts +4 -0
- package/src/xchains/injective/utils.ts +17 -0
- package/src/xchains/solana/SolanaXConnector.ts +26 -0
- package/src/xchains/solana/SolanaXService.ts +50 -0
- package/src/xchains/solana/hooks/useAnchorProvider.tsx +9 -0
- package/src/xchains/solana/index.ts +2 -0
- package/src/xchains/stellar/CustomSorobanServer.ts +93 -0
- package/src/xchains/stellar/StellarWalletsKitXConnector.ts +45 -0
- package/src/xchains/stellar/StellarXService.ts +61 -0
- package/src/xchains/stellar/index.tsx +2 -0
- package/src/xchains/stellar/useStellarXConnectors.ts +30 -0
- package/src/xchains/stellar/utils.ts +49 -0
- package/src/xchains/sui/SuiXConnector.ts +28 -0
- package/src/xchains/sui/SuiXService.ts +56 -0
- package/src/xchains/sui/index.ts +2 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) [2025] [Sodax]
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
# @sodax/wallet-sdk-react
|
|
2
|
+
|
|
3
|
+
A comprehensive React Wallet SDK tailored for the Sodax ecosystem that provides unified wallet connectivity across multiple blockchain networks.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
- Seamless wallet connectivity for all supported wallets in the Sodax network
|
|
7
|
+
- EVM Wallets: All browser extensions that support [EIP-6963](https://eips.ethereum.org/EIPS/eip-6963) (Hana Wallet, MetaMask, Phantom, etc.) ✅
|
|
8
|
+
- Sui Wallets: All browser extension that @mysten/dapp-kit supports (Hana, Sui Wallet, Suiet, etc.) ✅
|
|
9
|
+
- Solana Wallets: ✅
|
|
10
|
+
- Stellar Wallets: ✅
|
|
11
|
+
- Injective Wallets: ✅
|
|
12
|
+
- ICON Wallets: ✅ (Hana Wallet and other ICON-compatible extensions)
|
|
13
|
+
|
|
14
|
+
- Address and connection state management
|
|
15
|
+
- EVM (Arbitrum, Avalanche, Base, BSC, Optimism, Polygon) ✅
|
|
16
|
+
- Sui ✅
|
|
17
|
+
- Solana ✅
|
|
18
|
+
- Stellar ✅
|
|
19
|
+
- Injective ✅
|
|
20
|
+
- ICON ✅
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# Using npm
|
|
27
|
+
npm install @sodax/wallet-sdk-react
|
|
28
|
+
|
|
29
|
+
# Using yarn
|
|
30
|
+
yarn add @sodax/wallet-sdk-react
|
|
31
|
+
|
|
32
|
+
# Using pnpm
|
|
33
|
+
pnpm add @sodax/wallet-sdk-react
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Peer Dependencies
|
|
37
|
+
|
|
38
|
+
This package requires the following peer dependencies:
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"react": ">=19",
|
|
43
|
+
"@tanstack/react-query": "latest"
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Quick Start
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
import { SodaxWalletProvider, useXConnectors, useXConnect, useXAccount } from '@sodax/wallet-sdk-react';
|
|
51
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
52
|
+
import {
|
|
53
|
+
ARBITRUM_MAINNET_CHAIN_ID,
|
|
54
|
+
AVALANCHE_MAINNET_CHAIN_ID,
|
|
55
|
+
BASE_MAINNET_CHAIN_ID,
|
|
56
|
+
BSC_MAINNET_CHAIN_ID,
|
|
57
|
+
OPTIMISM_MAINNET_CHAIN_ID,
|
|
58
|
+
POLYGON_MAINNET_CHAIN_ID,
|
|
59
|
+
SONIC_MAINNET_CHAIN_ID,
|
|
60
|
+
} from '@sodax/types';
|
|
61
|
+
|
|
62
|
+
// Create a QueryClient instance
|
|
63
|
+
const queryClient = new QueryClient();
|
|
64
|
+
|
|
65
|
+
function App() {
|
|
66
|
+
return (
|
|
67
|
+
<QueryClientProvider client={queryClient}>
|
|
68
|
+
<SodaxWalletProvider
|
|
69
|
+
config={{
|
|
70
|
+
EVM: {
|
|
71
|
+
chains: [
|
|
72
|
+
ARBITRUM_MAINNET_CHAIN_ID,
|
|
73
|
+
AVALANCHE_MAINNET_CHAIN_ID,
|
|
74
|
+
BASE_MAINNET_CHAIN_ID,
|
|
75
|
+
BSC_MAINNET_CHAIN_ID,
|
|
76
|
+
OPTIMISM_MAINNET_CHAIN_ID,
|
|
77
|
+
POLYGON_MAINNET_CHAIN_ID,
|
|
78
|
+
SONIC_MAINNET_CHAIN_ID,
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
SUI: {
|
|
82
|
+
isMainnet: true,
|
|
83
|
+
},
|
|
84
|
+
SOLANA: {
|
|
85
|
+
endpoint: 'https://your-rpc-endpoint',
|
|
86
|
+
},
|
|
87
|
+
ICON: {},
|
|
88
|
+
INJECTIVE: {},
|
|
89
|
+
STELLAR: {},
|
|
90
|
+
}}
|
|
91
|
+
>
|
|
92
|
+
<WalletConnect />
|
|
93
|
+
</SodaxWalletProvider>
|
|
94
|
+
</QueryClientProvider>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function WalletConnect() {
|
|
99
|
+
// Get available connectors for EVM chain
|
|
100
|
+
const connectors = useXConnectors('EVM');
|
|
101
|
+
|
|
102
|
+
// Get connect mutation
|
|
103
|
+
const { mutateAsync: connect } = useXConnect();
|
|
104
|
+
|
|
105
|
+
// Get connected account info
|
|
106
|
+
const account = useXAccount('EVM');
|
|
107
|
+
|
|
108
|
+
return (
|
|
109
|
+
<div className="space-y-4">
|
|
110
|
+
{/* Display connected wallet address if connected */}
|
|
111
|
+
{account?.address && (
|
|
112
|
+
<div className="p-4 bg-gray-100 rounded-lg">
|
|
113
|
+
<p className="text-sm text-gray-600">Connected Wallet:</p>
|
|
114
|
+
<p className="font-mono">{account.address}</p>
|
|
115
|
+
</div>
|
|
116
|
+
)}
|
|
117
|
+
|
|
118
|
+
{/* Display available connectors */}
|
|
119
|
+
<div className="space-y-2">
|
|
120
|
+
{connectors.map((connector) => (
|
|
121
|
+
<button
|
|
122
|
+
key={connector.id}
|
|
123
|
+
onClick={() => connect(connector)}
|
|
124
|
+
className="flex items-center gap-2 p-2 border rounded-lg hover:bg-gray-50"
|
|
125
|
+
>
|
|
126
|
+
<img
|
|
127
|
+
src={connector.icon}
|
|
128
|
+
alt={connector.name}
|
|
129
|
+
width={24}
|
|
130
|
+
height={24}
|
|
131
|
+
className="rounded-md"
|
|
132
|
+
/>
|
|
133
|
+
<span>Connect {connector.name}</span>
|
|
134
|
+
</button>
|
|
135
|
+
))}
|
|
136
|
+
</div>
|
|
137
|
+
</div>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
This example demonstrates:
|
|
143
|
+
1. Setting up the required providers (`QueryClientProvider` and `SodaxWalletProvider`)
|
|
144
|
+
2. Using `useXConnectors` to get available wallet connectors
|
|
145
|
+
3. Using `useXConnect` to handle wallet connections
|
|
146
|
+
4. Using `useXAccount` to display the connected wallet address
|
|
147
|
+
5. A basic UI to display and connect to available wallets
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
## Requirements
|
|
151
|
+
|
|
152
|
+
- Node.js >= 18.0.0
|
|
153
|
+
- React >= 19
|
|
154
|
+
- TypeScript
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
## API Reference
|
|
158
|
+
|
|
159
|
+
### Components
|
|
160
|
+
|
|
161
|
+
- [`SodaxWalletProvider`](./src/SodaxWalletProvider.tsx) - Main provider component for wallet connectivity
|
|
162
|
+
|
|
163
|
+
### Hooks
|
|
164
|
+
|
|
165
|
+
#### Core Wallet Hooks
|
|
166
|
+
- [`useXConnectors`](./src/hooks/useXConnectors.ts) - Get available wallet connectors
|
|
167
|
+
- [`useXConnect`](./src/hooks/useXConnect.ts) - Connect to a wallet
|
|
168
|
+
- [`useXAccount`](./src/hooks/useXAccount.ts) - Get account information
|
|
169
|
+
- [`useXDisconnect`](./src/hooks/useXDisconnect.ts) - Disconnect from a wallet
|
|
170
|
+
|
|
171
|
+
#### Chain-Specific Hooks
|
|
172
|
+
- [`useEvmSwitchChain`](./src/hooks/evm/useEvmSwitchChain.ts) - Switch between EVM chains
|
|
173
|
+
|
|
174
|
+
#### Balance Hooks
|
|
175
|
+
- [`useXBalances`](./src/hooks/useXBalances.ts) - Fetch token balances
|
|
176
|
+
|
|
177
|
+
#### Service Hooks
|
|
178
|
+
- [`useXService`](./src/hooks/useXService.ts) - Access chain-specific service
|
|
179
|
+
|
|
180
|
+
### Types
|
|
181
|
+
|
|
182
|
+
#### Core Types
|
|
183
|
+
- [`XAccount`](./src/types/index.ts) - Wallet account type
|
|
184
|
+
- [`XConnection`](./src/types/index.ts) - Wallet connection type
|
|
185
|
+
- [`XConnector`](./src/types/index.ts) - Wallet connector type
|
|
186
|
+
- [`XToken`](./src/types/index.ts) - Cross-chain token type
|
|
187
|
+
|
|
188
|
+
### Classes
|
|
189
|
+
|
|
190
|
+
#### XConnector
|
|
191
|
+
- [`XConnector`](./src/core/XConnector.ts) - Base class for wallet connectors
|
|
192
|
+
- [`EvmXConnector`](./src/xchains/evm/EvmXConnector.ts) - EVM wallet connector
|
|
193
|
+
- [`SolanaXConnector`](./src/xchains/solana/SolanaXConnector.ts) - Solana wallet connector
|
|
194
|
+
- [`SuiXConnector`](./src/xchains/sui/SuiXConnector.ts) - Sui wallet connector
|
|
195
|
+
- [`StellarXConnector`](./src/xchains/stellar/StellarWalletsKitXConnector.ts) - Stellar wallet connector
|
|
196
|
+
- [`InjectiveMetamaskXConnector`](./src/xchains/injective/InjectiveMetamaskXConnector.ts) - Injective MetaMask connector
|
|
197
|
+
- [`InjectiveKelprXConnector`](./src/xchains/injective/InjectiveKelprXConnector.ts) - Injective Keplr connector
|
|
198
|
+
- [`IconXConnector`](./src/xchains/icon/IconHanaXConnector.ts) - ICON wallet connector
|
|
199
|
+
|
|
200
|
+
## Contributing
|
|
201
|
+
|
|
202
|
+
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
203
|
+
|
|
204
|
+
## Development
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
# Install dependencies
|
|
208
|
+
pnpm install
|
|
209
|
+
|
|
210
|
+
# Build the package
|
|
211
|
+
pnpm build
|
|
212
|
+
|
|
213
|
+
# Run in development mode
|
|
214
|
+
pnpm dev
|
|
215
|
+
|
|
216
|
+
# Run type checking
|
|
217
|
+
pnpm checkTs
|
|
218
|
+
|
|
219
|
+
# Format code
|
|
220
|
+
pnpm pretty
|
|
221
|
+
|
|
222
|
+
# Lint code
|
|
223
|
+
pnpm lint
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## License
|
|
227
|
+
|
|
228
|
+
[MIT](LICENSE)
|
|
229
|
+
|
|
230
|
+
## Support
|
|
231
|
+
|
|
232
|
+
- [GitHub Issues](https://github.com/icon-project/sodax-frontend/issues)
|
|
233
|
+
- [Discord Community](https://discord.gg/sodax-formerly-icon-880651922682560582)
|