@sodax/wallet-sdk-react 1.3.0-beta → 1.3.1-beta-rc1
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/dist/index.cjs +6 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -2
- package/dist/index.d.ts +0 -2
- package/dist/index.mjs +7 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -5
- package/src/Hydrate.ts +0 -7
- package/src/SodaxWalletProvider.tsx +1 -2
- package/src/hooks/useWalletProvider.ts +1 -1
- package/src/hooks/useXBalances.ts +2 -3
- package/src/xchains/solana/SolanaXService.ts +3 -7
- package/src/xchains/solana/hooks/useAnchorProvider.tsx +0 -9
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sodax/wallet-sdk-react",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.1-beta-rc1",
|
|
5
5
|
"description": "Wallet SDK of Sodax",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.cjs",
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
"url": "https://github.com/icon-project/sodax-frontend"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@coral-xyz/anchor": "0.30.1",
|
|
27
26
|
"@creit.tech/stellar-wallets-kit": "^1.7.5",
|
|
28
27
|
"@hot-labs/near-connect": "0.10.0",
|
|
29
28
|
"@injectivelabs/networks": "1.16.10",
|
|
@@ -36,7 +35,7 @@
|
|
|
36
35
|
"@injectivelabs/wallet-strategy": "1.16.10",
|
|
37
36
|
"@mysten/dapp-kit": "0.14.18",
|
|
38
37
|
"@mysten/sui": "1.21.2",
|
|
39
|
-
"near-api-js": "7.
|
|
38
|
+
"near-api-js": "7.2.0",
|
|
40
39
|
"@solana/spl-token": "0.4.9",
|
|
41
40
|
"@solana/wallet-adapter-react": "0.15.35",
|
|
42
41
|
"@solana/wallet-adapter-wallets": "0.19.30",
|
|
@@ -48,8 +47,8 @@
|
|
|
48
47
|
"wagmi": "2.16.9",
|
|
49
48
|
"zustand": "4.5.2",
|
|
50
49
|
"bs58": "6.0.0",
|
|
51
|
-
"@sodax/types": "1.3.
|
|
52
|
-
"@sodax/wallet-sdk-core": "1.3.
|
|
50
|
+
"@sodax/types": "1.3.1-beta-rc1",
|
|
51
|
+
"@sodax/wallet-sdk-core": "1.3.1-beta-rc1"
|
|
53
52
|
},
|
|
54
53
|
"devDependencies": {
|
|
55
54
|
"@types/react": "^19.0.8",
|
package/src/Hydrate.ts
CHANGED
|
@@ -5,7 +5,6 @@ import { useEffect } from 'react';
|
|
|
5
5
|
import { EvmXService } from './xchains/evm';
|
|
6
6
|
import { SolanaXService } from './xchains/solana/SolanaXService';
|
|
7
7
|
import { SuiXService } from './xchains/sui';
|
|
8
|
-
import { useAnchorProvider } from './xchains/solana/hooks/useAnchorProvider';
|
|
9
8
|
import { useConnection, useWallet } from '@solana/wallet-adapter-react';
|
|
10
9
|
import { useConfig } from 'wagmi';
|
|
11
10
|
|
|
@@ -33,7 +32,6 @@ export const Hydrate = () => {
|
|
|
33
32
|
// solana
|
|
34
33
|
const { connection: solanaConnection } = useConnection();
|
|
35
34
|
const solanaWallet = useWallet();
|
|
36
|
-
const solanaProvider = useAnchorProvider();
|
|
37
35
|
useEffect(() => {
|
|
38
36
|
if (solanaConnection) {
|
|
39
37
|
SolanaXService.getInstance().connection = solanaConnection;
|
|
@@ -44,11 +42,6 @@ export const Hydrate = () => {
|
|
|
44
42
|
SolanaXService.getInstance().wallet = solanaWallet;
|
|
45
43
|
}
|
|
46
44
|
}, [solanaWallet]);
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
if (solanaProvider) {
|
|
49
|
-
SolanaXService.getInstance().provider = solanaProvider;
|
|
50
|
-
}
|
|
51
|
-
}, [solanaProvider]);
|
|
52
45
|
|
|
53
46
|
// evm
|
|
54
47
|
const wagmiConfig = useConfig();
|
|
@@ -22,7 +22,6 @@ import type { RpcConfig } from '@sodax/types';
|
|
|
22
22
|
import { Hydrate } from './Hydrate';
|
|
23
23
|
import { createWagmiConfig } from './xchains/evm/EvmXService';
|
|
24
24
|
import { reconnectIcon } from './xchains/icon/actions';
|
|
25
|
-
// import { reconnectInjective } from './xchains/injective/actions';
|
|
26
25
|
import { reconnectStellar } from './xchains/stellar/actions';
|
|
27
26
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
28
27
|
|
|
@@ -40,7 +39,7 @@ export const SodaxWalletProvider = ({ children, rpcConfig }: { children: React.R
|
|
|
40
39
|
<WagmiProvider reconnectOnMount={false} config={wagmiConfig}>
|
|
41
40
|
<SuiClientProvider networks={{ mainnet: { url: getFullnodeUrl('mainnet') } }} defaultNetwork="mainnet">
|
|
42
41
|
<SuiWalletProvider autoConnect={true}>
|
|
43
|
-
<SolanaConnectionProvider endpoint={rpcConfig['solana'] ?? ''}>
|
|
42
|
+
<SolanaConnectionProvider endpoint={rpcConfig['solana'] ?? 'https://api.mainnet-beta.solana.com'}>
|
|
44
43
|
<SolanaWalletProvider wallets={wallets} autoConnect>
|
|
45
44
|
<Hydrate />
|
|
46
45
|
{children}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getXChainType } from '@/actions';
|
|
2
|
-
import { type UseQueryResult,
|
|
2
|
+
import { type UseQueryResult, useQuery } from '@tanstack/react-query';
|
|
3
3
|
import type { ChainId, XToken } from '@sodax/types';
|
|
4
4
|
import { useXService } from './useXService';
|
|
5
5
|
|
|
@@ -59,8 +59,7 @@ export function useXBalances({
|
|
|
59
59
|
|
|
60
60
|
return balances;
|
|
61
61
|
},
|
|
62
|
-
enabled: !!xService,
|
|
63
|
-
placeholderData: keepPreviousData,
|
|
62
|
+
enabled: !!xService && !!address && (xTokens?.length ?? 0) > 0,
|
|
64
63
|
refetchInterval: 5_000,
|
|
65
64
|
});
|
|
66
65
|
}
|
|
@@ -3,7 +3,6 @@ import { isNativeToken } from '@/utils';
|
|
|
3
3
|
import type { XToken } from '@sodax/types';
|
|
4
4
|
import { type Connection, PublicKey } from '@solana/web3.js';
|
|
5
5
|
import { getAccount, getAssociatedTokenAddressSync } from '@solana/spl-token';
|
|
6
|
-
import type { AnchorProvider } from '@coral-xyz/anchor';
|
|
7
6
|
import type { WalletContextState } from '@solana/wallet-adapter-react';
|
|
8
7
|
|
|
9
8
|
export class SolanaXService extends XService {
|
|
@@ -11,7 +10,6 @@ export class SolanaXService extends XService {
|
|
|
11
10
|
|
|
12
11
|
public connection: Connection | undefined;
|
|
13
12
|
public wallet: WalletContextState | undefined;
|
|
14
|
-
public provider: AnchorProvider | undefined;
|
|
15
13
|
|
|
16
14
|
private constructor() {
|
|
17
15
|
super('SOLANA');
|
|
@@ -29,7 +27,7 @@ export class SolanaXService extends XService {
|
|
|
29
27
|
|
|
30
28
|
const connection = this.connection;
|
|
31
29
|
if (!connection) {
|
|
32
|
-
|
|
30
|
+
return BigInt(0);
|
|
33
31
|
}
|
|
34
32
|
|
|
35
33
|
try {
|
|
@@ -41,10 +39,8 @@ export class SolanaXService extends XService {
|
|
|
41
39
|
const tokenAccountPubkey = getAssociatedTokenAddressSync(new PublicKey(xToken.address), new PublicKey(address));
|
|
42
40
|
const tokenAccount = await getAccount(connection, tokenAccountPubkey);
|
|
43
41
|
return BigInt(tokenAccount.amount);
|
|
44
|
-
} catch
|
|
45
|
-
|
|
42
|
+
} catch {
|
|
43
|
+
return BigInt(0);
|
|
46
44
|
}
|
|
47
|
-
|
|
48
|
-
return BigInt(0);
|
|
49
45
|
}
|
|
50
46
|
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { AnchorProvider } from '@coral-xyz/anchor';
|
|
2
|
-
import { type AnchorWallet, useConnection, useWallet } from '@solana/wallet-adapter-react';
|
|
3
|
-
|
|
4
|
-
export function useAnchorProvider() {
|
|
5
|
-
const { connection } = useConnection();
|
|
6
|
-
const wallet = useWallet();
|
|
7
|
-
|
|
8
|
-
return new AnchorProvider(connection, wallet as AnchorWallet, { commitment: 'confirmed' });
|
|
9
|
-
}
|