@hyperbridge/sdk 2.8.12 → 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 +61 -2
- package/dist/browser/index.js +133 -22
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +134 -20
- 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 +133 -22
- package/dist/node/index.js.map +1 -1
- package/dist/node/{intents-helpers-C9PJp8rx.d.cts → intents-helpers-fntBuoYM.d.cts} +61 -2
- package/dist/node/{intents-helpers-C9PJp8rx.d.ts → intents-helpers-fntBuoYM.d.ts} +61 -2
- package/dist/node/intents-helpers.cjs +135 -21
- 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 +134 -23
- package/dist/node/intents-helpers.js.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.d.ts
CHANGED
|
@@ -6492,6 +6492,24 @@ declare function decodeFillOrder(data: HexString$1): {
|
|
|
6492
6492
|
} | null;
|
|
6493
6493
|
|
|
6494
6494
|
type HexString = `0x${string}`;
|
|
6495
|
+
/** A complete Permit2-sponsored paymasterAndData, before any declaration is appended. */
|
|
6496
|
+
declare const PERMIT2_SPONSORSHIP_BYTES: number;
|
|
6497
|
+
/**
|
|
6498
|
+
* The Permit2 sponsorship a bid's paymasterAndData carries when it was built on the real-bid path:
|
|
6499
|
+
* which paymaster it names and the fee-token permit it signed for that paymaster. Read for the
|
|
6500
|
+
* record only — the bid's authenticity comes from the solver signature over the userOpHash, which
|
|
6501
|
+
* covers these bytes, so nothing here is verified further and the permit signature is not kept.
|
|
6502
|
+
*/
|
|
6503
|
+
interface PhantomBidSponsorship {
|
|
6504
|
+
paymaster: HexString;
|
|
6505
|
+
/** The fee token the permit draws on. */
|
|
6506
|
+
token: HexString;
|
|
6507
|
+
permitAmount: bigint;
|
|
6508
|
+
/** Permit2 unordered nonce — random per op, which is what lets a solver's bids run in parallel. */
|
|
6509
|
+
nonce: bigint;
|
|
6510
|
+
/** Unix seconds after which the permit is unusable. */
|
|
6511
|
+
deadline: bigint;
|
|
6512
|
+
}
|
|
6495
6513
|
/** What a phantom bid's paymasterAndData declares about the solver behind it. */
|
|
6496
6514
|
interface PhantomBidDeclaration {
|
|
6497
6515
|
/**
|
|
@@ -6515,12 +6533,53 @@ declare function encodePhantomBidDeclaration(declaration: {
|
|
|
6515
6533
|
acceptedSourceChains?: string[];
|
|
6516
6534
|
uniswapV4Positions?: bigint[];
|
|
6517
6535
|
}): HexString;
|
|
6536
|
+
/** Everything a phantom bid's paymasterAndData was found to carry. */
|
|
6537
|
+
interface PhantomBidPaymasterAndData {
|
|
6538
|
+
/**
|
|
6539
|
+
* Which shape the field was read as: a bare declaration, a Permit2-sponsored bid (with or
|
|
6540
|
+
* without a declaration appended), or neither — empty, or bytes matching no known layout.
|
|
6541
|
+
*/
|
|
6542
|
+
mode: "declaration" | "permit2" | "none";
|
|
6543
|
+
/** Never null: an unreadable or missing declaration is the absent one (null sources, no positions). */
|
|
6544
|
+
declaration: PhantomBidDeclaration;
|
|
6545
|
+
/** The paymaster fields of a sponsored bid; null for the other two modes. */
|
|
6546
|
+
sponsorship: PhantomBidSponsorship | null;
|
|
6547
|
+
}
|
|
6548
|
+
/**
|
|
6549
|
+
* Decodes a phantom bid's paymasterAndData in whichever shape it takes.
|
|
6550
|
+
*
|
|
6551
|
+
* A bare declaration is tried first, so every bid placed before sponsored phantom bids existed
|
|
6552
|
+
* decodes to the byte exactly as it did. Failing that, a blob opening with a complete
|
|
6553
|
+
* Permit2-sponsored payload is read as a sponsored bid, and whatever follows the permit is parsed
|
|
6554
|
+
* as its declaration. Both parsers demand exact consumption — a bare declaration must end where
|
|
6555
|
+
* the bytes end, and a sponsored bid's tail must be a whole declaration or nothing — so neither
|
|
6556
|
+
* shape can be half-read as the other.
|
|
6557
|
+
*
|
|
6558
|
+
* A malformed tail on a sponsored bid yields the absent declaration but still reports the
|
|
6559
|
+
* sponsorship: the bid is still a bid, it just declared nothing readable.
|
|
6560
|
+
*/
|
|
6561
|
+
declare function decodePhantomBidPaymasterAndData(paymasterAndData: string | undefined | null): PhantomBidPaymasterAndData;
|
|
6518
6562
|
/**
|
|
6519
|
-
* Decodes a phantom bid's paymasterAndData
|
|
6563
|
+
* Decodes the declaration out of a phantom bid's paymasterAndData, whichever shape it takes (see
|
|
6564
|
+
* {@link decodePhantomBidPaymasterAndData}). Understands both declaration versions, so bids placed
|
|
6520
6565
|
* before positions existed keep decoding unchanged. Anything absent, unversioned or malformed
|
|
6521
6566
|
* yields a null `acceptedSources` with no positions — never a partial read.
|
|
6522
6567
|
*/
|
|
6523
6568
|
declare function decodePhantomBidDeclaration(paymasterAndData: string | undefined | null): PhantomBidDeclaration;
|
|
6569
|
+
/**
|
|
6570
|
+
* Builds a phantom bid's paymasterAndData: the declaration alone, or appended to a Permit2
|
|
6571
|
+
* sponsorship when the bid was built on the real-bid path and carries one.
|
|
6572
|
+
*
|
|
6573
|
+
* `sponsorship` is the packed EntryPoint v0.8 paymasterAndData the paymaster builder produced. It
|
|
6574
|
+
* must be exactly the Permit2-mode layout — the only one the decoder recognises — so a caller
|
|
6575
|
+
* cannot sign bytes the aggregation would read as "no declaration"; anything else throws. Empty
|
|
6576
|
+
* or omitted, the result is the bare declaration, byte-identical to what unsponsored bids carry.
|
|
6577
|
+
*/
|
|
6578
|
+
declare function encodePhantomBidPaymasterAndData(bid: {
|
|
6579
|
+
sponsorship?: HexString | null;
|
|
6580
|
+
acceptedSourceChains?: string[];
|
|
6581
|
+
uniswapV4Positions?: bigint[];
|
|
6582
|
+
}): HexString;
|
|
6524
6583
|
/** Back-compat wrapper: the source-chain half of {@link encodePhantomBidDeclaration}. */
|
|
6525
6584
|
declare function encodeAcceptedSourceChains(chains: string[]): HexString;
|
|
6526
6585
|
/** Back-compat wrapper: the source-chain half of {@link decodePhantomBidDeclaration}. */
|
|
@@ -11580,4 +11639,4 @@ declare function teleport(teleport_param: {
|
|
|
11580
11639
|
extrinsics?: Array<SubmittableExtrinsic<"promise", ISubmittableResult>>;
|
|
11581
11640
|
}): Promise<ReadableStream<HyperbridgeTxEvents>>;
|
|
11582
11641
|
|
|
11583
|
-
export { ADDRESS_ZERO, type AllStatusKey, type AssetTeleported, type AssetTeleportedResponse, type AvailableLiquidity, type Bid, type BidStorageEntry, type BidSubmissionResult, type BlockMetadata, type BridgeParams, type BridgeStep, type BundlerGasEstimate, BundlerMethod, type BuyAndSellRates, type BytesLikeHex, CHAINS_WITHOUT_VALID_UNTIL, type CancelEvent, type CancelOptions, type CancelOrderOptions, type CancelQuote, type ChainConfig, type ChainConfigData, ChainConfigService, Chains, type ClientConfig, type ConfiguredAssetSymbol, type ConfiguredAssetSymbolInput, CryptoUtils, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DOMAIN_TYPEHASH, DUMMY_PRIVATE_KEY, type DecodedOrderPlacedLog, type DecodedPostRequestEvent, type DecodedPostResponseEvent, type Deployment, type DispatchGet, type DispatchInfo, type DispatchPost, ERC20Method, type ERC7821Call, ERC7821_BATCH_MODE, type Erc4626VaultConfigData, type EstimateFillOrderParams, type EstimateGasCallData, EvmChain, type EvmChainParams, ABI as EvmHostABI, EvmLanguage, type ExecuteIntentOrderOptions, type ExecutionResult, FILL_ORDER_V1_ABI, type FillOptions, type FillOptionsVersion, type FillOrderEstimate, type FillerBid, type FillerConfig, type GetRequestResponse, type GetRequestWithStatus, type GetResponseByRequestIdResponse, type GetResponseStorageValues, type HexString$1 as HexString, type HostParams, HyperClientStatus, HyperFungibleToken, HyperFungibleTokenABI, type HyperbridgeTxEvents, type IBatchConsensusAndGetResponseMessage, type IBatchConsensusAndPostRequestMessage, type IChain, type IConfig, type IConsensusMessage, type IEvmChain, type IEvmConfig, type IGetRequest, type IGetRequestMessage, type IGetResponse, type IGetResponseMessage, type IHyperbridgeConfig, type IIsmpMessage, type IMessage, INCLUSION_TIMEOUT_MS, type IPharosConfig, type IPolkadotHubConfig, type IPostRequest, type IPostResponse, type IProof, type IRequestMessage, type ISubstrateConfig, type ITimeoutPostRequestMessage, type IndexedRateIntentQuoteMetadata, type IndexedRateQuoteIntentResult, type IndexedRateSide, IndexedRateUnavailableError, type IndexerQueryClient, IntentGateway, ABI$1 as IntentGatewayABI, type IntentGatewayContext, type IntentGatewayParams, IntentOrderStatus, type IntentOrderStatusKey, type IntentOrderStatusUpdate, type IntentQuoteStrategy, type IntentQuoteTradeType, IntentsCoprocessor, InvalidIndexedRateError, InvalidLiquidityIndexerResponseError, InvalidPhantomSnapshotError, IsmpClient, type IsmpRequest, LEGACY_FILL_OPTIONS_IMPLEMENTATIONS, type LiquiditySlice, MOCK_ADDRESS, ORDER_V2_PARAM_TYPE, type Order, type OrderFeesQuote, type OrderResponse, OrderStatus, OrderStatusChecker, type OrderStatusMetadata, type OrderWithStatus, PACKED_USEROP_TYPEHASH, PLACE_ORDER_SELECTOR, type PackedUserOperation, type Params, type PaymentInfo, type PhantomBid, type PhantomBidBatchResult, type PhantomBidDeclaration, type PhantomBidOutcome, type PhantomOrderEvent, type PhantomOrderLeg, type PhantomOrderPriceSnapshot, type PhantomOrderPriceSnapshotsResponse, type PhantomSnapshotIntentQuoteMetadata, type PhantomSnapshotQuoteIntentResult, PhantomSnapshotUnavailableError, type PhantomTimings, PharosChain, type PharosChainParams, PolkadotHubChain, type PolkadotHubChainParams, type PollPhantomOrdersOptions, type PostRequestStatus, type PostRequestTimeoutStatus, type PostRequestWithStatus, type QueryBuyAndSellRatesParams, type QuoteIntentParams, type QuoteIntentResult, type QuoteNativeResult, type QuoteResult, type QuoteUniswapParams, type QuoteUniswapResult, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, type RequestBody, type RequestCommitment, RequestKind, type RequestResponse, RequestStatus, type RequestStatusKey, type RequestStatusWithMetadata, type ResponseCommitmentWithValues, type ResumeIntentOrderOptions, type RetryConfig, SELECT_SOLVER_TYPEHASH, STATE_COMMITMENTS_SLOT, type SelectBidResult, type SelectOptions, type SigningAccount, type StateMachineHeight, type StateMachineId, type StateMachineIdParams, type StateMachineResponse, type StateMachineUpdate, type StorageFacade, type SubmitBidOptions, SubstrateChain, Swap, TESTNET_CHAINS, type TeleportParams, TeleportStatus, TimeoutStatus, type TimeoutStatusKey, TokenGateway, type TokenGatewayAssetTeleportedResponse, type TokenGatewayAssetTeleportedWithStatus, type TokenInfo, type TokenPrice, type TokenPricesResponse, type Transaction, TronChain, type TronChainParams, UNISWAP_QUOTE_HAIRCUT_BPS, USE_ETHERSCAN_CHAINS, type UniswapProtocol, type UniswapQuote, type UniswapQuoteToken, type UniswapTradeType, type UniswapV4IntentQuoteMetadata, type UniswapV4IntentQuoteOptions, type UniswapV4PoolConfigData, type UniswapV4PoolKey, type UniswapV4QuoteIntentResult, UnsupportedIntentQuotePairError, UnsupportedIntentQuoteStrategyError, UnsupportedLiquidityAssetError, UnsupportedLiquidityChainError, WrappedHyperFungibleTokenABI, type XcmGatewayParams, __test, adjustDecimals, applyProtocolFeeHaircut, applyUniswapQuoteHaircut, bytes20ToBytes32, bytes32ToBytes20, calculateAllowanceMappingLocation, calculateBalanceMappingLocation, chainConfigs, constructRedeemEscrowRequestBody, constructRefundEscrowRequestBody, convertCodecToIGetRequest, convertCodecToIProof, convertIGetRequestToCodec, convertIProofToCodec, convertStateIdToStateMachineId, convertStateMachineEnumToString, convertStateMachineIdToEnum, createEvmChain, createQueryClient, decodeAcceptedSourceChains, decodeERC7821ExecuteBatch, decodeFillOrder, decodePhantomBidDeclaration, decodeUserOpScale, deriveHttpUrl, encodeAcceptedSourceChains, encodeERC7821ExecuteBatch, encodeFillOrder, encodeISMPMessage, encodePhantomBidDeclaration, 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 };
|
|
11642
|
+
export { ADDRESS_ZERO, type AllStatusKey, type AssetTeleported, type AssetTeleportedResponse, type AvailableLiquidity, type Bid, type BidStorageEntry, type BidSubmissionResult, type BlockMetadata, type BridgeParams, type BridgeStep, type BundlerGasEstimate, BundlerMethod, type BuyAndSellRates, type BytesLikeHex, CHAINS_WITHOUT_VALID_UNTIL, type CancelEvent, type CancelOptions, type CancelOrderOptions, type CancelQuote, type ChainConfig, type ChainConfigData, ChainConfigService, Chains, type ClientConfig, type ConfiguredAssetSymbol, type ConfiguredAssetSymbolInput, CryptoUtils, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DOMAIN_TYPEHASH, DUMMY_PRIVATE_KEY, type DecodedOrderPlacedLog, type DecodedPostRequestEvent, type DecodedPostResponseEvent, type Deployment, type DispatchGet, type DispatchInfo, type DispatchPost, ERC20Method, type ERC7821Call, ERC7821_BATCH_MODE, type Erc4626VaultConfigData, type EstimateFillOrderParams, type EstimateGasCallData, EvmChain, type EvmChainParams, ABI as EvmHostABI, EvmLanguage, type ExecuteIntentOrderOptions, type ExecutionResult, FILL_ORDER_V1_ABI, type FillOptions, type FillOptionsVersion, type FillOrderEstimate, type FillerBid, type FillerConfig, type GetRequestResponse, type GetRequestWithStatus, type GetResponseByRequestIdResponse, type GetResponseStorageValues, type HexString$1 as HexString, type HostParams, HyperClientStatus, HyperFungibleToken, HyperFungibleTokenABI, type HyperbridgeTxEvents, type IBatchConsensusAndGetResponseMessage, type IBatchConsensusAndPostRequestMessage, type IChain, type IConfig, type IConsensusMessage, type IEvmChain, type IEvmConfig, type IGetRequest, type IGetRequestMessage, type IGetResponse, type IGetResponseMessage, type IHyperbridgeConfig, type IIsmpMessage, type IMessage, INCLUSION_TIMEOUT_MS, type IPharosConfig, type IPolkadotHubConfig, type IPostRequest, type IPostResponse, type IProof, type IRequestMessage, type ISubstrateConfig, type ITimeoutPostRequestMessage, type IndexedRateIntentQuoteMetadata, type IndexedRateQuoteIntentResult, type IndexedRateSide, IndexedRateUnavailableError, type IndexerQueryClient, IntentGateway, ABI$1 as IntentGatewayABI, type IntentGatewayContext, type IntentGatewayParams, IntentOrderStatus, type IntentOrderStatusKey, type IntentOrderStatusUpdate, type IntentQuoteStrategy, type IntentQuoteTradeType, IntentsCoprocessor, InvalidIndexedRateError, InvalidLiquidityIndexerResponseError, InvalidPhantomSnapshotError, IsmpClient, type IsmpRequest, LEGACY_FILL_OPTIONS_IMPLEMENTATIONS, type LiquiditySlice, MOCK_ADDRESS, ORDER_V2_PARAM_TYPE, type Order, type OrderFeesQuote, type OrderResponse, OrderStatus, OrderStatusChecker, type OrderStatusMetadata, type OrderWithStatus, PACKED_USEROP_TYPEHASH, PERMIT2_SPONSORSHIP_BYTES, PLACE_ORDER_SELECTOR, type PackedUserOperation, type Params, type PaymentInfo, type PhantomBid, type PhantomBidBatchResult, type PhantomBidDeclaration, type PhantomBidOutcome, type PhantomBidPaymasterAndData, type PhantomBidSponsorship, type PhantomOrderEvent, type PhantomOrderLeg, type PhantomOrderPriceSnapshot, type PhantomOrderPriceSnapshotsResponse, type PhantomSnapshotIntentQuoteMetadata, type PhantomSnapshotQuoteIntentResult, PhantomSnapshotUnavailableError, type PhantomTimings, PharosChain, type PharosChainParams, PolkadotHubChain, type PolkadotHubChainParams, type PollPhantomOrdersOptions, type PostRequestStatus, type PostRequestTimeoutStatus, type PostRequestWithStatus, type QueryBuyAndSellRatesParams, type QuoteIntentParams, type QuoteIntentResult, type QuoteNativeResult, type QuoteResult, type QuoteUniswapParams, type QuoteUniswapResult, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, type RequestBody, type RequestCommitment, RequestKind, type RequestResponse, RequestStatus, type RequestStatusKey, type RequestStatusWithMetadata, type ResponseCommitmentWithValues, type ResumeIntentOrderOptions, type RetryConfig, SELECT_SOLVER_TYPEHASH, STATE_COMMITMENTS_SLOT, type SelectBidResult, type SelectOptions, type SigningAccount, type StateMachineHeight, type StateMachineId, type StateMachineIdParams, type StateMachineResponse, type StateMachineUpdate, type StorageFacade, type SubmitBidOptions, SubstrateChain, Swap, TESTNET_CHAINS, type TeleportParams, TeleportStatus, TimeoutStatus, type TimeoutStatusKey, TokenGateway, type TokenGatewayAssetTeleportedResponse, type TokenGatewayAssetTeleportedWithStatus, type TokenInfo, type TokenPrice, type TokenPricesResponse, type Transaction, TronChain, type TronChainParams, UNISWAP_QUOTE_HAIRCUT_BPS, USE_ETHERSCAN_CHAINS, type UniswapProtocol, type UniswapQuote, type UniswapQuoteToken, type UniswapTradeType, type UniswapV4IntentQuoteMetadata, type UniswapV4IntentQuoteOptions, type UniswapV4PoolConfigData, type UniswapV4PoolKey, type UniswapV4QuoteIntentResult, UnsupportedIntentQuotePairError, UnsupportedIntentQuoteStrategyError, UnsupportedLiquidityAssetError, UnsupportedLiquidityChainError, WrappedHyperFungibleTokenABI, type XcmGatewayParams, __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 };
|
package/dist/browser/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { match } from 'ts-pattern';
|
|
|
7
7
|
import { WsProvider, ApiPromise, Keyring, HttpProvider } from '@polkadot/api';
|
|
8
8
|
import { Struct, Vector, u8, Bytes, Enum, Tuple, _void, u64, u32, Option, bool, u128 } from 'scale-ts';
|
|
9
9
|
import { xxhashAsU8a, keccakAsU8a, decodeAddress, keccakAsHex, blake2AsU8a } from '@polkadot/util-crypto';
|
|
10
|
-
import { u8aToHex, u8aConcat, hexToU8a,
|
|
10
|
+
import { u8aToHex, u8aConcat, hexToU8a, isHex as isHex$1 } 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';
|
|
@@ -20655,8 +20655,67 @@ async function rpcCall(url, payload) {
|
|
|
20655
20655
|
var FILL_ORDER_ABI = IntentGatewayV2_default.ABI;
|
|
20656
20656
|
var DECLARATION_V1 = 1;
|
|
20657
20657
|
var DECLARATION_V2 = 2;
|
|
20658
|
+
var PAYMASTER_ADDRESS_BYTES = 20;
|
|
20659
|
+
var PAYMASTER_GAS_LIMIT_BYTES = 16;
|
|
20660
|
+
var PAYMASTER_DATA_OFFSET = PAYMASTER_ADDRESS_BYTES + 2 * PAYMASTER_GAS_LIMIT_BYTES;
|
|
20661
|
+
var SIMPLEX_MODE_PERMIT2 = 2;
|
|
20662
|
+
var PERMIT2_DATA_BYTES = 1 + 20 + 32 + 32 + 32 + 1 + 32 + 32;
|
|
20663
|
+
var PERMIT2_SPONSORSHIP_BYTES = PAYMASTER_DATA_OFFSET + PERMIT2_DATA_BYTES;
|
|
20658
20664
|
var MAX_DECLARED_ENTRIES = 255;
|
|
20659
20665
|
var MAX_TOKEN_ID_BYTES = 32;
|
|
20666
|
+
function utf8Encode(text) {
|
|
20667
|
+
const bytes = [];
|
|
20668
|
+
for (const char of text) {
|
|
20669
|
+
const codePoint = char.codePointAt(0);
|
|
20670
|
+
if (codePoint < 128) bytes.push(codePoint);
|
|
20671
|
+
else if (codePoint < 2048) bytes.push(192 | codePoint >> 6, 128 | codePoint & 63);
|
|
20672
|
+
else if (codePoint < 65536) {
|
|
20673
|
+
bytes.push(224 | codePoint >> 12, 128 | codePoint >> 6 & 63, 128 | codePoint & 63);
|
|
20674
|
+
} else {
|
|
20675
|
+
bytes.push(
|
|
20676
|
+
240 | codePoint >> 18,
|
|
20677
|
+
128 | codePoint >> 12 & 63,
|
|
20678
|
+
128 | codePoint >> 6 & 63,
|
|
20679
|
+
128 | codePoint & 63
|
|
20680
|
+
);
|
|
20681
|
+
}
|
|
20682
|
+
}
|
|
20683
|
+
return bytes;
|
|
20684
|
+
}
|
|
20685
|
+
function utf8Decode(bytes) {
|
|
20686
|
+
let text = "";
|
|
20687
|
+
for (let offset = 0; offset < bytes.length; ) {
|
|
20688
|
+
const lead = bytes[offset];
|
|
20689
|
+
let codePoint;
|
|
20690
|
+
let continuations;
|
|
20691
|
+
if (lead < 128) {
|
|
20692
|
+
codePoint = lead;
|
|
20693
|
+
continuations = 0;
|
|
20694
|
+
} else if ((lead & 224) === 192) {
|
|
20695
|
+
codePoint = lead & 31;
|
|
20696
|
+
continuations = 1;
|
|
20697
|
+
} else if ((lead & 240) === 224) {
|
|
20698
|
+
codePoint = lead & 15;
|
|
20699
|
+
continuations = 2;
|
|
20700
|
+
} else if ((lead & 248) === 240) {
|
|
20701
|
+
codePoint = lead & 7;
|
|
20702
|
+
continuations = 3;
|
|
20703
|
+
} else {
|
|
20704
|
+
return null;
|
|
20705
|
+
}
|
|
20706
|
+
if (offset + continuations >= bytes.length) return null;
|
|
20707
|
+
for (let index = 1; index <= continuations; index++) {
|
|
20708
|
+
const byte = bytes[offset + index];
|
|
20709
|
+
if ((byte & 192) !== 128) return null;
|
|
20710
|
+
codePoint = codePoint << 6 | byte & 63;
|
|
20711
|
+
}
|
|
20712
|
+
const overlong = continuations === 1 && codePoint < 128 || continuations === 2 && codePoint < 2048 || continuations === 3 && codePoint < 65536;
|
|
20713
|
+
if (overlong || codePoint > 1114111 || codePoint >= 55296 && codePoint <= 57343) return null;
|
|
20714
|
+
text += String.fromCodePoint(codePoint);
|
|
20715
|
+
offset += continuations + 1;
|
|
20716
|
+
}
|
|
20717
|
+
return text;
|
|
20718
|
+
}
|
|
20660
20719
|
function tokenIdToBytes(tokenId) {
|
|
20661
20720
|
if (tokenId < 0n) throw new Error(`Uniswap V4 tokenId cannot be negative: ${tokenId}`);
|
|
20662
20721
|
const bytes = [];
|
|
@@ -20679,7 +20738,7 @@ function encodePhantomBidDeclaration(declaration) {
|
|
|
20679
20738
|
const version = positions.length > 0 ? DECLARATION_V2 : DECLARATION_V1;
|
|
20680
20739
|
const bytes = [version, chains2.length];
|
|
20681
20740
|
for (const chain of chains2) {
|
|
20682
|
-
const encoded =
|
|
20741
|
+
const encoded = utf8Encode(chain);
|
|
20683
20742
|
if (encoded.length === 0 || encoded.length > 255) {
|
|
20684
20743
|
throw new Error(`Invalid state machine id in source chain declaration: ${chain}`);
|
|
20685
20744
|
}
|
|
@@ -20697,42 +20756,94 @@ function encodePhantomBidDeclaration(declaration) {
|
|
|
20697
20756
|
}
|
|
20698
20757
|
return u8aToHex(new Uint8Array(bytes));
|
|
20699
20758
|
}
|
|
20700
|
-
function
|
|
20701
|
-
|
|
20702
|
-
|
|
20703
|
-
|
|
20704
|
-
if (bytes.length < 2) return absent;
|
|
20705
|
-
const version = bytes[0];
|
|
20706
|
-
if (version !== DECLARATION_V1 && version !== DECLARATION_V2) return absent;
|
|
20759
|
+
function parseDeclaration(bytes, start) {
|
|
20760
|
+
if (bytes.length - start < 2) return null;
|
|
20761
|
+
const version = bytes[start];
|
|
20762
|
+
if (version !== DECLARATION_V1 && version !== DECLARATION_V2) return null;
|
|
20707
20763
|
const chains2 = [];
|
|
20708
|
-
let offset = 2;
|
|
20709
|
-
for (let entry = 0; entry < bytes[1]; entry++) {
|
|
20710
|
-
if (offset >= bytes.length) return
|
|
20764
|
+
let offset = start + 2;
|
|
20765
|
+
for (let entry = 0; entry < bytes[start + 1]; entry++) {
|
|
20766
|
+
if (offset >= bytes.length) return null;
|
|
20711
20767
|
const length = bytes[offset];
|
|
20712
20768
|
offset += 1;
|
|
20713
|
-
if (length === 0 || offset + length > bytes.length) return
|
|
20714
|
-
|
|
20769
|
+
if (length === 0 || offset + length > bytes.length) return null;
|
|
20770
|
+
const chain = utf8Decode(bytes.subarray(offset, offset + length));
|
|
20771
|
+
if (chain === null) return null;
|
|
20772
|
+
chains2.push(chain);
|
|
20715
20773
|
offset += length;
|
|
20716
20774
|
}
|
|
20717
20775
|
const positions = [];
|
|
20718
20776
|
if (version === DECLARATION_V2) {
|
|
20719
|
-
if (offset >= bytes.length) return
|
|
20777
|
+
if (offset >= bytes.length) return null;
|
|
20720
20778
|
const count = bytes[offset];
|
|
20721
20779
|
offset += 1;
|
|
20722
20780
|
for (let entry = 0; entry < count; entry++) {
|
|
20723
|
-
if (offset >= bytes.length) return
|
|
20781
|
+
if (offset >= bytes.length) return null;
|
|
20724
20782
|
const length = bytes[offset];
|
|
20725
20783
|
offset += 1;
|
|
20726
|
-
if (length === 0 || length > MAX_TOKEN_ID_BYTES || offset + length > bytes.length) return
|
|
20727
|
-
|
|
20728
|
-
for (const byte of bytes.subarray(offset, offset + length)) tokenId = tokenId << 8n | BigInt(byte);
|
|
20729
|
-
positions.push(tokenId);
|
|
20784
|
+
if (length === 0 || length > MAX_TOKEN_ID_BYTES || offset + length > bytes.length) return null;
|
|
20785
|
+
positions.push(bytesToBigInt3(bytes.subarray(offset, offset + length)));
|
|
20730
20786
|
offset += length;
|
|
20731
20787
|
}
|
|
20732
20788
|
}
|
|
20733
|
-
if (offset !== bytes.length) return
|
|
20789
|
+
if (offset !== bytes.length) return null;
|
|
20734
20790
|
return { acceptedSources: chains2, uniswapV4Positions: positions };
|
|
20735
20791
|
}
|
|
20792
|
+
function bytesToBigInt3(bytes) {
|
|
20793
|
+
let value = 0n;
|
|
20794
|
+
for (const byte of bytes) value = value << 8n | BigInt(byte);
|
|
20795
|
+
return value;
|
|
20796
|
+
}
|
|
20797
|
+
function bytesToAddress(bytes) {
|
|
20798
|
+
return u8aToHex(bytes);
|
|
20799
|
+
}
|
|
20800
|
+
function hasPermit2Sponsorship(bytes) {
|
|
20801
|
+
return bytes.length >= PERMIT2_SPONSORSHIP_BYTES && bytes[PAYMASTER_DATA_OFFSET] === SIMPLEX_MODE_PERMIT2;
|
|
20802
|
+
}
|
|
20803
|
+
function parseSponsorship(bytes) {
|
|
20804
|
+
let offset = 0;
|
|
20805
|
+
const take = (length) => {
|
|
20806
|
+
const slice = bytes.subarray(offset, offset + length);
|
|
20807
|
+
offset += length;
|
|
20808
|
+
return slice;
|
|
20809
|
+
};
|
|
20810
|
+
const paymaster = bytesToAddress(take(PAYMASTER_ADDRESS_BYTES));
|
|
20811
|
+
take(2 * PAYMASTER_GAS_LIMIT_BYTES);
|
|
20812
|
+
take(1);
|
|
20813
|
+
const token = bytesToAddress(take(20));
|
|
20814
|
+
const permitAmount = bytesToBigInt3(take(32));
|
|
20815
|
+
const nonce = bytesToBigInt3(take(32));
|
|
20816
|
+
const deadline = bytesToBigInt3(take(32));
|
|
20817
|
+
return { paymaster, token, permitAmount, nonce, deadline };
|
|
20818
|
+
}
|
|
20819
|
+
var absentDeclaration = () => ({ acceptedSources: null, uniswapV4Positions: [] });
|
|
20820
|
+
function decodePhantomBidPaymasterAndData(paymasterAndData) {
|
|
20821
|
+
const none = { mode: "none", declaration: absentDeclaration(), sponsorship: null };
|
|
20822
|
+
if (!paymasterAndData || !isHex$1(paymasterAndData)) return none;
|
|
20823
|
+
const bytes = hexToU8a(paymasterAndData);
|
|
20824
|
+
const bare = parseDeclaration(bytes, 0);
|
|
20825
|
+
if (bare) return { mode: "declaration", declaration: bare, sponsorship: null };
|
|
20826
|
+
if (!hasPermit2Sponsorship(bytes)) return none;
|
|
20827
|
+
const sponsorship = parseSponsorship(bytes);
|
|
20828
|
+
const tail = bytes.length > PERMIT2_SPONSORSHIP_BYTES ? parseDeclaration(bytes, PERMIT2_SPONSORSHIP_BYTES) : null;
|
|
20829
|
+
return { mode: "permit2", declaration: tail ?? absentDeclaration(), sponsorship };
|
|
20830
|
+
}
|
|
20831
|
+
function decodePhantomBidDeclaration(paymasterAndData) {
|
|
20832
|
+
return decodePhantomBidPaymasterAndData(paymasterAndData).declaration;
|
|
20833
|
+
}
|
|
20834
|
+
function encodePhantomBidPaymasterAndData(bid) {
|
|
20835
|
+
const declaration = encodePhantomBidDeclaration(bid);
|
|
20836
|
+
const sponsorship = bid.sponsorship;
|
|
20837
|
+
if (!sponsorship || sponsorship === "0x") return declaration;
|
|
20838
|
+
if (!isHex$1(sponsorship)) throw new Error("Phantom bid sponsorship is not hex");
|
|
20839
|
+
const bytes = hexToU8a(sponsorship);
|
|
20840
|
+
if (bytes.length !== PERMIT2_SPONSORSHIP_BYTES || !hasPermit2Sponsorship(bytes)) {
|
|
20841
|
+
throw new Error(
|
|
20842
|
+
`Phantom bid sponsorship must be a ${PERMIT2_SPONSORSHIP_BYTES}-byte Permit2-mode paymasterAndData, got ${bytes.length} bytes`
|
|
20843
|
+
);
|
|
20844
|
+
}
|
|
20845
|
+
return `${sponsorship}${declaration.slice(2)}`;
|
|
20846
|
+
}
|
|
20736
20847
|
function encodeAcceptedSourceChains(chains2) {
|
|
20737
20848
|
return encodePhantomBidDeclaration({ acceptedSourceChains: chains2 });
|
|
20738
20849
|
}
|
|
@@ -25243,6 +25354,6 @@ async function teleportDot(param_) {
|
|
|
25243
25354
|
return stream;
|
|
25244
25355
|
}
|
|
25245
25356
|
|
|
25246
|
-
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, 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, decodeUserOpScale, deriveHttpUrl, encodeAcceptedSourceChains, encodeERC7821ExecuteBatch, encodeFillOrder, encodeISMPMessage, encodePhantomBidDeclaration, 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 };
|
|
25357
|
+
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 };
|
|
25247
25358
|
//# sourceMappingURL=index.js.map
|
|
25248
25359
|
//# sourceMappingURL=index.js.map
|