@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
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunkMWBT7MCEcjs = require('./chunk-MWBT7MCE.cjs');
|
|
14
14
|
|
|
15
15
|
// src/drivers/near/index.ts
|
|
16
16
|
var _nearapijs = require('near-api-js');
|
|
@@ -61,18 +61,18 @@ async function payNear(params) {
|
|
|
61
61
|
return res.hash;
|
|
62
62
|
} catch (err) {
|
|
63
63
|
if (isNearRegistrationError(err)) {
|
|
64
|
-
throw new (0,
|
|
64
|
+
throw new (0, _chunkMWBT7MCEcjs.RecipientNotReadyError)(
|
|
65
65
|
`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)`,
|
|
66
66
|
{ cause: err }
|
|
67
67
|
);
|
|
68
68
|
}
|
|
69
69
|
if (isNearAffordability(err)) {
|
|
70
|
-
throw new (0,
|
|
70
|
+
throw new (0, _chunkMWBT7MCEcjs.InsufficientFundsError)(
|
|
71
71
|
err instanceof Error ? err.message : "Insufficient NEAR 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
|
async function payNearNative(params) {
|
|
@@ -82,12 +82,12 @@ async function payNearNative(params) {
|
|
|
82
82
|
return res.hash;
|
|
83
83
|
} catch (err) {
|
|
84
84
|
if (isNearAffordability(err)) {
|
|
85
|
-
throw new (0,
|
|
85
|
+
throw new (0, _chunkMWBT7MCEcjs.InsufficientFundsError)(
|
|
86
86
|
err instanceof Error ? err.message : "Insufficient NEAR balance for the payment.",
|
|
87
87
|
{ cause: err }
|
|
88
88
|
);
|
|
89
89
|
}
|
|
90
|
-
throw _nullishCoalesce(
|
|
90
|
+
throw _nullishCoalesce(_chunkMWBT7MCEcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
function isNearRegistrationError(err) {
|
|
@@ -109,28 +109,28 @@ var NONCE_BLOCK_MULTIPLIER = 1000000n;
|
|
|
109
109
|
async function payExactNear(input) {
|
|
110
110
|
const { signer, senderId, blockHeight, accessKeyNonce, accept } = input;
|
|
111
111
|
if (accept.asset === "native") {
|
|
112
|
-
throw new (0,
|
|
112
|
+
throw new (0, _chunkMWBT7MCEcjs.UnsupportedSchemeError)(
|
|
113
113
|
"NEAR exact is NEP-141-only (an ft_transfer); native NEAR is not exact-payable. Pay via onchain-proof."
|
|
114
114
|
);
|
|
115
115
|
}
|
|
116
116
|
if (!isValidNearAccountId(accept.asset)) {
|
|
117
|
-
throw new (0,
|
|
117
|
+
throw new (0, _chunkMWBT7MCEcjs.UnsupportedSchemeError)(`NEAR exact: asset "${accept.asset}" must be a NEP-141 contract account id.`);
|
|
118
118
|
}
|
|
119
119
|
if (!isValidNearAccountId(accept.payTo)) {
|
|
120
|
-
throw new (0,
|
|
120
|
+
throw new (0, _chunkMWBT7MCEcjs.UnsupportedSchemeError)(`NEAR exact: payTo "${accept.payTo}" is not a valid NEAR account id.`);
|
|
121
121
|
}
|
|
122
122
|
if (!isValidNearAccountId(senderId)) {
|
|
123
|
-
throw new (0,
|
|
123
|
+
throw new (0, _chunkMWBT7MCEcjs.UnsupportedSchemeError)(`NEAR exact: sender "${senderId}" is not a valid NEAR account id.`);
|
|
124
124
|
}
|
|
125
125
|
const t = accept.maxTimeoutSeconds;
|
|
126
126
|
if (!Number.isInteger(t) || t <= 0) {
|
|
127
|
-
throw new (0,
|
|
127
|
+
throw new (0, _chunkMWBT7MCEcjs.UnsupportedSchemeError)("NEAR exact: maxTimeoutSeconds must be a positive integer.");
|
|
128
128
|
}
|
|
129
129
|
const timeoutBlocks = BigInt(Math.max(1, Math.ceil(t / ESTIMATED_BLOCK_SECONDS)));
|
|
130
130
|
const maxBlockHeight = blockHeight + timeoutBlocks;
|
|
131
131
|
const nonce = accessKeyNonce + 1n;
|
|
132
132
|
if (nonce >= blockHeight * NONCE_BLOCK_MULTIPLIER) {
|
|
133
|
-
throw new (0,
|
|
133
|
+
throw new (0, _chunkMWBT7MCEcjs.UnsupportedSchemeError)(
|
|
134
134
|
"NEAR exact: the access-key nonce is at the protocol ceiling for this block height; cannot build a delegate action."
|
|
135
135
|
);
|
|
136
136
|
}
|
|
@@ -259,7 +259,7 @@ async function verifyAndSettleExactNear(input) {
|
|
|
259
259
|
if (/not enough|insufficient|exceeded the prepaid gas|NotEnoughBalance|doesn't have enough|is not registered/i.test(m)) {
|
|
260
260
|
return fail("tx_reverted", `the ft_transfer would fail on chain: ${shorten(m)}.`);
|
|
261
261
|
}
|
|
262
|
-
throw new (0,
|
|
262
|
+
throw new (0, _chunkMWBT7MCEcjs.SettlementError)(
|
|
263
263
|
`NEAR exact settle: the relayer could not submit the delegate (${shorten(m)}). The buyer's signed delegate is still valid \u2014 fund/fix the relayer and the buyer can re-present it.`,
|
|
264
264
|
{ cause: err }
|
|
265
265
|
);
|
|
@@ -408,13 +408,13 @@ function txNotFound(hash) {
|
|
|
408
408
|
|
|
409
409
|
function assertNearWallet(wallet, network) {
|
|
410
410
|
if (typeof wallet !== "object" || wallet === null) {
|
|
411
|
-
throw new (0,
|
|
411
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
412
412
|
`chain ${network} is NEAR; wallet must be { accountId, key } (key = ed25519:\u2026).`
|
|
413
413
|
);
|
|
414
414
|
}
|
|
415
|
-
|
|
415
|
+
_chunkMWBT7MCEcjs.assertNoLegacyWalletKey.call(void 0, wallet, "NEAR");
|
|
416
416
|
if (!("accountId" in wallet) || !("key" in wallet)) {
|
|
417
|
-
throw new (0,
|
|
417
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
418
418
|
`chain ${network} is NEAR; wallet must be { accountId, key } (key = ed25519:\u2026).`
|
|
419
419
|
);
|
|
420
420
|
}
|
|
@@ -422,13 +422,13 @@ function assertNearWallet(wallet, network) {
|
|
|
422
422
|
}
|
|
423
423
|
function resolveNearWallet(config) {
|
|
424
424
|
if (!config.accountId || !config.key) {
|
|
425
|
-
throw new (0,
|
|
425
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)("NEAR wallet needs { accountId, key } (key = ed25519:\u2026).");
|
|
426
426
|
}
|
|
427
427
|
let signer;
|
|
428
428
|
try {
|
|
429
429
|
signer = _nearapijs.KeyPairSigner.fromSecretKey(config.key);
|
|
430
430
|
} catch (cause) {
|
|
431
|
-
throw new (0,
|
|
431
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)("NEAR wallet { key } is not a valid ed25519:\u2026 secret key.", {
|
|
432
432
|
cause
|
|
433
433
|
});
|
|
434
434
|
}
|
|
@@ -490,16 +490,16 @@ function makeNearNetwork(preset, rpcUrl) {
|
|
|
490
490
|
const info = preset.tokens[token.toUpperCase()];
|
|
491
491
|
if (!info) {
|
|
492
492
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
493
|
-
throw new (0,
|
|
493
|
+
throw new (0, _chunkMWBT7MCEcjs.UnknownTokenError)(
|
|
494
494
|
`token "${token}" isn't built in for NEAR (known: ${known}). Pass { contractId, decimals } for a custom NEP-141.`
|
|
495
495
|
);
|
|
496
496
|
}
|
|
497
497
|
return { asset: info.contractId, decimals: info.decimals, symbol: info.symbol };
|
|
498
498
|
}
|
|
499
|
-
|
|
499
|
+
_chunkMWBT7MCEcjs.rejectForeignToken.call(void 0, token, "near", network);
|
|
500
500
|
const t = token;
|
|
501
501
|
if (!t.contractId || typeof t.decimals !== "number") {
|
|
502
|
-
throw new (0,
|
|
502
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
503
503
|
`chain ${network} is NEAR; a custom token must be { contractId, decimals }.`
|
|
504
504
|
);
|
|
505
505
|
}
|
|
@@ -518,12 +518,12 @@ function makeNearNetwork(preset, rpcUrl) {
|
|
|
518
518
|
},
|
|
519
519
|
assertValidPayTo(payTo) {
|
|
520
520
|
if (payTo.startsWith("0x")) {
|
|
521
|
-
throw new (0,
|
|
521
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
522
522
|
`chain ${network} is NEAR, but payTo "${payTo}" looks like an EVM/Sui 0x address.`
|
|
523
523
|
);
|
|
524
524
|
}
|
|
525
525
|
if (!isValidNearAccountId(payTo)) {
|
|
526
|
-
throw new (0,
|
|
526
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
527
527
|
`chain ${network} is NEAR, but payTo "${payTo}" is not a valid NEAR account id.`
|
|
528
528
|
);
|
|
529
529
|
}
|
|
@@ -567,10 +567,10 @@ function makeNearNetwork(preset, rpcUrl) {
|
|
|
567
567
|
if (tx && tx.success) return { height: "0" };
|
|
568
568
|
} catch (e11) {
|
|
569
569
|
}
|
|
570
|
-
throw new (0,
|
|
570
|
+
throw new (0, _chunkMWBT7MCEcjs.ConfirmationTimeoutError)(`NEAR tx ${hash} not confirmed in time.`);
|
|
571
571
|
},
|
|
572
572
|
async estimateCost() {
|
|
573
|
-
return
|
|
573
|
+
return _chunkMWBT7MCEcjs.nativeCost.call(void 0, {
|
|
574
574
|
symbol: "NEAR",
|
|
575
575
|
decimals: NEAR_DECIMALS,
|
|
576
576
|
fee: 1500000000000000000000n,
|
|
@@ -692,7 +692,7 @@ function makeNearNetwork(preset, rpcUrl) {
|
|
|
692
692
|
try {
|
|
693
693
|
relayerWallet = resolveNearWallet(relayer._native);
|
|
694
694
|
} catch (err) {
|
|
695
|
-
throw new (0,
|
|
695
|
+
throw new (0, _chunkMWBT7MCEcjs.SettlementError)(
|
|
696
696
|
`NEAR exact settle: the relayer wallet is invalid (${err instanceof Error ? err.message : String(err)}).`,
|
|
697
697
|
{ cause: err }
|
|
698
698
|
);
|
package/dist/node.cjs
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkO4UQOZ4Zcjs = require('./chunk-O4UQOZ4Z.cjs');
|
|
4
|
+
|
|
5
|
+
// src/node.ts
|
|
6
|
+
var _fs = require('fs');
|
|
7
|
+
function fileSpendStore(path) {
|
|
8
|
+
return {
|
|
9
|
+
load() {
|
|
10
|
+
try {
|
|
11
|
+
if (!_fs.existsSync.call(void 0, path)) return [];
|
|
12
|
+
const out = [];
|
|
13
|
+
for (const line of _fs.readFileSync.call(void 0, path, "utf8").split("\n")) {
|
|
14
|
+
const trimmed = line.trim();
|
|
15
|
+
if (!trimmed) continue;
|
|
16
|
+
try {
|
|
17
|
+
out.push(JSON.parse(trimmed));
|
|
18
|
+
} catch (e) {
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return out;
|
|
22
|
+
} catch (e2) {
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
append(record) {
|
|
27
|
+
try {
|
|
28
|
+
_fs.appendFileSync.call(void 0, path, `${JSON.stringify(record)}
|
|
29
|
+
`);
|
|
30
|
+
} catch (e3) {
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
exports.fileSpendStore = fileSpendStore; exports.memorySpendStore = _chunkO4UQOZ4Zcjs.memorySpendStore;
|
package/dist/node.d.cts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { o as SpendStore } from './ledger-BtzrfO-3.cjs';
|
|
2
|
+
export { D as memorySpendStore } from './ledger-BtzrfO-3.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A durable {@link SpendStore} backed by a local JSONL file (one settled payment per
|
|
6
|
+
* line). `load()` reads + parses the file at construction (a corrupt line is skipped,
|
|
7
|
+
* never fatal); `append()` writes one line per settle. Both swallow every I/O error so
|
|
8
|
+
* a disk hiccup can never abort a confirmed payment (ERRORS.md). The whole
|
|
9
|
+
* {@link SpendRecord} — incl. `decimals` + `denom` — round-trips, so totals and the
|
|
10
|
+
* cross-token grand total rebuild exactly on reload.
|
|
11
|
+
*
|
|
12
|
+
* @param path Filesystem path to the append-only log (created on first write).
|
|
13
|
+
*/
|
|
14
|
+
declare function fileSpendStore(path: string): SpendStore;
|
|
15
|
+
|
|
16
|
+
export { SpendStore, fileSpendStore };
|
package/dist/node.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { o as SpendStore } from './ledger-BtzrfO-3.js';
|
|
2
|
+
export { D as memorySpendStore } from './ledger-BtzrfO-3.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A durable {@link SpendStore} backed by a local JSONL file (one settled payment per
|
|
6
|
+
* line). `load()` reads + parses the file at construction (a corrupt line is skipped,
|
|
7
|
+
* never fatal); `append()` writes one line per settle. Both swallow every I/O error so
|
|
8
|
+
* a disk hiccup can never abort a confirmed payment (ERRORS.md). The whole
|
|
9
|
+
* {@link SpendRecord} — incl. `decimals` + `denom` — round-trips, so totals and the
|
|
10
|
+
* cross-token grand total rebuild exactly on reload.
|
|
11
|
+
*
|
|
12
|
+
* @param path Filesystem path to the append-only log (created on first write).
|
|
13
|
+
*/
|
|
14
|
+
declare function fileSpendStore(path: string): SpendStore;
|
|
15
|
+
|
|
16
|
+
export { SpendStore, fileSpendStore };
|
package/dist/node.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {
|
|
2
|
+
memorySpendStore
|
|
3
|
+
} from "./chunk-SK3CB7UA.js";
|
|
4
|
+
|
|
5
|
+
// src/node.ts
|
|
6
|
+
import { appendFileSync, existsSync, readFileSync } from "fs";
|
|
7
|
+
function fileSpendStore(path) {
|
|
8
|
+
return {
|
|
9
|
+
load() {
|
|
10
|
+
try {
|
|
11
|
+
if (!existsSync(path)) return [];
|
|
12
|
+
const out = [];
|
|
13
|
+
for (const line of readFileSync(path, "utf8").split("\n")) {
|
|
14
|
+
const trimmed = line.trim();
|
|
15
|
+
if (!trimmed) continue;
|
|
16
|
+
try {
|
|
17
|
+
out.push(JSON.parse(trimmed));
|
|
18
|
+
} catch {
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return out;
|
|
22
|
+
} catch {
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
append(record) {
|
|
27
|
+
try {
|
|
28
|
+
appendFileSync(path, `${JSON.stringify(record)}
|
|
29
|
+
`);
|
|
30
|
+
} catch {
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
fileSpendStore,
|
|
37
|
+
memorySpendStore
|
|
38
|
+
};
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkMWBT7MCEcjs = require('./chunk-MWBT7MCE.cjs');
|
|
12
12
|
|
|
13
13
|
// src/drivers/solana/index.ts
|
|
14
14
|
var _web3js = require('@solana/web3.js');
|
|
@@ -236,7 +236,7 @@ function isEmptySig(sig) {
|
|
|
236
236
|
function memoRandomNonce() {
|
|
237
237
|
const g = globalThis.crypto;
|
|
238
238
|
if (!_optionalChain([g, 'optionalAccess', _3 => _3.getRandomValues])) {
|
|
239
|
-
throw new (0,
|
|
239
|
+
throw new (0, _chunkMWBT7MCEcjs.UnsupportedSchemeError)(
|
|
240
240
|
"this runtime lacks Web Crypto (globalThis.crypto.getRandomValues); SVM exact needs a CSPRNG nonce."
|
|
241
241
|
);
|
|
242
242
|
}
|
|
@@ -248,7 +248,7 @@ function memoDataFor(accept) {
|
|
|
248
248
|
if (accept.extra.memo !== void 0) {
|
|
249
249
|
const bytes = Buffer.from(accept.extra.memo, "utf8");
|
|
250
250
|
if (bytes.length > MAX_MEMO_BYTES) {
|
|
251
|
-
throw new (0,
|
|
251
|
+
throw new (0, _chunkMWBT7MCEcjs.UnsupportedSchemeError)(
|
|
252
252
|
`SVM exact: extra.memo is ${bytes.length} bytes; the scheme caps it at ${MAX_MEMO_BYTES}.`
|
|
253
253
|
);
|
|
254
254
|
}
|
|
@@ -262,15 +262,15 @@ function memoInstruction(accept) {
|
|
|
262
262
|
async function payExactSolana(input) {
|
|
263
263
|
const { connection, keypair, accept } = input;
|
|
264
264
|
if (accept.asset === "native") {
|
|
265
|
-
throw new (0,
|
|
265
|
+
throw new (0, _chunkMWBT7MCEcjs.UnsupportedSchemeError)(
|
|
266
266
|
"SVM exact is SPL-token only (TransferChecked); native SOL is not exact-payable. Pay via onchain-proof."
|
|
267
267
|
);
|
|
268
268
|
}
|
|
269
269
|
if (!accept.extra.feePayer) {
|
|
270
|
-
throw new (0,
|
|
270
|
+
throw new (0, _chunkMWBT7MCEcjs.UnsupportedSchemeError)("SVM exact rail must advertise extra.feePayer (the merchant sponsor key).");
|
|
271
271
|
}
|
|
272
272
|
if (accept.extra.decimals === void 0) {
|
|
273
|
-
throw new (0,
|
|
273
|
+
throw new (0, _chunkMWBT7MCEcjs.UnsupportedSchemeError)("SVM exact rail must advertise extra.decimals for the TransferChecked.");
|
|
274
274
|
}
|
|
275
275
|
let feePayer;
|
|
276
276
|
let mint;
|
|
@@ -280,12 +280,12 @@ async function payExactSolana(input) {
|
|
|
280
280
|
mint = new (0, _web3js.PublicKey)(accept.asset);
|
|
281
281
|
payTo = new (0, _web3js.PublicKey)(accept.payTo);
|
|
282
282
|
} catch (err) {
|
|
283
|
-
throw new (0,
|
|
283
|
+
throw new (0, _chunkMWBT7MCEcjs.UnsupportedSchemeError)(
|
|
284
284
|
`SVM exact: bad feePayer/asset/payTo (${err instanceof Error ? err.message : String(err)}).`
|
|
285
285
|
);
|
|
286
286
|
}
|
|
287
287
|
if (feePayer.equals(payTo)) {
|
|
288
|
-
throw new (0,
|
|
288
|
+
throw new (0, _chunkMWBT7MCEcjs.UnsupportedSchemeError)(
|
|
289
289
|
"SVM exact: the fee payer must differ from payTo \u2014 payTo appears in the transfer instruction, which the fee payer must not (a scheme MUST-rule). Use a separate relayer key for the gate."
|
|
290
290
|
);
|
|
291
291
|
}
|
|
@@ -299,7 +299,7 @@ async function payExactSolana(input) {
|
|
|
299
299
|
destInfo = "unknown";
|
|
300
300
|
}
|
|
301
301
|
if (destInfo === null) {
|
|
302
|
-
throw new (0,
|
|
302
|
+
throw new (0, _chunkMWBT7MCEcjs.UnsupportedSchemeError)(
|
|
303
303
|
`SVM exact: the recipient's token account for ${mint.toBase58()} doesn't exist yet \u2014 the exact rail can't create it. Pay via onchain-proof (which creates it), or have ${payTo.toBase58()} create its associated token account first.`
|
|
304
304
|
);
|
|
305
305
|
}
|
|
@@ -330,11 +330,11 @@ async function payExactSolana(input) {
|
|
|
330
330
|
tx.sign([keypair]);
|
|
331
331
|
const buyerIndex = message.staticAccountKeys.findIndex((k) => k.equals(keypair.publicKey));
|
|
332
332
|
if (buyerIndex < 1 || buyerIndex >= message.header.numRequiredSignatures) {
|
|
333
|
-
throw new (0,
|
|
333
|
+
throw new (0, _chunkMWBT7MCEcjs.UnsupportedSchemeError)("SVM exact: could not locate the buyer signer slot.");
|
|
334
334
|
}
|
|
335
335
|
const buyerSig = tx.signatures[buyerIndex];
|
|
336
336
|
if (!buyerSig || isEmptySig(buyerSig)) {
|
|
337
|
-
throw new (0,
|
|
337
|
+
throw new (0, _chunkMWBT7MCEcjs.UnsupportedSchemeError)("SVM exact: the wallet did not produce a buyer signature.");
|
|
338
338
|
}
|
|
339
339
|
const transaction = Buffer.from(tx.serialize()).toString("base64");
|
|
340
340
|
return {
|
|
@@ -361,15 +361,15 @@ async function verifyAndSettleExactSolana(input) {
|
|
|
361
361
|
if (!accept.extra.feePayer) throw new Error("rail is missing extra.feePayer");
|
|
362
362
|
railFeePayer = new (0, _web3js.PublicKey)(accept.extra.feePayer);
|
|
363
363
|
} catch (err) {
|
|
364
|
-
throw new (0,
|
|
364
|
+
throw new (0, _chunkMWBT7MCEcjs.SettlementError)(`SVM exact: rail has a bad payTo/asset/feePayer (${err instanceof Error ? err.message : String(err)}).`);
|
|
365
365
|
}
|
|
366
366
|
if (!railFeePayer.equals(feePayerKeypair.publicKey)) {
|
|
367
|
-
throw new (0,
|
|
367
|
+
throw new (0, _chunkMWBT7MCEcjs.SettlementError)(
|
|
368
368
|
"SVM exact: the gate relayer key does not match the rail extra.feePayer \u2014 misconfigured rail."
|
|
369
369
|
);
|
|
370
370
|
}
|
|
371
371
|
if (feePayerKeypair.publicKey.equals(payTo)) {
|
|
372
|
-
throw new (0,
|
|
372
|
+
throw new (0, _chunkMWBT7MCEcjs.SettlementError)("SVM exact: the fee payer must differ from payTo \u2014 misconfigured rail.");
|
|
373
373
|
}
|
|
374
374
|
const program = tokenProgramFor(accept);
|
|
375
375
|
let tx;
|
|
@@ -509,7 +509,7 @@ async function verifyAndSettleExactSolana(input) {
|
|
|
509
509
|
} catch (err) {
|
|
510
510
|
const msg = err instanceof Error ? err.message : String(err);
|
|
511
511
|
if (/blockhash|block height|expired/i.test(msg)) return fail("payment_expired", `Settle broadcast rejected \u2014 blockhash expired: ${shorten(msg)}.`);
|
|
512
|
-
throw new (0,
|
|
512
|
+
throw new (0, _chunkMWBT7MCEcjs.SettlementError)(
|
|
513
513
|
`SVM exact settle: the merchant fee payer failed to broadcast (${shorten(msg)}). The buyer's signed transaction is still valid \u2014 fund/fix the fee payer and the buyer can re-present it.`,
|
|
514
514
|
{ cause: err }
|
|
515
515
|
);
|
|
@@ -519,7 +519,7 @@ async function verifyAndSettleExactSolana(input) {
|
|
|
519
519
|
return fail("tx_reverted", `Settle tx ${txid} reverted on-chain (a post-simulate race).`);
|
|
520
520
|
}
|
|
521
521
|
if (confirmed === "timeout") {
|
|
522
|
-
throw new (0,
|
|
522
|
+
throw new (0, _chunkMWBT7MCEcjs.SettlementError)(
|
|
523
523
|
`SVM exact settle: broadcast ${txid} but it did not confirm in time. It likely landed \u2014 re-verify by signature before re-presenting; do NOT re-pay.`
|
|
524
524
|
);
|
|
525
525
|
}
|
|
@@ -562,18 +562,18 @@ async function pollConfirmed(connection, signature) {
|
|
|
562
562
|
|
|
563
563
|
function toKeypair(wallet, network) {
|
|
564
564
|
if (typeof wallet !== "object" || wallet === null) {
|
|
565
|
-
throw new (0,
|
|
565
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
566
566
|
`chain ${network} is Solana; wallet must be { key } (base58 secret) or { signer }.`
|
|
567
567
|
);
|
|
568
568
|
}
|
|
569
|
-
|
|
569
|
+
_chunkMWBT7MCEcjs.assertNoLegacyWalletKey.call(void 0, wallet, "Solana");
|
|
570
570
|
if ("signer" in wallet) {
|
|
571
571
|
return wallet.signer;
|
|
572
572
|
}
|
|
573
573
|
if ("key" in wallet) {
|
|
574
574
|
const sk = wallet.key;
|
|
575
575
|
if (typeof sk === "string" && sk.startsWith("0x")) {
|
|
576
|
-
throw new (0,
|
|
576
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
577
577
|
`chain ${network} is Solana, but the wallet { key } is a 0x\u2026 hex key \u2014 that's an EVM key. A Solana key is a base58 secret string (or a 64-byte Uint8Array).`
|
|
578
578
|
);
|
|
579
579
|
}
|
|
@@ -581,12 +581,12 @@ function toKeypair(wallet, network) {
|
|
|
581
581
|
const bytes = typeof sk === "string" ? _bs582.default.decode(sk) : sk;
|
|
582
582
|
return _web3js.Keypair.fromSecretKey(bytes);
|
|
583
583
|
} catch (err) {
|
|
584
|
-
throw new (0,
|
|
584
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
585
585
|
`chain ${network} is Solana; the wallet { key } isn't a valid Solana secret (expected a base58 secret string or a 64-byte Uint8Array): ${err instanceof Error ? err.message : String(err)}.`
|
|
586
586
|
);
|
|
587
587
|
}
|
|
588
588
|
}
|
|
589
|
-
throw new (0,
|
|
589
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
590
590
|
`chain ${network} is Solana; wallet must be { key } (base58 secret) or { signer }.`
|
|
591
591
|
);
|
|
592
592
|
}
|
|
@@ -615,15 +615,15 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
615
615
|
const info = preset.tokens[token.toUpperCase()];
|
|
616
616
|
if (!info) {
|
|
617
617
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
618
|
-
throw new (0,
|
|
618
|
+
throw new (0, _chunkMWBT7MCEcjs.UnknownTokenError)(
|
|
619
619
|
`token "${token}" isn't built in for Solana (known: ${known}). Pass { mint, decimals } instead, or use 'native'.`
|
|
620
620
|
);
|
|
621
621
|
}
|
|
622
622
|
return { asset: info.mint, decimals: info.decimals, symbol: info.symbol };
|
|
623
623
|
}
|
|
624
|
-
|
|
624
|
+
_chunkMWBT7MCEcjs.rejectForeignToken.call(void 0, token, "solana", network);
|
|
625
625
|
if (!("mint" in token)) {
|
|
626
|
-
throw new (0,
|
|
626
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
627
627
|
`chain ${network} is Solana; a custom token must be { mint, decimals }.`
|
|
628
628
|
);
|
|
629
629
|
}
|
|
@@ -642,14 +642,14 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
642
642
|
},
|
|
643
643
|
assertValidPayTo(payTo) {
|
|
644
644
|
if (payTo.startsWith("0x")) {
|
|
645
|
-
throw new (0,
|
|
645
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
646
646
|
`chain ${network} is Solana, but payTo "${payTo}" looks like an EVM address.`
|
|
647
647
|
);
|
|
648
648
|
}
|
|
649
649
|
try {
|
|
650
650
|
new (0, _web3js.PublicKey)(payTo);
|
|
651
651
|
} catch (e7) {
|
|
652
|
-
throw new (0,
|
|
652
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
653
653
|
`chain ${network} is Solana, but payTo "${payTo}" is not a base58 address.`
|
|
654
654
|
);
|
|
655
655
|
}
|
|
@@ -661,7 +661,7 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
661
661
|
try {
|
|
662
662
|
return await paySolana({ connection, keypair: wallet._native, accept });
|
|
663
663
|
} catch (err) {
|
|
664
|
-
throw _nullishCoalesce(
|
|
664
|
+
throw _nullishCoalesce(_chunkMWBT7MCEcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
665
665
|
}
|
|
666
666
|
},
|
|
667
667
|
async confirm(ref) {
|
|
@@ -672,19 +672,19 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
672
672
|
});
|
|
673
673
|
info = value[0];
|
|
674
674
|
} catch (err) {
|
|
675
|
-
throw new (0,
|
|
675
|
+
throw new (0, _chunkMWBT7MCEcjs.ConfirmationTimeoutError)(
|
|
676
676
|
`Solana payment ${ref} could not be confirmed (RPC read failed).`,
|
|
677
677
|
{ cause: err }
|
|
678
678
|
);
|
|
679
679
|
}
|
|
680
680
|
if (!info || info.err || info.confirmationStatus !== "confirmed" && info.confirmationStatus !== "finalized") {
|
|
681
|
-
throw new (0,
|
|
681
|
+
throw new (0, _chunkMWBT7MCEcjs.ConfirmationTimeoutError)(`Solana payment ${ref} did not confirm in time.`);
|
|
682
682
|
}
|
|
683
683
|
return { height: String(info.slot) };
|
|
684
684
|
},
|
|
685
685
|
async estimateCost(accept) {
|
|
686
686
|
if (accept.scheme === "exact") {
|
|
687
|
-
return
|
|
687
|
+
return _chunkMWBT7MCEcjs.nativeCost.call(void 0, {
|
|
688
688
|
symbol: "SOL",
|
|
689
689
|
decimals: SOL_DECIMALS,
|
|
690
690
|
fee: 0n,
|
|
@@ -694,7 +694,7 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
694
694
|
}
|
|
695
695
|
const base = 5000n;
|
|
696
696
|
if (accept.asset === "native") {
|
|
697
|
-
return
|
|
697
|
+
return _chunkMWBT7MCEcjs.nativeCost.call(void 0, {
|
|
698
698
|
symbol: "SOL",
|
|
699
699
|
decimals: SOL_DECIMALS,
|
|
700
700
|
fee: base,
|
|
@@ -703,7 +703,7 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
703
703
|
});
|
|
704
704
|
}
|
|
705
705
|
const ataRent = 2039280n;
|
|
706
|
-
return
|
|
706
|
+
return _chunkMWBT7MCEcjs.nativeCost.call(void 0, {
|
|
707
707
|
symbol: "SOL",
|
|
708
708
|
decimals: SOL_DECIMALS,
|
|
709
709
|
fee: base + ataRent,
|