@crossmint/wallets-sdk 0.18.8 → 0.18.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/client.cjs +5 -5
- package/dist/api/client.js +4 -4
- package/dist/api/gen/client.gen.cjs +1 -1
- package/dist/api/gen/client.gen.js +1 -1
- package/dist/api/gen/index.cjs +4 -4
- package/dist/api/gen/index.js +3 -3
- package/dist/api/gen/sdk.gen.cjs +3 -3
- package/dist/api/gen/sdk.gen.js +2 -2
- package/dist/api/gen/types.gen.d.cts +35 -35
- package/dist/api/gen/types.gen.d.ts +35 -35
- package/dist/api/index.cjs +5 -5
- package/dist/api/index.js +4 -4
- package/dist/chains/chains.cjs +5 -4
- package/dist/chains/chains.d.cts +1 -1
- package/dist/chains/chains.d.ts +1 -1
- package/dist/chains/chains.js +4 -3
- package/dist/chains/definitions/arcTestnet.cjs +1 -1
- package/dist/chains/definitions/arcTestnet.js +1 -1
- package/dist/chains/definitions/story.cjs +1 -1
- package/dist/chains/definitions/story.js +1 -1
- package/dist/chains/definitions/storyTestnet.cjs +1 -1
- package/dist/chains/definitions/storyTestnet.js +1 -1
- package/dist/chains/definitions/tempoTestnet.cjs +7 -0
- package/dist/chains/definitions/tempoTestnet.d.cts +43 -0
- package/dist/chains/definitions/tempoTestnet.d.ts +43 -0
- package/dist/chains/definitions/tempoTestnet.js +7 -0
- package/dist/{chunk-ZTGRDOOH.js → chunk-2I2OFGNL.js} +1 -1
- package/dist/{chunk-ZPH2YLZO.js → chunk-3RSZDA3X.js} +2 -2
- package/dist/{chunk-MZBFXUHT.js → chunk-47WKYTRN.js} +1 -1
- package/dist/{chunk-BRNT3DZP.cjs → chunk-4GFSUI2I.cjs} +3 -3
- package/dist/{chunk-N3RG7OZW.cjs → chunk-5KFST6KH.cjs} +60 -37
- package/dist/chunk-6H6ZBJC2.cjs +25 -0
- package/dist/chunk-6Z5QSTIS.cjs +58 -0
- package/dist/{chunk-YSDATSFB.js → chunk-73EJIGRV.js} +30 -7
- package/dist/{chunk-AL77JANE.js → chunk-7GOUUPS4.js} +1 -1
- package/dist/{chunk-LLDPJU6L.cjs → chunk-AN7MHABM.cjs} +6 -6
- package/dist/{chunk-FPMW7Q5O.js → chunk-ASE2FXWP.js} +10 -0
- package/dist/{chunk-ZBW2YHQZ.cjs → chunk-AZIXXLMP.cjs} +29 -29
- package/dist/{chunk-RTRDZB52.js → chunk-BMMZIPXT.js} +1 -1
- package/dist/{chunk-V3QJQUT7.cjs → chunk-COR3CNRW.cjs} +128 -128
- package/dist/{chunk-SXR4KWXS.js → chunk-CQNVHQHH.js} +3 -3
- package/dist/{chunk-V3FETRWW.js → chunk-FOOISYCJ.js} +1 -1
- package/dist/{chunk-FWC2WXFN.cjs → chunk-GRAV7BTN.cjs} +31 -8
- package/dist/{chunk-6QEK7D2B.cjs → chunk-GROJZ247.cjs} +10 -4
- package/dist/{chunk-YBA7WO32.cjs → chunk-IOMKHF6R.cjs} +3 -3
- package/dist/{chunk-EYJQSDDI.js → chunk-IPO25BCU.js} +1 -1
- package/dist/{chunk-4NHVYWZC.js → chunk-IYTDGUGZ.js} +116 -50
- package/dist/chunk-IZJUOXOZ.js +25 -0
- package/dist/{chunk-CHGPNMRL.cjs → chunk-JSWTGW46.cjs} +3 -3
- package/dist/{chunk-K5HDSLUV.js → chunk-KMHPLOVX.js} +4 -4
- package/dist/{chunk-ASJVZCHA.js → chunk-LVSVT2VD.js} +1 -1
- package/dist/{chunk-SD7I7CQ4.cjs → chunk-MNJA5EPY.cjs} +6 -6
- package/dist/{chunk-2JCKWYGA.cjs → chunk-NBDHZJ44.cjs} +11 -11
- package/dist/{chunk-3ZIQQ4PW.js → chunk-NIHJXITI.js} +52 -29
- package/dist/{chunk-PROOTUIO.js → chunk-NJTKHWXR.js} +10 -4
- package/dist/{chunk-4CPLMKRO.cjs → chunk-OFQDCA2H.cjs} +1 -1
- package/dist/{chunk-PCFXTJL4.cjs → chunk-OWGPEA2A.cjs} +3 -3
- package/dist/{chunk-DQCXGBZM.js → chunk-PIFD6KNH.js} +1 -1
- package/dist/{chunk-WC7T2CR4.js → chunk-PK7J3Y3L.js} +1 -1
- package/dist/{chunk-R2OY54EJ.cjs → chunk-Q5KNPVYI.cjs} +3 -3
- package/dist/{chunk-Y24JAHPT.cjs → chunk-QXJZ75GW.cjs} +166 -100
- package/dist/{chunk-7L5EEVWT.js → chunk-R5TY6M5Z.js} +66 -9
- package/dist/{chunk-NUOU3SCU.js → chunk-RCK3ZEP7.js} +2 -2
- package/dist/{chunk-TR2CW644.js → chunk-SYZKDDGK.js} +2 -2
- package/dist/{chunk-EAMPCH35.cjs → chunk-TEQYWMHS.cjs} +13 -13
- package/dist/{chunk-BQF3R3BC.cjs → chunk-TYN3KL7U.cjs} +33 -10
- package/dist/{chunk-G5NYLGM5.cjs → chunk-UO2J2ZB2.cjs} +11 -1
- package/dist/{chunk-HNISEOCV.js → chunk-UPS2UQJO.js} +2 -2
- package/dist/{chunk-M4JBQNOI.cjs → chunk-UXNFYAIS.cjs} +71 -14
- package/dist/{chunk-ZFFB4RDK.js → chunk-UZN67GMO.js} +9 -9
- package/dist/{chunk-5BSYP2R3.cjs → chunk-WFGKVGZ2.cjs} +7 -7
- package/dist/{chunk-LLFD22UQ.cjs → chunk-XOCC3MPK.cjs} +3 -3
- package/dist/{chunk-V2DJ5TIR.js → chunk-YNLL6GP4.js} +29 -6
- package/dist/{chunk-VRMQGFQX.js → chunk-ZJUXMOUB.js} +1 -1
- package/dist/{chunk-BSC55MYK.cjs → chunk-ZNAGDENG.cjs} +3 -3
- package/dist/{chunk-7ECQJFYM.cjs → chunk-ZTEMOYS2.cjs} +3 -3
- package/dist/index.cjs +26 -25
- package/dist/index.js +25 -24
- package/dist/logger/index.cjs +4 -4
- package/dist/logger/index.js +3 -3
- package/dist/logger/init.cjs +4 -4
- package/dist/logger/init.js +3 -3
- package/dist/sdk.cjs +20 -20
- package/dist/sdk.js +19 -19
- package/dist/signers/evm-api-key.cjs +3 -3
- package/dist/signers/evm-api-key.js +2 -2
- package/dist/signers/evm-external-wallet.cjs +3 -3
- package/dist/signers/evm-external-wallet.js +2 -2
- package/dist/signers/index.cjs +14 -14
- package/dist/signers/index.js +13 -13
- package/dist/signers/non-custodial/index.cjs +7 -7
- package/dist/signers/non-custodial/index.js +6 -6
- package/dist/signers/non-custodial/ncs-evm-signer.cjs +5 -5
- package/dist/signers/non-custodial/ncs-evm-signer.js +4 -4
- package/dist/signers/non-custodial/ncs-iframe-manager.cjs +3 -3
- package/dist/signers/non-custodial/ncs-iframe-manager.js +2 -2
- package/dist/signers/non-custodial/ncs-signer.cjs +4 -4
- package/dist/signers/non-custodial/ncs-signer.js +3 -3
- package/dist/signers/non-custodial/ncs-solana-signer.cjs +5 -5
- package/dist/signers/non-custodial/ncs-solana-signer.js +4 -4
- package/dist/signers/non-custodial/ncs-stellar-signer.cjs +5 -5
- package/dist/signers/non-custodial/ncs-stellar-signer.js +4 -4
- package/dist/signers/passkey.cjs +3 -3
- package/dist/signers/passkey.js +2 -2
- package/dist/signers/solana-api-key.cjs +3 -3
- package/dist/signers/solana-api-key.js +2 -2
- package/dist/signers/solana-external-wallet.cjs +3 -3
- package/dist/signers/solana-external-wallet.js +2 -2
- package/dist/signers/stellar-external-wallet.cjs +3 -3
- package/dist/signers/stellar-external-wallet.js +2 -2
- package/dist/signers/types.cjs +1 -1
- package/dist/signers/types.js +1 -1
- package/dist/utils/constants.cjs +3 -3
- package/dist/utils/constants.js +2 -2
- package/dist/utils/errors.cjs +1 -1
- package/dist/utils/errors.js +1 -1
- package/dist/utils/signer-validation.cjs +1 -1
- package/dist/utils/signer-validation.js +1 -1
- package/dist/wallets/evm.cjs +15 -12
- package/dist/wallets/evm.js +14 -11
- package/dist/wallets/solana.cjs +13 -11
- package/dist/wallets/solana.js +12 -10
- package/dist/wallets/stellar.cjs +12 -10
- package/dist/wallets/stellar.js +11 -9
- package/dist/wallets/wallet-factory.cjs +18 -18
- package/dist/wallets/wallet-factory.js +17 -17
- package/dist/wallets/wallet.cjs +11 -9
- package/dist/wallets/wallet.js +10 -8
- package/package.json +3 -3
- package/dist/chunk-3LKDNHF5.cjs +0 -58
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkTEQYWMHScjs = require('./chunk-TEQYWMHS.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
@@ -18,30 +18,34 @@ var _chunkEAMPCH35cjs = require('./chunk-EAMPCH35.cjs');
|
|
|
18
18
|
var _chunkXC2V34TScjs = require('./chunk-XC2V34TS.cjs');
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
var
|
|
21
|
+
var _chunkOWGPEA2Acjs = require('./chunk-OWGPEA2A.cjs');
|
|
22
22
|
|
|
23
23
|
|
|
24
|
+
var _chunkOFQDCA2Hcjs = require('./chunk-OFQDCA2H.cjs');
|
|
24
25
|
|
|
25
26
|
|
|
26
27
|
|
|
27
28
|
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
var _chunkUO2J2ZB2cjs = require('./chunk-UO2J2ZB2.cjs');
|
|
30
34
|
|
|
31
35
|
// src/wallets/wallet.ts
|
|
32
36
|
var _commonsdkbase = require('@crossmint/common-sdk-base');
|
|
33
37
|
var _options, _apiClient;
|
|
34
38
|
var Wallet = class {
|
|
35
39
|
constructor(args, apiClient) {
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
_chunkUO2J2ZB2cjs.__privateAdd.call(void 0, this, _options);
|
|
41
|
+
_chunkUO2J2ZB2cjs.__privateAdd.call(void 0, this, _apiClient);
|
|
38
42
|
const { chain, address, owner, signer, options, alias } = args;
|
|
39
|
-
|
|
43
|
+
_chunkUO2J2ZB2cjs.__privateSet.call(void 0, this, _apiClient, apiClient);
|
|
40
44
|
this.chain = chain;
|
|
41
45
|
this.address = address;
|
|
42
46
|
this.owner = owner;
|
|
43
47
|
this.signer = signer;
|
|
44
|
-
|
|
48
|
+
_chunkUO2J2ZB2cjs.__privateSet.call(void 0, this, _options, options);
|
|
45
49
|
this.alias = alias;
|
|
46
50
|
}
|
|
47
51
|
static getApiClient(wallet) {
|
|
@@ -51,10 +55,10 @@ var Wallet = class {
|
|
|
51
55
|
return wallet.options;
|
|
52
56
|
}
|
|
53
57
|
get apiClient() {
|
|
54
|
-
return
|
|
58
|
+
return _chunkUO2J2ZB2cjs.__privateGet.call(void 0, this, _apiClient);
|
|
55
59
|
}
|
|
56
60
|
get options() {
|
|
57
|
-
return
|
|
61
|
+
return _chunkUO2J2ZB2cjs.__privateGet.call(void 0, this, _options);
|
|
58
62
|
}
|
|
59
63
|
/**
|
|
60
64
|
* Get the API client
|
|
@@ -62,17 +66,11 @@ var Wallet = class {
|
|
|
62
66
|
* @experimental This API is experimental and may change in the future
|
|
63
67
|
*/
|
|
64
68
|
experimental_apiClient() {
|
|
65
|
-
return
|
|
69
|
+
return _chunkUO2J2ZB2cjs.__privateGet.call(void 0, this, _apiClient);
|
|
66
70
|
}
|
|
67
|
-
/**
|
|
68
|
-
* Get the wallet balances - always includes USDC and native token (ETH/SOL)
|
|
69
|
-
* @param {string[]} tokens - Additional tokens to request (optional: native token and usdc are always included)
|
|
70
|
-
* @param {Chain[]} chains - The chains (optional)
|
|
71
|
-
* @returns {Promise<Balances<C>>} The balances returns nativeToken, usdc, tokens
|
|
72
|
-
* @throws {Error} If the balances cannot be retrieved
|
|
73
|
-
*/
|
|
74
71
|
balances(tokens, chains) {
|
|
75
|
-
return
|
|
72
|
+
return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
|
|
73
|
+
_chunkOWGPEA2Acjs.walletsLogger.info("wallet.balances.start");
|
|
76
74
|
let nativeToken;
|
|
77
75
|
switch (this.chain) {
|
|
78
76
|
case "solana":
|
|
@@ -86,28 +84,21 @@ var Wallet = class {
|
|
|
86
84
|
break;
|
|
87
85
|
}
|
|
88
86
|
const allTokens = [nativeToken, "usdc", ...tokens != null ? tokens : []];
|
|
89
|
-
const response = yield
|
|
87
|
+
const response = yield _chunkUO2J2ZB2cjs.__privateGet.call(void 0, this, _apiClient).getBalance(this.address, {
|
|
90
88
|
chains: chains != null ? chains : [this.chain],
|
|
91
89
|
tokens: allTokens
|
|
92
90
|
});
|
|
93
91
|
if ("error" in response) {
|
|
92
|
+
_chunkOWGPEA2Acjs.walletsLogger.error("wallet.balances.error", { error: response });
|
|
94
93
|
throw new Error(`Failed to get balances for wallet: ${JSON.stringify(response.message)}`);
|
|
95
94
|
}
|
|
95
|
+
_chunkOWGPEA2Acjs.walletsLogger.info("wallet.balances.success");
|
|
96
96
|
return this.transformBalanceResponse(response, nativeToken, tokens);
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
|
-
/**
|
|
100
|
-
* Funds the wallet with Crossmint's stablecoin (USDXM).
|
|
101
|
-
*
|
|
102
|
-
* **Note:** This method is only available in staging environments and exclusively supports USDXM tokens.
|
|
103
|
-
* It cannot be used in production environments.
|
|
104
|
-
* @param amount - The amount of USDXM to fund the wallet with
|
|
105
|
-
* @param chain - Optional chain to fund on. If not provided, uses the wallet's default chain
|
|
106
|
-
* @returns The funding response
|
|
107
|
-
* @throws {Error} If the funding operation fails or if called in a production environment
|
|
108
|
-
*/
|
|
109
99
|
stagingFund(amount, chain) {
|
|
110
|
-
return
|
|
100
|
+
return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
|
|
101
|
+
_chunkOWGPEA2Acjs.walletsLogger.info("wallet.stagingFund.start", { amount, chain: chain != null ? chain : this.chain });
|
|
111
102
|
const response = yield this.apiClient.fundWallet(this.address, {
|
|
112
103
|
amount,
|
|
113
104
|
token: "usdxm",
|
|
@@ -116,8 +107,10 @@ var Wallet = class {
|
|
|
116
107
|
chain: chain != null ? chain : this.chain
|
|
117
108
|
});
|
|
118
109
|
if ("error" in response) {
|
|
110
|
+
_chunkOWGPEA2Acjs.walletsLogger.error("wallet.stagingFund.error", { error: response });
|
|
119
111
|
throw new Error(`Failed to fund wallet: ${JSON.stringify(response.message)}`);
|
|
120
112
|
}
|
|
113
|
+
_chunkOWGPEA2Acjs.walletsLogger.info("wallet.stagingFund.success");
|
|
121
114
|
return response;
|
|
122
115
|
});
|
|
123
116
|
}
|
|
@@ -137,7 +130,7 @@ var Wallet = class {
|
|
|
137
130
|
} else if (chainData != null && "contractAddress" in chainData) {
|
|
138
131
|
chainSpecificField = { contractAddress: chainData.contractAddress };
|
|
139
132
|
}
|
|
140
|
-
return
|
|
133
|
+
return _chunkUO2J2ZB2cjs.__spreadValues.call(void 0, {
|
|
141
134
|
symbol: (_b = tokenData.symbol) != null ? _b : "",
|
|
142
135
|
name: (_c = tokenData.name) != null ? _c : "",
|
|
143
136
|
amount: (_d = tokenData.amount) != null ? _d : "0",
|
|
@@ -166,7 +159,7 @@ var Wallet = class {
|
|
|
166
159
|
} else {
|
|
167
160
|
chainSpecificField = { contractAddress: void 0 };
|
|
168
161
|
}
|
|
169
|
-
return
|
|
162
|
+
return _chunkUO2J2ZB2cjs.__spreadValues.call(void 0, _chunkUO2J2ZB2cjs.__spreadValues.call(void 0, {}, baseToken), chainSpecificField);
|
|
170
163
|
};
|
|
171
164
|
return {
|
|
172
165
|
nativeToken: nativeTokenData != null ? transformTokenBalance(nativeTokenData) : createDefaultToken(nativeTokenSymbol),
|
|
@@ -184,8 +177,8 @@ var Wallet = class {
|
|
|
184
177
|
* @experimental This API is experimental and may change in the future
|
|
185
178
|
*/
|
|
186
179
|
experimental_nfts(params) {
|
|
187
|
-
return
|
|
188
|
-
return yield
|
|
180
|
+
return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
|
|
181
|
+
return yield _chunkUO2J2ZB2cjs.__privateGet.call(void 0, this, _apiClient).experimental_getNfts(_chunkUO2J2ZB2cjs.__spreadProps.call(void 0, _chunkUO2J2ZB2cjs.__spreadValues.call(void 0, {}, params), {
|
|
189
182
|
chain: this.chain,
|
|
190
183
|
address: this.address
|
|
191
184
|
}));
|
|
@@ -197,8 +190,8 @@ var Wallet = class {
|
|
|
197
190
|
* @throws {Error} If the transactions cannot be retrieved
|
|
198
191
|
*/
|
|
199
192
|
experimental_transactions() {
|
|
200
|
-
return
|
|
201
|
-
const response = yield
|
|
193
|
+
return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
|
|
194
|
+
const response = yield _chunkUO2J2ZB2cjs.__privateGet.call(void 0, this, _apiClient).getTransactions(this.walletLocator);
|
|
202
195
|
if ("error" in response) {
|
|
203
196
|
throw new Error(`Failed to get transactions: ${JSON.stringify(response.message)}`);
|
|
204
197
|
}
|
|
@@ -211,8 +204,8 @@ var Wallet = class {
|
|
|
211
204
|
* @throws {Error} If the transaction cannot be retrieved
|
|
212
205
|
*/
|
|
213
206
|
experimental_transaction(transactionId) {
|
|
214
|
-
return
|
|
215
|
-
const response = yield
|
|
207
|
+
return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
|
|
208
|
+
const response = yield _chunkUO2J2ZB2cjs.__privateGet.call(void 0, this, _apiClient).getTransaction(this.walletLocator, transactionId);
|
|
216
209
|
if ("error" in response) {
|
|
217
210
|
throw new Error(`Failed to get transaction: ${JSON.stringify(response.error)}`);
|
|
218
211
|
}
|
|
@@ -226,7 +219,7 @@ var Wallet = class {
|
|
|
226
219
|
* @throws {Error} If the activity cannot be retrieved
|
|
227
220
|
*/
|
|
228
221
|
experimental_activity() {
|
|
229
|
-
return
|
|
222
|
+
return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
|
|
230
223
|
const response = yield this.apiClient.experimental_activity(this.walletLocator, { chain: this.chain });
|
|
231
224
|
if ("error" in response) {
|
|
232
225
|
throw new Error(`Failed to get activity: ${JSON.stringify(response.message)}`);
|
|
@@ -234,37 +227,37 @@ var Wallet = class {
|
|
|
234
227
|
return response;
|
|
235
228
|
});
|
|
236
229
|
}
|
|
237
|
-
/**
|
|
238
|
-
* Send a token to a wallet or user locator
|
|
239
|
-
* @param {string | UserLocator} to - The recipient (address or user locator)
|
|
240
|
-
* @param {string} token - The token (address or currency symbol)
|
|
241
|
-
* @param {string} amount - The amount to send (decimal units)
|
|
242
|
-
* @param {TransactionInputOptions} options - The options for the transaction
|
|
243
|
-
* @returns {Transaction} The transaction
|
|
244
|
-
*/
|
|
245
230
|
send(to, token, amount, options) {
|
|
246
|
-
return
|
|
247
|
-
yield this.preAuthIfNeeded();
|
|
231
|
+
return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
|
|
248
232
|
const recipient = toRecipientLocator(to);
|
|
249
233
|
const tokenLocator = toTokenLocator(token, this.chain);
|
|
250
|
-
|
|
234
|
+
_chunkOWGPEA2Acjs.walletsLogger.info("wallet.send.start", { recipient, token: tokenLocator, amount });
|
|
235
|
+
yield this.preAuthIfNeeded();
|
|
236
|
+
const sendParams = _chunkUO2J2ZB2cjs.__spreadValues.call(void 0, {
|
|
251
237
|
recipient,
|
|
252
238
|
amount
|
|
253
239
|
}, (options == null ? void 0 : options.experimental_signer) != null ? { signer: options.experimental_signer } : {});
|
|
254
|
-
const transactionCreationResponse = yield
|
|
240
|
+
const transactionCreationResponse = yield _chunkUO2J2ZB2cjs.__privateGet.call(void 0, this, _apiClient).send(this.walletLocator, tokenLocator, sendParams);
|
|
255
241
|
if ("message" in transactionCreationResponse) {
|
|
242
|
+
_chunkOWGPEA2Acjs.walletsLogger.error("wallet.send.error", { error: transactionCreationResponse });
|
|
256
243
|
throw new (0, _chunkXC2V34TScjs.TransactionNotCreatedError)(
|
|
257
244
|
`Failed to send token: ${JSON.stringify(transactionCreationResponse.message)}`
|
|
258
245
|
);
|
|
259
246
|
}
|
|
260
247
|
if (options == null ? void 0 : options.experimental_prepareOnly) {
|
|
248
|
+
_chunkOWGPEA2Acjs.walletsLogger.info("wallet.send.prepared", { transactionId: transactionCreationResponse.id });
|
|
261
249
|
return {
|
|
262
250
|
hash: void 0,
|
|
263
251
|
explorerLink: void 0,
|
|
264
252
|
transactionId: transactionCreationResponse.id
|
|
265
253
|
};
|
|
266
254
|
}
|
|
267
|
-
|
|
255
|
+
const result = yield this.approveTransactionAndWait(transactionCreationResponse.id);
|
|
256
|
+
_chunkOWGPEA2Acjs.walletsLogger.info("wallet.send.success", {
|
|
257
|
+
transactionId: transactionCreationResponse.id,
|
|
258
|
+
hash: result.hash
|
|
259
|
+
});
|
|
260
|
+
return result;
|
|
268
261
|
});
|
|
269
262
|
}
|
|
270
263
|
/**
|
|
@@ -279,101 +272,120 @@ var Wallet = class {
|
|
|
279
272
|
*/
|
|
280
273
|
// TODO: Remove this method in the next major version
|
|
281
274
|
approveTransaction(params) {
|
|
282
|
-
return
|
|
275
|
+
return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
|
|
283
276
|
console.warn(
|
|
284
277
|
"approveTransaction is deprecated. Use approve instead. This method will be removed in the next major version."
|
|
285
278
|
);
|
|
286
279
|
return yield this.approve(params);
|
|
287
280
|
});
|
|
288
281
|
}
|
|
289
|
-
/**
|
|
290
|
-
* Approve a transaction or signature
|
|
291
|
-
* @param params - The parameters
|
|
292
|
-
* @param params.transactionId - The transaction id or
|
|
293
|
-
* @param params.signatureId - The signature id
|
|
294
|
-
* @param params.options - The options for the transaction
|
|
295
|
-
* @param params.options.experimental_approval - The approval
|
|
296
|
-
* @param params.options.additionalSigners - The additional signers
|
|
297
|
-
* @returns The transaction or signature
|
|
298
|
-
*/
|
|
299
282
|
approve(params) {
|
|
300
|
-
return
|
|
283
|
+
return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
|
|
284
|
+
_chunkOWGPEA2Acjs.walletsLogger.info("wallet.approve.start", {
|
|
285
|
+
transactionId: params.transactionId,
|
|
286
|
+
signatureId: params.signatureId
|
|
287
|
+
});
|
|
301
288
|
if (params.transactionId != null) {
|
|
302
|
-
|
|
289
|
+
const result = yield this.approveTransactionAndWait(
|
|
290
|
+
params.transactionId,
|
|
291
|
+
params.options
|
|
292
|
+
);
|
|
293
|
+
_chunkOWGPEA2Acjs.walletsLogger.info("wallet.approve.success", { transactionId: params.transactionId });
|
|
294
|
+
return result;
|
|
303
295
|
}
|
|
304
296
|
if (params.signatureId != null) {
|
|
305
|
-
|
|
297
|
+
const result = yield this.approveSignatureAndWait(params.signatureId, params.options);
|
|
298
|
+
_chunkOWGPEA2Acjs.walletsLogger.info("wallet.approve.success", { signatureId: params.signatureId });
|
|
299
|
+
return result;
|
|
306
300
|
}
|
|
301
|
+
_chunkOWGPEA2Acjs.walletsLogger.error("wallet.approve.error", {
|
|
302
|
+
error: "Either transactionId or signatureId must be provided"
|
|
303
|
+
});
|
|
307
304
|
throw new Error("Either transactionId or signatureId must be provided");
|
|
308
305
|
});
|
|
309
306
|
}
|
|
310
|
-
/**
|
|
311
|
-
* Add a delegated signer to the wallet
|
|
312
|
-
* @param signer - The signer. For Solana, it must be a string. For EVM, it can be a string or a passkey.
|
|
313
|
-
* @param options - The options for the operation
|
|
314
|
-
* @param options.experimental_prepareOnly - If true, returns the transaction/signature ID without auto-approving
|
|
315
|
-
*/
|
|
316
307
|
addDelegatedSigner(params) {
|
|
317
|
-
return
|
|
308
|
+
return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
|
|
318
309
|
var _a, _b, _c;
|
|
319
|
-
|
|
310
|
+
_chunkOWGPEA2Acjs.walletsLogger.info("wallet.addDelegatedSigner.start");
|
|
311
|
+
const response = yield _chunkUO2J2ZB2cjs.__privateGet.call(void 0, this, _apiClient).registerSigner(this.walletLocator, {
|
|
320
312
|
signer: params.signer,
|
|
321
313
|
chain: this.chain === "solana" || this.chain === "stellar" ? void 0 : this.chain
|
|
322
314
|
});
|
|
323
315
|
if ("error" in response) {
|
|
316
|
+
_chunkOWGPEA2Acjs.walletsLogger.error("wallet.addDelegatedSigner.error", { error: response });
|
|
324
317
|
throw new Error(`Failed to register signer: ${JSON.stringify(response.message)}`);
|
|
325
318
|
}
|
|
326
319
|
if (this.chain === "solana" || this.chain === "stellar") {
|
|
327
320
|
if (!("transaction" in response) || response.transaction == null) {
|
|
321
|
+
_chunkOWGPEA2Acjs.walletsLogger.error("wallet.addDelegatedSigner.error", {
|
|
322
|
+
error: "Expected transaction in response for Solana/Stellar chain"
|
|
323
|
+
});
|
|
328
324
|
throw new Error("Expected transaction in response for Solana/Stellar chain");
|
|
329
325
|
}
|
|
330
326
|
const transactionId = response.transaction.id;
|
|
331
327
|
if ((_a = params.options) == null ? void 0 : _a.experimental_prepareOnly) {
|
|
328
|
+
_chunkOWGPEA2Acjs.walletsLogger.info("wallet.addDelegatedSigner.prepared", { transactionId });
|
|
332
329
|
return { transactionId };
|
|
333
330
|
}
|
|
334
331
|
yield this.approveTransactionAndWait(transactionId);
|
|
332
|
+
_chunkOWGPEA2Acjs.walletsLogger.info("wallet.addDelegatedSigner.success", { transactionId });
|
|
335
333
|
return void 0;
|
|
336
334
|
}
|
|
337
335
|
if (!("chains" in response)) {
|
|
336
|
+
_chunkOWGPEA2Acjs.walletsLogger.error("wallet.addDelegatedSigner.error", {
|
|
337
|
+
error: "Expected chains in response for EVM chain"
|
|
338
|
+
});
|
|
338
339
|
throw new Error("Expected chains in response for EVM chain");
|
|
339
340
|
}
|
|
340
341
|
const chainResponse = (_b = response.chains) == null ? void 0 : _b[this.chain];
|
|
341
342
|
if ((_c = params.options) == null ? void 0 : _c.experimental_prepareOnly) {
|
|
342
343
|
const signatureId = (chainResponse == null ? void 0 : chainResponse.status) !== "success" ? chainResponse == null ? void 0 : chainResponse.id : void 0;
|
|
344
|
+
_chunkOWGPEA2Acjs.walletsLogger.info("wallet.addDelegatedSigner.prepared", { signatureId });
|
|
343
345
|
return { signatureId };
|
|
344
346
|
}
|
|
345
347
|
if ((chainResponse == null ? void 0 : chainResponse.status) === "awaiting-approval") {
|
|
346
348
|
yield this.approveSignatureAndWait(chainResponse.id);
|
|
349
|
+
_chunkOWGPEA2Acjs.walletsLogger.info("wallet.addDelegatedSigner.success", { signatureId: chainResponse.id });
|
|
347
350
|
return void 0;
|
|
348
351
|
}
|
|
349
352
|
if ((chainResponse == null ? void 0 : chainResponse.status) === "pending") {
|
|
350
353
|
yield this.waitForSignature(chainResponse.id);
|
|
354
|
+
_chunkOWGPEA2Acjs.walletsLogger.info("wallet.addDelegatedSigner.success", { signatureId: chainResponse.id });
|
|
351
355
|
return void 0;
|
|
352
356
|
}
|
|
357
|
+
_chunkOWGPEA2Acjs.walletsLogger.info("wallet.addDelegatedSigner.success");
|
|
353
358
|
return void 0;
|
|
354
359
|
});
|
|
355
360
|
}
|
|
356
361
|
delegatedSigners() {
|
|
357
|
-
return
|
|
362
|
+
return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
|
|
358
363
|
var _a, _b, _c;
|
|
359
|
-
|
|
364
|
+
_chunkOWGPEA2Acjs.walletsLogger.info("wallet.delegatedSigners.start");
|
|
365
|
+
const walletResponse = yield _chunkUO2J2ZB2cjs.__privateGet.call(void 0, this, _apiClient).getWallet(this.walletLocator);
|
|
360
366
|
if ("error" in walletResponse) {
|
|
367
|
+
_chunkOWGPEA2Acjs.walletsLogger.error("wallet.delegatedSigners.error", { error: walletResponse });
|
|
361
368
|
throw new (0, _chunkXC2V34TScjs.WalletNotAvailableError)(JSON.stringify(walletResponse));
|
|
362
369
|
}
|
|
363
370
|
if (walletResponse.type !== "smart" || walletResponse.chainType !== "evm" && walletResponse.chainType !== "solana" && walletResponse.chainType !== "stellar") {
|
|
371
|
+
_chunkOWGPEA2Acjs.walletsLogger.error("wallet.delegatedSigners.error", {
|
|
372
|
+
error: `Wallet type ${walletResponse.type} not supported`
|
|
373
|
+
});
|
|
364
374
|
throw new (0, _chunkXC2V34TScjs.WalletTypeNotSupportedError)(`Wallet type ${walletResponse.type} not supported`);
|
|
365
375
|
}
|
|
366
|
-
|
|
376
|
+
const signers = (_c = (_b = (_a = walletResponse == null ? void 0 : walletResponse.config) == null ? void 0 : _a.delegatedSigners) == null ? void 0 : _b.map((signer) => {
|
|
367
377
|
const colonIndex = signer.locator.indexOf(":");
|
|
368
378
|
const address = colonIndex >= 0 ? signer.locator.slice(colonIndex + 1) : signer.locator;
|
|
369
379
|
return {
|
|
370
380
|
signer: `external-wallet:${address}`
|
|
371
381
|
};
|
|
372
382
|
})) != null ? _c : [];
|
|
383
|
+
_chunkOWGPEA2Acjs.walletsLogger.info("wallet.delegatedSigners.success", { count: signers.length });
|
|
384
|
+
return signers;
|
|
373
385
|
});
|
|
374
386
|
}
|
|
375
387
|
get walletLocator() {
|
|
376
|
-
if (
|
|
388
|
+
if (_chunkUO2J2ZB2cjs.__privateGet.call(void 0, this, _apiClient).isServerSide) {
|
|
377
389
|
return this.address;
|
|
378
390
|
} else {
|
|
379
391
|
let baseLocator;
|
|
@@ -393,8 +405,8 @@ var Wallet = class {
|
|
|
393
405
|
}
|
|
394
406
|
}
|
|
395
407
|
preAuthIfNeeded() {
|
|
396
|
-
return
|
|
397
|
-
if (this.signer instanceof
|
|
408
|
+
return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
|
|
409
|
+
if (this.signer instanceof _chunkTEQYWMHScjs.NonCustodialSigner) {
|
|
398
410
|
yield this.signer.ensureAuthenticated();
|
|
399
411
|
}
|
|
400
412
|
});
|
|
@@ -403,14 +415,14 @@ var Wallet = class {
|
|
|
403
415
|
return this.chain === "solana";
|
|
404
416
|
}
|
|
405
417
|
approveTransactionAndWait(transactionId, options) {
|
|
406
|
-
return
|
|
418
|
+
return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
|
|
407
419
|
yield this.approveTransactionInternal(transactionId, options);
|
|
408
420
|
yield this.sleep(1e3);
|
|
409
421
|
return yield this.waitForTransaction(transactionId);
|
|
410
422
|
});
|
|
411
423
|
}
|
|
412
424
|
approveSignatureAndWait(signatureId, options) {
|
|
413
|
-
return
|
|
425
|
+
return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
|
|
414
426
|
const signatureResponse = yield this.approveSignatureInternal(signatureId, options);
|
|
415
427
|
if (!("error" in signatureResponse) && signatureResponse.status === "success" && signatureResponse.outputSignature != null) {
|
|
416
428
|
return {
|
|
@@ -423,12 +435,12 @@ var Wallet = class {
|
|
|
423
435
|
});
|
|
424
436
|
}
|
|
425
437
|
approveSignatureInternal(signatureId, options) {
|
|
426
|
-
return
|
|
438
|
+
return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
|
|
427
439
|
var _a, _b;
|
|
428
440
|
if (this.isSolanaWallet) {
|
|
429
441
|
throw new Error("Approving signatures is only supported for EVM smart wallets");
|
|
430
442
|
}
|
|
431
|
-
const signature = yield
|
|
443
|
+
const signature = yield _chunkUO2J2ZB2cjs.__privateGet.call(void 0, this, _apiClient).getSignature(this.walletLocator, signatureId);
|
|
432
444
|
if ("error" in signature) {
|
|
433
445
|
throw new (0, _chunkXC2V34TScjs.SignatureNotAvailableError)(JSON.stringify(signature));
|
|
434
446
|
}
|
|
@@ -454,7 +466,7 @@ var Wallet = class {
|
|
|
454
466
|
})
|
|
455
467
|
);
|
|
456
468
|
const approvals = signedApprovals.map((signature2) => {
|
|
457
|
-
return
|
|
469
|
+
return _chunkUO2J2ZB2cjs.__spreadProps.call(void 0, _chunkUO2J2ZB2cjs.__spreadValues.call(void 0, {}, signature2), {
|
|
458
470
|
signer: this.signer.locator()
|
|
459
471
|
});
|
|
460
472
|
});
|
|
@@ -462,13 +474,13 @@ var Wallet = class {
|
|
|
462
474
|
});
|
|
463
475
|
}
|
|
464
476
|
approveTransactionInternal(transactionId, options) {
|
|
465
|
-
return
|
|
477
|
+
return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
|
|
466
478
|
var _a, _b, _c, _d, _e;
|
|
467
|
-
const transaction = yield
|
|
479
|
+
const transaction = yield _chunkUO2J2ZB2cjs.__privateGet.call(void 0, this, _apiClient).getTransaction(this.walletLocator, transactionId);
|
|
468
480
|
if ("error" in transaction) {
|
|
469
481
|
throw new (0, _chunkXC2V34TScjs.TransactionNotAvailableError)(JSON.stringify(transaction));
|
|
470
482
|
}
|
|
471
|
-
yield (_c = (_b = (_a =
|
|
483
|
+
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);
|
|
472
484
|
if (this.signer.type === "api-key") {
|
|
473
485
|
return transaction;
|
|
474
486
|
}
|
|
@@ -492,7 +504,7 @@ var Wallet = class {
|
|
|
492
504
|
})
|
|
493
505
|
);
|
|
494
506
|
const approvals = signedApprovals.map((signature) => {
|
|
495
|
-
return
|
|
507
|
+
return _chunkUO2J2ZB2cjs.__spreadProps.call(void 0, _chunkUO2J2ZB2cjs.__spreadValues.call(void 0, {}, signature), {
|
|
496
508
|
signer: this.signer.locator()
|
|
497
509
|
});
|
|
498
510
|
});
|
|
@@ -500,8 +512,8 @@ var Wallet = class {
|
|
|
500
512
|
});
|
|
501
513
|
}
|
|
502
514
|
executeApproveTransactionWithErrorHandling(transactionId, approvals) {
|
|
503
|
-
return
|
|
504
|
-
const approvedTransaction = yield
|
|
515
|
+
return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
|
|
516
|
+
const approvedTransaction = yield _chunkUO2J2ZB2cjs.__privateGet.call(void 0, this, _apiClient).approveTransaction(this.walletLocator, transactionId, {
|
|
505
517
|
approvals
|
|
506
518
|
});
|
|
507
519
|
if (approvedTransaction.error) {
|
|
@@ -511,8 +523,8 @@ var Wallet = class {
|
|
|
511
523
|
});
|
|
512
524
|
}
|
|
513
525
|
executeApproveSignatureWithErrorHandling(signatureId, approvals) {
|
|
514
|
-
return
|
|
515
|
-
const approvedSignature = yield
|
|
526
|
+
return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
|
|
527
|
+
const approvedSignature = yield _chunkUO2J2ZB2cjs.__privateGet.call(void 0, this, _apiClient).approveSignature(this.walletLocator, signatureId, {
|
|
516
528
|
approvals
|
|
517
529
|
});
|
|
518
530
|
if (approvedSignature.error) {
|
|
@@ -522,11 +534,11 @@ var Wallet = class {
|
|
|
522
534
|
});
|
|
523
535
|
}
|
|
524
536
|
waitForSignature(signatureId) {
|
|
525
|
-
return
|
|
537
|
+
return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
|
|
526
538
|
let signatureResponse = null;
|
|
527
539
|
do {
|
|
528
|
-
yield new Promise((resolve) => setTimeout(resolve,
|
|
529
|
-
signatureResponse = yield
|
|
540
|
+
yield new Promise((resolve) => setTimeout(resolve, _chunkOFQDCA2Hcjs.STATUS_POLLING_INTERVAL_MS));
|
|
541
|
+
signatureResponse = yield _chunkUO2J2ZB2cjs.__privateGet.call(void 0, this, _apiClient).getSignature(this.walletLocator, signatureId);
|
|
530
542
|
if ("error" in signatureResponse) {
|
|
531
543
|
throw new (0, _chunkXC2V34TScjs.SignatureNotAvailableError)(JSON.stringify(signatureResponse));
|
|
532
544
|
}
|
|
@@ -544,10 +556,10 @@ var Wallet = class {
|
|
|
544
556
|
});
|
|
545
557
|
}
|
|
546
558
|
waitForTransaction(_0) {
|
|
547
|
-
return
|
|
559
|
+
return _chunkUO2J2ZB2cjs.__async.call(void 0, this, arguments, function* (transactionId, timeoutMs = 6e4, {
|
|
548
560
|
backoffMultiplier = 1.1,
|
|
549
561
|
maxBackoffMs = 2e3,
|
|
550
|
-
initialBackoffMs =
|
|
562
|
+
initialBackoffMs = _chunkOFQDCA2Hcjs.STATUS_POLLING_INTERVAL_MS
|
|
551
563
|
} = {}) {
|
|
552
564
|
var _a;
|
|
553
565
|
const startTime = Date.now();
|
|
@@ -557,7 +569,7 @@ var Wallet = class {
|
|
|
557
569
|
const error = new (0, _chunkXC2V34TScjs.TransactionConfirmationTimeoutError)("Transaction confirmation timeout");
|
|
558
570
|
throw error;
|
|
559
571
|
}
|
|
560
|
-
transactionResponse = yield
|
|
572
|
+
transactionResponse = yield _chunkUO2J2ZB2cjs.__privateGet.call(void 0, this, _apiClient).getTransaction(this.walletLocator, transactionId);
|
|
561
573
|
if (transactionResponse.error) {
|
|
562
574
|
throw new (0, _chunkXC2V34TScjs.TransactionNotAvailableError)(JSON.stringify(transactionResponse));
|
|
563
575
|
}
|
|
@@ -589,13 +601,67 @@ var Wallet = class {
|
|
|
589
601
|
});
|
|
590
602
|
}
|
|
591
603
|
sleep(ms) {
|
|
592
|
-
return
|
|
604
|
+
return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
|
|
593
605
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
594
606
|
});
|
|
595
607
|
}
|
|
596
608
|
};
|
|
597
609
|
_options = new WeakMap();
|
|
598
610
|
_apiClient = new WeakMap();
|
|
611
|
+
_chunkUO2J2ZB2cjs.__decorateClass.call(void 0, [
|
|
612
|
+
_commonsdkbase.WithLoggerContext.call(void 0, {
|
|
613
|
+
logger: _chunkOWGPEA2Acjs.walletsLogger,
|
|
614
|
+
methodName: "wallet.balances",
|
|
615
|
+
buildContext(thisArg) {
|
|
616
|
+
return { chain: thisArg.chain, address: thisArg.address };
|
|
617
|
+
}
|
|
618
|
+
})
|
|
619
|
+
], Wallet.prototype, "balances", 1);
|
|
620
|
+
_chunkUO2J2ZB2cjs.__decorateClass.call(void 0, [
|
|
621
|
+
_commonsdkbase.WithLoggerContext.call(void 0, {
|
|
622
|
+
logger: _chunkOWGPEA2Acjs.walletsLogger,
|
|
623
|
+
methodName: "wallet.stagingFund",
|
|
624
|
+
buildContext(thisArg) {
|
|
625
|
+
return { chain: thisArg.chain, address: thisArg.address };
|
|
626
|
+
}
|
|
627
|
+
})
|
|
628
|
+
], Wallet.prototype, "stagingFund", 1);
|
|
629
|
+
_chunkUO2J2ZB2cjs.__decorateClass.call(void 0, [
|
|
630
|
+
_commonsdkbase.WithLoggerContext.call(void 0, {
|
|
631
|
+
logger: _chunkOWGPEA2Acjs.walletsLogger,
|
|
632
|
+
methodName: "wallet.send",
|
|
633
|
+
buildContext(thisArg) {
|
|
634
|
+
return { chain: thisArg.chain, address: thisArg.address };
|
|
635
|
+
}
|
|
636
|
+
})
|
|
637
|
+
], Wallet.prototype, "send", 1);
|
|
638
|
+
_chunkUO2J2ZB2cjs.__decorateClass.call(void 0, [
|
|
639
|
+
_commonsdkbase.WithLoggerContext.call(void 0, {
|
|
640
|
+
logger: _chunkOWGPEA2Acjs.walletsLogger,
|
|
641
|
+
methodName: "wallet.approve",
|
|
642
|
+
buildContext(thisArg) {
|
|
643
|
+
return { chain: thisArg.chain, address: thisArg.address };
|
|
644
|
+
}
|
|
645
|
+
})
|
|
646
|
+
], Wallet.prototype, "approve", 1);
|
|
647
|
+
_chunkUO2J2ZB2cjs.__decorateClass.call(void 0, [
|
|
648
|
+
_commonsdkbase.WithLoggerContext.call(void 0, {
|
|
649
|
+
logger: _chunkOWGPEA2Acjs.walletsLogger,
|
|
650
|
+
methodName: "wallet.addDelegatedSigner",
|
|
651
|
+
buildContext(thisArg) {
|
|
652
|
+
return { chain: thisArg.chain, address: thisArg.address };
|
|
653
|
+
}
|
|
654
|
+
})
|
|
655
|
+
], Wallet.prototype, "addDelegatedSigner", 1);
|
|
656
|
+
_chunkUO2J2ZB2cjs.__decorateClass.call(void 0, [
|
|
657
|
+
_commonsdkbase.WithLoggerContext.call(void 0, {
|
|
658
|
+
logger: _chunkOWGPEA2Acjs.walletsLogger,
|
|
659
|
+
methodName: "wallet.delegatedSigners",
|
|
660
|
+
buildContext(thisArg) {
|
|
661
|
+
return { chain: thisArg.chain, address: thisArg.address };
|
|
662
|
+
}
|
|
663
|
+
})
|
|
664
|
+
], Wallet.prototype, "delegatedSigners", 1);
|
|
599
665
|
function toRecipientLocator(to) {
|
|
600
666
|
if (typeof to === "string") {
|
|
601
667
|
return to;
|