@towns-labs/relayer 2.0.13 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/README.md +1 -1
- package/dist/index.js +33 -27
- package/dist/index.js.map +3 -3
- package/package.json +2 -2
- package/src/rpc/schema/intentTypes.ts +27 -0
- package/src/rpc/schema/prepareCalls.ts +1 -0
package/dist/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
This folder contains the built output assets for the worker "relayer-worker" generated at 2026-02-
|
|
1
|
+
This folder contains the built output assets for the worker "relayer-worker" generated at 2026-02-13T08:35:58.863Z.
|
package/dist/index.js
CHANGED
|
@@ -23801,7 +23801,7 @@ function isEip7702Delegated(code) {
|
|
|
23801
23801
|
}
|
|
23802
23802
|
__name(isEip7702Delegated, "isEip7702Delegated");
|
|
23803
23803
|
|
|
23804
|
-
// src/
|
|
23804
|
+
// src/rpc/schema/intentTypes.ts
|
|
23805
23805
|
var INTENT_TYPES = {
|
|
23806
23806
|
Intent: [
|
|
23807
23807
|
{ name: "multichain", type: "bool" },
|
|
@@ -23823,6 +23823,8 @@ var INTENT_TYPES = {
|
|
|
23823
23823
|
{ name: "data", type: "bytes" }
|
|
23824
23824
|
]
|
|
23825
23825
|
};
|
|
23826
|
+
|
|
23827
|
+
// src/services/relayer.ts
|
|
23826
23828
|
function createIntentNonceProvider(durableObject, chainId) {
|
|
23827
23829
|
const durableObjectNameFor = /* @__PURE__ */ __name((eoa) => `${chainId}:${eoa.toLowerCase()}`, "durableObjectNameFor");
|
|
23828
23830
|
return {
|
|
@@ -23953,6 +23955,26 @@ var DEFAULT_GAS_CONFIG = {
|
|
|
23953
23955
|
txGasBuffer: 0n,
|
|
23954
23956
|
allowSimulationFallback: false
|
|
23955
23957
|
};
|
|
23958
|
+
var DEFAULT_INTENT_EXPIRY_SECONDS = 3600n;
|
|
23959
|
+
var MAX_INTENT_EXPIRY_SECONDS_FROM_NOW = 365n * 24n * 60n * 60n;
|
|
23960
|
+
var MILLISECONDS_EPOCH_THRESHOLD = 1000000000000n;
|
|
23961
|
+
function resolveIntentExpirySeconds(rawExpiry, nowSeconds = BigInt(Math.floor(Date.now() / 1e3))) {
|
|
23962
|
+
if (!rawExpiry) {
|
|
23963
|
+
return nowSeconds + DEFAULT_INTENT_EXPIRY_SECONDS;
|
|
23964
|
+
}
|
|
23965
|
+
const expiry = BigInt(rawExpiry);
|
|
23966
|
+
const maxSupportedExpiry = nowSeconds + MAX_INTENT_EXPIRY_SECONDS_FROM_NOW;
|
|
23967
|
+
if (expiry > maxSupportedExpiry) {
|
|
23968
|
+
if (expiry >= MILLISECONDS_EPOCH_THRESHOLD) {
|
|
23969
|
+
throw new Error(
|
|
23970
|
+
`Invalid expiry: ${rawExpiry} appears to be milliseconds; use unix seconds`
|
|
23971
|
+
);
|
|
23972
|
+
}
|
|
23973
|
+
throw new Error(`Invalid expiry: ${rawExpiry} is too far in the future`);
|
|
23974
|
+
}
|
|
23975
|
+
return expiry;
|
|
23976
|
+
}
|
|
23977
|
+
__name(resolveIntentExpirySeconds, "resolveIntentExpirySeconds");
|
|
23956
23978
|
function isPaymentEnabled(payer, paymentToken) {
|
|
23957
23979
|
return payer !== zeroAddress && paymentToken !== zeroAddress;
|
|
23958
23980
|
}
|
|
@@ -24137,6 +24159,8 @@ var RelayerService = class {
|
|
|
24137
24159
|
],
|
|
24138
24160
|
[calls]
|
|
24139
24161
|
);
|
|
24162
|
+
const nowSeconds = BigInt(Math.floor(Date.now() / 1e3));
|
|
24163
|
+
const expiry = resolveIntentExpirySeconds(request.expiry, nowSeconds);
|
|
24140
24164
|
const intent = {
|
|
24141
24165
|
eoa: request.eoa,
|
|
24142
24166
|
executionData,
|
|
@@ -24149,7 +24173,7 @@ var RelayerService = class {
|
|
|
24149
24173
|
encodedPreCalls: request.encodedPreCalls ?? [],
|
|
24150
24174
|
encodedFundTransfers: request.encodedFundTransfers ?? [],
|
|
24151
24175
|
settler: request.settler ?? zeroAddress,
|
|
24152
|
-
expiry
|
|
24176
|
+
expiry,
|
|
24153
24177
|
isMultichain: request.isMultichain ?? false,
|
|
24154
24178
|
funder: request.funder ?? zeroAddress,
|
|
24155
24179
|
funderSignature: request.funderSignature ?? "0x",
|
|
@@ -24273,7 +24297,8 @@ var RelayerService = class {
|
|
|
24273
24297
|
return { success: false, error: nonceResult.error };
|
|
24274
24298
|
}
|
|
24275
24299
|
const nonce = nonceResult.nonce;
|
|
24276
|
-
const
|
|
24300
|
+
const nowSeconds = BigInt(Math.floor(Date.now() / 1e3));
|
|
24301
|
+
const expiry = resolveIntentExpirySeconds(request.expiry, nowSeconds);
|
|
24277
24302
|
const encodedPreCalls = request.encodedPreCalls ?? [];
|
|
24278
24303
|
const encodedFundTransfers = request.encodedFundTransfers ?? [];
|
|
24279
24304
|
const settler = request.settler ?? zeroAddress;
|
|
@@ -24557,30 +24582,9 @@ function hashQuotes(signedQuotes, config2) {
|
|
|
24557
24582
|
settler: quote.intent.settler ?? zeroAddress,
|
|
24558
24583
|
expiry: BigInt(quote.intent.expiry || "0")
|
|
24559
24584
|
};
|
|
24560
|
-
const INTENT_TYPES_FOR_HASH = {
|
|
24561
|
-
Intent: [
|
|
24562
|
-
{ name: "multichain", type: "bool" },
|
|
24563
|
-
{ name: "eoa", type: "address" },
|
|
24564
|
-
{ name: "calls", type: "Call[]" },
|
|
24565
|
-
{ name: "nonce", type: "uint256" },
|
|
24566
|
-
{ name: "payer", type: "address" },
|
|
24567
|
-
{ name: "paymentToken", type: "address" },
|
|
24568
|
-
{ name: "paymentMaxAmount", type: "uint256" },
|
|
24569
|
-
{ name: "combinedGas", type: "uint256" },
|
|
24570
|
-
{ name: "encodedPreCalls", type: "bytes[]" },
|
|
24571
|
-
{ name: "encodedFundTransfers", type: "bytes[]" },
|
|
24572
|
-
{ name: "settler", type: "address" },
|
|
24573
|
-
{ name: "expiry", type: "uint256" }
|
|
24574
|
-
],
|
|
24575
|
-
Call: [
|
|
24576
|
-
{ name: "to", type: "address" },
|
|
24577
|
-
{ name: "value", type: "uint256" },
|
|
24578
|
-
{ name: "data", type: "bytes" }
|
|
24579
|
-
]
|
|
24580
|
-
};
|
|
24581
24585
|
const intentDigest = hashTypedData({
|
|
24582
24586
|
domain: domain2,
|
|
24583
|
-
types:
|
|
24587
|
+
types: INTENT_TYPES,
|
|
24584
24588
|
primaryType: "Intent",
|
|
24585
24589
|
message: intentMessage
|
|
24586
24590
|
});
|
|
@@ -24637,7 +24641,7 @@ function extractIntentFromContext(context) {
|
|
|
24637
24641
|
__name(extractIntentFromContext, "extractIntentFromContext");
|
|
24638
24642
|
async function validateQuote(signedQuotes, env) {
|
|
24639
24643
|
const currentTime = Math.floor(Date.now() / 1e3);
|
|
24640
|
-
if (typeof signedQuotes.ttl !== "number" || signedQuotes.ttl
|
|
24644
|
+
if (typeof signedQuotes.ttl !== "number" || signedQuotes.ttl <= currentTime) {
|
|
24641
24645
|
return new RpcError2(
|
|
24642
24646
|
QUOTE_EXPIRED,
|
|
24643
24647
|
`Quote expired at ${signedQuotes.ttl}, current time is ${currentTime}`
|
|
@@ -40053,6 +40057,7 @@ async function handlePrepareCalls(params, ctx) {
|
|
|
40053
40057
|
const nonce = meta3?.nonce;
|
|
40054
40058
|
const seqKey = meta3?.seq_key;
|
|
40055
40059
|
const prepareKey = meta3?.prepare_key;
|
|
40060
|
+
const expiry = meta3?.expiry;
|
|
40056
40061
|
const payer = meta3?.fee_payer;
|
|
40057
40062
|
const paymentToken = meta3?.fee_token;
|
|
40058
40063
|
const paymentMaxAmount = meta3?.fee_max_amount;
|
|
@@ -40071,6 +40076,7 @@ async function handlePrepareCalls(params, ctx) {
|
|
|
40071
40076
|
calls: normalizedCalls,
|
|
40072
40077
|
nonce,
|
|
40073
40078
|
seqKey,
|
|
40079
|
+
expiry,
|
|
40074
40080
|
settler,
|
|
40075
40081
|
payer,
|
|
40076
40082
|
paymentToken,
|
|
@@ -45954,7 +45960,7 @@ var SignerDO = class extends DurableObject {
|
|
|
45954
45960
|
await this.ensureInitialized();
|
|
45955
45961
|
const rows = this.sql.exec(
|
|
45956
45962
|
`
|
|
45957
|
-
SELECT address, paused, last_balance_check, balance_wei
|
|
45963
|
+
SELECT address, chain_id, paused, last_balance_check, balance_wei
|
|
45958
45964
|
FROM signer_state WHERE id = 1
|
|
45959
45965
|
`
|
|
45960
45966
|
).toArray();
|