@swapkit/wallets 4.0.0-beta.54 → 4.0.0-beta.56

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 (294) hide show
  1. package/dist/{chunk-e674mh4n.js → chunk-mcrgqfr9.js} +3 -3
  2. package/dist/{chunk-e674mh4n.js.map → chunk-mcrgqfr9.js.map} +1 -1
  3. package/dist/{chunk-mvbb9fwb.js → chunk-sbf0f2p4.js} +2 -2
  4. package/dist/{chunk-p2ca0j1v.js → chunk-yqaz2d25.js} +3 -3
  5. package/dist/{chunk-p2ca0j1v.js.map → chunk-yqaz2d25.js.map} +1 -1
  6. package/dist/src/bitget/index.cjs +2 -2
  7. package/dist/src/bitget/index.cjs.map +3 -3
  8. package/dist/src/bitget/index.js +2 -2
  9. package/dist/src/bitget/index.js.map +3 -3
  10. package/dist/src/coinbase/index.cjs +2 -2
  11. package/dist/src/coinbase/index.cjs.map +3 -3
  12. package/dist/src/coinbase/index.js +2 -2
  13. package/dist/src/coinbase/index.js.map +3 -3
  14. package/dist/src/cosmostation/index.cjs +2 -2
  15. package/dist/src/cosmostation/index.cjs.map +3 -3
  16. package/dist/src/cosmostation/index.js +2 -2
  17. package/dist/src/cosmostation/index.js.map +3 -3
  18. package/dist/src/ctrl/index.cjs +2 -2
  19. package/dist/src/ctrl/index.cjs.map +3 -3
  20. package/dist/src/ctrl/index.js +2 -2
  21. package/dist/src/ctrl/index.js.map +3 -3
  22. package/dist/src/evm-extensions/index.cjs +2 -2
  23. package/dist/src/evm-extensions/index.cjs.map +3 -3
  24. package/dist/src/evm-extensions/index.js +2 -2
  25. package/dist/src/evm-extensions/index.js.map +3 -3
  26. package/dist/src/exodus/index.cjs +2 -2
  27. package/dist/src/exodus/index.cjs.map +3 -3
  28. package/dist/src/exodus/index.js +2 -2
  29. package/dist/src/exodus/index.js.map +3 -3
  30. package/dist/src/index.cjs +2 -2
  31. package/dist/src/index.cjs.map +5 -3
  32. package/dist/src/index.js +2 -2
  33. package/dist/src/index.js.map +5 -3
  34. package/dist/src/keepkey-bex/index.cjs +2 -2
  35. package/dist/src/keepkey-bex/index.cjs.map +3 -3
  36. package/dist/src/keepkey-bex/index.js +2 -2
  37. package/dist/src/keepkey-bex/index.js.map +3 -3
  38. package/dist/src/keepkey.cjs +4 -0
  39. package/dist/src/keepkey.cjs.map +10 -0
  40. package/dist/src/keepkey.js +4 -0
  41. package/dist/src/keepkey.js.map +10 -0
  42. package/dist/src/keplr/index.cjs +2 -2
  43. package/dist/src/keplr/index.cjs.map +3 -3
  44. package/dist/src/keplr/index.js +2 -2
  45. package/dist/src/keplr/index.js.map +3 -3
  46. package/dist/src/keystore.cjs +4 -0
  47. package/dist/src/keystore.cjs.map +10 -0
  48. package/dist/src/keystore.js +4 -0
  49. package/dist/src/keystore.js.map +10 -0
  50. package/dist/src/ledger.cjs +4 -0
  51. package/dist/src/ledger.cjs.map +10 -0
  52. package/dist/src/ledger.js +4 -0
  53. package/dist/src/ledger.js.map +10 -0
  54. package/dist/src/okx/index.cjs +2 -2
  55. package/dist/src/okx/index.cjs.map +4 -4
  56. package/dist/src/okx/index.js +2 -2
  57. package/dist/src/okx/index.js.map +4 -4
  58. package/dist/src/onekey/index.cjs +2 -2
  59. package/dist/src/onekey/index.cjs.map +3 -3
  60. package/dist/src/onekey/index.js +2 -2
  61. package/dist/src/onekey/index.js.map +3 -3
  62. package/dist/src/phantom/index.cjs +2 -2
  63. package/dist/src/phantom/index.cjs.map +3 -3
  64. package/dist/src/phantom/index.js +2 -2
  65. package/dist/src/phantom/index.js.map +3 -3
  66. package/dist/src/polkadotjs/index.cjs +2 -2
  67. package/dist/src/polkadotjs/index.cjs.map +3 -3
  68. package/dist/src/polkadotjs/index.js +2 -2
  69. package/dist/src/polkadotjs/index.js.map +3 -3
  70. package/dist/src/radix/index.cjs +2 -2
  71. package/dist/src/radix/index.cjs.map +3 -3
  72. package/dist/src/radix/index.js +2 -2
  73. package/dist/src/radix/index.js.map +3 -3
  74. package/dist/src/talisman/index.cjs +2 -2
  75. package/dist/src/talisman/index.cjs.map +3 -3
  76. package/dist/src/talisman/index.js +2 -2
  77. package/dist/src/talisman/index.js.map +3 -3
  78. package/dist/src/trezor.cjs +4 -0
  79. package/dist/src/trezor.cjs.map +10 -0
  80. package/dist/src/trezor.js +4 -0
  81. package/dist/src/trezor.js.map +10 -0
  82. package/dist/src/tronlink/index.cjs +4 -0
  83. package/dist/src/tronlink/index.cjs.map +11 -0
  84. package/dist/src/tronlink/index.js +4 -0
  85. package/dist/src/tronlink/index.js.map +11 -0
  86. package/dist/src/vultisig/index.cjs +2 -2
  87. package/dist/src/vultisig/index.cjs.map +3 -3
  88. package/dist/src/vultisig/index.js +2 -2
  89. package/dist/src/vultisig/index.js.map +3 -3
  90. package/dist/src/walletconnect/index.cjs +2 -2
  91. package/dist/src/walletconnect/index.cjs.map +3 -3
  92. package/dist/src/walletconnect/index.js +2 -2
  93. package/dist/src/walletconnect/index.js.map +3 -3
  94. package/dist/src/xaman/index.cjs +2 -2
  95. package/dist/src/xaman/index.cjs.map +5 -5
  96. package/dist/src/xaman/index.js +2 -2
  97. package/dist/src/xaman/index.js.map +5 -5
  98. package/dist/types/bitget/helpers.d.ts +330 -0
  99. package/dist/types/bitget/helpers.d.ts.map +1 -0
  100. package/dist/types/bitget/index.d.ts +11 -0
  101. package/dist/types/bitget/index.d.ts.map +1 -0
  102. package/dist/types/coinbase/index.d.ts +11 -0
  103. package/dist/types/coinbase/index.d.ts.map +1 -0
  104. package/dist/types/coinbase/signer.d.ts +91 -0
  105. package/dist/types/coinbase/signer.d.ts.map +1 -0
  106. package/dist/types/cosmostation/index.d.ts +21 -0
  107. package/dist/types/cosmostation/index.d.ts.map +1 -0
  108. package/dist/types/ctrl/index.d.ts +11 -0
  109. package/dist/types/ctrl/index.d.ts.map +1 -0
  110. package/dist/types/ctrl/walletHelpers.d.ts +24 -0
  111. package/dist/types/ctrl/walletHelpers.d.ts.map +1 -0
  112. package/dist/types/evm-extensions/index.d.ts +101 -0
  113. package/dist/types/evm-extensions/index.d.ts.map +1 -0
  114. package/{src/evm-extensions/types.ts → dist/types/evm-extensions/types.d.ts} +11 -13
  115. package/dist/types/evm-extensions/types.d.ts.map +1 -0
  116. package/dist/types/exodus/index.d.ts +14 -0
  117. package/dist/types/exodus/index.d.ts.map +1 -0
  118. package/dist/types/helpers/near.d.ts +57 -0
  119. package/dist/types/helpers/near.d.ts.map +1 -0
  120. package/dist/types/index.d.ts +4 -0
  121. package/dist/types/index.d.ts.map +1 -0
  122. package/dist/types/keepkey-bex/index.d.ts +11 -0
  123. package/dist/types/keepkey-bex/index.d.ts.map +1 -0
  124. package/dist/types/keepkey-bex/walletHelpers.d.ts +45 -0
  125. package/dist/types/keepkey-bex/walletHelpers.d.ts.map +1 -0
  126. package/dist/types/keepkey.d.ts +2 -0
  127. package/dist/types/keepkey.d.ts.map +1 -0
  128. package/dist/types/keplr/chainRegistry.d.ts +4 -0
  129. package/dist/types/keplr/chainRegistry.d.ts.map +1 -0
  130. package/dist/types/keplr/index.d.ts +11 -0
  131. package/dist/types/keplr/index.d.ts.map +1 -0
  132. package/dist/types/keystore.d.ts +2 -0
  133. package/dist/types/keystore.d.ts.map +1 -0
  134. package/dist/types/ledger.d.ts +2 -0
  135. package/dist/types/ledger.d.ts.map +1 -0
  136. package/dist/types/okx/helpers.d.ts +227 -0
  137. package/dist/types/okx/helpers.d.ts.map +1 -0
  138. package/dist/types/okx/index.d.ts +11 -0
  139. package/dist/types/okx/index.d.ts.map +1 -0
  140. package/dist/types/okx/types.d.ts +104 -0
  141. package/dist/types/okx/types.d.ts.map +1 -0
  142. package/dist/types/onekey/evmSigner.d.ts +29 -0
  143. package/dist/types/onekey/evmSigner.d.ts.map +1 -0
  144. package/dist/types/onekey/index.d.ts +11 -0
  145. package/dist/types/onekey/index.d.ts.map +1 -0
  146. package/dist/types/phantom/index.d.ts +12 -0
  147. package/dist/types/phantom/index.d.ts.map +1 -0
  148. package/dist/types/polkadotjs/index.d.ts +11 -0
  149. package/dist/types/polkadotjs/index.d.ts.map +1 -0
  150. package/dist/types/radix/index.d.ts +11 -0
  151. package/dist/types/radix/index.d.ts.map +1 -0
  152. package/dist/types/talisman/index.d.ts +11 -0
  153. package/dist/types/talisman/index.d.ts.map +1 -0
  154. package/dist/types/trezor.d.ts +2 -0
  155. package/dist/types/trezor.d.ts.map +1 -0
  156. package/dist/types/tronlink/helpers.d.ts +24 -0
  157. package/dist/types/tronlink/helpers.d.ts.map +1 -0
  158. package/dist/types/tronlink/index.d.ts +11 -0
  159. package/dist/types/tronlink/index.d.ts.map +1 -0
  160. package/dist/types/tronlink/types.d.ts +59 -0
  161. package/dist/types/tronlink/types.d.ts.map +1 -0
  162. package/dist/types/types.d.ts +249 -0
  163. package/dist/types/types.d.ts.map +1 -0
  164. package/dist/types/utils.d.ts +4 -0
  165. package/dist/types/utils.d.ts.map +1 -0
  166. package/dist/types/vultisig/index.d.ts +11 -0
  167. package/dist/types/vultisig/index.d.ts.map +1 -0
  168. package/dist/types/vultisig/walletHelpers.d.ts +34 -0
  169. package/dist/types/vultisig/walletHelpers.d.ts.map +1 -0
  170. package/dist/types/walletconnect/constants.d.ts +85 -0
  171. package/dist/types/walletconnect/constants.d.ts.map +1 -0
  172. package/dist/types/walletconnect/evmSigner.d.ts +25 -0
  173. package/dist/types/walletconnect/evmSigner.d.ts.map +1 -0
  174. package/dist/types/walletconnect/helpers.d.ts +4 -0
  175. package/dist/types/walletconnect/helpers.d.ts.map +1 -0
  176. package/dist/types/walletconnect/index.d.ts +22 -0
  177. package/dist/types/walletconnect/index.d.ts.map +1 -0
  178. package/dist/types/walletconnect/namespaces.d.ts +7 -0
  179. package/dist/types/walletconnect/namespaces.d.ts.map +1 -0
  180. package/dist/types/walletconnect/types.d.ts +7 -0
  181. package/dist/types/walletconnect/types.d.ts.map +1 -0
  182. package/dist/types/xaman/helpers.d.ts +54 -0
  183. package/dist/types/xaman/helpers.d.ts.map +1 -0
  184. package/dist/types/xaman/index.d.ts +14 -0
  185. package/dist/types/xaman/index.d.ts.map +1 -0
  186. package/dist/types/xaman/types.d.ts +24 -0
  187. package/dist/types/xaman/types.d.ts.map +1 -0
  188. package/dist/types/xaman/walletMethods.d.ts +16 -0
  189. package/dist/types/xaman/walletMethods.d.ts.map +1 -0
  190. package/package.json +53 -74
  191. package/dist/chunk-2aa1w78q.js +0 -4
  192. package/dist/chunk-2aa1w78q.js.map +0 -10
  193. package/dist/chunk-31bmhjxx.js +0 -4
  194. package/dist/chunk-31bmhjxx.js.map +0 -10
  195. package/dist/chunk-3etn0w20.js +0 -4
  196. package/dist/chunk-3etn0w20.js.map +0 -10
  197. package/dist/chunk-bk58smyr.js +0 -4
  198. package/dist/chunk-bk58smyr.js.map +0 -10
  199. package/dist/chunk-etm8zfkk.js +0 -4
  200. package/dist/chunk-etm8zfkk.js.map +0 -10
  201. package/dist/chunk-h7myvxxm.js +0 -5
  202. package/dist/chunk-h7myvxxm.js.map +0 -10
  203. package/dist/chunk-htvthkj1.js +0 -5
  204. package/dist/chunk-htvthkj1.js.map +0 -10
  205. package/dist/chunk-nfas79hz.js +0 -4
  206. package/dist/chunk-nfas79hz.js.map +0 -10
  207. package/dist/src/keepkey/index.cjs +0 -4
  208. package/dist/src/keepkey/index.cjs.map +0 -15
  209. package/dist/src/keepkey/index.js +0 -4
  210. package/dist/src/keepkey/index.js.map +0 -15
  211. package/dist/src/keystore/index.cjs +0 -4
  212. package/dist/src/keystore/index.cjs.map +0 -11
  213. package/dist/src/keystore/index.js +0 -4
  214. package/dist/src/keystore/index.js.map +0 -11
  215. package/dist/src/ledger/index.cjs +0 -5
  216. package/dist/src/ledger/index.cjs.map +0 -25
  217. package/dist/src/ledger/index.js +0 -5
  218. package/dist/src/ledger/index.js.map +0 -25
  219. package/dist/src/trezor/index.cjs +0 -4
  220. package/dist/src/trezor/index.cjs.map +0 -10
  221. package/dist/src/trezor/index.js +0 -4
  222. package/dist/src/trezor/index.js.map +0 -10
  223. package/src/bitget/helpers.ts +0 -167
  224. package/src/bitget/index.ts +0 -34
  225. package/src/coinbase/index.ts +0 -52
  226. package/src/coinbase/signer.ts +0 -83
  227. package/src/cosmostation/index.ts +0 -142
  228. package/src/ctrl/index.ts +0 -248
  229. package/src/ctrl/walletHelpers.ts +0 -297
  230. package/src/evm-extensions/index.ts +0 -134
  231. package/src/exodus/index.ts +0 -179
  232. package/src/helpers/near-browser-provider.d.ts +0 -286
  233. package/src/helpers/near.ts +0 -206
  234. package/src/index.ts +0 -2
  235. package/src/keepkey/chains/cosmos.ts +0 -78
  236. package/src/keepkey/chains/evm.ts +0 -125
  237. package/src/keepkey/chains/mayachain.ts +0 -123
  238. package/src/keepkey/chains/ripple.ts +0 -118
  239. package/src/keepkey/chains/thorchain.ts +0 -118
  240. package/src/keepkey/chains/utxo.ts +0 -147
  241. package/src/keepkey/coins.ts +0 -71
  242. package/src/keepkey/index.ts +0 -153
  243. package/src/keepkey-bex/index.ts +0 -162
  244. package/src/keepkey-bex/walletHelpers.ts +0 -255
  245. package/src/keplr/chainRegistry.ts +0 -211
  246. package/src/keplr/index.ts +0 -55
  247. package/src/keystore/helpers.ts +0 -102
  248. package/src/keystore/index.ts +0 -73
  249. package/src/ledger/clients/cosmos.ts +0 -102
  250. package/src/ledger/clients/evm.ts +0 -183
  251. package/src/ledger/clients/near.ts +0 -86
  252. package/src/ledger/clients/thorchain/common.ts +0 -117
  253. package/src/ledger/clients/thorchain/helpers.ts +0 -149
  254. package/src/ledger/clients/thorchain/index.ts +0 -94
  255. package/src/ledger/clients/thorchain/lib.ts +0 -300
  256. package/src/ledger/clients/thorchain/utils.ts +0 -76
  257. package/src/ledger/clients/tron.ts +0 -92
  258. package/src/ledger/clients/utxo.ts +0 -148
  259. package/src/ledger/clients/xrp.ts +0 -66
  260. package/src/ledger/cosmosTypes.ts +0 -101
  261. package/src/ledger/helpers/getLedgerAddress.ts +0 -67
  262. package/src/ledger/helpers/getLedgerClient.ts +0 -124
  263. package/src/ledger/helpers/getLedgerTransport.ts +0 -80
  264. package/src/ledger/helpers/index.ts +0 -3
  265. package/src/ledger/index.ts +0 -311
  266. package/src/ledger/interfaces/CosmosLedgerInterface.ts +0 -65
  267. package/src/ledger/types.ts +0 -45
  268. package/src/okx/helpers.ts +0 -181
  269. package/src/okx/index.ts +0 -43
  270. package/src/okx/types.ts +0 -117
  271. package/src/onekey/evmSigner.ts +0 -133
  272. package/src/onekey/index.ts +0 -213
  273. package/src/phantom/index.ts +0 -126
  274. package/src/polkadotjs/index.ts +0 -67
  275. package/src/radix/index.ts +0 -202
  276. package/src/talisman/index.ts +0 -130
  277. package/src/trezor/evmSigner.ts +0 -197
  278. package/src/trezor/index.ts +0 -260
  279. package/src/types.ts +0 -280
  280. package/src/utils.ts +0 -60
  281. package/src/vultisig/index.ts +0 -199
  282. package/src/vultisig/walletHelpers.ts +0 -359
  283. package/src/walletconnect/constants.ts +0 -104
  284. package/src/walletconnect/evmSigner.ts +0 -147
  285. package/src/walletconnect/helpers.ts +0 -77
  286. package/src/walletconnect/index.ts +0 -460
  287. package/src/walletconnect/namespaces.ts +0 -87
  288. package/src/walletconnect/types.ts +0 -6
  289. package/src/xaman/README.md +0 -66
  290. package/src/xaman/helpers.ts +0 -59
  291. package/src/xaman/index.ts +0 -79
  292. package/src/xaman/types.ts +0 -26
  293. package/src/xaman/walletMethods.ts +0 -126
  294. /package/dist/{chunk-mvbb9fwb.js.map → chunk-sbf0f2p4.js.map} +0 -0
