@piprail/sdk 2.8.0 → 2.9.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/CHANGELOG.md +62 -0
- package/README.md +5 -3
- package/dist/{algorand-WJL6VRXW.js → algorand-AA3WXKW4.js} +1 -1
- package/dist/{algorand-EKD34T4Q.cjs → algorand-FCEECDG6.cjs} +32 -32
- package/dist/{aptos-CVHLVMAF.cjs → aptos-GHJPO6JJ.cjs} +31 -31
- package/dist/{aptos-WMPFEASY.js → aptos-LY67Q6QF.js} +1 -1
- package/dist/{chunk-VPENSVOI.cjs → chunk-MWBT7MCE.cjs} +7 -3
- package/dist/chunk-O4UQOZ4Z.cjs +14 -0
- package/dist/{chunk-W3HOMXOF.js → chunk-SC2ZYDHD.js} +6 -2
- package/dist/chunk-SK3CB7UA.js +14 -0
- package/dist/index.cjs +748 -237
- package/dist/index.d.cts +2384 -2577
- package/dist/index.d.ts +2384 -2577
- package/dist/index.js +589 -78
- package/dist/ledger-BtzrfO-3.d.cts +658 -0
- package/dist/ledger-BtzrfO-3.d.ts +658 -0
- package/dist/{near-NYFMX2KA.cjs → near-6KAQVVG2.cjs} +26 -26
- package/dist/{near-QV4IOZNX.js → near-FZBUICCS.js} +1 -1
- package/dist/node.cjs +38 -0
- package/dist/node.d.cts +16 -0
- package/dist/node.d.ts +16 -0
- package/dist/node.js +38 -0
- package/dist/{solana-Z34OWXMO.js → solana-ELUWO6N5.js} +1 -1
- package/dist/{solana-L342QCSV.cjs → solana-MYF4HBO4.cjs} +32 -32
- package/dist/{stellar-PWC4LETJ.js → stellar-BEMT7UYF.js} +1 -1
- package/dist/{stellar-YEXRVR3W.cjs → stellar-SUKASK4N.cjs} +20 -20
- package/dist/{sui-VEOGHBYE.js → sui-F5JQ2N6I.js} +1 -1
- package/dist/{sui-EFRSCDWN.cjs → sui-VE5LT7BL.cjs} +16 -16
- package/dist/{ton-N7KSPSAR.js → ton-7GKCTC5H.js} +1 -1
- package/dist/{ton-LZKJWYHV.cjs → ton-AOR3EURW.cjs} +16 -16
- package/dist/{tron-DQU4WTGQ.cjs → tron-EMFXDFHW.cjs} +24 -24
- package/dist/{tron-WKDUQVZR.js → tron-ZZZS3FNN.js} +1 -1
- package/dist/{xrpl-6B4IYRWI.js → xrpl-DD7TJL5L.js} +1 -1
- package/dist/{xrpl-K3U3SBF4.cjs → xrpl-Y6SQNYLC.cjs} +20 -20
- package/package.json +11 -1
|
@@ -12,7 +12,7 @@ var _chunkCQREG5LEcjs = require('./chunk-CQREG5LE.cjs');
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkMWBT7MCEcjs = require('./chunk-MWBT7MCE.cjs');
|
|
16
16
|
|
|
17
17
|
// src/drivers/stellar/index.ts
|
|
18
18
|
var _stellarsdk = require('@stellar/stellar-sdk');
|
|
@@ -98,30 +98,30 @@ function mapSubmitError(err) {
|
|
|
98
98
|
const seen = codes.join(", ");
|
|
99
99
|
const has = (re) => codes.some((c) => re.test(c));
|
|
100
100
|
if (has(/op_no_destination/i)) {
|
|
101
|
-
return new (0,
|
|
101
|
+
return new (0, _chunkMWBT7MCEcjs.RecipientNotReadyError)(
|
|
102
102
|
`Stellar destination account doesn't exist yet \u2014 create it with \u22651 XLM (the base reserve) before it can receive. (Stellar: ${seen})`,
|
|
103
103
|
{ cause: err }
|
|
104
104
|
);
|
|
105
105
|
}
|
|
106
106
|
if (has(/op_(no_trust|line_full|not_authorized)/i) && !has(/src_no_trust/i)) {
|
|
107
|
-
return new (0,
|
|
107
|
+
return new (0, _chunkMWBT7MCEcjs.RecipientNotReadyError)(
|
|
108
108
|
`Stellar destination can't hold this asset \u2014 it needs a trustline for it (and to be authorized) before it can receive. (Stellar: ${seen})`,
|
|
109
109
|
{ cause: err }
|
|
110
110
|
);
|
|
111
111
|
}
|
|
112
112
|
if (has(/underfunded|insufficient|low_reserve|src_no_trust/i)) {
|
|
113
|
-
return new (0,
|
|
113
|
+
return new (0, _chunkMWBT7MCEcjs.InsufficientFundsError)(
|
|
114
114
|
`Stellar payment failed: the sender can't cover it \u2014 balance, base reserve, or no trustline to send this asset. (Stellar: ${seen})`,
|
|
115
115
|
{ cause: err }
|
|
116
116
|
);
|
|
117
117
|
}
|
|
118
118
|
if (isAccountNotFound(err)) {
|
|
119
|
-
return new (0,
|
|
119
|
+
return new (0, _chunkMWBT7MCEcjs.InsufficientFundsError)(
|
|
120
120
|
"Stellar source account not found on-chain \u2014 fund the sender (\u2265 base reserve) before it can pay.",
|
|
121
121
|
{ cause: err }
|
|
122
122
|
);
|
|
123
123
|
}
|
|
124
|
-
return _nullishCoalesce(
|
|
124
|
+
return _nullishCoalesce(_chunkMWBT7MCEcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
125
125
|
}
|
|
126
126
|
function isAccountNotFound(err) {
|
|
127
127
|
const e = err;
|
|
@@ -218,7 +218,7 @@ function assetMatches(p, want) {
|
|
|
218
218
|
}
|
|
219
219
|
function parseAmount(amount, decimals) {
|
|
220
220
|
try {
|
|
221
|
-
return
|
|
221
|
+
return _chunkMWBT7MCEcjs.parseUnits.call(void 0, amount, decimals);
|
|
222
222
|
} catch (e4) {
|
|
223
223
|
return 0n;
|
|
224
224
|
}
|
|
@@ -242,13 +242,13 @@ function rpcFailed(nonce) {
|
|
|
242
242
|
|
|
243
243
|
function assertStellarWallet(wallet, network) {
|
|
244
244
|
if (typeof wallet !== "object" || wallet === null) {
|
|
245
|
-
throw new (0,
|
|
245
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
246
246
|
`chain ${network} is Stellar; wallet must be { key } (S\u2026 seed) or { keypair }.`
|
|
247
247
|
);
|
|
248
248
|
}
|
|
249
|
-
|
|
249
|
+
_chunkMWBT7MCEcjs.assertNoLegacyWalletKey.call(void 0, wallet, "Stellar");
|
|
250
250
|
if (!("key" in wallet) && !("keypair" in wallet)) {
|
|
251
|
-
throw new (0,
|
|
251
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
252
252
|
`chain ${network} is Stellar; wallet must be { key } (S\u2026 seed) or { keypair }.`
|
|
253
253
|
);
|
|
254
254
|
}
|
|
@@ -258,11 +258,11 @@ function resolveStellarWallet(config) {
|
|
|
258
258
|
if (config.keypair) return config.keypair;
|
|
259
259
|
if (config.key) {
|
|
260
260
|
if (!_stellarsdk.StrKey.isValidEd25519SecretSeed(config.key)) {
|
|
261
|
-
throw new (0,
|
|
261
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)("Stellar wallet { key } is not a valid S\u2026 secret seed.");
|
|
262
262
|
}
|
|
263
263
|
return _stellarsdk.Keypair.fromSecret(config.key);
|
|
264
264
|
}
|
|
265
|
-
throw new (0,
|
|
265
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)("Stellar wallet needs { key } (S\u2026 seed) or { keypair }.");
|
|
266
266
|
}
|
|
267
267
|
|
|
268
268
|
// src/drivers/stellar/index.ts
|
|
@@ -317,7 +317,7 @@ function makeStellarNetwork(preset, rpcUrl) {
|
|
|
317
317
|
const info = preset.tokens[token.toUpperCase()];
|
|
318
318
|
if (!info) {
|
|
319
319
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
320
|
-
throw new (0,
|
|
320
|
+
throw new (0, _chunkMWBT7MCEcjs.UnknownTokenError)(
|
|
321
321
|
`token "${token}" isn't built in for Stellar (known: ${known}). Pass { issuer, code, decimals } for a custom asset, or use 'native'.`
|
|
322
322
|
);
|
|
323
323
|
}
|
|
@@ -327,10 +327,10 @@ function makeStellarNetwork(preset, rpcUrl) {
|
|
|
327
327
|
symbol: info.symbol
|
|
328
328
|
};
|
|
329
329
|
}
|
|
330
|
-
|
|
330
|
+
_chunkMWBT7MCEcjs.rejectForeignToken.call(void 0, token, "stellar", network);
|
|
331
331
|
const t = token;
|
|
332
332
|
if (!t.issuer || !t.code || typeof t.decimals !== "number") {
|
|
333
|
-
throw new (0,
|
|
333
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
334
334
|
`chain ${network} is Stellar; a custom token must be { issuer, code, decimals }.`
|
|
335
335
|
);
|
|
336
336
|
}
|
|
@@ -351,12 +351,12 @@ function makeStellarNetwork(preset, rpcUrl) {
|
|
|
351
351
|
},
|
|
352
352
|
assertValidPayTo(payTo) {
|
|
353
353
|
if (payTo.startsWith("0x")) {
|
|
354
|
-
throw new (0,
|
|
354
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
355
355
|
`chain ${network} is Stellar, but payTo "${payTo}" looks like an EVM address.`
|
|
356
356
|
);
|
|
357
357
|
}
|
|
358
358
|
if (!_stellarsdk.StrKey.isValidEd25519PublicKey(payTo)) {
|
|
359
|
-
throw new (0,
|
|
359
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
360
360
|
`chain ${network} is Stellar, but payTo "${payTo}" is not a valid Stellar account (G\u2026).`
|
|
361
361
|
);
|
|
362
362
|
}
|
|
@@ -377,10 +377,10 @@ function makeStellarNetwork(preset, rpcUrl) {
|
|
|
377
377
|
await _chunkCQREG5LEcjs.delay.call(void 0, 1500);
|
|
378
378
|
}
|
|
379
379
|
}
|
|
380
|
-
throw new (0,
|
|
380
|
+
throw new (0, _chunkMWBT7MCEcjs.ConfirmationTimeoutError)(`Stellar tx ${ref} not visible on Horizon in time.`);
|
|
381
381
|
},
|
|
382
382
|
async estimateCost() {
|
|
383
|
-
return
|
|
383
|
+
return _chunkMWBT7MCEcjs.nativeCost.call(void 0, {
|
|
384
384
|
symbol: XLM_SYMBOL,
|
|
385
385
|
decimals: STELLAR_DECIMALS,
|
|
386
386
|
fee: 100n,
|
|
@@ -404,7 +404,7 @@ function makeStellarNetwork(preset, rpcUrl) {
|
|
|
404
404
|
}
|
|
405
405
|
const toBase = (s) => {
|
|
406
406
|
try {
|
|
407
|
-
return s != null ?
|
|
407
|
+
return s != null ? _chunkMWBT7MCEcjs.parseUnits.call(void 0, s, STELLAR_DECIMALS) : 0n;
|
|
408
408
|
} catch (e7) {
|
|
409
409
|
return 0n;
|
|
410
410
|
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkMWBT7MCEcjs = require('./chunk-MWBT7MCE.cjs');
|
|
11
11
|
|
|
12
12
|
// src/drivers/sui/index.ts
|
|
13
13
|
var _jsonRpc = require('@mysten/sui/jsonRpc');
|
|
@@ -46,7 +46,7 @@ async function paySui(params) {
|
|
|
46
46
|
} else {
|
|
47
47
|
const coins = await client.getCoins({ owner: sender, coinType: accept.asset });
|
|
48
48
|
if (!coins.data.length) {
|
|
49
|
-
throw new (0,
|
|
49
|
+
throw new (0, _chunkMWBT7MCEcjs.InsufficientFundsError)(
|
|
50
50
|
`Sui wallet holds no ${accept.asset} coin objects to pay from.`
|
|
51
51
|
);
|
|
52
52
|
}
|
|
@@ -65,14 +65,14 @@ async function paySui(params) {
|
|
|
65
65
|
});
|
|
66
66
|
return res.digest;
|
|
67
67
|
} catch (err) {
|
|
68
|
-
if (err instanceof
|
|
68
|
+
if (err instanceof _chunkMWBT7MCEcjs.InsufficientFundsError) throw err;
|
|
69
69
|
if (isSuiAffordability(err)) {
|
|
70
|
-
throw new (0,
|
|
70
|
+
throw new (0, _chunkMWBT7MCEcjs.InsufficientFundsError)(
|
|
71
71
|
err instanceof Error ? err.message : "Insufficient SUI/coin balance for the payment.",
|
|
72
72
|
{ cause: err }
|
|
73
73
|
);
|
|
74
74
|
}
|
|
75
|
-
throw _nullishCoalesce(
|
|
75
|
+
throw _nullishCoalesce(_chunkMWBT7MCEcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
function isSuiAffordability(err) {
|
|
@@ -152,13 +152,13 @@ function txNotFound(digest) {
|
|
|
152
152
|
var _ed25519 = require('@mysten/sui/keypairs/ed25519');
|
|
153
153
|
function assertSuiWallet(wallet, network) {
|
|
154
154
|
if (typeof wallet !== "object" || wallet === null) {
|
|
155
|
-
throw new (0,
|
|
155
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
156
156
|
`chain ${network} is Sui; wallet must be { key } (suiprivkey1\u2026 ) or { keypair }.`
|
|
157
157
|
);
|
|
158
158
|
}
|
|
159
|
-
|
|
159
|
+
_chunkMWBT7MCEcjs.assertNoLegacyWalletKey.call(void 0, wallet, "Sui");
|
|
160
160
|
if (!("key" in wallet) && !("keypair" in wallet)) {
|
|
161
|
-
throw new (0,
|
|
161
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
162
162
|
`chain ${network} is Sui; wallet must be { key } (suiprivkey1\u2026) or { keypair }.`
|
|
163
163
|
);
|
|
164
164
|
}
|
|
@@ -170,13 +170,13 @@ function resolveSuiKeypair(config) {
|
|
|
170
170
|
try {
|
|
171
171
|
return _ed25519.Ed25519Keypair.fromSecretKey(config.key);
|
|
172
172
|
} catch (cause) {
|
|
173
|
-
throw new (0,
|
|
173
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
174
174
|
"Sui wallet { key } is not a valid suiprivkey1\u2026 secret (or 32-byte key).",
|
|
175
175
|
{ cause }
|
|
176
176
|
);
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
|
-
throw new (0,
|
|
179
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)("Sui wallet needs { key } (suiprivkey1\u2026) or { keypair }.");
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
// src/drivers/sui/index.ts
|
|
@@ -228,16 +228,16 @@ function makeSuiNetwork(preset, rpcUrl) {
|
|
|
228
228
|
const info = preset.tokens[token.toUpperCase()];
|
|
229
229
|
if (!info) {
|
|
230
230
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
231
|
-
throw new (0,
|
|
231
|
+
throw new (0, _chunkMWBT7MCEcjs.UnknownTokenError)(
|
|
232
232
|
`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'.`
|
|
233
233
|
);
|
|
234
234
|
}
|
|
235
235
|
return { asset: info.coinType, decimals: info.decimals, symbol: info.symbol };
|
|
236
236
|
}
|
|
237
|
-
|
|
237
|
+
_chunkMWBT7MCEcjs.rejectForeignToken.call(void 0, token, "sui", network);
|
|
238
238
|
const t = token;
|
|
239
239
|
if (!t.coinType || typeof t.decimals !== "number") {
|
|
240
|
-
throw new (0,
|
|
240
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
241
241
|
`chain ${network} is Sui; a custom token must be { coinType, decimals }.`
|
|
242
242
|
);
|
|
243
243
|
}
|
|
@@ -256,7 +256,7 @@ function makeSuiNetwork(preset, rpcUrl) {
|
|
|
256
256
|
},
|
|
257
257
|
assertValidPayTo(payTo) {
|
|
258
258
|
if (!_utils.isValidSuiAddress.call(void 0, payTo)) {
|
|
259
|
-
throw new (0,
|
|
259
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
260
260
|
`chain ${network} is Sui, but payTo "${payTo}" is not a valid Sui address (0x + 32 bytes).`
|
|
261
261
|
);
|
|
262
262
|
}
|
|
@@ -273,11 +273,11 @@ function makeSuiNetwork(preset, rpcUrl) {
|
|
|
273
273
|
const tx = await client.waitForTransaction({ digest: ref, options: { showEffects: true } });
|
|
274
274
|
return { height: String(_nullishCoalesce(tx.checkpoint, () => ( "0"))) };
|
|
275
275
|
} catch (err) {
|
|
276
|
-
throw new (0,
|
|
276
|
+
throw new (0, _chunkMWBT7MCEcjs.ConfirmationTimeoutError)(`Sui tx ${ref} did not finalize in time.`, { cause: err });
|
|
277
277
|
}
|
|
278
278
|
},
|
|
279
279
|
async estimateCost() {
|
|
280
|
-
return
|
|
280
|
+
return _chunkMWBT7MCEcjs.nativeCost.call(void 0, {
|
|
281
281
|
symbol: SUI_SYMBOL,
|
|
282
282
|
decimals: SUI_DECIMALS,
|
|
283
283
|
fee: 3000000n,
|
|
@@ -9,7 +9,7 @@ var _chunkCQREG5LEcjs = require('./chunk-CQREG5LE.cjs');
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunkMWBT7MCEcjs = require('./chunk-MWBT7MCE.cjs');
|
|
13
13
|
|
|
14
14
|
// src/drivers/ton/index.ts
|
|
15
15
|
var _core = require('@ton/core');
|
|
@@ -76,7 +76,7 @@ async function waitForSeqno(opened, from, { tries = 30, intervalMs = 2e3 } = {})
|
|
|
76
76
|
}
|
|
77
77
|
if (current > from) return;
|
|
78
78
|
}
|
|
79
|
-
throw new (0,
|
|
79
|
+
throw new (0, _chunkMWBT7MCEcjs.ConfirmationTimeoutError)(
|
|
80
80
|
`TON wallet seqno did not advance past ${from} \u2014 the payment may not have been accepted.`
|
|
81
81
|
);
|
|
82
82
|
}
|
|
@@ -204,13 +204,13 @@ var _crypto = require('@ton/crypto');
|
|
|
204
204
|
|
|
205
205
|
function assertTonWallet(wallet, network) {
|
|
206
206
|
if (typeof wallet !== "object" || wallet === null) {
|
|
207
|
-
throw new (0,
|
|
207
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
208
208
|
`chain ${network} is TON; wallet must be { key } (24-word mnemonic) or { keyPair }.`
|
|
209
209
|
);
|
|
210
210
|
}
|
|
211
|
-
|
|
211
|
+
_chunkMWBT7MCEcjs.assertNoLegacyWalletKey.call(void 0, wallet, "TON");
|
|
212
212
|
if (!("key" in wallet) && !("keyPair" in wallet)) {
|
|
213
|
-
throw new (0,
|
|
213
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
214
214
|
`chain ${network} is TON; wallet must be { key } (24-word mnemonic) or { keyPair }.`
|
|
215
215
|
);
|
|
216
216
|
}
|
|
@@ -221,13 +221,13 @@ async function resolveTonWallet(config) {
|
|
|
221
221
|
let keyPair;
|
|
222
222
|
if (config.key) {
|
|
223
223
|
if (typeof config.key !== "string" && !Array.isArray(config.key)) {
|
|
224
|
-
throw new (0,
|
|
224
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
225
225
|
"chain is TON; the wallet { key } must be a 24-word mnemonic (a string or string[])."
|
|
226
226
|
);
|
|
227
227
|
}
|
|
228
228
|
const words = Array.isArray(config.key) ? config.key : config.key.trim().split(/\s+/);
|
|
229
229
|
if (!await _crypto.mnemonicValidate.call(void 0, words)) {
|
|
230
|
-
throw new (0,
|
|
230
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
231
231
|
"chain is TON; the wallet { key } is not a valid TON mnemonic (expected 24 words from the TON/BIP-39 wordlist)."
|
|
232
232
|
);
|
|
233
233
|
}
|
|
@@ -235,7 +235,7 @@ async function resolveTonWallet(config) {
|
|
|
235
235
|
} else if (config.keyPair) {
|
|
236
236
|
keyPair = config.keyPair;
|
|
237
237
|
} else {
|
|
238
|
-
throw new (0,
|
|
238
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)("TON wallet needs { key } (24-word mnemonic) or { keyPair }.");
|
|
239
239
|
}
|
|
240
240
|
const contract = version === "v5r1" ? _ton.WalletContractV5R1.create({ workchain: 0, publicKey: keyPair.publicKey }) : _ton.WalletContractV4.create({ workchain: 0, publicKey: keyPair.publicKey });
|
|
241
241
|
return { keyPair, contract };
|
|
@@ -281,15 +281,15 @@ function makeTonNetwork(preset, rpcUrl) {
|
|
|
281
281
|
const info = preset.tokens[token.toUpperCase()];
|
|
282
282
|
if (!info) {
|
|
283
283
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
284
|
-
throw new (0,
|
|
284
|
+
throw new (0, _chunkMWBT7MCEcjs.UnknownTokenError)(
|
|
285
285
|
`token "${token}" isn't built in for TON (known: ${known}). Note: native USDC doesn't exist on TON. Pass { master, decimals } for a custom jetton, or use 'native'.`
|
|
286
286
|
);
|
|
287
287
|
}
|
|
288
288
|
return { asset: info.master, decimals: info.decimals, symbol: info.symbol };
|
|
289
289
|
}
|
|
290
|
-
|
|
290
|
+
_chunkMWBT7MCEcjs.rejectForeignToken.call(void 0, token, "ton", network);
|
|
291
291
|
if (!("master" in token)) {
|
|
292
|
-
throw new (0,
|
|
292
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
293
293
|
`chain ${network} is TON; a custom token must be { master, decimals }.`
|
|
294
294
|
);
|
|
295
295
|
}
|
|
@@ -308,14 +308,14 @@ function makeTonNetwork(preset, rpcUrl) {
|
|
|
308
308
|
},
|
|
309
309
|
assertValidPayTo(payTo) {
|
|
310
310
|
if (payTo.startsWith("0x")) {
|
|
311
|
-
throw new (0,
|
|
311
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
312
312
|
`chain ${network} is TON, but payTo "${payTo}" looks like an EVM address.`
|
|
313
313
|
);
|
|
314
314
|
}
|
|
315
315
|
try {
|
|
316
316
|
_core.Address.parse(payTo);
|
|
317
317
|
} catch (e6) {
|
|
318
|
-
throw new (0,
|
|
318
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
319
319
|
`chain ${network} is TON, but payTo "${payTo}" is not a valid TON address.`
|
|
320
320
|
);
|
|
321
321
|
}
|
|
@@ -331,7 +331,7 @@ function makeTonNetwork(preset, rpcUrl) {
|
|
|
331
331
|
const watch = await watchAccountFor(accept);
|
|
332
332
|
return encodeRef(watch, accept.extra.nonce);
|
|
333
333
|
} catch (err) {
|
|
334
|
-
throw _nullishCoalesce(
|
|
334
|
+
throw _nullishCoalesce(_chunkMWBT7MCEcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
335
335
|
}
|
|
336
336
|
},
|
|
337
337
|
async confirm(ref) {
|
|
@@ -350,12 +350,12 @@ function makeTonNetwork(preset, rpcUrl) {
|
|
|
350
350
|
if (inc && inc.comment === nonce) return { height: tx.lt.toString() };
|
|
351
351
|
}
|
|
352
352
|
}
|
|
353
|
-
throw new (0,
|
|
353
|
+
throw new (0, _chunkMWBT7MCEcjs.ConfirmationTimeoutError)(`TON payment for nonce ${nonce} did not settle in time.`);
|
|
354
354
|
},
|
|
355
355
|
async estimateCost(accept) {
|
|
356
356
|
const fee = accept.asset === "native" ? 10000000n : 50000000n;
|
|
357
357
|
const detail = accept.asset === "native" ? `~0.01 ${TON_NATIVE_SYMBOL} network fee` : `~0.05 ${TON_NATIVE_SYMBOL} attached for the jetton transfer (leftover refunded)`;
|
|
358
|
-
return
|
|
358
|
+
return _chunkMWBT7MCEcjs.nativeCost.call(void 0, { symbol: TON_NATIVE_SYMBOL, decimals: TON_DECIMALS, fee, basis: "heuristic", detail });
|
|
359
359
|
},
|
|
360
360
|
async balanceOf(wallet, asset) {
|
|
361
361
|
let owner;
|
|
@@ -10,7 +10,7 @@ var _chunkCQREG5LEcjs = require('./chunk-CQREG5LE.cjs');
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunkMWBT7MCEcjs = require('./chunk-MWBT7MCE.cjs');
|
|
14
14
|
|
|
15
15
|
// src/drivers/tron/index.ts
|
|
16
16
|
var _tronweb = require('tronweb');
|
|
@@ -62,7 +62,7 @@ async function payTron(params) {
|
|
|
62
62
|
return _nullishCoalesce(_nullishCoalesce(broadcast.txid, () => ( _optionalChain([broadcast, 'access', _7 => _7.transaction, 'optionalAccess', _8 => _8.txID]))), () => ( signed.txID));
|
|
63
63
|
}
|
|
64
64
|
if (isTronAffordability(broadcast.code, broadcast.message)) {
|
|
65
|
-
throw new (0,
|
|
65
|
+
throw new (0, _chunkMWBT7MCEcjs.InsufficientFundsError)(
|
|
66
66
|
`Tron payment rejected (${_nullishCoalesce(broadcast.code, () => ( "broadcast"))}): not enough TRX for energy/bandwidth, or insufficient token balance.`
|
|
67
67
|
);
|
|
68
68
|
}
|
|
@@ -70,8 +70,8 @@ async function payTron(params) {
|
|
|
70
70
|
`Tron broadcast failed: ${_nullishCoalesce(broadcast.code, () => ( ""))} ${decodeMaybeHex(broadcast.message)}`.trim()
|
|
71
71
|
);
|
|
72
72
|
} catch (err) {
|
|
73
|
-
if (err instanceof
|
|
74
|
-
throw _nullishCoalesce(
|
|
73
|
+
if (err instanceof _chunkMWBT7MCEcjs.InsufficientFundsError) throw err;
|
|
74
|
+
throw _nullishCoalesce(_chunkMWBT7MCEcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
async function payTronNative(params) {
|
|
@@ -84,7 +84,7 @@ async function payTronNative(params) {
|
|
|
84
84
|
return _nullishCoalesce(_nullishCoalesce(broadcast.txid, () => ( _optionalChain([broadcast, 'access', _11 => _11.transaction, 'optionalAccess', _12 => _12.txID]))), () => ( signed.txID));
|
|
85
85
|
}
|
|
86
86
|
if (isTronAffordability(broadcast.code, broadcast.message)) {
|
|
87
|
-
throw new (0,
|
|
87
|
+
throw new (0, _chunkMWBT7MCEcjs.InsufficientFundsError)(
|
|
88
88
|
`Tron TRX payment rejected (${_nullishCoalesce(broadcast.code, () => ( "broadcast"))}): not enough TRX for the amount plus bandwidth (and the ~1 TRX account-creation fee if the recipient is new).`
|
|
89
89
|
);
|
|
90
90
|
}
|
|
@@ -92,8 +92,8 @@ async function payTronNative(params) {
|
|
|
92
92
|
`Tron TRX broadcast failed: ${_nullishCoalesce(broadcast.code, () => ( ""))} ${decodeMaybeHex(broadcast.message)}`.trim()
|
|
93
93
|
);
|
|
94
94
|
} catch (err) {
|
|
95
|
-
if (err instanceof
|
|
96
|
-
throw _nullishCoalesce(
|
|
95
|
+
if (err instanceof _chunkMWBT7MCEcjs.InsufficientFundsError) throw err;
|
|
96
|
+
throw _nullishCoalesce(_chunkMWBT7MCEcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
function decodeMaybeHex(message) {
|
|
@@ -264,13 +264,13 @@ function txNotFound(txid) {
|
|
|
264
264
|
// src/drivers/tron/wallet.ts
|
|
265
265
|
function assertTronWallet(wallet, network) {
|
|
266
266
|
if (typeof wallet !== "object" || wallet === null) {
|
|
267
|
-
throw new (0,
|
|
267
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
268
268
|
`chain ${network} is Tron; wallet must be { key } (32-byte hex).`
|
|
269
269
|
);
|
|
270
270
|
}
|
|
271
|
-
|
|
271
|
+
_chunkMWBT7MCEcjs.assertNoLegacyWalletKey.call(void 0, wallet, "Tron");
|
|
272
272
|
if (!("key" in wallet)) {
|
|
273
|
-
throw new (0,
|
|
273
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
274
274
|
`chain ${network} is Tron; wallet must be { key } (32-byte hex).`
|
|
275
275
|
);
|
|
276
276
|
}
|
|
@@ -278,14 +278,14 @@ function assertTronWallet(wallet, network) {
|
|
|
278
278
|
}
|
|
279
279
|
function resolveTronPrivateKey(config) {
|
|
280
280
|
if (!config.key) {
|
|
281
|
-
throw new (0,
|
|
281
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)("Tron wallet needs { key } (32-byte hex).");
|
|
282
282
|
}
|
|
283
283
|
if (typeof config.key !== "string") {
|
|
284
|
-
throw new (0,
|
|
284
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)("Tron wallet { key } must be a 32-byte hex string.");
|
|
285
285
|
}
|
|
286
286
|
const hex = config.key.replace(/^0x/i, "").toLowerCase();
|
|
287
287
|
if (!/^[0-9a-f]{64}$/.test(hex)) {
|
|
288
|
-
throw new (0,
|
|
288
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
289
289
|
"Tron wallet { key } must be a 32-byte hex string (64 hex chars)."
|
|
290
290
|
);
|
|
291
291
|
}
|
|
@@ -335,21 +335,21 @@ function makeTronNetwork(preset, rpcUrl) {
|
|
|
335
335
|
const info = preset.tokens[token.toUpperCase()];
|
|
336
336
|
if (!info) {
|
|
337
337
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
338
|
-
throw new (0,
|
|
338
|
+
throw new (0, _chunkMWBT7MCEcjs.UnknownTokenError)(
|
|
339
339
|
`token "${token}" isn't built in for Tron (known: ${known}). Note: native USDC doesn't exist on Tron. Pass { address, decimals } for a custom TRC-20.`
|
|
340
340
|
);
|
|
341
341
|
}
|
|
342
342
|
return { asset: info.address, decimals: info.decimals, symbol: info.symbol };
|
|
343
343
|
}
|
|
344
|
-
|
|
344
|
+
_chunkMWBT7MCEcjs.rejectForeignToken.call(void 0, token, "tron", network);
|
|
345
345
|
if (!("address" in token)) {
|
|
346
|
-
throw new (0,
|
|
346
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
347
347
|
`chain ${network} is Tron; a custom token must be { address, decimals } (Base58 T\u2026 contract).`
|
|
348
348
|
);
|
|
349
349
|
}
|
|
350
350
|
const t = token;
|
|
351
351
|
if (t.address.startsWith("0x") || !tronWeb.isAddress(t.address)) {
|
|
352
|
-
throw new (0,
|
|
352
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
353
353
|
`chain ${network} is Tron, but token address "${t.address}" is not a valid Tron contract (T\u2026).`
|
|
354
354
|
);
|
|
355
355
|
}
|
|
@@ -368,12 +368,12 @@ function makeTronNetwork(preset, rpcUrl) {
|
|
|
368
368
|
},
|
|
369
369
|
assertValidPayTo(payTo) {
|
|
370
370
|
if (payTo.startsWith("0x")) {
|
|
371
|
-
throw new (0,
|
|
371
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
372
372
|
`chain ${network} is Tron, but payTo "${payTo}" looks like an EVM address.`
|
|
373
373
|
);
|
|
374
374
|
}
|
|
375
375
|
if (!tronWeb.isAddress(payTo)) {
|
|
376
|
-
throw new (0,
|
|
376
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
377
377
|
`chain ${network} is Tron, but payTo "${payTo}" is not a valid Tron address (T\u2026).`
|
|
378
378
|
);
|
|
379
379
|
}
|
|
@@ -385,7 +385,7 @@ function makeTronNetwork(preset, rpcUrl) {
|
|
|
385
385
|
const privateKey = resolveTronPrivateKey(wallet._native);
|
|
386
386
|
const from = tronWeb.address.fromPrivateKey(privateKey);
|
|
387
387
|
if (!from) {
|
|
388
|
-
throw new (0,
|
|
388
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)("Tron wallet { key } could not derive an address.");
|
|
389
389
|
}
|
|
390
390
|
if (accept.asset === "native") {
|
|
391
391
|
return payTronNative({ client: tronWeb, from, privateKey, accept });
|
|
@@ -408,11 +408,11 @@ function makeTronNetwork(preset, rpcUrl) {
|
|
|
408
408
|
}
|
|
409
409
|
await _chunkCQREG5LEcjs.delay.call(void 0, 2500);
|
|
410
410
|
}
|
|
411
|
-
throw new (0,
|
|
411
|
+
throw new (0, _chunkMWBT7MCEcjs.ConfirmationTimeoutError)(`Tron tx ${txid} did not solidify in time.`);
|
|
412
412
|
},
|
|
413
413
|
async estimateCost(accept, opts) {
|
|
414
414
|
if (accept.asset === "native") {
|
|
415
|
-
return
|
|
415
|
+
return _chunkMWBT7MCEcjs.nativeCost.call(void 0, {
|
|
416
416
|
symbol: "TRX",
|
|
417
417
|
decimals: TRX_DECIMALS,
|
|
418
418
|
fee: 1300000n,
|
|
@@ -436,7 +436,7 @@ function makeTronNetwork(preset, rpcUrl) {
|
|
|
436
436
|
);
|
|
437
437
|
const energy = BigInt(_nullishCoalesce(r.energy_used, () => ( 0)));
|
|
438
438
|
if (energy > 0n) {
|
|
439
|
-
return
|
|
439
|
+
return _chunkMWBT7MCEcjs.nativeCost.call(void 0, {
|
|
440
440
|
symbol: "TRX",
|
|
441
441
|
decimals: TRX_DECIMALS,
|
|
442
442
|
fee: energy * ENERGY_PRICE + BANDWIDTH_SUN,
|
|
@@ -447,7 +447,7 @@ function makeTronNetwork(preset, rpcUrl) {
|
|
|
447
447
|
} catch (e8) {
|
|
448
448
|
}
|
|
449
449
|
}
|
|
450
|
-
return
|
|
450
|
+
return _chunkMWBT7MCEcjs.nativeCost.call(void 0, {
|
|
451
451
|
symbol: "TRX",
|
|
452
452
|
decimals: TRX_DECIMALS,
|
|
453
453
|
fee: 30000n * ENERGY_PRICE + BANDWIDTH_SUN,
|