@sodax/wallet-sdk-react 0.0.1-rc.7 → 1.0.0-beta
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/README.md +20 -20
- package/dist/index.cjs +30 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +32 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/SodaxWalletProvider.tsx +1 -1
- package/src/core/XService.ts +1 -1
- package/src/hooks/useXBalances.ts +1 -1
- package/src/xchains/evm/EvmXService.ts +27 -25
- package/src/xchains/sui/SuiXService.ts +20 -10
package/dist/index.d.cts
CHANGED
|
@@ -106,7 +106,7 @@ declare abstract class XService {
|
|
|
106
106
|
* @param xTokens Array of tokens to get balances for
|
|
107
107
|
* @returns Promise resolving to object mapping token addresses to balances
|
|
108
108
|
*/
|
|
109
|
-
getBalances(address: string | undefined, xTokens: XToken[]): Promise<Record<string, bigint>>;
|
|
109
|
+
getBalances(address: string | undefined, xTokens: readonly XToken[]): Promise<Record<string, bigint>>;
|
|
110
110
|
/**
|
|
111
111
|
* Gets all available connectors for this chain
|
|
112
112
|
*/
|
|
@@ -258,7 +258,7 @@ declare class SuiXService extends XService {
|
|
|
258
258
|
suiAccount: any;
|
|
259
259
|
private constructor();
|
|
260
260
|
static getInstance(): SuiXService;
|
|
261
|
-
getBalances(address: string | undefined, xTokens: XToken[]): Promise<
|
|
261
|
+
getBalances(address: string | undefined, xTokens: readonly XToken[]): Promise<Record<string, bigint>>;
|
|
262
262
|
}
|
|
263
263
|
|
|
264
264
|
declare class SuiXConnector extends XConnector {
|
|
@@ -397,7 +397,7 @@ declare function useXService(xChainType: ChainType | undefined): XService | unde
|
|
|
397
397
|
*/
|
|
398
398
|
declare function useXBalances({ xChainId, xTokens, address, }: {
|
|
399
399
|
xChainId: ChainId;
|
|
400
|
-
xTokens: XToken[];
|
|
400
|
+
xTokens: readonly XToken[];
|
|
401
401
|
address: string | undefined;
|
|
402
402
|
}): UseQueryResult<{
|
|
403
403
|
[key: string]: bigint;
|
package/dist/index.d.ts
CHANGED
|
@@ -106,7 +106,7 @@ declare abstract class XService {
|
|
|
106
106
|
* @param xTokens Array of tokens to get balances for
|
|
107
107
|
* @returns Promise resolving to object mapping token addresses to balances
|
|
108
108
|
*/
|
|
109
|
-
getBalances(address: string | undefined, xTokens: XToken[]): Promise<Record<string, bigint>>;
|
|
109
|
+
getBalances(address: string | undefined, xTokens: readonly XToken[]): Promise<Record<string, bigint>>;
|
|
110
110
|
/**
|
|
111
111
|
* Gets all available connectors for this chain
|
|
112
112
|
*/
|
|
@@ -258,7 +258,7 @@ declare class SuiXService extends XService {
|
|
|
258
258
|
suiAccount: any;
|
|
259
259
|
private constructor();
|
|
260
260
|
static getInstance(): SuiXService;
|
|
261
|
-
getBalances(address: string | undefined, xTokens: XToken[]): Promise<
|
|
261
|
+
getBalances(address: string | undefined, xTokens: readonly XToken[]): Promise<Record<string, bigint>>;
|
|
262
262
|
}
|
|
263
263
|
|
|
264
264
|
declare class SuiXConnector extends XConnector {
|
|
@@ -397,7 +397,7 @@ declare function useXService(xChainType: ChainType | undefined): XService | unde
|
|
|
397
397
|
*/
|
|
398
398
|
declare function useXBalances({ xChainId, xTokens, address, }: {
|
|
399
399
|
xChainId: ChainId;
|
|
400
|
-
xTokens: XToken[];
|
|
400
|
+
xTokens: readonly XToken[];
|
|
401
401
|
address: string | undefined;
|
|
402
402
|
}): UseQueryResult<{
|
|
403
403
|
[key: string]: bigint;
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { baseChainInfo } from '@sodax/types';
|
|
1
|
+
import { baseChainInfo, LIGHTLINK_MAINNET_CHAIN_ID, HYPEREVM_MAINNET_CHAIN_ID, POLYGON_MAINNET_CHAIN_ID, OPTIMISM_MAINNET_CHAIN_ID, SONIC_MAINNET_CHAIN_ID, BSC_MAINNET_CHAIN_ID, BASE_MAINNET_CHAIN_ID, ARBITRUM_MAINNET_CHAIN_ID, AVALANCHE_MAINNET_CHAIN_ID, ETHEREUM_MAINNET_CHAIN_ID } from '@sodax/types';
|
|
2
2
|
import { erc20Abi, defineChain } from 'viem';
|
|
3
3
|
import { getPublicClient } from 'wagmi/actions';
|
|
4
4
|
import { useConnections, useAccount, useConnect, useConnectors, useDisconnect, useSwitchChain, usePublicClient, useWalletClient, useSignMessage, WagmiProvider, createConfig, http, useConfig } from 'wagmi';
|
|
5
|
-
import { mainnet, avalanche, arbitrum, base, bsc, sonic, optimism, polygon,
|
|
5
|
+
import { mainnet, avalanche, arbitrum, base, bsc, sonic, optimism, polygon, lightlinkPhoenix } from 'wagmi/chains';
|
|
6
6
|
import * as IconSdkRaw from 'icon-sdk-js';
|
|
7
7
|
import { getNetworkEndpoints, Network } from '@injectivelabs/networks';
|
|
8
8
|
import { IndexerGrpcAccountPortfolioApi, ChainGrpcWasmApi, getInjectiveAddress, getEthereumAddress } from '@injectivelabs/sdk-ts';
|
|
@@ -172,19 +172,19 @@ var hyper = /* @__PURE__ */ defineChain({
|
|
|
172
172
|
});
|
|
173
173
|
var createWagmiConfig = (config) => {
|
|
174
174
|
return createConfig({
|
|
175
|
-
chains: [mainnet, avalanche, arbitrum, base, bsc, sonic, optimism, polygon,
|
|
175
|
+
chains: [mainnet, avalanche, arbitrum, base, bsc, sonic, optimism, polygon, hyper, lightlinkPhoenix],
|
|
176
|
+
ssr: true,
|
|
176
177
|
transports: {
|
|
177
|
-
[mainnet.id]: http(config[
|
|
178
|
-
[avalanche.id]: http(config[
|
|
179
|
-
[arbitrum.id]: http(config[
|
|
180
|
-
[base.id]: http(config[
|
|
181
|
-
[bsc.id]: http(config[
|
|
182
|
-
[sonic.id]: http(config[
|
|
183
|
-
[optimism.id]: http(config[
|
|
184
|
-
[polygon.id]: http(config[
|
|
185
|
-
[
|
|
186
|
-
[
|
|
187
|
-
[lightlinkPhoenix.id]: http(config["lightlinkPhoenix"])
|
|
178
|
+
[mainnet.id]: http(config[ETHEREUM_MAINNET_CHAIN_ID]),
|
|
179
|
+
[avalanche.id]: http(config[AVALANCHE_MAINNET_CHAIN_ID]),
|
|
180
|
+
[arbitrum.id]: http(config[ARBITRUM_MAINNET_CHAIN_ID]),
|
|
181
|
+
[base.id]: http(config[BASE_MAINNET_CHAIN_ID]),
|
|
182
|
+
[bsc.id]: http(config[BSC_MAINNET_CHAIN_ID]),
|
|
183
|
+
[sonic.id]: http(config[SONIC_MAINNET_CHAIN_ID]),
|
|
184
|
+
[optimism.id]: http(config[OPTIMISM_MAINNET_CHAIN_ID]),
|
|
185
|
+
[polygon.id]: http(config[POLYGON_MAINNET_CHAIN_ID]),
|
|
186
|
+
[hyper.id]: http(config[HYPEREVM_MAINNET_CHAIN_ID]),
|
|
187
|
+
[lightlinkPhoenix.id]: http(config[LIGHTLINK_MAINNET_CHAIN_ID])
|
|
188
188
|
}
|
|
189
189
|
});
|
|
190
190
|
};
|
|
@@ -711,18 +711,27 @@ var SuiXService = class _SuiXService extends XService {
|
|
|
711
711
|
async getBalances(address, xTokens) {
|
|
712
712
|
if (!address) return {};
|
|
713
713
|
try {
|
|
714
|
-
const
|
|
715
|
-
owner: address
|
|
716
|
-
});
|
|
717
|
-
const tokenMap = xTokens.reduce((map, xToken) => {
|
|
714
|
+
const balancePromises = xTokens.map(async (xToken) => {
|
|
718
715
|
let coinType = isNativeToken(xToken) ? "0x2::sui::SUI" : xToken.address;
|
|
719
716
|
if (coinType === "0x03917a812fe4a6d6bc779c5ab53f8a80ba741f8af04121193fc44e0f662e2ceb::balanced_dollar::BALANCED_DOLLAR") {
|
|
720
717
|
coinType = "0x3917a812fe4a6d6bc779c5ab53f8a80ba741f8af04121193fc44e0f662e2ceb::balanced_dollar::BALANCED_DOLLAR";
|
|
721
718
|
}
|
|
722
|
-
const balance =
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
719
|
+
const balance = await this.suiClient.getBalance({
|
|
720
|
+
owner: address,
|
|
721
|
+
coinType
|
|
722
|
+
});
|
|
723
|
+
return {
|
|
724
|
+
address: xToken.address,
|
|
725
|
+
balance: balance ? BigInt(balance.totalBalance) : void 0
|
|
726
|
+
};
|
|
727
|
+
});
|
|
728
|
+
const results = await Promise.all(balancePromises);
|
|
729
|
+
const tokenMap = {};
|
|
730
|
+
results.forEach((result) => {
|
|
731
|
+
if (result.balance !== void 0) {
|
|
732
|
+
tokenMap[result.address] = result.balance;
|
|
733
|
+
}
|
|
734
|
+
});
|
|
726
735
|
return tokenMap;
|
|
727
736
|
} catch (e) {
|
|
728
737
|
console.log("error", e);
|
|
@@ -1363,7 +1372,7 @@ var SodaxWalletProvider = ({ children, rpcConfig }) => {
|
|
|
1363
1372
|
return createWagmiConfig(rpcConfig);
|
|
1364
1373
|
}, [rpcConfig]);
|
|
1365
1374
|
const wallets = useMemo(() => [new UnsafeBurnerWalletAdapter()], []);
|
|
1366
|
-
return /* @__PURE__ */ React2.createElement(WagmiProvider, { config: wagmiConfig
|
|
1375
|
+
return /* @__PURE__ */ React2.createElement(WagmiProvider, { 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)))));
|
|
1367
1376
|
};
|
|
1368
1377
|
reconnectIcon();
|
|
1369
1378
|
reconnectStellar();
|