@@ -1,460 +0,0 @@
1
- import type { StdSignDoc } from "@cosmjs/amino";
2
- import {
3
- Chain,
4
- ChainId,
5
- type GenericTransferParams,
6
- SKConfig,
7
- SwapKitError,
8
- WalletOption,
9
- createWallet,
10
- filterSupportedChains,
11
- } from "@swapkit/helpers";
12
- import type { ThorchainDepositParams, createThorchainToolbox } from "@swapkit/toolboxes/cosmos";
13
- import type { NearSigner } from "@swapkit/toolboxes/near";
14
- import type { TronSignedTransaction, TronSigner, TronTransaction } from "@swapkit/toolboxes/tron";
15
- import type { WalletConnectModal } from "@walletconnect/modal";
16
- import type { SessionTypes, SignClientTypes } from "@walletconnect/types";
17
- import type { Transaction } from "near-api-js/lib/transaction";
18
-
19
- import type { SignClient } from "@walletconnect/sign-client";
20
- import { getWalletSupportedChains } from "../utils";
21
- import {
22
- DEFAULT_APP_METADATA,
23
- DEFAULT_COSMOS_METHODS,
24
- DEFAULT_LOGGER,
25
- DEFAULT_RELAY_URL,
26
- THORCHAIN_MAINNET_ID,
27
- } from "./constants";
28
- import { getEVMSigner } from "./evmSigner";
29
- import { chainToChainId, getAddressByChain } from "./helpers";
30
- import { getRequiredNamespaces } from "./namespaces";
31
-
32
- export * from "./constants";
33
- export * from "./types";
34
-
35
- export const walletconnectWallet = createWallet({
36
- name: "connectWalletconnect",
37
- walletType: WalletOption.WALLETCONNECT,
38
- supportedChains: [
39
- Chain.Arbitrum,
40
- Chain.Aurora,
41
- Chain.Avalanche,
42
- Chain.Base,
43
- Chain.Berachain,
44
- Chain.BinanceSmartChain,
45
- Chain.Cosmos,
46
- Chain.Ethereum,
47
- Chain.Kujira,
48
- Chain.Maya,
49
- Chain.Near,
50
- Chain.Optimism,
51
- Chain.Polygon,
52
- Chain.THORChain,
53
- Chain.Tron,
54
- ],
55
- connect: ({ addChain, supportedChains, walletType }) =>
56
- async function connectWalletconnect(
57
- chains: Chain[],
58
- walletconnectOptions?: SignClientTypes.Options,
59
- ) {
60
- const filteredChains = filterSupportedChains({ chains, supportedChains, walletType });
61
- const { walletConnectProjectId } = SKConfig.get("apiKeys");
62
-
63
- if (!walletConnectProjectId) {
64
- throw new SwapKitError("wallet_walletconnect_project_id_not_specified");
65
- }
66
-
67
- const walletconnect = await getWalletconnect(
68
- filteredChains,
69
- walletConnectProjectId,
70
- walletconnectOptions,
71
- );
72
-
73
- if (!walletconnect) {
74
- throw new SwapKitError("wallet_walletconnect_connection_not_established");
75
- }
76
-
77
- const { accounts } = walletconnect;
78
-
79
- await Promise.all(
80
- filteredChains.map(async (chain) => {
81
- const address = getAddressByChain(chain, accounts || []);
82
- const toolbox = await getToolbox({ address, chain, walletconnect });
83
-
84
- addChain({
85
- ...toolbox,
86
- address,
87
- chain,
88
- disconnect: walletconnect.disconnect,
89
- walletType: WalletOption.WALLETCONNECT,
90
- });
91
- }),
92
- );
93
-
94
- return true;
95
- },
96
- });
97
-
98
- export const WC_SUPPORTED_CHAINS = getWalletSupportedChains(walletconnectWallet);
99
- export type Walletconnect = Awaited<ReturnType<typeof getWalletconnect>>;
100
-
101
- async function getToolbox<T extends (typeof WC_SUPPORTED_CHAINS)[number]>({
102
- chain,
103
- walletconnect,
104
- address,
105
- }: {
106
- walletconnect: Walletconnect;
107
- chain: T;
108
- address: string;
109
- }) {
110
- const session = walletconnect?.session;
111
- if (!session) {
112
- throw new SwapKitError("wallet_walletconnect_connection_not_established");
113
- }
114
-
115
- switch (chain) {
116
- case Chain.Arbitrum:
117
- case Chain.Avalanche:
118
- case Chain.Base:
119
- case Chain.BinanceSmartChain:
120
- case Chain.Ethereum:
121
- case Chain.Optimism:
122
- case Chain.Polygon: {
123
- const { getProvider, getEvmToolbox } = await import("@swapkit/toolboxes/evm");
124
-
125
- const provider = await getProvider(chain);
126
- const signer = await getEVMSigner({ walletconnect, chain, provider });
127
- const toolbox = await getEvmToolbox(chain, { provider, signer });
128
-
129
- return toolbox;
130
- }
131
-
132
- case Chain.THORChain: {
133
- const { SignMode } = await import("cosmjs-types/cosmos/tx/signing/v1beta1/signing.js");
134
- const { TxRaw } = await import("cosmjs-types/cosmos/tx/v1beta1/tx.js");
135
-
136
- const importedSigning = await import("@cosmjs/proto-signing");
137
- const encodePubkey = importedSigning.encodePubkey ?? importedSigning.default?.encodePubkey;
138
- const makeAuthInfoBytes =
139
- importedSigning.makeAuthInfoBytes ?? importedSigning.default?.makeAuthInfoBytes;
140
- const importedAmino = await import("@cosmjs/amino");
141
- const makeSignDoc = importedAmino.makeSignDoc ?? importedSigning.default?.makeSignDoc;
142
-
143
- const {
144
- getCosmosToolbox,
145
- buildAminoMsg,
146
- buildEncodedTxBody,
147
- createStargateClient,
148
- fromBase64,
149
- getDefaultChainFee,
150
- parseAminoMessageForDirectSigning,
151
- } = await import("@swapkit/toolboxes/cosmos");
152
- const toolbox = await getCosmosToolbox(Chain.THORChain);
153
-
154
- async function getAccount(accountAddress: string) {
155
- const cosmosToolbox = toolbox;
156
- const account = await (
157
- cosmosToolbox as Awaited<ReturnType<typeof createThorchainToolbox>>
158
- ).getAccount(accountAddress);
159
-
160
- if (chain !== Chain.THORChain) {
161
- return account;
162
- }
163
-
164
- const [{ address, algo, pubkey }] = (await walletconnect?.client.request({
165
- chainId: THORCHAIN_MAINNET_ID,
166
- // @ts-ignore
167
- topic: session.topic,
168
- request: {
169
- method: DEFAULT_COSMOS_METHODS.COSMOS_GET_ACCOUNTS,
170
- params: {},
171
- },
172
- })) as [{ address: string; algo: string; pubkey: string }];
173
-
174
- return { ...account, address, pubkey: { type: algo, value: pubkey } };
175
- }
176
-
177
- const fee = getDefaultChainFee(chain);
178
-
179
- const signRequest = (signDoc: StdSignDoc) =>
180
- walletconnect?.client.request({
181
- chainId: THORCHAIN_MAINNET_ID,
182
- topic: session.topic,
183
- request: {
184
- method: DEFAULT_COSMOS_METHODS.COSMOS_SIGN_AMINO,
185
- params: { signerAddress: address, signDoc },
186
- },
187
- });
188
-
189
- async function thorchainTransfer({
190
- assetValue,
191
- memo,
192
- ...rest
193
- }: GenericTransferParams | ThorchainDepositParams) {
194
- const account = await toolbox.getAccount(address);
195
- if (!account) {
196
- throw new SwapKitError({ errorKey: "wallet_missing_params", info: { account } });
197
- }
198
-
199
- if (!account.pubkey) {
200
- throw new SwapKitError({
201
- errorKey: "wallet_missing_params",
202
- info: { account, pubkey: account?.pubkey },
203
- });
204
- }
205
-
206
- const { accountNumber, sequence = 0 } = account;
207
-
208
- const msgs = [buildAminoMsg({ assetValue, memo, sender: address, ...rest })];
209
-
210
- const chainId = ChainId.THORChain;
211
-
212
- const signDoc = makeSignDoc(
213
- msgs,
214
- fee,
215
- chainId,
216
- memo,
217
- accountNumber?.toString(),
218
- sequence?.toString() || "0",
219
- );
220
-
221
- const signature: any = await signRequest(signDoc);
222
-
223
- const bodyBytes = await buildEncodedTxBody({
224
- chain: Chain.THORChain,
225
- msgs: msgs.map(parseAminoMessageForDirectSigning),
226
- memo: memo || "",
227
- });
228
- const pubkey = encodePubkey(account.pubkey);
229
- const authInfoBytes = makeAuthInfoBytes(
230
- [{ pubkey, sequence }],
231
- fee.amount,
232
- Number.parseInt(fee.gas),
233
- undefined,
234
- undefined,
235
- SignMode.SIGN_MODE_LEGACY_AMINO_JSON,
236
- );
237
-
238
- const txRaw = TxRaw.fromPartial({
239
- bodyBytes,
240
- authInfoBytes,
241
- signatures: [
242
- fromBase64(
243
- typeof signature.signature === "string"
244
- ? signature.signature
245
- : signature.signature.signature,
246
- ),
247
- ],
248
- });
249
- const txBytes = TxRaw.encode(txRaw).finish();
250
-
251
- const broadcaster = await createStargateClient(SKConfig.get("rpcUrls")[Chain.THORChain]);
252
- const result = await broadcaster.broadcastTx(txBytes);
253
- return result.transactionHash;
254
- }
255
-
256
- return {
257
- ...toolbox,
258
- transfer: (params: GenericTransferParams) => thorchainTransfer(params),
259
- deposit: (params: ThorchainDepositParams) => thorchainTransfer(params),
260
- getAccount,
261
- };
262
- }
263
-
264
- case Chain.Near: {
265
- const { getNearToolbox } = await import("@swapkit/toolboxes/near");
266
- const { DEFAULT_NEAR_METHODS } = await import("./constants");
267
-
268
- // Create a NEAR signer that uses WalletConnect
269
- const signer = {
270
- getPublicKey() {
271
- // WalletConnect NEAR doesn't expose public key directly
272
- return Promise.reject(
273
- new SwapKitError("wallet_walletconnect_method_not_supported", {
274
- method: "getPublicKey",
275
- }),
276
- );
277
- },
278
-
279
- signNep413Message(
280
- _message: string,
281
- _accountId: string,
282
- _recipient: string,
283
- _nonce: Uint8Array,
284
- _callbackUrl?: string,
285
- ) {
286
- // WalletConnect NEAR spec doesn't include NEP-413 message signing
287
- return Promise.reject(
288
- new SwapKitError("wallet_walletconnect_method_not_supported", {
289
- method: "signNep413Message",
290
- }),
291
- );
292
- },
293
-
294
- async signTransaction(transaction: Transaction) {
295
- if (!walletconnect) {
296
- throw new SwapKitError("wallet_walletconnect_connection_not_established");
297
- }
298
- // WalletConnect signs and sends in one operation
299
- const result = await walletconnect.client.request({
300
- topic: session.topic,
301
- chainId: chainToChainId(Chain.Near),
302
- request: {
303
- method: DEFAULT_NEAR_METHODS.NEAR_SIGN_AND_SEND_TRANSACTION,
304
- params: { transaction },
305
- },
306
- });
307
- // Return dummy hash and result
308
- return [new Uint8Array(32), result];
309
- },
310
-
311
- signDelegateAction(_delegateAction: any) {
312
- return Promise.reject(
313
- new SwapKitError("wallet_walletconnect_method_not_supported", {
314
- method: "signDelegateAction",
315
- }),
316
- );
317
- },
318
-
319
- getAddress() {
320
- return Promise.resolve(address);
321
- },
322
- } as NearSigner;
323
-
324
- const toolbox = await getNearToolbox({ signer });
325
- return toolbox;
326
- }
327
-
328
- case Chain.Tron: {
329
- const { createTronToolbox } = await import("@swapkit/toolboxes/tron");
330
- const { DEFAULT_TRON_METHODS } = await import("./constants");
331
-
332
- // Create a Tron signer that uses WalletConnect
333
- const signer: TronSigner = {
334
- getAddress() {
335
- return Promise.resolve(address);
336
- },
337
-
338
- async signTransaction(transaction: TronTransaction) {
339
- if (!walletconnect) {
340
- throw new SwapKitError("wallet_walletconnect_connection_not_established");
341
- }
342
-
343
- const signedTx = await walletconnect.client.request({
344
- topic: session.topic,
345
- chainId: chainToChainId(Chain.Tron),
346
- request: {
347
- method: DEFAULT_TRON_METHODS.TRON_SIGN_TRANSACTION,
348
- params: { transaction },
349
- },
350
- });
351
-
352
- return signedTx as TronSignedTransaction;
353
- },
354
- };
355
-
356
- const toolbox = await createTronToolbox({ signer });
357
- return toolbox;
358
- }
359
-
360
- default:
361
- throw new SwapKitError({
362
- errorKey: "wallet_chain_not_supported",
363
- info: { chain, wallet: WalletOption.WALLETCONNECT },
364
- });
365
- }
366
- }
367
-
368
- async function getWalletconnect(
369
- chains: Chain[],
370
- walletConnectProjectId?: string,
371
- walletconnectOptions?: SignClientTypes.Options,
372
- ) {
373
- let modal: WalletConnectModal | undefined;
374
- let signer: typeof SignClient | undefined;
375
- let session: SessionTypes.Struct | undefined;
376
- let accounts: string[] | undefined;
377
- try {
378
- if (!walletConnectProjectId) {
379
- throw new SwapKitError("wallet_walletconnect_project_id_not_specified");
380
- }
381
- const requiredNamespaces = getRequiredNamespaces(chains.map(chainToChainId));
382
-
383
- const { SignClient } = await import("@walletconnect/sign-client");
384
- const { WalletConnectModal } = await import("@walletconnect/modal");
385
-
386
- const client = new SignClient({
387
- logger: DEFAULT_LOGGER,
388
- relayUrl: DEFAULT_RELAY_URL,
389
- projectId: walletConnectProjectId,
390
- metadata: walletconnectOptions?.metadata || DEFAULT_APP_METADATA,
391
- ...walletconnectOptions?.core,
392
- });
393
-
394
- const modal = new WalletConnectModal({
395
- logger: DEFAULT_LOGGER,
396
- relayUrl: DEFAULT_RELAY_URL,
397
- projectId: walletConnectProjectId,
398
- ...walletconnectOptions?.core,
399
- });
400
-
401
- const oldSession = await client.session.getAll()[0];
402
-
403
- // disconnect old Session cause we can't handle using it with current ui
404
- if (oldSession) {
405
- await client.disconnect({
406
- topic: oldSession.topic,
407
- reason: { code: 0, message: "Resetting session" },
408
- });
409
- }
410
-
411
- const { uri, approval } = await client.connect({
412
- // Optionally: pass a known prior pairing (e.g. from `client.core.pairing.getPairings()`) to skip the `uri` step.
413
- // pairingTopic: pairing?.topic,
414
- // Provide the namespaces and chains (e.g. `eip155` for EVM-based chains) we want to use in this session.
415
- requiredNamespaces,
416
- });
417
-
418
- if (uri) {
419
- modal.openModal({ uri });
420
- // Await session approval from the wallet.
421
- session = await approval();
422
- // Handle the returned session (e.g. update UI to "connected" state).
423
- // Close the QRCode modal in case it was open.
424
- modal.closeModal();
425
-
426
- function extractAccountsFromSession(session: SessionTypes.Struct) {
427
- const accounts: string[] = [];
428
-
429
- for (const [_namespace, data] of Object.entries(session.namespaces)) {
430
- accounts.push(...data.accounts);
431
- }
432
-
433
- return accounts;
434
- }
435
-
436
- accounts = extractAccountsFromSession(session);
437
- }
438
-
439
- const disconnect = async () => {
440
- session &&
441
- (await client.disconnect({
442
- topic: session.topic,
443
- reason: { code: 0, message: "User disconnected" },
444
- }));
445
- };
446
-
447
- if (!session) {
448
- throw new SwapKitError("wallet_walletconnect_connection_not_established");
449
- }
450
-
451
- return { signer, session, accounts, client, disconnect };
452
- } catch (_e) {
453
- // Errors are handled by returning undefined
454
- } finally {
455
- if (modal) {
456
- modal.closeModal();
457
- }
458
- }
459
- return undefined;
460
- }
@@ -1,87 +0,0 @@
1
- import type { ProposalTypes } from "@walletconnect/types";
2
-
3
- import { SwapKitError } from "@swapkit/helpers";
4
- import {
5
- DEFAULT_COSMOS_METHODS,
6
- DEFAULT_EIP155_METHODS,
7
- DEFAULT_EIP_155_EVENTS,
8
- DEFAULT_NEAR_EVENTS,
9
- DEFAULT_NEAR_METHODS,
10
- DEFAULT_POLKADOT_EVENTS,
11
- DEFAULT_POLKADOT_METHODS,
12
- DEFAULT_SOLANA_EVENTS,
13
- DEFAULT_SOLANA_METHODS,
14
- DEFAULT_TRON_EVENTS,
15
- DEFAULT_TRON_METHODS,
16
- } from "./constants";
17
-
18
- export const getNamespacesFromChains = (chains: string[]) => {
19
- const supportedNamespaces: string[] = [];
20
- for (const chainId of chains) {
21
- const [namespace] = chainId.split(":");
22
- if (namespace && !supportedNamespaces.includes(namespace)) {
23
- supportedNamespaces.push(namespace);
24
- }
25
- }
26
-
27
- return supportedNamespaces;
28
- };
29
-
30
- export const getSupportedMethodsByNamespace = (namespace: string) => {
31
- switch (namespace) {
32
- case "eip155":
33
- return Object.values(DEFAULT_EIP155_METHODS);
34
- case "cosmos":
35
- return Object.values(DEFAULT_COSMOS_METHODS);
36
- case "solana":
37
- return Object.values(DEFAULT_SOLANA_METHODS);
38
- case "polkadot":
39
- return Object.values(DEFAULT_POLKADOT_METHODS);
40
- case "near":
41
- return Object.values(DEFAULT_NEAR_METHODS);
42
- case "tron":
43
- return Object.values(DEFAULT_TRON_METHODS);
44
- default:
45
- throw new SwapKitError({
46
- errorKey: "wallet_walletconnect_namespace_not_supported",
47
- info: { namespace },
48
- });
49
- }
50
- };
51
-
52
- export const getSupportedEventsByNamespace = (namespace: string) => {
53
- switch (namespace) {
54
- case "eip155":
55
- return Object.values(DEFAULT_EIP_155_EVENTS);
56
- case "cosmos":
57
- return [];
58
- case "solana":
59
- return Object.values(DEFAULT_SOLANA_EVENTS);
60
- case "polkadot":
61
- return Object.values(DEFAULT_POLKADOT_EVENTS);
62
- case "near":
63
- return Object.values(DEFAULT_NEAR_EVENTS);
64
- case "tron":
65
- return Object.values(DEFAULT_TRON_EVENTS);
66
- default:
67
- throw new SwapKitError({
68
- errorKey: "wallet_walletconnect_namespace_not_supported",
69
- info: { namespace },
70
- });
71
- }
72
- };
73
-
74
- export const getRequiredNamespaces = (chains: string[]): ProposalTypes.RequiredNamespaces => {
75
- const selectedNamespaces = getNamespacesFromChains(chains);
76
-
77
- return Object.fromEntries(
78
- selectedNamespaces.map((namespace) => [
79
- namespace,
80
- {
81
- methods: getSupportedMethodsByNamespace(namespace),
82
- chains: chains.filter((chain) => chain.startsWith(namespace)),
83
- events: getSupportedEventsByNamespace(namespace) as any[],
84
- },
85
- ]),
86
- );
87
- };
@@ -1,6 +0,0 @@
1
- export interface ClientMetadata {
2
- name: string;
3
- description: string;
4
- url: string;
5
- icons: string[];
6
- }
@@ -1,66 +0,0 @@
1
- # Xaman Wallet Integration
2
-
3
- ## Configuration
4
-
5
- ### Option 1: Configure via SKConfig (Recommended)
6
-
7
- ```typescript
8
- import { SwapKit } from "@swapkit/core";
9
- import { SKConfig } from "@swapkit/helpers";
10
-
11
- // Set the Xaman API key globally
12
- SKConfig.setApiKey("xaman", "your-xaman-api-key");
13
-
14
- // Or configure during SwapKit initialization
15
- const swapKit = SwapKit({
16
- config: {
17
- apiKeys: {
18
- xaman: "your-xaman-api-key"
19
- }
20
- }
21
- });
22
-
23
- // Connect to Xaman wallet
24
- await swapKit.connectWallet(WalletOption.XAMAN, [Chain.Ripple]);
25
- ```
26
-
27
- ### Option 2: Pass API key during connection
28
-
29
- ```typescript
30
- // Connect with API key override
31
- await swapKit.connectWallet(WalletOption.XAMAN, [Chain.Ripple], {
32
- apiKey: "your-xaman-api-key"
33
- });
34
- ```
35
-
36
- ## Usage Example
37
-
38
- ```typescript
39
- // Get the connected wallet
40
- const wallet = swapKit.getWallet(Chain.Ripple);
41
-
42
- // Send XRP
43
- const txHash = await wallet.transfer({
44
- assetValue: AssetValue.from({ chain: Chain.Ripple, value: 1 }),
45
- recipient: "rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH",
46
- memo: "Payment memo"
47
- });
48
- ```
49
-
50
- ## Destination Tags
51
-
52
- For exchange addresses that require destination tags:
53
-
54
- ```typescript
55
- // The destination tag should be included in the memo field
56
- // Format: "DestinationTag:123456"
57
- const txHash = await wallet.transfer({
58
- assetValue: AssetValue.from({ chain: Chain.Ripple, value: 10 }),
59
- recipient: "rExchangeAddress...",
60
- memo: "DestinationTag:123456"
61
- });
62
- ```
63
-
64
- ## Getting an API Key
65
-
66
- To use the Xaman wallet, you need to obtain an API key from the [Xaman Developer Console](https://apps.xumm.dev/).
@@ -1,59 +0,0 @@
1
- import { type AssetValue, Chain, SwapKitError } from "@swapkit/helpers";
2
- import type { Xumm } from "xumm";
3
- import { sendXamanTransaction } from "./walletMethods.js";
4
-
5
- interface GetWalletForChainParams {
6
- chain: Chain;
7
- address: string;
8
- rpcUrl?: string;
9
- xumm: Xumm;
10
- }
11
-
12
- export async function getWalletForChain({ xumm, chain, address, rpcUrl }: GetWalletForChainParams) {
13
- switch (chain) {
14
- case Chain.Ripple: {
15
- const { getRippleToolbox } = await import("@swapkit/toolboxes/ripple");
16
-
17
- // const api = apis?.[chain]; // Unused for now
18
- const toolbox = await getRippleToolbox({ rpcUrl });
19
-
20
- // Override transfer method to use Xaman transaction flow
21
- const transfer = async (params: {
22
- assetValue: AssetValue;
23
- recipient: string;
24
- memo?: string;
25
- }) => {
26
- const { recipient, assetValue, memo } = params;
27
-
28
- // Create and subscribe to payment via Xaman
29
- const paymentResult = await sendXamanTransaction(xumm, {
30
- from: address,
31
- destination: recipient,
32
- amount: assetValue.getValue("string"),
33
- memo: memo,
34
- });
35
-
36
- // If not successful or no transaction ID, throw error
37
- if (!(paymentResult.result.success && paymentResult.result.transactionId)) {
38
- throw new SwapKitError("wallet_xaman_transaction_failed");
39
- }
40
-
41
- // Return the transaction ID string
42
- return paymentResult.result.transactionId;
43
- };
44
-
45
- return {
46
- ...toolbox,
47
- address,
48
- getAddress: () => address,
49
- transfer,
50
- // Expose Xaman-specific methods
51
- createAndSubscribePayment: sendXamanTransaction,
52
- disconnect: xumm.logout,
53
- };
54
- }
55
-
56
- default:
57
- throw new SwapKitError("wallet_chain_not_supported", { wallet: "Xaman", chain });
58
- }
59
- }