@hyperbridge/sdk 2.7.2 → 2.8.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/dist/browser/index.d.ts +524 -407
- package/dist/browser/index.js +178 -50
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +178 -48
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +3 -3
- package/dist/node/index.d.ts +3 -3
- package/dist/node/index.js +178 -50
- package/dist/node/index.js.map +1 -1
- package/dist/node/{IntentGatewayV2-MxUcNZNs.d.cts → intents-helpers-D_km9I2f.d.cts} +1943 -242
- package/dist/node/{IntentGatewayV2-MxUcNZNs.d.ts → intents-helpers-D_km9I2f.d.ts} +1943 -242
- package/dist/node/intents-helpers.cjs +124 -19
- package/dist/node/intents-helpers.cjs.map +1 -1
- package/dist/node/intents-helpers.d.cts +3 -1506
- package/dist/node/intents-helpers.d.ts +3 -1506
- package/dist/node/intents-helpers.js +122 -21
- package/dist/node/intents-helpers.js.map +1 -1
- package/package.json +1 -1
package/dist/node/index.cjs
CHANGED
|
@@ -2699,13 +2699,26 @@ var chainConfigs = {
|
|
|
2699
2699
|
tokenDecimals: {
|
|
2700
2700
|
USDC: 6,
|
|
2701
2701
|
USDT: 6,
|
|
2702
|
-
cNGN: 6
|
|
2702
|
+
cNGN: 6,
|
|
2703
|
+
ZARP: 18,
|
|
2704
|
+
EURC: 6,
|
|
2705
|
+
XSGD: 6,
|
|
2706
|
+
TRYB: 6,
|
|
2707
|
+
USDR: 6
|
|
2703
2708
|
},
|
|
2704
2709
|
tokenStorageSlots: {
|
|
2705
2710
|
USDT: { balanceSlot: 2, allowanceSlot: 5 },
|
|
2706
2711
|
USDC: { balanceSlot: 9, allowanceSlot: 10 },
|
|
2707
2712
|
WETH: { balanceSlot: 3, allowanceSlot: 4 },
|
|
2708
|
-
DAI: { balanceSlot: 0, allowanceSlot: 0 }
|
|
2713
|
+
DAI: { balanceSlot: 0, allowanceSlot: 0 },
|
|
2714
|
+
cNGN: { balanceSlot: 201, allowanceSlot: 202 },
|
|
2715
|
+
// custom upgradeable layout
|
|
2716
|
+
ZARP: { balanceSlot: 51, allowanceSlot: 52 },
|
|
2717
|
+
EURC: { balanceSlot: 9, allowanceSlot: 10 },
|
|
2718
|
+
// Circle FiatToken layout
|
|
2719
|
+
XSGD: { balanceSlot: 7, allowanceSlot: 8 },
|
|
2720
|
+
TRYB: { balanceSlot: 9, allowanceSlot: 10 },
|
|
2721
|
+
USDR: { balanceSlot: 51, allowanceSlot: 52 }
|
|
2709
2722
|
},
|
|
2710
2723
|
addresses: {
|
|
2711
2724
|
IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
|
|
@@ -2885,13 +2898,22 @@ var chainConfigs = {
|
|
|
2885
2898
|
USDC: 6,
|
|
2886
2899
|
USDT: 6,
|
|
2887
2900
|
cNGN: 6,
|
|
2888
|
-
EXT: 18
|
|
2901
|
+
EXT: 18,
|
|
2902
|
+
ZARP: 18,
|
|
2903
|
+
EURC: 6,
|
|
2904
|
+
USDR: 6
|
|
2889
2905
|
},
|
|
2890
2906
|
tokenStorageSlots: {
|
|
2891
2907
|
USDT: { balanceSlot: 0, allowanceSlot: 1 },
|
|
2892
2908
|
USDC: { balanceSlot: 9, allowanceSlot: 10 },
|
|
2893
2909
|
WETH: { balanceSlot: 3, allowanceSlot: 4 },
|
|
2894
|
-
DAI: { balanceSlot: 0, allowanceSlot: 0 }
|
|
2910
|
+
DAI: { balanceSlot: 0, allowanceSlot: 0 },
|
|
2911
|
+
cNGN: { balanceSlot: 201, allowanceSlot: 202 },
|
|
2912
|
+
// custom upgradeable layout
|
|
2913
|
+
ZARP: { balanceSlot: 51, allowanceSlot: 52 },
|
|
2914
|
+
EURC: { balanceSlot: 9, allowanceSlot: 10 },
|
|
2915
|
+
// Circle FiatToken layout
|
|
2916
|
+
USDR: { balanceSlot: 51, allowanceSlot: 52 }
|
|
2895
2917
|
},
|
|
2896
2918
|
addresses: {
|
|
2897
2919
|
IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
|
|
@@ -2952,13 +2974,21 @@ var chainConfigs = {
|
|
|
2952
2974
|
USDC: 6,
|
|
2953
2975
|
USDT: 6,
|
|
2954
2976
|
EXT: 18,
|
|
2955
|
-
cNGN: 6
|
|
2977
|
+
cNGN: 6,
|
|
2978
|
+
ZARP: 18,
|
|
2979
|
+
XSGD: 6,
|
|
2980
|
+
USDR: 6
|
|
2956
2981
|
},
|
|
2957
2982
|
tokenStorageSlots: {
|
|
2958
2983
|
USDT: { balanceSlot: 0, allowanceSlot: 1 },
|
|
2959
2984
|
USDC: { balanceSlot: 9, allowanceSlot: 10 },
|
|
2960
2985
|
WETH: { balanceSlot: 3, allowanceSlot: 4 },
|
|
2961
|
-
DAI: { balanceSlot: 0, allowanceSlot: 0 }
|
|
2986
|
+
DAI: { balanceSlot: 0, allowanceSlot: 0 },
|
|
2987
|
+
cNGN: { balanceSlot: 201, allowanceSlot: 202 },
|
|
2988
|
+
// custom upgradeable layout
|
|
2989
|
+
ZARP: { balanceSlot: 51, allowanceSlot: 52 },
|
|
2990
|
+
XSGD: { balanceSlot: 7, allowanceSlot: 8 },
|
|
2991
|
+
USDR: { balanceSlot: 51, allowanceSlot: 52 }
|
|
2962
2992
|
},
|
|
2963
2993
|
addresses: {
|
|
2964
2994
|
IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
|
|
@@ -3259,8 +3289,9 @@ var chainConfigs = {
|
|
|
3259
3289
|
assets: {
|
|
3260
3290
|
WETH: "0x0000000000000000000000000000000000000000",
|
|
3261
3291
|
DAI: "0x0000000000000000000000000000000000000000",
|
|
3292
|
+
// Asset Hub assets at their asset-id precompile addresses: 0x539 = 1337, 0x7c0 = 1984.
|
|
3262
3293
|
USDC: "0x0000053900000000000000000000000001200000",
|
|
3263
|
-
USDT: "
|
|
3294
|
+
USDT: "0x000007c000000000000000000000000001200000"
|
|
3264
3295
|
},
|
|
3265
3296
|
tokenDecimals: {
|
|
3266
3297
|
USDC: 6,
|
|
@@ -4852,6 +4883,24 @@ var ABI3 = [
|
|
|
4852
4883
|
internalType: "uint256"
|
|
4853
4884
|
}
|
|
4854
4885
|
]
|
|
4886
|
+
},
|
|
4887
|
+
{
|
|
4888
|
+
name: "predispatchCall",
|
|
4889
|
+
type: "bytes",
|
|
4890
|
+
indexed: false,
|
|
4891
|
+
internalType: "bytes"
|
|
4892
|
+
},
|
|
4893
|
+
{
|
|
4894
|
+
name: "outputCall",
|
|
4895
|
+
type: "bytes",
|
|
4896
|
+
indexed: false,
|
|
4897
|
+
internalType: "bytes"
|
|
4898
|
+
},
|
|
4899
|
+
{
|
|
4900
|
+
name: "graffiti",
|
|
4901
|
+
type: "bytes32",
|
|
4902
|
+
indexed: false,
|
|
4903
|
+
internalType: "bytes32"
|
|
4855
4904
|
}
|
|
4856
4905
|
],
|
|
4857
4906
|
anonymous: false
|
|
@@ -7899,15 +7948,25 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
|
|
|
7899
7948
|
/**
|
|
7900
7949
|
* Signs and sends an extrinsic. Submissions are serialised through {@link submissionQueue} so
|
|
7901
7950
|
* concurrent calls never collide on the substrate account nonce — each extrinsic reaches a block
|
|
7902
|
-
* before the next is signed
|
|
7951
|
+
* (or is confirmed still pooled and returned as `pending`) before the next is signed; auto-nonce
|
|
7952
|
+
* via `system.accountNextIndex` counts pooled extrinsics, so a pending one is never re-used.
|
|
7903
7953
|
*/
|
|
7904
7954
|
async signAndSendExtrinsic(extrinsic, maxRetries = 3, timeoutMs = 3e4) {
|
|
7905
|
-
const result = await this.submissionQueue.add(
|
|
7955
|
+
const result = await this.submissionQueue.add(
|
|
7956
|
+
() => this.sendExtrinsicWithRetries(extrinsic, maxRetries, timeoutMs)
|
|
7957
|
+
);
|
|
7906
7958
|
return result ?? { success: false, error: "Submission queue returned no result" };
|
|
7907
7959
|
}
|
|
7908
7960
|
/**
|
|
7909
7961
|
* Signs and sends an extrinsic, handling status updates and errors.
|
|
7910
7962
|
* Implements retry logic with progressive tip increases for stuck transactions.
|
|
7963
|
+
*
|
|
7964
|
+
* A retry only happens when the previous attempt verifiably went nowhere. Once an attempt's
|
|
7965
|
+
* extrinsic is known to be pooled (`pending`), re-signing the same call would race our own
|
|
7966
|
+
* submission: the copy either bounces off the pool (1014, same nonce below the replacement
|
|
7967
|
+
* priority bump) or — if the original lands first, freeing the nonce — executes as a duplicate
|
|
7968
|
+
* and fails on-chain (e.g. `BidNotFound` for a retraction). Neither can succeed, so the pending
|
|
7969
|
+
* result is returned for the caller to confirm later.
|
|
7911
7970
|
*/
|
|
7912
7971
|
async sendExtrinsicWithRetries(extrinsic, maxRetries, timeoutMs) {
|
|
7913
7972
|
const keyPair = this.getKeyPair();
|
|
@@ -7918,7 +7977,7 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
|
|
|
7918
7977
|
attempt++;
|
|
7919
7978
|
try {
|
|
7920
7979
|
const result = await this.sendWithTimeout(extrinsic, keyPair, currentTip, timeoutMs);
|
|
7921
|
-
if (result.success || result.error?.includes("Dispatch error")) {
|
|
7980
|
+
if (result.success || result.pending || result.error?.includes("Dispatch error")) {
|
|
7922
7981
|
return result;
|
|
7923
7982
|
}
|
|
7924
7983
|
} catch (err) {
|
|
@@ -7934,12 +7993,30 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
|
|
|
7934
7993
|
};
|
|
7935
7994
|
}
|
|
7936
7995
|
/**
|
|
7937
|
-
*
|
|
7996
|
+
* Classifies a submission rejection. Codes 1013 ("already imported") and 1014 ("priority is
|
|
7997
|
+
* too low") both mean a copy of this account+nonce is already in the pool — almost always our
|
|
7998
|
+
* own earlier attempt whose watch handle didn't confirm cleanly. That extrinsic is in flight;
|
|
7999
|
+
* resubmitting can only bounce again or land a duplicate, so these are surfaced as `pending`
|
|
8000
|
+
* rather than failure.
|
|
8001
|
+
*/
|
|
8002
|
+
classifySubmissionError(err) {
|
|
8003
|
+
const code = err.code;
|
|
8004
|
+
const inFlight = code === 1013 || code === 1014 || /already imported|already in the pool|priority is too low/i.test(err.message);
|
|
8005
|
+
return { success: false, pending: inFlight || void 0, error: err.message };
|
|
8006
|
+
}
|
|
8007
|
+
/**
|
|
8008
|
+
* Sends an extrinsic with a timeout.
|
|
8009
|
+
*
|
|
8010
|
+
* A timeout is only a failure when the extrinsic never made it into the transaction pool.
|
|
8011
|
+
* Once a pool-entry status (Future/Ready/Broadcast/Retracted) has been seen, the extrinsic is
|
|
8012
|
+
* in flight and may well execute after the watch is abandoned — the result is then `pending`,
|
|
8013
|
+
* telling the caller to confirm the outcome later instead of re-signing the same call.
|
|
7938
8014
|
*/
|
|
7939
8015
|
async sendWithTimeout(extrinsic, keyPair, tip, timeoutMs) {
|
|
7940
8016
|
return new Promise((resolve) => {
|
|
7941
8017
|
let resolved = false;
|
|
7942
8018
|
let unsubscribe = null;
|
|
8019
|
+
let enteredPool = false;
|
|
7943
8020
|
const timeoutId = setTimeout(() => {
|
|
7944
8021
|
if (!resolved) {
|
|
7945
8022
|
resolved = true;
|
|
@@ -7948,12 +8025,17 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
|
|
|
7948
8025
|
}
|
|
7949
8026
|
resolve({
|
|
7950
8027
|
success: false,
|
|
7951
|
-
|
|
8028
|
+
pending: enteredPool || void 0,
|
|
8029
|
+
extrinsicHash: enteredPool ? extrinsic.hash.toHex() : void 0,
|
|
8030
|
+
error: `Transaction timed out after ${timeoutMs}ms${enteredPool ? " while in the transaction pool" : ""}`
|
|
7952
8031
|
});
|
|
7953
8032
|
}
|
|
7954
8033
|
}, timeoutMs);
|
|
7955
8034
|
extrinsic.signAndSend(keyPair, { tip }, (result) => {
|
|
7956
8035
|
if (resolved) return;
|
|
8036
|
+
if (result.status.isFuture || result.status.isReady || result.status.isBroadcast || result.status.isRetracted) {
|
|
8037
|
+
enteredPool = true;
|
|
8038
|
+
}
|
|
7957
8039
|
if (result.dispatchError && (result.status.isInBlock || result.status.isFinalized)) {
|
|
7958
8040
|
resolved = true;
|
|
7959
8041
|
clearTimeout(timeoutId);
|
|
@@ -8011,7 +8093,7 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
|
|
|
8011
8093
|
if (!resolved) {
|
|
8012
8094
|
resolved = true;
|
|
8013
8095
|
clearTimeout(timeoutId);
|
|
8014
|
-
resolve(
|
|
8096
|
+
resolve(this.classifySubmissionError(err));
|
|
8015
8097
|
}
|
|
8016
8098
|
});
|
|
8017
8099
|
});
|
|
@@ -8185,9 +8267,7 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
|
|
|
8185
8267
|
if (!result || result.isNone) return null;
|
|
8186
8268
|
const rawHex = result.unwrap().toHex();
|
|
8187
8269
|
if (rawHex === "0x" || rawHex === "0x00") return null;
|
|
8188
|
-
const placeOrderAbi = IntentGatewayV2_default.ABI.find(
|
|
8189
|
-
(item) => item.type === "function" && item.name === "placeOrder"
|
|
8190
|
-
);
|
|
8270
|
+
const placeOrderAbi = IntentGatewayV2_default.ABI.find((item) => item.type === "function" && item.name === "placeOrder");
|
|
8191
8271
|
const orderType = placeOrderAbi?.inputs?.[0];
|
|
8192
8272
|
if (!orderType) return null;
|
|
8193
8273
|
const [decoded] = viem.decodeAbiParameters([orderType], rawHex);
|
|
@@ -8233,14 +8313,17 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
|
|
|
8233
8313
|
const orders = [];
|
|
8234
8314
|
for (const { event } of records) {
|
|
8235
8315
|
if (event.section !== "intentsCoprocessor" || event.method !== "PhantomOrderRegistered") continue;
|
|
8236
|
-
const [commitment, chain, createdAt,
|
|
8316
|
+
const [commitment, chain, createdAt, legs] = event.data;
|
|
8237
8317
|
orders.push({
|
|
8238
8318
|
commitment: commitment.toHex(),
|
|
8239
8319
|
chain: new TextDecoder().decode(util.hexToU8a(chain.toHex())),
|
|
8240
8320
|
createdAt: createdAt.toNumber(),
|
|
8241
|
-
|
|
8242
|
-
|
|
8243
|
-
|
|
8321
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8322
|
+
legs: legs.map((leg) => ({
|
|
8323
|
+
tokenA: leg.tokenA.toHex(),
|
|
8324
|
+
tokenB: leg.tokenB.toHex(),
|
|
8325
|
+
standardAmount: BigInt(leg.standardAmount.toString())
|
|
8326
|
+
}))
|
|
8244
8327
|
});
|
|
8245
8328
|
}
|
|
8246
8329
|
return orders;
|
|
@@ -15536,13 +15619,13 @@ function deriveCanonicalPlacedOrder(order, args) {
|
|
|
15536
15619
|
session: args.session,
|
|
15537
15620
|
predispatch: {
|
|
15538
15621
|
assets: args.predispatch.map((asset) => ({ ...asset })),
|
|
15539
|
-
call: order.predispatch.call
|
|
15622
|
+
call: args.predispatchCall ?? order.predispatch.call
|
|
15540
15623
|
},
|
|
15541
15624
|
inputs: args.inputs.map((asset) => ({ ...asset })),
|
|
15542
15625
|
output: {
|
|
15543
15626
|
beneficiary: args.beneficiary,
|
|
15544
15627
|
assets: args.outputs.map((asset) => ({ ...asset })),
|
|
15545
|
-
call: order.output.call
|
|
15628
|
+
call: args.outputCall ?? order.output.call
|
|
15546
15629
|
}
|
|
15547
15630
|
};
|
|
15548
15631
|
return { ...canonicalOrder, id: orderCommitment(canonicalOrder) };
|
|
@@ -16973,14 +17056,14 @@ var BidManager = class {
|
|
|
16973
17056
|
}
|
|
16974
17057
|
/**
|
|
16975
17058
|
* Autopilot bid selection: sorts the given bids by output value, simulates
|
|
16976
|
-
* each in order
|
|
16977
|
-
*
|
|
17059
|
+
* each in order and attempts execution. Any bid that fails simulation or
|
|
17060
|
+
* execution is skipped once so the next ranked bid can be attempted in the
|
|
17061
|
+
* same round. For consumers that do not need custom selection logic.
|
|
16978
17062
|
*
|
|
16979
17063
|
* @param order - The placed order to fill.
|
|
16980
17064
|
* @param bids - Candidate bids (from {@link buildBids}).
|
|
16981
17065
|
* @returns A {@link SelectBidResult} for the executed bid.
|
|
16982
|
-
* @throws If no valid bids exist
|
|
16983
|
-
* the UserOperation.
|
|
17066
|
+
* @throws If no valid bids exist or every bid fails simulation/execution.
|
|
16984
17067
|
*/
|
|
16985
17068
|
async selectAndExecuteBest(order, bids) {
|
|
16986
17069
|
const commitment = order.id;
|
|
@@ -16997,22 +17080,34 @@ var BidManager = class {
|
|
|
16997
17080
|
throw new Error("No valid bids found");
|
|
16998
17081
|
}
|
|
16999
17082
|
console.log(`[BidManager] Simulating ${sortedBids.length} sorted bid(s) to find a valid one`);
|
|
17083
|
+
let simulationFailures = 0;
|
|
17084
|
+
let executionFailures = 0;
|
|
17000
17085
|
for (let idx = 0; idx < sortedBids.length; idx++) {
|
|
17001
17086
|
const bid = sortedBids[idx];
|
|
17002
17087
|
console.log(`[BidManager] Simulating bid ${idx + 1}/${sortedBids.length} from solver=${bid.solverAddress}`);
|
|
17003
17088
|
try {
|
|
17004
17089
|
await bid.simulate();
|
|
17005
17090
|
} catch (err) {
|
|
17091
|
+
simulationFailures += 1;
|
|
17006
17092
|
console.warn(
|
|
17007
17093
|
`[BidManager] Bid ${idx + 1} from solver=${bid.solverAddress}: simulation FAILED: ${err instanceof Error ? err.message : String(err)}`
|
|
17008
17094
|
);
|
|
17009
17095
|
continue;
|
|
17010
17096
|
}
|
|
17011
17097
|
console.log(`[BidManager] Bid ${idx + 1} from solver=${bid.solverAddress}: simulation PASSED`);
|
|
17012
|
-
|
|
17098
|
+
try {
|
|
17099
|
+
return await bid.execute();
|
|
17100
|
+
} catch (err) {
|
|
17101
|
+
executionFailures += 1;
|
|
17102
|
+
console.warn(
|
|
17103
|
+
`[BidManager] Bid ${idx + 1} from solver=${bid.solverAddress}: execution FAILED: ${err instanceof Error ? err.message : String(err)}; trying next bid`
|
|
17104
|
+
);
|
|
17105
|
+
}
|
|
17013
17106
|
}
|
|
17014
|
-
console.error(
|
|
17015
|
-
|
|
17107
|
+
console.error(
|
|
17108
|
+
`[BidManager] No executable bids for commitment=${commitment}: ${simulationFailures} simulation failure(s), ${executionFailures} execution failure(s)`
|
|
17109
|
+
);
|
|
17110
|
+
throw new Error("No bids passed simulation and execution");
|
|
17016
17111
|
}
|
|
17017
17112
|
/**
|
|
17018
17113
|
* Sorts a list of bids for the given order by output value.
|
|
@@ -17352,6 +17447,10 @@ var BidManager = class {
|
|
|
17352
17447
|
}
|
|
17353
17448
|
};
|
|
17354
17449
|
var RELAYER_MESSAGE_GAS = 1000000n;
|
|
17450
|
+
var NO_BUNDLER_FILL_GAS_BASE = 700000n;
|
|
17451
|
+
var NO_BUNDLER_FILL_GAS_PER_OUTPUT = 150000n;
|
|
17452
|
+
var NO_BUNDLER_PAYMASTER_VERIFICATION_GAS = 250000n;
|
|
17453
|
+
var NO_BUNDLER_PAYMASTER_POST_OP_GAS = 100000n;
|
|
17355
17454
|
var GasEstimator = class {
|
|
17356
17455
|
/**
|
|
17357
17456
|
* @param ctx - Shared IntentsV2 context providing the source and destination
|
|
@@ -17385,8 +17484,10 @@ var GasEstimator = class {
|
|
|
17385
17484
|
* headroom. If the bundler is Pimlico, gas prices are refined with
|
|
17386
17485
|
* `pimlico_getUserOperationGasPrice`.
|
|
17387
17486
|
*
|
|
17388
|
-
* **Fallback path (no bundler):**
|
|
17389
|
-
*
|
|
17487
|
+
* **Fallback path (no bundler):** uses a fixed budget
|
|
17488
|
+
* ({@link NO_BUNDLER_FILL_GAS_BASE} plus {@link NO_BUNDLER_FILL_GAS_PER_OUTPUT}
|
|
17489
|
+
* per output leg) — public RPCs don't reliably support estimation with
|
|
17490
|
+
* state overrides.
|
|
17390
17491
|
*
|
|
17391
17492
|
* @param params - Parameters including the order to estimate and optional
|
|
17392
17493
|
* percentage bumps for `maxPriorityFeePerGas` and `maxFeePerGas`.
|
|
@@ -17421,14 +17522,14 @@ var GasEstimator = class {
|
|
|
17421
17522
|
}
|
|
17422
17523
|
const isSameChain = souceStateMachineId === destStateMachineId;
|
|
17423
17524
|
const [stateOverridesResult, crossChainFees] = await Promise.all([
|
|
17424
|
-
this.buildStateOverride({
|
|
17525
|
+
this.ctx.bundlerUrl ? this.buildStateOverride({
|
|
17425
17526
|
accountAddress: solverAccountAddress,
|
|
17426
17527
|
chain: destStateMachineId,
|
|
17427
17528
|
outputAssets: assetsForOverrides,
|
|
17428
17529
|
spenderAddress: intentGatewayV2Address,
|
|
17429
17530
|
intentGatewayV2Address,
|
|
17430
17531
|
entryPointAddress
|
|
17431
|
-
}),
|
|
17532
|
+
}) : Promise.resolve({ viem: [], bundler: {} }),
|
|
17432
17533
|
isSameChain ? Promise.resolve({ postRequestFee: 0n, relayerFeeInSourceFeeToken: 0n }) : this.estimateCrossChainFees(
|
|
17433
17534
|
sourceFeeToken,
|
|
17434
17535
|
destFeeToken,
|
|
@@ -17436,7 +17537,7 @@ var GasEstimator = class {
|
|
|
17436
17537
|
orderFeeGasPriceBumpPercent
|
|
17437
17538
|
)
|
|
17438
17539
|
]);
|
|
17439
|
-
const {
|
|
17540
|
+
const { bundler: bundlerStateOverrides } = stateOverridesResult;
|
|
17440
17541
|
const fillOptions = {
|
|
17441
17542
|
relayerFee: crossChainFees.postRequestFee,
|
|
17442
17543
|
// Always dispatch with the fee token (see the method docs).
|
|
@@ -17577,20 +17678,9 @@ var GasEstimator = class {
|
|
|
17577
17678
|
console.warn("Bundler gas estimation failed, using fallback values:", e);
|
|
17578
17679
|
}
|
|
17579
17680
|
} else {
|
|
17580
|
-
|
|
17581
|
-
|
|
17582
|
-
|
|
17583
|
-
address: intentGatewayV2Address,
|
|
17584
|
-
functionName: "fillOrder",
|
|
17585
|
-
args: [transformOrderForContract(order), fillOptions],
|
|
17586
|
-
account: solverAccountAddress,
|
|
17587
|
-
value: totalNativeValue,
|
|
17588
|
-
stateOverride: stateOverrides
|
|
17589
|
-
});
|
|
17590
|
-
callGasLimit = estimatedGas * 105n / 100n;
|
|
17591
|
-
} catch (e) {
|
|
17592
|
-
console.warn("fillOrder gas estimation failed, using fallback:", e);
|
|
17593
|
-
}
|
|
17681
|
+
callGasLimit = NO_BUNDLER_FILL_GAS_BASE + NO_BUNDLER_FILL_GAS_PER_OUTPUT * BigInt(order.output.assets.length);
|
|
17682
|
+
paymasterVerificationGasLimit = NO_BUNDLER_PAYMASTER_VERIFICATION_GAS;
|
|
17683
|
+
paymasterPostOpGasLimit = NO_BUNDLER_PAYMASTER_POST_OP_GAS;
|
|
17594
17684
|
}
|
|
17595
17685
|
const totalGas = callGasLimit + verificationGasLimit + preVerificationGas + paymasterVerificationGasLimit + paymasterPostOpGasLimit;
|
|
17596
17686
|
const rawTotalGasCostWei = totalGas * maxFeePerGas;
|
|
@@ -19120,6 +19210,44 @@ var IntentGateway = class _IntentGateway {
|
|
|
19120
19210
|
}
|
|
19121
19211
|
}
|
|
19122
19212
|
};
|
|
19213
|
+
var FILL_ORDER_ABI = IntentGatewayV2_default.ABI;
|
|
19214
|
+
var DECLARATION_VERSION = 1;
|
|
19215
|
+
var MAX_DECLARED_CHAINS = 255;
|
|
19216
|
+
function encodeAcceptedSourceChains(chains2) {
|
|
19217
|
+
if (chains2.length > MAX_DECLARED_CHAINS) {
|
|
19218
|
+
throw new Error(`Cannot declare more than ${MAX_DECLARED_CHAINS} source chains`);
|
|
19219
|
+
}
|
|
19220
|
+
const bytes = [DECLARATION_VERSION, chains2.length];
|
|
19221
|
+
for (const chain of chains2) {
|
|
19222
|
+
const encoded = util.stringToU8a(chain);
|
|
19223
|
+
if (encoded.length === 0 || encoded.length > 255) {
|
|
19224
|
+
throw new Error(`Invalid state machine id in source chain declaration: ${chain}`);
|
|
19225
|
+
}
|
|
19226
|
+
bytes.push(encoded.length, ...encoded);
|
|
19227
|
+
}
|
|
19228
|
+
return util.u8aToHex(new Uint8Array(bytes));
|
|
19229
|
+
}
|
|
19230
|
+
function decodeAcceptedSourceChains(paymasterAndData) {
|
|
19231
|
+
if (!paymasterAndData || !util.isHex(paymasterAndData)) return null;
|
|
19232
|
+
const bytes = util.hexToU8a(paymasterAndData);
|
|
19233
|
+
if (bytes.length < 2 || bytes[0] !== DECLARATION_VERSION) return null;
|
|
19234
|
+
const count = bytes[1];
|
|
19235
|
+
const chains2 = [];
|
|
19236
|
+
let offset = 2;
|
|
19237
|
+
for (let entry = 0; entry < count; entry++) {
|
|
19238
|
+
if (offset >= bytes.length) return null;
|
|
19239
|
+
const length = bytes[offset];
|
|
19240
|
+
offset += 1;
|
|
19241
|
+
if (length === 0 || offset + length > bytes.length) return null;
|
|
19242
|
+
chains2.push(util.u8aToString(bytes.subarray(offset, offset + length)));
|
|
19243
|
+
offset += length;
|
|
19244
|
+
}
|
|
19245
|
+
if (offset !== bytes.length) return null;
|
|
19246
|
+
return chains2;
|
|
19247
|
+
}
|
|
19248
|
+
FILL_ORDER_ABI.find(
|
|
19249
|
+
(item) => item?.type === "function" && item?.name === "fillOrder"
|
|
19250
|
+
)?.inputs?.[0];
|
|
19123
19251
|
var TokenGateway = class {
|
|
19124
19252
|
source;
|
|
19125
19253
|
dest;
|
|
@@ -23659,8 +23787,10 @@ exports.convertStateMachineEnumToString = convertStateMachineEnumToString;
|
|
|
23659
23787
|
exports.convertStateMachineIdToEnum = convertStateMachineIdToEnum;
|
|
23660
23788
|
exports.createEvmChain = createEvmChain;
|
|
23661
23789
|
exports.createQueryClient = createQueryClient;
|
|
23790
|
+
exports.decodeAcceptedSourceChains = decodeAcceptedSourceChains;
|
|
23662
23791
|
exports.decodeERC7821ExecuteBatch = decodeERC7821ExecuteBatch;
|
|
23663
23792
|
exports.decodeUserOpScale = decodeUserOpScale;
|
|
23793
|
+
exports.encodeAcceptedSourceChains = encodeAcceptedSourceChains;
|
|
23664
23794
|
exports.encodeERC7821ExecuteBatch = encodeERC7821ExecuteBatch;
|
|
23665
23795
|
exports.encodeISMPMessage = encodeISMPMessage;
|
|
23666
23796
|
exports.encodeStateMachineId = encodeStateMachineId;
|