@blockrun/clawrouter 0.12.314 → 0.12.316
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +543 -325
- package/dist/index.d.ts +25 -1
- package/dist/index.js +468 -250
- package/package.json +6 -6
package/dist/cli.js
CHANGED
|
@@ -59115,7 +59115,7 @@ var init_chunk_XW2CWVLZ = __esm({
|
|
|
59115
59115
|
}
|
|
59116
59116
|
});
|
|
59117
59117
|
|
|
59118
|
-
// node_modules/@x402/core/dist/esm/chunk-
|
|
59118
|
+
// node_modules/@x402/core/dist/esm/chunk-PVRH2E6N.mjs
|
|
59119
59119
|
async function readLimitedText(response, limit) {
|
|
59120
59120
|
if (!response.body) {
|
|
59121
59121
|
return response.text();
|
|
@@ -59165,8 +59165,8 @@ function decodePaymentResponseHeader(paymentResponseHeader) {
|
|
|
59165
59165
|
);
|
|
59166
59166
|
}
|
|
59167
59167
|
var MAX_CONTROL_PLANE_RESPONSE_BYTES, ResponseBodyTooLargeError2, verifyResponseSchema, settleResponseSchema, supportedKindSchema, supportedResponseSchema, x402HTTPClient, requireDecodedJsonObject;
|
|
59168
|
-
var
|
|
59169
|
-
"node_modules/@x402/core/dist/esm/chunk-
|
|
59168
|
+
var init_chunk_PVRH2E6N = __esm({
|
|
59169
|
+
"node_modules/@x402/core/dist/esm/chunk-PVRH2E6N.mjs"() {
|
|
59170
59170
|
"use strict";
|
|
59171
59171
|
init_chunk_Z7WXFCST();
|
|
59172
59172
|
init_chunk_VE37GDG2();
|
|
@@ -59490,7 +59490,7 @@ var DEFAULT_MAX_AMOUNT_PER_PAYMENT, x402Client;
|
|
|
59490
59490
|
var init_client = __esm({
|
|
59491
59491
|
"node_modules/@x402/core/dist/esm/client/index.mjs"() {
|
|
59492
59492
|
"use strict";
|
|
59493
|
-
|
|
59493
|
+
init_chunk_PVRH2E6N();
|
|
59494
59494
|
init_chunk_Z7WXFCST();
|
|
59495
59495
|
init_chunk_VE37GDG2();
|
|
59496
59496
|
init_chunk_MA7F3CLI();
|
|
@@ -60131,7 +60131,7 @@ var init_client = __esm({
|
|
|
60131
60131
|
var init_http4 = __esm({
|
|
60132
60132
|
"node_modules/@x402/core/dist/esm/http/index.mjs"() {
|
|
60133
60133
|
"use strict";
|
|
60134
|
-
|
|
60134
|
+
init_chunk_PVRH2E6N();
|
|
60135
60135
|
init_chunk_Z7WXFCST();
|
|
60136
60136
|
init_chunk_VE37GDG2();
|
|
60137
60137
|
init_chunk_MA7F3CLI();
|
|
@@ -60293,6 +60293,7 @@ var init_payment_chain = __esm({
|
|
|
60293
60293
|
import * as fs from "fs";
|
|
60294
60294
|
import * as path from "path";
|
|
60295
60295
|
import { homedir as homedir2 } from "os";
|
|
60296
|
+
import { randomUUID } from "crypto";
|
|
60296
60297
|
function normalizePayee(value) {
|
|
60297
60298
|
return EVM_ADDRESS.test(value) ? value.toLowerCase() : value;
|
|
60298
60299
|
}
|
|
@@ -60318,6 +60319,15 @@ function cloneLimits(limits) {
|
|
|
60318
60319
|
}
|
|
60319
60320
|
return clone2;
|
|
60320
60321
|
}
|
|
60322
|
+
function recordKey(r2) {
|
|
60323
|
+
return r2.id ?? `${r2.timestamp}|${r2.amount}|${r2.model ?? ""}|${r2.action ?? ""}`;
|
|
60324
|
+
}
|
|
60325
|
+
function mergeSpendHistory(a, b) {
|
|
60326
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
60327
|
+
for (const r2 of a) byKey.set(recordKey(r2), r2);
|
|
60328
|
+
for (const r2 of b) if (!byKey.has(recordKey(r2))) byKey.set(recordKey(r2), r2);
|
|
60329
|
+
return [...byKey.values()].sort((x, y) => x.timestamp - y.timestamp);
|
|
60330
|
+
}
|
|
60321
60331
|
function canonicalLimits(limits) {
|
|
60322
60332
|
return JSON.stringify(
|
|
60323
60333
|
Object.fromEntries(Object.entries(limits).sort(([a], [b]) => a < b ? -1 : 1))
|
|
@@ -60484,53 +60494,61 @@ var init_spend_control = __esm({
|
|
|
60484
60494
|
};
|
|
60485
60495
|
FileSpendControlStorage = class {
|
|
60486
60496
|
spendingFile;
|
|
60487
|
-
constructor() {
|
|
60488
|
-
this.spendingFile = path.join(WALLET_DIR, "spending.json");
|
|
60497
|
+
constructor(spendingFile) {
|
|
60498
|
+
this.spendingFile = spendingFile ?? path.join(WALLET_DIR, "spending.json");
|
|
60489
60499
|
}
|
|
60490
60500
|
load() {
|
|
60501
|
+
let raw;
|
|
60491
60502
|
try {
|
|
60492
|
-
|
|
60493
|
-
|
|
60494
|
-
|
|
60495
|
-
|
|
60496
|
-
|
|
60497
|
-
|
|
60498
|
-
|
|
60499
|
-
|
|
60500
|
-
|
|
60501
|
-
|
|
60502
|
-
|
|
60503
|
-
|
|
60504
|
-
|
|
60505
|
-
|
|
60506
|
-
|
|
60507
|
-
|
|
60508
|
-
|
|
60509
|
-
|
|
60510
|
-
|
|
60511
|
-
|
|
60512
|
-
|
|
60513
|
-
|
|
60514
|
-
|
|
60515
|
-
|
|
60516
|
-
|
|
60517
|
-
|
|
60518
|
-
|
|
60519
|
-
|
|
60520
|
-
|
|
60521
|
-
|
|
60522
|
-
|
|
60503
|
+
raw = readTextFileSync(this.spendingFile);
|
|
60504
|
+
} catch (err) {
|
|
60505
|
+
const code = err?.code;
|
|
60506
|
+
if (code === "ENOENT" || code === "ENOTDIR") {
|
|
60507
|
+
return null;
|
|
60508
|
+
}
|
|
60509
|
+
throw new UnreadableSpendPolicyError(err);
|
|
60510
|
+
}
|
|
60511
|
+
try {
|
|
60512
|
+
const data = JSON.parse(raw);
|
|
60513
|
+
const rawLimits = data.limits ?? {};
|
|
60514
|
+
const rawHistory = data.history ?? [];
|
|
60515
|
+
const limits = {};
|
|
60516
|
+
for (const key3 of ["perRequest", "hourly", "daily", "session"]) {
|
|
60517
|
+
const val = rawLimits[key3];
|
|
60518
|
+
if (typeof val === "number" && val > 0 && Number.isFinite(val)) {
|
|
60519
|
+
limits[key3] = val;
|
|
60520
|
+
}
|
|
60521
|
+
}
|
|
60522
|
+
for (const key3 of POLICY_LISTS) {
|
|
60523
|
+
if (!Object.prototype.hasOwnProperty.call(rawLimits, key3)) continue;
|
|
60524
|
+
const val = rawLimits[key3];
|
|
60525
|
+
if (!isValidPolicyValues(val)) {
|
|
60526
|
+
throw new MalformedSpendPolicyError(key3);
|
|
60527
|
+
}
|
|
60528
|
+
if (val.length === 0) continue;
|
|
60529
|
+
limits[key3] = normalizePolicyValues(key3, val);
|
|
60530
|
+
}
|
|
60531
|
+
const history = [];
|
|
60532
|
+
if (Array.isArray(rawHistory)) {
|
|
60533
|
+
for (const r2 of rawHistory) {
|
|
60534
|
+
if (typeof r2?.timestamp === "number" && typeof r2?.amount === "number" && Number.isFinite(r2.timestamp) && Number.isFinite(r2.amount) && r2.amount >= 0) {
|
|
60535
|
+
history.push({
|
|
60536
|
+
timestamp: r2.timestamp,
|
|
60537
|
+
amount: r2.amount,
|
|
60538
|
+
model: typeof r2.model === "string" ? r2.model : void 0,
|
|
60539
|
+
action: typeof r2.action === "string" ? r2.action : void 0,
|
|
60540
|
+
...typeof r2.id === "string" && r2.id !== "" ? { id: r2.id } : {}
|
|
60541
|
+
});
|
|
60523
60542
|
}
|
|
60524
60543
|
}
|
|
60525
|
-
return { limits, history };
|
|
60526
60544
|
}
|
|
60545
|
+
return { limits, history };
|
|
60527
60546
|
} catch (err) {
|
|
60528
60547
|
if (err instanceof MalformedSpendPolicyError) {
|
|
60529
60548
|
throw err;
|
|
60530
60549
|
}
|
|
60531
60550
|
throw new UnreadableSpendPolicyError(err);
|
|
60532
60551
|
}
|
|
60533
|
-
return null;
|
|
60534
60552
|
}
|
|
60535
60553
|
save(data) {
|
|
60536
60554
|
try {
|
|
@@ -60618,6 +60636,8 @@ var init_spend_control = __esm({
|
|
|
60618
60636
|
diskLimits = {};
|
|
60619
60637
|
/** Set when spending.json held an unusable policy list: refuse every payment. */
|
|
60620
60638
|
policyFileBroken;
|
|
60639
|
+
/** Whether persisted history loaded successfully; when false, recovery from an initial failure restores history. */
|
|
60640
|
+
initialHistoryLoaded = false;
|
|
60621
60641
|
storage;
|
|
60622
60642
|
now;
|
|
60623
60643
|
constructor(options) {
|
|
@@ -60683,7 +60703,7 @@ var init_spend_control = __esm({
|
|
|
60683
60703
|
data = this.storage.load();
|
|
60684
60704
|
} catch (err) {
|
|
60685
60705
|
if (err instanceof UnreadableSpendPolicyError) {
|
|
60686
|
-
console.error(`${err.message}
|
|
60706
|
+
console.error(`${err.message}: keeping the limits already in effect`);
|
|
60687
60707
|
return;
|
|
60688
60708
|
}
|
|
60689
60709
|
if (!(err instanceof MalformedSpendPolicyError)) throw err;
|
|
@@ -60691,6 +60711,13 @@ var init_spend_control = __esm({
|
|
|
60691
60711
|
console.error(`[ClawRouter] ${err.message}`);
|
|
60692
60712
|
return;
|
|
60693
60713
|
}
|
|
60714
|
+
if (!this.initialHistoryLoaded) {
|
|
60715
|
+
if (data) {
|
|
60716
|
+
this.history = data.history;
|
|
60717
|
+
this.cleanup();
|
|
60718
|
+
}
|
|
60719
|
+
this.initialHistoryLoaded = true;
|
|
60720
|
+
}
|
|
60694
60721
|
this.policyFileBroken = void 0;
|
|
60695
60722
|
this.limits = data ? cloneLimits(data.limits) : {};
|
|
60696
60723
|
this.diskLimits = cloneLimits(this.limits);
|
|
@@ -60784,6 +60811,9 @@ var init_spend_control = __esm({
|
|
|
60784
60811
|
};
|
|
60785
60812
|
}
|
|
60786
60813
|
const now2 = this.now();
|
|
60814
|
+
if (this.limits.hourly !== void 0 || this.limits.daily !== void 0) {
|
|
60815
|
+
this.syncHistory();
|
|
60816
|
+
}
|
|
60787
60817
|
if (this.limits.perRequest !== void 0) {
|
|
60788
60818
|
if (estimatedCost3 > this.limits.perRequest) {
|
|
60789
60819
|
return {
|
|
@@ -60846,7 +60876,8 @@ var init_spend_control = __esm({
|
|
|
60846
60876
|
timestamp: this.now(),
|
|
60847
60877
|
amount,
|
|
60848
60878
|
model: metadata?.model,
|
|
60849
|
-
action: metadata?.action
|
|
60879
|
+
action: metadata?.action,
|
|
60880
|
+
id: randomUUID()
|
|
60850
60881
|
};
|
|
60851
60882
|
this.history.push(record2);
|
|
60852
60883
|
this.sessionSpent += amount;
|
|
@@ -60977,6 +61008,32 @@ var init_spend_control = __esm({
|
|
|
60977
61008
|
this.sessionSpent = 0;
|
|
60978
61009
|
this.sessionCalls = 0;
|
|
60979
61010
|
}
|
|
61011
|
+
/**
|
|
61012
|
+
* Fold in spend that other processes recorded to the same spending.json.
|
|
61013
|
+
*
|
|
61014
|
+
* The hourly and daily windows are per wallet, not per process, but each
|
|
61015
|
+
* process used to read the file once at startup and then trust its own copy:
|
|
61016
|
+
* N proxies started on one wallet each let the full window through, and the
|
|
61017
|
+
* last writer's history replaced the others' on disk (GHSA-9xv2-9567-rxrw).
|
|
61018
|
+
* Re-reading before every amount check and every write closes that for
|
|
61019
|
+
* anything not signed in the same instant. Two processes checking within
|
|
61020
|
+
* one signing round trip of each other can still both pass; reservations
|
|
61021
|
+
* are per process by design (see reserve()).
|
|
61022
|
+
*
|
|
61023
|
+
* A read failure keeps the ledger this instance already has: a file we
|
|
61024
|
+
* cannot read is no reason to forget spend we know about.
|
|
61025
|
+
*/
|
|
61026
|
+
syncHistory() {
|
|
61027
|
+
let data;
|
|
61028
|
+
try {
|
|
61029
|
+
data = this.storage.load();
|
|
61030
|
+
} catch {
|
|
61031
|
+
return;
|
|
61032
|
+
}
|
|
61033
|
+
if (!data || data.history.length === 0) return;
|
|
61034
|
+
this.history = mergeSpendHistory(this.history, data.history);
|
|
61035
|
+
this.cleanup();
|
|
61036
|
+
}
|
|
60980
61037
|
cleanup() {
|
|
60981
61038
|
const cutoff = this.now() - DAY_MS;
|
|
60982
61039
|
this.history = this.history.filter((r2) => r2.timestamp >= cutoff);
|
|
@@ -60986,6 +61043,7 @@ var init_spend_control = __esm({
|
|
|
60986
61043
|
return;
|
|
60987
61044
|
}
|
|
60988
61045
|
if (!this.limitsDirty && this.storage.saveHistory) {
|
|
61046
|
+
this.syncHistory();
|
|
60989
61047
|
this.storage.saveHistory([...this.history]);
|
|
60990
61048
|
return;
|
|
60991
61049
|
}
|
|
@@ -61018,19 +61076,15 @@ var init_spend_control = __esm({
|
|
|
61018
61076
|
try {
|
|
61019
61077
|
data = this.storage.load();
|
|
61020
61078
|
} catch (err) {
|
|
61021
|
-
if (err instanceof UnreadableSpendPolicyError) {
|
|
61079
|
+
if (err instanceof UnreadableSpendPolicyError || err instanceof MalformedSpendPolicyError) {
|
|
61080
|
+
this.policyFileBroken = err.message;
|
|
61081
|
+
console.error(`[ClawRouter] ${err.message}`);
|
|
61022
61082
|
console.error(
|
|
61023
|
-
|
|
61083
|
+
"[ClawRouter] All paid requests will be refused until spending.json is repaired. Free models are unaffected."
|
|
61024
61084
|
);
|
|
61025
61085
|
return;
|
|
61026
61086
|
}
|
|
61027
|
-
|
|
61028
|
-
this.policyFileBroken = err.message;
|
|
61029
|
-
console.error(`[ClawRouter] ${err.message}`);
|
|
61030
|
-
console.error(
|
|
61031
|
-
"[ClawRouter] All paid requests will be refused until spending.json is repaired. Free models are unaffected."
|
|
61032
|
-
);
|
|
61033
|
-
return;
|
|
61087
|
+
throw err;
|
|
61034
61088
|
}
|
|
61035
61089
|
if (data) {
|
|
61036
61090
|
this.limits = cloneLimits(data.limits);
|
|
@@ -61038,6 +61092,7 @@ var init_spend_control = __esm({
|
|
|
61038
61092
|
this.history = data.history;
|
|
61039
61093
|
this.cleanup();
|
|
61040
61094
|
}
|
|
61095
|
+
this.initialHistoryLoaded = true;
|
|
61041
61096
|
}
|
|
61042
61097
|
};
|
|
61043
61098
|
sharedControlHost = () => process;
|
|
@@ -61400,7 +61455,7 @@ var init_chunk_EKCH75YB = __esm({
|
|
|
61400
61455
|
}
|
|
61401
61456
|
});
|
|
61402
61457
|
|
|
61403
|
-
// node_modules/@x402/evm/dist/esm/chunk-
|
|
61458
|
+
// node_modules/@x402/evm/dist/esm/chunk-5AIYL4HT.mjs
|
|
61404
61459
|
function getEvmChainIdV1(network) {
|
|
61405
61460
|
const chainId = EVM_NETWORK_CHAIN_ID_MAP[network];
|
|
61406
61461
|
if (!chainId) {
|
|
@@ -61409,8 +61464,8 @@ function getEvmChainIdV1(network) {
|
|
|
61409
61464
|
return chainId;
|
|
61410
61465
|
}
|
|
61411
61466
|
var EVM_NETWORK_CHAIN_ID_MAP, NETWORKS, authorizationTypes, permit2WitnessTypes, eip2612PermitTypes, eip2612NoncesAbi, erc20ApproveAbi, erc20AllowanceAbi, ERC20_APPROVE_GAS_LIMIT, DEFAULT_MAX_FEE_PER_GAS, DEFAULT_MAX_PRIORITY_FEE_PER_GAS, PERMIT2_ADDRESS, x402ExactPermit2ProxyAddress;
|
|
61412
|
-
var
|
|
61413
|
-
"node_modules/@x402/evm/dist/esm/chunk-
|
|
61467
|
+
var init_chunk_5AIYL4HT = __esm({
|
|
61468
|
+
"node_modules/@x402/evm/dist/esm/chunk-5AIYL4HT.mjs"() {
|
|
61414
61469
|
"use strict";
|
|
61415
61470
|
EVM_NETWORK_CHAIN_ID_MAP = {
|
|
61416
61471
|
ethereum: 1,
|
|
@@ -61436,7 +61491,9 @@ var init_chunk_GPMYUGHX = __esm({
|
|
|
61436
61491
|
stable: 988,
|
|
61437
61492
|
"stable-testnet": 2201,
|
|
61438
61493
|
celo: 42220,
|
|
61439
|
-
flare: 14
|
|
61494
|
+
flare: 14,
|
|
61495
|
+
hemi: 43111,
|
|
61496
|
+
"hemi-testnet": 743111
|
|
61440
61497
|
};
|
|
61441
61498
|
NETWORKS = Object.keys(EVM_NETWORK_CHAIN_ID_MAP);
|
|
61442
61499
|
authorizationTypes = {
|
|
@@ -61516,7 +61573,7 @@ var init_chunk_GPMYUGHX = __esm({
|
|
|
61516
61573
|
}
|
|
61517
61574
|
});
|
|
61518
61575
|
|
|
61519
|
-
// node_modules/@x402/evm/dist/esm/chunk-
|
|
61576
|
+
// node_modules/@x402/evm/dist/esm/chunk-AB46Q4WU.mjs
|
|
61520
61577
|
async function signEip2612Permit(signer, tokenAddress, tokenName, tokenVersion, chainId, deadline, permittedAmount) {
|
|
61521
61578
|
const owner = signer.address;
|
|
61522
61579
|
const spender = getAddress(PERMIT2_ADDRESS);
|
|
@@ -61747,11 +61804,11 @@ async function trySignErc20ApprovalExtension(signer, options, requirements, cont
|
|
|
61747
61804
|
};
|
|
61748
61805
|
}
|
|
61749
61806
|
var EIP2612_GAS_SPONSORING_KEY, ERC20_APPROVAL_GAS_SPONSORING_KEY, ERC20_APPROVAL_GAS_SPONSORING_VERSION, rpcClientCache, warnedNetworks;
|
|
61750
|
-
var
|
|
61751
|
-
"node_modules/@x402/evm/dist/esm/chunk-
|
|
61807
|
+
var init_chunk_AB46Q4WU = __esm({
|
|
61808
|
+
"node_modules/@x402/evm/dist/esm/chunk-AB46Q4WU.mjs"() {
|
|
61752
61809
|
"use strict";
|
|
61753
61810
|
init_chunk_EKCH75YB();
|
|
61754
|
-
|
|
61811
|
+
init_chunk_5AIYL4HT();
|
|
61755
61812
|
init_esm3();
|
|
61756
61813
|
init_esm3();
|
|
61757
61814
|
init_esm3();
|
|
@@ -61764,7 +61821,7 @@ var init_chunk_DIAR36YQ = __esm({
|
|
|
61764
61821
|
}
|
|
61765
61822
|
});
|
|
61766
61823
|
|
|
61767
|
-
// node_modules/@x402/evm/dist/esm/chunk-
|
|
61824
|
+
// node_modules/@x402/evm/dist/esm/chunk-6XWQF37J.mjs
|
|
61768
61825
|
function resolveNetworkKey(network) {
|
|
61769
61826
|
if (network in DEFAULT_ASSETS) {
|
|
61770
61827
|
return network;
|
|
@@ -61776,10 +61833,10 @@ function resolveNetworkKey(network) {
|
|
|
61776
61833
|
return network;
|
|
61777
61834
|
}
|
|
61778
61835
|
var DEFAULT_ASSETS, findDefaultAsset;
|
|
61779
|
-
var
|
|
61780
|
-
"node_modules/@x402/evm/dist/esm/chunk-
|
|
61836
|
+
var init_chunk_6XWQF37J = __esm({
|
|
61837
|
+
"node_modules/@x402/evm/dist/esm/chunk-6XWQF37J.mjs"() {
|
|
61781
61838
|
"use strict";
|
|
61782
|
-
|
|
61839
|
+
init_chunk_5AIYL4HT();
|
|
61783
61840
|
DEFAULT_ASSETS = {
|
|
61784
61841
|
"eip155:8453": [
|
|
61785
61842
|
{
|
|
@@ -62094,8 +62151,39 @@ var init_chunk_LQQ3M4DU = __esm({
|
|
|
62094
62151
|
decimals: 6,
|
|
62095
62152
|
symbol: "USDC"
|
|
62096
62153
|
}
|
|
62097
|
-
]
|
|
62154
|
+
],
|
|
62098
62155
|
// Arc Testnet USDC (EIP-3009 supported)
|
|
62156
|
+
"eip155:4663": [
|
|
62157
|
+
{
|
|
62158
|
+
asset: "0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",
|
|
62159
|
+
name: "Global Dollar",
|
|
62160
|
+
version: "1",
|
|
62161
|
+
decimals: 6,
|
|
62162
|
+
symbol: "USDG"
|
|
62163
|
+
}
|
|
62164
|
+
],
|
|
62165
|
+
// Robinhood Chain mainnet USDG (EIP-3009 supported)
|
|
62166
|
+
"eip155:43111": [
|
|
62167
|
+
{
|
|
62168
|
+
asset: "0xad11a8BEb98bbf61dbb1aa0F6d6F2ECD87b35afA",
|
|
62169
|
+
name: "Bridged USDC (Stargate)",
|
|
62170
|
+
version: "2",
|
|
62171
|
+
decimals: 6,
|
|
62172
|
+
symbol: "USDC.e"
|
|
62173
|
+
}
|
|
62174
|
+
],
|
|
62175
|
+
// Hemi mainnet USDC.e (EIP-3009 supported)
|
|
62176
|
+
"eip155:743111": [
|
|
62177
|
+
{
|
|
62178
|
+
asset: "0xD47971C7F5B1067d25cd45d30b2c9eb60de96443",
|
|
62179
|
+
name: "USDC.e",
|
|
62180
|
+
version: "1",
|
|
62181
|
+
decimals: 6,
|
|
62182
|
+
symbol: "USDC.e",
|
|
62183
|
+
assetTransferMethod: "permit2"
|
|
62184
|
+
}
|
|
62185
|
+
]
|
|
62186
|
+
// Hemi testnet USDC.e (no EIP-3009, no EIP-2612)
|
|
62099
62187
|
};
|
|
62100
62188
|
findDefaultAsset = (asset, network) => {
|
|
62101
62189
|
const key3 = resolveNetworkKey(network);
|
|
@@ -62109,19 +62197,19 @@ var init_chunk_LQQ3M4DU = __esm({
|
|
|
62109
62197
|
}
|
|
62110
62198
|
});
|
|
62111
62199
|
|
|
62112
|
-
// node_modules/@x402/evm/dist/esm/chunk-
|
|
62200
|
+
// node_modules/@x402/evm/dist/esm/chunk-X42JDBHW.mjs
|
|
62113
62201
|
var ExactEvmSchemeV1;
|
|
62114
|
-
var
|
|
62115
|
-
"node_modules/@x402/evm/dist/esm/chunk-
|
|
62202
|
+
var init_chunk_X42JDBHW = __esm({
|
|
62203
|
+
"node_modules/@x402/evm/dist/esm/chunk-X42JDBHW.mjs"() {
|
|
62116
62204
|
"use strict";
|
|
62117
62205
|
init_chunk_EL2GVDVK();
|
|
62118
62206
|
init_chunk_5JE2UIZP();
|
|
62119
62207
|
init_chunk_VS3RYAYE();
|
|
62120
62208
|
init_chunk_23QU4APL();
|
|
62121
|
-
|
|
62209
|
+
init_chunk_AB46Q4WU();
|
|
62122
62210
|
init_chunk_EKCH75YB();
|
|
62123
|
-
|
|
62124
|
-
|
|
62211
|
+
init_chunk_6XWQF37J();
|
|
62212
|
+
init_chunk_5AIYL4HT();
|
|
62125
62213
|
init_esm3();
|
|
62126
62214
|
ExactEvmSchemeV1 = class {
|
|
62127
62215
|
/**
|
|
@@ -62206,7 +62294,7 @@ var init_chunk_7TZ3NXXP = __esm({
|
|
|
62206
62294
|
}
|
|
62207
62295
|
});
|
|
62208
62296
|
|
|
62209
|
-
// node_modules/@x402/evm/dist/esm/chunk-
|
|
62297
|
+
// node_modules/@x402/evm/dist/esm/chunk-QKR4OFMY.mjs
|
|
62210
62298
|
async function createPermit2PayloadForProxy(proxyAddress, signer, x402Version2, paymentRequirements) {
|
|
62211
62299
|
const now2 = Math.floor(Date.now() / 1e3);
|
|
62212
62300
|
const nonce = createPermit2Nonce();
|
|
@@ -62257,19 +62345,19 @@ async function signPermit2Authorization(signer, permit2Authorization, requiremen
|
|
|
62257
62345
|
}
|
|
62258
62346
|
});
|
|
62259
62347
|
}
|
|
62260
|
-
var
|
|
62261
|
-
"node_modules/@x402/evm/dist/esm/chunk-
|
|
62348
|
+
var init_chunk_QKR4OFMY = __esm({
|
|
62349
|
+
"node_modules/@x402/evm/dist/esm/chunk-QKR4OFMY.mjs"() {
|
|
62262
62350
|
"use strict";
|
|
62263
62351
|
init_chunk_VS3RYAYE();
|
|
62264
62352
|
init_chunk_23QU4APL();
|
|
62265
|
-
|
|
62353
|
+
init_chunk_AB46Q4WU();
|
|
62266
62354
|
init_chunk_EKCH75YB();
|
|
62267
|
-
|
|
62355
|
+
init_chunk_5AIYL4HT();
|
|
62268
62356
|
init_esm3();
|
|
62269
62357
|
}
|
|
62270
62358
|
});
|
|
62271
62359
|
|
|
62272
|
-
// node_modules/@x402/evm/dist/esm/chunk-
|
|
62360
|
+
// node_modules/@x402/evm/dist/esm/chunk-H3CLVT6Z.mjs
|
|
62273
62361
|
async function createPermit2Payload(signer, x402Version2, paymentRequirements) {
|
|
62274
62362
|
return createPermit2PayloadForProxy(
|
|
62275
62363
|
x402ExactPermit2ProxyAddress,
|
|
@@ -62279,11 +62367,11 @@ async function createPermit2Payload(signer, x402Version2, paymentRequirements) {
|
|
|
62279
62367
|
);
|
|
62280
62368
|
}
|
|
62281
62369
|
var MAX_UINT256;
|
|
62282
|
-
var
|
|
62283
|
-
"node_modules/@x402/evm/dist/esm/chunk-
|
|
62370
|
+
var init_chunk_H3CLVT6Z = __esm({
|
|
62371
|
+
"node_modules/@x402/evm/dist/esm/chunk-H3CLVT6Z.mjs"() {
|
|
62284
62372
|
"use strict";
|
|
62285
|
-
|
|
62286
|
-
|
|
62373
|
+
init_chunk_QKR4OFMY();
|
|
62374
|
+
init_chunk_5AIYL4HT();
|
|
62287
62375
|
MAX_UINT256 = BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
|
62288
62376
|
}
|
|
62289
62377
|
});
|
|
@@ -62296,7 +62384,7 @@ var init_utils10 = __esm({
|
|
|
62296
62384
|
}
|
|
62297
62385
|
});
|
|
62298
62386
|
|
|
62299
|
-
// node_modules/@x402/evm/dist/esm/chunk-
|
|
62387
|
+
// node_modules/@x402/evm/dist/esm/chunk-374U7QOG.mjs
|
|
62300
62388
|
async function createEIP3009Payload(signer, x402Version2, paymentRequirements) {
|
|
62301
62389
|
const nonce = createNonce();
|
|
62302
62390
|
const now2 = Math.floor(Date.now() / 1e3);
|
|
@@ -62372,15 +62460,15 @@ function registerExactEvmScheme(client, config2) {
|
|
|
62372
62460
|
return client;
|
|
62373
62461
|
}
|
|
62374
62462
|
var ExactEvmScheme;
|
|
62375
|
-
var
|
|
62376
|
-
"node_modules/@x402/evm/dist/esm/chunk-
|
|
62463
|
+
var init_chunk_374U7QOG = __esm({
|
|
62464
|
+
"node_modules/@x402/evm/dist/esm/chunk-374U7QOG.mjs"() {
|
|
62377
62465
|
"use strict";
|
|
62378
|
-
|
|
62379
|
-
|
|
62380
|
-
|
|
62466
|
+
init_chunk_X42JDBHW();
|
|
62467
|
+
init_chunk_H3CLVT6Z();
|
|
62468
|
+
init_chunk_AB46Q4WU();
|
|
62381
62469
|
init_chunk_EKCH75YB();
|
|
62382
|
-
|
|
62383
|
-
|
|
62470
|
+
init_chunk_6XWQF37J();
|
|
62471
|
+
init_chunk_5AIYL4HT();
|
|
62384
62472
|
init_esm3();
|
|
62385
62473
|
init_utils10();
|
|
62386
62474
|
ExactEvmScheme = class {
|
|
@@ -62460,29 +62548,29 @@ var init_chunk_DBYTBFOQ = __esm({
|
|
|
62460
62548
|
var init_client2 = __esm({
|
|
62461
62549
|
"node_modules/@x402/evm/dist/esm/exact/client/index.mjs"() {
|
|
62462
62550
|
"use strict";
|
|
62463
|
-
|
|
62464
|
-
|
|
62551
|
+
init_chunk_374U7QOG();
|
|
62552
|
+
init_chunk_X42JDBHW();
|
|
62465
62553
|
init_chunk_EL2GVDVK();
|
|
62466
62554
|
init_chunk_5JE2UIZP();
|
|
62467
62555
|
init_chunk_DBYTBFOQ();
|
|
62468
|
-
|
|
62469
|
-
|
|
62556
|
+
init_chunk_H3CLVT6Z();
|
|
62557
|
+
init_chunk_QKR4OFMY();
|
|
62470
62558
|
init_chunk_VS3RYAYE();
|
|
62471
62559
|
init_chunk_23QU4APL();
|
|
62472
|
-
|
|
62560
|
+
init_chunk_AB46Q4WU();
|
|
62473
62561
|
init_chunk_EKCH75YB();
|
|
62474
|
-
|
|
62475
|
-
|
|
62562
|
+
init_chunk_6XWQF37J();
|
|
62563
|
+
init_chunk_5AIYL4HT();
|
|
62476
62564
|
}
|
|
62477
62565
|
});
|
|
62478
62566
|
|
|
62479
|
-
// node_modules/@x402/evm/dist/esm/chunk-
|
|
62567
|
+
// node_modules/@x402/evm/dist/esm/chunk-BBPWOJXX.mjs
|
|
62480
62568
|
var SALT_BINDING_TYPEHASH, PAYMENT_INFO_TYPEHASH;
|
|
62481
|
-
var
|
|
62482
|
-
"node_modules/@x402/evm/dist/esm/chunk-
|
|
62569
|
+
var init_chunk_BBPWOJXX = __esm({
|
|
62570
|
+
"node_modules/@x402/evm/dist/esm/chunk-BBPWOJXX.mjs"() {
|
|
62483
62571
|
"use strict";
|
|
62484
62572
|
init_chunk_5JE2UIZP();
|
|
62485
|
-
|
|
62573
|
+
init_chunk_5AIYL4HT();
|
|
62486
62574
|
init_esm3();
|
|
62487
62575
|
init_esm3();
|
|
62488
62576
|
SALT_BINDING_TYPEHASH = keccak256(
|
|
@@ -62498,13 +62586,13 @@ var init_chunk_F43KMW3I = __esm({
|
|
|
62498
62586
|
}
|
|
62499
62587
|
});
|
|
62500
62588
|
|
|
62501
|
-
// node_modules/@x402/evm/dist/esm/chunk-
|
|
62502
|
-
var
|
|
62503
|
-
"node_modules/@x402/evm/dist/esm/chunk-
|
|
62589
|
+
// node_modules/@x402/evm/dist/esm/chunk-QCE52OSD.mjs
|
|
62590
|
+
var init_chunk_QCE52OSD = __esm({
|
|
62591
|
+
"node_modules/@x402/evm/dist/esm/chunk-QCE52OSD.mjs"() {
|
|
62504
62592
|
"use strict";
|
|
62505
|
-
|
|
62593
|
+
init_chunk_BBPWOJXX();
|
|
62506
62594
|
init_chunk_EKCH75YB();
|
|
62507
|
-
|
|
62595
|
+
init_chunk_6XWQF37J();
|
|
62508
62596
|
}
|
|
62509
62597
|
});
|
|
62510
62598
|
|
|
@@ -62529,10 +62617,10 @@ var init_chunk_BOZHBVFZ = __esm({
|
|
|
62529
62617
|
}
|
|
62530
62618
|
});
|
|
62531
62619
|
|
|
62532
|
-
// node_modules/@x402/evm/dist/esm/chunk-
|
|
62620
|
+
// node_modules/@x402/evm/dist/esm/chunk-7DJ4WEQ5.mjs
|
|
62533
62621
|
var CHANNEL_CONFIG_TYPEHASH, UINT96_MASK;
|
|
62534
|
-
var
|
|
62535
|
-
"node_modules/@x402/evm/dist/esm/chunk-
|
|
62622
|
+
var init_chunk_7DJ4WEQ5 = __esm({
|
|
62623
|
+
"node_modules/@x402/evm/dist/esm/chunk-7DJ4WEQ5.mjs"() {
|
|
62536
62624
|
"use strict";
|
|
62537
62625
|
init_chunk_EKCH75YB();
|
|
62538
62626
|
init_esm3();
|
|
@@ -62545,30 +62633,30 @@ var init_chunk_X3UZRZQA = __esm({
|
|
|
62545
62633
|
}
|
|
62546
62634
|
});
|
|
62547
62635
|
|
|
62548
|
-
// node_modules/@x402/evm/dist/esm/chunk-
|
|
62549
|
-
var
|
|
62550
|
-
"node_modules/@x402/evm/dist/esm/chunk-
|
|
62636
|
+
// node_modules/@x402/evm/dist/esm/chunk-AEYKXGQA.mjs
|
|
62637
|
+
var init_chunk_AEYKXGQA = __esm({
|
|
62638
|
+
"node_modules/@x402/evm/dist/esm/chunk-AEYKXGQA.mjs"() {
|
|
62551
62639
|
"use strict";
|
|
62552
62640
|
init_chunk_W6ON4LG2();
|
|
62553
62641
|
init_chunk_BOZHBVFZ();
|
|
62554
|
-
|
|
62642
|
+
init_chunk_7DJ4WEQ5();
|
|
62555
62643
|
init_chunk_DBYTBFOQ();
|
|
62556
|
-
|
|
62644
|
+
init_chunk_AB46Q4WU();
|
|
62557
62645
|
init_chunk_EKCH75YB();
|
|
62558
|
-
|
|
62559
|
-
|
|
62646
|
+
init_chunk_6XWQF37J();
|
|
62647
|
+
init_chunk_5AIYL4HT();
|
|
62560
62648
|
init_http4();
|
|
62561
62649
|
init_http4();
|
|
62562
62650
|
init_client();
|
|
62563
62651
|
}
|
|
62564
62652
|
});
|
|
62565
62653
|
|
|
62566
|
-
// node_modules/@x402/evm/dist/esm/chunk-
|
|
62567
|
-
var
|
|
62568
|
-
"node_modules/@x402/evm/dist/esm/chunk-
|
|
62654
|
+
// node_modules/@x402/evm/dist/esm/chunk-SPPQBP6P.mjs
|
|
62655
|
+
var init_chunk_SPPQBP6P = __esm({
|
|
62656
|
+
"node_modules/@x402/evm/dist/esm/chunk-SPPQBP6P.mjs"() {
|
|
62569
62657
|
"use strict";
|
|
62570
62658
|
init_chunk_BOZHBVFZ();
|
|
62571
|
-
|
|
62659
|
+
init_chunk_7DJ4WEQ5();
|
|
62572
62660
|
}
|
|
62573
62661
|
});
|
|
62574
62662
|
|
|
@@ -62582,14 +62670,14 @@ var init_chunk_VGMBXJLA = __esm({
|
|
|
62582
62670
|
}
|
|
62583
62671
|
});
|
|
62584
62672
|
|
|
62585
|
-
// node_modules/@x402/evm/dist/esm/chunk-
|
|
62586
|
-
var
|
|
62587
|
-
"node_modules/@x402/evm/dist/esm/chunk-
|
|
62673
|
+
// node_modules/@x402/evm/dist/esm/chunk-3EVS7UJG.mjs
|
|
62674
|
+
var init_chunk_3EVS7UJG = __esm({
|
|
62675
|
+
"node_modules/@x402/evm/dist/esm/chunk-3EVS7UJG.mjs"() {
|
|
62588
62676
|
"use strict";
|
|
62589
|
-
|
|
62677
|
+
init_chunk_AB46Q4WU();
|
|
62590
62678
|
init_chunk_EKCH75YB();
|
|
62591
|
-
|
|
62592
|
-
|
|
62679
|
+
init_chunk_6XWQF37J();
|
|
62680
|
+
init_chunk_5AIYL4HT();
|
|
62593
62681
|
}
|
|
62594
62682
|
});
|
|
62595
62683
|
|
|
@@ -62620,29 +62708,29 @@ function toClientEvmSigner(signer, publicClient) {
|
|
|
62620
62708
|
var init_esm5 = __esm({
|
|
62621
62709
|
"node_modules/@x402/evm/dist/esm/index.mjs"() {
|
|
62622
62710
|
"use strict";
|
|
62623
|
-
|
|
62711
|
+
init_chunk_QCE52OSD();
|
|
62624
62712
|
init_chunk_XE4FB4AB();
|
|
62625
|
-
|
|
62626
|
-
|
|
62713
|
+
init_chunk_BBPWOJXX();
|
|
62714
|
+
init_chunk_AEYKXGQA();
|
|
62627
62715
|
init_chunk_W6ON4LG2();
|
|
62628
|
-
|
|
62716
|
+
init_chunk_SPPQBP6P();
|
|
62629
62717
|
init_chunk_BOZHBVFZ();
|
|
62630
|
-
|
|
62631
|
-
|
|
62718
|
+
init_chunk_7DJ4WEQ5();
|
|
62719
|
+
init_chunk_374U7QOG();
|
|
62632
62720
|
init_chunk_VGMBXJLA();
|
|
62633
|
-
|
|
62721
|
+
init_chunk_X42JDBHW();
|
|
62634
62722
|
init_chunk_EL2GVDVK();
|
|
62635
62723
|
init_chunk_5JE2UIZP();
|
|
62636
62724
|
init_chunk_DBYTBFOQ();
|
|
62637
|
-
|
|
62638
|
-
|
|
62639
|
-
|
|
62725
|
+
init_chunk_3EVS7UJG();
|
|
62726
|
+
init_chunk_H3CLVT6Z();
|
|
62727
|
+
init_chunk_QKR4OFMY();
|
|
62640
62728
|
init_chunk_VS3RYAYE();
|
|
62641
62729
|
init_chunk_23QU4APL();
|
|
62642
|
-
|
|
62730
|
+
init_chunk_AB46Q4WU();
|
|
62643
62731
|
init_chunk_EKCH75YB();
|
|
62644
|
-
|
|
62645
|
-
|
|
62732
|
+
init_chunk_6XWQF37J();
|
|
62733
|
+
init_chunk_5AIYL4HT();
|
|
62646
62734
|
}
|
|
62647
62735
|
});
|
|
62648
62736
|
|
|
@@ -90470,6 +90558,8 @@ var init_session_spend = __esm({
|
|
|
90470
90558
|
signedMicros = 0n;
|
|
90471
90559
|
/** Each signature this request made, in order, at the amount that still counts. */
|
|
90472
90560
|
signedLog = [];
|
|
90561
|
+
/** API-key rail: the latest dispatch's charge was reported by the gateway and recorded. */
|
|
90562
|
+
lastDispatchCharged = false;
|
|
90473
90563
|
released = false;
|
|
90474
90564
|
/**
|
|
90475
90565
|
* Strict mode: admit the request only if the session's spend, plus what its
|
|
@@ -90559,13 +90649,32 @@ var init_session_spend = __esm({
|
|
|
90559
90649
|
this.signedMicros += delta;
|
|
90560
90650
|
this.store.addSessionCost(this.sessionId, delta);
|
|
90561
90651
|
}
|
|
90652
|
+
/**
|
|
90653
|
+
* API-key rail: a dispatch is about to go out. Its charge, if the gateway
|
|
90654
|
+
* reports one, belongs to it alone — an earlier attempt's reported charge
|
|
90655
|
+
* must not stand in for this one's estimate.
|
|
90656
|
+
*/
|
|
90657
|
+
beginDispatch() {
|
|
90658
|
+
this.lastDispatchCharged = false;
|
|
90659
|
+
}
|
|
90660
|
+
/**
|
|
90661
|
+
* API-key rail: the gateway reported what it charged for the latest
|
|
90662
|
+
* dispatch (`x-blockrun-cost-usd`), on whatever status. It is spend now.
|
|
90663
|
+
*/
|
|
90664
|
+
recordCharged(chargedMicros) {
|
|
90665
|
+
this.lastDispatchCharged = true;
|
|
90666
|
+
if (chargedMicros <= 0n) return;
|
|
90667
|
+
this.store.addSessionCost(this.sessionId, chargedMicros);
|
|
90668
|
+
this.shrinkHold(chargedMicros);
|
|
90669
|
+
}
|
|
90562
90670
|
/**
|
|
90563
90671
|
* An attempt succeeded. When nothing was signed for this request (the API
|
|
90564
|
-
* key rail), the local estimate is the only record of the spend
|
|
90565
|
-
*
|
|
90672
|
+
* key rail), the local estimate is the only record of the spend — unless the
|
|
90673
|
+
* gateway reported the winning dispatch's charge, which is already recorded.
|
|
90674
|
+
* When a payment was signed, it is already recorded at its real amount.
|
|
90566
90675
|
*/
|
|
90567
90676
|
recordSuccess(estimateMicros) {
|
|
90568
|
-
if (this.signedLog.length > 0 || estimateMicros <= 0n) return;
|
|
90677
|
+
if (this.signedLog.length > 0 || this.lastDispatchCharged || estimateMicros <= 0n) return;
|
|
90569
90678
|
this.store.addSessionCost(this.sessionId, estimateMicros);
|
|
90570
90679
|
this.shrinkHold(estimateMicros);
|
|
90571
90680
|
}
|
|
@@ -90958,12 +91067,28 @@ var init_paths = __esm({
|
|
|
90958
91067
|
|
|
90959
91068
|
// src/compression/layers/json-compact.ts
|
|
90960
91069
|
function compactJson(jsonString) {
|
|
91070
|
+
if (typeof jsonString !== "string") return jsonString;
|
|
90961
91071
|
try {
|
|
90962
|
-
|
|
90963
|
-
return JSON.stringify(parsed);
|
|
91072
|
+
JSON.parse(jsonString);
|
|
90964
91073
|
} catch {
|
|
90965
91074
|
return jsonString;
|
|
90966
91075
|
}
|
|
91076
|
+
let out = "";
|
|
91077
|
+
let start = 0;
|
|
91078
|
+
let inString = false;
|
|
91079
|
+
for (let i = 0; i < jsonString.length; i++) {
|
|
91080
|
+
const ch = jsonString[i];
|
|
91081
|
+
if (inString) {
|
|
91082
|
+
if (ch === "\\") i++;
|
|
91083
|
+
else if (ch === '"') inString = false;
|
|
91084
|
+
} else if (ch === '"') {
|
|
91085
|
+
inString = true;
|
|
91086
|
+
} else if (ch === " " || ch === " " || ch === "\n" || ch === "\r") {
|
|
91087
|
+
out += jsonString.slice(start, i);
|
|
91088
|
+
start = i + 1;
|
|
91089
|
+
}
|
|
91090
|
+
}
|
|
91091
|
+
return out + jsonString.slice(start);
|
|
90967
91092
|
}
|
|
90968
91093
|
function looksLikeJson(str) {
|
|
90969
91094
|
const trimmed = str.trim();
|
|
@@ -104663,7 +104788,7 @@ var init_src3 = __esm({
|
|
|
104663
104788
|
}
|
|
104664
104789
|
});
|
|
104665
104790
|
|
|
104666
|
-
// node_modules/@x402/svm/dist/esm/chunk-
|
|
104791
|
+
// node_modules/@x402/svm/dist/esm/chunk-DAIKIZVB.mjs
|
|
104667
104792
|
function normalizeNetwork(network) {
|
|
104668
104793
|
if (network.includes(":")) {
|
|
104669
104794
|
const supported = [SOLANA_MAINNET_CAIP2, SOLANA_DEVNET_CAIP2, SOLANA_TESTNET_CAIP2];
|
|
@@ -104900,8 +105025,8 @@ async function recordPendingOrTerminal(store, key3, signature3, payer, network,
|
|
|
104900
105025
|
};
|
|
104901
105026
|
}
|
|
104902
105027
|
var TOKEN_PROGRAM_ADDRESS3, TOKEN_2022_PROGRAM_ADDRESS2, COMPUTE_BUDGET_PROGRAM_ADDRESS2, MEMO_PROGRAM_ADDRESS, LIGHTHOUSE_PROGRAM_ADDRESS, DEVNET_RPC_URL, TESTNET_RPC_URL, MAINNET_RPC_URL, DEVNET_WS_URL, TESTNET_WS_URL, MAINNET_WS_URL, DEFAULT_COMPUTE_UNIT_PRICE_MICROLAMPORTS, MAX_COMPUTE_UNIT_PRICE_MICROLAMPORTS, DEFAULT_COMPUTE_UNIT_LIMIT, DEFAULT_MAX_COMPUTE_UNITS, DEFAULT_MAX_REQUIRED_SIGNATURES, MAX_MEMO_BYTES, ACCEPTED_TRANSACTION_VERSIONS, ADVERTISED_TRANSACTION_VERSIONS, CLIENT_SUPPORTED_TRANSACTION_VERSIONS, SETTLEMENT_TTL_MS, SVM_ADDRESS_REGEX, SOLANA_MAINNET_CAIP2, SOLANA_DEVNET_CAIP2, SOLANA_TESTNET_CAIP2, V1_TO_V2_NETWORK_MAP, ErrInvalidPayloadTransaction, ErrUnsupportedTransactionVersion, ErrFeePayerTransferringFunds, ErrMemoMismatch, ErrMemoCount, ErrSmartWalletFeePayerNotIsolated, ErrSmartWalletMalformedComputeBudget, ErrSmartWalletMalformedComputeLimit, ErrSmartWalletMalformedComputePrice, ErrSmartWalletComputeUnitsTooHigh, ErrSmartWalletPriorityFeeTooHigh, ErrSmartWalletUnsupportedComputeBudget, ErrSmartWalletAltResolutionUnavailable, ErrSmartWalletAltResolutionFailed, ErrSmartWalletComputeBudgetViolation, ErrSmartWalletSimulationFailed, ErrSmartWalletCannotDeriveATA, ErrSmartWalletNoTransferInSimulation, ErrSmartWalletTransferMismatch, ErrSmartWalletMultipleMatchingTransfers, USDC_MAINNET_ADDRESS, USDC_DEVNET_ADDRESS, USDC_TESTNET_ADDRESS, DEFAULT_ASSETS2, getDefaultAsset2, findDefaultAsset2, BASIS_POINTS_DENOMINATOR, SLOT_COMMITMENT, TransactionOnchainFailureError;
|
|
104903
|
-
var
|
|
104904
|
-
"node_modules/@x402/svm/dist/esm/chunk-
|
|
105028
|
+
var init_chunk_DAIKIZVB = __esm({
|
|
105029
|
+
"node_modules/@x402/svm/dist/esm/chunk-DAIKIZVB.mjs"() {
|
|
104905
105030
|
"use strict";
|
|
104906
105031
|
init_sha2563();
|
|
104907
105032
|
init_index_node39();
|
|
@@ -105121,7 +105246,7 @@ var init_src4 = __esm({
|
|
|
105121
105246
|
}
|
|
105122
105247
|
});
|
|
105123
105248
|
|
|
105124
|
-
// node_modules/@x402/svm/dist/esm/chunk-
|
|
105249
|
+
// node_modules/@x402/svm/dist/esm/chunk-RZ6M7L3U.mjs
|
|
105125
105250
|
function maxTransactionSize(version31) {
|
|
105126
105251
|
return version31 === 1 ? V1_MAX_TRANSACTION_SIZE : V0_MAX_TRANSACTION_SIZE;
|
|
105127
105252
|
}
|
|
@@ -105219,10 +105344,10 @@ function checkTransactionV1Budget(config2, programAddresses, limits) {
|
|
|
105219
105344
|
return void 0;
|
|
105220
105345
|
}
|
|
105221
105346
|
var V0_MAX_TRANSACTION_SIZE, V1_MAX_TRANSACTION_SIZE, DEFAULT_LOADED_ACCOUNTS_DATA_SIZE_LIMIT;
|
|
105222
|
-
var
|
|
105223
|
-
"node_modules/@x402/svm/dist/esm/chunk-
|
|
105347
|
+
var init_chunk_RZ6M7L3U = __esm({
|
|
105348
|
+
"node_modules/@x402/svm/dist/esm/chunk-RZ6M7L3U.mjs"() {
|
|
105224
105349
|
"use strict";
|
|
105225
|
-
|
|
105350
|
+
init_chunk_DAIKIZVB();
|
|
105226
105351
|
init_index_node39();
|
|
105227
105352
|
init_src4();
|
|
105228
105353
|
V0_MAX_TRANSACTION_SIZE = 1232;
|
|
@@ -105231,7 +105356,7 @@ var init_chunk_A5U3JRDR = __esm({
|
|
|
105231
105356
|
}
|
|
105232
105357
|
});
|
|
105233
105358
|
|
|
105234
|
-
// node_modules/@x402/svm/dist/esm/chunk-
|
|
105359
|
+
// node_modules/@x402/svm/dist/esm/chunk-DP3B4MQJ.mjs
|
|
105235
105360
|
function encodeVoucherMessageBytes(args) {
|
|
105236
105361
|
const channelBytes = getBase58Encoder().encode(args.channelId);
|
|
105237
105362
|
if (channelBytes.byteLength !== 32) {
|
|
@@ -105677,11 +105802,11 @@ function randomU64() {
|
|
|
105677
105802
|
return new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength).getBigUint64(0, true);
|
|
105678
105803
|
}
|
|
105679
105804
|
var VOUCHER_MAGIC, PAYMENT_CHANNELS_PROGRAM_ADDRESS, ASSOCIATED_TOKEN_PROGRAM_ID, PAYMENT_CHANNELS_PROGRAM_ID, MAINNET_TREASURY_OWNER_BYTES, MAINNET_TREASURY_OWNER, DEVNET_TREASURY_OWNER, OPEN_DISCRIMINATOR, TOP_UP_DISCRIMINATOR, U64_MAX2, OPEN_MAX_COMPUTE_UNIT_LIMIT, OPEN_DEFAULT_COMPUTE_UNIT_LIMIT, RENT_SYSVAR, MAX_CHANNEL_PDA_CACHE_ENTRIES, channelPdaCache;
|
|
105680
|
-
var
|
|
105681
|
-
"node_modules/@x402/svm/dist/esm/chunk-
|
|
105805
|
+
var init_chunk_DP3B4MQJ = __esm({
|
|
105806
|
+
"node_modules/@x402/svm/dist/esm/chunk-DP3B4MQJ.mjs"() {
|
|
105682
105807
|
"use strict";
|
|
105683
|
-
|
|
105684
|
-
|
|
105808
|
+
init_chunk_RZ6M7L3U();
|
|
105809
|
+
init_chunk_DAIKIZVB();
|
|
105685
105810
|
init_index_node39();
|
|
105686
105811
|
init_index_node39();
|
|
105687
105812
|
init_index_node39();
|
|
@@ -105746,7 +105871,7 @@ var init_chunk_BU4OMUDH = __esm({
|
|
|
105746
105871
|
}
|
|
105747
105872
|
});
|
|
105748
105873
|
|
|
105749
|
-
// node_modules/@x402/svm/dist/esm/chunk-
|
|
105874
|
+
// node_modules/@x402/svm/dist/esm/chunk-VITMNYMM.mjs
|
|
105750
105875
|
function getRequestCloseInstructionDataEncoder() {
|
|
105751
105876
|
return transformEncoder(getStructEncoder([["discriminator", getU8Encoder()]]), (value) => ({
|
|
105752
105877
|
...value,
|
|
@@ -105819,12 +105944,12 @@ function requestMemo(value) {
|
|
|
105819
105944
|
);
|
|
105820
105945
|
}
|
|
105821
105946
|
var REQUEST_CLOSE_DISCRIMINATOR;
|
|
105822
|
-
var
|
|
105823
|
-
"node_modules/@x402/svm/dist/esm/chunk-
|
|
105947
|
+
var init_chunk_VITMNYMM = __esm({
|
|
105948
|
+
"node_modules/@x402/svm/dist/esm/chunk-VITMNYMM.mjs"() {
|
|
105824
105949
|
"use strict";
|
|
105825
|
-
|
|
105826
|
-
|
|
105827
|
-
|
|
105950
|
+
init_chunk_DP3B4MQJ();
|
|
105951
|
+
init_chunk_RZ6M7L3U();
|
|
105952
|
+
init_chunk_DAIKIZVB();
|
|
105828
105953
|
init_index_node39();
|
|
105829
105954
|
init_index_node39();
|
|
105830
105955
|
init_index_node40();
|
|
@@ -105832,7 +105957,7 @@ var init_chunk_3WM4BBCN = __esm({
|
|
|
105832
105957
|
}
|
|
105833
105958
|
});
|
|
105834
105959
|
|
|
105835
|
-
// node_modules/@x402/svm/dist/esm/chunk-
|
|
105960
|
+
// node_modules/@x402/svm/dist/esm/chunk-NUK2USQ3.mjs
|
|
105836
105961
|
function getChannelDecoder() {
|
|
105837
105962
|
return getStructDecoder([
|
|
105838
105963
|
["discriminator", getU8Decoder()],
|
|
@@ -105854,15 +105979,15 @@ function getChannelDecoder() {
|
|
|
105854
105979
|
["openSlot", getU64Decoder()]
|
|
105855
105980
|
]);
|
|
105856
105981
|
}
|
|
105857
|
-
var
|
|
105858
|
-
"node_modules/@x402/svm/dist/esm/chunk-
|
|
105982
|
+
var init_chunk_NUK2USQ3 = __esm({
|
|
105983
|
+
"node_modules/@x402/svm/dist/esm/chunk-NUK2USQ3.mjs"() {
|
|
105859
105984
|
"use strict";
|
|
105860
|
-
|
|
105985
|
+
init_chunk_DP3B4MQJ();
|
|
105861
105986
|
init_index_node39();
|
|
105862
105987
|
}
|
|
105863
105988
|
});
|
|
105864
105989
|
|
|
105865
|
-
// node_modules/@x402/svm/dist/esm/chunk-
|
|
105990
|
+
// node_modules/@x402/svm/dist/esm/chunk-RMG2KWUT.mjs
|
|
105866
105991
|
function channelAddressFilters(value, offset) {
|
|
105867
105992
|
return [
|
|
105868
105993
|
{ dataSize: CHANNEL_ACCOUNT_SIZE },
|
|
@@ -105933,11 +106058,11 @@ async function validateDiscoveredAccount(pubkey, owner, base64Data, expectedProg
|
|
|
105933
106058
|
return { channelId: pubkey, channel };
|
|
105934
106059
|
}
|
|
105935
106060
|
var CHANNEL_ACCOUNT_SIZE, CHANNEL_RENT_PAYER_OFFSET, CHANNEL_PAYER_OFFSET;
|
|
105936
|
-
var
|
|
105937
|
-
"node_modules/@x402/svm/dist/esm/chunk-
|
|
106061
|
+
var init_chunk_RMG2KWUT = __esm({
|
|
106062
|
+
"node_modules/@x402/svm/dist/esm/chunk-RMG2KWUT.mjs"() {
|
|
105938
106063
|
"use strict";
|
|
105939
|
-
|
|
105940
|
-
|
|
106064
|
+
init_chunk_NUK2USQ3();
|
|
106065
|
+
init_chunk_DP3B4MQJ();
|
|
105941
106066
|
init_index_node39();
|
|
105942
106067
|
CHANNEL_ACCOUNT_SIZE = 256n;
|
|
105943
106068
|
CHANNEL_RENT_PAYER_OFFSET = 216n;
|
|
@@ -105945,7 +106070,7 @@ var init_chunk_PQ3QK4Z4 = __esm({
|
|
|
105945
106070
|
}
|
|
105946
106071
|
});
|
|
105947
106072
|
|
|
105948
|
-
// node_modules/@x402/svm/dist/esm/chunk-
|
|
106073
|
+
// node_modules/@x402/svm/dist/esm/chunk-CJ2GGI22.mjs
|
|
105949
106074
|
function isBatchVoucher(value) {
|
|
105950
106075
|
if (!isRecord(value)) return false;
|
|
105951
106076
|
return typeof value.channelId === "string" && typeof value.maxClaimableAmount === "string" && typeof value.expiresAt === "number" && typeof value.signature === "string";
|
|
@@ -106130,12 +106255,12 @@ function parseReceiverBindingMemo(memo2) {
|
|
|
106130
106255
|
return isAddress2(authorizer) ? authorizer : void 0;
|
|
106131
106256
|
}
|
|
106132
106257
|
var BATCH_SETTLEMENT_SCHEME2, MIN_WITHDRAW_DELAY2, MAX_WITHDRAW_DELAY, FULL_SPLIT_BPS, CLIENT_VOUCHER_EXPIRES_AT, AUTHORIZATION_DOMAIN, CLOSE_DOMAIN, V1_MAX_CLAIM_CHANNELS, V1_MAX_SETTLE_CHANNELS, PREFIX, BatchError, isDecimal, isSafeUint, isOptional, isString, RECEIVER_BINDING_MEMO_PREFIX;
|
|
106133
|
-
var
|
|
106134
|
-
"node_modules/@x402/svm/dist/esm/chunk-
|
|
106258
|
+
var init_chunk_CJ2GGI22 = __esm({
|
|
106259
|
+
"node_modules/@x402/svm/dist/esm/chunk-CJ2GGI22.mjs"() {
|
|
106135
106260
|
"use strict";
|
|
106136
|
-
|
|
106137
|
-
|
|
106138
|
-
|
|
106261
|
+
init_chunk_DP3B4MQJ();
|
|
106262
|
+
init_chunk_RZ6M7L3U();
|
|
106263
|
+
init_chunk_DAIKIZVB();
|
|
106139
106264
|
init_index_node39();
|
|
106140
106265
|
init_index_node39();
|
|
106141
106266
|
BATCH_SETTLEMENT_SCHEME2 = "batch-settlement";
|
|
@@ -106183,7 +106308,7 @@ var init_chunk_GAYY7QRO = __esm({
|
|
|
106183
106308
|
}
|
|
106184
106309
|
});
|
|
106185
106310
|
|
|
106186
|
-
// node_modules/@x402/svm/dist/esm/chunk-
|
|
106311
|
+
// node_modules/@x402/svm/dist/esm/chunk-2RSZYSMO.mjs
|
|
106187
106312
|
function parseTokenProgramHint(extra) {
|
|
106188
106313
|
const hint = extra?.tokenProgram;
|
|
106189
106314
|
if (hint === void 0 || hint === null || hint === "") {
|
|
@@ -106211,14 +106336,14 @@ function requireTokenProgramHint(extra, invalid) {
|
|
|
106211
106336
|
if (hinted === void 0) throw new Error(invalid);
|
|
106212
106337
|
return hinted;
|
|
106213
106338
|
}
|
|
106214
|
-
var
|
|
106215
|
-
"node_modules/@x402/svm/dist/esm/chunk-
|
|
106339
|
+
var init_chunk_2RSZYSMO = __esm({
|
|
106340
|
+
"node_modules/@x402/svm/dist/esm/chunk-2RSZYSMO.mjs"() {
|
|
106216
106341
|
"use strict";
|
|
106217
|
-
|
|
106342
|
+
init_chunk_DAIKIZVB();
|
|
106218
106343
|
}
|
|
106219
106344
|
});
|
|
106220
106345
|
|
|
106221
|
-
// node_modules/@x402/svm/dist/esm/chunk-
|
|
106346
|
+
// node_modules/@x402/svm/dist/esm/chunk-HRH33QP2.mjs
|
|
106222
106347
|
async function checkCorrectiveState(args) {
|
|
106223
106348
|
const state = args.accept.extra?.channelState;
|
|
106224
106349
|
if (!isBatchChannelState(state)) {
|
|
@@ -106659,15 +106784,15 @@ async function buildBatchRefundPayload(args) {
|
|
|
106659
106784
|
});
|
|
106660
106785
|
}
|
|
106661
106786
|
var BatchChannelTracker, NoBatchChannelToRefundError, DEFAULT_SERVER_SIGNED_MAX_DEPOSIT, UntrustedOperatorError, ServerSignedTrustPolicy, DEFAULT_DEPOSIT_MULTIPLIER, MIN_DEPOSIT_MULTIPLIER, OPERATION_KEY_SEPARATOR, BatchSvmScheme;
|
|
106662
|
-
var
|
|
106663
|
-
"node_modules/@x402/svm/dist/esm/chunk-
|
|
106664
|
-
"use strict";
|
|
106665
|
-
|
|
106666
|
-
|
|
106667
|
-
|
|
106668
|
-
|
|
106669
|
-
|
|
106670
|
-
|
|
106787
|
+
var init_chunk_HRH33QP2 = __esm({
|
|
106788
|
+
"node_modules/@x402/svm/dist/esm/chunk-HRH33QP2.mjs"() {
|
|
106789
|
+
"use strict";
|
|
106790
|
+
init_chunk_VITMNYMM();
|
|
106791
|
+
init_chunk_RMG2KWUT();
|
|
106792
|
+
init_chunk_CJ2GGI22();
|
|
106793
|
+
init_chunk_2RSZYSMO();
|
|
106794
|
+
init_chunk_DP3B4MQJ();
|
|
106795
|
+
init_chunk_DAIKIZVB();
|
|
106671
106796
|
init_index_node39();
|
|
106672
106797
|
init_http4();
|
|
106673
106798
|
init_utils10();
|
|
@@ -107655,7 +107780,7 @@ var init_chunk_Y7W3OBHW = __esm({
|
|
|
107655
107780
|
}
|
|
107656
107781
|
});
|
|
107657
107782
|
|
|
107658
|
-
// node_modules/@x402/svm/dist/esm/chunk-
|
|
107783
|
+
// node_modules/@x402/svm/dist/esm/chunk-HQM7VUNZ.mjs
|
|
107659
107784
|
function getChannelDistributionHash(splits) {
|
|
107660
107785
|
const hasher = sha2568.create();
|
|
107661
107786
|
const count = new Uint8Array(4);
|
|
@@ -107669,19 +107794,19 @@ function getChannelDistributionHash(splits) {
|
|
|
107669
107794
|
}
|
|
107670
107795
|
return hasher.digest();
|
|
107671
107796
|
}
|
|
107672
|
-
var
|
|
107673
|
-
"node_modules/@x402/svm/dist/esm/chunk-
|
|
107797
|
+
var init_chunk_HQM7VUNZ = __esm({
|
|
107798
|
+
"node_modules/@x402/svm/dist/esm/chunk-HQM7VUNZ.mjs"() {
|
|
107674
107799
|
"use strict";
|
|
107675
|
-
|
|
107676
|
-
|
|
107677
|
-
|
|
107678
|
-
|
|
107800
|
+
init_chunk_NUK2USQ3();
|
|
107801
|
+
init_chunk_DP3B4MQJ();
|
|
107802
|
+
init_chunk_RZ6M7L3U();
|
|
107803
|
+
init_chunk_DAIKIZVB();
|
|
107679
107804
|
init_sha2563();
|
|
107680
107805
|
init_index_node39();
|
|
107681
107806
|
}
|
|
107682
107807
|
});
|
|
107683
107808
|
|
|
107684
|
-
// node_modules/@x402/svm/dist/esm/chunk-
|
|
107809
|
+
// node_modules/@x402/svm/dist/esm/chunk-SINLL373.mjs
|
|
107685
107810
|
function encodeCloseAuthorizationDigest(binding) {
|
|
107686
107811
|
const base582 = getBase58Encoder();
|
|
107687
107812
|
const network = new TextEncoder().encode(binding.network);
|
|
@@ -107752,11 +107877,11 @@ async function verifyCloseAuthorization(authorization, binding, receiverAuthoriz
|
|
|
107752
107877
|
return false;
|
|
107753
107878
|
}
|
|
107754
107879
|
}
|
|
107755
|
-
var
|
|
107756
|
-
"node_modules/@x402/svm/dist/esm/chunk-
|
|
107880
|
+
var init_chunk_SINLL373 = __esm({
|
|
107881
|
+
"node_modules/@x402/svm/dist/esm/chunk-SINLL373.mjs"() {
|
|
107757
107882
|
"use strict";
|
|
107758
|
-
|
|
107759
|
-
|
|
107883
|
+
init_chunk_CJ2GGI22();
|
|
107884
|
+
init_chunk_DP3B4MQJ();
|
|
107760
107885
|
init_sha2563();
|
|
107761
107886
|
init_index_node39();
|
|
107762
107887
|
}
|
|
@@ -107789,14 +107914,14 @@ var init_chunk_WIPN332D = __esm({
|
|
|
107789
107914
|
}
|
|
107790
107915
|
});
|
|
107791
107916
|
|
|
107792
|
-
// node_modules/@x402/svm/dist/esm/chunk-
|
|
107917
|
+
// node_modules/@x402/svm/dist/esm/chunk-2P7IHAQJ.mjs
|
|
107793
107918
|
var ExactSvmScheme;
|
|
107794
|
-
var
|
|
107795
|
-
"node_modules/@x402/svm/dist/esm/chunk-
|
|
107919
|
+
var init_chunk_2P7IHAQJ = __esm({
|
|
107920
|
+
"node_modules/@x402/svm/dist/esm/chunk-2P7IHAQJ.mjs"() {
|
|
107796
107921
|
"use strict";
|
|
107797
107922
|
init_chunk_WIPN332D();
|
|
107798
|
-
|
|
107799
|
-
|
|
107923
|
+
init_chunk_RZ6M7L3U();
|
|
107924
|
+
init_chunk_DAIKIZVB();
|
|
107800
107925
|
init_src2();
|
|
107801
107926
|
init_src3();
|
|
107802
107927
|
init_index_node39();
|
|
@@ -107910,7 +108035,7 @@ var init_chunk_OJGL5KXB = __esm({
|
|
|
107910
108035
|
}
|
|
107911
108036
|
});
|
|
107912
108037
|
|
|
107913
|
-
// node_modules/@x402/svm/dist/esm/chunk-
|
|
108038
|
+
// node_modules/@x402/svm/dist/esm/chunk-7TSGYOB2.mjs
|
|
107914
108039
|
function assertSmartWalletLimits(limits) {
|
|
107915
108040
|
assertLimit("smartWalletMaxComputeUnits", limits?.maxComputeUnits, 1);
|
|
107916
108041
|
assertLimit("smartWalletMaxPriorityFeeMicroLamports", limits?.maxPriorityFeeMicroLamports, 0);
|
|
@@ -108336,11 +108461,11 @@ async function verifyPostSettlement(signer, signature3, network, requirements, s
|
|
|
108336
108461
|
return { verified: false, method: "unverified" };
|
|
108337
108462
|
}
|
|
108338
108463
|
var DEFAULT_SMART_WALLET_MAX_COMPUTE_UNITS, DEFAULT_SMART_WALLET_MAX_PRIORITY_FEE_MICROLAMPORTS, IX_SET_COMPUTE_UNIT_LIMIT, IX_SET_COMPUTE_UNIT_PRICE, IX_TOKEN_TRANSFER_CHECKED, TOKEN_PROGRAMS, SMART_WALLET_V1_BUDGET_REASONS;
|
|
108339
|
-
var
|
|
108340
|
-
"node_modules/@x402/svm/dist/esm/chunk-
|
|
108464
|
+
var init_chunk_7TSGYOB2 = __esm({
|
|
108465
|
+
"node_modules/@x402/svm/dist/esm/chunk-7TSGYOB2.mjs"() {
|
|
108341
108466
|
"use strict";
|
|
108342
|
-
|
|
108343
|
-
|
|
108467
|
+
init_chunk_RZ6M7L3U();
|
|
108468
|
+
init_chunk_DAIKIZVB();
|
|
108344
108469
|
init_src4();
|
|
108345
108470
|
init_src2();
|
|
108346
108471
|
init_src3();
|
|
@@ -108366,12 +108491,12 @@ var init_chunk_FHYNBUS4 = __esm({
|
|
|
108366
108491
|
}
|
|
108367
108492
|
});
|
|
108368
108493
|
|
|
108369
|
-
// node_modules/@x402/svm/dist/esm/chunk-
|
|
108494
|
+
// node_modules/@x402/svm/dist/esm/chunk-L56Y5KBE.mjs
|
|
108370
108495
|
var SettlementCache;
|
|
108371
|
-
var
|
|
108372
|
-
"node_modules/@x402/svm/dist/esm/chunk-
|
|
108496
|
+
var init_chunk_L56Y5KBE = __esm({
|
|
108497
|
+
"node_modules/@x402/svm/dist/esm/chunk-L56Y5KBE.mjs"() {
|
|
108373
108498
|
"use strict";
|
|
108374
|
-
|
|
108499
|
+
init_chunk_DAIKIZVB();
|
|
108375
108500
|
SettlementCache = class {
|
|
108376
108501
|
constructor() {
|
|
108377
108502
|
this.entries = /* @__PURE__ */ new Map();
|
|
@@ -108418,7 +108543,7 @@ var init_chunk_BAY4U3CP = __esm({
|
|
|
108418
108543
|
}
|
|
108419
108544
|
});
|
|
108420
108545
|
|
|
108421
|
-
// node_modules/@x402/svm/dist/esm/chunk-
|
|
108546
|
+
// node_modules/@x402/svm/dist/esm/chunk-NQRJ53N4.mjs
|
|
108422
108547
|
function resolveUptoSvmPaymentChannelConfig(requirements) {
|
|
108423
108548
|
const feePayer = requirements.extra?.feePayer;
|
|
108424
108549
|
if (typeof feePayer !== "string" || feePayer.length === 0) {
|
|
@@ -108435,22 +108560,22 @@ function resolveUptoSvmPaymentChannelConfig(requirements) {
|
|
|
108435
108560
|
const splits = [{ bps: BASIS_POINTS_DENOMINATOR, recipient: requirements.payTo }];
|
|
108436
108561
|
return { feePayer, receiverAuthorizer, splits, withdrawDelay };
|
|
108437
108562
|
}
|
|
108438
|
-
var
|
|
108439
|
-
"node_modules/@x402/svm/dist/esm/chunk-
|
|
108563
|
+
var init_chunk_NQRJ53N4 = __esm({
|
|
108564
|
+
"node_modules/@x402/svm/dist/esm/chunk-NQRJ53N4.mjs"() {
|
|
108440
108565
|
"use strict";
|
|
108441
|
-
|
|
108566
|
+
init_chunk_DAIKIZVB();
|
|
108442
108567
|
}
|
|
108443
108568
|
});
|
|
108444
108569
|
|
|
108445
|
-
// node_modules/@x402/svm/dist/esm/chunk-
|
|
108570
|
+
// node_modules/@x402/svm/dist/esm/chunk-QPYYLXPW.mjs
|
|
108446
108571
|
var UptoSvmScheme;
|
|
108447
|
-
var
|
|
108448
|
-
"node_modules/@x402/svm/dist/esm/chunk-
|
|
108572
|
+
var init_chunk_QPYYLXPW = __esm({
|
|
108573
|
+
"node_modules/@x402/svm/dist/esm/chunk-QPYYLXPW.mjs"() {
|
|
108449
108574
|
"use strict";
|
|
108450
|
-
|
|
108451
|
-
|
|
108452
|
-
|
|
108453
|
-
|
|
108575
|
+
init_chunk_NQRJ53N4();
|
|
108576
|
+
init_chunk_2RSZYSMO();
|
|
108577
|
+
init_chunk_DP3B4MQJ();
|
|
108578
|
+
init_chunk_DAIKIZVB();
|
|
108454
108579
|
init_src3();
|
|
108455
108580
|
init_src2();
|
|
108456
108581
|
UptoSvmScheme = class {
|
|
@@ -108924,23 +109049,23 @@ var init_esm8 = __esm({
|
|
|
108924
109049
|
"node_modules/@x402/svm/dist/esm/index.mjs"() {
|
|
108925
109050
|
"use strict";
|
|
108926
109051
|
init_chunk_NLVYNPNC();
|
|
108927
|
-
|
|
108928
|
-
|
|
108929
|
-
|
|
108930
|
-
|
|
108931
|
-
|
|
108932
|
-
|
|
108933
|
-
|
|
108934
|
-
|
|
109052
|
+
init_chunk_HRH33QP2();
|
|
109053
|
+
init_chunk_HQM7VUNZ();
|
|
109054
|
+
init_chunk_VITMNYMM();
|
|
109055
|
+
init_chunk_RMG2KWUT();
|
|
109056
|
+
init_chunk_SINLL373();
|
|
109057
|
+
init_chunk_CJ2GGI22();
|
|
109058
|
+
init_chunk_NUK2USQ3();
|
|
109059
|
+
init_chunk_2P7IHAQJ();
|
|
108935
109060
|
init_chunk_WIPN332D();
|
|
108936
|
-
|
|
108937
|
-
|
|
108938
|
-
|
|
108939
|
-
|
|
108940
|
-
|
|
108941
|
-
|
|
108942
|
-
|
|
108943
|
-
|
|
109061
|
+
init_chunk_7TSGYOB2();
|
|
109062
|
+
init_chunk_L56Y5KBE();
|
|
109063
|
+
init_chunk_QPYYLXPW();
|
|
109064
|
+
init_chunk_NQRJ53N4();
|
|
109065
|
+
init_chunk_2RSZYSMO();
|
|
109066
|
+
init_chunk_DP3B4MQJ();
|
|
109067
|
+
init_chunk_RZ6M7L3U();
|
|
109068
|
+
init_chunk_DAIKIZVB();
|
|
108944
109069
|
init_index_node39();
|
|
108945
109070
|
}
|
|
108946
109071
|
});
|
|
@@ -108967,15 +109092,15 @@ __export(client_exports2, {
|
|
|
108967
109092
|
var init_client3 = __esm({
|
|
108968
109093
|
"node_modules/@x402/svm/dist/esm/batch-settlement/client/index.mjs"() {
|
|
108969
109094
|
"use strict";
|
|
108970
|
-
|
|
108971
|
-
|
|
108972
|
-
|
|
108973
|
-
|
|
108974
|
-
|
|
108975
|
-
|
|
108976
|
-
|
|
108977
|
-
|
|
108978
|
-
|
|
109095
|
+
init_chunk_HRH33QP2();
|
|
109096
|
+
init_chunk_VITMNYMM();
|
|
109097
|
+
init_chunk_RMG2KWUT();
|
|
109098
|
+
init_chunk_CJ2GGI22();
|
|
109099
|
+
init_chunk_NUK2USQ3();
|
|
109100
|
+
init_chunk_2RSZYSMO();
|
|
109101
|
+
init_chunk_DP3B4MQJ();
|
|
109102
|
+
init_chunk_RZ6M7L3U();
|
|
109103
|
+
init_chunk_DAIKIZVB();
|
|
108979
109104
|
}
|
|
108980
109105
|
});
|
|
108981
109106
|
|
|
@@ -109094,7 +109219,7 @@ import * as path4 from "path";
|
|
|
109094
109219
|
import * as os3 from "os";
|
|
109095
109220
|
import { createPrivateKey as createPrivateKey2, createPublicKey as createPublicKey2, sign as ed25519Sign } from "crypto";
|
|
109096
109221
|
import { AsyncLocalStorage } from "async_hooks";
|
|
109097
|
-
import { randomUUID } from "crypto";
|
|
109222
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
109098
109223
|
import * as fs6 from "fs";
|
|
109099
109224
|
import * as path5 from "path";
|
|
109100
109225
|
import * as fs7 from "fs";
|
|
@@ -111634,7 +111759,7 @@ function lockChannelFile(file2) {
|
|
|
111634
111759
|
if (registry22.locks.has(file2)) return void 0;
|
|
111635
111760
|
const lock = `${file2}.lock`;
|
|
111636
111761
|
fs6.mkdirSync(path5.dirname(lock), { recursive: true, mode: 448 });
|
|
111637
|
-
const token =
|
|
111762
|
+
const token = randomUUID2();
|
|
111638
111763
|
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
111639
111764
|
const tmp = `${lock}.${process.pid}.${token}.tmp`;
|
|
111640
111765
|
try {
|
|
@@ -111854,7 +111979,7 @@ function withDepositBlockhash(paymentRequired, blockhash2) {
|
|
|
111854
111979
|
function withPaymentIdentifier(paymentRequired) {
|
|
111855
111980
|
const declared = paymentRequired.extensions?.[PAYMENT_IDENTIFIER];
|
|
111856
111981
|
if (typeof declared?.info?.required !== "boolean") return paymentRequired;
|
|
111857
|
-
const id2 = `pay_${
|
|
111982
|
+
const id2 = `pay_${randomUUID2().replace(/-/g, "")}`;
|
|
111858
111983
|
return {
|
|
111859
111984
|
...paymentRequired,
|
|
111860
111985
|
extensions: { ...paymentRequired.extensions, [PAYMENT_IDENTIFIER]: { ...declared, info: { ...declared.info, id: id2 } } }
|
|
@@ -120346,7 +120471,7 @@ var init_dist2 = __esm({
|
|
|
120346
120471
|
fsyncDirectory(dir);
|
|
120347
120472
|
return;
|
|
120348
120473
|
}
|
|
120349
|
-
const tmp = `${this.file}.${process.pid}.${
|
|
120474
|
+
const tmp = `${this.file}.${process.pid}.${randomUUID2()}.tmp`;
|
|
120350
120475
|
const fd = fs6.openSync(tmp, "w", 384);
|
|
120351
120476
|
try {
|
|
120352
120477
|
fs6.writeSync(fd, JSON.stringify({ version: 1, intents }, null, 2));
|
|
@@ -156046,7 +156171,7 @@ function transform2(md, preset) {
|
|
|
156046
156171
|
(seg) => seg.isFence ? transformFenceForPreset(seg, preset) : applyTextRulesPerPreset(seg.content, preset)
|
|
156047
156172
|
).join("");
|
|
156048
156173
|
}
|
|
156049
|
-
var SHARE_PRESETS, PH_BOLD, PH_LINK, PH_END, TABLE_BLOCK_REGEX, TELEGRAM_ESCAPE_CHARS;
|
|
156174
|
+
var SHARE_PRESETS, TELEGRAM_MAX_LEN, TELEGRAM_SUFFIX_RESERVE, TELEGRAM_CHUNK_CONTENT_LIMIT, PH_BOLD, PH_LINK, PH_END, TABLE_BLOCK_REGEX, TELEGRAM_ESCAPE_CHARS;
|
|
156050
156175
|
var init_share_formatters = __esm({
|
|
156051
156176
|
"src/share-formatters.ts"() {
|
|
156052
156177
|
"use strict";
|
|
@@ -156058,6 +156183,9 @@ var init_share_formatters = __esm({
|
|
|
156058
156183
|
"whatsapp",
|
|
156059
156184
|
"plain"
|
|
156060
156185
|
];
|
|
156186
|
+
TELEGRAM_MAX_LEN = 4096;
|
|
156187
|
+
TELEGRAM_SUFFIX_RESERVE = 24;
|
|
156188
|
+
TELEGRAM_CHUNK_CONTENT_LIMIT = TELEGRAM_MAX_LEN - TELEGRAM_SUFFIX_RESERVE;
|
|
156061
156189
|
PH_BOLD = "__CR_PH_BOLD_";
|
|
156062
156190
|
PH_LINK = "__CR_PH_LINK_";
|
|
156063
156191
|
PH_END = "__";
|
|
@@ -156223,14 +156351,14 @@ var init_chunk_WWACQNRQ = __esm({
|
|
|
156223
156351
|
}
|
|
156224
156352
|
});
|
|
156225
156353
|
|
|
156226
|
-
// node_modules/@x402/svm/dist/esm/chunk-
|
|
156354
|
+
// node_modules/@x402/svm/dist/esm/chunk-PQ2KWLVO.mjs
|
|
156227
156355
|
var ExactSvmSchemeV1;
|
|
156228
|
-
var
|
|
156229
|
-
"node_modules/@x402/svm/dist/esm/chunk-
|
|
156356
|
+
var init_chunk_PQ2KWLVO = __esm({
|
|
156357
|
+
"node_modules/@x402/svm/dist/esm/chunk-PQ2KWLVO.mjs"() {
|
|
156230
156358
|
"use strict";
|
|
156231
156359
|
init_chunk_WIPN332D();
|
|
156232
|
-
|
|
156233
|
-
|
|
156360
|
+
init_chunk_RZ6M7L3U();
|
|
156361
|
+
init_chunk_DAIKIZVB();
|
|
156234
156362
|
init_src2();
|
|
156235
156363
|
init_src3();
|
|
156236
156364
|
init_index_node39();
|
|
@@ -156358,15 +156486,15 @@ var init_facilitator = __esm({
|
|
|
156358
156486
|
}
|
|
156359
156487
|
});
|
|
156360
156488
|
|
|
156361
|
-
// node_modules/@x402/svm/dist/esm/chunk-
|
|
156489
|
+
// node_modules/@x402/svm/dist/esm/chunk-RCDWMK2L.mjs
|
|
156362
156490
|
var addressEncoder, compiledMessageDecoder, compiledMessageDecoder2;
|
|
156363
|
-
var
|
|
156364
|
-
"node_modules/@x402/svm/dist/esm/chunk-
|
|
156491
|
+
var init_chunk_RCDWMK2L = __esm({
|
|
156492
|
+
"node_modules/@x402/svm/dist/esm/chunk-RCDWMK2L.mjs"() {
|
|
156365
156493
|
"use strict";
|
|
156366
|
-
|
|
156367
|
-
|
|
156368
|
-
|
|
156369
|
-
|
|
156494
|
+
init_chunk_7TSGYOB2();
|
|
156495
|
+
init_chunk_L56Y5KBE();
|
|
156496
|
+
init_chunk_RZ6M7L3U();
|
|
156497
|
+
init_chunk_DAIKIZVB();
|
|
156370
156498
|
init_index_node39();
|
|
156371
156499
|
init_facilitator();
|
|
156372
156500
|
init_index_node39();
|
|
@@ -156411,15 +156539,15 @@ function registerExactSvmScheme(client, config2) {
|
|
|
156411
156539
|
var init_client4 = __esm({
|
|
156412
156540
|
"node_modules/@x402/svm/dist/esm/exact/client/index.mjs"() {
|
|
156413
156541
|
"use strict";
|
|
156414
|
-
|
|
156542
|
+
init_chunk_2P7IHAQJ();
|
|
156415
156543
|
init_chunk_WWACQNRQ();
|
|
156416
|
-
|
|
156544
|
+
init_chunk_PQ2KWLVO();
|
|
156417
156545
|
init_chunk_WIPN332D();
|
|
156418
|
-
|
|
156419
|
-
|
|
156420
|
-
|
|
156421
|
-
|
|
156422
|
-
|
|
156546
|
+
init_chunk_RCDWMK2L();
|
|
156547
|
+
init_chunk_7TSGYOB2();
|
|
156548
|
+
init_chunk_L56Y5KBE();
|
|
156549
|
+
init_chunk_RZ6M7L3U();
|
|
156550
|
+
init_chunk_DAIKIZVB();
|
|
156423
156551
|
init_utils10();
|
|
156424
156552
|
}
|
|
156425
156553
|
});
|
|
@@ -156434,13 +156562,13 @@ var init_v1 = __esm({
|
|
|
156434
156562
|
"node_modules/@x402/svm/dist/esm/v1/index.mjs"() {
|
|
156435
156563
|
"use strict";
|
|
156436
156564
|
init_chunk_WWACQNRQ();
|
|
156437
|
-
|
|
156565
|
+
init_chunk_PQ2KWLVO();
|
|
156438
156566
|
init_chunk_WIPN332D();
|
|
156439
|
-
|
|
156440
|
-
|
|
156441
|
-
|
|
156442
|
-
|
|
156443
|
-
|
|
156567
|
+
init_chunk_RCDWMK2L();
|
|
156568
|
+
init_chunk_7TSGYOB2();
|
|
156569
|
+
init_chunk_L56Y5KBE();
|
|
156570
|
+
init_chunk_RZ6M7L3U();
|
|
156571
|
+
init_chunk_DAIKIZVB();
|
|
156444
156572
|
}
|
|
156445
156573
|
});
|
|
156446
156574
|
|
|
@@ -156520,20 +156648,44 @@ function toUpstreamModelId(modelId) {
|
|
|
156520
156648
|
function timeoutForModel(modelId, models) {
|
|
156521
156649
|
return models.get(modelId)?.reasoning ? REASONING_MODEL_TIMEOUT_MS : PER_MODEL_TIMEOUT_MS;
|
|
156522
156650
|
}
|
|
156523
|
-
|
|
156651
|
+
function isClientAbortError(err, res) {
|
|
156652
|
+
if (err instanceof ClientDisconnectedError) return true;
|
|
156653
|
+
if (!(err instanceof Error)) return false;
|
|
156654
|
+
const clientGone = res.destroyed && !res.writableEnded;
|
|
156655
|
+
return clientGone && (err.name === "AbortError" || err.message.includes("aborted"));
|
|
156656
|
+
}
|
|
156657
|
+
async function readBodyWithTimeout(body, timeoutMs = MODEL_BODY_READ_TIMEOUT_MS, signal, abortError = () => new ClientDisconnectedError()) {
|
|
156524
156658
|
if (!body) return [];
|
|
156659
|
+
if (signal?.aborted) {
|
|
156660
|
+
await body.cancel().catch(() => {
|
|
156661
|
+
});
|
|
156662
|
+
throw abortError();
|
|
156663
|
+
}
|
|
156525
156664
|
const reader = body.getReader();
|
|
156526
156665
|
const chunks = [];
|
|
156527
156666
|
let timer2;
|
|
156667
|
+
let abortHandler;
|
|
156528
156668
|
try {
|
|
156529
156669
|
while (true) {
|
|
156670
|
+
if (signal?.aborted) {
|
|
156671
|
+
throw abortError();
|
|
156672
|
+
}
|
|
156673
|
+
const abortPromise = signal ? new Promise((_, reject) => {
|
|
156674
|
+
abortHandler = () => reject(abortError());
|
|
156675
|
+
signal.addEventListener("abort", abortHandler, { once: true });
|
|
156676
|
+
}) : null;
|
|
156530
156677
|
const result = await Promise.race([
|
|
156531
156678
|
reader.read(),
|
|
156532
156679
|
new Promise((_, reject) => {
|
|
156533
156680
|
timer2 = setTimeout(() => reject(new Error("Body read timeout")), timeoutMs);
|
|
156534
|
-
})
|
|
156681
|
+
}),
|
|
156682
|
+
...abortPromise ? [abortPromise] : []
|
|
156535
156683
|
]);
|
|
156536
156684
|
clearTimeout(timer2);
|
|
156685
|
+
if (signal && abortHandler) {
|
|
156686
|
+
signal.removeEventListener("abort", abortHandler);
|
|
156687
|
+
abortHandler = void 0;
|
|
156688
|
+
}
|
|
156537
156689
|
if (result.done) break;
|
|
156538
156690
|
chunks.push(result.value);
|
|
156539
156691
|
}
|
|
@@ -156543,6 +156695,9 @@ async function readBodyWithTimeout(body, timeoutMs = MODEL_BODY_READ_TIMEOUT_MS)
|
|
|
156543
156695
|
throw err;
|
|
156544
156696
|
} finally {
|
|
156545
156697
|
clearTimeout(timer2);
|
|
156698
|
+
if (signal && abortHandler) {
|
|
156699
|
+
signal.removeEventListener("abort", abortHandler);
|
|
156700
|
+
}
|
|
156546
156701
|
reader.releaseLock();
|
|
156547
156702
|
}
|
|
156548
156703
|
return chunks;
|
|
@@ -157384,6 +157539,26 @@ function withZeroCapGuard(inner, isFree) {
|
|
|
157384
157539
|
return inner(input2, init2);
|
|
157385
157540
|
};
|
|
157386
157541
|
}
|
|
157542
|
+
function withSessionCostCap(inner) {
|
|
157543
|
+
return async (input2, init2) => {
|
|
157544
|
+
const store = paymentStore.getStore();
|
|
157545
|
+
const spend = store?.sessionSpend;
|
|
157546
|
+
const published = store?.estimatedUsd;
|
|
157547
|
+
if (spend?.isStrict && published !== void 0) {
|
|
157548
|
+
const attemptMicros = usdToMicros(published);
|
|
157549
|
+
if (!spend.coverPayment(attemptMicros)) {
|
|
157550
|
+
throw new CostCapError(
|
|
157551
|
+
`ClawRouter cost cap exceeded: dispatching an estimated $${microsToUsd(attemptMicros).toFixed(6)} would push this session past its maxCostPerRun limit`
|
|
157552
|
+
);
|
|
157553
|
+
}
|
|
157554
|
+
}
|
|
157555
|
+
if (published !== void 0) spend?.beginDispatch();
|
|
157556
|
+
const response = await inner(input2, init2);
|
|
157557
|
+
const charged = gatewaySettledCostUsd(response);
|
|
157558
|
+
if (spend && charged !== void 0) spend.recordCharged(usdToMicros(charged));
|
|
157559
|
+
return response;
|
|
157560
|
+
};
|
|
157561
|
+
}
|
|
157387
157562
|
function isMessagesPath(url3) {
|
|
157388
157563
|
return url3 === "/v1/messages" || (url3?.startsWith("/v1/messages?") ?? false);
|
|
157389
157564
|
}
|
|
@@ -157431,9 +157606,15 @@ async function proxyPaidApiRequest(req, res, apiBase, payFetch, getActualPayment
|
|
|
157431
157606
|
headers["user-agent"] = USER_AGENT;
|
|
157432
157607
|
console.log(`[ClawRouter] ${requestLabel} request: ${req.method} ${req.url}`);
|
|
157433
157608
|
const clientAbort = new AbortController();
|
|
157434
|
-
|
|
157435
|
-
if (!res.writableEnded
|
|
157436
|
-
|
|
157609
|
+
const onClientDisconnect = () => {
|
|
157610
|
+
if (!res.writableEnded && !clientAbort.signal.aborted) {
|
|
157611
|
+
clientAbort.abort();
|
|
157612
|
+
}
|
|
157613
|
+
};
|
|
157614
|
+
res.on("close", onClientDisconnect);
|
|
157615
|
+
if ((res.destroyed || req.socket?.destroyed) && !res.writableEnded) {
|
|
157616
|
+
onClientDisconnect();
|
|
157617
|
+
}
|
|
157437
157618
|
publishDispatchCost(0);
|
|
157438
157619
|
const upstream = await payFetch(upstreamUrl, {
|
|
157439
157620
|
method: req.method ?? "POST",
|
|
@@ -157475,7 +157656,7 @@ async function proxyPaidApiRequest(req, res, apiBase, payFetch, getActualPayment
|
|
|
157475
157656
|
res.end();
|
|
157476
157657
|
}
|
|
157477
157658
|
} else {
|
|
157478
|
-
const chunks = upstream.body ? await readBodyWithTimeout(upstream.body, ERROR_BODY_READ_TIMEOUT_MS) : [];
|
|
157659
|
+
const chunks = upstream.body ? await readBodyWithTimeout(upstream.body, ERROR_BODY_READ_TIMEOUT_MS, clientAbort.signal) : [];
|
|
157479
157660
|
res.writeHead(upstream.status, responseHeaders);
|
|
157480
157661
|
for (const chunk of chunks) {
|
|
157481
157662
|
safeWrite(res, Buffer.from(chunk));
|
|
@@ -157817,15 +157998,17 @@ async function startProxy(options) {
|
|
|
157817
157998
|
const { freeIds } = catalog.current();
|
|
157818
157999
|
return freeIds.has(resolveModelAlias(model)) || [...freeIds].some((id2) => toUpstreamModelId(id2) === model);
|
|
157819
158000
|
};
|
|
157820
|
-
const payFetch = authMode === "api-key" ?
|
|
157821
|
-
|
|
157822
|
-
|
|
157823
|
-
|
|
157824
|
-
|
|
157825
|
-
|
|
157826
|
-
|
|
157827
|
-
|
|
157828
|
-
|
|
158001
|
+
const payFetch = authMode === "api-key" ? withSessionCostCap(
|
|
158002
|
+
withSpendPolicy(
|
|
158003
|
+
options.maxCostPerRunUsd === 0 ? withZeroCapGuard(keyFetch, isFreeForCap) : keyFetch,
|
|
158004
|
+
options.spendControl ?? getSharedSpendControl(),
|
|
158005
|
+
() => {
|
|
158006
|
+
const store = paymentStore.getStore();
|
|
158007
|
+
const published = store?.estimatedUsd;
|
|
158008
|
+
if (store) store.estimatedUsd = void 0;
|
|
158009
|
+
return published;
|
|
158010
|
+
}
|
|
158011
|
+
)
|
|
157829
158012
|
) : createPayFetchWithPreAuth(fetch, x402, void 0, {
|
|
157830
158013
|
skipPreAuth: paymentChain === "solana",
|
|
157831
158014
|
// Per-request cost estimate so pre-auth is only reused when the cached
|
|
@@ -158823,13 +159006,18 @@ async function startProxy(options) {
|
|
|
158823
159006
|
);
|
|
158824
159007
|
} catch (err) {
|
|
158825
159008
|
if (refuseOverCostCap(res, err)) return;
|
|
158826
|
-
const
|
|
158827
|
-
options.onError?.(
|
|
158828
|
-
if (
|
|
159009
|
+
const clientGone = isClientAbortError(err, res);
|
|
159010
|
+
if (!clientGone) options.onError?.(err instanceof Error ? err : new Error(String(err)));
|
|
159011
|
+
if (clientGone) {
|
|
159012
|
+
if (!res.writableEnded) res.destroy();
|
|
159013
|
+
} else if (!res.headersSent) {
|
|
158829
159014
|
res.writeHead(502, { "Content-Type": "application/json" });
|
|
158830
159015
|
res.end(
|
|
158831
159016
|
JSON.stringify({
|
|
158832
|
-
error: {
|
|
159017
|
+
error: {
|
|
159018
|
+
message: `Partner proxy error: ${err instanceof Error ? err.message : String(err)}`,
|
|
159019
|
+
type: "partner_error"
|
|
159020
|
+
}
|
|
158833
159021
|
})
|
|
158834
159022
|
);
|
|
158835
159023
|
} else if (!res.writableEnded) {
|
|
@@ -158858,18 +159046,25 @@ async function startProxy(options) {
|
|
|
158858
159046
|
);
|
|
158859
159047
|
} catch (err) {
|
|
158860
159048
|
if (refuseOverCostCap(res, err)) return;
|
|
158861
|
-
const
|
|
158862
|
-
options.onError?.(
|
|
158863
|
-
if (
|
|
159049
|
+
const clientGone = isClientAbortError(err, res);
|
|
159050
|
+
if (!clientGone) options.onError?.(err instanceof Error ? err : new Error(String(err)));
|
|
159051
|
+
if (clientGone) {
|
|
159052
|
+
if (!res.writableEnded) res.destroy();
|
|
159053
|
+
} else if (!res.headersSent) {
|
|
158864
159054
|
res.writeHead(502, { "Content-Type": "application/json" });
|
|
158865
159055
|
res.end(
|
|
158866
159056
|
JSON.stringify({
|
|
158867
|
-
error: {
|
|
159057
|
+
error: {
|
|
159058
|
+
message: `Account API error: ${err instanceof Error ? err.message : String(err)}`,
|
|
159059
|
+
type: "account_error"
|
|
159060
|
+
}
|
|
158868
159061
|
})
|
|
158869
159062
|
);
|
|
158870
159063
|
} else if (!res.writableEnded) {
|
|
158871
159064
|
res.end();
|
|
158872
159065
|
}
|
|
159066
|
+
} finally {
|
|
159067
|
+
paymentStore.getStore()?.sessionSpend?.release();
|
|
158873
159068
|
}
|
|
158874
159069
|
return;
|
|
158875
159070
|
}
|
|
@@ -160402,6 +160597,7 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
160402
160597
|
} else {
|
|
160403
160598
|
clearInterval(heartbeatInterval);
|
|
160404
160599
|
heartbeatInterval = void 0;
|
|
160600
|
+
onClientClose();
|
|
160405
160601
|
}
|
|
160406
160602
|
}, HEARTBEAT_INTERVAL_MS);
|
|
160407
160603
|
}
|
|
@@ -160431,7 +160627,7 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
160431
160627
|
const timeoutMs = options.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
|
|
160432
160628
|
const globalController = new AbortController();
|
|
160433
160629
|
const timeoutId = setTimeout(() => globalController.abort(), timeoutMs);
|
|
160434
|
-
const clientDisconnected = () => res.destroyed && !res.writableEnded;
|
|
160630
|
+
const clientDisconnected = () => (res.destroyed || req.socket?.destroyed === true) && !res.writableEnded;
|
|
160435
160631
|
const abortError = () => clientDisconnected() ? new ClientDisconnectedError() : new Error(`Request timed out after ${timeoutMs}ms`);
|
|
160436
160632
|
const onClientClose = () => {
|
|
160437
160633
|
if (!res.writableEnded && !globalController.signal.aborted) {
|
|
@@ -160440,7 +160636,9 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
160440
160636
|
}
|
|
160441
160637
|
};
|
|
160442
160638
|
res.on("close", onClientClose);
|
|
160443
|
-
if (
|
|
160639
|
+
if (clientDisconnected()) {
|
|
160640
|
+
onClientClose();
|
|
160641
|
+
}
|
|
160444
160642
|
try {
|
|
160445
160643
|
let modelsToTry;
|
|
160446
160644
|
const excludeList = options.excludeModels ?? loadExcludeList();
|
|
@@ -161088,7 +161286,12 @@ data: [DONE]
|
|
|
161088
161286
|
const responseChunks = [];
|
|
161089
161287
|
if (headersSentEarly) {
|
|
161090
161288
|
if (upstream.body) {
|
|
161091
|
-
const chunks = await readBodyWithTimeout(
|
|
161289
|
+
const chunks = await readBodyWithTimeout(
|
|
161290
|
+
upstream.body,
|
|
161291
|
+
MODEL_BODY_READ_TIMEOUT_MS,
|
|
161292
|
+
globalController.signal,
|
|
161293
|
+
abortError
|
|
161294
|
+
);
|
|
161092
161295
|
const jsonBody = Buffer.concat(chunks);
|
|
161093
161296
|
const jsonStr = jsonBody.toString();
|
|
161094
161297
|
try {
|
|
@@ -161219,7 +161422,9 @@ data: [DONE]
|
|
|
161219
161422
|
responseChunks.push(Buffer.from(finishData));
|
|
161220
161423
|
}
|
|
161221
161424
|
}
|
|
161222
|
-
} catch {
|
|
161425
|
+
} catch (err) {
|
|
161426
|
+
if (err instanceof ClientDisconnectedError) throw err;
|
|
161427
|
+
if (globalController.signal.aborted) throw abortError();
|
|
161223
161428
|
const errPayload = JSON.stringify({
|
|
161224
161429
|
error: {
|
|
161225
161430
|
message: `Upstream response could not be parsed: ${jsonStr.slice(0, 200)}`,
|
|
@@ -161307,7 +161512,12 @@ data: [DONE]
|
|
|
161307
161512
|
}
|
|
161308
161513
|
const bodyParts = [];
|
|
161309
161514
|
if (upstream.body) {
|
|
161310
|
-
const chunks = await readBodyWithTimeout(
|
|
161515
|
+
const chunks = await readBodyWithTimeout(
|
|
161516
|
+
upstream.body,
|
|
161517
|
+
MODEL_BODY_READ_TIMEOUT_MS,
|
|
161518
|
+
globalController.signal,
|
|
161519
|
+
abortError
|
|
161520
|
+
);
|
|
161311
161521
|
for (const chunk of chunks) {
|
|
161312
161522
|
bodyParts.push(Buffer.from(chunk));
|
|
161313
161523
|
}
|
|
@@ -163773,7 +163983,7 @@ var init_config2 = __esm({
|
|
|
163773
163983
|
conditionalTokens: "0x69308FB512518e39F9b16112fA8d994F4e2Bf8bB",
|
|
163774
163984
|
exchangeV2: "0xE111180000d2663C0091e4f400237545B87B996B",
|
|
163775
163985
|
negRiskExchangeV2: "0xe2222d279d744050d28e00520010520000310F59",
|
|
163776
|
-
exchangeV3: "
|
|
163986
|
+
exchangeV3: "0xe3333700cA9d93003F00f0F71f8515005F6c00Aa"
|
|
163777
163987
|
};
|
|
163778
163988
|
MATIC_CONTRACTS = {
|
|
163779
163989
|
exchange: "0x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E",
|
|
@@ -179163,7 +179373,7 @@ var VERSION2;
|
|
|
179163
179373
|
var init_data2 = __esm({
|
|
179164
179374
|
"node_modules/axios/lib/env/data.js"() {
|
|
179165
179375
|
"use strict";
|
|
179166
|
-
VERSION2 = "1.21.
|
|
179376
|
+
VERSION2 = "1.21.1";
|
|
179167
179377
|
}
|
|
179168
179378
|
});
|
|
179169
179379
|
|
|
@@ -182919,8 +183129,11 @@ function throwIfCancellationRequested(config2) {
|
|
|
182919
183129
|
throw new CanceledError_default(null, config2);
|
|
182920
183130
|
}
|
|
182921
183131
|
}
|
|
182922
|
-
function
|
|
182923
|
-
return
|
|
183132
|
+
function resolveClock() {
|
|
183133
|
+
return typeof performance !== "undefined" && utils_default.isFunction(performance.now) ? () => performance.now() : Date.now;
|
|
183134
|
+
}
|
|
183135
|
+
function elapsedSince(now2, start) {
|
|
183136
|
+
return Math.max(0, Math.round(now2() - start));
|
|
182924
183137
|
}
|
|
182925
183138
|
function dispatchRequest(_config) {
|
|
182926
183139
|
const config2 = utils_default.toSafeFlatObject(_config);
|
|
@@ -182931,11 +183144,12 @@ function dispatchRequest(_config) {
|
|
|
182931
183144
|
config2.headers.setContentType("application/x-www-form-urlencoded", false);
|
|
182932
183145
|
}
|
|
182933
183146
|
const adapter2 = adapters_default.getAdapter(config2.adapter || defaults_default.adapter, config2);
|
|
182934
|
-
const
|
|
183147
|
+
const now2 = resolveClock();
|
|
183148
|
+
const start = now2();
|
|
182935
183149
|
return adapter2(config2).then(
|
|
182936
183150
|
function onAdapterResolution(response) {
|
|
182937
183151
|
throwIfCancellationRequested(config2);
|
|
182938
|
-
response.duration = elapsedSince(start);
|
|
183152
|
+
response.duration = elapsedSince(now2, start);
|
|
182939
183153
|
config2.response = response;
|
|
182940
183154
|
try {
|
|
182941
183155
|
response.data = transformData.call(config2, config2.transformResponse, response);
|
|
@@ -182949,7 +183163,7 @@ function dispatchRequest(_config) {
|
|
|
182949
183163
|
if (!isCancel(reason)) {
|
|
182950
183164
|
throwIfCancellationRequested(config2);
|
|
182951
183165
|
if (reason && reason.response) {
|
|
182952
|
-
reason.response.duration = elapsedSince(start);
|
|
183166
|
+
reason.response.duration = elapsedSince(now2, start);
|
|
182953
183167
|
config2.response = reason.response;
|
|
182954
183168
|
try {
|
|
182955
183169
|
reason.response.data = transformData.call(
|
|
@@ -304831,7 +305045,7 @@ var require_axios = __commonJS({
|
|
|
304831
305045
|
function getEnv2(key3) {
|
|
304832
305046
|
return process.env[key3.toLowerCase()] || process.env[key3.toUpperCase()] || "";
|
|
304833
305047
|
}
|
|
304834
|
-
var VERSION4 = "1.21.
|
|
305048
|
+
var VERSION4 = "1.21.1";
|
|
304835
305049
|
function parseProtocol2(url4) {
|
|
304836
305050
|
const match = /^([-+\w]{1,25}):(?:\/\/)?/.exec(url4);
|
|
304837
305051
|
return match && match[1].toLowerCase() || "";
|
|
@@ -308039,8 +308253,11 @@ var require_axios = __commonJS({
|
|
|
308039
308253
|
throw new CanceledError3(null, config2);
|
|
308040
308254
|
}
|
|
308041
308255
|
}
|
|
308042
|
-
function
|
|
308043
|
-
return
|
|
308256
|
+
function resolveClock2() {
|
|
308257
|
+
return typeof performance !== "undefined" && utils$1.isFunction(performance.now) ? () => performance.now() : Date.now;
|
|
308258
|
+
}
|
|
308259
|
+
function elapsedSince2(now2, start) {
|
|
308260
|
+
return Math.max(0, Math.round(now2() - start));
|
|
308044
308261
|
}
|
|
308045
308262
|
function dispatchRequest2(_config) {
|
|
308046
308263
|
const config2 = utils$1.toSafeFlatObject(_config);
|
|
@@ -308051,10 +308268,11 @@ var require_axios = __commonJS({
|
|
|
308051
308268
|
config2.headers.setContentType("application/x-www-form-urlencoded", false);
|
|
308052
308269
|
}
|
|
308053
308270
|
const adapter2 = adapters.getAdapter(config2.adapter || defaults2.adapter, config2);
|
|
308054
|
-
const
|
|
308271
|
+
const now2 = resolveClock2();
|
|
308272
|
+
const start = now2();
|
|
308055
308273
|
return adapter2(config2).then(function onAdapterResolution(response) {
|
|
308056
308274
|
throwIfCancellationRequested2(config2);
|
|
308057
|
-
response.duration = elapsedSince2(start);
|
|
308275
|
+
response.duration = elapsedSince2(now2, start);
|
|
308058
308276
|
config2.response = response;
|
|
308059
308277
|
try {
|
|
308060
308278
|
response.data = transformData2.call(config2, config2.transformResponse, response);
|
|
@@ -308067,7 +308285,7 @@ var require_axios = __commonJS({
|
|
|
308067
308285
|
if (!isCancel3(reason)) {
|
|
308068
308286
|
throwIfCancellationRequested2(config2);
|
|
308069
308287
|
if (reason && reason.response) {
|
|
308070
|
-
reason.response.duration = elapsedSince2(start);
|
|
308288
|
+
reason.response.duration = elapsedSince2(now2, start);
|
|
308071
308289
|
config2.response = reason.response;
|
|
308072
308290
|
try {
|
|
308073
308291
|
reason.response.data = transformData2.call(config2, config2.transformResponse, reason.response);
|
|
@@ -313425,7 +313643,7 @@ import {
|
|
|
313425
313643
|
} from "fs";
|
|
313426
313644
|
import { readFile as readFileAsync } from "fs/promises";
|
|
313427
313645
|
import { homedir as homedir16 } from "os";
|
|
313428
|
-
import { randomUUID as
|
|
313646
|
+
import { randomUUID as randomUUID3 } from "crypto";
|
|
313429
313647
|
import { join as join20 } from "path";
|
|
313430
313648
|
async function waitForProxyHealth(port, timeoutMs = 3e3) {
|
|
313431
313649
|
const start = Date.now();
|
|
@@ -313440,7 +313658,7 @@ async function waitForProxyHealth(port, timeoutMs = 3e3) {
|
|
|
313440
313658
|
return false;
|
|
313441
313659
|
}
|
|
313442
313660
|
function writePrivateJsonSync(path8, value) {
|
|
313443
|
-
const temporary = `${path8}.tmp.${
|
|
313661
|
+
const temporary = `${path8}.tmp.${randomUUID3()}`;
|
|
313444
313662
|
try {
|
|
313445
313663
|
writeFileSync8(temporary, JSON.stringify(value, null, 2), { mode: 384 });
|
|
313446
313664
|
renameSync3(temporary, path8);
|
|
@@ -317458,6 +317676,6 @@ js-sha3/src/sha3.js:
|
|
|
317458
317676
|
*)
|
|
317459
317677
|
|
|
317460
317678
|
axios/dist/node/axios.cjs:
|
|
317461
|
-
(*! Axios v1.21.
|
|
317679
|
+
(*! Axios v1.21.1 Copyright (c) 2026 Matt Zabriskie and contributors *)
|
|
317462
317680
|
*/
|
|
317463
317681
|
//# sourceMappingURL=cli.js.map
|