@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/browser/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { match } from 'ts-pattern';
|
|
|
7
7
|
import { WsProvider, ApiPromise, Keyring } from '@polkadot/api';
|
|
8
8
|
import { Struct, Vector, u8, Bytes, Enum, Tuple, _void, u64, u32, Option, bool, u128 } from 'scale-ts';
|
|
9
9
|
import { keccakAsU8a, decodeAddress, keccakAsHex, xxhashAsU8a, blake2AsU8a } from '@polkadot/util-crypto';
|
|
10
|
-
import { hexToU8a, u8aToHex, u8aConcat } from '@polkadot/util';
|
|
10
|
+
import { hexToU8a, u8aToHex, u8aConcat, stringToU8a, isHex as isHex$1, u8aToString } from '@polkadot/util';
|
|
11
11
|
import PQueue from 'p-queue';
|
|
12
12
|
import { hasWindow, isNode, env } from 'std-env';
|
|
13
13
|
import mergeRace from '@async-generator/merge-race';
|
|
@@ -2738,13 +2738,26 @@ var chainConfigs = {
|
|
|
2738
2738
|
tokenDecimals: {
|
|
2739
2739
|
USDC: 6,
|
|
2740
2740
|
USDT: 6,
|
|
2741
|
-
cNGN: 6
|
|
2741
|
+
cNGN: 6,
|
|
2742
|
+
ZARP: 18,
|
|
2743
|
+
EURC: 6,
|
|
2744
|
+
XSGD: 6,
|
|
2745
|
+
TRYB: 6,
|
|
2746
|
+
USDR: 6
|
|
2742
2747
|
},
|
|
2743
2748
|
tokenStorageSlots: {
|
|
2744
2749
|
USDT: { balanceSlot: 2, allowanceSlot: 5 },
|
|
2745
2750
|
USDC: { balanceSlot: 9, allowanceSlot: 10 },
|
|
2746
2751
|
WETH: { balanceSlot: 3, allowanceSlot: 4 },
|
|
2747
|
-
DAI: { balanceSlot: 0, allowanceSlot: 0 }
|
|
2752
|
+
DAI: { balanceSlot: 0, allowanceSlot: 0 },
|
|
2753
|
+
cNGN: { balanceSlot: 201, allowanceSlot: 202 },
|
|
2754
|
+
// custom upgradeable layout
|
|
2755
|
+
ZARP: { balanceSlot: 51, allowanceSlot: 52 },
|
|
2756
|
+
EURC: { balanceSlot: 9, allowanceSlot: 10 },
|
|
2757
|
+
// Circle FiatToken layout
|
|
2758
|
+
XSGD: { balanceSlot: 7, allowanceSlot: 8 },
|
|
2759
|
+
TRYB: { balanceSlot: 9, allowanceSlot: 10 },
|
|
2760
|
+
USDR: { balanceSlot: 51, allowanceSlot: 52 }
|
|
2748
2761
|
},
|
|
2749
2762
|
addresses: {
|
|
2750
2763
|
IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
|
|
@@ -2924,13 +2937,22 @@ var chainConfigs = {
|
|
|
2924
2937
|
USDC: 6,
|
|
2925
2938
|
USDT: 6,
|
|
2926
2939
|
cNGN: 6,
|
|
2927
|
-
EXT: 18
|
|
2940
|
+
EXT: 18,
|
|
2941
|
+
ZARP: 18,
|
|
2942
|
+
EURC: 6,
|
|
2943
|
+
USDR: 6
|
|
2928
2944
|
},
|
|
2929
2945
|
tokenStorageSlots: {
|
|
2930
2946
|
USDT: { balanceSlot: 0, allowanceSlot: 1 },
|
|
2931
2947
|
USDC: { balanceSlot: 9, allowanceSlot: 10 },
|
|
2932
2948
|
WETH: { balanceSlot: 3, allowanceSlot: 4 },
|
|
2933
|
-
DAI: { balanceSlot: 0, allowanceSlot: 0 }
|
|
2949
|
+
DAI: { balanceSlot: 0, allowanceSlot: 0 },
|
|
2950
|
+
cNGN: { balanceSlot: 201, allowanceSlot: 202 },
|
|
2951
|
+
// custom upgradeable layout
|
|
2952
|
+
ZARP: { balanceSlot: 51, allowanceSlot: 52 },
|
|
2953
|
+
EURC: { balanceSlot: 9, allowanceSlot: 10 },
|
|
2954
|
+
// Circle FiatToken layout
|
|
2955
|
+
USDR: { balanceSlot: 51, allowanceSlot: 52 }
|
|
2934
2956
|
},
|
|
2935
2957
|
addresses: {
|
|
2936
2958
|
IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
|
|
@@ -2991,13 +3013,21 @@ var chainConfigs = {
|
|
|
2991
3013
|
USDC: 6,
|
|
2992
3014
|
USDT: 6,
|
|
2993
3015
|
EXT: 18,
|
|
2994
|
-
cNGN: 6
|
|
3016
|
+
cNGN: 6,
|
|
3017
|
+
ZARP: 18,
|
|
3018
|
+
XSGD: 6,
|
|
3019
|
+
USDR: 6
|
|
2995
3020
|
},
|
|
2996
3021
|
tokenStorageSlots: {
|
|
2997
3022
|
USDT: { balanceSlot: 0, allowanceSlot: 1 },
|
|
2998
3023
|
USDC: { balanceSlot: 9, allowanceSlot: 10 },
|
|
2999
3024
|
WETH: { balanceSlot: 3, allowanceSlot: 4 },
|
|
3000
|
-
DAI: { balanceSlot: 0, allowanceSlot: 0 }
|
|
3025
|
+
DAI: { balanceSlot: 0, allowanceSlot: 0 },
|
|
3026
|
+
cNGN: { balanceSlot: 201, allowanceSlot: 202 },
|
|
3027
|
+
// custom upgradeable layout
|
|
3028
|
+
ZARP: { balanceSlot: 51, allowanceSlot: 52 },
|
|
3029
|
+
XSGD: { balanceSlot: 7, allowanceSlot: 8 },
|
|
3030
|
+
USDR: { balanceSlot: 51, allowanceSlot: 52 }
|
|
3001
3031
|
},
|
|
3002
3032
|
addresses: {
|
|
3003
3033
|
IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
|
|
@@ -3298,8 +3328,9 @@ var chainConfigs = {
|
|
|
3298
3328
|
assets: {
|
|
3299
3329
|
WETH: "0x0000000000000000000000000000000000000000",
|
|
3300
3330
|
DAI: "0x0000000000000000000000000000000000000000",
|
|
3331
|
+
// Asset Hub assets at their asset-id precompile addresses: 0x539 = 1337, 0x7c0 = 1984.
|
|
3301
3332
|
USDC: "0x0000053900000000000000000000000001200000",
|
|
3302
|
-
USDT: "
|
|
3333
|
+
USDT: "0x000007c000000000000000000000000001200000"
|
|
3303
3334
|
},
|
|
3304
3335
|
tokenDecimals: {
|
|
3305
3336
|
USDC: 6,
|
|
@@ -4891,6 +4922,24 @@ var ABI3 = [
|
|
|
4891
4922
|
internalType: "uint256"
|
|
4892
4923
|
}
|
|
4893
4924
|
]
|
|
4925
|
+
},
|
|
4926
|
+
{
|
|
4927
|
+
name: "predispatchCall",
|
|
4928
|
+
type: "bytes",
|
|
4929
|
+
indexed: false,
|
|
4930
|
+
internalType: "bytes"
|
|
4931
|
+
},
|
|
4932
|
+
{
|
|
4933
|
+
name: "outputCall",
|
|
4934
|
+
type: "bytes",
|
|
4935
|
+
indexed: false,
|
|
4936
|
+
internalType: "bytes"
|
|
4937
|
+
},
|
|
4938
|
+
{
|
|
4939
|
+
name: "graffiti",
|
|
4940
|
+
type: "bytes32",
|
|
4941
|
+
indexed: false,
|
|
4942
|
+
internalType: "bytes32"
|
|
4894
4943
|
}
|
|
4895
4944
|
],
|
|
4896
4945
|
anonymous: false
|
|
@@ -7938,15 +7987,25 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
|
|
|
7938
7987
|
/**
|
|
7939
7988
|
* Signs and sends an extrinsic. Submissions are serialised through {@link submissionQueue} so
|
|
7940
7989
|
* concurrent calls never collide on the substrate account nonce — each extrinsic reaches a block
|
|
7941
|
-
* before the next is signed
|
|
7990
|
+
* (or is confirmed still pooled and returned as `pending`) before the next is signed; auto-nonce
|
|
7991
|
+
* via `system.accountNextIndex` counts pooled extrinsics, so a pending one is never re-used.
|
|
7942
7992
|
*/
|
|
7943
7993
|
async signAndSendExtrinsic(extrinsic, maxRetries = 3, timeoutMs = 3e4) {
|
|
7944
|
-
const result = await this.submissionQueue.add(
|
|
7994
|
+
const result = await this.submissionQueue.add(
|
|
7995
|
+
() => this.sendExtrinsicWithRetries(extrinsic, maxRetries, timeoutMs)
|
|
7996
|
+
);
|
|
7945
7997
|
return result ?? { success: false, error: "Submission queue returned no result" };
|
|
7946
7998
|
}
|
|
7947
7999
|
/**
|
|
7948
8000
|
* Signs and sends an extrinsic, handling status updates and errors.
|
|
7949
8001
|
* Implements retry logic with progressive tip increases for stuck transactions.
|
|
8002
|
+
*
|
|
8003
|
+
* A retry only happens when the previous attempt verifiably went nowhere. Once an attempt's
|
|
8004
|
+
* extrinsic is known to be pooled (`pending`), re-signing the same call would race our own
|
|
8005
|
+
* submission: the copy either bounces off the pool (1014, same nonce below the replacement
|
|
8006
|
+
* priority bump) or — if the original lands first, freeing the nonce — executes as a duplicate
|
|
8007
|
+
* and fails on-chain (e.g. `BidNotFound` for a retraction). Neither can succeed, so the pending
|
|
8008
|
+
* result is returned for the caller to confirm later.
|
|
7950
8009
|
*/
|
|
7951
8010
|
async sendExtrinsicWithRetries(extrinsic, maxRetries, timeoutMs) {
|
|
7952
8011
|
const keyPair = this.getKeyPair();
|
|
@@ -7957,7 +8016,7 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
|
|
|
7957
8016
|
attempt++;
|
|
7958
8017
|
try {
|
|
7959
8018
|
const result = await this.sendWithTimeout(extrinsic, keyPair, currentTip, timeoutMs);
|
|
7960
|
-
if (result.success || result.error?.includes("Dispatch error")) {
|
|
8019
|
+
if (result.success || result.pending || result.error?.includes("Dispatch error")) {
|
|
7961
8020
|
return result;
|
|
7962
8021
|
}
|
|
7963
8022
|
} catch (err) {
|
|
@@ -7973,12 +8032,30 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
|
|
|
7973
8032
|
};
|
|
7974
8033
|
}
|
|
7975
8034
|
/**
|
|
7976
|
-
*
|
|
8035
|
+
* Classifies a submission rejection. Codes 1013 ("already imported") and 1014 ("priority is
|
|
8036
|
+
* too low") both mean a copy of this account+nonce is already in the pool — almost always our
|
|
8037
|
+
* own earlier attempt whose watch handle didn't confirm cleanly. That extrinsic is in flight;
|
|
8038
|
+
* resubmitting can only bounce again or land a duplicate, so these are surfaced as `pending`
|
|
8039
|
+
* rather than failure.
|
|
8040
|
+
*/
|
|
8041
|
+
classifySubmissionError(err) {
|
|
8042
|
+
const code = err.code;
|
|
8043
|
+
const inFlight = code === 1013 || code === 1014 || /already imported|already in the pool|priority is too low/i.test(err.message);
|
|
8044
|
+
return { success: false, pending: inFlight || void 0, error: err.message };
|
|
8045
|
+
}
|
|
8046
|
+
/**
|
|
8047
|
+
* Sends an extrinsic with a timeout.
|
|
8048
|
+
*
|
|
8049
|
+
* A timeout is only a failure when the extrinsic never made it into the transaction pool.
|
|
8050
|
+
* Once a pool-entry status (Future/Ready/Broadcast/Retracted) has been seen, the extrinsic is
|
|
8051
|
+
* in flight and may well execute after the watch is abandoned — the result is then `pending`,
|
|
8052
|
+
* telling the caller to confirm the outcome later instead of re-signing the same call.
|
|
7977
8053
|
*/
|
|
7978
8054
|
async sendWithTimeout(extrinsic, keyPair, tip, timeoutMs) {
|
|
7979
8055
|
return new Promise((resolve) => {
|
|
7980
8056
|
let resolved = false;
|
|
7981
8057
|
let unsubscribe = null;
|
|
8058
|
+
let enteredPool = false;
|
|
7982
8059
|
const timeoutId = setTimeout(() => {
|
|
7983
8060
|
if (!resolved) {
|
|
7984
8061
|
resolved = true;
|
|
@@ -7987,12 +8064,17 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
|
|
|
7987
8064
|
}
|
|
7988
8065
|
resolve({
|
|
7989
8066
|
success: false,
|
|
7990
|
-
|
|
8067
|
+
pending: enteredPool || void 0,
|
|
8068
|
+
extrinsicHash: enteredPool ? extrinsic.hash.toHex() : void 0,
|
|
8069
|
+
error: `Transaction timed out after ${timeoutMs}ms${enteredPool ? " while in the transaction pool" : ""}`
|
|
7991
8070
|
});
|
|
7992
8071
|
}
|
|
7993
8072
|
}, timeoutMs);
|
|
7994
8073
|
extrinsic.signAndSend(keyPair, { tip }, (result) => {
|
|
7995
8074
|
if (resolved) return;
|
|
8075
|
+
if (result.status.isFuture || result.status.isReady || result.status.isBroadcast || result.status.isRetracted) {
|
|
8076
|
+
enteredPool = true;
|
|
8077
|
+
}
|
|
7996
8078
|
if (result.dispatchError && (result.status.isInBlock || result.status.isFinalized)) {
|
|
7997
8079
|
resolved = true;
|
|
7998
8080
|
clearTimeout(timeoutId);
|
|
@@ -8050,7 +8132,7 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
|
|
|
8050
8132
|
if (!resolved) {
|
|
8051
8133
|
resolved = true;
|
|
8052
8134
|
clearTimeout(timeoutId);
|
|
8053
|
-
resolve(
|
|
8135
|
+
resolve(this.classifySubmissionError(err));
|
|
8054
8136
|
}
|
|
8055
8137
|
});
|
|
8056
8138
|
});
|
|
@@ -8224,9 +8306,7 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
|
|
|
8224
8306
|
if (!result || result.isNone) return null;
|
|
8225
8307
|
const rawHex = result.unwrap().toHex();
|
|
8226
8308
|
if (rawHex === "0x" || rawHex === "0x00") return null;
|
|
8227
|
-
const placeOrderAbi = IntentGatewayV2_default.ABI.find(
|
|
8228
|
-
(item) => item.type === "function" && item.name === "placeOrder"
|
|
8229
|
-
);
|
|
8309
|
+
const placeOrderAbi = IntentGatewayV2_default.ABI.find((item) => item.type === "function" && item.name === "placeOrder");
|
|
8230
8310
|
const orderType = placeOrderAbi?.inputs?.[0];
|
|
8231
8311
|
if (!orderType) return null;
|
|
8232
8312
|
const [decoded] = decodeAbiParameters([orderType], rawHex);
|
|
@@ -8272,14 +8352,17 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
|
|
|
8272
8352
|
const orders = [];
|
|
8273
8353
|
for (const { event } of records) {
|
|
8274
8354
|
if (event.section !== "intentsCoprocessor" || event.method !== "PhantomOrderRegistered") continue;
|
|
8275
|
-
const [commitment, chain, createdAt,
|
|
8355
|
+
const [commitment, chain, createdAt, legs] = event.data;
|
|
8276
8356
|
orders.push({
|
|
8277
8357
|
commitment: commitment.toHex(),
|
|
8278
8358
|
chain: new TextDecoder().decode(hexToU8a(chain.toHex())),
|
|
8279
8359
|
createdAt: createdAt.toNumber(),
|
|
8280
|
-
|
|
8281
|
-
|
|
8282
|
-
|
|
8360
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8361
|
+
legs: legs.map((leg) => ({
|
|
8362
|
+
tokenA: leg.tokenA.toHex(),
|
|
8363
|
+
tokenB: leg.tokenB.toHex(),
|
|
8364
|
+
standardAmount: BigInt(leg.standardAmount.toString())
|
|
8365
|
+
}))
|
|
8283
8366
|
});
|
|
8284
8367
|
}
|
|
8285
8368
|
return orders;
|
|
@@ -15585,13 +15668,13 @@ function deriveCanonicalPlacedOrder(order, args) {
|
|
|
15585
15668
|
session: args.session,
|
|
15586
15669
|
predispatch: {
|
|
15587
15670
|
assets: args.predispatch.map((asset) => ({ ...asset })),
|
|
15588
|
-
call: order.predispatch.call
|
|
15671
|
+
call: args.predispatchCall ?? order.predispatch.call
|
|
15589
15672
|
},
|
|
15590
15673
|
inputs: args.inputs.map((asset) => ({ ...asset })),
|
|
15591
15674
|
output: {
|
|
15592
15675
|
beneficiary: args.beneficiary,
|
|
15593
15676
|
assets: args.outputs.map((asset) => ({ ...asset })),
|
|
15594
|
-
call: order.output.call
|
|
15677
|
+
call: args.outputCall ?? order.output.call
|
|
15595
15678
|
}
|
|
15596
15679
|
};
|
|
15597
15680
|
return { ...canonicalOrder, id: orderCommitment(canonicalOrder) };
|
|
@@ -17022,14 +17105,14 @@ var BidManager = class {
|
|
|
17022
17105
|
}
|
|
17023
17106
|
/**
|
|
17024
17107
|
* Autopilot bid selection: sorts the given bids by output value, simulates
|
|
17025
|
-
* each in order
|
|
17026
|
-
*
|
|
17108
|
+
* each in order and attempts execution. Any bid that fails simulation or
|
|
17109
|
+
* execution is skipped once so the next ranked bid can be attempted in the
|
|
17110
|
+
* same round. For consumers that do not need custom selection logic.
|
|
17027
17111
|
*
|
|
17028
17112
|
* @param order - The placed order to fill.
|
|
17029
17113
|
* @param bids - Candidate bids (from {@link buildBids}).
|
|
17030
17114
|
* @returns A {@link SelectBidResult} for the executed bid.
|
|
17031
|
-
* @throws If no valid bids exist
|
|
17032
|
-
* the UserOperation.
|
|
17115
|
+
* @throws If no valid bids exist or every bid fails simulation/execution.
|
|
17033
17116
|
*/
|
|
17034
17117
|
async selectAndExecuteBest(order, bids) {
|
|
17035
17118
|
const commitment = order.id;
|
|
@@ -17046,22 +17129,34 @@ var BidManager = class {
|
|
|
17046
17129
|
throw new Error("No valid bids found");
|
|
17047
17130
|
}
|
|
17048
17131
|
console.log(`[BidManager] Simulating ${sortedBids.length} sorted bid(s) to find a valid one`);
|
|
17132
|
+
let simulationFailures = 0;
|
|
17133
|
+
let executionFailures = 0;
|
|
17049
17134
|
for (let idx = 0; idx < sortedBids.length; idx++) {
|
|
17050
17135
|
const bid = sortedBids[idx];
|
|
17051
17136
|
console.log(`[BidManager] Simulating bid ${idx + 1}/${sortedBids.length} from solver=${bid.solverAddress}`);
|
|
17052
17137
|
try {
|
|
17053
17138
|
await bid.simulate();
|
|
17054
17139
|
} catch (err) {
|
|
17140
|
+
simulationFailures += 1;
|
|
17055
17141
|
console.warn(
|
|
17056
17142
|
`[BidManager] Bid ${idx + 1} from solver=${bid.solverAddress}: simulation FAILED: ${err instanceof Error ? err.message : String(err)}`
|
|
17057
17143
|
);
|
|
17058
17144
|
continue;
|
|
17059
17145
|
}
|
|
17060
17146
|
console.log(`[BidManager] Bid ${idx + 1} from solver=${bid.solverAddress}: simulation PASSED`);
|
|
17061
|
-
|
|
17147
|
+
try {
|
|
17148
|
+
return await bid.execute();
|
|
17149
|
+
} catch (err) {
|
|
17150
|
+
executionFailures += 1;
|
|
17151
|
+
console.warn(
|
|
17152
|
+
`[BidManager] Bid ${idx + 1} from solver=${bid.solverAddress}: execution FAILED: ${err instanceof Error ? err.message : String(err)}; trying next bid`
|
|
17153
|
+
);
|
|
17154
|
+
}
|
|
17062
17155
|
}
|
|
17063
|
-
console.error(
|
|
17064
|
-
|
|
17156
|
+
console.error(
|
|
17157
|
+
`[BidManager] No executable bids for commitment=${commitment}: ${simulationFailures} simulation failure(s), ${executionFailures} execution failure(s)`
|
|
17158
|
+
);
|
|
17159
|
+
throw new Error("No bids passed simulation and execution");
|
|
17065
17160
|
}
|
|
17066
17161
|
/**
|
|
17067
17162
|
* Sorts a list of bids for the given order by output value.
|
|
@@ -17401,6 +17496,10 @@ var BidManager = class {
|
|
|
17401
17496
|
}
|
|
17402
17497
|
};
|
|
17403
17498
|
var RELAYER_MESSAGE_GAS = 1000000n;
|
|
17499
|
+
var NO_BUNDLER_FILL_GAS_BASE = 700000n;
|
|
17500
|
+
var NO_BUNDLER_FILL_GAS_PER_OUTPUT = 150000n;
|
|
17501
|
+
var NO_BUNDLER_PAYMASTER_VERIFICATION_GAS = 250000n;
|
|
17502
|
+
var NO_BUNDLER_PAYMASTER_POST_OP_GAS = 100000n;
|
|
17404
17503
|
var GasEstimator = class {
|
|
17405
17504
|
/**
|
|
17406
17505
|
* @param ctx - Shared IntentsV2 context providing the source and destination
|
|
@@ -17434,8 +17533,10 @@ var GasEstimator = class {
|
|
|
17434
17533
|
* headroom. If the bundler is Pimlico, gas prices are refined with
|
|
17435
17534
|
* `pimlico_getUserOperationGasPrice`.
|
|
17436
17535
|
*
|
|
17437
|
-
* **Fallback path (no bundler):**
|
|
17438
|
-
*
|
|
17536
|
+
* **Fallback path (no bundler):** uses a fixed budget
|
|
17537
|
+
* ({@link NO_BUNDLER_FILL_GAS_BASE} plus {@link NO_BUNDLER_FILL_GAS_PER_OUTPUT}
|
|
17538
|
+
* per output leg) — public RPCs don't reliably support estimation with
|
|
17539
|
+
* state overrides.
|
|
17439
17540
|
*
|
|
17440
17541
|
* @param params - Parameters including the order to estimate and optional
|
|
17441
17542
|
* percentage bumps for `maxPriorityFeePerGas` and `maxFeePerGas`.
|
|
@@ -17470,14 +17571,14 @@ var GasEstimator = class {
|
|
|
17470
17571
|
}
|
|
17471
17572
|
const isSameChain = souceStateMachineId === destStateMachineId;
|
|
17472
17573
|
const [stateOverridesResult, crossChainFees] = await Promise.all([
|
|
17473
|
-
this.buildStateOverride({
|
|
17574
|
+
this.ctx.bundlerUrl ? this.buildStateOverride({
|
|
17474
17575
|
accountAddress: solverAccountAddress,
|
|
17475
17576
|
chain: destStateMachineId,
|
|
17476
17577
|
outputAssets: assetsForOverrides,
|
|
17477
17578
|
spenderAddress: intentGatewayV2Address,
|
|
17478
17579
|
intentGatewayV2Address,
|
|
17479
17580
|
entryPointAddress
|
|
17480
|
-
}),
|
|
17581
|
+
}) : Promise.resolve({ viem: [], bundler: {} }),
|
|
17481
17582
|
isSameChain ? Promise.resolve({ postRequestFee: 0n, relayerFeeInSourceFeeToken: 0n }) : this.estimateCrossChainFees(
|
|
17482
17583
|
sourceFeeToken,
|
|
17483
17584
|
destFeeToken,
|
|
@@ -17485,7 +17586,7 @@ var GasEstimator = class {
|
|
|
17485
17586
|
orderFeeGasPriceBumpPercent
|
|
17486
17587
|
)
|
|
17487
17588
|
]);
|
|
17488
|
-
const {
|
|
17589
|
+
const { bundler: bundlerStateOverrides } = stateOverridesResult;
|
|
17489
17590
|
const fillOptions = {
|
|
17490
17591
|
relayerFee: crossChainFees.postRequestFee,
|
|
17491
17592
|
// Always dispatch with the fee token (see the method docs).
|
|
@@ -17626,20 +17727,9 @@ var GasEstimator = class {
|
|
|
17626
17727
|
console.warn("Bundler gas estimation failed, using fallback values:", e);
|
|
17627
17728
|
}
|
|
17628
17729
|
} else {
|
|
17629
|
-
|
|
17630
|
-
|
|
17631
|
-
|
|
17632
|
-
address: intentGatewayV2Address,
|
|
17633
|
-
functionName: "fillOrder",
|
|
17634
|
-
args: [transformOrderForContract(order), fillOptions],
|
|
17635
|
-
account: solverAccountAddress,
|
|
17636
|
-
value: totalNativeValue,
|
|
17637
|
-
stateOverride: stateOverrides
|
|
17638
|
-
});
|
|
17639
|
-
callGasLimit = estimatedGas * 105n / 100n;
|
|
17640
|
-
} catch (e) {
|
|
17641
|
-
console.warn("fillOrder gas estimation failed, using fallback:", e);
|
|
17642
|
-
}
|
|
17730
|
+
callGasLimit = NO_BUNDLER_FILL_GAS_BASE + NO_BUNDLER_FILL_GAS_PER_OUTPUT * BigInt(order.output.assets.length);
|
|
17731
|
+
paymasterVerificationGasLimit = NO_BUNDLER_PAYMASTER_VERIFICATION_GAS;
|
|
17732
|
+
paymasterPostOpGasLimit = NO_BUNDLER_PAYMASTER_POST_OP_GAS;
|
|
17643
17733
|
}
|
|
17644
17734
|
const totalGas = callGasLimit + verificationGasLimit + preVerificationGas + paymasterVerificationGasLimit + paymasterPostOpGasLimit;
|
|
17645
17735
|
const rawTotalGasCostWei = totalGas * maxFeePerGas;
|
|
@@ -19169,6 +19259,44 @@ var IntentGateway = class _IntentGateway {
|
|
|
19169
19259
|
}
|
|
19170
19260
|
}
|
|
19171
19261
|
};
|
|
19262
|
+
var FILL_ORDER_ABI = IntentGatewayV2_default.ABI;
|
|
19263
|
+
var DECLARATION_VERSION = 1;
|
|
19264
|
+
var MAX_DECLARED_CHAINS = 255;
|
|
19265
|
+
function encodeAcceptedSourceChains(chains2) {
|
|
19266
|
+
if (chains2.length > MAX_DECLARED_CHAINS) {
|
|
19267
|
+
throw new Error(`Cannot declare more than ${MAX_DECLARED_CHAINS} source chains`);
|
|
19268
|
+
}
|
|
19269
|
+
const bytes = [DECLARATION_VERSION, chains2.length];
|
|
19270
|
+
for (const chain of chains2) {
|
|
19271
|
+
const encoded = stringToU8a(chain);
|
|
19272
|
+
if (encoded.length === 0 || encoded.length > 255) {
|
|
19273
|
+
throw new Error(`Invalid state machine id in source chain declaration: ${chain}`);
|
|
19274
|
+
}
|
|
19275
|
+
bytes.push(encoded.length, ...encoded);
|
|
19276
|
+
}
|
|
19277
|
+
return u8aToHex(new Uint8Array(bytes));
|
|
19278
|
+
}
|
|
19279
|
+
function decodeAcceptedSourceChains(paymasterAndData) {
|
|
19280
|
+
if (!paymasterAndData || !isHex$1(paymasterAndData)) return null;
|
|
19281
|
+
const bytes = hexToU8a(paymasterAndData);
|
|
19282
|
+
if (bytes.length < 2 || bytes[0] !== DECLARATION_VERSION) return null;
|
|
19283
|
+
const count = bytes[1];
|
|
19284
|
+
const chains2 = [];
|
|
19285
|
+
let offset = 2;
|
|
19286
|
+
for (let entry = 0; entry < count; entry++) {
|
|
19287
|
+
if (offset >= bytes.length) return null;
|
|
19288
|
+
const length = bytes[offset];
|
|
19289
|
+
offset += 1;
|
|
19290
|
+
if (length === 0 || offset + length > bytes.length) return null;
|
|
19291
|
+
chains2.push(u8aToString(bytes.subarray(offset, offset + length)));
|
|
19292
|
+
offset += length;
|
|
19293
|
+
}
|
|
19294
|
+
if (offset !== bytes.length) return null;
|
|
19295
|
+
return chains2;
|
|
19296
|
+
}
|
|
19297
|
+
FILL_ORDER_ABI.find(
|
|
19298
|
+
(item) => item?.type === "function" && item?.name === "fillOrder"
|
|
19299
|
+
)?.inputs?.[0];
|
|
19172
19300
|
var TokenGateway = class {
|
|
19173
19301
|
source;
|
|
19174
19302
|
dest;
|
|
@@ -23639,6 +23767,6 @@ async function teleportDot(param_) {
|
|
|
23639
23767
|
return stream;
|
|
23640
23768
|
}
|
|
23641
23769
|
|
|
23642
|
-
export { ADDRESS_ZERO2 as ADDRESS_ZERO, BundlerMethod, ChainConfigService, Chains, CryptoUtils, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DOMAIN_TYPEHASH, DUMMY_PRIVATE_KEY, ERC20Method, ERC7821_BATCH_MODE, EvmChain, ABI as EvmHostABI, EvmLanguage, HyperClientStatus, HyperFungibleToken, HyperFungibleTokenABI, IntentGateway, ABI3 as IntentGatewayABI, IntentOrderStatus, IntentsCoprocessor, InvalidPhantomSnapshotError, IsmpClient, MOCK_ADDRESS, ORDER_V2_PARAM_TYPE, OrderStatus, OrderStatusChecker, PACKED_USEROP_TYPEHASH, PLACE_ORDER_SELECTOR, PhantomSnapshotUnavailableError, PharosChain, PolkadotHubChain, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, RequestKind, RequestStatus, SELECT_SOLVER_TYPEHASH, STATE_COMMITMENTS_SLOT, SubstrateChain, Swap, TESTNET_CHAINS, TeleportStatus, TimeoutStatus, TokenGateway, TronChain, USE_ETHERSCAN_CHAINS, UnsupportedIntentQuotePairError, UnsupportedIntentQuoteStrategyError, WrappedHyperFungibleTokenABI, __test, adjustDecimals, bytes20ToBytes32, bytes32ToBytes20, calculateAllowanceMappingLocation, calculateBalanceMappingLocation, chainConfigs, constructRedeemEscrowRequestBody, constructRefundEscrowRequestBody, convertCodecToIGetRequest, convertCodecToIProof, convertIGetRequestToCodec, convertIProofToCodec, convertStateIdToStateMachineId, convertStateMachineEnumToString, convertStateMachineIdToEnum, createEvmChain, createQueryClient, decodeERC7821ExecuteBatch, decodeUserOpScale, encodeERC7821ExecuteBatch, encodeISMPMessage, encodeStateMachineId, encodeUserOpScale, encodeWithdrawalRequest, estimateGasForPost, fetchPrice, fetchSourceProof, generateRootWithProof, getChainId, getConfigByStateMachineId, getContractCallInput, getContractCallInputs, getGasPriceFromEtherscan, getOrFetchStorageSlot, getOrderPlacedFromTx, getPostRequestEventFromTx, getPostResponseEventFromTx, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, getViemChain, hexToString, hyperbridgeAddress, maxBigInt, normalizeAddressForEvmBytes32, normalizeAddressForStateMachine, normalizeEvmAddress, normalizeEvmChainId, normalizeStateMachineId, orderCommitment, parseStateMachineId, pharosAtlantic, pharosMainnet, polkadotAssetHubPaseo, polkadotHubMainnet, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, quoteUniswap, requestCommitmentKey, responseCommitmentKey, retryPromise, teleport, teleportDot, transformOrderForContract, tronChainIds, tronNile };
|
|
23770
|
+
export { ADDRESS_ZERO2 as ADDRESS_ZERO, BundlerMethod, ChainConfigService, Chains, CryptoUtils, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DOMAIN_TYPEHASH, DUMMY_PRIVATE_KEY, ERC20Method, ERC7821_BATCH_MODE, EvmChain, ABI as EvmHostABI, EvmLanguage, HyperClientStatus, HyperFungibleToken, HyperFungibleTokenABI, IntentGateway, ABI3 as IntentGatewayABI, IntentOrderStatus, IntentsCoprocessor, InvalidPhantomSnapshotError, IsmpClient, MOCK_ADDRESS, ORDER_V2_PARAM_TYPE, OrderStatus, OrderStatusChecker, PACKED_USEROP_TYPEHASH, PLACE_ORDER_SELECTOR, PhantomSnapshotUnavailableError, PharosChain, PolkadotHubChain, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, RequestKind, RequestStatus, SELECT_SOLVER_TYPEHASH, STATE_COMMITMENTS_SLOT, SubstrateChain, Swap, TESTNET_CHAINS, TeleportStatus, TimeoutStatus, TokenGateway, TronChain, USE_ETHERSCAN_CHAINS, UnsupportedIntentQuotePairError, UnsupportedIntentQuoteStrategyError, WrappedHyperFungibleTokenABI, __test, adjustDecimals, bytes20ToBytes32, bytes32ToBytes20, calculateAllowanceMappingLocation, calculateBalanceMappingLocation, chainConfigs, constructRedeemEscrowRequestBody, constructRefundEscrowRequestBody, convertCodecToIGetRequest, convertCodecToIProof, convertIGetRequestToCodec, convertIProofToCodec, convertStateIdToStateMachineId, convertStateMachineEnumToString, convertStateMachineIdToEnum, createEvmChain, createQueryClient, decodeAcceptedSourceChains, decodeERC7821ExecuteBatch, decodeUserOpScale, encodeAcceptedSourceChains, encodeERC7821ExecuteBatch, encodeISMPMessage, encodeStateMachineId, encodeUserOpScale, encodeWithdrawalRequest, estimateGasForPost, fetchPrice, fetchSourceProof, generateRootWithProof, getChainId, getConfigByStateMachineId, getContractCallInput, getContractCallInputs, getGasPriceFromEtherscan, getOrFetchStorageSlot, getOrderPlacedFromTx, getPostRequestEventFromTx, getPostResponseEventFromTx, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, getViemChain, hexToString, hyperbridgeAddress, maxBigInt, normalizeAddressForEvmBytes32, normalizeAddressForStateMachine, normalizeEvmAddress, normalizeEvmChainId, normalizeStateMachineId, orderCommitment, parseStateMachineId, pharosAtlantic, pharosMainnet, polkadotAssetHubPaseo, polkadotHubMainnet, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, quoteUniswap, requestCommitmentKey, responseCommitmentKey, retryPromise, teleport, teleportDot, transformOrderForContract, tronChainIds, tronNile };
|
|
23643
23771
|
//# sourceMappingURL=index.js.map
|
|
23644
23772
|
//# sourceMappingURL=index.js.map
|