@crossmint/wallets-sdk 0.20.2 → 0.20.5

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 (257) hide show
  1. package/package.json +1 -1
  2. package/LICENSE +0 -201
  3. package/README.md +0 -96
  4. package/dist/api/__tests__/constants.cjs +0 -31
  5. package/dist/api/__tests__/constants.d.cts +0 -96
  6. package/dist/api/__tests__/constants.d.ts +0 -96
  7. package/dist/api/__tests__/constants.js +0 -31
  8. package/dist/api/__tests__/test-utils.cjs +0 -372
  9. package/dist/api/__tests__/test-utils.d.cts +0 -99
  10. package/dist/api/__tests__/test-utils.d.ts +0 -99
  11. package/dist/api/__tests__/test-utils.js +0 -372
  12. package/dist/api/client.cjs +0 -10
  13. package/dist/api/client.d.cts +0 -42
  14. package/dist/api/client.d.ts +0 -42
  15. package/dist/api/client.js +0 -10
  16. package/dist/api/gen/client.gen.cjs +0 -7
  17. package/dist/api/gen/client.gen.d.cts +0 -16
  18. package/dist/api/gen/client.gen.d.ts +0 -16
  19. package/dist/api/gen/client.gen.js +0 -7
  20. package/dist/api/gen/index.cjs +0 -179
  21. package/dist/api/gen/index.d.cts +0 -3
  22. package/dist/api/gen/index.d.ts +0 -3
  23. package/dist/api/gen/index.js +0 -179
  24. package/dist/api/gen/sdk.gen.cjs +0 -178
  25. package/dist/api/gen/sdk.gen.d.cts +0 -611
  26. package/dist/api/gen/sdk.gen.d.ts +0 -611
  27. package/dist/api/gen/sdk.gen.js +0 -178
  28. package/dist/api/gen/types.gen.cjs +0 -1
  29. package/dist/api/gen/types.gen.d.cts +0 -13865
  30. package/dist/api/gen/types.gen.d.ts +0 -13865
  31. package/dist/api/gen/types.gen.js +0 -1
  32. package/dist/api/index.cjs +0 -12
  33. package/dist/api/index.d.cts +0 -6
  34. package/dist/api/index.d.ts +0 -6
  35. package/dist/api/index.js +0 -12
  36. package/dist/api/types.cjs +0 -1
  37. package/dist/api/types.d.cts +0 -55
  38. package/dist/api/types.d.ts +0 -55
  39. package/dist/api/types.js +0 -1
  40. package/dist/chains/chains.cjs +0 -24
  41. package/dist/chains/chains.d.cts +0 -28
  42. package/dist/chains/chains.d.ts +0 -28
  43. package/dist/chains/chains.js +0 -24
  44. package/dist/chains/definitions/arcTestnet.cjs +0 -7
  45. package/dist/chains/definitions/arcTestnet.d.cts +0 -43
  46. package/dist/chains/definitions/arcTestnet.d.ts +0 -43
  47. package/dist/chains/definitions/arcTestnet.js +0 -7
  48. package/dist/chains/definitions/story.cjs +0 -7
  49. package/dist/chains/definitions/story.d.cts +0 -49
  50. package/dist/chains/definitions/story.d.ts +0 -49
  51. package/dist/chains/definitions/story.js +0 -7
  52. package/dist/chains/definitions/storyTestnet.cjs +0 -7
  53. package/dist/chains/definitions/storyTestnet.d.cts +0 -43
  54. package/dist/chains/definitions/storyTestnet.d.ts +0 -43
  55. package/dist/chains/definitions/storyTestnet.js +0 -7
  56. package/dist/chains/definitions/tempo.cjs +0 -7
  57. package/dist/chains/definitions/tempo.d.cts +0 -39
  58. package/dist/chains/definitions/tempo.d.ts +0 -39
  59. package/dist/chains/definitions/tempo.js +0 -7
  60. package/dist/chains/definitions/tempoTestnet.cjs +0 -7
  61. package/dist/chains/definitions/tempoTestnet.d.cts +0 -39
  62. package/dist/chains/definitions/tempoTestnet.d.ts +0 -39
  63. package/dist/chains/definitions/tempoTestnet.js +0 -7
  64. package/dist/chunk-2I2OFGNL.js +0 -36
  65. package/dist/chunk-2T5HHKUI.js +0 -19
  66. package/dist/chunk-2WBSPOWU.js +0 -223
  67. package/dist/chunk-3U6UAYOV.js +0 -25
  68. package/dist/chunk-455NK5LB.js +0 -0
  69. package/dist/chunk-47R3UV3J.cjs +0 -58
  70. package/dist/chunk-47WKYTRN.js +0 -63
  71. package/dist/chunk-4GFSUI2I.cjs +0 -66
  72. package/dist/chunk-55V4VMTX.cjs +0 -25
  73. package/dist/chunk-5IFDVB4Y.js +0 -0
  74. package/dist/chunk-66UY53KP.cjs +0 -336
  75. package/dist/chunk-6FG5QXII.cjs +0 -110
  76. package/dist/chunk-6HXIZLEQ.cjs +0 -1
  77. package/dist/chunk-6UMJYMAY.js +0 -82
  78. package/dist/chunk-7GOUUPS4.js +0 -36
  79. package/dist/chunk-7TT3VUDF.cjs +0 -84
  80. package/dist/chunk-7USEVMTW.cjs +0 -21
  81. package/dist/chunk-A6E67ZZP.js +0 -237
  82. package/dist/chunk-ABMZ3ZVN.js +0 -52
  83. package/dist/chunk-ASE2FXWP.js +0 -65
  84. package/dist/chunk-BMMZIPXT.js +0 -778
  85. package/dist/chunk-CCIGWTAO.cjs +0 -1
  86. package/dist/chunk-CMBFV325.js +0 -69
  87. package/dist/chunk-COR3CNRW.cjs +0 -778
  88. package/dist/chunk-ECAM5KTH.cjs +0 -1
  89. package/dist/chunk-F7L2TZ3I.cjs +0 -21
  90. package/dist/chunk-FHMKNG62.js +0 -741
  91. package/dist/chunk-FICVKSXZ.js +0 -84
  92. package/dist/chunk-FOOISYCJ.js +0 -66
  93. package/dist/chunk-G6QJHFSY.cjs +0 -74
  94. package/dist/chunk-HTSQPZHW.cjs +0 -25
  95. package/dist/chunk-HXJ3YPAN.js +0 -110
  96. package/dist/chunk-IDKGJO2G.cjs +0 -115
  97. package/dist/chunk-IOMKHF6R.cjs +0 -44
  98. package/dist/chunk-IPO25BCU.js +0 -43
  99. package/dist/chunk-JREZWZ2S.cjs +0 -52
  100. package/dist/chunk-JSWTGW46.cjs +0 -36
  101. package/dist/chunk-JWMQALLN.js +0 -21
  102. package/dist/chunk-KBJA7JDT.js +0 -0
  103. package/dist/chunk-KQH5ZXJ4.js +0 -336
  104. package/dist/chunk-KT3CVXFG.js +0 -9
  105. package/dist/chunk-MMISP35W.js +0 -21
  106. package/dist/chunk-MRZXYVQO.cjs +0 -82
  107. package/dist/chunk-NIBKCMQ2.cjs +0 -19
  108. package/dist/chunk-PIFD6KNH.js +0 -59
  109. package/dist/chunk-PJOJIRTY.js +0 -74
  110. package/dist/chunk-PK7J3Y3L.js +0 -44
  111. package/dist/chunk-PM7BGATN.cjs +0 -237
  112. package/dist/chunk-PO6S7UR3.cjs +0 -1
  113. package/dist/chunk-POG76HDD.cjs +0 -741
  114. package/dist/chunk-PUO4QNXH.js +0 -89
  115. package/dist/chunk-Q5KNPVYI.cjs +0 -59
  116. package/dist/chunk-R4AW5ADG.cjs +0 -16
  117. package/dist/chunk-R6DH4V7S.cjs +0 -69
  118. package/dist/chunk-RBHGZDDX.cjs +0 -58
  119. package/dist/chunk-RHR6P2KP.cjs +0 -15
  120. package/dist/chunk-RYQI3RXL.cjs +0 -247
  121. package/dist/chunk-SGINWAB6.js +0 -155
  122. package/dist/chunk-T2XUADHW.js +0 -58
  123. package/dist/chunk-TYQ4YIP7.js +0 -16
  124. package/dist/chunk-U3NV7UY7.js +0 -323
  125. package/dist/chunk-UO2J2ZB2.cjs +0 -65
  126. package/dist/chunk-W7K5E64Q.js +0 -247
  127. package/dist/chunk-WDZY4PP4.cjs +0 -223
  128. package/dist/chunk-WHTECI7J.cjs +0 -89
  129. package/dist/chunk-WJUPOCKJ.js +0 -15
  130. package/dist/chunk-WWW6IGZ7.js +0 -115
  131. package/dist/chunk-XC2V34TS.cjs +0 -155
  132. package/dist/chunk-XOCC3MPK.cjs +0 -36
  133. package/dist/chunk-XPMCPXI3.cjs +0 -1
  134. package/dist/chunk-YDZRBHS3.js +0 -0
  135. package/dist/chunk-YMRXMNME.js +0 -0
  136. package/dist/chunk-ZAX22GSI.cjs +0 -323
  137. package/dist/chunk-ZBLW42YE.js +0 -25
  138. package/dist/chunk-ZNAGDENG.cjs +0 -43
  139. package/dist/chunk-ZP4ZZCIE.js +0 -58
  140. package/dist/chunk-ZT7EGOCI.cjs +0 -9
  141. package/dist/chunk-ZTEMOYS2.cjs +0 -63
  142. package/dist/index.cjs +0 -60
  143. package/dist/index.d.cts +0 -19
  144. package/dist/index.d.ts +0 -19
  145. package/dist/index.js +0 -60
  146. package/dist/logger/index.cjs +0 -11
  147. package/dist/logger/index.d.cts +0 -2
  148. package/dist/logger/index.d.ts +0 -2
  149. package/dist/logger/index.js +0 -11
  150. package/dist/logger/init.cjs +0 -10
  151. package/dist/logger/init.d.cts +0 -15
  152. package/dist/logger/init.d.ts +0 -15
  153. package/dist/logger/init.js +0 -10
  154. package/dist/sdk.cjs +0 -39
  155. package/dist/sdk.d.cts +0 -48
  156. package/dist/sdk.d.ts +0 -48
  157. package/dist/sdk.js +0 -39
  158. package/dist/signers/evm-api-key.cjs +0 -7
  159. package/dist/signers/evm-api-key.d.cts +0 -18
  160. package/dist/signers/evm-api-key.d.ts +0 -18
  161. package/dist/signers/evm-api-key.js +0 -7
  162. package/dist/signers/evm-external-wallet.cjs +0 -7
  163. package/dist/signers/evm-external-wallet.d.cts +0 -26
  164. package/dist/signers/evm-external-wallet.d.ts +0 -26
  165. package/dist/signers/evm-external-wallet.js +0 -7
  166. package/dist/signers/index.cjs +0 -24
  167. package/dist/signers/index.d.cts +0 -11
  168. package/dist/signers/index.d.ts +0 -11
  169. package/dist/signers/index.js +0 -24
  170. package/dist/signers/non-custodial/index.cjs +0 -27
  171. package/dist/signers/non-custodial/index.d.cts +0 -11
  172. package/dist/signers/non-custodial/index.d.ts +0 -11
  173. package/dist/signers/non-custodial/index.js +0 -27
  174. package/dist/signers/non-custodial/ncs-evm-signer.cjs +0 -13
  175. package/dist/signers/non-custodial/ncs-evm-signer.d.cts +0 -30
  176. package/dist/signers/non-custodial/ncs-evm-signer.d.ts +0 -30
  177. package/dist/signers/non-custodial/ncs-evm-signer.js +0 -13
  178. package/dist/signers/non-custodial/ncs-iframe-manager.cjs +0 -7
  179. package/dist/signers/non-custodial/ncs-iframe-manager.d.cts +0 -16
  180. package/dist/signers/non-custodial/ncs-iframe-manager.d.ts +0 -16
  181. package/dist/signers/non-custodial/ncs-iframe-manager.js +0 -7
  182. package/dist/signers/non-custodial/ncs-signer.cjs +0 -14
  183. package/dist/signers/non-custodial/ncs-signer.d.cts +0 -50
  184. package/dist/signers/non-custodial/ncs-signer.d.ts +0 -50
  185. package/dist/signers/non-custodial/ncs-signer.js +0 -14
  186. package/dist/signers/non-custodial/ncs-solana-signer.cjs +0 -13
  187. package/dist/signers/non-custodial/ncs-solana-signer.d.cts +0 -27
  188. package/dist/signers/non-custodial/ncs-solana-signer.d.ts +0 -27
  189. package/dist/signers/non-custodial/ncs-solana-signer.js +0 -13
  190. package/dist/signers/non-custodial/ncs-stellar-signer.cjs +0 -13
  191. package/dist/signers/non-custodial/ncs-stellar-signer.d.cts +0 -27
  192. package/dist/signers/non-custodial/ncs-stellar-signer.d.ts +0 -27
  193. package/dist/signers/non-custodial/ncs-stellar-signer.js +0 -13
  194. package/dist/signers/passkey.cjs +0 -7
  195. package/dist/signers/passkey.d.cts +0 -19
  196. package/dist/signers/passkey.d.ts +0 -19
  197. package/dist/signers/passkey.js +0 -7
  198. package/dist/signers/solana-api-key.cjs +0 -7
  199. package/dist/signers/solana-api-key.d.cts +0 -18
  200. package/dist/signers/solana-api-key.d.ts +0 -18
  201. package/dist/signers/solana-api-key.js +0 -7
  202. package/dist/signers/solana-external-wallet.cjs +0 -8
  203. package/dist/signers/solana-external-wallet.d.cts +0 -24
  204. package/dist/signers/solana-external-wallet.d.ts +0 -24
  205. package/dist/signers/solana-external-wallet.js +0 -8
  206. package/dist/signers/stellar-external-wallet.cjs +0 -7
  207. package/dist/signers/stellar-external-wallet.d.cts +0 -23
  208. package/dist/signers/stellar-external-wallet.d.ts +0 -23
  209. package/dist/signers/stellar-external-wallet.js +0 -7
  210. package/dist/signers/types.cjs +0 -9
  211. package/dist/signers/types.d.cts +0 -91
  212. package/dist/signers/types.d.ts +0 -91
  213. package/dist/signers/types.js +0 -9
  214. package/dist/utils/constants.cjs +0 -13
  215. package/dist/utils/constants.d.cts +0 -6
  216. package/dist/utils/constants.d.ts +0 -6
  217. package/dist/utils/constants.js +0 -13
  218. package/dist/utils/errors.cjs +0 -55
  219. package/dist/utils/errors.d.cts +0 -80
  220. package/dist/utils/errors.d.ts +0 -80
  221. package/dist/utils/errors.js +0 -55
  222. package/dist/utils/signer-validation.cjs +0 -10
  223. package/dist/utils/signer-validation.d.cts +0 -9
  224. package/dist/utils/signer-validation.d.ts +0 -9
  225. package/dist/utils/signer-validation.js +0 -10
  226. package/dist/wallets/__tests__/setup.cjs +0 -36
  227. package/dist/wallets/__tests__/setup.d.cts +0 -2
  228. package/dist/wallets/__tests__/setup.d.ts +0 -2
  229. package/dist/wallets/__tests__/setup.js +0 -36
  230. package/dist/wallets/__tests__/test-helpers.cjs +0 -93
  231. package/dist/wallets/__tests__/test-helpers.d.cts +0 -36
  232. package/dist/wallets/__tests__/test-helpers.d.ts +0 -36
  233. package/dist/wallets/__tests__/test-helpers.js +0 -93
  234. package/dist/wallets/evm.cjs +0 -25
  235. package/dist/wallets/evm.d.cts +0 -155
  236. package/dist/wallets/evm.d.ts +0 -155
  237. package/dist/wallets/evm.js +0 -25
  238. package/dist/wallets/solana.cjs +0 -26
  239. package/dist/wallets/solana.d.cts +0 -28
  240. package/dist/wallets/solana.d.ts +0 -28
  241. package/dist/wallets/solana.js +0 -26
  242. package/dist/wallets/stellar.cjs +0 -25
  243. package/dist/wallets/stellar.d.cts +0 -30
  244. package/dist/wallets/stellar.d.ts +0 -30
  245. package/dist/wallets/stellar.js +0 -25
  246. package/dist/wallets/types.cjs +0 -1
  247. package/dist/wallets/types.d.cts +0 -170
  248. package/dist/wallets/types.d.ts +0 -170
  249. package/dist/wallets/types.js +0 -0
  250. package/dist/wallets/wallet-factory.cjs +0 -33
  251. package/dist/wallets/wallet-factory.d.cts +0 -33
  252. package/dist/wallets/wallet-factory.d.ts +0 -33
  253. package/dist/wallets/wallet-factory.js +0 -33
  254. package/dist/wallets/wallet.cjs +0 -24
  255. package/dist/wallets/wallet.d.cts +0 -168
  256. package/dist/wallets/wallet.d.ts +0 -168
  257. package/dist/wallets/wallet.js +0 -24
