@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/dist/index.d.cts
CHANGED
|
@@ -5,7 +5,6 @@ import { IndexerGrpcAccountPortfolioApi, ChainGrpcWasmApi } from '@injectivelabs
|
|
|
5
5
|
import { MsgBroadcaster } from '@injectivelabs/wallet-core';
|
|
6
6
|
import { WalletStrategy } from '@injectivelabs/wallet-strategy';
|
|
7
7
|
import { Connection } from '@solana/web3.js';
|
|
8
|
-
import { AnchorProvider } from '@coral-xyz/anchor';
|
|
9
8
|
import { WalletContextState } from '@solana/wallet-adapter-react';
|
|
10
9
|
import { StellarWalletsKit } from '@creit.tech/stellar-wallets-kit';
|
|
11
10
|
import * as StellarSdk from '@stellar/stellar-sdk';
|
|
@@ -202,7 +201,6 @@ declare class SolanaXService extends XService {
|
|
|
202
201
|
private static instance;
|
|
203
202
|
connection: Connection | undefined;
|
|
204
203
|
wallet: WalletContextState | undefined;
|
|
205
|
-
provider: AnchorProvider | undefined;
|
|
206
204
|
private constructor();
|
|
207
205
|
static getInstance(): SolanaXService;
|
|
208
206
|
getBalance(address: string | undefined, xToken: XToken): Promise<bigint>;
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,6 @@ import { IndexerGrpcAccountPortfolioApi, ChainGrpcWasmApi } from '@injectivelabs
|
|
|
5
5
|
import { MsgBroadcaster } from '@injectivelabs/wallet-core';
|
|
6
6
|
import { WalletStrategy } from '@injectivelabs/wallet-strategy';
|
|
7
7
|
import { Connection } from '@solana/web3.js';
|
|
8
|
-
import { AnchorProvider } from '@coral-xyz/anchor';
|
|
9
8
|
import { WalletContextState } from '@solana/wallet-adapter-react';
|
|
10
9
|
import { StellarWalletsKit } from '@creit.tech/stellar-wallets-kit';
|
|
11
10
|
import * as StellarSdk from '@stellar/stellar-sdk';
|
|
@@ -202,7 +201,6 @@ declare class SolanaXService extends XService {
|
|
|
202
201
|
private static instance;
|
|
203
202
|
connection: Connection | undefined;
|
|
204
203
|
wallet: WalletContextState | undefined;
|
|
205
|
-
provider: AnchorProvider | undefined;
|
|
206
204
|
private constructor();
|
|
207
205
|
static getInstance(): SolanaXService;
|
|
208
206
|
getBalance(address: string | undefined, xToken: XToken): Promise<bigint>;
|
package/dist/index.mjs
CHANGED
|
@@ -24,12 +24,11 @@ import { useWallet, ConnectionProvider, WalletProvider as WalletProvider$1, useC
|
|
|
24
24
|
import { create } from 'zustand';
|
|
25
25
|
import { devtools, persist, createJSONStorage } from 'zustand/middleware';
|
|
26
26
|
import { immer } from 'zustand/middleware/immer';
|
|
27
|
-
import { QueryClient, useMutation, useQuery,
|
|
27
|
+
import { QueryClient, useMutation, useQuery, QueryClientProvider } from '@tanstack/react-query';
|
|
28
28
|
import { mainnet as mainnet$1 } from 'viem/chains';
|
|
29
29
|
import { NearWalletProvider, SolanaWalletProvider, StellarWalletProvider, InjectiveWalletProvider, IconWalletProvider, SuiWalletProvider, EvmWalletProvider } from '@sodax/wallet-sdk-core';
|
|
30
30
|
import { getFullnodeUrl } from '@mysten/sui/client';
|
|
31
31
|
import { UnsafeBurnerWalletAdapter } from '@solana/wallet-adapter-wallets';
|
|
32
|
-
import { AnchorProvider } from '@coral-xyz/anchor';
|
|
33
32
|
|
|
34
33
|
// src/actions/getXChainType.ts
|
|
35
34
|
function getXChainType(xChainId) {
|
|
@@ -568,7 +567,7 @@ var SolanaXService = class _SolanaXService extends XService {
|
|
|
568
567
|
if (!address) return BigInt(0);
|
|
569
568
|
const connection = this.connection;
|
|
570
569
|
if (!connection) {
|
|
571
|
-
|
|
570
|
+
return BigInt(0);
|
|
572
571
|
}
|
|
573
572
|
try {
|
|
574
573
|
if (isNativeToken(xToken)) {
|
|
@@ -578,10 +577,9 @@ var SolanaXService = class _SolanaXService extends XService {
|
|
|
578
577
|
const tokenAccountPubkey = getAssociatedTokenAddressSync(new PublicKey(xToken.address), new PublicKey(address));
|
|
579
578
|
const tokenAccount = await getAccount(connection, tokenAccountPubkey);
|
|
580
579
|
return BigInt(tokenAccount.amount);
|
|
581
|
-
} catch
|
|
582
|
-
|
|
580
|
+
} catch {
|
|
581
|
+
return BigInt(0);
|
|
583
582
|
}
|
|
584
|
-
return BigInt(0);
|
|
585
583
|
}
|
|
586
584
|
};
|
|
587
585
|
|
|
@@ -1220,8 +1218,7 @@ function useXBalances({
|
|
|
1220
1218
|
const balances = await xService.getBalances(address, xTokens);
|
|
1221
1219
|
return balances;
|
|
1222
1220
|
},
|
|
1223
|
-
enabled: !!xService,
|
|
1224
|
-
placeholderData: keepPreviousData,
|
|
1221
|
+
enabled: !!xService && !!address && (xTokens?.length ?? 0) > 0,
|
|
1225
1222
|
refetchInterval: 5e3
|
|
1226
1223
|
});
|
|
1227
1224
|
}
|
|
@@ -1351,7 +1348,7 @@ function useWalletProvider(spokeChainId) {
|
|
|
1351
1348
|
}
|
|
1352
1349
|
return new SolanaWalletProvider({
|
|
1353
1350
|
wallet: solanaXService.wallet,
|
|
1354
|
-
|
|
1351
|
+
endpoint: solanaXService.connection.rpcEndpoint
|
|
1355
1352
|
});
|
|
1356
1353
|
}
|
|
1357
1354
|
case "NEAR": {
|
|
@@ -1420,11 +1417,6 @@ function useXSignMessage() {
|
|
|
1420
1417
|
}
|
|
1421
1418
|
});
|
|
1422
1419
|
}
|
|
1423
|
-
function useAnchorProvider() {
|
|
1424
|
-
const { connection } = useConnection();
|
|
1425
|
-
const wallet = useWallet();
|
|
1426
|
-
return new AnchorProvider(connection, wallet, { commitment: "confirmed" });
|
|
1427
|
-
}
|
|
1428
1420
|
var Hydrate = () => {
|
|
1429
1421
|
const suiClient = useSuiClient();
|
|
1430
1422
|
useEffect(() => {
|
|
@@ -1446,7 +1438,6 @@ var Hydrate = () => {
|
|
|
1446
1438
|
}, [suiAccount]);
|
|
1447
1439
|
const { connection: solanaConnection } = useConnection();
|
|
1448
1440
|
const solanaWallet = useWallet();
|
|
1449
|
-
const solanaProvider = useAnchorProvider();
|
|
1450
1441
|
useEffect(() => {
|
|
1451
1442
|
if (solanaConnection) {
|
|
1452
1443
|
SolanaXService.getInstance().connection = solanaConnection;
|
|
@@ -1457,11 +1448,6 @@ var Hydrate = () => {
|
|
|
1457
1448
|
SolanaXService.getInstance().wallet = solanaWallet;
|
|
1458
1449
|
}
|
|
1459
1450
|
}, [solanaWallet]);
|
|
1460
|
-
useEffect(() => {
|
|
1461
|
-
if (solanaProvider) {
|
|
1462
|
-
SolanaXService.getInstance().provider = solanaProvider;
|
|
1463
|
-
}
|
|
1464
|
-
}, [solanaProvider]);
|
|
1465
1451
|
const wagmiConfig = useConfig();
|
|
1466
1452
|
useEffect(() => {
|
|
1467
1453
|
if (wagmiConfig) {
|
|
@@ -1522,7 +1508,7 @@ var SodaxWalletProvider = ({ children, rpcConfig }) => {
|
|
|
1522
1508
|
return createWagmiConfig(rpcConfig);
|
|
1523
1509
|
}, [rpcConfig]);
|
|
1524
1510
|
const wallets = useMemo(() => [new UnsafeBurnerWalletAdapter()], []);
|
|
1525
|
-
return /* @__PURE__ */ React2.createElement(QueryClientProvider, { client: queryClient }, /* @__PURE__ */ React2.createElement(WagmiProvider, { reconnectOnMount: false, config: wagmiConfig }, /* @__PURE__ */ React2.createElement(SuiClientProvider, { networks: { mainnet: { url: getFullnodeUrl("mainnet") } }, defaultNetwork: "mainnet" }, /* @__PURE__ */ React2.createElement(WalletProvider, { autoConnect: true }, /* @__PURE__ */ React2.createElement(ConnectionProvider, { endpoint: rpcConfig["solana"] ?? "" }, /* @__PURE__ */ React2.createElement(WalletProvider$1, { wallets, autoConnect: true }, /* @__PURE__ */ React2.createElement(Hydrate, null), children))))));
|
|
1511
|
+
return /* @__PURE__ */ React2.createElement(QueryClientProvider, { client: queryClient }, /* @__PURE__ */ React2.createElement(WagmiProvider, { reconnectOnMount: false, config: wagmiConfig }, /* @__PURE__ */ React2.createElement(SuiClientProvider, { networks: { mainnet: { url: getFullnodeUrl("mainnet") } }, defaultNetwork: "mainnet" }, /* @__PURE__ */ React2.createElement(WalletProvider, { autoConnect: true }, /* @__PURE__ */ React2.createElement(ConnectionProvider, { endpoint: rpcConfig["solana"] ?? "https://api.mainnet-beta.solana.com" }, /* @__PURE__ */ React2.createElement(WalletProvider$1, { wallets, autoConnect: true }, /* @__PURE__ */ React2.createElement(Hydrate, null), children))))));
|
|
1526
1512
|
};
|
|
1527
1513
|
reconnectIcon();
|
|
1528
1514
|
reconnectStellar();
|