@tcswap/wallets 4.3.16
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/chunk-6dcwbjsg.js +5 -0
- package/dist/chunk-6dcwbjsg.js.map +10 -0
- package/dist/chunk-78m70510.js +5 -0
- package/dist/chunk-78m70510.js.map +9 -0
- package/dist/chunk-vb4wtm2w.js +4 -0
- package/dist/chunk-vb4wtm2w.js.map +9 -0
- package/dist/chunk-y6rjn578.js +4 -0
- package/dist/chunk-y6rjn578.js.map +10 -0
- package/dist/src/bitget.cjs +4 -0
- package/dist/src/bitget.cjs.map +10 -0
- package/dist/src/bitget.js +4 -0
- package/dist/src/bitget.js.map +10 -0
- package/dist/src/coinbase/index.cjs +4 -0
- package/dist/src/coinbase/index.cjs.map +11 -0
- package/dist/src/coinbase/index.js +4 -0
- package/dist/src/coinbase/index.js.map +11 -0
- package/dist/src/cosmostation.cjs +4 -0
- package/dist/src/cosmostation.cjs.map +10 -0
- package/dist/src/cosmostation.js +4 -0
- package/dist/src/cosmostation.js.map +10 -0
- package/dist/src/ctrl.cjs +4 -0
- package/dist/src/ctrl.cjs.map +10 -0
- package/dist/src/ctrl.js +4 -0
- package/dist/src/ctrl.js.map +10 -0
- package/dist/src/evm-extensions.cjs +4 -0
- package/dist/src/evm-extensions.cjs.map +10 -0
- package/dist/src/evm-extensions.js +4 -0
- package/dist/src/evm-extensions.js.map +10 -0
- package/dist/src/index.cjs +4 -0
- package/dist/src/index.cjs.map +11 -0
- package/dist/src/index.js +4 -0
- package/dist/src/index.js.map +11 -0
- package/dist/src/keepkey-bex.cjs +4 -0
- package/dist/src/keepkey-bex.cjs.map +10 -0
- package/dist/src/keepkey-bex.js +4 -0
- package/dist/src/keepkey-bex.js.map +10 -0
- package/dist/src/keepkey.cjs +4 -0
- package/dist/src/keepkey.cjs.map +10 -0
- package/dist/src/keepkey.js +4 -0
- package/dist/src/keepkey.js.map +10 -0
- package/dist/src/keplr.cjs +4 -0
- package/dist/src/keplr.cjs.map +10 -0
- package/dist/src/keplr.js +4 -0
- package/dist/src/keplr.js.map +10 -0
- package/dist/src/keystore.cjs +4 -0
- package/dist/src/keystore.cjs.map +10 -0
- package/dist/src/keystore.js +4 -0
- package/dist/src/keystore.js.map +10 -0
- package/dist/src/ledger.cjs +4 -0
- package/dist/src/ledger.cjs.map +10 -0
- package/dist/src/ledger.js +4 -0
- package/dist/src/ledger.js.map +10 -0
- package/dist/src/near-wallet-selector/index.cjs +4 -0
- package/dist/src/near-wallet-selector/index.cjs.map +10 -0
- package/dist/src/near-wallet-selector/index.js +4 -0
- package/dist/src/near-wallet-selector/index.js.map +10 -0
- package/dist/src/okx.cjs +4 -0
- package/dist/src/okx.cjs.map +10 -0
- package/dist/src/okx.js +4 -0
- package/dist/src/okx.js.map +10 -0
- package/dist/src/onekey.cjs +4 -0
- package/dist/src/onekey.cjs.map +10 -0
- package/dist/src/onekey.js +4 -0
- package/dist/src/onekey.js.map +10 -0
- package/dist/src/passkeys/index.cjs +4 -0
- package/dist/src/passkeys/index.cjs.map +10 -0
- package/dist/src/passkeys/index.js +4 -0
- package/dist/src/passkeys/index.js.map +10 -0
- package/dist/src/phantom.cjs +4 -0
- package/dist/src/phantom.cjs.map +10 -0
- package/dist/src/phantom.js +4 -0
- package/dist/src/phantom.js.map +10 -0
- package/dist/src/polkadotjs.cjs +4 -0
- package/dist/src/polkadotjs.cjs.map +10 -0
- package/dist/src/polkadotjs.js +4 -0
- package/dist/src/polkadotjs.js.map +10 -0
- package/dist/src/radix/index.cjs +4 -0
- package/dist/src/radix/index.cjs.map +10 -0
- package/dist/src/radix/index.js +4 -0
- package/dist/src/radix/index.js.map +10 -0
- package/dist/src/talisman.cjs +4 -0
- package/dist/src/talisman.cjs.map +10 -0
- package/dist/src/talisman.js +4 -0
- package/dist/src/talisman.js.map +10 -0
- package/dist/src/trezor.cjs +4 -0
- package/dist/src/trezor.cjs.map +10 -0
- package/dist/src/trezor.js +4 -0
- package/dist/src/trezor.js.map +10 -0
- package/dist/src/tronlink.cjs +4 -0
- package/dist/src/tronlink.cjs.map +10 -0
- package/dist/src/tronlink.js +4 -0
- package/dist/src/tronlink.js.map +10 -0
- package/dist/src/vultisig.cjs +4 -0
- package/dist/src/vultisig.cjs.map +10 -0
- package/dist/src/vultisig.js +4 -0
- package/dist/src/vultisig.js.map +10 -0
- package/dist/src/walletconnect/index.cjs +4 -0
- package/dist/src/walletconnect/index.cjs.map +13 -0
- package/dist/src/walletconnect/index.js +4 -0
- package/dist/src/walletconnect/index.js.map +13 -0
- package/dist/src/xaman/index.cjs +4 -0
- package/dist/src/xaman/index.cjs.map +12 -0
- package/dist/src/xaman/index.js +4 -0
- package/dist/src/xaman/index.js.map +12 -0
- package/dist/types/bitget.d.ts +2 -0
- package/dist/types/bitget.d.ts.map +1 -0
- package/dist/types/coinbase/index.d.ts +14 -0
- package/dist/types/coinbase/index.d.ts.map +1 -0
- package/dist/types/coinbase/signer.d.ts +313 -0
- package/dist/types/coinbase/signer.d.ts.map +1 -0
- package/dist/types/cosmostation.d.ts +2 -0
- package/dist/types/cosmostation.d.ts.map +1 -0
- package/dist/types/ctrl.d.ts +2 -0
- package/dist/types/ctrl.d.ts.map +1 -0
- package/dist/types/evm-extensions.d.ts +2 -0
- package/dist/types/evm-extensions.d.ts.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/keepkey-bex.d.ts +2 -0
- package/dist/types/keepkey-bex.d.ts.map +1 -0
- package/dist/types/keepkey.d.ts +2 -0
- package/dist/types/keepkey.d.ts.map +1 -0
- package/dist/types/keplr.d.ts +2 -0
- package/dist/types/keplr.d.ts.map +1 -0
- package/dist/types/keystore.d.ts +2 -0
- package/dist/types/keystore.d.ts.map +1 -0
- package/dist/types/ledger.d.ts +2 -0
- package/dist/types/ledger.d.ts.map +1 -0
- package/dist/types/near-wallet-selector/index.d.ts +16 -0
- package/dist/types/near-wallet-selector/index.d.ts.map +1 -0
- package/dist/types/okx.d.ts +2 -0
- package/dist/types/okx.d.ts.map +1 -0
- package/dist/types/onekey.d.ts +2 -0
- package/dist/types/onekey.d.ts.map +1 -0
- package/dist/types/passkeys/index.d.ts +17 -0
- package/dist/types/passkeys/index.d.ts.map +1 -0
- package/dist/types/phantom.d.ts +2 -0
- package/dist/types/phantom.d.ts.map +1 -0
- package/dist/types/polkadotjs.d.ts +2 -0
- package/dist/types/polkadotjs.d.ts.map +1 -0
- package/dist/types/radix/index.d.ts +14 -0
- package/dist/types/radix/index.d.ts.map +1 -0
- package/dist/types/talisman.d.ts +2 -0
- package/dist/types/talisman.d.ts.map +1 -0
- package/dist/types/trezor.d.ts +2 -0
- package/dist/types/trezor.d.ts.map +1 -0
- package/dist/types/tronlink.d.ts +2 -0
- package/dist/types/tronlink.d.ts.map +1 -0
- package/dist/types/types.d.ts +92 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/utils.d.ts +4 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/dist/types/vultisig.d.ts +2 -0
- package/dist/types/vultisig.d.ts.map +1 -0
- package/dist/types/walletconnect/constants.d.ts +89 -0
- package/dist/types/walletconnect/constants.d.ts.map +1 -0
- package/dist/types/walletconnect/evmSigner.d.ts +28 -0
- package/dist/types/walletconnect/evmSigner.d.ts.map +1 -0
- package/dist/types/walletconnect/helpers.d.ts +7 -0
- package/dist/types/walletconnect/helpers.d.ts.map +1 -0
- package/dist/types/walletconnect/index.d.ts +25 -0
- package/dist/types/walletconnect/index.d.ts.map +1 -0
- package/dist/types/walletconnect/namespaces.d.ts +10 -0
- package/dist/types/walletconnect/namespaces.d.ts.map +1 -0
- package/dist/types/walletconnect/types.d.ts +7 -0
- package/dist/types/walletconnect/types.d.ts.map +1 -0
- package/dist/types/xaman/helpers.d.ts +59 -0
- package/dist/types/xaman/helpers.d.ts.map +1 -0
- package/dist/types/xaman/index.d.ts +17 -0
- package/dist/types/xaman/index.d.ts.map +1 -0
- package/dist/types/xaman/types.d.ts +24 -0
- package/dist/types/xaman/types.d.ts.map +1 -0
- package/dist/types/xaman/walletMethods.d.ts +19 -0
- package/dist/types/xaman/walletMethods.d.ts.map +1 -0
- package/package.json +220 -0
- package/src/bitget.ts +1 -0
- package/src/coinbase/index.ts +48 -0
- package/src/coinbase/signer.ts +81 -0
- package/src/cosmostation.ts +1 -0
- package/src/ctrl.ts +1 -0
- package/src/evm-extensions.ts +1 -0
- package/src/index.ts +3 -0
- package/src/keepkey-bex.ts +1 -0
- package/src/keepkey.ts +1 -0
- package/src/keplr.ts +1 -0
- package/src/keystore.ts +1 -0
- package/src/ledger.ts +1 -0
- package/src/near-wallet-selector/index.ts +116 -0
- package/src/okx.ts +1 -0
- package/src/onekey.ts +1 -0
- package/src/passkeys/index.ts +187 -0
- package/src/phantom.ts +1 -0
- package/src/polkadotjs.ts +1 -0
- package/src/radix/index.ts +198 -0
- package/src/talisman.ts +1 -0
- package/src/trezor.ts +1 -0
- package/src/tronlink.ts +1 -0
- package/src/types.ts +94 -0
- package/src/utils.ts +59 -0
- package/src/vultisig.ts +1 -0
- package/src/walletconnect/constants.ts +109 -0
- package/src/walletconnect/evmSigner.ts +129 -0
- package/src/walletconnect/helpers.ts +77 -0
- package/src/walletconnect/index.ts +396 -0
- package/src/walletconnect/namespaces.ts +84 -0
- package/src/walletconnect/types.ts +6 -0
- package/src/xaman/helpers.ts +58 -0
- package/src/xaman/index.ts +66 -0
- package/src/xaman/types.ts +26 -0
- package/src/xaman/walletMethods.ts +114 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Modifications © 2025 Horizontal Systems.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { Wallet } from "@passkeys/core";
|
|
6
|
+
import {
|
|
7
|
+
Chain,
|
|
8
|
+
EVMChains,
|
|
9
|
+
filterSupportedChains,
|
|
10
|
+
prepareNetworkSwitch,
|
|
11
|
+
switchEVMWalletNetwork,
|
|
12
|
+
USwapConfig,
|
|
13
|
+
USwapError,
|
|
14
|
+
WalletOption,
|
|
15
|
+
} from "@tcswap/helpers";
|
|
16
|
+
import type { SolanaProvider } from "@tcswap/toolboxes/solana";
|
|
17
|
+
import { createWallet, getWalletSupportedChains } from "@tcswap/wallet-core";
|
|
18
|
+
import { Psbt } from "bitcoinjs-lib";
|
|
19
|
+
import {
|
|
20
|
+
AddressPurpose,
|
|
21
|
+
BitcoinNetworkType,
|
|
22
|
+
type GetAddressOptions,
|
|
23
|
+
type GetAddressResponse,
|
|
24
|
+
getAddress,
|
|
25
|
+
type SignTransactionOptions,
|
|
26
|
+
signTransaction as satsSignTransaction,
|
|
27
|
+
} from "sats-connect";
|
|
28
|
+
import { match } from "ts-pattern";
|
|
29
|
+
|
|
30
|
+
async function getPasskeyWallet() {
|
|
31
|
+
const appId = USwapConfig.get("apiKeys").passkeys;
|
|
32
|
+
const { createWallet } = await import("@passkeys/core");
|
|
33
|
+
|
|
34
|
+
return createWallet({
|
|
35
|
+
appId: appId.length > 0 ? appId : undefined,
|
|
36
|
+
providers: { bitcoin: true, ethereum: true, solana: true },
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function getWalletMethods({ wallet, chain: paramChain }: { wallet: Wallet; chain: Chain }) {
|
|
41
|
+
return match(paramChain)
|
|
42
|
+
.with(Chain.Bitcoin, async (chain) => {
|
|
43
|
+
const { getUtxoToolbox } = await import("@tcswap/toolboxes/utxo");
|
|
44
|
+
const provider = await wallet.getProvider("bitcoin");
|
|
45
|
+
|
|
46
|
+
if (!provider) {
|
|
47
|
+
throw new USwapError("wallet_passkeys_not_found");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
let address = "";
|
|
51
|
+
|
|
52
|
+
const getProvider = () => Promise.resolve(provider);
|
|
53
|
+
|
|
54
|
+
const getAddressOptions: GetAddressOptions = {
|
|
55
|
+
getProvider,
|
|
56
|
+
onCancel: () => {
|
|
57
|
+
throw new USwapError("wallet_passkeys_request_canceled");
|
|
58
|
+
},
|
|
59
|
+
onFinish: (response: GetAddressResponse) => {
|
|
60
|
+
if (!response.addresses[0]) throw new USwapError("wallet_passkeys_no_address");
|
|
61
|
+
address = response.addresses[0].address;
|
|
62
|
+
},
|
|
63
|
+
payload: {
|
|
64
|
+
message: "Address for receiving and sending payments",
|
|
65
|
+
network: { type: BitcoinNetworkType.Mainnet },
|
|
66
|
+
purposes: [AddressPurpose.Payment],
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// TODO: Towan - probably not needed ?
|
|
71
|
+
await getAddress(getAddressOptions);
|
|
72
|
+
|
|
73
|
+
async function signTransaction(psbt: Psbt) {
|
|
74
|
+
let signedPsbt: Psbt | undefined;
|
|
75
|
+
const signPsbtOptions: SignTransactionOptions = {
|
|
76
|
+
getProvider,
|
|
77
|
+
onCancel: () => {
|
|
78
|
+
throw new USwapError("wallet_passkeys_signature_canceled");
|
|
79
|
+
},
|
|
80
|
+
onFinish: (response) => {
|
|
81
|
+
signedPsbt = Psbt.fromBase64(response.psbtBase64);
|
|
82
|
+
},
|
|
83
|
+
payload: {
|
|
84
|
+
broadcast: false,
|
|
85
|
+
inputsToSign: [{ address: address, signingIndexes: psbt.txInputs.map((_, index) => index) }],
|
|
86
|
+
message: "Sign transaction",
|
|
87
|
+
network: { type: BitcoinNetworkType.Mainnet },
|
|
88
|
+
psbtBase64: psbt.toBase64(),
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
await satsSignTransaction(signPsbtOptions);
|
|
93
|
+
if (!signedPsbt) throw new USwapError("wallet_passkeys_sign_transaction_error");
|
|
94
|
+
return signedPsbt;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const signer = { getAddress: () => Promise.resolve(address), signTransaction };
|
|
98
|
+
const toolbox = await getUtxoToolbox(chain, { signer });
|
|
99
|
+
|
|
100
|
+
return { ...toolbox, address };
|
|
101
|
+
})
|
|
102
|
+
.with(...EVMChains, async (chain) => {
|
|
103
|
+
const { getProvider, getEvmToolbox } = await import("@tcswap/toolboxes/evm");
|
|
104
|
+
const { BrowserProvider } = await import("ethers");
|
|
105
|
+
|
|
106
|
+
const walletProvider = await wallet.getProvider("ethereum");
|
|
107
|
+
if (!walletProvider) {
|
|
108
|
+
throw new USwapError("wallet_passkeys_not_found");
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const jsonRpcProvider = await getProvider(chain);
|
|
112
|
+
const browserProvider = new BrowserProvider(walletProvider, "any");
|
|
113
|
+
|
|
114
|
+
await browserProvider.send("eth_requestAccounts", []);
|
|
115
|
+
|
|
116
|
+
const signer = await browserProvider.getSigner();
|
|
117
|
+
const address = await signer.getAddress();
|
|
118
|
+
const toolbox = await getEvmToolbox(chain, { provider: jsonRpcProvider, signer });
|
|
119
|
+
|
|
120
|
+
try {
|
|
121
|
+
if (chain !== Chain.Ethereum) {
|
|
122
|
+
const networkParams = toolbox.getNetworkParams();
|
|
123
|
+
await switchEVMWalletNetwork(browserProvider, chain, networkParams);
|
|
124
|
+
}
|
|
125
|
+
} catch {
|
|
126
|
+
throw new USwapError("wallet_passkeys_failed_to_switch_network", { chain });
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return { ...prepareNetworkSwitch({ chain, provider: browserProvider, toolbox }), address };
|
|
130
|
+
})
|
|
131
|
+
.with(Chain.Solana, async () => {
|
|
132
|
+
const { getSolanaToolbox } = await import("@tcswap/toolboxes/solana");
|
|
133
|
+
const provider = (await wallet.getProvider("solana")) as any as SolanaProvider;
|
|
134
|
+
const providerConnection = await provider.connect();
|
|
135
|
+
const address = providerConnection.publicKey.toString();
|
|
136
|
+
const toolbox = await getSolanaToolbox({ signer: provider });
|
|
137
|
+
|
|
138
|
+
const disconnect = async () => {
|
|
139
|
+
await provider.disconnect();
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
return { ...toolbox, address, disconnect };
|
|
143
|
+
})
|
|
144
|
+
.otherwise((chain) => {
|
|
145
|
+
throw new USwapError("wallet_passkeys_chain_not_supported", { chain });
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export const passkeysWallet = createWallet({
|
|
150
|
+
connect: ({ addChain, walletType, supportedChains }) =>
|
|
151
|
+
async function connectPasskeys(chains: Chain[], paramWallet?: Wallet) {
|
|
152
|
+
const wallet = paramWallet || (await getPasskeyWallet());
|
|
153
|
+
|
|
154
|
+
if (!wallet) throw new USwapError("wallet_passkeys_instance_missing");
|
|
155
|
+
const filteredChains = filterSupportedChains({ chains, supportedChains, walletType });
|
|
156
|
+
|
|
157
|
+
await Promise.all(
|
|
158
|
+
filteredChains.map(async (chain) => {
|
|
159
|
+
try {
|
|
160
|
+
const walletData = await getWalletMethods({ chain, wallet });
|
|
161
|
+
|
|
162
|
+
const { address, ...walletMethods } = walletData;
|
|
163
|
+
|
|
164
|
+
addChain({
|
|
165
|
+
...walletMethods,
|
|
166
|
+
address,
|
|
167
|
+
chain,
|
|
168
|
+
disconnect: wallet.disconnect,
|
|
169
|
+
walletType: WalletOption.PASSKEYS,
|
|
170
|
+
});
|
|
171
|
+
} catch (error) {
|
|
172
|
+
console.error(`Failed to connect ${chain} wallet:`, error);
|
|
173
|
+
throw error;
|
|
174
|
+
}
|
|
175
|
+
}),
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
return true;
|
|
179
|
+
},
|
|
180
|
+
name: "connectPasskeys",
|
|
181
|
+
supportedChains: [...EVMChains, Chain.Bitcoin, Chain.Solana],
|
|
182
|
+
walletType: WalletOption.PASSKEYS,
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
export const PASSKEYS_SUPPORTED_CHAINS = getWalletSupportedChains(passkeysWallet);
|
|
186
|
+
export * from "@passkeys/core";
|
|
187
|
+
export * from "@passkeys/react";
|
package/src/phantom.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@tcswap/wallet-extensions/phantom";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@tcswap/wallet-extensions/polkadotjs";
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Modifications © 2025 Horizontal Systems.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type {
|
|
6
|
+
FungibleResourcesCollectionItem,
|
|
7
|
+
GatewayApiClient,
|
|
8
|
+
StateEntityDetailsVaultResponseItem,
|
|
9
|
+
StateEntityFungiblesPageRequest,
|
|
10
|
+
StateEntityFungiblesPageResponse,
|
|
11
|
+
} from "@radixdlt/babylon-gateway-api-sdk";
|
|
12
|
+
import { AssetValue, Chain, filterSupportedChains, USwapConfig, USwapError, WalletOption } from "@tcswap/helpers";
|
|
13
|
+
import { createWallet, getWalletSupportedChains } from "@tcswap/wallet-core";
|
|
14
|
+
|
|
15
|
+
export const radixWallet = createWallet({
|
|
16
|
+
connect: ({ addChain, supportedChains, walletType }) =>
|
|
17
|
+
async function connectRadixWallet(chains: Chain[]) {
|
|
18
|
+
const filteredChains = filterSupportedChains({ chains, supportedChains, walletType });
|
|
19
|
+
const radixConfig = USwapConfig.get("integrations").radix;
|
|
20
|
+
|
|
21
|
+
if (!radixConfig) {
|
|
22
|
+
throw new USwapError("wallet_radix_not_found");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
await Promise.all(
|
|
26
|
+
filteredChains.map(async (chain) => {
|
|
27
|
+
const walletMethods = await getWalletMethods();
|
|
28
|
+
|
|
29
|
+
addChain({ ...walletMethods, chain, walletType });
|
|
30
|
+
}),
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
return true;
|
|
34
|
+
},
|
|
35
|
+
name: "connectRadixWallet",
|
|
36
|
+
supportedChains: [Chain.Radix],
|
|
37
|
+
walletType: WalletOption.RADIX_WALLET,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export const RADIX_SUPPORTED_CHAINS = getWalletSupportedChains(radixWallet);
|
|
41
|
+
|
|
42
|
+
async function fetchFungibleResources(address: string): Promise<FungibleResourcesCollectionItem[]> {
|
|
43
|
+
const { GatewayApiClient } = await import("@radixdlt/babylon-gateway-api-sdk");
|
|
44
|
+
const { applicationName } = USwapConfig.get("integrations").radix;
|
|
45
|
+
const networkApi = GatewayApiClient.initialize({ applicationName, networkId: 1 });
|
|
46
|
+
|
|
47
|
+
let hasNextPage = true;
|
|
48
|
+
let nextCursor: string | undefined;
|
|
49
|
+
let fungibleResources: FungibleResourcesCollectionItem[] = [];
|
|
50
|
+
|
|
51
|
+
const stateVersion = await currentStateVersion(networkApi);
|
|
52
|
+
|
|
53
|
+
while (hasNextPage) {
|
|
54
|
+
const stateEntityFungiblesPageRequest: StateEntityFungiblesPageRequest = {
|
|
55
|
+
address: address,
|
|
56
|
+
at_ledger_state: { state_version: stateVersion },
|
|
57
|
+
cursor: nextCursor,
|
|
58
|
+
limit_per_page: 100,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const stateEntityFungiblesPageResponse: StateEntityFungiblesPageResponse =
|
|
62
|
+
await networkApi.state.innerClient.entityFungiblesPage({
|
|
63
|
+
stateEntityFungiblesPageRequest: stateEntityFungiblesPageRequest,
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
fungibleResources = fungibleResources.concat(stateEntityFungiblesPageResponse.items);
|
|
67
|
+
|
|
68
|
+
if (stateEntityFungiblesPageResponse.next_cursor) {
|
|
69
|
+
nextCursor = stateEntityFungiblesPageResponse.next_cursor;
|
|
70
|
+
} else {
|
|
71
|
+
hasNextPage = false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return fungibleResources;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function currentStateVersion(networkApi: GatewayApiClient) {
|
|
78
|
+
return networkApi.status.getCurrent().then((status) => status.ledger_state.state_version);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// TODO - @Towan: is that still needed with USwapApi.getChainBalance()?
|
|
82
|
+
async function getBalance(address: string): Promise<AssetValue[]> {
|
|
83
|
+
const { GatewayApiClient } = await import("@radixdlt/babylon-gateway-api-sdk");
|
|
84
|
+
const resources = await fetchFungibleResources(address);
|
|
85
|
+
const { applicationName } = USwapConfig.get("integrations").radix;
|
|
86
|
+
const networkApi = GatewayApiClient.initialize({ applicationName, networkId: 1 });
|
|
87
|
+
|
|
88
|
+
const balances: AssetValue[] = [];
|
|
89
|
+
const BATCH_SIZE = 50;
|
|
90
|
+
|
|
91
|
+
// Split resources into batches of up to 50 items
|
|
92
|
+
const resourceBatches: FungibleResourcesCollectionItem[][] = [];
|
|
93
|
+
for (let i = 0; i < resources.length; i += BATCH_SIZE) {
|
|
94
|
+
resourceBatches.push(resources.slice(i, i + BATCH_SIZE));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
for (const batch of resourceBatches) {
|
|
98
|
+
const addresses = batch.map((item) => item.resource_address);
|
|
99
|
+
const response: StateEntityDetailsVaultResponseItem[] =
|
|
100
|
+
await networkApi.state.getEntityDetailsVaultAggregated(addresses);
|
|
101
|
+
|
|
102
|
+
const divisibilities = new Map<string, { decimals: number; symbol: string }>();
|
|
103
|
+
|
|
104
|
+
for (const result of response) {
|
|
105
|
+
if (result.details !== undefined) {
|
|
106
|
+
const metaDataSymbol = result.metadata?.items.find((item) => item.key === "symbol");
|
|
107
|
+
const symbol = metaDataSymbol?.value.typed.type === "String" ? metaDataSymbol.value.typed.value : "?";
|
|
108
|
+
|
|
109
|
+
if (result.details.type === "FungibleResource") {
|
|
110
|
+
divisibilities.set(result.address, { decimals: result.details.divisibility, symbol });
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
for (const item of batch) {
|
|
116
|
+
if (item.aggregation_level === "Global") {
|
|
117
|
+
const assetInfo = divisibilities.get(item.resource_address) || { decimals: 0, symbol: "?" };
|
|
118
|
+
|
|
119
|
+
const balance = AssetValue.from({
|
|
120
|
+
asset:
|
|
121
|
+
assetInfo.symbol !== Chain.Radix
|
|
122
|
+
? `${Chain.Radix}.${assetInfo.symbol}-${item.resource_address}`
|
|
123
|
+
: "XRD.XRD",
|
|
124
|
+
value: item.amount,
|
|
125
|
+
});
|
|
126
|
+
balances.push(balance);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const hasNativeAsset = balances.some((asset) => asset.isGasAsset);
|
|
132
|
+
if (!hasNativeAsset) {
|
|
133
|
+
return [AssetValue.from({ chain: Chain.Radix }), ...balances];
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return balances;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
async function getWalletMethods() {
|
|
140
|
+
const { RadixDappToolkit } = await import("@radixdlt/radix-dapp-toolkit");
|
|
141
|
+
const dappConfig = USwapConfig.get("integrations").radix;
|
|
142
|
+
const rdt = RadixDappToolkit({ ...dappConfig, networkId: dappConfig.network.networkId });
|
|
143
|
+
|
|
144
|
+
function delay(ms: number) {
|
|
145
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// TODO: @Towan - Wat is dat?
|
|
149
|
+
await delay(400);
|
|
150
|
+
|
|
151
|
+
function getAddress() {
|
|
152
|
+
const existingWalletData = rdt.walletApi.getWalletData();
|
|
153
|
+
const account = existingWalletData?.accounts?.[0];
|
|
154
|
+
|
|
155
|
+
return account?.address;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const getNewAddress = async () => {
|
|
159
|
+
const { DataRequestBuilder } = await import("@radixdlt/radix-dapp-toolkit");
|
|
160
|
+
rdt.walletApi.setRequestData(DataRequestBuilder.accounts().exactly(1));
|
|
161
|
+
const res = await rdt.walletApi.sendRequest();
|
|
162
|
+
|
|
163
|
+
if (!res) {
|
|
164
|
+
throw new USwapError("wallet_radix_no_account");
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const newAddress = res.unwrapOr(null)?.accounts[0]?.address;
|
|
168
|
+
|
|
169
|
+
if (!newAddress) {
|
|
170
|
+
throw new USwapError("wallet_radix_no_account");
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return newAddress;
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
const address = getAddress() || (await getNewAddress());
|
|
177
|
+
|
|
178
|
+
return {
|
|
179
|
+
address,
|
|
180
|
+
getAddress,
|
|
181
|
+
getBalance: () => getBalance(address),
|
|
182
|
+
radixDappToolkit: rdt,
|
|
183
|
+
signAndBroadcast: async ({ manifest, message }: { manifest: string; message: string }) => {
|
|
184
|
+
const tx = await rdt.walletApi.sendTransaction({ message, transactionManifest: manifest });
|
|
185
|
+
|
|
186
|
+
const txResult = tx.unwrapOr(null)?.transactionIntentHash;
|
|
187
|
+
|
|
188
|
+
if (!txResult) {
|
|
189
|
+
throw new USwapError("wallet_radix_transaction_failed");
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return txResult;
|
|
193
|
+
},
|
|
194
|
+
transfer: (_params: { assetValue: AssetValue; recipient: string; from: string }) => {
|
|
195
|
+
throw new USwapError("wallet_radix_method_not_supported", { method: "transfer" });
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
}
|
package/src/talisman.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@tcswap/wallet-extensions/talisman";
|
package/src/trezor.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@tcswap/wallet-hardware/trezor";
|
package/src/tronlink.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@tcswap/wallet-extensions/tronlink";
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { WalletOption } from "@tcswap/helpers";
|
|
2
|
+
import type { bitgetWallet } from "@tcswap/wallet-extensions/bitget";
|
|
3
|
+
import type { cosmostationWallet } from "@tcswap/wallet-extensions/cosmostation";
|
|
4
|
+
import type { ctrlWallet } from "@tcswap/wallet-extensions/ctrl";
|
|
5
|
+
import type { evmWallet } from "@tcswap/wallet-extensions/evm-extensions";
|
|
6
|
+
import type { keepkeyBexWallet } from "@tcswap/wallet-extensions/keepkey-bex";
|
|
7
|
+
import type { keplrWallet } from "@tcswap/wallet-extensions/keplr";
|
|
8
|
+
import type { okxWallet } from "@tcswap/wallet-extensions/okx";
|
|
9
|
+
import type { onekeyWallet } from "@tcswap/wallet-extensions/onekey";
|
|
10
|
+
import type { phantomWallet } from "@tcswap/wallet-extensions/phantom";
|
|
11
|
+
import type { polkadotWallet } from "@tcswap/wallet-extensions/polkadotjs";
|
|
12
|
+
import type { talismanWallet } from "@tcswap/wallet-extensions/talisman";
|
|
13
|
+
import type { tronlinkWallet } from "@tcswap/wallet-extensions/tronlink";
|
|
14
|
+
import type { vultisigWallet } from "@tcswap/wallet-extensions/vultisig";
|
|
15
|
+
import type { keepkeyWallet } from "@tcswap/wallet-hardware/keepkey";
|
|
16
|
+
import type { ledgerWallet } from "@tcswap/wallet-hardware/ledger";
|
|
17
|
+
import type { trezorWallet } from "@tcswap/wallet-hardware/trezor";
|
|
18
|
+
import type { coinbaseWallet } from "./coinbase";
|
|
19
|
+
import type { keystoreWallet } from "./keystore";
|
|
20
|
+
import type { walletSelectorWallet } from "./near-wallet-selector";
|
|
21
|
+
import type { passkeysWallet } from "./passkeys";
|
|
22
|
+
import type { radixWallet } from "./radix";
|
|
23
|
+
import type { walletconnectWallet } from "./walletconnect";
|
|
24
|
+
import type { xamanWallet } from "./xaman";
|
|
25
|
+
|
|
26
|
+
export type SKWallets = {
|
|
27
|
+
[WalletOption.BITGET]: typeof bitgetWallet;
|
|
28
|
+
[WalletOption.BRAVE]: typeof evmWallet;
|
|
29
|
+
[WalletOption.COINBASE_MOBILE]: typeof coinbaseWallet;
|
|
30
|
+
[WalletOption.COINBASE_WEB]: typeof evmWallet;
|
|
31
|
+
[WalletOption.COSMOSTATION]: typeof cosmostationWallet;
|
|
32
|
+
[WalletOption.CTRL]: typeof ctrlWallet;
|
|
33
|
+
[WalletOption.EIP6963]: typeof evmWallet;
|
|
34
|
+
[WalletOption.EXODUS]: typeof passkeysWallet;
|
|
35
|
+
[WalletOption.KEEPKEY]: typeof keepkeyWallet;
|
|
36
|
+
[WalletOption.KEEPKEY_BEX]: typeof keepkeyBexWallet;
|
|
37
|
+
[WalletOption.KEPLR]: typeof keplrWallet;
|
|
38
|
+
[WalletOption.KEYSTORE]: typeof keystoreWallet;
|
|
39
|
+
[WalletOption.LEAP]: typeof keplrWallet;
|
|
40
|
+
[WalletOption.LEDGER]: typeof ledgerWallet;
|
|
41
|
+
[WalletOption.LEDGER_LIVE]: typeof ledgerWallet;
|
|
42
|
+
[WalletOption.METAMASK]: typeof evmWallet;
|
|
43
|
+
[WalletOption.OKX]: typeof okxWallet;
|
|
44
|
+
[WalletOption.OKX_MOBILE]: typeof evmWallet;
|
|
45
|
+
[WalletOption.ONEKEY]: typeof onekeyWallet;
|
|
46
|
+
[WalletOption.PASSKEYS]: typeof passkeysWallet;
|
|
47
|
+
[WalletOption.PHANTOM]: typeof phantomWallet;
|
|
48
|
+
[WalletOption.POLKADOT_JS]: typeof polkadotWallet;
|
|
49
|
+
[WalletOption.RADIX_WALLET]: typeof radixWallet;
|
|
50
|
+
[WalletOption.TALISMAN]: typeof talismanWallet;
|
|
51
|
+
[WalletOption.TREZOR]: typeof trezorWallet;
|
|
52
|
+
[WalletOption.TRONLINK]: typeof tronlinkWallet;
|
|
53
|
+
[WalletOption.TRUSTWALLET_WEB]: typeof evmWallet;
|
|
54
|
+
[WalletOption.VULTISIG]: typeof vultisigWallet;
|
|
55
|
+
[WalletOption.WALLETCONNECT]: typeof walletconnectWallet;
|
|
56
|
+
[WalletOption.WALLET_SELECTOR]: typeof walletSelectorWallet;
|
|
57
|
+
[WalletOption.XAMAN]: typeof xamanWallet;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export type SKConnectWallets = SKWallets[keyof SKWallets];
|
|
61
|
+
|
|
62
|
+
export type SKWalletsSupportedChains = {
|
|
63
|
+
[WalletOption.BITGET]: typeof bitgetWallet.connectBitget.supportedChains;
|
|
64
|
+
[WalletOption.BRAVE]: typeof evmWallet.connectEVMWallet.supportedChains;
|
|
65
|
+
[WalletOption.COINBASE_MOBILE]: typeof coinbaseWallet.connectCoinbaseWallet.supportedChains;
|
|
66
|
+
[WalletOption.COINBASE_WEB]: typeof evmWallet.connectEVMWallet.supportedChains;
|
|
67
|
+
[WalletOption.COSMOSTATION]: typeof cosmostationWallet.connectCosmostation.supportedChains;
|
|
68
|
+
[WalletOption.CTRL]: typeof ctrlWallet.connectCtrl.supportedChains;
|
|
69
|
+
[WalletOption.EIP6963]: typeof evmWallet.connectEVMWallet.supportedChains;
|
|
70
|
+
[WalletOption.EXODUS]: typeof passkeysWallet.connectPasskeys.supportedChains;
|
|
71
|
+
[WalletOption.KEEPKEY]: typeof keepkeyWallet.connectKeepkey.supportedChains;
|
|
72
|
+
[WalletOption.KEEPKEY_BEX]: typeof keepkeyBexWallet.connectKeepkeyBex.supportedChains;
|
|
73
|
+
[WalletOption.KEPLR]: typeof keplrWallet.connectKeplr.supportedChains;
|
|
74
|
+
[WalletOption.KEYSTORE]: typeof keystoreWallet.connectKeystore.supportedChains;
|
|
75
|
+
[WalletOption.LEAP]: typeof keplrWallet.connectKeplr.supportedChains;
|
|
76
|
+
[WalletOption.LEDGER]: typeof ledgerWallet.connectLedger.supportedChains;
|
|
77
|
+
[WalletOption.LEDGER_LIVE]: typeof ledgerWallet.connectLedger.supportedChains;
|
|
78
|
+
[WalletOption.METAMASK]: typeof evmWallet.connectEVMWallet.supportedChains;
|
|
79
|
+
[WalletOption.OKX]: typeof okxWallet.connectOkx.supportedChains;
|
|
80
|
+
[WalletOption.OKX_MOBILE]: typeof evmWallet.connectEVMWallet.supportedChains;
|
|
81
|
+
[WalletOption.ONEKEY]: typeof onekeyWallet.connectOnekeyWallet.supportedChains;
|
|
82
|
+
[WalletOption.PASSKEYS]: typeof passkeysWallet.connectPasskeys.supportedChains;
|
|
83
|
+
[WalletOption.PHANTOM]: typeof phantomWallet.connectPhantom.supportedChains;
|
|
84
|
+
[WalletOption.POLKADOT_JS]: typeof polkadotWallet.connectPolkadotJs.supportedChains;
|
|
85
|
+
[WalletOption.RADIX_WALLET]: typeof radixWallet.connectRadixWallet.supportedChains;
|
|
86
|
+
[WalletOption.TALISMAN]: typeof talismanWallet.connectTalisman.supportedChains;
|
|
87
|
+
[WalletOption.TREZOR]: typeof trezorWallet.connectTrezor.supportedChains;
|
|
88
|
+
[WalletOption.TRONLINK]: typeof tronlinkWallet.connectTronLink.supportedChains;
|
|
89
|
+
[WalletOption.TRUSTWALLET_WEB]: typeof evmWallet.connectEVMWallet.supportedChains;
|
|
90
|
+
[WalletOption.VULTISIG]: typeof vultisigWallet.connectVultisig.supportedChains;
|
|
91
|
+
[WalletOption.WALLETCONNECT]: typeof walletconnectWallet.connectWalletconnect.supportedChains;
|
|
92
|
+
[WalletOption.WALLET_SELECTOR]: typeof walletSelectorWallet.connectWalletSelector.supportedChains;
|
|
93
|
+
[WalletOption.XAMAN]: typeof xamanWallet.connectXaman.supportedChains;
|
|
94
|
+
};
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { WalletOption } from "@tcswap/helpers";
|
|
2
|
+
import type { SKWallets } from "./types";
|
|
3
|
+
|
|
4
|
+
export async function loadWallet<W extends WalletOption>(walletOption: W): Promise<SKWallets[W]> {
|
|
5
|
+
const { match } = await import("ts-pattern");
|
|
6
|
+
|
|
7
|
+
const wallet = await match(walletOption as WalletOption)
|
|
8
|
+
.with(WalletOption.COINBASE_MOBILE, async () => (await import("./coinbase")).coinbaseWallet)
|
|
9
|
+
.with(WalletOption.BITGET, async () => (await import("@tcswap/wallet-extensions/bitget")).bitgetWallet)
|
|
10
|
+
.with(WalletOption.CTRL, async () => (await import("@tcswap/wallet-extensions/ctrl")).ctrlWallet)
|
|
11
|
+
.with(WalletOption.VULTISIG, async () => (await import("@tcswap/wallet-extensions/vultisig")).vultisigWallet)
|
|
12
|
+
.with(WalletOption.OKX, async () => (await import("@tcswap/wallet-extensions/okx")).okxWallet)
|
|
13
|
+
.with(WalletOption.ONEKEY, async () => (await import("@tcswap/wallet-extensions/onekey")).onekeyWallet)
|
|
14
|
+
.with(WalletOption.EXODUS, async () => (await import("./passkeys")).passkeysWallet)
|
|
15
|
+
.with(WalletOption.KEEPKEY, async () => (await import("@tcswap/wallet-hardware/keepkey")).keepkeyWallet)
|
|
16
|
+
.with(
|
|
17
|
+
WalletOption.KEEPKEY_BEX,
|
|
18
|
+
async () => (await import("@tcswap/wallet-extensions/keepkey-bex")).keepkeyBexWallet,
|
|
19
|
+
)
|
|
20
|
+
.with(WalletOption.WALLETCONNECT, async () => (await import("./walletconnect")).walletconnectWallet)
|
|
21
|
+
.with(
|
|
22
|
+
WalletOption.KEPLR,
|
|
23
|
+
WalletOption.LEAP,
|
|
24
|
+
async () => (await import("@tcswap/wallet-extensions/keplr")).keplrWallet,
|
|
25
|
+
)
|
|
26
|
+
.with(
|
|
27
|
+
WalletOption.COSMOSTATION,
|
|
28
|
+
async () => (await import("@tcswap/wallet-extensions/cosmostation")).cosmostationWallet,
|
|
29
|
+
)
|
|
30
|
+
.with(
|
|
31
|
+
WalletOption.BRAVE,
|
|
32
|
+
WalletOption.COINBASE_WEB,
|
|
33
|
+
WalletOption.EIP6963,
|
|
34
|
+
WalletOption.METAMASK,
|
|
35
|
+
WalletOption.OKX_MOBILE,
|
|
36
|
+
WalletOption.TRUSTWALLET_WEB,
|
|
37
|
+
async () => (await import("@tcswap/wallet-extensions/evm-extensions")).evmWallet,
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
.with(WalletOption.KEYSTORE, async () => (await import("@tcswap/wallet-keystore")).keystoreWallet)
|
|
41
|
+
.with(WalletOption.TREZOR, async () => (await import("@tcswap/wallet-hardware/trezor")).trezorWallet)
|
|
42
|
+
.with(
|
|
43
|
+
WalletOption.LEDGER,
|
|
44
|
+
// TODO: Remove
|
|
45
|
+
WalletOption.LEDGER_LIVE,
|
|
46
|
+
async () => (await import("@tcswap/wallet-hardware/ledger")).ledgerWallet,
|
|
47
|
+
)
|
|
48
|
+
.with(WalletOption.PASSKEYS, async () => (await import("./passkeys")).passkeysWallet)
|
|
49
|
+
.with(WalletOption.PHANTOM, async () => (await import("@tcswap/wallet-extensions/phantom")).phantomWallet)
|
|
50
|
+
.with(WalletOption.POLKADOT_JS, async () => (await import("@tcswap/wallet-extensions/polkadotjs")).polkadotWallet)
|
|
51
|
+
.with(WalletOption.RADIX_WALLET, async () => (await import("./radix")).radixWallet)
|
|
52
|
+
.with(WalletOption.TALISMAN, async () => (await import("@tcswap/wallet-extensions/talisman")).talismanWallet)
|
|
53
|
+
.with(WalletOption.TRONLINK, async () => (await import("@tcswap/wallet-extensions/tronlink")).tronlinkWallet)
|
|
54
|
+
.with(WalletOption.WALLET_SELECTOR, async () => (await import("./near-wallet-selector")).walletSelectorWallet)
|
|
55
|
+
.with(WalletOption.XAMAN, async () => (await import("./xaman")).xamanWallet)
|
|
56
|
+
.exhaustive();
|
|
57
|
+
|
|
58
|
+
return wallet as SKWallets[W];
|
|
59
|
+
}
|
package/src/vultisig.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@tcswap/wallet-extensions/vultisig";
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Modifications © 2025 Horizontal Systems.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { ClientMetadata } from "./types";
|
|
6
|
+
|
|
7
|
+
export const DEFAULT_RELAY_URL = "wss://relay.walletconnect.com";
|
|
8
|
+
|
|
9
|
+
export const ETHEREUM_MAINNET_ID = "eip155:1";
|
|
10
|
+
export const BSC_MAINNET_ID = "eip155:56";
|
|
11
|
+
export const AVALANCHE_MAINNET_ID = "eip155:43114";
|
|
12
|
+
export const THORCHAIN_MAINNET_ID = "cosmos:thorchain";
|
|
13
|
+
export const COSMOS_HUB_MAINNET_ID = "cosmos:cosmoshub-4";
|
|
14
|
+
export const KUJIRA_MAINNET_ID = "cosmos:kaiyo-1";
|
|
15
|
+
export const MAYACHAIN_MAINNET_ID = "cosmos:mayachain-mainnet-v1";
|
|
16
|
+
export const ARBITRUM_ONE_MAINNET_ID = "eip155:42161";
|
|
17
|
+
export const OPTIMISM_MAINNET_ID = "eip155:10";
|
|
18
|
+
export const POLYGON_MAINNET_ID = "eip155:137";
|
|
19
|
+
export const BASE_MAINNET_ID = "eip155:8453";
|
|
20
|
+
export const NEAR_MAINNET_ID = "near:mainnet";
|
|
21
|
+
export const NEAR_TESTNET_ID = "near:testnet";
|
|
22
|
+
export const TRON_MAINNET_ID = "tron:0x2b6653dc";
|
|
23
|
+
export const AURORA_MAINNET_ID = "eip155:1313161554";
|
|
24
|
+
export const BERACHAIN_MAINNET_ID = "eip155:80094";
|
|
25
|
+
export const MONAD_MAINNET_ID = "eip155:143";
|
|
26
|
+
|
|
27
|
+
export const DEFAULT_LOGGER = "debug";
|
|
28
|
+
|
|
29
|
+
export const DEFAULT_APP_METADATA: ClientMetadata = {
|
|
30
|
+
description: "USwap cross-chain SDK",
|
|
31
|
+
icons: [
|
|
32
|
+
"https://raw.githubusercontent.com/horizontalsystems/USwap/refs/heads/develop/docs/src/assets/logo-black.png",
|
|
33
|
+
],
|
|
34
|
+
name: "USwap",
|
|
35
|
+
url: "https://uswap.dev/",
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* EIP155
|
|
40
|
+
*/
|
|
41
|
+
export enum DEFAULT_EIP155_METHODS {
|
|
42
|
+
ETH_SEND_TRANSACTION = "eth_sendTransaction",
|
|
43
|
+
// not supported by most WC wallets
|
|
44
|
+
// ETH_SIGN_TRANSACTION = 'eth_signTransaction',
|
|
45
|
+
ETH_SIGN = "eth_sign",
|
|
46
|
+
PERSONAL_SIGN = "personal_sign",
|
|
47
|
+
ETH_SIGN_TYPED_DATA = "eth_signTypedData",
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export enum DEFAULT_EIP_155_EVENTS {
|
|
51
|
+
ETH_CHAIN_CHANGED = "chainChanged",
|
|
52
|
+
ETH_ACCOUNTS_CHANGED = "accountsChanged",
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* COSMOS
|
|
57
|
+
*/
|
|
58
|
+
export enum DEFAULT_COSMOS_METHODS {
|
|
59
|
+
COSMOS_SIGN_DIRECT = "cosmos_signDirect",
|
|
60
|
+
COSMOS_SIGN_AMINO = "cosmos_signAmino",
|
|
61
|
+
COSMOS_GET_ACCOUNTS = "cosmos_getAccounts",
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export enum DEFAULT_COSMOS_EVENTS {}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* SOLANA
|
|
68
|
+
*/
|
|
69
|
+
export enum DEFAULT_SOLANA_METHODS {
|
|
70
|
+
SOL_SIGN_TRANSACTION = "solana_signTransaction",
|
|
71
|
+
SOL_SIGN_MESSAGE = "solana_signMessage",
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export enum DEFAULT_SOLANA_EVENTS {}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* POLKADOT
|
|
78
|
+
*/
|
|
79
|
+
export enum DEFAULT_POLKADOT_METHODS {
|
|
80
|
+
POLKADOT_SIGN_TRANSACTION = "polkadot_signTransaction",
|
|
81
|
+
POLKADOT_SIGN_MESSAGE = "polkadot_signMessage",
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export enum DEFAULT_POLKADOT_EVENTS {}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* NEAR
|
|
88
|
+
*/
|
|
89
|
+
export enum DEFAULT_NEAR_METHODS {
|
|
90
|
+
NEAR_SIGN_IN = "near_signIn",
|
|
91
|
+
NEAR_SIGN_OUT = "near_signOut",
|
|
92
|
+
NEAR_GET_ACCOUNTS = "near_getAccounts",
|
|
93
|
+
NEAR_SIGN_AND_SEND_TRANSACTION = "near_signAndSendTransaction",
|
|
94
|
+
NEAR_SIGN_AND_SEND_TRANSACTIONS = "near_signAndSendTransactions",
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export enum DEFAULT_NEAR_EVENTS {}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* TRON
|
|
101
|
+
*/
|
|
102
|
+
export enum DEFAULT_TRON_METHODS {
|
|
103
|
+
TRON_SIGN_MESSAGE = "tron_signMessage",
|
|
104
|
+
TRON_SIGN_TRANSACTION = "tron_signTransaction",
|
|
105
|
+
TRON_SEND_TRANSACTION = "tron_sendTransaction",
|
|
106
|
+
TRON_GET_ACCOUNTS = "tron_getAccounts",
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export enum DEFAULT_TRON_EVENTS {}
|