@@ -1,741 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
- var _chunkZAX22GSIcjs = require('./chunk-ZAX22GSI.cjs');
4
-
5
-
6
- var _chunkWDZY4PP4cjs = require('./chunk-WDZY4PP4.cjs');
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
- var _chunkXC2V34TScjs = require('./chunk-XC2V34TS.cjs');
22
-
23
-
24
- var _chunkJREZWZ2Scjs = require('./chunk-JREZWZ2S.cjs');
25
-
26
-
27
- var _chunkR4AW5ADGcjs = require('./chunk-R4AW5ADG.cjs');
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
- var _chunkUO2J2ZB2cjs = require('./chunk-UO2J2ZB2.cjs');
37
-
38
- // src/wallets/wallet.ts
39
- var _commonsdkbase = require('@crossmint/common-sdk-base');
40
- var _options, _apiClient;
41
- var Wallet = class {
42
- constructor(args, apiClient) {
43
- _chunkUO2J2ZB2cjs.__privateAdd.call(void 0, this, _options);
44
- _chunkUO2J2ZB2cjs.__privateAdd.call(void 0, this, _apiClient);
45
- const { chain, address, owner, signer, options, alias } = args;
46
- _chunkUO2J2ZB2cjs.__privateSet.call(void 0, this, _apiClient, apiClient);
47
- this.chain = chain;
48
- this.address = address;
49
- this.owner = owner;
50
- this.signer = signer;
51
- _chunkUO2J2ZB2cjs.__privateSet.call(void 0, this, _options, options);
52
- this.alias = alias;
53
- }
54
- static getApiClient(wallet) {
55
- return wallet.apiClient;
56
- }
57
- static getOptions(wallet) {
58
- return wallet.options;
59
- }
60
- get apiClient() {
61
- return _chunkUO2J2ZB2cjs.__privateGet.call(void 0, this, _apiClient);
62
- }
63
- get options() {
64
- return _chunkUO2J2ZB2cjs.__privateGet.call(void 0, this, _options);
65
- }
66
- /**
67
- * Get the API client
68
- * @returns The API client
69
- * @experimental This API is experimental and may change in the future
70
- */
71
- experimental_apiClient() {
72
- return _chunkUO2J2ZB2cjs.__privateGet.call(void 0, this, _apiClient);
73
- }
74
- balances(tokens) {
75
- return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
76
- _chunkJREZWZ2Scjs.walletsLogger.info("wallet.balances.start");
77
- const resolvedChain = this.resolveChainForEnvironment();
78
- let nativeToken;
79
- switch (this.chain) {
80
- case "solana":
81
- nativeToken = "sol";
82
- break;
83
- case "stellar":
84
- nativeToken = "xlm";
85
- break;
86
- default:
87
- nativeToken = "eth";
88
- break;
89
- }
90
- const allTokens = [nativeToken, "usdc", ...tokens != null ? tokens : []];
91
- const response = yield _chunkUO2J2ZB2cjs.__privateGet.call(void 0, this, _apiClient).getBalance(this.address, {
92
- chains: [resolvedChain],
93
- tokens: allTokens
94
- });
95
- if ("error" in response) {
96
- _chunkJREZWZ2Scjs.walletsLogger.error("wallet.balances.error", { error: response });
97
- throw new Error(`Failed to get balances for wallet: ${JSON.stringify(response.message)}`);
98
- }
99
- _chunkJREZWZ2Scjs.walletsLogger.info("wallet.balances.success");
100
- return this.transformBalanceResponse(response, nativeToken, tokens);
101
- });
102
- }
103
- stagingFund(amount, chain) {
104
- return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
105
- _chunkJREZWZ2Scjs.walletsLogger.info("wallet.stagingFund.start", {
106
- amount,
107
- chain: chain != null ? chain : this.chain
108
- });
109
- const response = yield this.apiClient.fundWallet(this.address, {
110
- amount,
111
- token: "usdxm",
112
- // Type casting is necessary here due to a type mismatch between our DTO schema and server-side types
113
- // (which only contains 10 testnet chains. Variable in main server is called EvmUsdcEnabledTestnetChains for reference).
114
- chain: chain != null ? chain : this.chain
115
- });
116
- if ("error" in response) {
117
- _chunkJREZWZ2Scjs.walletsLogger.error("wallet.stagingFund.error", {
118
- error: response
119
- });
120
- throw new Error(`Failed to fund wallet: ${JSON.stringify(response.message)}`);
121
- }
122
- _chunkJREZWZ2Scjs.walletsLogger.info("wallet.stagingFund.success");
123
- return response;
124
- });
125
- }
126
- /**
127
- * Transform the API balance response to the new structure
128
- * @private
129
- */
130
- transformBalanceResponse(apiResponse, nativeTokenSymbol, requestedTokens) {
131
- const transformTokenBalance = (tokenData) => {
132
- var _a, _b, _c, _d, _e;
133
- const chainData = (_a = tokenData.chains) == null ? void 0 : _a[this.chain];
134
- let chainSpecificField = {};
135
- if (this.chain === "solana" && chainData != null && "mintHash" in chainData) {
136
- chainSpecificField = { mintHash: chainData.mintHash };
137
- } else if (this.chain === "stellar" && chainData != null && "contractId" in chainData) {
138
- chainSpecificField = { contractId: chainData.contractId };
139
- } else if (chainData != null && "contractAddress" in chainData) {
140
- chainSpecificField = {
141
- contractAddress: chainData.contractAddress
142
- };
143
- }
144
- return _chunkUO2J2ZB2cjs.__spreadValues.call(void 0, {
145
- symbol: (_b = tokenData.symbol) != null ? _b : "",
146
- name: (_c = tokenData.name) != null ? _c : "",
147
- amount: (_d = tokenData.amount) != null ? _d : "0",
148
- decimals: tokenData.decimals,
149
- rawAmount: (_e = tokenData.rawAmount) != null ? _e : "0"
150
- }, chainSpecificField);
151
- };
152
- const nativeTokenData = apiResponse.find((token) => token.symbol === nativeTokenSymbol);
153
- const usdcData = apiResponse.find((token) => token.symbol === "usdc");
154
- const otherTokens = apiResponse.filter((token) => {
155
- return token.symbol !== nativeTokenSymbol && token.symbol !== "usdc";
156
- });
157
- const createDefaultToken = (symbol) => {
158
- const baseToken = {
159
- symbol,
160
- name: symbol,
161
- amount: "0",
162
- decimals: 0,
163
- rawAmount: "0"
164
- };
165
- let chainSpecificField = {};
166
- if (this.chain === "solana") {
167
- chainSpecificField = { mintHash: void 0 };
168
- } else if (this.chain === "stellar") {
169
- chainSpecificField = { contractId: void 0 };
170
- } else {
171
- chainSpecificField = { contractAddress: void 0 };
172
- }
173
- return _chunkUO2J2ZB2cjs.__spreadValues.call(void 0, _chunkUO2J2ZB2cjs.__spreadValues.call(void 0, {}, baseToken), chainSpecificField);
174
- };
175
- return {
176
- nativeToken: nativeTokenData != null ? transformTokenBalance(nativeTokenData) : createDefaultToken(nativeTokenSymbol),
177
- usdc: usdcData != null ? transformTokenBalance(usdcData) : createDefaultToken("usdc"),
178
- tokens: otherTokens.map(transformTokenBalance)
179
- };
180
- }
181
- /**
182
- * Get the wallet NFTs
183
- * @param {Object} params - The parameters
184
- * @param {number} params.perPage - The number of NFTs per page
185
- * @param {number} params.page - The page number
186
- * @param {WalletLocator} [params.locator] - The locator
187
- * @returns The NFTs
188
- * @experimental This API is experimental and may change in the future
189
- */
190
- experimental_nfts(params) {
191
- return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
192
- return yield _chunkUO2J2ZB2cjs.__privateGet.call(void 0, this, _apiClient).experimental_getNfts(_chunkUO2J2ZB2cjs.__spreadProps.call(void 0, _chunkUO2J2ZB2cjs.__spreadValues.call(void 0, {}, params), {
193
- chain: this.chain,
194
- address: this.address
195
- }));
196
- });
197
- }
198
- /**
199
- * Get the wallet transactions
200
- * @returns The transactions
201
- * @throws {Error} If the transactions cannot be retrieved
202
- */
203
- experimental_transactions() {
204
- return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
205
- const response = yield _chunkUO2J2ZB2cjs.__privateGet.call(void 0, this, _apiClient).getTransactions(this.walletLocator);
206
- if ("error" in response) {
207
- throw new Error(`Failed to get transactions: ${JSON.stringify(response.message)}`);
208
- }
209
- return response;
210
- });
211
- }
212
- /**
213
- * Get a transaction by id
214
- * @returns The transaction
215
- * @throws {Error} If the transaction cannot be retrieved
216
- */
217
- experimental_transaction(transactionId) {
218
- return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
219
- const response = yield _chunkUO2J2ZB2cjs.__privateGet.call(void 0, this, _apiClient).getTransaction(this.walletLocator, transactionId);
220
- if ("error" in response) {
221
- throw new Error(`Failed to get transaction: ${JSON.stringify(response.error)}`);
222
- }
223
- return response;
224
- });
225
- }
226
- /**
227
- * Get the wallet activity
228
- * @returns The activity
229
- * @experimental This API is experimental and may change in the future
230
- * @throws {Error} If the activity cannot be retrieved
231
- */
232
- experimental_activity() {
233
- return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
234
- const resolvedChain = this.resolveChainForEnvironment();
235
- const response = yield this.apiClient.experimental_activity(this.walletLocator, { chain: resolvedChain });
236
- if ("error" in response) {
237
- throw new Error(`Failed to get activity: ${JSON.stringify(response.message)}`);
238
- }
239
- return response;
240
- });
241
- }
242
- send(to, token, amount, options) {
243
- return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
244
- const resolvedChain = this.resolveChainForEnvironment();
245
- const recipient = toRecipientLocator(to);
246
- const tokenLocator = toTokenLocator(token, resolvedChain);
247
- _chunkJREZWZ2Scjs.walletsLogger.info("wallet.send.start", _chunkUO2J2ZB2cjs.__spreadValues.call(void 0, {
248
- recipient,
249
- token: tokenLocator,
250
- amount
251
- }, (options == null ? void 0 : options.transactionType) != null ? { transactionType: options.transactionType } : {}));
252
- yield this.preAuthIfNeeded();
253
- const sendParams = _chunkUO2J2ZB2cjs.__spreadValues.call(void 0, _chunkUO2J2ZB2cjs.__spreadValues.call(void 0, {
254
- recipient,
255
- amount
256
- }, (options == null ? void 0 : options.experimental_signer) != null ? { signer: options.experimental_signer } : {}), (options == null ? void 0 : options.transactionType) != null ? { transactionType: options.transactionType } : {});
257
- const transactionCreationResponse = yield _chunkUO2J2ZB2cjs.__privateGet.call(void 0, this, _apiClient).send(this.walletLocator, tokenLocator, sendParams);
258
- if ("message" in transactionCreationResponse) {
259
- _chunkJREZWZ2Scjs.walletsLogger.error("wallet.send.error", {
260
- error: transactionCreationResponse
261
- });
262
- throw new (0, _chunkXC2V34TScjs.TransactionNotCreatedError)(
263
- `Failed to send token: ${JSON.stringify(transactionCreationResponse.message)}`
264
- );
265
- }
266
- if (options == null ? void 0 : options.experimental_prepareOnly) {
267
- _chunkJREZWZ2Scjs.walletsLogger.info("wallet.send.prepared", {
268
- transactionId: transactionCreationResponse.id
269
- });
270
- return {
271
- hash: void 0,
272
- explorerLink: void 0,
273
- transactionId: transactionCreationResponse.id
274
- };
275
- }
276
- const result = yield this.approveTransactionAndWait(transactionCreationResponse.id);
277
- _chunkJREZWZ2Scjs.walletsLogger.info("wallet.send.success", {
278
- transactionId: transactionCreationResponse.id,
279
- hash: result.hash
280
- });
281
- return result;
282
- });
283
- }
284
- /**
285
- * @deprecated Use `approve` instead.
286
- * Approve a transaction
287
- * @param params - The parameters
288
- * @param params.transactionId - The transaction id
289
- * @param params.options - The options for the transaction
290
- * @param params.options.experimental_approval - The approval
291
- * @param params.options.additionalSigners - The additional signers
292
- * @returns The transaction
293
- */
294
- // TODO: Remove this method in the next major version
295
- approveTransaction(params) {
296
- return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
297
- console.warn(
298
- "approveTransaction is deprecated. Use approve instead. This method will be removed in the next major version."
299
- );
300
- return yield this.approve(params);
301
- });
302
- }
303
- approve(params) {
304
- return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
305
- _chunkJREZWZ2Scjs.walletsLogger.info("wallet.approve.start", {
306
- transactionId: params.transactionId,
307
- signatureId: params.signatureId
308
- });
309
- if (params.transactionId != null) {
310
- const result = yield this.approveTransactionAndWait(
311
- params.transactionId,
312
- params.options
313
- );
314
- _chunkJREZWZ2Scjs.walletsLogger.info("wallet.approve.success", {
315
- transactionId: params.transactionId
316
- });
317
- return result;
318
- }
319
- if (params.signatureId != null) {
320
- const result = yield this.approveSignatureAndWait(params.signatureId, params.options);
321
- _chunkJREZWZ2Scjs.walletsLogger.info("wallet.approve.success", {
322
- signatureId: params.signatureId
323
- });
324
- return result;
325
- }
326
- _chunkJREZWZ2Scjs.walletsLogger.error("wallet.approve.error", {
327
- error: "Either transactionId or signatureId must be provided"
328
- });
329
- throw new Error("Either transactionId or signatureId must be provided");
330
- });
331
- }
332
- addDelegatedSigner(params) {
333
- return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
334
- var _a, _b, _c;
335
- _chunkJREZWZ2Scjs.walletsLogger.info("wallet.addDelegatedSigner.start");
336
- const response = yield _chunkUO2J2ZB2cjs.__privateGet.call(void 0, this, _apiClient).registerSigner(this.walletLocator, {
337
- signer: params.signer,
338
- chain: this.chain === "solana" || this.chain === "stellar" ? void 0 : this.chain
339
- });
340
- if ("error" in response) {
341
- _chunkJREZWZ2Scjs.walletsLogger.error("wallet.addDelegatedSigner.error", {
342
- error: response
343
- });
344
- throw new Error(`Failed to register signer: ${JSON.stringify(response.message)}`);
345
- }
346
- if (this.chain === "solana" || this.chain === "stellar") {
347
- if (!("transaction" in response) || response.transaction == null) {
348
- _chunkJREZWZ2Scjs.walletsLogger.error("wallet.addDelegatedSigner.error", {
349
- error: "Expected transaction in response for Solana/Stellar chain"
350
- });
351
- throw new Error("Expected transaction in response for Solana/Stellar chain");
352
- }
353
- const transactionId = response.transaction.id;
354
- if ((_a = params.options) == null ? void 0 : _a.experimental_prepareOnly) {
355
- _chunkJREZWZ2Scjs.walletsLogger.info("wallet.addDelegatedSigner.prepared", {
356
- transactionId
357
- });
358
- return { transactionId };
359
- }
360
- yield this.approveTransactionAndWait(transactionId);
361
- _chunkJREZWZ2Scjs.walletsLogger.info("wallet.addDelegatedSigner.success", {
362
- transactionId
363
- });
364
- return void 0;
365
- }
366
- if (!("chains" in response)) {
367
- _chunkJREZWZ2Scjs.walletsLogger.error("wallet.addDelegatedSigner.error", {
368
- error: "Expected chains in response for EVM chain"
369
- });
370
- throw new Error("Expected chains in response for EVM chain");
371
- }
372
- const chainResponse = (_b = response.chains) == null ? void 0 : _b[this.chain];
373
- if ((_c = params.options) == null ? void 0 : _c.experimental_prepareOnly) {
374
- const signatureId = (chainResponse == null ? void 0 : chainResponse.status) !== "success" ? chainResponse == null ? void 0 : chainResponse.id : void 0;
375
- _chunkJREZWZ2Scjs.walletsLogger.info("wallet.addDelegatedSigner.prepared", {
376
- signatureId
377
- });
378
- return { signatureId };
379
- }
380
- if ((chainResponse == null ? void 0 : chainResponse.status) === "awaiting-approval") {
381
- yield this.approveSignatureAndWait(chainResponse.id);
382
- _chunkJREZWZ2Scjs.walletsLogger.info("wallet.addDelegatedSigner.success", {
383
- signatureId: chainResponse.id
384
- });
385
- return void 0;
386
- }
387
- if ((chainResponse == null ? void 0 : chainResponse.status) === "pending") {
388
- yield this.waitForSignature(chainResponse.id);
389
- _chunkJREZWZ2Scjs.walletsLogger.info("wallet.addDelegatedSigner.success", {
390
- signatureId: chainResponse.id
391
- });
392
- return void 0;
393
- }
394
- _chunkJREZWZ2Scjs.walletsLogger.info("wallet.addDelegatedSigner.success");
395
- return void 0;
396
- });
397
- }
398
- delegatedSigners() {
399
- return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
400
- var _a, _b, _c;
401
- _chunkJREZWZ2Scjs.walletsLogger.info("wallet.delegatedSigners.start");
402
- const walletResponse = yield _chunkUO2J2ZB2cjs.__privateGet.call(void 0, this, _apiClient).getWallet(this.walletLocator);
403
- if ("error" in walletResponse) {
404
- _chunkJREZWZ2Scjs.walletsLogger.error("wallet.delegatedSigners.error", {
405
- error: walletResponse
406
- });
407
- throw new (0, _chunkXC2V34TScjs.WalletNotAvailableError)(JSON.stringify(walletResponse));
408
- }
409
- if (walletResponse.type !== "smart" || walletResponse.chainType !== "evm" && walletResponse.chainType !== "solana" && walletResponse.chainType !== "stellar") {
410
- _chunkJREZWZ2Scjs.walletsLogger.error("wallet.delegatedSigners.error", {
411
- error: `Wallet type ${walletResponse.type} not supported`
412
- });
413
- throw new (0, _chunkXC2V34TScjs.WalletTypeNotSupportedError)(`Wallet type ${walletResponse.type} not supported`);
414
- }
415
- const signers = (_c = (_b = (_a = walletResponse == null ? void 0 : walletResponse.config) == null ? void 0 : _a.delegatedSigners) == null ? void 0 : _b.map((signer) => {
416
- const colonIndex = signer.locator.indexOf(":");
417
- const address = colonIndex >= 0 ? signer.locator.slice(colonIndex + 1) : signer.locator;
418
- return {
419
- signer: `external-wallet:${address}`
420
- };
421
- })) != null ? _c : [];
422
- _chunkJREZWZ2Scjs.walletsLogger.info("wallet.delegatedSigners.success", {
423
- count: signers.length
424
- });
425
- return signers;
426
- });
427
- }
428
- get walletLocator() {
429
- if (_chunkUO2J2ZB2cjs.__privateGet.call(void 0, this, _apiClient).isServerSide) {
430
- return this.address;
431
- } else {
432
- let baseLocator;
433
- switch (this.chain) {
434
- case "stellar":
435
- baseLocator = `me:stellar:smart`;
436
- break;
437
- case "solana":
438
- baseLocator = `me:solana:smart`;
439
- break;
440
- default:
441
- baseLocator = `me:evm:smart`;
442
- break;
443
- }
444
- const aliasLocatorPart = this.alias != null ? `:alias:${this.alias}` : "";
445
- return baseLocator + aliasLocatorPart;
446
- }
447
- }
448
- preAuthIfNeeded() {
449
- return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
450
- if (this.signer instanceof _chunkZAX22GSIcjs.NonCustodialSigner) {
451
- yield this.signer.ensureAuthenticated();
452
- }
453
- });
454
- }
455
- get isSolanaWallet() {
456
- return this.chain === "solana";
457
- }
458
- resolveChainForEnvironment() {
459
- const resolvedChain = _chunkWDZY4PP4cjs.validateChainForEnvironment.call(void 0, this.chain, _chunkUO2J2ZB2cjs.__privateGet.call(void 0, this, _apiClient).environment);
460
- if (resolvedChain !== this.chain) {
461
- this.chain = resolvedChain;
462
- }
463
- return this.chain;
464
- }
465
- approveTransactionAndWait(transactionId, options) {
466
- return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
467
- yield this.approveTransactionInternal(transactionId, options);
468
- yield this.sleep(1e3);
469
- return yield this.waitForTransaction(transactionId);
470
- });
471
- }
472
- approveSignatureAndWait(signatureId, options) {
473
- return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
474
- const signatureResponse = yield this.approveSignatureInternal(signatureId, options);
475
- if (!("error" in signatureResponse) && signatureResponse.status === "success" && signatureResponse.outputSignature != null) {
476
- return {
477
- signature: signatureResponse.outputSignature,
478
- signatureId
479
- };
480
- }
481
- yield this.sleep(1e3);
482
- return yield this.waitForSignature(signatureId);
483
- });
484
- }
485
- approveSignatureInternal(signatureId, options) {
486
- return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
487
- var _a, _b;
488
- if (this.isSolanaWallet) {
489
- throw new Error("Approving signatures is only supported for EVM smart wallets");
490
- }
491
- const signature = yield _chunkUO2J2ZB2cjs.__privateGet.call(void 0, this, _apiClient).getSignature(this.walletLocator, signatureId);
492
- if ("error" in signature) {
493
- throw new (0, _chunkXC2V34TScjs.SignatureNotAvailableError)(JSON.stringify(signature));
494
- }
495
- if (this.signer.type === "api-key") {
496
- return signature;
497
- }
498
- if ((options == null ? void 0 : options.experimental_approval) != null) {
499
- const approvals2 = [options.experimental_approval];
500
- return yield this.executeApproveSignatureWithErrorHandling(signatureId, approvals2);
501
- }
502
- const pendingApprovals = (_a = signature.approvals) == null ? void 0 : _a.pending;
503
- if (pendingApprovals == null) {
504
- return signature;
505
- }
506
- const signers = [...(_b = options == null ? void 0 : options.additionalSigners) != null ? _b : [], this.signer];
507
- const approvals = yield Promise.all(
508
- pendingApprovals.map((pendingApproval) => _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
509
- const signer = signers.find((s) => s.locator() === pendingApproval.signer.locator);
510
- if (signer == null) {
511
- throw new (0, _chunkXC2V34TScjs.InvalidSignerError)(`Signer ${pendingApproval.signer} not found in pending approvals`);
512
- }
513
- const signature2 = yield signer.signMessage(pendingApproval.message);
514
- return _chunkUO2J2ZB2cjs.__spreadProps.call(void 0, _chunkUO2J2ZB2cjs.__spreadValues.call(void 0, {}, signature2), {
515
- signer: signer.locator()
516
- });
517
- }))
518
- );
519
- return yield this.executeApproveSignatureWithErrorHandling(signatureId, approvals);
520
- });
521
- }
522
- approveTransactionInternal(transactionId, options) {
523
- return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
524
- var _a, _b, _c, _d, _e;
525
- const transaction = yield _chunkUO2J2ZB2cjs.__privateGet.call(void 0, this, _apiClient).getTransaction(this.walletLocator, transactionId);
526
- if ("error" in transaction) {
527
- throw new (0, _chunkXC2V34TScjs.TransactionNotAvailableError)(JSON.stringify(transaction));
528
- }
529
- yield (_c = (_b = (_a = _chunkUO2J2ZB2cjs.__privateGet.call(void 0, this, _options)) == null ? void 0 : _a.experimental_callbacks) == null ? void 0 : _b.onTransactionStart) == null ? void 0 : _c.call(_b);
530
- if (this.signer.type === "api-key") {
531
- return transaction;
532
- }
533
- if ((options == null ? void 0 : options.experimental_approval) != null) {
534
- const approvals2 = [options.experimental_approval];
535
- return yield this.executeApproveTransactionWithErrorHandling(transactionId, approvals2);
536
- }
537
- const pendingApprovals = (_d = transaction.approvals) == null ? void 0 : _d.pending;
538
- if (pendingApprovals == null) {
539
- return transaction;
540
- }
541
- const signers = [...(_e = options == null ? void 0 : options.additionalSigners) != null ? _e : [], this.signer];
542
- const approvals = yield Promise.all(
543
- pendingApprovals.map((pendingApproval) => _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
544
- const signer = signers.find((s) => s.locator() === pendingApproval.signer.locator);
545
- if (signer == null) {
546
- throw new (0, _chunkXC2V34TScjs.InvalidSignerError)(`Signer ${pendingApproval.signer} not found in pending approvals`);
547
- }
548
- const transactionToSign = transaction.chainType === "solana" && "transaction" in transaction.onChain ? transaction.onChain.transaction : pendingApproval.message;
549
- const signature = yield signer.signTransaction(transactionToSign);
550
- return _chunkUO2J2ZB2cjs.__spreadProps.call(void 0, _chunkUO2J2ZB2cjs.__spreadValues.call(void 0, {}, signature), {
551
- signer: signer.locator()
552
- });
553
- }))
554
- );
555
- return yield this.executeApproveTransactionWithErrorHandling(transactionId, approvals);
556
- });
557
- }
558
- executeApproveTransactionWithErrorHandling(transactionId, approvals) {
559
- return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
560
- _chunkJREZWZ2Scjs.walletsLogger.info("wallet.approve: submitting approval to API", { transactionId });
561
- const approvedTransaction = yield _chunkUO2J2ZB2cjs.__privateGet.call(void 0, this, _apiClient).approveTransaction(this.walletLocator, transactionId, {
562
- approvals
563
- });
564
- if (approvedTransaction.error) {
565
- throw new (0, _chunkXC2V34TScjs.TransactionFailedError)(JSON.stringify(approvedTransaction));
566
- }
567
- return approvedTransaction;
568
- });
569
- }
570
- executeApproveSignatureWithErrorHandling(signatureId, approvals) {
571
- return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
572
- const approvedSignature = yield _chunkUO2J2ZB2cjs.__privateGet.call(void 0, this, _apiClient).approveSignature(this.walletLocator, signatureId, {
573
- approvals
574
- });
575
- if (approvedSignature.error) {
576
- throw new (0, _chunkXC2V34TScjs.SignatureFailedError)(JSON.stringify(approvedSignature));
577
- }
578
- return approvedSignature;
579
- });
580
- }
581
- waitForSignature(signatureId) {
582
- return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
583
- let signatureResponse = null;
584
- do {
585
- yield new Promise((resolve) => setTimeout(resolve, _chunkR4AW5ADGcjs.STATUS_POLLING_INTERVAL_MS));
586
- signatureResponse = yield _chunkUO2J2ZB2cjs.__privateGet.call(void 0, this, _apiClient).getSignature(this.walletLocator, signatureId);
587
- if ("error" in signatureResponse) {
588
- throw new (0, _chunkXC2V34TScjs.SignatureNotAvailableError)(JSON.stringify(signatureResponse));
589
- }
590
- } while (signatureResponse === null || signatureResponse.status === "pending");
591
- if (signatureResponse.status === "failed") {
592
- throw new (0, _chunkXC2V34TScjs.SigningFailedError)("Signature signing failed");
593
- }
594
- if (!signatureResponse.outputSignature) {
595
- throw new (0, _chunkXC2V34TScjs.SignatureNotAvailableError)("Signature not available");
596
- }
597
- return {
598
- signature: signatureResponse.outputSignature,
599
- signatureId
600
- };
601
- });
602
- }
603
- waitForTransaction(_0) {
604
- return _chunkUO2J2ZB2cjs.__async.call(void 0, this, arguments, function* (transactionId, timeoutMs = 6e4, {
605
- backoffMultiplier = 1.1,
606
- maxBackoffMs = 2e3,
607
- initialBackoffMs = _chunkR4AW5ADGcjs.STATUS_POLLING_INTERVAL_MS
608
- } = {}) {
609
- var _a;
610
- _chunkJREZWZ2Scjs.walletsLogger.info("wallet.approve: waiting for transaction confirmation", { transactionId, timeoutMs });
611
- const startTime = Date.now();
612
- let transactionResponse;
613
- do {
614
- if (Date.now() - startTime > timeoutMs) {
615
- const error = new (0, _chunkXC2V34TScjs.TransactionConfirmationTimeoutError)("Transaction confirmation timeout");
616
- throw error;
617
- }
618
- transactionResponse = yield _chunkUO2J2ZB2cjs.__privateGet.call(void 0, this, _apiClient).getTransaction(this.walletLocator, transactionId);
619
- if (transactionResponse.error) {
620
- throw new (0, _chunkXC2V34TScjs.TransactionNotAvailableError)(JSON.stringify(transactionResponse));
621
- }
622
- yield this.sleep(initialBackoffMs);
623
- initialBackoffMs = Math.min(initialBackoffMs * backoffMultiplier, maxBackoffMs);
624
- } while (transactionResponse.status === "pending");
625
- if (transactionResponse.status === "failed") {
626
- const error = new (0, _chunkXC2V34TScjs.TransactionSendingFailedError)(
627
- `Transaction sending failed: ${JSON.stringify(transactionResponse.error)}`
628
- );
629
- throw error;
630
- }
631
- if (transactionResponse.status === "awaiting-approval") {
632
- const error = new (0, _chunkXC2V34TScjs.TransactionAwaitingApprovalError)(
633
- `Transaction is awaiting approval. Please submit required approvals before waiting for completion.`
634
- );
635
- throw error;
636
- }
637
- const transactionHash = transactionResponse.onChain.txId;
638
- if (transactionHash == null) {
639
- const error = new (0, _chunkXC2V34TScjs.TransactionHashNotFoundError)("Transaction hash not found on transaction response");
640
- throw error;
641
- }
642
- return {
643
- hash: transactionHash,
644
- explorerLink: (_a = transactionResponse.onChain.explorerLink) != null ? _a : "",
645
- transactionId: transactionResponse.id
646
- };
647
- });
648
- }
649
- sleep(ms) {
650
- return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
651
- return new Promise((resolve) => setTimeout(resolve, ms));
652
- });
653
- }
654
- };
655
- _options = new WeakMap();
656
- _apiClient = new WeakMap();
657
- _chunkUO2J2ZB2cjs.__decorateClass.call(void 0, [
658
- _commonsdkbase.WithLoggerContext.call(void 0, {
659
- logger: _chunkJREZWZ2Scjs.walletsLogger,
660
- methodName: "wallet.balances",
661
- buildContext(thisArg) {
662
- return { chain: thisArg.chain, address: thisArg.address };
663
- }
664
- })
665
- ], Wallet.prototype, "balances", 1);
666
- _chunkUO2J2ZB2cjs.__decorateClass.call(void 0, [
667
- _commonsdkbase.WithLoggerContext.call(void 0, {
668
- logger: _chunkJREZWZ2Scjs.walletsLogger,
669
- methodName: "wallet.stagingFund",
670
- buildContext(thisArg) {
671
- return { chain: thisArg.chain, address: thisArg.address };
672
- }
673
- })
674
- ], Wallet.prototype, "stagingFund", 1);
675
- _chunkUO2J2ZB2cjs.__decorateClass.call(void 0, [
676
- _commonsdkbase.WithLoggerContext.call(void 0, {
677
- logger: _chunkJREZWZ2Scjs.walletsLogger,
678
- methodName: "wallet.send",
679
- buildContext(thisArg) {
680
- return { chain: thisArg.chain, address: thisArg.address };
681
- }
682
- })
683
- ], Wallet.prototype, "send", 1);
684
- _chunkUO2J2ZB2cjs.__decorateClass.call(void 0, [
685
- _commonsdkbase.WithLoggerContext.call(void 0, {
686
- logger: _chunkJREZWZ2Scjs.walletsLogger,
687
- methodName: "wallet.approve",
688
- buildContext(thisArg) {
689
- return { chain: thisArg.chain, address: thisArg.address };
690
- }
691
- })
692
- ], Wallet.prototype, "approve", 1);
693
- _chunkUO2J2ZB2cjs.__decorateClass.call(void 0, [
694
- _commonsdkbase.WithLoggerContext.call(void 0, {
695
- logger: _chunkJREZWZ2Scjs.walletsLogger,
696
- methodName: "wallet.addDelegatedSigner",
697
- buildContext(thisArg) {
698
- return { chain: thisArg.chain, address: thisArg.address };
699
- }
700
- })
701
- ], Wallet.prototype, "addDelegatedSigner", 1);
702
- _chunkUO2J2ZB2cjs.__decorateClass.call(void 0, [
703
- _commonsdkbase.WithLoggerContext.call(void 0, {
704
- logger: _chunkJREZWZ2Scjs.walletsLogger,
705
- methodName: "wallet.delegatedSigners",
706
- buildContext(thisArg) {
707
- return { chain: thisArg.chain, address: thisArg.address };
708
- }
709
- })
710
- ], Wallet.prototype, "delegatedSigners", 1);
711
- function toRecipientLocator(to) {
712
- if (typeof to === "string") {
713
- return to;
714
- }
715
- if ("email" in to) {
716
- return `email:${to.email}`;
717
- }
718
- if ("x" in to) {
719
- return `x:${to.x}`;
720
- }
721
- if ("twitter" in to) {
722
- return `twitter:${to.twitter}`;
723
- }
724
- if ("phone" in to) {
725
- return `phoneNumber:${to.phone}`;
726
- }
727
- if ("userId" in to) {
728
- return `userId:${to.userId}`;
729
- }
730
- throw new Error("Invalid recipient locator");
731
- }
732
- function toTokenLocator(token, chain) {
733
- if (_commonsdkbase.isValidAddress.call(void 0, token)) {
734
- return `${chain}:${token}`;
735
- }
736
- return `${chain}:${token.toLowerCase()}`;
737
- }
738
-
739
-
740
-
741
- exports.Wallet = Wallet;