@piprail/sdk 1.13.0 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHAINS.md +3 -2
- package/CHANGELOG.md +49 -0
- package/ERRORS.md +2 -1
- package/README.md +19 -2
- package/STANDARDS.md +2 -0
- package/dist/{algorand-WGVF4KTU.js → algorand-7EUZYL2Z.js} +1 -1
- package/dist/{algorand-MXUSKX46.cjs → algorand-OIHGJN5S.cjs} +17 -17
- package/dist/{aptos-LPBLSEIQ.js → aptos-CDEYDDM5.js} +1 -1
- package/dist/{aptos-YT7SXWPF.cjs → aptos-WDWZOU25.cjs} +16 -16
- package/dist/{chunk-MDLZJGLY.cjs → chunk-FTKVCP6K.cjs} +24 -13
- package/dist/{chunk-SVMGHASK.js → chunk-H3A4KWLJ.js} +12 -1
- package/dist/index.cjs +399 -145
- package/dist/index.d.cts +209 -31
- package/dist/index.d.ts +209 -31
- package/dist/index.js +308 -54
- package/dist/{near-K6BDBABG.js → near-DT6LRIKB.js} +1 -1
- package/dist/{near-7ZDNISUX.cjs → near-FUH3VAXT.cjs} +19 -19
- package/dist/{solana-S3UFI3FE.js → solana-3TRYD4QB.js} +1 -1
- package/dist/{solana-PU7N2M64.cjs → solana-QUVXPKBZ.cjs} +14 -14
- package/dist/{stellar-VDQOFQEO.cjs → stellar-APZEBFAD.cjs} +21 -21
- package/dist/{stellar-Q5PO23SC.js → stellar-IK3UML6O.js} +1 -1
- package/dist/{sui-FKSMLKRF.cjs → sui-L7BQNJWO.cjs} +17 -17
- package/dist/{sui-WOXRKJXS.js → sui-VSE63WQM.js} +1 -1
- package/dist/{ton-VK6KRJHP.cjs → ton-5DLKKOFE.cjs} +14 -14
- package/dist/{ton-WPTXGLVK.js → ton-QHGQLJX2.js} +1 -1
- package/dist/{tron-6GXBXTR4.js → tron-2N2GA62O.js} +1 -1
- package/dist/{tron-WLOF5OUV.cjs → tron-HHIT6WKY.cjs} +24 -24
- package/dist/{xrpl-HEAPEXAM.js → xrpl-2GZMDYW5.js} +1 -1
- package/dist/{xrpl-CMNI25BV.cjs → xrpl-USEG4AHX.cjs} +21 -21
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkFTKVCP6Kcjs = require('./chunk-FTKVCP6K.cjs');
|
|
11
11
|
|
|
12
12
|
// src/drivers/near/index.ts
|
|
13
13
|
var _nearapijs = require('near-api-js');
|
|
@@ -53,18 +53,18 @@ async function payNear(params) {
|
|
|
53
53
|
return res.hash;
|
|
54
54
|
} catch (err) {
|
|
55
55
|
if (isNearRegistrationError(err)) {
|
|
56
|
-
throw new (0,
|
|
56
|
+
throw new (0, _chunkFTKVCP6Kcjs.RecipientNotReadyError)(
|
|
57
57
|
`NEAR recipient ${accept.payTo} isn't registered on token ${accept.asset} (NEP-145 storage_deposit) \u2014 register it once (\u22480.00125 NEAR) before it can receive. (NEAR: not registered)`,
|
|
58
58
|
{ cause: err }
|
|
59
59
|
);
|
|
60
60
|
}
|
|
61
61
|
if (isNearAffordability(err)) {
|
|
62
|
-
throw new (0,
|
|
62
|
+
throw new (0, _chunkFTKVCP6Kcjs.InsufficientFundsError)(
|
|
63
63
|
err instanceof Error ? err.message : "Insufficient NEAR balance for the payment.",
|
|
64
64
|
{ cause: err }
|
|
65
65
|
);
|
|
66
66
|
}
|
|
67
|
-
throw _nullishCoalesce(
|
|
67
|
+
throw _nullishCoalesce(_chunkFTKVCP6Kcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
async function payNearNative(params) {
|
|
@@ -74,12 +74,12 @@ async function payNearNative(params) {
|
|
|
74
74
|
return res.hash;
|
|
75
75
|
} catch (err) {
|
|
76
76
|
if (isNearAffordability(err)) {
|
|
77
|
-
throw new (0,
|
|
77
|
+
throw new (0, _chunkFTKVCP6Kcjs.InsufficientFundsError)(
|
|
78
78
|
err instanceof Error ? err.message : "Insufficient NEAR balance for the payment.",
|
|
79
79
|
{ cause: err }
|
|
80
80
|
);
|
|
81
81
|
}
|
|
82
|
-
throw _nullishCoalesce(
|
|
82
|
+
throw _nullishCoalesce(_chunkFTKVCP6Kcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
function isNearRegistrationError(err) {
|
|
@@ -216,22 +216,22 @@ function txNotFound(hash) {
|
|
|
216
216
|
|
|
217
217
|
function assertNearWallet(wallet, network) {
|
|
218
218
|
if (typeof wallet !== "object" || wallet === null) {
|
|
219
|
-
throw new (0,
|
|
219
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
|
|
220
220
|
`chain ${network} is NEAR; wallet must be { accountId, privateKey } (privateKey = ed25519:\u2026).`
|
|
221
221
|
);
|
|
222
222
|
}
|
|
223
223
|
if ("walletClient" in wallet) {
|
|
224
|
-
throw new (0,
|
|
224
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
|
|
225
225
|
`chain ${network} is NEAR; a viem { walletClient } can't be used \u2014 pass { accountId, privateKey }.`
|
|
226
226
|
);
|
|
227
227
|
}
|
|
228
228
|
if ("secretKey" in wallet || "signer" in wallet || "mnemonic" in wallet || "keyPair" in wallet || "secret" in wallet || "seed" in wallet || "keypair" in wallet) {
|
|
229
|
-
throw new (0,
|
|
229
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
|
|
230
230
|
`chain ${network} is NEAR; that looks like another family's wallet \u2014 pass { accountId, privateKey }.`
|
|
231
231
|
);
|
|
232
232
|
}
|
|
233
233
|
if (!("accountId" in wallet) || !("privateKey" in wallet)) {
|
|
234
|
-
throw new (0,
|
|
234
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
|
|
235
235
|
`chain ${network} is NEAR; wallet must be { accountId, privateKey } (privateKey = ed25519:\u2026).`
|
|
236
236
|
);
|
|
237
237
|
}
|
|
@@ -239,13 +239,13 @@ function assertNearWallet(wallet, network) {
|
|
|
239
239
|
}
|
|
240
240
|
function resolveNearWallet(config) {
|
|
241
241
|
if (!config.accountId || !config.privateKey) {
|
|
242
|
-
throw new (0,
|
|
242
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)("NEAR wallet needs { accountId, privateKey } (privateKey = ed25519:\u2026).");
|
|
243
243
|
}
|
|
244
244
|
let signer;
|
|
245
245
|
try {
|
|
246
246
|
signer = _nearapijs.KeyPairSigner.fromSecretKey(config.privateKey);
|
|
247
247
|
} catch (cause) {
|
|
248
|
-
throw new (0,
|
|
248
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)("NEAR wallet { privateKey } is not a valid ed25519:\u2026 secret key.", {
|
|
249
249
|
cause
|
|
250
250
|
});
|
|
251
251
|
}
|
|
@@ -312,16 +312,16 @@ function makeNearNetwork(preset, rpcUrl) {
|
|
|
312
312
|
const info = preset.tokens[token.toUpperCase()];
|
|
313
313
|
if (!info) {
|
|
314
314
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
315
|
-
throw new (0,
|
|
315
|
+
throw new (0, _chunkFTKVCP6Kcjs.UnknownTokenError)(
|
|
316
316
|
`token "${token}" isn't built in for NEAR (known: ${known}). Pass { contractId, decimals } for a custom NEP-141.`
|
|
317
317
|
);
|
|
318
318
|
}
|
|
319
319
|
return { asset: info.contractId, decimals: info.decimals, symbol: info.symbol };
|
|
320
320
|
}
|
|
321
|
-
|
|
321
|
+
_chunkFTKVCP6Kcjs.rejectForeignToken.call(void 0, token, "near", network);
|
|
322
322
|
const t = token;
|
|
323
323
|
if (!t.contractId || typeof t.decimals !== "number") {
|
|
324
|
-
throw new (0,
|
|
324
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
|
|
325
325
|
`chain ${network} is NEAR; a custom token must be { contractId, decimals }.`
|
|
326
326
|
);
|
|
327
327
|
}
|
|
@@ -340,12 +340,12 @@ function makeNearNetwork(preset, rpcUrl) {
|
|
|
340
340
|
},
|
|
341
341
|
assertValidPayTo(payTo) {
|
|
342
342
|
if (payTo.startsWith("0x")) {
|
|
343
|
-
throw new (0,
|
|
343
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
|
|
344
344
|
`chain ${network} is NEAR, but payTo "${payTo}" looks like an EVM/Sui 0x address.`
|
|
345
345
|
);
|
|
346
346
|
}
|
|
347
347
|
if (!isValidNearAccountId(payTo)) {
|
|
348
|
-
throw new (0,
|
|
348
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
|
|
349
349
|
`chain ${network} is NEAR, but payTo "${payTo}" is not a valid NEAR account id.`
|
|
350
350
|
);
|
|
351
351
|
}
|
|
@@ -389,10 +389,10 @@ function makeNearNetwork(preset, rpcUrl) {
|
|
|
389
389
|
if (tx && tx.success) return { height: "0" };
|
|
390
390
|
} catch (e7) {
|
|
391
391
|
}
|
|
392
|
-
throw new (0,
|
|
392
|
+
throw new (0, _chunkFTKVCP6Kcjs.ConfirmationTimeoutError)(`NEAR tx ${hash} not confirmed in time.`);
|
|
393
393
|
},
|
|
394
394
|
async estimateCost() {
|
|
395
|
-
return
|
|
395
|
+
return _chunkFTKVCP6Kcjs.nativeCost.call(void 0, {
|
|
396
396
|
symbol: "NEAR",
|
|
397
397
|
decimals: NEAR_DECIMALS,
|
|
398
398
|
fee: 1500000000000000000000n,
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkFTKVCP6Kcjs = require('./chunk-FTKVCP6K.cjs');
|
|
9
9
|
|
|
10
10
|
// src/drivers/solana/index.ts
|
|
11
11
|
var _web3js = require('@solana/web3.js');
|
|
@@ -204,12 +204,12 @@ function notFound(signature) {
|
|
|
204
204
|
var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);
|
|
205
205
|
function toKeypair(wallet, network) {
|
|
206
206
|
if (typeof wallet !== "object" || wallet === null) {
|
|
207
|
-
throw new (0,
|
|
207
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
|
|
208
208
|
`chain ${network} is Solana; wallet must be { secretKey } or { signer }.`
|
|
209
209
|
);
|
|
210
210
|
}
|
|
211
211
|
if ("privateKey" in wallet || "walletClient" in wallet) {
|
|
212
|
-
throw new (0,
|
|
212
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
|
|
213
213
|
`chain ${network} is Solana; an EVM wallet can't be used \u2014 pass { secretKey } or { signer }.`
|
|
214
214
|
);
|
|
215
215
|
}
|
|
@@ -221,7 +221,7 @@ function toKeypair(wallet, network) {
|
|
|
221
221
|
const bytes = typeof sk === "string" ? _bs582.default.decode(sk) : sk;
|
|
222
222
|
return _web3js.Keypair.fromSecretKey(bytes);
|
|
223
223
|
}
|
|
224
|
-
throw new (0,
|
|
224
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
|
|
225
225
|
`chain ${network} is Solana; wallet must be { secretKey } or { signer }.`
|
|
226
226
|
);
|
|
227
227
|
}
|
|
@@ -250,15 +250,15 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
250
250
|
const info = preset.tokens[token.toUpperCase()];
|
|
251
251
|
if (!info) {
|
|
252
252
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
253
|
-
throw new (0,
|
|
253
|
+
throw new (0, _chunkFTKVCP6Kcjs.UnknownTokenError)(
|
|
254
254
|
`token "${token}" isn't built in for Solana (known: ${known}). Pass { mint, decimals } instead, or use 'native'.`
|
|
255
255
|
);
|
|
256
256
|
}
|
|
257
257
|
return { asset: info.mint, decimals: info.decimals, symbol: info.symbol };
|
|
258
258
|
}
|
|
259
|
-
|
|
259
|
+
_chunkFTKVCP6Kcjs.rejectForeignToken.call(void 0, token, "solana", network);
|
|
260
260
|
if (!("mint" in token)) {
|
|
261
|
-
throw new (0,
|
|
261
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
|
|
262
262
|
`chain ${network} is Solana; a custom token must be { mint, decimals }.`
|
|
263
263
|
);
|
|
264
264
|
}
|
|
@@ -277,14 +277,14 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
277
277
|
},
|
|
278
278
|
assertValidPayTo(payTo) {
|
|
279
279
|
if (payTo.startsWith("0x")) {
|
|
280
|
-
throw new (0,
|
|
280
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
|
|
281
281
|
`chain ${network} is Solana, but payTo "${payTo}" looks like an EVM address.`
|
|
282
282
|
);
|
|
283
283
|
}
|
|
284
284
|
try {
|
|
285
285
|
new (0, _web3js.PublicKey)(payTo);
|
|
286
286
|
} catch (e3) {
|
|
287
|
-
throw new (0,
|
|
287
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
|
|
288
288
|
`chain ${network} is Solana, but payTo "${payTo}" is not a base58 address.`
|
|
289
289
|
);
|
|
290
290
|
}
|
|
@@ -296,7 +296,7 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
296
296
|
try {
|
|
297
297
|
return await paySolana({ connection, keypair: wallet._native, accept });
|
|
298
298
|
} catch (err) {
|
|
299
|
-
throw _nullishCoalesce(
|
|
299
|
+
throw _nullishCoalesce(_chunkFTKVCP6Kcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
300
300
|
}
|
|
301
301
|
},
|
|
302
302
|
async confirm(ref) {
|
|
@@ -307,20 +307,20 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
307
307
|
});
|
|
308
308
|
info = value[0];
|
|
309
309
|
} catch (err) {
|
|
310
|
-
throw new (0,
|
|
310
|
+
throw new (0, _chunkFTKVCP6Kcjs.ConfirmationTimeoutError)(
|
|
311
311
|
`Solana payment ${ref} could not be confirmed (RPC read failed).`,
|
|
312
312
|
{ cause: err }
|
|
313
313
|
);
|
|
314
314
|
}
|
|
315
315
|
if (!info || info.err || info.confirmationStatus !== "confirmed" && info.confirmationStatus !== "finalized") {
|
|
316
|
-
throw new (0,
|
|
316
|
+
throw new (0, _chunkFTKVCP6Kcjs.ConfirmationTimeoutError)(`Solana payment ${ref} did not confirm in time.`);
|
|
317
317
|
}
|
|
318
318
|
return { height: String(info.slot) };
|
|
319
319
|
},
|
|
320
320
|
async estimateCost(accept) {
|
|
321
321
|
const base = 5000n;
|
|
322
322
|
if (accept.asset === "native") {
|
|
323
|
-
return
|
|
323
|
+
return _chunkFTKVCP6Kcjs.nativeCost.call(void 0, {
|
|
324
324
|
symbol: "SOL",
|
|
325
325
|
decimals: SOL_DECIMALS,
|
|
326
326
|
fee: base,
|
|
@@ -329,7 +329,7 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
329
329
|
});
|
|
330
330
|
}
|
|
331
331
|
const ataRent = 2039280n;
|
|
332
|
-
return
|
|
332
|
+
return _chunkFTKVCP6Kcjs.nativeCost.call(void 0, {
|
|
333
333
|
symbol: "SOL",
|
|
334
334
|
decimals: SOL_DECIMALS,
|
|
335
335
|
fee: base + ataRent,
|
|
@@ -11,7 +11,7 @@ var _chunkCQREG5LEcjs = require('./chunk-CQREG5LE.cjs');
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _chunkFTKVCP6Kcjs = require('./chunk-FTKVCP6K.cjs');
|
|
15
15
|
|
|
16
16
|
// src/drivers/stellar/index.ts
|
|
17
17
|
var _stellarsdk = require('@stellar/stellar-sdk');
|
|
@@ -97,30 +97,30 @@ function mapSubmitError(err) {
|
|
|
97
97
|
const seen = codes.join(", ");
|
|
98
98
|
const has = (re) => codes.some((c) => re.test(c));
|
|
99
99
|
if (has(/op_no_destination/i)) {
|
|
100
|
-
return new (0,
|
|
100
|
+
return new (0, _chunkFTKVCP6Kcjs.RecipientNotReadyError)(
|
|
101
101
|
`Stellar destination account doesn't exist yet \u2014 create it with \u22651 XLM (the base reserve) before it can receive. (Stellar: ${seen})`,
|
|
102
102
|
{ cause: err }
|
|
103
103
|
);
|
|
104
104
|
}
|
|
105
105
|
if (has(/op_(no_trust|line_full|not_authorized)/i) && !has(/src_no_trust/i)) {
|
|
106
|
-
return new (0,
|
|
106
|
+
return new (0, _chunkFTKVCP6Kcjs.RecipientNotReadyError)(
|
|
107
107
|
`Stellar destination can't hold this asset \u2014 it needs a trustline for it (and to be authorized) before it can receive. (Stellar: ${seen})`,
|
|
108
108
|
{ cause: err }
|
|
109
109
|
);
|
|
110
110
|
}
|
|
111
111
|
if (has(/underfunded|insufficient|low_reserve|src_no_trust/i)) {
|
|
112
|
-
return new (0,
|
|
112
|
+
return new (0, _chunkFTKVCP6Kcjs.InsufficientFundsError)(
|
|
113
113
|
`Stellar payment failed: the sender can't cover it \u2014 balance, base reserve, or no trustline to send this asset. (Stellar: ${seen})`,
|
|
114
114
|
{ cause: err }
|
|
115
115
|
);
|
|
116
116
|
}
|
|
117
117
|
if (isAccountNotFound(err)) {
|
|
118
|
-
return new (0,
|
|
118
|
+
return new (0, _chunkFTKVCP6Kcjs.InsufficientFundsError)(
|
|
119
119
|
"Stellar source account not found on-chain \u2014 fund the sender (\u2265 base reserve) before it can pay.",
|
|
120
120
|
{ cause: err }
|
|
121
121
|
);
|
|
122
122
|
}
|
|
123
|
-
return _nullishCoalesce(
|
|
123
|
+
return _nullishCoalesce(_chunkFTKVCP6Kcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
124
124
|
}
|
|
125
125
|
function isAccountNotFound(err) {
|
|
126
126
|
const e = err;
|
|
@@ -217,7 +217,7 @@ function assetMatches(p, want) {
|
|
|
217
217
|
}
|
|
218
218
|
function parseAmount(amount, decimals) {
|
|
219
219
|
try {
|
|
220
|
-
return
|
|
220
|
+
return _chunkFTKVCP6Kcjs.parseUnits.call(void 0, amount, decimals);
|
|
221
221
|
} catch (e4) {
|
|
222
222
|
return 0n;
|
|
223
223
|
}
|
|
@@ -241,22 +241,22 @@ function rpcFailed(nonce) {
|
|
|
241
241
|
|
|
242
242
|
function assertStellarWallet(wallet, network) {
|
|
243
243
|
if (typeof wallet !== "object" || wallet === null) {
|
|
244
|
-
throw new (0,
|
|
244
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
|
|
245
245
|
`chain ${network} is Stellar; wallet must be { secret } (S\u2026 seed) or { keypair }.`
|
|
246
246
|
);
|
|
247
247
|
}
|
|
248
248
|
if ("privateKey" in wallet || "walletClient" in wallet) {
|
|
249
|
-
throw new (0,
|
|
249
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
|
|
250
250
|
`chain ${network} is Stellar; an EVM wallet can't be used \u2014 pass { secret } (S\u2026 seed) or { keypair }.`
|
|
251
251
|
);
|
|
252
252
|
}
|
|
253
253
|
if ("secretKey" in wallet || "signer" in wallet || "mnemonic" in wallet || "keyPair" in wallet) {
|
|
254
|
-
throw new (0,
|
|
254
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
|
|
255
255
|
`chain ${network} is Stellar; that looks like a Solana/TON wallet \u2014 pass { secret } (S\u2026 seed) or { keypair }.`
|
|
256
256
|
);
|
|
257
257
|
}
|
|
258
258
|
if (!("secret" in wallet) && !("keypair" in wallet)) {
|
|
259
|
-
throw new (0,
|
|
259
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
|
|
260
260
|
`chain ${network} is Stellar; wallet must be { secret } (S\u2026 seed) or { keypair }.`
|
|
261
261
|
);
|
|
262
262
|
}
|
|
@@ -266,13 +266,13 @@ function resolveStellarWallet(config) {
|
|
|
266
266
|
if (config.keypair) return config.keypair;
|
|
267
267
|
if (config.secret) {
|
|
268
268
|
if (!_stellarsdk.StrKey.isValidEd25519SecretSeed(config.secret)) {
|
|
269
|
-
throw new (0,
|
|
269
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
|
|
270
270
|
"Stellar wallet { secret } is not a valid S\u2026 secret seed."
|
|
271
271
|
);
|
|
272
272
|
}
|
|
273
273
|
return _stellarsdk.Keypair.fromSecret(config.secret);
|
|
274
274
|
}
|
|
275
|
-
throw new (0,
|
|
275
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)("Stellar wallet needs { secret } (S\u2026 seed) or { keypair }.");
|
|
276
276
|
}
|
|
277
277
|
|
|
278
278
|
// src/drivers/stellar/index.ts
|
|
@@ -327,7 +327,7 @@ function makeStellarNetwork(preset, rpcUrl) {
|
|
|
327
327
|
const info = preset.tokens[token.toUpperCase()];
|
|
328
328
|
if (!info) {
|
|
329
329
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
330
|
-
throw new (0,
|
|
330
|
+
throw new (0, _chunkFTKVCP6Kcjs.UnknownTokenError)(
|
|
331
331
|
`token "${token}" isn't built in for Stellar (known: ${known}). Pass { issuer, code, decimals } for a custom asset, or use 'native'.`
|
|
332
332
|
);
|
|
333
333
|
}
|
|
@@ -337,10 +337,10 @@ function makeStellarNetwork(preset, rpcUrl) {
|
|
|
337
337
|
symbol: info.symbol
|
|
338
338
|
};
|
|
339
339
|
}
|
|
340
|
-
|
|
340
|
+
_chunkFTKVCP6Kcjs.rejectForeignToken.call(void 0, token, "stellar", network);
|
|
341
341
|
const t = token;
|
|
342
342
|
if (!t.issuer || !t.code || typeof t.decimals !== "number") {
|
|
343
|
-
throw new (0,
|
|
343
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
|
|
344
344
|
`chain ${network} is Stellar; a custom token must be { issuer, code, decimals }.`
|
|
345
345
|
);
|
|
346
346
|
}
|
|
@@ -361,12 +361,12 @@ function makeStellarNetwork(preset, rpcUrl) {
|
|
|
361
361
|
},
|
|
362
362
|
assertValidPayTo(payTo) {
|
|
363
363
|
if (payTo.startsWith("0x")) {
|
|
364
|
-
throw new (0,
|
|
364
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
|
|
365
365
|
`chain ${network} is Stellar, but payTo "${payTo}" looks like an EVM address.`
|
|
366
366
|
);
|
|
367
367
|
}
|
|
368
368
|
if (!_stellarsdk.StrKey.isValidEd25519PublicKey(payTo)) {
|
|
369
|
-
throw new (0,
|
|
369
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
|
|
370
370
|
`chain ${network} is Stellar, but payTo "${payTo}" is not a valid Stellar account (G\u2026).`
|
|
371
371
|
);
|
|
372
372
|
}
|
|
@@ -387,10 +387,10 @@ function makeStellarNetwork(preset, rpcUrl) {
|
|
|
387
387
|
await _chunkCQREG5LEcjs.delay.call(void 0, 1500);
|
|
388
388
|
}
|
|
389
389
|
}
|
|
390
|
-
throw new (0,
|
|
390
|
+
throw new (0, _chunkFTKVCP6Kcjs.ConfirmationTimeoutError)(`Stellar tx ${ref} not visible on Horizon in time.`);
|
|
391
391
|
},
|
|
392
392
|
async estimateCost() {
|
|
393
|
-
return
|
|
393
|
+
return _chunkFTKVCP6Kcjs.nativeCost.call(void 0, {
|
|
394
394
|
symbol: XLM_SYMBOL,
|
|
395
395
|
decimals: STELLAR_DECIMALS,
|
|
396
396
|
fee: 100n,
|
|
@@ -414,7 +414,7 @@ function makeStellarNetwork(preset, rpcUrl) {
|
|
|
414
414
|
}
|
|
415
415
|
const toBase = (s) => {
|
|
416
416
|
try {
|
|
417
|
-
return s != null ?
|
|
417
|
+
return s != null ? _chunkFTKVCP6Kcjs.parseUnits.call(void 0, s, STELLAR_DECIMALS) : 0n;
|
|
418
418
|
} catch (e7) {
|
|
419
419
|
return 0n;
|
|
420
420
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkFTKVCP6Kcjs = require('./chunk-FTKVCP6K.cjs');
|
|
10
10
|
|
|
11
11
|
// src/drivers/sui/index.ts
|
|
12
12
|
var _jsonRpc = require('@mysten/sui/jsonRpc');
|
|
@@ -45,7 +45,7 @@ async function paySui(params) {
|
|
|
45
45
|
} else {
|
|
46
46
|
const coins = await client.getCoins({ owner: sender, coinType: accept.asset });
|
|
47
47
|
if (!coins.data.length) {
|
|
48
|
-
throw new (0,
|
|
48
|
+
throw new (0, _chunkFTKVCP6Kcjs.InsufficientFundsError)(
|
|
49
49
|
`Sui wallet holds no ${accept.asset} coin objects to pay from.`
|
|
50
50
|
);
|
|
51
51
|
}
|
|
@@ -64,14 +64,14 @@ async function paySui(params) {
|
|
|
64
64
|
});
|
|
65
65
|
return res.digest;
|
|
66
66
|
} catch (err) {
|
|
67
|
-
if (err instanceof
|
|
67
|
+
if (err instanceof _chunkFTKVCP6Kcjs.InsufficientFundsError) throw err;
|
|
68
68
|
if (isSuiAffordability(err)) {
|
|
69
|
-
throw new (0,
|
|
69
|
+
throw new (0, _chunkFTKVCP6Kcjs.InsufficientFundsError)(
|
|
70
70
|
err instanceof Error ? err.message : "Insufficient SUI/coin balance for the payment.",
|
|
71
71
|
{ cause: err }
|
|
72
72
|
);
|
|
73
73
|
}
|
|
74
|
-
throw _nullishCoalesce(
|
|
74
|
+
throw _nullishCoalesce(_chunkFTKVCP6Kcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
function isSuiAffordability(err) {
|
|
@@ -151,22 +151,22 @@ function txNotFound(digest) {
|
|
|
151
151
|
var _ed25519 = require('@mysten/sui/keypairs/ed25519');
|
|
152
152
|
function assertSuiWallet(wallet, network) {
|
|
153
153
|
if (typeof wallet !== "object" || wallet === null) {
|
|
154
|
-
throw new (0,
|
|
154
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
|
|
155
155
|
`chain ${network} is Sui; wallet must be { privateKey } (suiprivkey1\u2026 ) or { keypair }.`
|
|
156
156
|
);
|
|
157
157
|
}
|
|
158
158
|
if ("walletClient" in wallet) {
|
|
159
|
-
throw new (0,
|
|
159
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
|
|
160
160
|
`chain ${network} is Sui; a viem { walletClient } can't be used \u2014 pass { privateKey } (suiprivkey1\u2026) or { keypair }.`
|
|
161
161
|
);
|
|
162
162
|
}
|
|
163
163
|
if ("secretKey" in wallet || "signer" in wallet || "mnemonic" in wallet || "keyPair" in wallet || "secret" in wallet || "seed" in wallet || "accountId" in wallet) {
|
|
164
|
-
throw new (0,
|
|
164
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
|
|
165
165
|
`chain ${network} is Sui; that looks like another family's wallet \u2014 pass { privateKey } (suiprivkey1\u2026) or { keypair }.`
|
|
166
166
|
);
|
|
167
167
|
}
|
|
168
168
|
if (!("privateKey" in wallet) && !("keypair" in wallet)) {
|
|
169
|
-
throw new (0,
|
|
169
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
|
|
170
170
|
`chain ${network} is Sui; wallet must be { privateKey } (suiprivkey1\u2026) or { keypair }.`
|
|
171
171
|
);
|
|
172
172
|
}
|
|
@@ -178,13 +178,13 @@ function resolveSuiKeypair(config) {
|
|
|
178
178
|
try {
|
|
179
179
|
return _ed25519.Ed25519Keypair.fromSecretKey(config.privateKey);
|
|
180
180
|
} catch (cause) {
|
|
181
|
-
throw new (0,
|
|
181
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
|
|
182
182
|
"Sui wallet { privateKey } is not a valid suiprivkey1\u2026 secret (or 32-byte key).",
|
|
183
183
|
{ cause }
|
|
184
184
|
);
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
|
-
throw new (0,
|
|
187
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)("Sui wallet needs { privateKey } (suiprivkey1\u2026) or { keypair }.");
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
// src/drivers/sui/index.ts
|
|
@@ -236,16 +236,16 @@ function makeSuiNetwork(preset, rpcUrl) {
|
|
|
236
236
|
const info = preset.tokens[token.toUpperCase()];
|
|
237
237
|
if (!info) {
|
|
238
238
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
239
|
-
throw new (0,
|
|
239
|
+
throw new (0, _chunkFTKVCP6Kcjs.UnknownTokenError)(
|
|
240
240
|
`token "${token}" isn't built in for Sui (known: ${known}). Note: no native USDT on Sui. Pass { coinType, decimals } for a custom coin, or use 'native'.`
|
|
241
241
|
);
|
|
242
242
|
}
|
|
243
243
|
return { asset: info.coinType, decimals: info.decimals, symbol: info.symbol };
|
|
244
244
|
}
|
|
245
|
-
|
|
245
|
+
_chunkFTKVCP6Kcjs.rejectForeignToken.call(void 0, token, "sui", network);
|
|
246
246
|
const t = token;
|
|
247
247
|
if (!t.coinType || typeof t.decimals !== "number") {
|
|
248
|
-
throw new (0,
|
|
248
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
|
|
249
249
|
`chain ${network} is Sui; a custom token must be { coinType, decimals }.`
|
|
250
250
|
);
|
|
251
251
|
}
|
|
@@ -264,7 +264,7 @@ function makeSuiNetwork(preset, rpcUrl) {
|
|
|
264
264
|
},
|
|
265
265
|
assertValidPayTo(payTo) {
|
|
266
266
|
if (!_utils.isValidSuiAddress.call(void 0, payTo)) {
|
|
267
|
-
throw new (0,
|
|
267
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
|
|
268
268
|
`chain ${network} is Sui, but payTo "${payTo}" is not a valid Sui address (0x + 32 bytes).`
|
|
269
269
|
);
|
|
270
270
|
}
|
|
@@ -281,11 +281,11 @@ function makeSuiNetwork(preset, rpcUrl) {
|
|
|
281
281
|
const tx = await client.waitForTransaction({ digest: ref, options: { showEffects: true } });
|
|
282
282
|
return { height: String(_nullishCoalesce(tx.checkpoint, () => ( "0"))) };
|
|
283
283
|
} catch (err) {
|
|
284
|
-
throw new (0,
|
|
284
|
+
throw new (0, _chunkFTKVCP6Kcjs.ConfirmationTimeoutError)(`Sui tx ${ref} did not finalize in time.`, { cause: err });
|
|
285
285
|
}
|
|
286
286
|
},
|
|
287
287
|
async estimateCost() {
|
|
288
|
-
return
|
|
288
|
+
return _chunkFTKVCP6Kcjs.nativeCost.call(void 0, {
|
|
289
289
|
symbol: SUI_SYMBOL,
|
|
290
290
|
decimals: SUI_DECIMALS,
|
|
291
291
|
fee: 3000000n,
|