@hyperbridge/sdk 2.8.11 → 2.8.13
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 +76 -19
- package/dist/browser/index.js +202 -27
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +205 -27
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +2 -2
- package/dist/node/index.d.ts +2 -2
- package/dist/node/index.js +202 -27
- package/dist/node/index.js.map +1 -1
- package/dist/node/{intents-helpers-BRegx4yZ.d.cts → intents-helpers-fntBuoYM.d.cts} +76 -19
- package/dist/node/{intents-helpers-BRegx4yZ.d.ts → intents-helpers-fntBuoYM.d.ts} +76 -19
- package/dist/node/intents-helpers.cjs +162 -27
- package/dist/node/intents-helpers.cjs.map +1 -1
- package/dist/node/intents-helpers.d.cts +1 -1
- package/dist/node/intents-helpers.d.ts +1 -1
- package/dist/node/intents-helpers.js +159 -27
- package/dist/node/intents-helpers.js.map +1 -1
- package/package.json +1 -1
package/dist/node/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as IChain, H as HexString, a as IEvmConfig, C as ChainConfigService, b as IMessage, S as StateMachineIdParams, c as StateMachineHeight, d as IIsmpMessage, e as IPostRequest, f as IGetRequest, O as Order, E as EstimateGasCallData, R as RetryConfig, g as IPolkadotHubConfig, h as IPharosConfig, i as StateMachineUpdate, P as PostRequestWithStatus, G as GetRequestWithStatus, j as ResponseCommitmentWithValues, k as RequestStatusWithMetadata, l as PostRequestTimeoutStatus, m as SubstrateChain, n as ClientConfig, o as IndexerQueryClient, A as AssetTeleported, T as Transaction, p as IProof, q as IEvmChain, r as IntentsCoprocessor, s as Chains, t as ConfiguredAssetSymbol, u as AvailableLiquidity, Q as QueryBuyAndSellRatesParams, B as BuyAndSellRates, v as IntentOrderStatusUpdate, w as SelectBidResult, x as ResumeIntentOrderOptions, y as CancelOrderOptions, z as CancelQuote, D as SubmitBidOptions, F as PackedUserOperation, J as FillerBid, K as Bid, L as EstimateFillOrderParams, M as FillOrderEstimate, N as OrderFeesQuote, U as ERC7821Call, V as OrderWithStatus, W as OrderStatus, X as TokenGatewayAssetTeleportedWithStatus, Y as TeleportStatus, Z as DecodedOrderPlacedLog, _ as DecodedPostRequestEvent, $ as DecodedPostResponseEvent } from './intents-helpers-
|
|
2
|
-
export { a0 as AllStatusKey, a1 as AssetTeleportedResponse, a2 as BidStorageEntry, a3 as BidSubmissionResult, a4 as BlockMetadata, a5 as BytesLikeHex, a6 as CHAINS_WITHOUT_VALID_UNTIL, a7 as CancelOptions, a8 as ChainConfig, a9 as ChainConfigData, aa as ConfiguredAssetSymbolInput, ab as Deployment, ac as DispatchGet, ad as DispatchInfo, ae as DispatchPost, af as Erc4626VaultConfigData, ag as ExecuteIntentOrderOptions, ah as ExecutionResult, ai as FILL_ORDER_V1_ABI, aj as FillOptions, ak as FillOptionsVersion, al as FillerConfig, am as GetRequestResponse, an as GetResponseByRequestIdResponse, ao as GetResponseStorageValues, ap as HostParams, aq as HyperClientStatus, ar as IBatchConsensusAndGetResponseMessage, as as IBatchConsensusAndPostRequestMessage, at as IConfig, au as IConsensusMessage, av as IGetRequestMessage, aw as IGetResponse, ax as IGetResponseMessage, ay as IHyperbridgeConfig, az as INCLUSION_TIMEOUT_MS, aA as IPostResponse, aB as IRequestMessage, aC as ISubstrateConfig, aD as ITimeoutPostRequestMessage, aE as IntentGatewayABI, aF as IntentGatewayParams, aG as IntentOrderStatus, aH as IntentOrderStatusKey, aI as IsmpRequest, aJ as LEGACY_FILL_OPTIONS_IMPLEMENTATIONS, aK as LiquiditySlice, aL as OrderResponse, aM as OrderStatusMetadata, aN as
|
|
1
|
+
import { I as IChain, H as HexString, a as IEvmConfig, C as ChainConfigService, b as IMessage, S as StateMachineIdParams, c as StateMachineHeight, d as IIsmpMessage, e as IPostRequest, f as IGetRequest, O as Order, E as EstimateGasCallData, R as RetryConfig, g as IPolkadotHubConfig, h as IPharosConfig, i as StateMachineUpdate, P as PostRequestWithStatus, G as GetRequestWithStatus, j as ResponseCommitmentWithValues, k as RequestStatusWithMetadata, l as PostRequestTimeoutStatus, m as SubstrateChain, n as ClientConfig, o as IndexerQueryClient, A as AssetTeleported, T as Transaction, p as IProof, q as IEvmChain, r as IntentsCoprocessor, s as Chains, t as ConfiguredAssetSymbol, u as AvailableLiquidity, Q as QueryBuyAndSellRatesParams, B as BuyAndSellRates, v as IntentOrderStatusUpdate, w as SelectBidResult, x as ResumeIntentOrderOptions, y as CancelOrderOptions, z as CancelQuote, D as SubmitBidOptions, F as PackedUserOperation, J as FillerBid, K as Bid, L as EstimateFillOrderParams, M as FillOrderEstimate, N as OrderFeesQuote, U as ERC7821Call, V as OrderWithStatus, W as OrderStatus, X as TokenGatewayAssetTeleportedWithStatus, Y as TeleportStatus, Z as DecodedOrderPlacedLog, _ as DecodedPostRequestEvent, $ as DecodedPostResponseEvent } from './intents-helpers-fntBuoYM.cjs';
|
|
2
|
+
export { a0 as AllStatusKey, a1 as AssetTeleportedResponse, a2 as BidStorageEntry, a3 as BidSubmissionResult, a4 as BlockMetadata, a5 as BytesLikeHex, a6 as CHAINS_WITHOUT_VALID_UNTIL, a7 as CancelOptions, a8 as ChainConfig, a9 as ChainConfigData, aa as ConfiguredAssetSymbolInput, ab as Deployment, ac as DispatchGet, ad as DispatchInfo, ae as DispatchPost, af as Erc4626VaultConfigData, ag as ExecuteIntentOrderOptions, ah as ExecutionResult, ai as FILL_ORDER_V1_ABI, aj as FillOptions, ak as FillOptionsVersion, al as FillerConfig, am as GetRequestResponse, an as GetResponseByRequestIdResponse, ao as GetResponseStorageValues, ap as HostParams, aq as HyperClientStatus, ar as IBatchConsensusAndGetResponseMessage, as as IBatchConsensusAndPostRequestMessage, at as IConfig, au as IConsensusMessage, av as IGetRequestMessage, aw as IGetResponse, ax as IGetResponseMessage, ay as IHyperbridgeConfig, az as INCLUSION_TIMEOUT_MS, aA as IPostResponse, aB as IRequestMessage, aC as ISubstrateConfig, aD as ITimeoutPostRequestMessage, aE as IntentGatewayABI, aF as IntentGatewayParams, aG as IntentOrderStatus, aH as IntentOrderStatusKey, aI as IsmpRequest, aJ as LEGACY_FILL_OPTIONS_IMPLEMENTATIONS, aK as LiquiditySlice, aL as OrderResponse, aM as OrderStatusMetadata, aN as PERMIT2_SPONSORSHIP_BYTES, aO as PaymentInfo, aP as PhantomBid, aQ as PhantomBidBatchResult, aR as PhantomBidDeclaration, aS as PhantomBidOutcome, aT as PhantomBidPaymasterAndData, aU as PhantomBidSponsorship, aV as PhantomOrderEvent, aW as PhantomOrderLeg, aX as PhantomOrderPriceSnapshot, aY as PhantomOrderPriceSnapshotsResponse, aZ as PhantomTimings, a_ as PollPhantomOrdersOptions, a$ as PostRequestStatus, b0 as RequestBody, b1 as RequestCommitment, b2 as RequestKind, b3 as RequestResponse, b4 as RequestStatus, b5 as RequestStatusKey, b6 as SelectOptions, b7 as SigningAccount, b8 as StateMachineId, b9 as StateMachineResponse, ba as StorageFacade, bb as TimeoutStatus, bc as TimeoutStatusKey, bd as TokenGatewayAssetTeleportedResponse, be as TokenInfo, bf as TokenPrice, bg as TokenPricesResponse, bh as UNISWAP_QUOTE_HAIRCUT_BPS, bi as UniswapV4PoolConfigData, bj as applyProtocolFeeHaircut, bk as applyUniswapQuoteHaircut, bl as chainConfigs, bm as convertCodecToIGetRequest, bn as convertCodecToIProof, bo as convertIGetRequestToCodec, bp as convertIProofToCodec, bq as convertStateIdToStateMachineId, br as convertStateMachineEnumToString, bs as convertStateMachineIdToEnum, bt as decodeAcceptedSourceChains, bu as decodeERC7821ExecuteBatch, bv as decodeFillOrder, bw as decodePhantomBidDeclaration, bx as decodePhantomBidPaymasterAndData, by as decodeUserOpScale, bz as deriveHttpUrl, bA as encodeAcceptedSourceChains, bB as encodeERC7821ExecuteBatch, bC as encodeFillOrder, bD as encodeISMPMessage, bE as encodePhantomBidDeclaration, bF as encodePhantomBidPaymasterAndData, bG as encodeUserOpScale, bH as getChainId, bI as getConfigByStateMachineId, bJ as getFillOptionsVersion, bK as getViemChain, bL as hyperbridgeAddress, bM as pharosAtlantic, bN as pharosMainnet, bO as polkadotAssetHubPaseo, bP as polkadotHubMainnet, bQ as poolSlug, bR as readProtocolFeeHaircutBps, bS as resetFillOptionsVersionCache, bT as sortPoolSymbols, bU as tronChainIds, bV as tronNile } from './intents-helpers-fntBuoYM.cjs';
|
|
3
3
|
import { ConsolaInstance } from 'consola';
|
|
4
4
|
import { GraphQLClient } from 'graphql-request';
|
|
5
5
|
import { PublicClient, TransactionReceipt, Hex, Address } from 'viem';
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as IChain, H as HexString, a as IEvmConfig, C as ChainConfigService, b as IMessage, S as StateMachineIdParams, c as StateMachineHeight, d as IIsmpMessage, e as IPostRequest, f as IGetRequest, O as Order, E as EstimateGasCallData, R as RetryConfig, g as IPolkadotHubConfig, h as IPharosConfig, i as StateMachineUpdate, P as PostRequestWithStatus, G as GetRequestWithStatus, j as ResponseCommitmentWithValues, k as RequestStatusWithMetadata, l as PostRequestTimeoutStatus, m as SubstrateChain, n as ClientConfig, o as IndexerQueryClient, A as AssetTeleported, T as Transaction, p as IProof, q as IEvmChain, r as IntentsCoprocessor, s as Chains, t as ConfiguredAssetSymbol, u as AvailableLiquidity, Q as QueryBuyAndSellRatesParams, B as BuyAndSellRates, v as IntentOrderStatusUpdate, w as SelectBidResult, x as ResumeIntentOrderOptions, y as CancelOrderOptions, z as CancelQuote, D as SubmitBidOptions, F as PackedUserOperation, J as FillerBid, K as Bid, L as EstimateFillOrderParams, M as FillOrderEstimate, N as OrderFeesQuote, U as ERC7821Call, V as OrderWithStatus, W as OrderStatus, X as TokenGatewayAssetTeleportedWithStatus, Y as TeleportStatus, Z as DecodedOrderPlacedLog, _ as DecodedPostRequestEvent, $ as DecodedPostResponseEvent } from './intents-helpers-
|
|
2
|
-
export { a0 as AllStatusKey, a1 as AssetTeleportedResponse, a2 as BidStorageEntry, a3 as BidSubmissionResult, a4 as BlockMetadata, a5 as BytesLikeHex, a6 as CHAINS_WITHOUT_VALID_UNTIL, a7 as CancelOptions, a8 as ChainConfig, a9 as ChainConfigData, aa as ConfiguredAssetSymbolInput, ab as Deployment, ac as DispatchGet, ad as DispatchInfo, ae as DispatchPost, af as Erc4626VaultConfigData, ag as ExecuteIntentOrderOptions, ah as ExecutionResult, ai as FILL_ORDER_V1_ABI, aj as FillOptions, ak as FillOptionsVersion, al as FillerConfig, am as GetRequestResponse, an as GetResponseByRequestIdResponse, ao as GetResponseStorageValues, ap as HostParams, aq as HyperClientStatus, ar as IBatchConsensusAndGetResponseMessage, as as IBatchConsensusAndPostRequestMessage, at as IConfig, au as IConsensusMessage, av as IGetRequestMessage, aw as IGetResponse, ax as IGetResponseMessage, ay as IHyperbridgeConfig, az as INCLUSION_TIMEOUT_MS, aA as IPostResponse, aB as IRequestMessage, aC as ISubstrateConfig, aD as ITimeoutPostRequestMessage, aE as IntentGatewayABI, aF as IntentGatewayParams, aG as IntentOrderStatus, aH as IntentOrderStatusKey, aI as IsmpRequest, aJ as LEGACY_FILL_OPTIONS_IMPLEMENTATIONS, aK as LiquiditySlice, aL as OrderResponse, aM as OrderStatusMetadata, aN as
|
|
1
|
+
import { I as IChain, H as HexString, a as IEvmConfig, C as ChainConfigService, b as IMessage, S as StateMachineIdParams, c as StateMachineHeight, d as IIsmpMessage, e as IPostRequest, f as IGetRequest, O as Order, E as EstimateGasCallData, R as RetryConfig, g as IPolkadotHubConfig, h as IPharosConfig, i as StateMachineUpdate, P as PostRequestWithStatus, G as GetRequestWithStatus, j as ResponseCommitmentWithValues, k as RequestStatusWithMetadata, l as PostRequestTimeoutStatus, m as SubstrateChain, n as ClientConfig, o as IndexerQueryClient, A as AssetTeleported, T as Transaction, p as IProof, q as IEvmChain, r as IntentsCoprocessor, s as Chains, t as ConfiguredAssetSymbol, u as AvailableLiquidity, Q as QueryBuyAndSellRatesParams, B as BuyAndSellRates, v as IntentOrderStatusUpdate, w as SelectBidResult, x as ResumeIntentOrderOptions, y as CancelOrderOptions, z as CancelQuote, D as SubmitBidOptions, F as PackedUserOperation, J as FillerBid, K as Bid, L as EstimateFillOrderParams, M as FillOrderEstimate, N as OrderFeesQuote, U as ERC7821Call, V as OrderWithStatus, W as OrderStatus, X as TokenGatewayAssetTeleportedWithStatus, Y as TeleportStatus, Z as DecodedOrderPlacedLog, _ as DecodedPostRequestEvent, $ as DecodedPostResponseEvent } from './intents-helpers-fntBuoYM.js';
|
|
2
|
+
export { a0 as AllStatusKey, a1 as AssetTeleportedResponse, a2 as BidStorageEntry, a3 as BidSubmissionResult, a4 as BlockMetadata, a5 as BytesLikeHex, a6 as CHAINS_WITHOUT_VALID_UNTIL, a7 as CancelOptions, a8 as ChainConfig, a9 as ChainConfigData, aa as ConfiguredAssetSymbolInput, ab as Deployment, ac as DispatchGet, ad as DispatchInfo, ae as DispatchPost, af as Erc4626VaultConfigData, ag as ExecuteIntentOrderOptions, ah as ExecutionResult, ai as FILL_ORDER_V1_ABI, aj as FillOptions, ak as FillOptionsVersion, al as FillerConfig, am as GetRequestResponse, an as GetResponseByRequestIdResponse, ao as GetResponseStorageValues, ap as HostParams, aq as HyperClientStatus, ar as IBatchConsensusAndGetResponseMessage, as as IBatchConsensusAndPostRequestMessage, at as IConfig, au as IConsensusMessage, av as IGetRequestMessage, aw as IGetResponse, ax as IGetResponseMessage, ay as IHyperbridgeConfig, az as INCLUSION_TIMEOUT_MS, aA as IPostResponse, aB as IRequestMessage, aC as ISubstrateConfig, aD as ITimeoutPostRequestMessage, aE as IntentGatewayABI, aF as IntentGatewayParams, aG as IntentOrderStatus, aH as IntentOrderStatusKey, aI as IsmpRequest, aJ as LEGACY_FILL_OPTIONS_IMPLEMENTATIONS, aK as LiquiditySlice, aL as OrderResponse, aM as OrderStatusMetadata, aN as PERMIT2_SPONSORSHIP_BYTES, aO as PaymentInfo, aP as PhantomBid, aQ as PhantomBidBatchResult, aR as PhantomBidDeclaration, aS as PhantomBidOutcome, aT as PhantomBidPaymasterAndData, aU as PhantomBidSponsorship, aV as PhantomOrderEvent, aW as PhantomOrderLeg, aX as PhantomOrderPriceSnapshot, aY as PhantomOrderPriceSnapshotsResponse, aZ as PhantomTimings, a_ as PollPhantomOrdersOptions, a$ as PostRequestStatus, b0 as RequestBody, b1 as RequestCommitment, b2 as RequestKind, b3 as RequestResponse, b4 as RequestStatus, b5 as RequestStatusKey, b6 as SelectOptions, b7 as SigningAccount, b8 as StateMachineId, b9 as StateMachineResponse, ba as StorageFacade, bb as TimeoutStatus, bc as TimeoutStatusKey, bd as TokenGatewayAssetTeleportedResponse, be as TokenInfo, bf as TokenPrice, bg as TokenPricesResponse, bh as UNISWAP_QUOTE_HAIRCUT_BPS, bi as UniswapV4PoolConfigData, bj as applyProtocolFeeHaircut, bk as applyUniswapQuoteHaircut, bl as chainConfigs, bm as convertCodecToIGetRequest, bn as convertCodecToIProof, bo as convertIGetRequestToCodec, bp as convertIProofToCodec, bq as convertStateIdToStateMachineId, br as convertStateMachineEnumToString, bs as convertStateMachineIdToEnum, bt as decodeAcceptedSourceChains, bu as decodeERC7821ExecuteBatch, bv as decodeFillOrder, bw as decodePhantomBidDeclaration, bx as decodePhantomBidPaymasterAndData, by as decodeUserOpScale, bz as deriveHttpUrl, bA as encodeAcceptedSourceChains, bB as encodeERC7821ExecuteBatch, bC as encodeFillOrder, bD as encodeISMPMessage, bE as encodePhantomBidDeclaration, bF as encodePhantomBidPaymasterAndData, bG as encodeUserOpScale, bH as getChainId, bI as getConfigByStateMachineId, bJ as getFillOptionsVersion, bK as getViemChain, bL as hyperbridgeAddress, bM as pharosAtlantic, bN as pharosMainnet, bO as polkadotAssetHubPaseo, bP as polkadotHubMainnet, bQ as poolSlug, bR as readProtocolFeeHaircutBps, bS as resetFillOptionsVersionCache, bT as sortPoolSymbols, bU as tronChainIds, bV as tronNile } from './intents-helpers-fntBuoYM.js';
|
|
3
3
|
import { ConsolaInstance } from 'consola';
|
|
4
4
|
import { GraphQLClient } from 'graphql-request';
|
|
5
5
|
import { PublicClient, TransactionReceipt, Hex, Address } from 'viem';
|
package/dist/node/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import { match } from 'ts-pattern';
|
|
|
10
10
|
import { WsProvider, ApiPromise, Keyring, HttpProvider } from '@polkadot/api';
|
|
11
11
|
import { Struct, Vector, u8, Bytes, Enum, Tuple, _void, u64, u32, Option, bool, u128 } from 'scale-ts';
|
|
12
12
|
import { xxhashAsU8a, keccakAsU8a, decodeAddress, keccakAsHex, blake2AsU8a } from '@polkadot/util-crypto';
|
|
13
|
-
import { u8aToHex, u8aConcat, hexToU8a,
|
|
13
|
+
import { u8aToHex, u8aConcat, hexToU8a, isHex as isHex$1 } from '@polkadot/util';
|
|
14
14
|
import PQueue from 'p-queue';
|
|
15
15
|
import { hasWindow, isNode, env } from 'std-env';
|
|
16
16
|
import mergeRace from '@async-generator/merge-race';
|
|
@@ -20546,13 +20546,116 @@ var IntentGateway = class _IntentGateway {
|
|
|
20546
20546
|
}
|
|
20547
20547
|
}
|
|
20548
20548
|
};
|
|
20549
|
-
|
|
20550
|
-
|
|
20549
|
+
function rpcFetch() {
|
|
20550
|
+
const f = globalThis.fetch;
|
|
20551
|
+
if (typeof f !== "function") {
|
|
20552
|
+
throw new Error("No fetch available; call setAggregationFetch() before using the aggregation helpers");
|
|
20553
|
+
}
|
|
20554
|
+
return f;
|
|
20555
|
+
}
|
|
20556
|
+
var PhantomRpcError = class extends Error {
|
|
20557
|
+
constructor(message, cause) {
|
|
20558
|
+
super(message);
|
|
20559
|
+
this.cause = cause;
|
|
20560
|
+
this.name = "PhantomRpcError";
|
|
20561
|
+
}
|
|
20562
|
+
cause;
|
|
20563
|
+
};
|
|
20564
|
+
async function rpcCall(url, payload) {
|
|
20565
|
+
let lastErr;
|
|
20566
|
+
for (let attempt = 0; attempt < 4; attempt++) {
|
|
20567
|
+
if (attempt > 0) await new Promise((resolve) => setTimeout(resolve, 150 * attempt));
|
|
20568
|
+
let timer;
|
|
20569
|
+
try {
|
|
20570
|
+
const timeout = new Promise((_, reject) => {
|
|
20571
|
+
timer = setTimeout(() => reject(new Error(`rpc timeout: ${url}`)), 12e3);
|
|
20572
|
+
});
|
|
20573
|
+
const response = await Promise.race([
|
|
20574
|
+
rpcFetch()(url, {
|
|
20575
|
+
method: "POST",
|
|
20576
|
+
headers: { accept: "application/json", "content-type": "application/json" },
|
|
20577
|
+
body: JSON.stringify(payload)
|
|
20578
|
+
}),
|
|
20579
|
+
timeout
|
|
20580
|
+
]);
|
|
20581
|
+
const body = await response.json();
|
|
20582
|
+
if (body?.error) {
|
|
20583
|
+
lastErr = new Error(`rpc error: ${JSON.stringify(body.error).slice(0, 200)}`);
|
|
20584
|
+
continue;
|
|
20585
|
+
}
|
|
20586
|
+
return body;
|
|
20587
|
+
} catch (err) {
|
|
20588
|
+
lastErr = err;
|
|
20589
|
+
} finally {
|
|
20590
|
+
if (timer) clearTimeout(timer);
|
|
20591
|
+
}
|
|
20592
|
+
}
|
|
20593
|
+
throw new PhantomRpcError(`RPC call failed after 4 attempts: ${url}`, lastErr);
|
|
20594
|
+
}
|
|
20551
20595
|
var FILL_ORDER_ABI = IntentGatewayV2_default.ABI;
|
|
20552
20596
|
var DECLARATION_V1 = 1;
|
|
20553
20597
|
var DECLARATION_V2 = 2;
|
|
20598
|
+
var PAYMASTER_ADDRESS_BYTES = 20;
|
|
20599
|
+
var PAYMASTER_GAS_LIMIT_BYTES = 16;
|
|
20600
|
+
var PAYMASTER_DATA_OFFSET = PAYMASTER_ADDRESS_BYTES + 2 * PAYMASTER_GAS_LIMIT_BYTES;
|
|
20601
|
+
var SIMPLEX_MODE_PERMIT2 = 2;
|
|
20602
|
+
var PERMIT2_DATA_BYTES = 1 + 20 + 32 + 32 + 32 + 1 + 32 + 32;
|
|
20603
|
+
var PERMIT2_SPONSORSHIP_BYTES = PAYMASTER_DATA_OFFSET + PERMIT2_DATA_BYTES;
|
|
20554
20604
|
var MAX_DECLARED_ENTRIES = 255;
|
|
20555
20605
|
var MAX_TOKEN_ID_BYTES = 32;
|
|
20606
|
+
function utf8Encode(text) {
|
|
20607
|
+
const bytes = [];
|
|
20608
|
+
for (const char of text) {
|
|
20609
|
+
const codePoint = char.codePointAt(0);
|
|
20610
|
+
if (codePoint < 128) bytes.push(codePoint);
|
|
20611
|
+
else if (codePoint < 2048) bytes.push(192 | codePoint >> 6, 128 | codePoint & 63);
|
|
20612
|
+
else if (codePoint < 65536) {
|
|
20613
|
+
bytes.push(224 | codePoint >> 12, 128 | codePoint >> 6 & 63, 128 | codePoint & 63);
|
|
20614
|
+
} else {
|
|
20615
|
+
bytes.push(
|
|
20616
|
+
240 | codePoint >> 18,
|
|
20617
|
+
128 | codePoint >> 12 & 63,
|
|
20618
|
+
128 | codePoint >> 6 & 63,
|
|
20619
|
+
128 | codePoint & 63
|
|
20620
|
+
);
|
|
20621
|
+
}
|
|
20622
|
+
}
|
|
20623
|
+
return bytes;
|
|
20624
|
+
}
|
|
20625
|
+
function utf8Decode(bytes) {
|
|
20626
|
+
let text = "";
|
|
20627
|
+
for (let offset = 0; offset < bytes.length; ) {
|
|
20628
|
+
const lead = bytes[offset];
|
|
20629
|
+
let codePoint;
|
|
20630
|
+
let continuations;
|
|
20631
|
+
if (lead < 128) {
|
|
20632
|
+
codePoint = lead;
|
|
20633
|
+
continuations = 0;
|
|
20634
|
+
} else if ((lead & 224) === 192) {
|
|
20635
|
+
codePoint = lead & 31;
|
|
20636
|
+
continuations = 1;
|
|
20637
|
+
} else if ((lead & 240) === 224) {
|
|
20638
|
+
codePoint = lead & 15;
|
|
20639
|
+
continuations = 2;
|
|
20640
|
+
} else if ((lead & 248) === 240) {
|
|
20641
|
+
codePoint = lead & 7;
|
|
20642
|
+
continuations = 3;
|
|
20643
|
+
} else {
|
|
20644
|
+
return null;
|
|
20645
|
+
}
|
|
20646
|
+
if (offset + continuations >= bytes.length) return null;
|
|
20647
|
+
for (let index = 1; index <= continuations; index++) {
|
|
20648
|
+
const byte = bytes[offset + index];
|
|
20649
|
+
if ((byte & 192) !== 128) return null;
|
|
20650
|
+
codePoint = codePoint << 6 | byte & 63;
|
|
20651
|
+
}
|
|
20652
|
+
const overlong = continuations === 1 && codePoint < 128 || continuations === 2 && codePoint < 2048 || continuations === 3 && codePoint < 65536;
|
|
20653
|
+
if (overlong || codePoint > 1114111 || codePoint >= 55296 && codePoint <= 57343) return null;
|
|
20654
|
+
text += String.fromCodePoint(codePoint);
|
|
20655
|
+
offset += continuations + 1;
|
|
20656
|
+
}
|
|
20657
|
+
return text;
|
|
20658
|
+
}
|
|
20556
20659
|
function tokenIdToBytes(tokenId) {
|
|
20557
20660
|
if (tokenId < 0n) throw new Error(`Uniswap V4 tokenId cannot be negative: ${tokenId}`);
|
|
20558
20661
|
const bytes = [];
|
|
@@ -20575,7 +20678,7 @@ function encodePhantomBidDeclaration(declaration) {
|
|
|
20575
20678
|
const version = positions.length > 0 ? DECLARATION_V2 : DECLARATION_V1;
|
|
20576
20679
|
const bytes = [version, chains2.length];
|
|
20577
20680
|
for (const chain of chains2) {
|
|
20578
|
-
const encoded =
|
|
20681
|
+
const encoded = utf8Encode(chain);
|
|
20579
20682
|
if (encoded.length === 0 || encoded.length > 255) {
|
|
20580
20683
|
throw new Error(`Invalid state machine id in source chain declaration: ${chain}`);
|
|
20581
20684
|
}
|
|
@@ -20593,42 +20696,94 @@ function encodePhantomBidDeclaration(declaration) {
|
|
|
20593
20696
|
}
|
|
20594
20697
|
return u8aToHex(new Uint8Array(bytes));
|
|
20595
20698
|
}
|
|
20596
|
-
function
|
|
20597
|
-
|
|
20598
|
-
|
|
20599
|
-
|
|
20600
|
-
if (bytes.length < 2) return absent;
|
|
20601
|
-
const version = bytes[0];
|
|
20602
|
-
if (version !== DECLARATION_V1 && version !== DECLARATION_V2) return absent;
|
|
20699
|
+
function parseDeclaration(bytes, start) {
|
|
20700
|
+
if (bytes.length - start < 2) return null;
|
|
20701
|
+
const version = bytes[start];
|
|
20702
|
+
if (version !== DECLARATION_V1 && version !== DECLARATION_V2) return null;
|
|
20603
20703
|
const chains2 = [];
|
|
20604
|
-
let offset = 2;
|
|
20605
|
-
for (let entry = 0; entry < bytes[1]; entry++) {
|
|
20606
|
-
if (offset >= bytes.length) return
|
|
20704
|
+
let offset = start + 2;
|
|
20705
|
+
for (let entry = 0; entry < bytes[start + 1]; entry++) {
|
|
20706
|
+
if (offset >= bytes.length) return null;
|
|
20607
20707
|
const length = bytes[offset];
|
|
20608
20708
|
offset += 1;
|
|
20609
|
-
if (length === 0 || offset + length > bytes.length) return
|
|
20610
|
-
|
|
20709
|
+
if (length === 0 || offset + length > bytes.length) return null;
|
|
20710
|
+
const chain = utf8Decode(bytes.subarray(offset, offset + length));
|
|
20711
|
+
if (chain === null) return null;
|
|
20712
|
+
chains2.push(chain);
|
|
20611
20713
|
offset += length;
|
|
20612
20714
|
}
|
|
20613
20715
|
const positions = [];
|
|
20614
20716
|
if (version === DECLARATION_V2) {
|
|
20615
|
-
if (offset >= bytes.length) return
|
|
20717
|
+
if (offset >= bytes.length) return null;
|
|
20616
20718
|
const count = bytes[offset];
|
|
20617
20719
|
offset += 1;
|
|
20618
20720
|
for (let entry = 0; entry < count; entry++) {
|
|
20619
|
-
if (offset >= bytes.length) return
|
|
20721
|
+
if (offset >= bytes.length) return null;
|
|
20620
20722
|
const length = bytes[offset];
|
|
20621
20723
|
offset += 1;
|
|
20622
|
-
if (length === 0 || length > MAX_TOKEN_ID_BYTES || offset + length > bytes.length) return
|
|
20623
|
-
|
|
20624
|
-
for (const byte of bytes.subarray(offset, offset + length)) tokenId = tokenId << 8n | BigInt(byte);
|
|
20625
|
-
positions.push(tokenId);
|
|
20724
|
+
if (length === 0 || length > MAX_TOKEN_ID_BYTES || offset + length > bytes.length) return null;
|
|
20725
|
+
positions.push(bytesToBigInt3(bytes.subarray(offset, offset + length)));
|
|
20626
20726
|
offset += length;
|
|
20627
20727
|
}
|
|
20628
20728
|
}
|
|
20629
|
-
if (offset !== bytes.length) return
|
|
20729
|
+
if (offset !== bytes.length) return null;
|
|
20630
20730
|
return { acceptedSources: chains2, uniswapV4Positions: positions };
|
|
20631
20731
|
}
|
|
20732
|
+
function bytesToBigInt3(bytes) {
|
|
20733
|
+
let value = 0n;
|
|
20734
|
+
for (const byte of bytes) value = value << 8n | BigInt(byte);
|
|
20735
|
+
return value;
|
|
20736
|
+
}
|
|
20737
|
+
function bytesToAddress(bytes) {
|
|
20738
|
+
return u8aToHex(bytes);
|
|
20739
|
+
}
|
|
20740
|
+
function hasPermit2Sponsorship(bytes) {
|
|
20741
|
+
return bytes.length >= PERMIT2_SPONSORSHIP_BYTES && bytes[PAYMASTER_DATA_OFFSET] === SIMPLEX_MODE_PERMIT2;
|
|
20742
|
+
}
|
|
20743
|
+
function parseSponsorship(bytes) {
|
|
20744
|
+
let offset = 0;
|
|
20745
|
+
const take = (length) => {
|
|
20746
|
+
const slice = bytes.subarray(offset, offset + length);
|
|
20747
|
+
offset += length;
|
|
20748
|
+
return slice;
|
|
20749
|
+
};
|
|
20750
|
+
const paymaster = bytesToAddress(take(PAYMASTER_ADDRESS_BYTES));
|
|
20751
|
+
take(2 * PAYMASTER_GAS_LIMIT_BYTES);
|
|
20752
|
+
take(1);
|
|
20753
|
+
const token = bytesToAddress(take(20));
|
|
20754
|
+
const permitAmount = bytesToBigInt3(take(32));
|
|
20755
|
+
const nonce = bytesToBigInt3(take(32));
|
|
20756
|
+
const deadline = bytesToBigInt3(take(32));
|
|
20757
|
+
return { paymaster, token, permitAmount, nonce, deadline };
|
|
20758
|
+
}
|
|
20759
|
+
var absentDeclaration = () => ({ acceptedSources: null, uniswapV4Positions: [] });
|
|
20760
|
+
function decodePhantomBidPaymasterAndData(paymasterAndData) {
|
|
20761
|
+
const none = { mode: "none", declaration: absentDeclaration(), sponsorship: null };
|
|
20762
|
+
if (!paymasterAndData || !isHex$1(paymasterAndData)) return none;
|
|
20763
|
+
const bytes = hexToU8a(paymasterAndData);
|
|
20764
|
+
const bare = parseDeclaration(bytes, 0);
|
|
20765
|
+
if (bare) return { mode: "declaration", declaration: bare, sponsorship: null };
|
|
20766
|
+
if (!hasPermit2Sponsorship(bytes)) return none;
|
|
20767
|
+
const sponsorship = parseSponsorship(bytes);
|
|
20768
|
+
const tail = bytes.length > PERMIT2_SPONSORSHIP_BYTES ? parseDeclaration(bytes, PERMIT2_SPONSORSHIP_BYTES) : null;
|
|
20769
|
+
return { mode: "permit2", declaration: tail ?? absentDeclaration(), sponsorship };
|
|
20770
|
+
}
|
|
20771
|
+
function decodePhantomBidDeclaration(paymasterAndData) {
|
|
20772
|
+
return decodePhantomBidPaymasterAndData(paymasterAndData).declaration;
|
|
20773
|
+
}
|
|
20774
|
+
function encodePhantomBidPaymasterAndData(bid) {
|
|
20775
|
+
const declaration = encodePhantomBidDeclaration(bid);
|
|
20776
|
+
const sponsorship = bid.sponsorship;
|
|
20777
|
+
if (!sponsorship || sponsorship === "0x") return declaration;
|
|
20778
|
+
if (!isHex$1(sponsorship)) throw new Error("Phantom bid sponsorship is not hex");
|
|
20779
|
+
const bytes = hexToU8a(sponsorship);
|
|
20780
|
+
if (bytes.length !== PERMIT2_SPONSORSHIP_BYTES || !hasPermit2Sponsorship(bytes)) {
|
|
20781
|
+
throw new Error(
|
|
20782
|
+
`Phantom bid sponsorship must be a ${PERMIT2_SPONSORSHIP_BYTES}-byte Permit2-mode paymasterAndData, got ${bytes.length} bytes`
|
|
20783
|
+
);
|
|
20784
|
+
}
|
|
20785
|
+
return `${sponsorship}${declaration.slice(2)}`;
|
|
20786
|
+
}
|
|
20632
20787
|
function encodeAcceptedSourceChains(chains2) {
|
|
20633
20788
|
return encodePhantomBidDeclaration({ acceptedSourceChains: chains2 });
|
|
20634
20789
|
}
|
|
@@ -20636,15 +20791,35 @@ function decodeAcceptedSourceChains(paymasterAndData) {
|
|
|
20636
20791
|
return decodePhantomBidDeclaration(paymasterAndData).acceptedSources;
|
|
20637
20792
|
}
|
|
20638
20793
|
var UNISWAP_QUOTE_HAIRCUT_BPS = 10n;
|
|
20639
|
-
var PHANTOM_QUOTE_HAIRCUT_BPS = 5n;
|
|
20640
20794
|
function haircut(amount, bps) {
|
|
20641
20795
|
return amount * (10000n - bps) / 10000n;
|
|
20642
20796
|
}
|
|
20643
20797
|
function applyUniswapQuoteHaircut(amount) {
|
|
20644
20798
|
return haircut(amount, UNISWAP_QUOTE_HAIRCUT_BPS);
|
|
20645
20799
|
}
|
|
20646
|
-
|
|
20647
|
-
|
|
20800
|
+
var SELECTOR_GATEWAY_PARAMS = "0xcff0ab96";
|
|
20801
|
+
var GATEWAY_PARAMS_WORDS = 6;
|
|
20802
|
+
var GATEWAY_PARAMS_FEE_WORD = 4;
|
|
20803
|
+
async function readProtocolFeeHaircutBps(evmRpcUrl, gatewayAddress) {
|
|
20804
|
+
const result = await rpcCall(evmRpcUrl, {
|
|
20805
|
+
id: 1,
|
|
20806
|
+
jsonrpc: "2.0",
|
|
20807
|
+
method: "eth_call",
|
|
20808
|
+
params: [{ to: gatewayAddress, data: SELECTOR_GATEWAY_PARAMS }, "latest"]
|
|
20809
|
+
});
|
|
20810
|
+
const hex = result.result;
|
|
20811
|
+
if (typeof hex !== "string" || hex.length < 2 + 64 * GATEWAY_PARAMS_WORDS) {
|
|
20812
|
+
throw new PhantomRpcError(`IntentGateway.params() returned no usable result from ${gatewayAddress} on ${evmRpcUrl}`);
|
|
20813
|
+
}
|
|
20814
|
+
const start = 2 + 64 * GATEWAY_PARAMS_FEE_WORD;
|
|
20815
|
+
const protocolFeeBps = BigInt(`0x${hex.slice(start, start + 64)}`);
|
|
20816
|
+
if (protocolFeeBps >= 10000n) {
|
|
20817
|
+
throw new PhantomRpcError(`IntentGateway ${gatewayAddress} reports an implausible protocol fee: ${protocolFeeBps} bps`);
|
|
20818
|
+
}
|
|
20819
|
+
return protocolFeeBps;
|
|
20820
|
+
}
|
|
20821
|
+
function applyProtocolFeeHaircut(amount, protocolFeeBps) {
|
|
20822
|
+
return haircut(amount, protocolFeeBps);
|
|
20648
20823
|
}
|
|
20649
20824
|
FILL_ORDER_ABI.find(
|
|
20650
20825
|
(item) => item?.type === "function" && item?.name === "fillOrder"
|
|
@@ -25119,6 +25294,6 @@ async function teleportDot(param_) {
|
|
|
25119
25294
|
return stream;
|
|
25120
25295
|
}
|
|
25121
25296
|
|
|
25122
|
-
export { ADDRESS_ZERO2 as ADDRESS_ZERO, BundlerMethod, CHAINS_WITHOUT_VALID_UNTIL, ChainConfigService, Chains, CryptoUtils, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DOMAIN_TYPEHASH, DUMMY_PRIVATE_KEY, ERC20Method, ERC7821_BATCH_MODE, EvmChain, ABI as EvmHostABI, EvmLanguage, FILL_ORDER_V1_ABI, HyperClientStatus, HyperFungibleToken, HyperFungibleTokenABI, INCLUSION_TIMEOUT_MS, IndexedRateUnavailableError, IntentGateway, ABI3 as IntentGatewayABI, IntentOrderStatus, IntentsCoprocessor, InvalidIndexedRateError, InvalidLiquidityIndexerResponseError, InvalidPhantomSnapshotError, IsmpClient, LEGACY_FILL_OPTIONS_IMPLEMENTATIONS, MOCK_ADDRESS, ORDER_V2_PARAM_TYPE, OrderStatus, OrderStatusChecker, PACKED_USEROP_TYPEHASH,
|
|
25297
|
+
export { ADDRESS_ZERO2 as ADDRESS_ZERO, BundlerMethod, CHAINS_WITHOUT_VALID_UNTIL, ChainConfigService, Chains, CryptoUtils, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DOMAIN_TYPEHASH, DUMMY_PRIVATE_KEY, ERC20Method, ERC7821_BATCH_MODE, EvmChain, ABI as EvmHostABI, EvmLanguage, FILL_ORDER_V1_ABI, HyperClientStatus, HyperFungibleToken, HyperFungibleTokenABI, INCLUSION_TIMEOUT_MS, IndexedRateUnavailableError, IntentGateway, ABI3 as IntentGatewayABI, IntentOrderStatus, IntentsCoprocessor, InvalidIndexedRateError, InvalidLiquidityIndexerResponseError, InvalidPhantomSnapshotError, IsmpClient, LEGACY_FILL_OPTIONS_IMPLEMENTATIONS, MOCK_ADDRESS, ORDER_V2_PARAM_TYPE, OrderStatus, OrderStatusChecker, PACKED_USEROP_TYPEHASH, PERMIT2_SPONSORSHIP_BYTES, 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, UNISWAP_QUOTE_HAIRCUT_BPS, USE_ETHERSCAN_CHAINS, UnsupportedIntentQuotePairError, UnsupportedIntentQuoteStrategyError, UnsupportedLiquidityAssetError, UnsupportedLiquidityChainError, WrappedHyperFungibleTokenABI, __test, adjustDecimals, applyProtocolFeeHaircut, applyUniswapQuoteHaircut, bytes20ToBytes32, bytes32ToBytes20, calculateAllowanceMappingLocation, calculateBalanceMappingLocation, chainConfigs, constructRedeemEscrowRequestBody, constructRefundEscrowRequestBody, convertCodecToIGetRequest, convertCodecToIProof, convertIGetRequestToCodec, convertIProofToCodec, convertStateIdToStateMachineId, convertStateMachineEnumToString, convertStateMachineIdToEnum, createEvmChain, createQueryClient, decodeAcceptedSourceChains, decodeERC7821ExecuteBatch, decodeFillOrder, decodePhantomBidDeclaration, decodePhantomBidPaymasterAndData, decodeUserOpScale, deriveHttpUrl, encodeAcceptedSourceChains, encodeERC7821ExecuteBatch, encodeFillOrder, encodeISMPMessage, encodePhantomBidDeclaration, encodePhantomBidPaymasterAndData, encodeStateMachineId, encodeUserOpScale, encodeWithdrawalRequest, estimateGasForPost, fetchPrice, fetchSourceProof, generateRootWithProof, getChainId, getConfigByStateMachineId, getContractCallInput, getContractCallInputs, getFillOptionsVersion, getGasPriceFromEtherscan, getOrFetchStorageSlot, getOrderPlacedFromTx, getPostRequestEventFromTx, getPostResponseEventFromTx, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, getViemChain, hexToString, hyperbridgeAddress, maxBigInt, normalizeAddressForEvmBytes32, normalizeAddressForStateMachine, normalizeEvmAddress, normalizeEvmChainId, normalizeStateMachineId, orderCommitment, parseStateMachineId, pharosAtlantic, pharosMainnet, polkadotAssetHubPaseo, polkadotHubMainnet, poolSlug, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, quoteUniswap, readProtocolFeeHaircutBps, requestCommitmentKey, resetFillOptionsVersionCache, responseCommitmentKey, retryPromise, sortPoolSymbols, teleport, teleportDot, transformOrderForContract, tronChainIds, tronNile };
|
|
25123
25298
|
//# sourceMappingURL=index.js.map
|
|
25124
25299
|
//# sourceMappingURL=index.js.map
|