@swapkit/wallets 4.3.11 → 4.6.0

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.
Files changed (121) hide show
  1. package/dist/LICENSE +246 -0
  2. package/dist/chunk-1m30h0t9.js +4 -0
  3. package/dist/{chunk-vb4wtm2w.js.map → chunk-1m30h0t9.js.map} +1 -1
  4. package/dist/chunk-5jj4jvy9.js +5 -0
  5. package/dist/{chunk-78m70510.js.map → chunk-5jj4jvy9.js.map} +1 -1
  6. package/dist/chunk-ae6bkfs5.js +3 -0
  7. package/dist/chunk-ae6bkfs5.js.map +9 -0
  8. package/dist/chunk-dx5r3mz1.js +5 -0
  9. package/dist/chunk-dx5r3mz1.js.map +10 -0
  10. package/dist/chunk-ewwx4745.js +4 -0
  11. package/dist/chunk-ewwx4745.js.map +9 -0
  12. package/dist/chunk-qv7snmdv.js +5 -0
  13. package/dist/chunk-qv7snmdv.js.map +10 -0
  14. package/dist/chunk-ttryb513.js +4 -0
  15. package/dist/chunk-ttryb513.js.map +10 -0
  16. package/dist/chunk-zrqsb6ng.js +4 -0
  17. package/dist/chunk-zrqsb6ng.js.map +10 -0
  18. package/dist/src/coinbase/index.cjs +2 -2
  19. package/dist/src/coinbase/index.cjs.map +4 -4
  20. package/dist/src/coinbase/index.js +2 -2
  21. package/dist/src/coinbase/index.js.map +4 -4
  22. package/dist/src/index.cjs +2 -2
  23. package/dist/src/index.cjs.map +4 -5
  24. package/dist/src/index.js +2 -2
  25. package/dist/src/index.js.map +4 -5
  26. package/dist/src/keystore.cjs +2 -2
  27. package/dist/src/keystore.cjs.map +5 -4
  28. package/dist/src/keystore.js +2 -2
  29. package/dist/src/keystore.js.map +5 -4
  30. package/dist/src/near-wallet-selector/index.cjs +2 -2
  31. package/dist/src/near-wallet-selector/index.cjs.map +3 -3
  32. package/dist/src/near-wallet-selector/index.js +2 -2
  33. package/dist/src/near-wallet-selector/index.js.map +3 -3
  34. package/dist/src/passkeys/index.cjs +2 -2
  35. package/dist/src/passkeys/index.cjs.map +3 -3
  36. package/dist/src/passkeys/index.js +2 -2
  37. package/dist/src/passkeys/index.js.map +3 -3
  38. package/dist/src/radix/index.cjs +2 -2
  39. package/dist/src/radix/index.cjs.map +3 -3
  40. package/dist/src/radix/index.js +2 -2
  41. package/dist/src/radix/index.js.map +3 -3
  42. package/dist/src/walletconnect/index.cjs +2 -2
  43. package/dist/src/walletconnect/index.cjs.map +4 -4
  44. package/dist/src/walletconnect/index.js +2 -2
  45. package/dist/src/walletconnect/index.js.map +4 -4
  46. package/dist/src/xaman/index.cjs +2 -2
  47. package/dist/src/xaman/index.cjs.map +5 -5
  48. package/dist/src/xaman/index.js +2 -2
  49. package/dist/src/xaman/index.js.map +5 -5
  50. package/dist/types/coinbase/signer.d.ts +58 -23
  51. package/dist/types/coinbase/signer.d.ts.map +1 -1
  52. package/dist/types/core.d.ts +18 -0
  53. package/dist/types/core.d.ts.map +1 -0
  54. package/dist/types/index.d.ts +1 -1
  55. package/dist/types/index.d.ts.map +1 -1
  56. package/dist/types/keystore-helpers.d.ts +42 -0
  57. package/dist/types/keystore-helpers.d.ts.map +1 -0
  58. package/dist/types/keystore.d.ts +66 -1
  59. package/dist/types/keystore.d.ts.map +1 -1
  60. package/dist/types/passkeys/index.d.ts +2 -2
  61. package/dist/types/passkeys/index.d.ts.map +1 -1
  62. package/dist/types/radix/index.d.ts.map +1 -1
  63. package/dist/types/types.d.ts +6 -4
  64. package/dist/types/types.d.ts.map +1 -1
  65. package/dist/types/utils.d.ts.map +1 -1
  66. package/dist/types/walletconnect/constants.d.ts +2 -1
  67. package/dist/types/walletconnect/constants.d.ts.map +1 -1
  68. package/dist/types/walletconnect/evmSigner.d.ts +2 -2
  69. package/dist/types/walletconnect/evmSigner.d.ts.map +1 -1
  70. package/dist/types/walletconnect/index.d.ts +2 -2
  71. package/dist/types/walletconnect/index.d.ts.map +1 -1
  72. package/dist/types/xaman/helpers.d.ts +22 -20
  73. package/dist/types/xaman/helpers.d.ts.map +1 -1
  74. package/dist/types/xaman/index.d.ts +1 -1
  75. package/dist/types/xaman/index.d.ts.map +1 -1
  76. package/dist/types/xaman/types.d.ts +8 -0
  77. package/dist/types/xaman/types.d.ts.map +1 -1
  78. package/dist/types/xaman/walletMethods.d.ts +14 -2
  79. package/dist/types/xaman/walletMethods.d.ts.map +1 -1
  80. package/package.json +26 -16
  81. package/dist/chunk-78m70510.js +0 -5
  82. package/dist/chunk-7jmqkkhs.js +0 -4
  83. package/dist/chunk-7jmqkkhs.js.map +0 -10
  84. package/dist/chunk-9acqzpjy.js +0 -5
  85. package/dist/chunk-9acqzpjy.js.map +0 -10
  86. package/dist/chunk-vb4wtm2w.js +0 -4
  87. package/src/bitget.ts +0 -1
  88. package/src/coinbase/index.ts +0 -44
  89. package/src/coinbase/signer.ts +0 -77
  90. package/src/cosmostation.ts +0 -1
  91. package/src/ctrl.ts +0 -1
  92. package/src/evm-extensions.ts +0 -1
  93. package/src/index.ts +0 -3
  94. package/src/keepkey-bex.ts +0 -1
  95. package/src/keepkey.ts +0 -1
  96. package/src/keplr.ts +0 -1
  97. package/src/keystore.ts +0 -1
  98. package/src/ledger.ts +0 -1
  99. package/src/near-wallet-selector/index.ts +0 -115
  100. package/src/okx.ts +0 -1
  101. package/src/onekey.ts +0 -1
  102. package/src/passkeys/index.ts +0 -183
  103. package/src/phantom.ts +0 -1
  104. package/src/polkadotjs.ts +0 -1
  105. package/src/radix/index.ts +0 -194
  106. package/src/talisman.ts +0 -1
  107. package/src/trezor.ts +0 -1
  108. package/src/tronlink.ts +0 -1
  109. package/src/types.ts +0 -94
  110. package/src/utils.ts +0 -59
  111. package/src/vultisig.ts +0 -1
  112. package/src/walletconnect/constants.ts +0 -103
  113. package/src/walletconnect/evmSigner.ts +0 -125
  114. package/src/walletconnect/helpers.ts +0 -73
  115. package/src/walletconnect/index.ts +0 -392
  116. package/src/walletconnect/namespaces.ts +0 -80
  117. package/src/walletconnect/types.ts +0 -6
  118. package/src/xaman/helpers.ts +0 -54
  119. package/src/xaman/index.ts +0 -62
  120. package/src/xaman/types.ts +0 -26
  121. package/src/xaman/walletMethods.ts +0 -110
