@sodax/wallet-sdk-react 1.5.6-beta → 2.0.0-rc.1
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 +103 -145
- package/ai-exported/AGENTS.md +122 -0
- package/ai-exported/integration/README.md +102 -0
- package/ai-exported/integration/ai-rules.md +136 -0
- package/ai-exported/integration/architecture.md +181 -0
- package/ai-exported/integration/examples/01-minimal-evm.tsx +75 -0
- package/ai-exported/integration/examples/02-multi-chain-modal.tsx +169 -0
- package/ai-exported/integration/examples/03-nextjs-app-router.tsx +99 -0
- package/ai-exported/integration/examples/04-walletconnect-setup.tsx +89 -0
- package/ai-exported/integration/examples/README.md +29 -0
- package/ai-exported/integration/recipes/batch-operations.md +223 -0
- package/ai-exported/integration/recipes/bridge-to-sdk.md +164 -0
- package/ai-exported/integration/recipes/chain-detection.md +254 -0
- package/ai-exported/integration/recipes/connect-button.md +156 -0
- package/ai-exported/integration/recipes/multi-chain-modal.md +199 -0
- package/ai-exported/integration/recipes/setup.md +158 -0
- package/ai-exported/integration/recipes/sign-message.md +137 -0
- package/ai-exported/integration/recipes/sub-path-imports.md +95 -0
- package/ai-exported/integration/recipes/switch-chain.md +141 -0
- package/ai-exported/integration/recipes/walletconnect-setup.md +139 -0
- package/ai-exported/integration/reference/api-surface.md +175 -0
- package/ai-exported/integration/reference/chain-support.md +78 -0
- package/ai-exported/integration/reference/connectors.md +74 -0
- package/ai-exported/integration/reference/hooks.md +204 -0
- package/ai-exported/integration/reference/wallet-brands.md +106 -0
- package/ai-exported/migration/README.md +49 -0
- package/ai-exported/migration/ai-rules.md +144 -0
- package/ai-exported/migration/breaking-changes.md +305 -0
- package/ai-exported/migration/checklist.md +159 -0
- package/ai-exported/migration/recipes/connect-button.md +166 -0
- package/ai-exported/migration/recipes/multi-chain-modal.md +244 -0
- package/ai-exported/migration/recipes/ssr-setup.md +162 -0
- package/ai-exported/migration/recipes/walletconnect-migration.md +168 -0
- package/ai-exported/migration/reference/components.md +73 -0
- package/ai-exported/migration/reference/config.md +307 -0
- package/ai-exported/migration/reference/hooks.md +278 -0
- package/ai-exported/migration/reference/imports.md +157 -0
- package/dist/XConnector-B9YQTVJ4.d.ts +146 -0
- package/dist/chunk-2BOUGCJ7.mjs +150 -0
- package/dist/chunk-2BOUGCJ7.mjs.map +1 -0
- package/dist/chunk-66BAUK56.mjs +202 -0
- package/dist/chunk-66BAUK56.mjs.map +1 -0
- package/dist/chunk-7ULB6DW4.mjs +102 -0
- package/dist/chunk-7ULB6DW4.mjs.map +1 -0
- package/dist/chunk-BKJB527E.mjs +125 -0
- package/dist/chunk-BKJB527E.mjs.map +1 -0
- package/dist/chunk-BXJLBR4G.mjs +88 -0
- package/dist/chunk-BXJLBR4G.mjs.map +1 -0
- package/dist/chunk-E5IAZ7E6.mjs +186 -0
- package/dist/chunk-E5IAZ7E6.mjs.map +1 -0
- package/dist/chunk-MAQ47Q52.mjs +33 -0
- package/dist/chunk-MAQ47Q52.mjs.map +1 -0
- package/dist/chunk-MXZVF5HR.mjs +34 -0
- package/dist/chunk-MXZVF5HR.mjs.map +1 -0
- package/dist/chunk-N5A2TMF6.mjs +33 -0
- package/dist/chunk-N5A2TMF6.mjs.map +1 -0
- package/dist/chunk-NY7U7OJW.mjs +64 -0
- package/dist/chunk-NY7U7OJW.mjs.map +1 -0
- package/dist/chunk-PJLEJVAU.mjs +140 -0
- package/dist/chunk-PJLEJVAU.mjs.map +1 -0
- package/dist/chunk-PLCA4ZDJ.mjs +1585 -0
- package/dist/chunk-PLCA4ZDJ.mjs.map +1 -0
- package/dist/chunk-TZMKDXFA.mjs +3 -0
- package/dist/chunk-TZMKDXFA.mjs.map +1 -0
- package/dist/chunk-X2MHIWXO.mjs +100 -0
- package/dist/chunk-X2MHIWXO.mjs.map +1 -0
- package/dist/chunk-XZ7CHO2S.mjs +41 -0
- package/dist/chunk-XZ7CHO2S.mjs.map +1 -0
- package/dist/config-OlnzyEUE.d.ts +146 -0
- package/dist/index.cjs +2784 -1594
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +768 -1498
- package/dist/index.mjs +463 -2004
- package/dist/index.mjs.map +1 -1
- package/dist/xchains/bitcoin/index.cjs +1927 -0
- package/dist/xchains/bitcoin/index.cjs.map +1 -0
- package/dist/xchains/bitcoin/index.d.ts +125 -0
- package/dist/xchains/bitcoin/index.mjs +16 -0
- package/dist/xchains/bitcoin/index.mjs.map +1 -0
- package/dist/xchains/evm/index.cjs +316 -0
- package/dist/xchains/evm/index.cjs.map +1 -0
- package/dist/xchains/evm/index.d.ts +39 -0
- package/dist/xchains/evm/index.mjs +5 -0
- package/dist/xchains/evm/index.mjs.map +1 -0
- package/dist/xchains/icon/index.cjs +311 -0
- package/dist/xchains/icon/index.cjs.map +1 -0
- package/dist/xchains/icon/index.d.ts +37 -0
- package/dist/xchains/icon/index.mjs +7 -0
- package/dist/xchains/icon/index.mjs.map +1 -0
- package/dist/xchains/injective/index.cjs +223 -0
- package/dist/xchains/injective/index.cjs.map +1 -0
- package/dist/xchains/injective/index.d.ts +35 -0
- package/dist/xchains/injective/index.mjs +5 -0
- package/dist/xchains/injective/index.mjs.map +1 -0
- package/dist/xchains/near/index.cjs +190 -0
- package/dist/xchains/near/index.cjs.map +1 -0
- package/dist/xchains/near/index.d.ts +34 -0
- package/dist/xchains/near/index.mjs +6 -0
- package/dist/xchains/near/index.mjs.map +1 -0
- package/dist/xchains/solana/index.cjs +186 -0
- package/dist/xchains/solana/index.cjs.map +1 -0
- package/dist/xchains/solana/index.d.ts +26 -0
- package/dist/xchains/solana/index.mjs +7 -0
- package/dist/xchains/solana/index.mjs.map +1 -0
- package/dist/xchains/stacks/index.cjs +240 -0
- package/dist/xchains/stacks/index.cjs.map +1 -0
- package/dist/xchains/stacks/index.d.ts +36 -0
- package/dist/xchains/stacks/index.mjs +5 -0
- package/dist/xchains/stacks/index.mjs.map +1 -0
- package/dist/xchains/stellar/index.cjs +322 -0
- package/dist/xchains/stellar/index.cjs.map +1 -0
- package/dist/xchains/stellar/index.d.ts +44 -0
- package/dist/xchains/stellar/index.mjs +6 -0
- package/dist/xchains/stellar/index.mjs.map +1 -0
- package/dist/xchains/sui/index.cjs +248 -0
- package/dist/xchains/sui/index.cjs.map +1 -0
- package/dist/xchains/sui/index.d.ts +37 -0
- package/dist/xchains/sui/index.mjs +7 -0
- package/dist/xchains/sui/index.mjs.map +1 -0
- package/docs/ADDING_A_NEW_CHAIN.md +440 -0
- package/docs/ARCHITECTURE.md +291 -0
- package/docs/BATCH_OPERATIONS.md +267 -0
- package/docs/CHAIN_DETECTION.md +216 -0
- package/docs/CONFIGURE_PROVIDER.md +360 -0
- package/docs/CONNECTORS.md +247 -0
- package/docs/CONNECT_FLOW.md +276 -0
- package/docs/EVM_SWITCH_CHAIN.md +161 -0
- package/docs/SIGN_MESSAGE.md +213 -0
- package/docs/SUB_PATH_EXPORTS.md +246 -0
- package/docs/WALLETCONNECT.md +154 -0
- package/docs/WALLET_MODAL.md +331 -0
- package/docs/WALLET_PROVIDER_BRIDGE.md +226 -0
- package/package.json +34 -9
- package/skills/SKILLS.md +84 -0
- package/skills/bridge-to-sdk.md +148 -0
- package/skills/connect-button.md +116 -0
- package/skills/evm-only-walletconnect.md +111 -0
- package/skills/multi-chain-modal.md +178 -0
- package/skills/setup.md +107 -0
- package/dist/index.d.cts +0 -1579
- package/src/Hydrate.ts +0 -65
- package/src/SodaxWalletProvider.tsx +0 -97
- package/src/actions/getXChainType.ts +0 -8
- package/src/actions/getXService.ts +0 -33
- package/src/actions/index.ts +0 -2
- package/src/assets/wallets/hana.svg +0 -6
- package/src/assets/wallets/havah.svg +0 -76
- package/src/assets/wallets/keplr.svg +0 -30
- package/src/assets/wallets/metamask.svg +0 -60
- package/src/assets/wallets/phantom.svg +0 -4
- package/src/assets/wallets/sui.svg +0 -20
- package/src/core/XConnector.ts +0 -54
- package/src/core/XService.ts +0 -85
- package/src/core/index.ts +0 -2
- package/src/hooks/index.ts +0 -11
- package/src/hooks/useEthereumChainId.ts +0 -44
- package/src/hooks/useEvmSwitchChain.ts +0 -91
- package/src/hooks/useWalletProvider.ts +0 -206
- package/src/hooks/useXAccount.ts +0 -51
- package/src/hooks/useXAccounts.ts +0 -56
- package/src/hooks/useXBalances.ts +0 -65
- package/src/hooks/useXConnect.ts +0 -118
- package/src/hooks/useXConnection.ts +0 -72
- package/src/hooks/useXConnectors.ts +0 -72
- package/src/hooks/useXDisconnect.ts +0 -73
- package/src/hooks/useXService.ts +0 -8
- package/src/hooks/useXSignMessage.ts +0 -82
- package/src/index.ts +0 -19
- package/src/types/index.ts +0 -22
- package/src/useXWagmiStore.ts +0 -116
- package/src/utils/index.ts +0 -21
- package/src/xchains/bitcoin/BitcoinXConnector.ts +0 -34
- package/src/xchains/bitcoin/BitcoinXService.ts +0 -40
- package/src/xchains/bitcoin/OKXXConnector.ts +0 -117
- package/src/xchains/bitcoin/UnisatXConnector.ts +0 -117
- package/src/xchains/bitcoin/XverseXConnector.ts +0 -232
- package/src/xchains/bitcoin/index.ts +0 -7
- package/src/xchains/bitcoin/useBitcoinXConnectors.ts +0 -14
- package/src/xchains/evm/EvmXConnector.ts +0 -27
- package/src/xchains/evm/EvmXService.ts +0 -211
- package/src/xchains/evm/index.ts +0 -3
- package/src/xchains/icon/IconHanaXConnector.ts +0 -39
- package/src/xchains/icon/IconXService.ts +0 -117
- package/src/xchains/icon/actions.ts +0 -28
- package/src/xchains/icon/iconex/index.tsx +0 -46
- package/src/xchains/icon/index.ts +0 -2
- package/src/xchains/injective/InjectiveXConnector.ts +0 -60
- package/src/xchains/injective/InjectiveXService.ts +0 -62
- package/src/xchains/injective/actions.ts +0 -32
- package/src/xchains/injective/index.ts +0 -2
- package/src/xchains/near/NearXConnector.ts +0 -42
- package/src/xchains/near/NearXService.ts +0 -46
- package/src/xchains/near/useNearXConnectors.ts +0 -23
- package/src/xchains/solana/SolanaXConnector.ts +0 -26
- package/src/xchains/solana/SolanaXService.ts +0 -46
- package/src/xchains/solana/index.ts +0 -2
- package/src/xchains/stacks/StacksXConnector.ts +0 -63
- package/src/xchains/stacks/StacksXService.ts +0 -59
- package/src/xchains/stacks/constants.ts +0 -42
- package/src/xchains/stacks/index.ts +0 -4
- package/src/xchains/stacks/useStacksXConnectors.ts +0 -7
- package/src/xchains/stellar/CustomSorobanServer.ts +0 -93
- package/src/xchains/stellar/StellarWalletsKitXConnector.ts +0 -53
- package/src/xchains/stellar/StellarXService.ts +0 -93
- package/src/xchains/stellar/actions.ts +0 -24
- package/src/xchains/stellar/index.tsx +0 -2
- package/src/xchains/stellar/useStellarXConnectors.ts +0 -21
- package/src/xchains/stellar/utils.ts +0 -49
- package/src/xchains/sui/SuiXConnector.ts +0 -28
- package/src/xchains/sui/SuiXService.ts +0 -66
- package/src/xchains/sui/index.ts +0 -2
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Address,
|
|
3
|
-
Contract,
|
|
4
|
-
type Memo,
|
|
5
|
-
type MemoType,
|
|
6
|
-
type Operation,
|
|
7
|
-
TimeoutInfinite,
|
|
8
|
-
type Transaction,
|
|
9
|
-
type TransactionBuilder,
|
|
10
|
-
scValToBigInt,
|
|
11
|
-
xdr,
|
|
12
|
-
} from '@stellar/stellar-sdk';
|
|
13
|
-
import type CustomSorobanServer from './CustomSorobanServer';
|
|
14
|
-
|
|
15
|
-
export const STELLAR_RLP_MSG_TYPE = { type: 'symbol' };
|
|
16
|
-
|
|
17
|
-
// Can be used whenever you need an Address argument for a contract method
|
|
18
|
-
export const accountToScVal = (account: string) => new Address(account).toScVal();
|
|
19
|
-
|
|
20
|
-
export const simulateTx = async (
|
|
21
|
-
tx: Transaction<Memo<MemoType>, Operation[]>,
|
|
22
|
-
server: CustomSorobanServer,
|
|
23
|
-
): Promise<any> => {
|
|
24
|
-
const response = await server.simulateTransaction(tx);
|
|
25
|
-
|
|
26
|
-
if (response !== undefined) {
|
|
27
|
-
return response;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
throw new Error('cannot simulate transaction');
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export const getTokenBalance = async (
|
|
34
|
-
address: string,
|
|
35
|
-
tokenId: string,
|
|
36
|
-
txBuilder: TransactionBuilder,
|
|
37
|
-
server: CustomSorobanServer,
|
|
38
|
-
) => {
|
|
39
|
-
const params = [accountToScVal(address)];
|
|
40
|
-
const contract = new Contract(tokenId);
|
|
41
|
-
const tx = txBuilder
|
|
42
|
-
.addOperation(contract.call('balance', ...params))
|
|
43
|
-
.setTimeout(TimeoutInfinite)
|
|
44
|
-
.build();
|
|
45
|
-
|
|
46
|
-
const result = await simulateTx(tx, server);
|
|
47
|
-
|
|
48
|
-
return result.results ? scValToBigInt(xdr.ScVal.fromXDR(result.results[0].xdr, 'base64')) : 0n;
|
|
49
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { XAccount } from '@/types';
|
|
2
|
-
|
|
3
|
-
import { XConnector } from '@/core';
|
|
4
|
-
import { SuiXService } from './SuiXService';
|
|
5
|
-
|
|
6
|
-
export class SuiXConnector extends XConnector {
|
|
7
|
-
wallet: any;
|
|
8
|
-
|
|
9
|
-
constructor(wallet: any) {
|
|
10
|
-
// super('SUI', wallet.name, wallet.id);
|
|
11
|
-
super('SUI', wallet?.name, wallet?.name);
|
|
12
|
-
this.wallet = wallet;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
getXService(): SuiXService {
|
|
16
|
-
return SuiXService.getInstance();
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async connect(): Promise<XAccount | undefined> {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async disconnect(): Promise<void> {}
|
|
24
|
-
|
|
25
|
-
public get icon() {
|
|
26
|
-
return this.wallet?.icon;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { XService } from '@/core/XService';
|
|
2
|
-
import type { XToken } from '@sodax/types';
|
|
3
|
-
import { isNativeToken } from '@/utils';
|
|
4
|
-
|
|
5
|
-
export class SuiXService extends XService {
|
|
6
|
-
private static instance: SuiXService;
|
|
7
|
-
|
|
8
|
-
public suiClient: any; // TODO: define suiClient type
|
|
9
|
-
public suiWallet: any; // TODO: define suiWallet type
|
|
10
|
-
public suiAccount: any; // TODO: define suiAccount type
|
|
11
|
-
|
|
12
|
-
private constructor() {
|
|
13
|
-
super('SUI');
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
public static getInstance(): SuiXService {
|
|
17
|
-
if (!SuiXService.instance) {
|
|
18
|
-
SuiXService.instance = new SuiXService();
|
|
19
|
-
}
|
|
20
|
-
return SuiXService.instance;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// getBalance is not used because getBalances uses getAllBalances which returns all balances
|
|
24
|
-
|
|
25
|
-
async getBalances(address: string | undefined, xTokens: readonly XToken[]): Promise<Record<string, bigint>> {
|
|
26
|
-
if (!address) return {};
|
|
27
|
-
try {
|
|
28
|
-
const balancePromises = xTokens.map(async xToken => {
|
|
29
|
-
let coinType = isNativeToken(xToken) ? '0x2::sui::SUI' : xToken.address;
|
|
30
|
-
|
|
31
|
-
// TODO: hard coded for getting legacy bnUSD balance
|
|
32
|
-
if (
|
|
33
|
-
coinType ===
|
|
34
|
-
'0x03917a812fe4a6d6bc779c5ab53f8a80ba741f8af04121193fc44e0f662e2ceb::balanced_dollar::BALANCED_DOLLAR'
|
|
35
|
-
) {
|
|
36
|
-
coinType =
|
|
37
|
-
'0x3917a812fe4a6d6bc779c5ab53f8a80ba741f8af04121193fc44e0f662e2ceb::balanced_dollar::BALANCED_DOLLAR';
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const balance = await this.suiClient.getBalance({
|
|
41
|
-
owner: address,
|
|
42
|
-
coinType: coinType,
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
address: xToken.address,
|
|
47
|
-
balance: balance ? BigInt(balance.totalBalance) : undefined,
|
|
48
|
-
};
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
const results = await Promise.all(balancePromises);
|
|
52
|
-
|
|
53
|
-
const tokenMap: Record<string, bigint> = {};
|
|
54
|
-
results.forEach(result => {
|
|
55
|
-
if (result.balance !== undefined) {
|
|
56
|
-
tokenMap[result.address] = result.balance;
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
return tokenMap;
|
|
61
|
-
} catch (e) {
|
|
62
|
-
console.log('error', e);
|
|
63
|
-
return {};
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
package/src/xchains/sui/index.ts
DELETED