@piprail/sdk 2.14.1 → 2.14.2
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 +26 -0
- package/dist/{algorand-RM7MP4PK.js → algorand-CSEUTWNW.js} +1 -1
- package/dist/{algorand-ICJNXO5V.cjs → algorand-I2O24RSM.cjs} +32 -32
- package/dist/{aptos-MVEG5ZPS.cjs → aptos-GA5AEYYL.cjs} +31 -31
- package/dist/{aptos-2FIRTMQX.js → aptos-J7QGCWNW.js} +1 -1
- package/dist/{chunk-57V5DNJT.cjs → chunk-3FR22M3O.cjs} +5 -0
- package/dist/{chunk-NUPCFNC5.js → chunk-3ZWM3DKM.js} +5 -0
- package/dist/index.cjs +240 -208
- package/dist/index.d.cts +0 -9
- package/dist/index.d.ts +0 -9
- package/dist/index.js +72 -40
- package/dist/{near-C2IS4RCH.cjs → near-NDQLGI4U.cjs} +27 -27
- package/dist/{near-L2OWD7M6.js → near-YA4Y4IGC.js} +1 -1
- package/dist/{solana-V2TGLHJ4.js → solana-MB6G3OA5.js} +1 -1
- package/dist/{solana-B424IQ5I.cjs → solana-OU6IUMQM.cjs} +32 -32
- package/dist/{stellar-4YR4UZQX.cjs → stellar-RSNVOIKL.cjs} +20 -20
- package/dist/{stellar-J7VE7QP7.js → stellar-WDWSYOED.js} +1 -1
- package/dist/{sui-GMRQAAJH.js → sui-GVSFNNJX.js} +1 -1
- package/dist/{sui-F7UW6JXJ.cjs → sui-MVC46BFJ.cjs} +16 -16
- package/dist/{ton-PEBYBNWJ.js → ton-EJMGM3YI.js} +1 -1
- package/dist/{ton-3SHFVDLP.cjs → ton-MYOI3U3H.cjs} +16 -16
- package/dist/{tron-BS5EID2U.cjs → tron-42X5N4GQ.cjs} +25 -25
- package/dist/{tron-ZYJHHROT.js → tron-VAPVMGJK.js} +1 -1
- package/dist/{xrpl-SUEFOOKW.cjs → xrpl-MGUBUNSZ.cjs} +20 -20
- package/dist/{xrpl-P2D6TS6I.js → xrpl-Q2UWPCTJ.js} +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -6749,15 +6749,6 @@ declare function buildOpenApi(input: ManifestInput): OpenApiDocument;
|
|
|
6749
6749
|
* `/openapi.json` is the primary doc; this is a compatibility breadcrumb.
|
|
6750
6750
|
*/
|
|
6751
6751
|
declare function buildWellKnownX402(input: ManifestInput): WellKnownX402;
|
|
6752
|
-
/**
|
|
6753
|
-
* Build the official `/.well-known/x402.json` manifest (x402-foundation PR #2646 shape) — a
|
|
6754
|
-
* SECOND, richer discovery file beside the legacy {@link buildWellKnownX402}. Forward-compatible
|
|
6755
|
-
* by design: it emits only the fields the proposal defines, tolerates the spec adding more, and
|
|
6756
|
-
* pins nothing (the PR is explicitly pre-merge), so when #2646 stabilises only this one emitter
|
|
6757
|
-
* (and the docs recommendation) move — no default ever changed. `lastUpdated` defaults to now
|
|
6758
|
-
* (Unix seconds); pass it explicitly for a deterministic file. PURE — no network, no chain
|
|
6759
|
-
* library, fully deterministic given its args. The merchant hosts the result; PipRail serves nothing.
|
|
6760
|
-
*/
|
|
6761
6752
|
declare function buildWellKnownX402Manifest(input: ManifestInput & {
|
|
6762
6753
|
lastUpdated?: number;
|
|
6763
6754
|
}): WellKnownX402Manifest;
|
package/dist/index.d.ts
CHANGED
|
@@ -6749,15 +6749,6 @@ declare function buildOpenApi(input: ManifestInput): OpenApiDocument;
|
|
|
6749
6749
|
* `/openapi.json` is the primary doc; this is a compatibility breadcrumb.
|
|
6750
6750
|
*/
|
|
6751
6751
|
declare function buildWellKnownX402(input: ManifestInput): WellKnownX402;
|
|
6752
|
-
/**
|
|
6753
|
-
* Build the official `/.well-known/x402.json` manifest (x402-foundation PR #2646 shape) — a
|
|
6754
|
-
* SECOND, richer discovery file beside the legacy {@link buildWellKnownX402}. Forward-compatible
|
|
6755
|
-
* by design: it emits only the fields the proposal defines, tolerates the spec adding more, and
|
|
6756
|
-
* pins nothing (the PR is explicitly pre-merge), so when #2646 stabilises only this one emitter
|
|
6757
|
-
* (and the docs recommendation) move — no default ever changed. `lastUpdated` defaults to now
|
|
6758
|
-
* (Unix seconds); pass it explicitly for a deterministic file. PURE — no network, no chain
|
|
6759
|
-
* library, fully deterministic given its args. The merchant hosts the result; PipRail serves nothing.
|
|
6760
|
-
*/
|
|
6761
6752
|
declare function buildWellKnownX402Manifest(input: ManifestInput & {
|
|
6762
6753
|
lastUpdated?: number;
|
|
6763
6754
|
}): WellKnownX402Manifest;
|
package/dist/index.js
CHANGED
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
parseUnits,
|
|
33
33
|
rejectForeignToken,
|
|
34
34
|
toInsufficientFundsError
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-3ZWM3DKM.js";
|
|
36
36
|
|
|
37
37
|
// src/drivers/registry.ts
|
|
38
38
|
var byFamily = /* @__PURE__ */ new Map();
|
|
@@ -2382,7 +2382,7 @@ var loaders = {
|
|
|
2382
2382
|
solana: async () => {
|
|
2383
2383
|
let mod;
|
|
2384
2384
|
try {
|
|
2385
|
-
mod = await import("./solana-
|
|
2385
|
+
mod = await import("./solana-MB6G3OA5.js");
|
|
2386
2386
|
} catch (cause) {
|
|
2387
2387
|
throw new MissingDriverError(
|
|
2388
2388
|
`Solana selected, but its packages aren't installed. Run: npm install @solana/web3.js @solana/spl-token bs58`,
|
|
@@ -2394,7 +2394,7 @@ var loaders = {
|
|
|
2394
2394
|
ton: async () => {
|
|
2395
2395
|
let mod;
|
|
2396
2396
|
try {
|
|
2397
|
-
mod = await import("./ton-
|
|
2397
|
+
mod = await import("./ton-EJMGM3YI.js");
|
|
2398
2398
|
} catch (cause) {
|
|
2399
2399
|
throw new MissingDriverError(
|
|
2400
2400
|
`TON selected, but its packages aren't installed. Run: npm install @ton/ton @ton/core @ton/crypto`,
|
|
@@ -2406,7 +2406,7 @@ var loaders = {
|
|
|
2406
2406
|
stellar: async () => {
|
|
2407
2407
|
let mod;
|
|
2408
2408
|
try {
|
|
2409
|
-
mod = await import("./stellar-
|
|
2409
|
+
mod = await import("./stellar-WDWSYOED.js");
|
|
2410
2410
|
} catch (cause) {
|
|
2411
2411
|
throw new MissingDriverError(
|
|
2412
2412
|
`Stellar selected, but its package isn't installed. Run: npm install @stellar/stellar-sdk`,
|
|
@@ -2418,7 +2418,7 @@ var loaders = {
|
|
|
2418
2418
|
xrpl: async () => {
|
|
2419
2419
|
let mod;
|
|
2420
2420
|
try {
|
|
2421
|
-
mod = await import("./xrpl-
|
|
2421
|
+
mod = await import("./xrpl-Q2UWPCTJ.js");
|
|
2422
2422
|
} catch (cause) {
|
|
2423
2423
|
throw new MissingDriverError(
|
|
2424
2424
|
`XRPL selected, but its package isn't installed. Run: npm install xrpl`,
|
|
@@ -2430,7 +2430,7 @@ var loaders = {
|
|
|
2430
2430
|
tron: async () => {
|
|
2431
2431
|
let mod;
|
|
2432
2432
|
try {
|
|
2433
|
-
mod = await import("./tron-
|
|
2433
|
+
mod = await import("./tron-VAPVMGJK.js");
|
|
2434
2434
|
} catch (cause) {
|
|
2435
2435
|
throw new MissingDriverError(
|
|
2436
2436
|
`Tron selected, but its package isn't installed. Run: npm install tronweb`,
|
|
@@ -2442,7 +2442,7 @@ var loaders = {
|
|
|
2442
2442
|
sui: async () => {
|
|
2443
2443
|
let mod;
|
|
2444
2444
|
try {
|
|
2445
|
-
mod = await import("./sui-
|
|
2445
|
+
mod = await import("./sui-GVSFNNJX.js");
|
|
2446
2446
|
} catch (cause) {
|
|
2447
2447
|
throw new MissingDriverError(
|
|
2448
2448
|
`Sui selected, but its package isn't installed. Run: npm install @mysten/sui`,
|
|
@@ -2454,7 +2454,7 @@ var loaders = {
|
|
|
2454
2454
|
near: async () => {
|
|
2455
2455
|
let mod;
|
|
2456
2456
|
try {
|
|
2457
|
-
mod = await import("./near-
|
|
2457
|
+
mod = await import("./near-YA4Y4IGC.js");
|
|
2458
2458
|
} catch (cause) {
|
|
2459
2459
|
throw new MissingDriverError(
|
|
2460
2460
|
`NEAR selected, but its package isn't installed. Run: npm install near-api-js`,
|
|
@@ -2466,7 +2466,7 @@ var loaders = {
|
|
|
2466
2466
|
aptos: async () => {
|
|
2467
2467
|
let mod;
|
|
2468
2468
|
try {
|
|
2469
|
-
mod = await import("./aptos-
|
|
2469
|
+
mod = await import("./aptos-J7QGCWNW.js");
|
|
2470
2470
|
} catch (cause) {
|
|
2471
2471
|
throw new MissingDriverError(
|
|
2472
2472
|
`Aptos selected, but its package isn't installed. Run: npm install @aptos-labs/ts-sdk`,
|
|
@@ -2478,7 +2478,7 @@ var loaders = {
|
|
|
2478
2478
|
algorand: async () => {
|
|
2479
2479
|
let mod;
|
|
2480
2480
|
try {
|
|
2481
|
-
mod = await import("./algorand-
|
|
2481
|
+
mod = await import("./algorand-CSEUTWNW.js");
|
|
2482
2482
|
} catch (cause) {
|
|
2483
2483
|
throw new MissingDriverError(
|
|
2484
2484
|
`Algorand selected, but its package isn't installed. Run: npm install algosdk`,
|
|
@@ -5537,17 +5537,20 @@ function formatSpendReport(summary) {
|
|
|
5537
5537
|
return `${perAsset} \u2014 grand total: ${grand}`;
|
|
5538
5538
|
}
|
|
5539
5539
|
function describeChallenge(challenge) {
|
|
5540
|
-
const
|
|
5541
|
-
|
|
5542
|
-
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
|
|
5549
|
-
|
|
5550
|
-
|
|
5540
|
+
const generic = `${BRAND.name} x402 payment endpoint. Pay with @piprail/sdk (${BRAND.sdkInstall}). Docs: ${BRAND.home}.`;
|
|
5541
|
+
try {
|
|
5542
|
+
const accepts = Array.isArray(challenge?.accepts) ? challenge.accepts : [];
|
|
5543
|
+
const first = accepts[0];
|
|
5544
|
+
if (!first) return generic;
|
|
5545
|
+
const extra = first.extra ?? {};
|
|
5546
|
+
const amount = extra.amountFormatted ?? first.amount;
|
|
5547
|
+
const token = extra.symbol ?? first.asset;
|
|
5548
|
+
const hasExact = accepts.some((a) => a?.scheme === "exact");
|
|
5549
|
+
const standard = hasExact ? "; or any standard x402 client (an exact rail is offered)" : "";
|
|
5550
|
+
return `${BRAND.name} x402 payment endpoint \u2014 pay ${amount} ${token} on ${first.network} to ${first.payTo}. Programmatic: ${BRAND.sdkInstall} then client.fetch(url)${standard}. Docs: ${BRAND.home}.`;
|
|
5551
|
+
} catch {
|
|
5552
|
+
return generic;
|
|
5553
|
+
}
|
|
5551
5554
|
}
|
|
5552
5555
|
|
|
5553
5556
|
// src/agentGuide.ts
|
|
@@ -6037,17 +6040,29 @@ function paymentTools(client) {
|
|
|
6037
6040
|
|
|
6038
6041
|
// src/classify.ts
|
|
6039
6042
|
function classifyChallenge(challenge, opts) {
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
|
|
6045
|
-
|
|
6046
|
-
|
|
6047
|
-
(a) => a.
|
|
6048
|
-
|
|
6049
|
-
|
|
6050
|
-
|
|
6043
|
+
try {
|
|
6044
|
+
const accepts = Array.isArray(challenge?.accepts) ? challenge.accepts : [];
|
|
6045
|
+
const network = opts?.network;
|
|
6046
|
+
const schemes = opts?.schemes ?? [];
|
|
6047
|
+
const offeredSchemes = [
|
|
6048
|
+
...new Set(accepts.map((a) => a?.scheme).filter((s) => s != null))
|
|
6049
|
+
];
|
|
6050
|
+
const offeredNetworks = [...new Set(accepts.map((a) => a?.network).filter((n) => n != null))];
|
|
6051
|
+
const onClientChain = accepts.some((a) => a?.network === network);
|
|
6052
|
+
const payableScheme = accepts.some(
|
|
6053
|
+
(a) => a?.network === network && schemes.includes(a?.scheme)
|
|
6054
|
+
);
|
|
6055
|
+
const verdict = accepts.length === 0 ? "NO_RAIL" : payableScheme ? "PAYABLE_RAIL" : onClientChain ? "UNPAYABLE_SCHEME" : "WRONG_CHAIN";
|
|
6056
|
+
return { onClientChain, payableScheme, offeredSchemes, offeredNetworks, verdict };
|
|
6057
|
+
} catch {
|
|
6058
|
+
return {
|
|
6059
|
+
onClientChain: false,
|
|
6060
|
+
payableScheme: false,
|
|
6061
|
+
offeredSchemes: [],
|
|
6062
|
+
offeredNetworks: [],
|
|
6063
|
+
verdict: "NO_RAIL"
|
|
6064
|
+
};
|
|
6065
|
+
}
|
|
6051
6066
|
}
|
|
6052
6067
|
|
|
6053
6068
|
// src/discovery.ts
|
|
@@ -6094,6 +6109,7 @@ function pathOf(url) {
|
|
|
6094
6109
|
}
|
|
6095
6110
|
}
|
|
6096
6111
|
function buildOpenApi(input) {
|
|
6112
|
+
assertResourceList(input?.resources, "buildOpenApi");
|
|
6097
6113
|
const paths = {};
|
|
6098
6114
|
for (const r of input.resources) {
|
|
6099
6115
|
const path = pathOf(r.url);
|
|
@@ -6123,18 +6139,27 @@ function buildOpenApi(input) {
|
|
|
6123
6139
|
};
|
|
6124
6140
|
}
|
|
6125
6141
|
function buildWellKnownX402(input) {
|
|
6142
|
+
assertResourceList(input?.resources, "buildWellKnownX402");
|
|
6126
6143
|
return {
|
|
6127
6144
|
version: 1,
|
|
6128
6145
|
resources: input.resources.map((r) => r.url),
|
|
6129
6146
|
...input.ownershipProofs && input.ownershipProofs.length > 0 ? { ownershipProofs: input.ownershipProofs } : {}
|
|
6130
6147
|
};
|
|
6131
6148
|
}
|
|
6132
|
-
function
|
|
6133
|
-
if (!Array.isArray(
|
|
6134
|
-
throw new InvalidConfigError(
|
|
6135
|
-
"buildWellKnownX402Manifest: `resources` must be an array of ResourceDescription."
|
|
6136
|
-
);
|
|
6149
|
+
function assertResourceList(resources, fn) {
|
|
6150
|
+
if (!Array.isArray(resources)) {
|
|
6151
|
+
throw new InvalidConfigError(`${fn}: \`resources\` must be an array of ResourceDescription.`);
|
|
6137
6152
|
}
|
|
6153
|
+
resources.forEach((r, i) => {
|
|
6154
|
+
if (r === null || typeof r !== "object" || typeof r.url !== "string") {
|
|
6155
|
+
throw new InvalidConfigError(
|
|
6156
|
+
`${fn}: resources[${i}] must be a ResourceDescription with a string \`url\`.`
|
|
6157
|
+
);
|
|
6158
|
+
}
|
|
6159
|
+
});
|
|
6160
|
+
}
|
|
6161
|
+
function buildWellKnownX402Manifest(input) {
|
|
6162
|
+
assertResourceList(input?.resources, "buildWellKnownX402Manifest");
|
|
6138
6163
|
const lastUpdated = typeof input.lastUpdated === "number" && Number.isFinite(input.lastUpdated) ? input.lastUpdated : Math.floor(Date.now() / 1e3);
|
|
6139
6164
|
return {
|
|
6140
6165
|
x402Version: 2,
|
|
@@ -6684,18 +6709,25 @@ function toInvalidBody(result) {
|
|
|
6684
6709
|
return { x402Version: 2, status: "invalid", error: result.error, detail: result.detail };
|
|
6685
6710
|
}
|
|
6686
6711
|
function normaliseAccepts(options) {
|
|
6687
|
-
if (options.accept && options.accept.length > 0) {
|
|
6712
|
+
if (Array.isArray(options.accept) && options.accept.length > 0) {
|
|
6688
6713
|
if (options.chain !== void 0 || options.token !== void 0 || options.amount !== void 0) {
|
|
6689
|
-
throw new
|
|
6714
|
+
throw new InvalidConfigError(
|
|
6690
6715
|
"requirePayment: pass EITHER `accept: [...]` (multi-chain) OR `chain`/`token`/`amount` (single) \u2014 not both."
|
|
6691
6716
|
);
|
|
6692
6717
|
}
|
|
6718
|
+
options.accept.forEach((a, i) => {
|
|
6719
|
+
if (a === null || typeof a !== "object") {
|
|
6720
|
+
throw new InvalidConfigError(
|
|
6721
|
+
`requirePayment: accept[${i}] must be { chain, token, amount }, got ${a === null ? "null" : typeof a}.`
|
|
6722
|
+
);
|
|
6723
|
+
}
|
|
6724
|
+
});
|
|
6693
6725
|
return options.accept;
|
|
6694
6726
|
}
|
|
6695
6727
|
if (options.chain !== void 0 && options.token !== void 0 && options.amount !== void 0) {
|
|
6696
6728
|
return [{ chain: options.chain, token: options.token, amount: options.amount }];
|
|
6697
6729
|
}
|
|
6698
|
-
throw new
|
|
6730
|
+
throw new InvalidConfigError(
|
|
6699
6731
|
"requirePayment: provide either { chain, token, amount } or a non-empty `accept: [{ chain, token, amount }, \u2026]`."
|
|
6700
6732
|
);
|
|
6701
6733
|
}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunk3FR22M3Ocjs = require('./chunk-3FR22M3O.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, _chunk3FR22M3Ocjs.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, _chunk3FR22M3Ocjs.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(_chunk3FR22M3Ocjs.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, _chunk3FR22M3Ocjs.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(_chunk3FR22M3Ocjs.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, _chunk3FR22M3Ocjs.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, _chunk3FR22M3Ocjs.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, _chunk3FR22M3Ocjs.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, _chunk3FR22M3Ocjs.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, _chunk3FR22M3Ocjs.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, _chunk3FR22M3Ocjs.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, _chunk3FR22M3Ocjs.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, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
412
412
|
`chain ${network} is NEAR; wallet must be { accountId, key } (key = ed25519:\u2026).`
|
|
413
413
|
);
|
|
414
414
|
}
|
|
415
|
-
|
|
415
|
+
_chunk3FR22M3Ocjs.assertNoLegacyWalletKey.call(void 0, wallet, "NEAR");
|
|
416
416
|
if (!("accountId" in wallet) || !("key" in wallet)) {
|
|
417
|
-
throw new (0,
|
|
417
|
+
throw new (0, _chunk3FR22M3Ocjs.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, _chunk3FR22M3Ocjs.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, _chunk3FR22M3Ocjs.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, _chunk3FR22M3Ocjs.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
|
+
_chunk3FR22M3Ocjs.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, _chunk3FR22M3Ocjs.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, _chunk3FR22M3Ocjs.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, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
527
527
|
`chain ${network} is NEAR, but payTo "${payTo}" is not a valid NEAR account id.`
|
|
528
528
|
);
|
|
529
529
|
}
|
|
@@ -567,11 +567,11 @@ 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, _chunk3FR22M3Ocjs.ConfirmationTimeoutError)(`NEAR tx ${hash} not confirmed in time.`);
|
|
571
571
|
},
|
|
572
572
|
async estimateCost(accept) {
|
|
573
573
|
if (accept.scheme === "exact") {
|
|
574
|
-
return
|
|
574
|
+
return _chunk3FR22M3Ocjs.nativeCost.call(void 0, {
|
|
575
575
|
symbol: "NEAR",
|
|
576
576
|
decimals: NEAR_DECIMALS,
|
|
577
577
|
fee: 0n,
|
|
@@ -579,7 +579,7 @@ function makeNearNetwork(preset, rpcUrl) {
|
|
|
579
579
|
detail: "gasless \u2014 the relayer prepays gas + the 1 yocto; the buyer pays 0 NEAR"
|
|
580
580
|
});
|
|
581
581
|
}
|
|
582
|
-
return
|
|
582
|
+
return _chunk3FR22M3Ocjs.nativeCost.call(void 0, {
|
|
583
583
|
symbol: "NEAR",
|
|
584
584
|
decimals: NEAR_DECIMALS,
|
|
585
585
|
fee: 1500000000000000000000n,
|
|
@@ -701,7 +701,7 @@ function makeNearNetwork(preset, rpcUrl) {
|
|
|
701
701
|
try {
|
|
702
702
|
relayerWallet = resolveNearWallet(relayer._native);
|
|
703
703
|
} catch (err) {
|
|
704
|
-
throw new (0,
|
|
704
|
+
throw new (0, _chunk3FR22M3Ocjs.SettlementError)(
|
|
705
705
|
`NEAR exact settle: the relayer wallet is invalid (${err instanceof Error ? err.message : String(err)}).`,
|
|
706
706
|
{ cause: err }
|
|
707
707
|
);
|