@@ -1,392 +0,0 @@
1
- import type { StdSignDoc } from "@cosmjs/amino";
2
- import type { Transaction } from "@near-js/transactions";
3
- import {
4
- Chain,
5
- filterSupportedChains,
6
- type GenericTransferParams,
7
- getRPCUrl,
8
- SKConfig,
9
- SwapKitError,
10
- WalletOption,
11
- } from "@swapkit/helpers";
12
- import type { ThorchainDepositParams } from "@swapkit/toolboxes/cosmos";
13
- import type { NearSigner } from "@swapkit/toolboxes/near";
14
- import type { TronSignedTransaction, TronSigner, TronTransaction } from "@swapkit/toolboxes/tron";
15
- import { createWallet, getWalletSupportedChains } from "@swapkit/wallet-core";
16
- import type { WalletConnectModal } from "@walletconnect/modal";
17
- import type { SignClient } from "@walletconnect/sign-client";
18
- import type { SessionTypes, SignClientTypes } from "@walletconnect/types";
19
- import {
20
- DEFAULT_APP_METADATA,
21
- DEFAULT_COSMOS_METHODS,
22
- DEFAULT_LOGGER,
23
- DEFAULT_RELAY_URL,
24
- THORCHAIN_MAINNET_ID,
25
- } from "./constants";
26
- import { getEVMSigner } from "./evmSigner";
27
- import { chainToChainId, getAddressByChain } from "./helpers";
28
- import { getRequiredNamespaces } from "./namespaces";
29
-
30
- export * from "./constants";
31
- export * from "./types";
32
-
33
- export const walletconnectWallet = createWallet({
34
- connect: ({ addChain, supportedChains, walletType }) =>
35
- async function connectWalletconnect(chains: Chain[], walletconnectOptions?: SignClientTypes.Options) {
36
- const filteredChains = filterSupportedChains({ chains, supportedChains, walletType });
37
- const { walletConnectProjectId } = SKConfig.get("apiKeys");
38
-
39
- if (!walletConnectProjectId) {
40
- throw new SwapKitError("wallet_walletconnect_project_id_not_specified");
41
- }
42
-
43
- const walletconnect = await getWalletconnect(filteredChains, walletConnectProjectId, walletconnectOptions);
44
-
45
- if (!walletconnect) {
46
- throw new SwapKitError("wallet_walletconnect_connection_not_established");
47
- }
48
-
49
- const { accounts } = walletconnect;
50
-
51
- await Promise.all(
52
- filteredChains.map(async (chain) => {
53
- const address = getAddressByChain(chain, accounts || []);
54
- const toolbox = await getToolbox({ address, chain, walletconnect });
55
-
56
- addChain({
57
- ...toolbox,
58
- address,
59
- chain,
60
- disconnect: walletconnect.disconnect,
61
- walletType: WalletOption.WALLETCONNECT,
62
- });
63
- }),
64
- );
65
-
66
- return true;
67
- },
68
- name: "connectWalletconnect",
69
- supportedChains: [
70
- Chain.Arbitrum,
71
- Chain.Aurora,
72
- Chain.Avalanche,
73
- Chain.Base,
74
- Chain.Berachain,
75
- Chain.BinanceSmartChain,
76
- Chain.Cosmos,
77
- Chain.Ethereum,
78
- Chain.Kujira,
79
- Chain.Maya,
80
- Chain.Monad,
81
- Chain.Near,
82
- Chain.Optimism,
83
- Chain.Polygon,
84
- Chain.THORChain,
85
- Chain.Tron,
86
- Chain.XLayer,
87
- ],
88
- walletType: WalletOption.WALLETCONNECT,
89
- });
90
-
91
- export const WC_SUPPORTED_CHAINS = getWalletSupportedChains(walletconnectWallet);
92
- export type Walletconnect = Awaited<ReturnType<typeof getWalletconnect>>;
93
-
94
- async function getToolbox<T extends (typeof WC_SUPPORTED_CHAINS)[number]>({
95
- chain,
96
- walletconnect,
97
- address,
98
- }: {
99
- walletconnect: Walletconnect;
100
- chain: T;
101
- address: string;
102
- }) {
103
- const session = walletconnect?.session;
104
- if (!session) {
105
- throw new SwapKitError("wallet_walletconnect_connection_not_established");
106
- }
107
-
108
- switch (chain) {
109
- case Chain.Arbitrum:
110
- case Chain.Avalanche:
111
- case Chain.Base:
112
- case Chain.BinanceSmartChain:
113
- case Chain.Ethereum:
114
- case Chain.Monad:
115
- case Chain.Optimism:
116
- case Chain.Polygon:
117
- case Chain.XLayer: {
118
- const { getProvider, getEvmToolbox } = await import("@swapkit/toolboxes/evm");
119
-
120
- const provider = await getProvider(chain);
121
- const signer = await getEVMSigner({ chain, provider, walletconnect });
122
- const toolbox = await getEvmToolbox(chain, { provider, signer });
123
-
124
- return toolbox;
125
- }
126
-
127
- case Chain.THORChain: {
128
- const { SignMode } = await import("cosmjs-types/cosmos/tx/signing/v1beta1/signing.js");
129
- const { TxRaw } = await import("cosmjs-types/cosmos/tx/v1beta1/tx.js");
130
-
131
- const importedSigning = await import("@cosmjs/proto-signing");
132
- const encodePubkey = importedSigning.encodePubkey ?? importedSigning.default?.encodePubkey;
133
- const makeAuthInfoBytes = importedSigning.makeAuthInfoBytes ?? importedSigning.default?.makeAuthInfoBytes;
134
- const importedAmino = await import("@cosmjs/amino");
135
- const makeSignDoc = importedAmino.makeSignDoc ?? importedSigning.default?.makeSignDoc;
136
-
137
- const {
138
- getCosmosToolbox,
139
- buildAminoMsg,
140
- buildEncodedTxBody,
141
- createStargateClient,
142
- fromBase64,
143
- getDefaultChainFee,
144
- parseAminoMessageForDirectSigning,
145
- } = await import("@swapkit/toolboxes/cosmos");
146
- const toolbox = await getCosmosToolbox(chain);
147
-
148
- const fee = getDefaultChainFee(chain);
149
-
150
- const signRequest = (signDoc: StdSignDoc) =>
151
- walletconnect?.client.request({
152
- chainId: THORCHAIN_MAINNET_ID,
153
- request: { method: DEFAULT_COSMOS_METHODS.COSMOS_SIGN_AMINO, params: { signDoc, signerAddress: address } },
154
- topic: session.topic,
155
- });
156
-
157
- async function thorchainTransfer({ assetValue, memo, ...rest }: GenericTransferParams | ThorchainDepositParams) {
158
- const account = await toolbox.getAccount(address);
159
- if (!account) {
160
- throw new SwapKitError({ errorKey: "wallet_missing_params", info: { account } });
161
- }
162
-
163
- if (!account.pubkey) {
164
- throw new SwapKitError({ errorKey: "wallet_missing_params", info: { account, pubkey: account?.pubkey } });
165
- }
166
-
167
- const { accountNumber, sequence = 0 } = account;
168
-
169
- const msgs = [buildAminoMsg({ ...rest, assetValue, memo, sender: address })];
170
-
171
- const signDoc = makeSignDoc(
172
- msgs,
173
- fee,
174
- assetValue.chainId,
175
- memo,
176
- accountNumber?.toString(),
177
- sequence?.toString() || "0",
178
- );
179
-
180
- const signature: any = await signRequest(signDoc);
181
-
182
- const bodyBytes = await buildEncodedTxBody({
183
- chain: Chain.THORChain,
184
- memo: memo || "",
185
- msgs: msgs.map(parseAminoMessageForDirectSigning),
186
- });
187
- const pubkey = encodePubkey(account.pubkey);
188
- const authInfoBytes = makeAuthInfoBytes(
189
- [{ pubkey, sequence }],
190
- fee.amount,
191
- Number.parseInt(fee.gas, 10),
192
- undefined,
193
- undefined,
194
- SignMode.SIGN_MODE_LEGACY_AMINO_JSON,
195
- );
196
-
197
- const txRaw = TxRaw.fromPartial({
198
- authInfoBytes,
199
- bodyBytes,
200
- signatures: [
201
- fromBase64(typeof signature.signature === "string" ? signature.signature : signature.signature.signature),
202
- ],
203
- });
204
- const txBytes = TxRaw.encode(txRaw).finish();
205
-
206
- const rpcUrl = await getRPCUrl(Chain.THORChain);
207
- const broadcaster = await createStargateClient(rpcUrl);
208
- const result = await broadcaster.broadcastTx(txBytes);
209
- return result.transactionHash;
210
- }
211
-
212
- return {
213
- ...toolbox,
214
- deposit: (params: ThorchainDepositParams) => thorchainTransfer(params),
215
- transfer: (params: GenericTransferParams) => thorchainTransfer(params),
216
- };
217
- }
218
-
219
- case Chain.Near: {
220
- const { getNearToolbox } = await import("@swapkit/toolboxes/near");
221
- const { DEFAULT_NEAR_METHODS } = await import("./constants");
222
-
223
- // Create a NEAR signer that uses WalletConnect
224
- const signer = {
225
- getAddress() {
226
- return Promise.resolve(address);
227
- },
228
- getPublicKey() {
229
- // WalletConnect NEAR doesn't expose public key directly
230
- return Promise.reject(
231
- new SwapKitError("wallet_walletconnect_method_not_supported", { method: "getPublicKey" }),
232
- );
233
- },
234
-
235
- signDelegateAction(_delegateAction: any) {
236
- return Promise.reject(
237
- new SwapKitError("wallet_walletconnect_method_not_supported", { method: "signDelegateAction" }),
238
- );
239
- },
240
-
241
- signNep413Message(
242
- _message: string,
243
- _accountId: string,
244
- _recipient: string,
245
- _nonce: Uint8Array,
246
- _callbackUrl?: string,
247
- ) {
248
- // WalletConnect NEAR spec doesn't include NEP-413 message signing
249
- return Promise.reject(
250
- new SwapKitError("wallet_walletconnect_method_not_supported", { method: "signNep413Message" }),
251
- );
252
- },
253
-
254
- async signTransaction(transaction: Transaction) {
255
- if (!walletconnect) {
256
- throw new SwapKitError("wallet_walletconnect_connection_not_established");
257
- }
258
- // WalletConnect signs and sends in one operation
259
- const result = await walletconnect.client.request({
260
- chainId: chainToChainId(Chain.Near),
261
- request: { method: DEFAULT_NEAR_METHODS.NEAR_SIGN_AND_SEND_TRANSACTION, params: { transaction } },
262
- topic: session.topic,
263
- });
264
- // Return dummy hash and result
265
- return [new Uint8Array(32), result];
266
- },
267
- } as NearSigner;
268
-
269
- const toolbox = await getNearToolbox({ signer });
270
- return toolbox;
271
- }
272
-
273
- case Chain.Tron: {
274
- const { createTronToolbox } = await import("@swapkit/toolboxes/tron");
275
- const { DEFAULT_TRON_METHODS } = await import("./constants");
276
-
277
- // Create a Tron signer that uses WalletConnect
278
- const signer: TronSigner = {
279
- getAddress() {
280
- return Promise.resolve(address);
281
- },
282
-
283
- async signTransaction(transaction: TronTransaction) {
284
- if (!walletconnect) {
285
- throw new SwapKitError("wallet_walletconnect_connection_not_established");
286
- }
287
-
288
- const signedTx = await walletconnect.client.request({
289
- chainId: chainToChainId(Chain.Tron),
290
- request: { method: DEFAULT_TRON_METHODS.TRON_SIGN_TRANSACTION, params: { transaction } },
291
- topic: session.topic,
292
- });
293
-
294
- return signedTx as TronSignedTransaction;
295
- },
296
- };
297
-
298
- const toolbox = await createTronToolbox({ signer });
299
- return toolbox;
300
- }
301
-
302
- default:
303
- throw new SwapKitError({
304
- errorKey: "wallet_chain_not_supported",
305
- info: { chain, wallet: WalletOption.WALLETCONNECT },
306
- });
307
- }
308
- }
309
-
310
- async function getWalletconnect(
311
- chains: Chain[],
312
- walletConnectProjectId: string,
313
- walletconnectOptions?: SignClientTypes.Options,
314
- ) {
315
- let modal: WalletConnectModal | undefined;
316
- let signer: typeof SignClient | undefined;
317
- let session: SessionTypes.Struct | undefined;
318
- let accounts: string[] | undefined;
319
- try {
320
- const requiredNamespaces = getRequiredNamespaces(chains.map(chainToChainId));
321
-
322
- const { SignClient } = await import("@walletconnect/sign-client");
323
- const { WalletConnectModal } = await import("@walletconnect/modal");
324
-
325
- const client = await SignClient.init({
326
- logger: DEFAULT_LOGGER,
327
- metadata: walletconnectOptions?.metadata || DEFAULT_APP_METADATA,
328
- projectId: walletConnectProjectId,
329
- relayUrl: DEFAULT_RELAY_URL,
330
- ...walletconnectOptions?.core,
331
- });
332
-
333
- const modal = new WalletConnectModal({
334
- logger: DEFAULT_LOGGER,
335
- projectId: walletConnectProjectId,
336
- relayUrl: DEFAULT_RELAY_URL,
337
- ...walletconnectOptions?.core,
338
- });
339
-
340
- const oldSession = (await client.session.getAll())[0];
341
-
342
- // disconnect old Session cause we can't handle using it with current ui
343
- if (oldSession) {
344
- await client.disconnect({ reason: { code: 0, message: "Resetting session" }, topic: oldSession.topic });
345
- }
346
-
347
- const { uri, approval } = await client.connect({
348
- // Optionally: pass a known prior pairing (e.g. from `client.core.pairing.getPairings()`) to skip the `uri` step.
349
- // pairingTopic: pairing?.topic,
350
- // Provide the namespaces and chains (e.g. `eip155` for EVM-based chains) we want to use in this session.
351
- requiredNamespaces,
352
- });
353
-
354
- if (uri) {
355
- modal.openModal({ uri });
356
- // Await session approval from the wallet.
357
- session = await approval();
358
- // Handle the returned session (e.g. update UI to "connected" state).
359
- // Close the QRCode modal in case it was open.
360
- modal.closeModal();
361
-
362
- function extractAccountsFromSession(session: SessionTypes.Struct) {
363
- const accounts: string[] = [];
364
-
365
- for (const [_namespace, data] of Object.entries(session.namespaces)) {
366
- accounts.push(...data.accounts);
367
- }
368
-
369
- return accounts;
370
- }
371
-
372
- accounts = extractAccountsFromSession(session);
373
- }
374
-
375
- const disconnect = async () => {
376
- session && (await client.disconnect({ reason: { code: 0, message: "User disconnected" }, topic: session.topic }));
377
- };
378
-
379
- if (!session) {
380
- throw new SwapKitError("wallet_walletconnect_connection_not_established");
381
- }
382
-
383
- return { accounts, client, disconnect, session, signer };
384
- } catch {
385
- // Errors are handled by returning undefined
386
- } finally {
387
- if (modal) {
388
- modal.closeModal();
389
- }
390
- }
391
- return undefined;
392
- }
@@ -1,80 +0,0 @@
1
- import { SwapKitError } from "@swapkit/helpers";
2
- import type { ProposalTypes } from "@walletconnect/types";
3
- import {
4
- DEFAULT_COSMOS_METHODS,
5
- DEFAULT_EIP_155_EVENTS,
6
- DEFAULT_EIP155_METHODS,
7
- DEFAULT_NEAR_EVENTS,
8
- DEFAULT_NEAR_METHODS,
9
- DEFAULT_POLKADOT_EVENTS,
10
- DEFAULT_POLKADOT_METHODS,
11
- DEFAULT_SOLANA_EVENTS,
12
- DEFAULT_SOLANA_METHODS,
13
- DEFAULT_TRON_EVENTS,
14
- DEFAULT_TRON_METHODS,
15
- } from "./constants";
16
-
17
- export const getNamespacesFromChains = (chains: string[]) => {
18
- const supportedNamespaces: string[] = [];
19
- for (const chainId of chains) {
20
- const [namespace] = chainId.split(":");
21
- if (namespace && !supportedNamespaces.includes(namespace)) {
22
- supportedNamespaces.push(namespace);
23
- }
24
- }
25
-
26
- return supportedNamespaces;
27
- };
28
-
29
- export const getSupportedMethodsByNamespace = (namespace: string) => {
30
- switch (namespace) {
31
- case "eip155":
32
- return Object.values(DEFAULT_EIP155_METHODS);
33
- case "cosmos":
34
- return Object.values(DEFAULT_COSMOS_METHODS);
35
- case "solana":
36
- return Object.values(DEFAULT_SOLANA_METHODS);
37
- case "polkadot":
38
- return Object.values(DEFAULT_POLKADOT_METHODS);
39
- case "near":
40
- return Object.values(DEFAULT_NEAR_METHODS);
41
- case "tron":
42
- return Object.values(DEFAULT_TRON_METHODS);
43
- default:
44
- throw new SwapKitError({ errorKey: "wallet_walletconnect_namespace_not_supported", info: { namespace } });
45
- }
46
- };
47
-
48
- export const getSupportedEventsByNamespace = (namespace: string) => {
49
- switch (namespace) {
50
- case "eip155":
51
- return Object.values(DEFAULT_EIP_155_EVENTS);
52
- case "cosmos":
53
- return [];
54
- case "solana":
55
- return Object.values(DEFAULT_SOLANA_EVENTS);
56
- case "polkadot":
57
- return Object.values(DEFAULT_POLKADOT_EVENTS);
58
- case "near":
59
- return Object.values(DEFAULT_NEAR_EVENTS);
60
- case "tron":
61
- return Object.values(DEFAULT_TRON_EVENTS);
62
- default:
63
- throw new SwapKitError({ errorKey: "wallet_walletconnect_namespace_not_supported", info: { namespace } });
64
- }
65
- };
66
-
67
- export const getRequiredNamespaces = (chains: string[]): ProposalTypes.RequiredNamespaces => {
68
- const selectedNamespaces = getNamespacesFromChains(chains);
69
-
70
- return Object.fromEntries(
71
- selectedNamespaces.map((namespace) => [
72
- namespace,
73
- {
74
- chains: chains.filter((chain) => chain.startsWith(namespace)),
75
- events: getSupportedEventsByNamespace(namespace) as any[],
76
- methods: getSupportedMethodsByNamespace(namespace),
77
- },
78
- ]),
79
- );
80
- };
@@ -1,6 +0,0 @@
1
- export interface ClientMetadata {
2
- name: string;
3
- description: string;
4
- url: string;
5
- icons: string[];
6
- }
@@ -1,54 +0,0 @@
1
- import { type AssetValue, Chain, SwapKitError } from "@swapkit/helpers";
2
- import type { Xumm } from "xumm";
3
- import { sendXamanTransaction } from "./walletMethods";
4
-
5
- interface GetWalletForChainParams {
6
- chain: Chain;
7
- address: string;
8
- xumm: Xumm;
9
- }
10
-
11
- export async function getWalletForChain({ xumm, chain, address }: GetWalletForChainParams) {
12
- switch (chain) {
13
- case Chain.Ripple: {
14
- const { getRippleToolbox } = await import("@swapkit/toolboxes/ripple");
15
-
16
- // const api = apis?.[chain]; // Unused for now
17
- const toolbox = await getRippleToolbox({});
18
-
19
- // Override transfer method to use Xaman transaction flow
20
- const transfer = async (params: { assetValue: AssetValue; recipient: string; memo?: string }) => {
21
- const { recipient, assetValue, memo } = params;
22
-
23
- // Create and subscribe to payment via Xaman
24
- const paymentResult = await sendXamanTransaction(xumm, {
25
- amount: assetValue.getValue("string"),
26
- destination: recipient,
27
- from: address,
28
- memo: memo,
29
- });
30
-
31
- // If not successful or no transaction ID, throw error
32
- if (!(paymentResult.result.success && paymentResult.result.transactionId)) {
33
- throw new SwapKitError("wallet_xaman_transaction_failed");
34
- }
35
-
36
- // Return the transaction ID string
37
- return paymentResult.result.transactionId;
38
- };
39
-
40
- return {
41
- ...toolbox,
42
- address,
43
- // Expose Xaman-specific methods
44
- createAndSubscribePayment: sendXamanTransaction,
45
- disconnect: xumm.logout,
46
- getAddress: () => address,
47
- transfer,
48
- };
49
- }
50
-
51
- default:
52
- throw new SwapKitError("wallet_chain_not_supported", { chain, wallet: "Xaman" });
53
- }
54
- }
@@ -1,62 +0,0 @@
1
- import { Chain, filterSupportedChains, SKConfig, SwapKitError, WalletOption } from "@swapkit/helpers";
2
- import { createWallet, getWalletSupportedChains } from "@swapkit/wallet-core";
3
- import { Xumm } from "xumm";
4
- import { getWalletForChain } from "./helpers";
5
- import type { XamanConfig } from "./types";
6
- import { connectXamanWallet as connectXamanWalletMethod } from "./walletMethods";
7
-
8
- export const xamanWallet = createWallet({
9
- connect: ({ addChain, supportedChains: walletSupportedChains, walletType }) =>
10
- function connectXamanWallet(chains: Chain[], xamanConfigOverwrite?: XamanConfig) {
11
- const supportedChains = filterSupportedChains({ chains, supportedChains: walletSupportedChains, walletType });
12
-
13
- const { xaman: xamanApiKey } = SKConfig.get("apiKeys");
14
- const apiKey = xamanConfigOverwrite?.apiKey || xamanApiKey;
15
-
16
- if (!apiKey) {
17
- throw new SwapKitError("wallet_missing_api_key", { wallet: "Xaman" });
18
- }
19
-
20
- const xumm = new Xumm(apiKey);
21
-
22
- return new Promise<boolean>((resolve, reject) => {
23
- xumm.on("success", async () => {
24
- try {
25
- const address = await connectXamanWalletMethod(xumm);
26
-
27
- const promises = supportedChains.map(async (chain) => {
28
- const walletMethods = await getWalletForChain({ address, chain, xumm });
29
-
30
- addChain({
31
- ...walletMethods,
32
- address,
33
- balance: [],
34
- chain,
35
- disconnect: xumm.logout,
36
- walletType: WalletOption.XAMAN,
37
- });
38
- });
39
-
40
- await Promise.all(promises);
41
- resolve(true);
42
- } catch (error) {
43
- reject(error);
44
- }
45
- });
46
-
47
- xumm.on("error", (error) => {
48
- reject(error);
49
- });
50
-
51
- xumm.authorize();
52
- });
53
- },
54
- name: "connectXaman",
55
- supportedChains: [Chain.Ripple],
56
- walletType: WalletOption.XAMAN,
57
- });
58
-
59
- export const XAMAN_SUPPORTED_CHAINS = getWalletSupportedChains(xamanWallet);
60
- export type XamanSupportedChain = (typeof XAMAN_SUPPORTED_CHAINS)[number];
61
-
62
- export type { XamanConfig } from "./types";
@@ -1,26 +0,0 @@
1
- export interface XamanConfig {
2
- apiKey: string;
3
- }
4
-
5
- export interface XamanPaymentParams {
6
- destination: string;
7
- from: string;
8
- amount: string;
9
- memo?: string;
10
- destinationTag?: number;
11
- }
12
-
13
- export interface XamanPaymentResult {
14
- payloadId: string;
15
- qrCode: string;
16
- deepLink: string;
17
- websocketUrl: string;
18
- result: XamanTransactionResult;
19
- }
20
-
21
- export interface XamanTransactionResult {
22
- success: boolean;
23
- transactionId?: string;
24
- account?: string;
25
- reason?: string;
26
- }