@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.
Files changed (210) hide show
  1. package/dist/chunk-6dcwbjsg.js +5 -0
  2. package/dist/chunk-6dcwbjsg.js.map +10 -0
  3. package/dist/chunk-78m70510.js +5 -0
  4. package/dist/chunk-78m70510.js.map +9 -0
  5. package/dist/chunk-vb4wtm2w.js +4 -0
  6. package/dist/chunk-vb4wtm2w.js.map +9 -0
  7. package/dist/chunk-y6rjn578.js +4 -0
  8. package/dist/chunk-y6rjn578.js.map +10 -0
  9. package/dist/src/bitget.cjs +4 -0
  10. package/dist/src/bitget.cjs.map +10 -0
  11. package/dist/src/bitget.js +4 -0
  12. package/dist/src/bitget.js.map +10 -0
  13. package/dist/src/coinbase/index.cjs +4 -0
  14. package/dist/src/coinbase/index.cjs.map +11 -0
  15. package/dist/src/coinbase/index.js +4 -0
  16. package/dist/src/coinbase/index.js.map +11 -0
  17. package/dist/src/cosmostation.cjs +4 -0
  18. package/dist/src/cosmostation.cjs.map +10 -0
  19. package/dist/src/cosmostation.js +4 -0
  20. package/dist/src/cosmostation.js.map +10 -0
  21. package/dist/src/ctrl.cjs +4 -0
  22. package/dist/src/ctrl.cjs.map +10 -0
  23. package/dist/src/ctrl.js +4 -0
  24. package/dist/src/ctrl.js.map +10 -0
  25. package/dist/src/evm-extensions.cjs +4 -0
  26. package/dist/src/evm-extensions.cjs.map +10 -0
  27. package/dist/src/evm-extensions.js +4 -0
  28. package/dist/src/evm-extensions.js.map +10 -0
  29. package/dist/src/index.cjs +4 -0
  30. package/dist/src/index.cjs.map +11 -0
  31. package/dist/src/index.js +4 -0
  32. package/dist/src/index.js.map +11 -0
  33. package/dist/src/keepkey-bex.cjs +4 -0
  34. package/dist/src/keepkey-bex.cjs.map +10 -0
  35. package/dist/src/keepkey-bex.js +4 -0
  36. package/dist/src/keepkey-bex.js.map +10 -0
  37. package/dist/src/keepkey.cjs +4 -0
  38. package/dist/src/keepkey.cjs.map +10 -0
  39. package/dist/src/keepkey.js +4 -0
  40. package/dist/src/keepkey.js.map +10 -0
  41. package/dist/src/keplr.cjs +4 -0
  42. package/dist/src/keplr.cjs.map +10 -0
  43. package/dist/src/keplr.js +4 -0
  44. package/dist/src/keplr.js.map +10 -0
  45. package/dist/src/keystore.cjs +4 -0
  46. package/dist/src/keystore.cjs.map +10 -0
  47. package/dist/src/keystore.js +4 -0
  48. package/dist/src/keystore.js.map +10 -0
  49. package/dist/src/ledger.cjs +4 -0
  50. package/dist/src/ledger.cjs.map +10 -0
  51. package/dist/src/ledger.js +4 -0
  52. package/dist/src/ledger.js.map +10 -0
  53. package/dist/src/near-wallet-selector/index.cjs +4 -0
  54. package/dist/src/near-wallet-selector/index.cjs.map +10 -0
  55. package/dist/src/near-wallet-selector/index.js +4 -0
  56. package/dist/src/near-wallet-selector/index.js.map +10 -0
  57. package/dist/src/okx.cjs +4 -0
  58. package/dist/src/okx.cjs.map +10 -0
  59. package/dist/src/okx.js +4 -0
  60. package/dist/src/okx.js.map +10 -0
  61. package/dist/src/onekey.cjs +4 -0
  62. package/dist/src/onekey.cjs.map +10 -0
  63. package/dist/src/onekey.js +4 -0
  64. package/dist/src/onekey.js.map +10 -0
  65. package/dist/src/passkeys/index.cjs +4 -0
  66. package/dist/src/passkeys/index.cjs.map +10 -0
  67. package/dist/src/passkeys/index.js +4 -0
  68. package/dist/src/passkeys/index.js.map +10 -0
  69. package/dist/src/phantom.cjs +4 -0
  70. package/dist/src/phantom.cjs.map +10 -0
  71. package/dist/src/phantom.js +4 -0
  72. package/dist/src/phantom.js.map +10 -0
  73. package/dist/src/polkadotjs.cjs +4 -0
  74. package/dist/src/polkadotjs.cjs.map +10 -0
  75. package/dist/src/polkadotjs.js +4 -0
  76. package/dist/src/polkadotjs.js.map +10 -0
  77. package/dist/src/radix/index.cjs +4 -0
  78. package/dist/src/radix/index.cjs.map +10 -0
  79. package/dist/src/radix/index.js +4 -0
  80. package/dist/src/radix/index.js.map +10 -0
  81. package/dist/src/talisman.cjs +4 -0
  82. package/dist/src/talisman.cjs.map +10 -0
  83. package/dist/src/talisman.js +4 -0
  84. package/dist/src/talisman.js.map +10 -0
  85. package/dist/src/trezor.cjs +4 -0
  86. package/dist/src/trezor.cjs.map +10 -0
  87. package/dist/src/trezor.js +4 -0
  88. package/dist/src/trezor.js.map +10 -0
  89. package/dist/src/tronlink.cjs +4 -0
  90. package/dist/src/tronlink.cjs.map +10 -0
  91. package/dist/src/tronlink.js +4 -0
  92. package/dist/src/tronlink.js.map +10 -0
  93. package/dist/src/vultisig.cjs +4 -0
  94. package/dist/src/vultisig.cjs.map +10 -0
  95. package/dist/src/vultisig.js +4 -0
  96. package/dist/src/vultisig.js.map +10 -0
  97. package/dist/src/walletconnect/index.cjs +4 -0
  98. package/dist/src/walletconnect/index.cjs.map +13 -0
  99. package/dist/src/walletconnect/index.js +4 -0
  100. package/dist/src/walletconnect/index.js.map +13 -0
  101. package/dist/src/xaman/index.cjs +4 -0
  102. package/dist/src/xaman/index.cjs.map +12 -0
  103. package/dist/src/xaman/index.js +4 -0
  104. package/dist/src/xaman/index.js.map +12 -0
  105. package/dist/types/bitget.d.ts +2 -0
  106. package/dist/types/bitget.d.ts.map +1 -0
  107. package/dist/types/coinbase/index.d.ts +14 -0
  108. package/dist/types/coinbase/index.d.ts.map +1 -0
  109. package/dist/types/coinbase/signer.d.ts +313 -0
  110. package/dist/types/coinbase/signer.d.ts.map +1 -0
  111. package/dist/types/cosmostation.d.ts +2 -0
  112. package/dist/types/cosmostation.d.ts.map +1 -0
  113. package/dist/types/ctrl.d.ts +2 -0
  114. package/dist/types/ctrl.d.ts.map +1 -0
  115. package/dist/types/evm-extensions.d.ts +2 -0
  116. package/dist/types/evm-extensions.d.ts.map +1 -0
  117. package/dist/types/index.d.ts +4 -0
  118. package/dist/types/index.d.ts.map +1 -0
  119. package/dist/types/keepkey-bex.d.ts +2 -0
  120. package/dist/types/keepkey-bex.d.ts.map +1 -0
  121. package/dist/types/keepkey.d.ts +2 -0
  122. package/dist/types/keepkey.d.ts.map +1 -0
  123. package/dist/types/keplr.d.ts +2 -0
  124. package/dist/types/keplr.d.ts.map +1 -0
  125. package/dist/types/keystore.d.ts +2 -0
  126. package/dist/types/keystore.d.ts.map +1 -0
  127. package/dist/types/ledger.d.ts +2 -0
  128. package/dist/types/ledger.d.ts.map +1 -0
  129. package/dist/types/near-wallet-selector/index.d.ts +16 -0
  130. package/dist/types/near-wallet-selector/index.d.ts.map +1 -0
  131. package/dist/types/okx.d.ts +2 -0
  132. package/dist/types/okx.d.ts.map +1 -0
  133. package/dist/types/onekey.d.ts +2 -0
  134. package/dist/types/onekey.d.ts.map +1 -0
  135. package/dist/types/passkeys/index.d.ts +17 -0
  136. package/dist/types/passkeys/index.d.ts.map +1 -0
  137. package/dist/types/phantom.d.ts +2 -0
  138. package/dist/types/phantom.d.ts.map +1 -0
  139. package/dist/types/polkadotjs.d.ts +2 -0
  140. package/dist/types/polkadotjs.d.ts.map +1 -0
  141. package/dist/types/radix/index.d.ts +14 -0
  142. package/dist/types/radix/index.d.ts.map +1 -0
  143. package/dist/types/talisman.d.ts +2 -0
  144. package/dist/types/talisman.d.ts.map +1 -0
  145. package/dist/types/trezor.d.ts +2 -0
  146. package/dist/types/trezor.d.ts.map +1 -0
  147. package/dist/types/tronlink.d.ts +2 -0
  148. package/dist/types/tronlink.d.ts.map +1 -0
  149. package/dist/types/types.d.ts +92 -0
  150. package/dist/types/types.d.ts.map +1 -0
  151. package/dist/types/utils.d.ts +4 -0
  152. package/dist/types/utils.d.ts.map +1 -0
  153. package/dist/types/vultisig.d.ts +2 -0
  154. package/dist/types/vultisig.d.ts.map +1 -0
  155. package/dist/types/walletconnect/constants.d.ts +89 -0
  156. package/dist/types/walletconnect/constants.d.ts.map +1 -0
  157. package/dist/types/walletconnect/evmSigner.d.ts +28 -0
  158. package/dist/types/walletconnect/evmSigner.d.ts.map +1 -0
  159. package/dist/types/walletconnect/helpers.d.ts +7 -0
  160. package/dist/types/walletconnect/helpers.d.ts.map +1 -0
  161. package/dist/types/walletconnect/index.d.ts +25 -0
  162. package/dist/types/walletconnect/index.d.ts.map +1 -0
  163. package/dist/types/walletconnect/namespaces.d.ts +10 -0
  164. package/dist/types/walletconnect/namespaces.d.ts.map +1 -0
  165. package/dist/types/walletconnect/types.d.ts +7 -0
  166. package/dist/types/walletconnect/types.d.ts.map +1 -0
  167. package/dist/types/xaman/helpers.d.ts +59 -0
  168. package/dist/types/xaman/helpers.d.ts.map +1 -0
  169. package/dist/types/xaman/index.d.ts +17 -0
  170. package/dist/types/xaman/index.d.ts.map +1 -0
  171. package/dist/types/xaman/types.d.ts +24 -0
  172. package/dist/types/xaman/types.d.ts.map +1 -0
  173. package/dist/types/xaman/walletMethods.d.ts +19 -0
  174. package/dist/types/xaman/walletMethods.d.ts.map +1 -0
  175. package/package.json +220 -0
  176. package/src/bitget.ts +1 -0
  177. package/src/coinbase/index.ts +48 -0
  178. package/src/coinbase/signer.ts +81 -0
  179. package/src/cosmostation.ts +1 -0
  180. package/src/ctrl.ts +1 -0
  181. package/src/evm-extensions.ts +1 -0
  182. package/src/index.ts +3 -0
  183. package/src/keepkey-bex.ts +1 -0
  184. package/src/keepkey.ts +1 -0
  185. package/src/keplr.ts +1 -0
  186. package/src/keystore.ts +1 -0
  187. package/src/ledger.ts +1 -0
  188. package/src/near-wallet-selector/index.ts +116 -0
  189. package/src/okx.ts +1 -0
  190. package/src/onekey.ts +1 -0
  191. package/src/passkeys/index.ts +187 -0
  192. package/src/phantom.ts +1 -0
  193. package/src/polkadotjs.ts +1 -0
  194. package/src/radix/index.ts +198 -0
  195. package/src/talisman.ts +1 -0
  196. package/src/trezor.ts +1 -0
  197. package/src/tronlink.ts +1 -0
  198. package/src/types.ts +94 -0
  199. package/src/utils.ts +59 -0
  200. package/src/vultisig.ts +1 -0
  201. package/src/walletconnect/constants.ts +109 -0
  202. package/src/walletconnect/evmSigner.ts +129 -0
  203. package/src/walletconnect/helpers.ts +77 -0
  204. package/src/walletconnect/index.ts +396 -0
  205. package/src/walletconnect/namespaces.ts +84 -0
  206. package/src/walletconnect/types.ts +6 -0
  207. package/src/xaman/helpers.ts +58 -0
  208. package/src/xaman/index.ts +66 -0
  209. package/src/xaman/types.ts +26 -0
  210. package/src/xaman/walletMethods.ts +114 -0
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Modifications © 2025 Horizontal Systems.
3
+ */
4
+
5
+ import { type AssetValue, Chain, USwapError } from "@tcswap/helpers";
6
+ import type { Xumm } from "xumm";
7
+ import { sendXamanTransaction } from "./walletMethods";
8
+
9
+ interface GetWalletForChainParams {
10
+ chain: Chain;
11
+ address: string;
12
+ xumm: Xumm;
13
+ }
14
+
15
+ export async function getWalletForChain({ xumm, chain, address }: GetWalletForChainParams) {
16
+ switch (chain) {
17
+ case Chain.Ripple: {
18
+ const { getRippleToolbox } = await import("@tcswap/toolboxes/ripple");
19
+
20
+ // const api = apis?.[chain]; // Unused for now
21
+ const toolbox = await getRippleToolbox({});
22
+
23
+ // Override transfer method to use Xaman transaction flow
24
+ const transfer = async (params: { assetValue: AssetValue; recipient: string; memo?: string }) => {
25
+ const { recipient, assetValue, memo } = params;
26
+
27
+ // Create and subscribe to payment via Xaman
28
+ const paymentResult = await sendXamanTransaction(xumm, {
29
+ amount: assetValue.getValue("string"),
30
+ destination: recipient,
31
+ from: address,
32
+ memo: memo,
33
+ });
34
+
35
+ // If not successful or no transaction ID, throw error
36
+ if (!(paymentResult.result.success && paymentResult.result.transactionId)) {
37
+ throw new USwapError("wallet_xaman_transaction_failed");
38
+ }
39
+
40
+ // Return the transaction ID string
41
+ return paymentResult.result.transactionId;
42
+ };
43
+
44
+ return {
45
+ ...toolbox,
46
+ address,
47
+ // Expose Xaman-specific methods
48
+ createAndSubscribePayment: sendXamanTransaction,
49
+ disconnect: xumm.logout,
50
+ getAddress: () => address,
51
+ transfer,
52
+ };
53
+ }
54
+
55
+ default:
56
+ throw new USwapError("wallet_chain_not_supported", { chain, wallet: "Xaman" });
57
+ }
58
+ }
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Modifications © 2025 Horizontal Systems.
3
+ */
4
+
5
+ import { Chain, filterSupportedChains, USwapConfig, USwapError, WalletOption } from "@tcswap/helpers";
6
+ import { createWallet, getWalletSupportedChains } from "@tcswap/wallet-core";
7
+ import { Xumm } from "xumm";
8
+ import { getWalletForChain } from "./helpers";
9
+ import type { XamanConfig } from "./types";
10
+ import { connectXamanWallet as connectXamanWalletMethod } from "./walletMethods";
11
+
12
+ export const xamanWallet = createWallet({
13
+ connect: ({ addChain, supportedChains: walletSupportedChains, walletType }) =>
14
+ function connectXamanWallet(chains: Chain[], xamanConfigOverwrite?: XamanConfig) {
15
+ const supportedChains = filterSupportedChains({ chains, supportedChains: walletSupportedChains, walletType });
16
+
17
+ const { xaman: xamanApiKey } = USwapConfig.get("apiKeys");
18
+ const apiKey = xamanConfigOverwrite?.apiKey || xamanApiKey;
19
+
20
+ if (!apiKey) {
21
+ throw new USwapError("wallet_missing_api_key", { wallet: "Xaman" });
22
+ }
23
+
24
+ const xumm = new Xumm(apiKey);
25
+
26
+ return new Promise<boolean>((resolve, reject) => {
27
+ xumm.on("success", async () => {
28
+ try {
29
+ const address = await connectXamanWalletMethod(xumm);
30
+
31
+ const promises = supportedChains.map(async (chain) => {
32
+ const walletMethods = await getWalletForChain({ address, chain, xumm });
33
+
34
+ addChain({
35
+ ...walletMethods,
36
+ address,
37
+ balance: [],
38
+ chain,
39
+ disconnect: xumm.logout,
40
+ walletType: WalletOption.XAMAN,
41
+ });
42
+ });
43
+
44
+ await Promise.all(promises);
45
+ resolve(true);
46
+ } catch (error) {
47
+ reject(error);
48
+ }
49
+ });
50
+
51
+ xumm.on("error", (error) => {
52
+ reject(error);
53
+ });
54
+
55
+ xumm.authorize();
56
+ });
57
+ },
58
+ name: "connectXaman",
59
+ supportedChains: [Chain.Ripple],
60
+ walletType: WalletOption.XAMAN,
61
+ });
62
+
63
+ export const XAMAN_SUPPORTED_CHAINS = getWalletSupportedChains(xamanWallet);
64
+ export type XamanSupportedChain = (typeof XAMAN_SUPPORTED_CHAINS)[number];
65
+
66
+ export type { XamanConfig } from "./types";
@@ -0,0 +1,26 @@
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
+ }
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Modifications © 2025 Horizontal Systems.
3
+ */
4
+
5
+ import { USwapError } from "@tcswap/helpers";
6
+ import type { Xumm } from "xumm";
7
+ import type { XamanPaymentParams } from "./types";
8
+
9
+ export const connectXamanWallet = async (xumm: Xumm) => {
10
+ if (!xumm) {
11
+ throw new USwapError("wallet_xaman_not_configured");
12
+ }
13
+
14
+ try {
15
+ const user = await xumm.user;
16
+ const account = await user?.account;
17
+
18
+ if (account) {
19
+ return account;
20
+ }
21
+
22
+ throw new USwapError("wallet_xaman_auth_failed");
23
+ } catch (error) {
24
+ console.error("Xaman wallet connection failed:", error);
25
+ throw new USwapError("wallet_xaman_connection_failed");
26
+ }
27
+ };
28
+
29
+ export const sendXamanTransaction = async (xumm: Xumm, params: XamanPaymentParams) => {
30
+ try {
31
+ // Validate required parameters
32
+ if (!(params.destination && params.amount && params.from)) {
33
+ throw new USwapError("wallet_xaman_connection_failed");
34
+ }
35
+
36
+ // Convert XRP to drops (1 XRP = 1,000,000 drops)
37
+ const amountInDrops = (Number.parseFloat(params.amount) * 1000000).toString();
38
+
39
+ // Create transaction object
40
+ const transaction = {
41
+ Account: params.from,
42
+ Amount: amountInDrops,
43
+ Destination: params.destination,
44
+ TransactionType: "Payment" as const,
45
+ ...(params.destinationTag !== undefined && { DestinationTag: params.destinationTag }),
46
+ ...(params.memo && {
47
+ Memos: [{ Memo: { MemoData: Buffer.from(params.memo, "utf8").toString("hex").toUpperCase() } }],
48
+ }),
49
+ };
50
+
51
+ // Create and subscribe to payload following the official example
52
+ const subscription = await xumm.payload?.createAndSubscribe(transaction, (event) => {
53
+ if ("signed" in event.data) {
54
+ // Return event.data to close subscription and resolve promise
55
+ return event.data; // { signed: true|false, payload_uuidv4: '...' }
56
+ }
57
+ return undefined;
58
+ });
59
+
60
+ if (!subscription) {
61
+ throw new USwapError("wallet_xaman_transaction_failed");
62
+ }
63
+
64
+ const { created } = subscription;
65
+
66
+ // Handle payload presentation based on runtime environment
67
+ if (xumm.runtime?.xapp) {
68
+ xumm.xapp?.openSignRequest(created);
69
+ } else if (typeof window !== "undefined") {
70
+ const url =
71
+ created.pushed && created.next?.no_push_msg_received ? created.next.no_push_msg_received : created.next?.always;
72
+ if (url) window.open(url);
73
+ }
74
+
75
+ // Wait until the user signed/rejected
76
+ const resolved = await subscription.resolved;
77
+
78
+ if (!resolved || typeof resolved !== "object" || !("signed" in resolved) || !resolved.signed) {
79
+ throw new USwapError("wallet_xaman_transaction_failed");
80
+ }
81
+
82
+ // Fetch the full payload result using the UUID from resolved data
83
+ const payloadDetails = await xumm.payload?.get((resolved as any).payload_uuidv4);
84
+
85
+ if (!payloadDetails) {
86
+ throw new USwapError("wallet_xaman_monitoring_failed");
87
+ }
88
+
89
+ // Extract transaction ID from response
90
+ const transactionId = payloadDetails.response?.txid || "";
91
+ const account = payloadDetails.response?.account || "";
92
+
93
+ if (!transactionId) {
94
+ throw new USwapError("wallet_xaman_transaction_failed");
95
+ }
96
+
97
+ // Return comprehensive result
98
+ return {
99
+ deepLink: created.next?.always || "",
100
+ // Initial payload info for QR codes, deep links, etc.
101
+ payloadId: created.uuid || "",
102
+ qrCode: created.refs?.qr_png || "",
103
+ // Final transaction result - SUCCESS with tx hash
104
+ result: { account, reason: undefined, success: true, transactionId },
105
+ websocketUrl: created.refs?.websocket_status || "",
106
+ };
107
+ } catch (error) {
108
+ console.error("Xaman payment creation and subscription failed:", error);
109
+ if (error instanceof USwapError) {
110
+ throw error;
111
+ }
112
+ throw new USwapError("wallet_xaman_transaction_failed");
113
+ }
114
+ };