@hyperbridge/sdk 2.2.3 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.d.ts +70 -19
- package/dist/browser/index.js +217 -35
- package/dist/browser/index.js.map +1 -1
- package/dist/node/IntentGatewayV2-C55Aitcb.d.cts +5717 -0
- package/dist/node/IntentGatewayV2-C55Aitcb.d.ts +5717 -0
- package/dist/node/index.cjs +217 -33
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +1478 -5742
- package/dist/node/index.d.ts +1478 -5742
- package/dist/node/index.js +217 -35
- package/dist/node/index.js.map +1 -1
- package/dist/node/intents-helpers.cjs +2084 -0
- package/dist/node/intents-helpers.cjs.map +1 -0
- package/dist/node/intents-helpers.d.cts +1469 -0
- package/dist/node/intents-helpers.d.ts +1469 -0
- package/dist/node/intents-helpers.js +2072 -0
- package/dist/node/intents-helpers.js.map +1 -0
- package/package.json +15 -1
package/dist/browser/index.d.ts
CHANGED
|
@@ -1822,6 +1822,14 @@ declare function encodeUserOpScale(userOp: PackedUserOperation): HexString;
|
|
|
1822
1822
|
* @returns The decoded PackedUserOperation
|
|
1823
1823
|
*/
|
|
1824
1824
|
declare function decodeUserOpScale(hex: HexString): PackedUserOperation;
|
|
1825
|
+
interface PhantomOrderEvent {
|
|
1826
|
+
commitment: HexString;
|
|
1827
|
+
chain: string;
|
|
1828
|
+
createdAt: number;
|
|
1829
|
+
tokenA: HexString;
|
|
1830
|
+
tokenB: HexString;
|
|
1831
|
+
standardAmount: bigint;
|
|
1832
|
+
}
|
|
1825
1833
|
/**
|
|
1826
1834
|
* Service for interacting with Hyperbridge's pallet-intents coprocessor.
|
|
1827
1835
|
* Handles bid submission and retrieval for the IntentGatewayV2 protocol.
|
|
@@ -1834,6 +1842,7 @@ declare class IntentsCoprocessor {
|
|
|
1834
1842
|
private ownsConnection;
|
|
1835
1843
|
/** Cached result of whether the node exposes intents_* RPC methods */
|
|
1836
1844
|
private hasIntentsRpc;
|
|
1845
|
+
private submissionQueue;
|
|
1837
1846
|
/**
|
|
1838
1847
|
* Creates and connects an IntentsCoprocessor to a Hyperbridge node.
|
|
1839
1848
|
* This creates and manages its own API connection.
|
|
@@ -1865,15 +1874,21 @@ declare class IntentsCoprocessor {
|
|
|
1865
1874
|
*/
|
|
1866
1875
|
disconnect(): Promise<void>;
|
|
1867
1876
|
/**
|
|
1868
|
-
* Creates a Substrate keypair from the configured private key
|
|
1869
|
-
* Supports
|
|
1877
|
+
* Creates a Substrate keypair from the configured private key.
|
|
1878
|
+
* Supports hex seed (with or without 0x), mnemonic phrases, and URI derivation paths (//Alice).
|
|
1870
1879
|
*/
|
|
1871
1880
|
getKeyPair(): KeyringPair;
|
|
1872
1881
|
/**
|
|
1873
|
-
* Signs and sends an extrinsic
|
|
1874
|
-
*
|
|
1882
|
+
* Signs and sends an extrinsic. Submissions are serialised through {@link submissionQueue} so
|
|
1883
|
+
* concurrent calls never collide on the substrate account nonce — each extrinsic reaches a block
|
|
1884
|
+
* before the next is signed.
|
|
1875
1885
|
*/
|
|
1876
1886
|
private signAndSendExtrinsic;
|
|
1887
|
+
/**
|
|
1888
|
+
* Signs and sends an extrinsic, handling status updates and errors.
|
|
1889
|
+
* Implements retry logic with progressive tip increases for stuck transactions.
|
|
1890
|
+
*/
|
|
1891
|
+
private sendExtrinsicWithRetries;
|
|
1877
1892
|
/**
|
|
1878
1893
|
* Sends an extrinsic with a timeout
|
|
1879
1894
|
*/
|
|
@@ -1895,6 +1910,18 @@ declare class IntentsCoprocessor {
|
|
|
1895
1910
|
* @returns BidSubmissionResult with success status and block/extrinsic hash
|
|
1896
1911
|
*/
|
|
1897
1912
|
retractBid(commitment: HexString): Promise<BidSubmissionResult>;
|
|
1913
|
+
/**
|
|
1914
|
+
* Retracts a previous bid and places a new one in a single transaction via utility.batch.
|
|
1915
|
+
* The retraction runs first, so the old deposit is reclaimed even if the new bid then fails
|
|
1916
|
+
* (batch is non-atomic — a failing call interrupts the batch without reverting the calls that
|
|
1917
|
+
* already succeeded, unlike batchAll which would roll the retraction back too).
|
|
1918
|
+
*
|
|
1919
|
+
* @param retractCommitment - The order commitment of the bid to retract (bytes32)
|
|
1920
|
+
* @param bidCommitment - The order commitment of the new bid (bytes32)
|
|
1921
|
+
* @param userOp - The encoded PackedUserOperation as hex string
|
|
1922
|
+
* @returns BidSubmissionResult with success status and block/extrinsic hash
|
|
1923
|
+
*/
|
|
1924
|
+
submitBidWithRetraction(retractCommitment: HexString, bidCommitment: HexString, userOp: HexString): Promise<BidSubmissionResult>;
|
|
1898
1925
|
/**
|
|
1899
1926
|
* Fetches all bid storage entries for a given order commitment.
|
|
1900
1927
|
* Returns the on-chain data only (filler addresses and deposits).
|
|
@@ -1928,6 +1955,21 @@ declare class IntentsCoprocessor {
|
|
|
1928
1955
|
private decodeBid;
|
|
1929
1956
|
/** Builds offchain storage key: "intents::bid::" + commitment + filler */
|
|
1930
1957
|
private buildOffchainBidKey;
|
|
1958
|
+
/**
|
|
1959
|
+
* Fetches the ABI-encoded phantom order from offchain storage and decodes it
|
|
1960
|
+
* into an `Order` object. The pallet writes the order bytes under the key
|
|
1961
|
+
* `intents::phantom::order::<commitment>` when it calls `on_initialize`.
|
|
1962
|
+
*
|
|
1963
|
+
* Returns `null` if the key is absent (e.g. the node is not an offchain worker
|
|
1964
|
+
* or the commitment has expired and been cleared).
|
|
1965
|
+
*/
|
|
1966
|
+
fetchPhantomOrder(commitment: HexString): Promise<Order | null>;
|
|
1967
|
+
/**
|
|
1968
|
+
* Subscribes to PhantomOrderRegistered events from the intents coprocessor pallet.
|
|
1969
|
+
* Calls the callback for each new phantom order as blocks arrive.
|
|
1970
|
+
* Returns an unsubscribe function to stop the subscription.
|
|
1971
|
+
*/
|
|
1972
|
+
subscribePhantomOrders(callback: (event: PhantomOrderEvent) => void): Promise<() => void>;
|
|
1931
1973
|
}
|
|
1932
1974
|
|
|
1933
1975
|
/**
|
|
@@ -3105,6 +3147,10 @@ interface DispatchGet {
|
|
|
3105
3147
|
* Context for the request
|
|
3106
3148
|
*/
|
|
3107
3149
|
context: HexString;
|
|
3150
|
+
/**
|
|
3151
|
+
* Who pays for this request?
|
|
3152
|
+
*/
|
|
3153
|
+
payer: HexString;
|
|
3108
3154
|
}
|
|
3109
3155
|
interface StateMachineHeight {
|
|
3110
3156
|
id: {
|
|
@@ -5066,24 +5112,13 @@ declare class OrderStatusChecker {
|
|
|
5066
5112
|
isOrderRefunded(order: Order): Promise<boolean>;
|
|
5067
5113
|
}
|
|
5068
5114
|
|
|
5115
|
+
declare function encodeERC7821ExecuteBatch(calls: ERC7821Call[]): HexString;
|
|
5116
|
+
declare function decodeERC7821ExecuteBatch(callData: HexString): ERC7821Call[] | null;
|
|
5117
|
+
|
|
5069
5118
|
type ContractOrder = Omit<Order, "id" | "source" | "destination"> & {
|
|
5070
5119
|
source: HexString;
|
|
5071
5120
|
destination: HexString;
|
|
5072
5121
|
};
|
|
5073
|
-
/**
|
|
5074
|
-
* Encodes a list of calls into ERC-7821 `execute` function calldata using
|
|
5075
|
-
* single-batch mode.
|
|
5076
|
-
*
|
|
5077
|
-
* This is a standalone utility that can be used outside of the
|
|
5078
|
-
* `IntentGatewayV2` class — for example, by filler strategies that need to
|
|
5079
|
-
* build custom batch calldata for combined swap-and-fill operations before
|
|
5080
|
-
* submitting a UserOperation.
|
|
5081
|
-
*
|
|
5082
|
-
* @param calls - Ordered list of calls to batch; each specifies a target
|
|
5083
|
-
* address, ETH value, and calldata.
|
|
5084
|
-
* @returns ABI-encoded calldata for the ERC-7821 `execute(bytes32,bytes)` function.
|
|
5085
|
-
*/
|
|
5086
|
-
declare function encodeERC7821ExecuteBatch(calls: ERC7821Call[]): HexString;
|
|
5087
5122
|
/**
|
|
5088
5123
|
* Fetches a Merkle/state proof for the given ISMP request commitment on the
|
|
5089
5124
|
* source chain.
|
|
@@ -6171,6 +6206,10 @@ declare const ABI$1: readonly [{
|
|
|
6171
6206
|
readonly name: "context";
|
|
6172
6207
|
readonly type: "bytes";
|
|
6173
6208
|
readonly internalType: "bytes";
|
|
6209
|
+
}, {
|
|
6210
|
+
readonly name: "payer";
|
|
6211
|
+
readonly type: "address";
|
|
6212
|
+
readonly internalType: "address";
|
|
6174
6213
|
}];
|
|
6175
6214
|
}];
|
|
6176
6215
|
readonly outputs: readonly [{
|
|
@@ -6866,6 +6905,10 @@ declare const ABI: readonly [{
|
|
|
6866
6905
|
readonly name: "context";
|
|
6867
6906
|
readonly type: "bytes";
|
|
6868
6907
|
readonly internalType: "bytes";
|
|
6908
|
+
}, {
|
|
6909
|
+
readonly name: "payer";
|
|
6910
|
+
readonly type: "address";
|
|
6911
|
+
readonly internalType: "address";
|
|
6869
6912
|
}];
|
|
6870
6913
|
}];
|
|
6871
6914
|
readonly outputs: readonly [{
|
|
@@ -8825,6 +8868,10 @@ declare const HyperFungibleTokenABI: readonly [{
|
|
|
8825
8868
|
readonly name: "context";
|
|
8826
8869
|
readonly type: "bytes";
|
|
8827
8870
|
readonly internalType: "bytes";
|
|
8871
|
+
}, {
|
|
8872
|
+
readonly name: "payer";
|
|
8873
|
+
readonly type: "address";
|
|
8874
|
+
readonly internalType: "address";
|
|
8828
8875
|
}];
|
|
8829
8876
|
}];
|
|
8830
8877
|
readonly outputs: readonly [{
|
|
@@ -9689,6 +9736,10 @@ declare const WrappedHyperFungibleTokenABI: readonly [{
|
|
|
9689
9736
|
readonly name: "context";
|
|
9690
9737
|
readonly type: "bytes";
|
|
9691
9738
|
readonly internalType: "bytes";
|
|
9739
|
+
}, {
|
|
9740
|
+
readonly name: "payer";
|
|
9741
|
+
readonly type: "address";
|
|
9742
|
+
readonly internalType: "address";
|
|
9692
9743
|
}];
|
|
9693
9744
|
}];
|
|
9694
9745
|
readonly outputs: readonly [{
|
|
@@ -10166,4 +10217,4 @@ declare function teleport(teleport_param: {
|
|
|
10166
10217
|
extrinsics?: Array<SubmittableExtrinsic<"promise", ISubmittableResult>>;
|
|
10167
10218
|
}): Promise<ReadableStream<HyperbridgeTxEvents>>;
|
|
10168
10219
|
|
|
10169
|
-
export { ADDRESS_ZERO, type AllStatusKey, type AssetTeleported, type AssetTeleportedResponse, type Bid, type BidStorageEntry, type BidSubmissionResult, type BlockMetadata, type BridgeParams, type BridgeStep, type BundlerGasEstimate, BundlerMethod, type BytesLikeHex, type CancelEvent, type CancelOptions, type CancelOrderOptions, type CancelQuote, type ChainConfig, type ChainConfigData, ChainConfigService, Chains, type ClientConfig, type ConfiguredAssetSymbol, 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 EstimateFillOrderParams, type EstimateGasCallData, EvmChain, type EvmChainParams, ABI as EvmHostABI, EvmLanguage, type ExecuteIntentOrderOptions, type ExecutionResult, type FillOptions, type FillOrderEstimate, type FillerBid, type FillerConfig, type GetRequestResponse, type GetRequestWithStatus, type GetResponseByRequestIdResponse, type GetResponseStorageValues, type 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, type IPharosConfig, type IPolkadotHubConfig, type IPostRequest, type IPostResponse, type IProof, type IRequestMessage, type ISubstrateConfig, type ITimeoutPostRequestMessage, type IndexerQueryClient, IntentGateway, ABI$1 as IntentGatewayABI, type IntentGatewayContext, type IntentGatewayParams, IntentOrderStatus, type IntentOrderStatusKey, type IntentOrderStatusUpdate, type IntentQuoteStrategy, type IntentQuoteToken, type IntentQuoteTradeType, IntentsCoprocessor, IsmpClient, type IsmpRequest, MOCK_ADDRESS, ORDER_V2_PARAM_TYPE, type Order, type OrderResponse, OrderStatus, OrderStatusChecker, type OrderStatusMetadata, type OrderWithStatus, PACKED_USEROP_TYPEHASH, PLACE_ORDER_SELECTOR, type PackedUserOperation, type Params, type PaymentInfo, PharosChain, type PharosChainParams, PolkadotHubChain, type PolkadotHubChainParams, type PostRequestStatus, type PostRequestTimeoutStatus, type PostRequestWithStatus, 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, USE_ETHERSCAN_CHAINS, type UniswapProtocol, type UniswapQuote, type UniswapQuoteToken, type UniswapTradeType, type UniswapV4IntentQuoteMetadata, type UniswapV4IntentQuoteOptions, type UniswapV4PoolConfigData, type UniswapV4PoolKey, UnsupportedIntentQuotePairError, UnsupportedIntentQuoteStrategyError, WrappedHyperFungibleTokenABI, type XcmGatewayParams, __test, adjustDecimals, bytes20ToBytes32, bytes32ToBytes20, calculateAllowanceMappingLocation, calculateBalanceMappingLocation, chainConfigs, constructRedeemEscrowRequestBody, constructRefundEscrowRequestBody, convertCodecToIGetRequest, convertCodecToIProof, convertIGetRequestToCodec, convertIProofToCodec, convertStateIdToStateMachineId, convertStateMachineEnumToString, convertStateMachineIdToEnum, createEvmChain, createQueryClient, 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, normalizeEvmChainId, normalizeStateMachineId, orderCommitment, parseStateMachineId, pharosAtlantic, pharosMainnet, polkadotAssetHubPaseo, polkadotHubMainnet, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, quoteUniswap, requestCommitmentKey, responseCommitmentKey, retryPromise, teleport, teleportDot, transformOrderForContract, tronChainIds, tronNile };
|
|
10220
|
+
export { ADDRESS_ZERO, type AllStatusKey, type AssetTeleported, type AssetTeleportedResponse, type Bid, type BidStorageEntry, type BidSubmissionResult, type BlockMetadata, type BridgeParams, type BridgeStep, type BundlerGasEstimate, BundlerMethod, type BytesLikeHex, type CancelEvent, type CancelOptions, type CancelOrderOptions, type CancelQuote, type ChainConfig, type ChainConfigData, ChainConfigService, Chains, type ClientConfig, type ConfiguredAssetSymbol, 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 EstimateFillOrderParams, type EstimateGasCallData, EvmChain, type EvmChainParams, ABI as EvmHostABI, EvmLanguage, type ExecuteIntentOrderOptions, type ExecutionResult, type FillOptions, type FillOrderEstimate, type FillerBid, type FillerConfig, type GetRequestResponse, type GetRequestWithStatus, type GetResponseByRequestIdResponse, type GetResponseStorageValues, type 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, type IPharosConfig, type IPolkadotHubConfig, type IPostRequest, type IPostResponse, type IProof, type IRequestMessage, type ISubstrateConfig, type ITimeoutPostRequestMessage, type IndexerQueryClient, IntentGateway, ABI$1 as IntentGatewayABI, type IntentGatewayContext, type IntentGatewayParams, IntentOrderStatus, type IntentOrderStatusKey, type IntentOrderStatusUpdate, type IntentQuoteStrategy, type IntentQuoteToken, type IntentQuoteTradeType, IntentsCoprocessor, IsmpClient, type IsmpRequest, MOCK_ADDRESS, ORDER_V2_PARAM_TYPE, type Order, type OrderResponse, OrderStatus, OrderStatusChecker, type OrderStatusMetadata, type OrderWithStatus, PACKED_USEROP_TYPEHASH, PLACE_ORDER_SELECTOR, type PackedUserOperation, type Params, type PaymentInfo, type PhantomOrderEvent, PharosChain, type PharosChainParams, PolkadotHubChain, type PolkadotHubChainParams, type PostRequestStatus, type PostRequestTimeoutStatus, type PostRequestWithStatus, 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, USE_ETHERSCAN_CHAINS, type UniswapProtocol, type UniswapQuote, type UniswapQuoteToken, type UniswapTradeType, type UniswapV4IntentQuoteMetadata, type UniswapV4IntentQuoteOptions, type UniswapV4PoolConfigData, type UniswapV4PoolKey, UnsupportedIntentQuotePairError, UnsupportedIntentQuoteStrategyError, WrappedHyperFungibleTokenABI, type XcmGatewayParams, __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, normalizeEvmChainId, normalizeStateMachineId, orderCommitment, parseStateMachineId, pharosAtlantic, pharosMainnet, polkadotAssetHubPaseo, polkadotHubMainnet, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, quoteUniswap, requestCommitmentKey, responseCommitmentKey, retryPromise, teleport, teleportDot, transformOrderForContract, tronChainIds, tronNile };
|
package/dist/browser/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createConsola, LogLevels } from 'consola';
|
|
2
|
-
import { defineChain, keccak256, toHex, createPublicClient, http, hexToBytes, toFunctionSelector, bytesToHex, encodeFunctionData, erc20Abi, bytesToBigInt, pad, toBytes, numberToBytes, getAddress, encodeAbiParameters, isHex, maxUint256, parseAbiParameters, encodePacked, parseAbiItem, concat, decodeFunctionData,
|
|
2
|
+
import { defineChain, keccak256, toHex, createPublicClient, http, hexToBytes, toFunctionSelector, bytesToHex, encodeFunctionData, erc20Abi, bytesToBigInt, pad, toBytes, numberToBytes, decodeAbiParameters, getAddress, encodeAbiParameters, isHex, maxUint256, parseAbiParameters, encodePacked, parseAbiItem, concat, decodeFunctionData, hexToString as hexToString$1, decodeEventLog, parseEventLogs, parseUnits, concatHex, zeroAddress, decodeFunctionResult, formatUnits } from 'viem';
|
|
3
3
|
import { baseSepolia, optimismSepolia, arbitrumSepolia, soneium, gnosis, optimism, polygonAmoy, polygon, base, arbitrum, bsc, mainnet, sepolia, gnosisChiado, bscTestnet, tron, unichain } from 'viem/chains';
|
|
4
4
|
import { TronWeb } from 'tronweb';
|
|
5
5
|
import { flatten, zip, capitalize, maxBy, isNil } from 'lodash-es';
|
|
@@ -8,6 +8,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
10
|
import { hexToU8a, u8aToHex, u8aConcat } from '@polkadot/util';
|
|
11
|
+
import PQueue from 'p-queue';
|
|
11
12
|
import { hasWindow, isNode, env } from 'std-env';
|
|
12
13
|
import mergeRace from '@async-generator/merge-race';
|
|
13
14
|
import { GraphQLClient } from 'graphql-request';
|
|
@@ -564,6 +565,11 @@ var ABI = [
|
|
|
564
565
|
name: "context",
|
|
565
566
|
type: "bytes",
|
|
566
567
|
internalType: "bytes"
|
|
568
|
+
},
|
|
569
|
+
{
|
|
570
|
+
name: "payer",
|
|
571
|
+
type: "address",
|
|
572
|
+
internalType: "address"
|
|
567
573
|
}
|
|
568
574
|
]
|
|
569
575
|
}
|
|
@@ -2619,9 +2625,9 @@ var chainConfigs = {
|
|
|
2619
2625
|
USDT: { balanceSlot: 151, allowanceSlot: 152 }
|
|
2620
2626
|
},
|
|
2621
2627
|
addresses: {
|
|
2622
|
-
IntentGateway: "
|
|
2628
|
+
IntentGateway: "0x6CF42FA9BecbC5b6a26884964956b113530f7cFA",
|
|
2623
2629
|
TokenGateway: "0xFcDa26cA021d5535C3059547390E6cCd8De7acA6",
|
|
2624
|
-
Host: "
|
|
2630
|
+
Host: "0x9AA003594d59C62EE17A73A569Fd7B1DbdBd71E1",
|
|
2625
2631
|
UniswapRouter02: "0x9639379819420704457B07A0C33B678D9E0F8Df0",
|
|
2626
2632
|
UniswapV2Factory: "0x12e036669DA18F4A2777853d6e2136b32AceEC86",
|
|
2627
2633
|
UniswapV3Factory: "0x0000000000000000000000000000000000000000",
|
|
@@ -2629,7 +2635,7 @@ var chainConfigs = {
|
|
|
2629
2635
|
UniswapV3Quoter: "0x0000000000000000000000000000000000000000",
|
|
2630
2636
|
UniswapV4Quoter: "0x0000000000000000000000000000000000000000",
|
|
2631
2637
|
EntryPointV08: "0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108",
|
|
2632
|
-
SolverAccount: "
|
|
2638
|
+
SolverAccount: "0x07FeC66d967800998060194EaECDd7C66dA4a1B1"
|
|
2633
2639
|
},
|
|
2634
2640
|
rpcEnvKey: "BSC_CHAPEL",
|
|
2635
2641
|
defaultRpcUrl: "https://bnb-testnet.api.onfinality.io/public",
|
|
@@ -2660,7 +2666,7 @@ var chainConfigs = {
|
|
|
2660
2666
|
addresses: {
|
|
2661
2667
|
IntentGateway: "0x016b6ffC9f890d1e28f9Fdb9eaDA776b02F89509",
|
|
2662
2668
|
TokenGateway: "0xFcDa26cA021d5535C3059547390E6cCd8De7acA6",
|
|
2663
|
-
Host: "
|
|
2669
|
+
Host: "0x58A41B89F4871725E5D898d98eF4BF917601c5eB",
|
|
2664
2670
|
UniswapRouter02: "0x0000000000000000000000000000000000000000",
|
|
2665
2671
|
UniswapV2Factory: "0x0000000000000000000000000000000000000000",
|
|
2666
2672
|
UniswapV3Factory: "0x0000000000000000000000000000000000000000",
|
|
@@ -2699,7 +2705,7 @@ var chainConfigs = {
|
|
|
2699
2705
|
addresses: {
|
|
2700
2706
|
IntentGateway: "0x016b6ffC9f890d1e28f9Fdb9eaDA776b02F89509",
|
|
2701
2707
|
TokenGateway: "0xFcDa26cA021d5535C3059547390E6cCd8De7acA6",
|
|
2702
|
-
Host: "
|
|
2708
|
+
Host: "0x9AA003594d59C62EE17A73A569Fd7B1DbdBd71E1",
|
|
2703
2709
|
UniswapRouter02: "0x0000000000000000000000000000000000000000",
|
|
2704
2710
|
UniswapV2Factory: "0x0000000000000000000000000000000000000000",
|
|
2705
2711
|
UniswapV3Factory: "0x0000000000000000000000000000000000000000",
|
|
@@ -3045,13 +3051,13 @@ var chainConfigs = {
|
|
|
3045
3051
|
USDC: { balanceSlot: 1, allowanceSlot: 2 }
|
|
3046
3052
|
},
|
|
3047
3053
|
addresses: {
|
|
3048
|
-
IntentGateway: "
|
|
3054
|
+
IntentGateway: "0x6CF42FA9BecbC5b6a26884964956b113530f7cFA",
|
|
3049
3055
|
TokenGateway: "0x8b536105b6Fae2aE9199f5146D3C57Dfe53b614E",
|
|
3050
|
-
Host: "
|
|
3056
|
+
Host: "0x9AA003594d59C62EE17A73A569Fd7B1DbdBd71E1",
|
|
3051
3057
|
Calldispatcher: "0x876F1891982E260026630c233A4897160A281Fb8",
|
|
3052
3058
|
Permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
|
|
3053
3059
|
EntryPointV08: "0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108",
|
|
3054
|
-
SolverAccount: "
|
|
3060
|
+
SolverAccount: "0x07FeC66d967800998060194EaECDd7C66dA4a1B1"
|
|
3055
3061
|
},
|
|
3056
3062
|
rpcEnvKey: "POLYGON_AMOY",
|
|
3057
3063
|
defaultRpcUrl: "https://rpc-amoy.polygon.technology",
|
|
@@ -3167,7 +3173,7 @@ var chainConfigs = {
|
|
|
3167
3173
|
},
|
|
3168
3174
|
addresses: {
|
|
3169
3175
|
TokenGateway: "0xFcDa26cA021d5535C3059547390E6cCd8De7acA6",
|
|
3170
|
-
Host: "
|
|
3176
|
+
Host: "0x9AA003594d59C62EE17A73A569Fd7B1DbdBd71E1",
|
|
3171
3177
|
EntryPointV08: "0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108"
|
|
3172
3178
|
},
|
|
3173
3179
|
defaultRpcUrl: "https://sepolia-rollup.arbitrum.io/rpc",
|
|
@@ -3191,7 +3197,7 @@ var chainConfigs = {
|
|
|
3191
3197
|
},
|
|
3192
3198
|
addresses: {
|
|
3193
3199
|
TokenGateway: "0xFcDa26cA021d5535C3059547390E6cCd8De7acA6",
|
|
3194
|
-
Host: "
|
|
3200
|
+
Host: "0x9AA003594d59C62EE17A73A569Fd7B1DbdBd71E1",
|
|
3195
3201
|
EntryPointV08: "0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108"
|
|
3196
3202
|
},
|
|
3197
3203
|
defaultRpcUrl: "https://sepolia.optimism.io",
|
|
@@ -3215,7 +3221,7 @@ var chainConfigs = {
|
|
|
3215
3221
|
},
|
|
3216
3222
|
addresses: {
|
|
3217
3223
|
TokenGateway: "0xFcDa26cA021d5535C3059547390E6cCd8De7acA6",
|
|
3218
|
-
Host: "
|
|
3224
|
+
Host: "0x9AA003594d59C62EE17A73A569Fd7B1DbdBd71E1",
|
|
3219
3225
|
EntryPointV08: "0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108"
|
|
3220
3226
|
},
|
|
3221
3227
|
defaultRpcUrl: "https://sepolia.base.org",
|
|
@@ -3241,7 +3247,7 @@ var chainConfigs = {
|
|
|
3241
3247
|
addresses: {
|
|
3242
3248
|
IntentGateway: "0x606ba811aa6cb424ce2108e8977c5284686f0d1f",
|
|
3243
3249
|
TokenGateway: "0x1c1e5be83df4a54c7a2230c337e4a3e8b7354b1c",
|
|
3244
|
-
Host: "
|
|
3250
|
+
Host: "0x9AA003594d59C62EE17A73A569Fd7B1DbdBd71E1",
|
|
3245
3251
|
EntryPointV08: "0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108"
|
|
3246
3252
|
},
|
|
3247
3253
|
defaultRpcUrl: "https://testnet-asset-hub-eth-rpc.polkadot.io",
|
|
@@ -3291,7 +3297,7 @@ var chainConfigs = {
|
|
|
3291
3297
|
wrappedNativeDecimals: 18,
|
|
3292
3298
|
addresses: {
|
|
3293
3299
|
TokenGateway: "0x451bDd8273839AD0Ec7F4Fa798E8B3DABb223fD8",
|
|
3294
|
-
Host: "
|
|
3300
|
+
Host: "0x9AA003594d59C62EE17A73A569Fd7B1DbdBd71E1",
|
|
3295
3301
|
IntentGateway: "0xb8039832c6c9266F928d038eA49A8a169300C670"
|
|
3296
3302
|
},
|
|
3297
3303
|
consensusStateId: "PHAR",
|
|
@@ -4423,6 +4429,11 @@ var ABI3 = [
|
|
|
4423
4429
|
name: "context",
|
|
4424
4430
|
type: "bytes",
|
|
4425
4431
|
internalType: "bytes"
|
|
4432
|
+
},
|
|
4433
|
+
{
|
|
4434
|
+
name: "payer",
|
|
4435
|
+
type: "address",
|
|
4436
|
+
internalType: "address"
|
|
4426
4437
|
}
|
|
4427
4438
|
]
|
|
4428
4439
|
}
|
|
@@ -7583,6 +7594,7 @@ function encodeISMPMessage(message) {
|
|
|
7583
7594
|
}
|
|
7584
7595
|
}
|
|
7585
7596
|
var OFFCHAIN_BID_PREFIX = new TextEncoder().encode("intents::bid::");
|
|
7597
|
+
var OFFCHAIN_PHANTOM_PREFIX = new TextEncoder().encode("intents::phantom::order::");
|
|
7586
7598
|
var BidCodec = Struct({ filler: Bytes(32), user_op: Vector(u8) });
|
|
7587
7599
|
var PackedUserOperationCodec = Struct({
|
|
7588
7600
|
sender: Bytes(20),
|
|
@@ -7643,6 +7655,11 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
|
|
|
7643
7655
|
ownsConnection;
|
|
7644
7656
|
/** Cached result of whether the node exposes intents_* RPC methods */
|
|
7645
7657
|
hasIntentsRpc = null;
|
|
7658
|
+
// Serialises every extrinsic submission on this instance's substrate account. All submit/retract
|
|
7659
|
+
// methods funnel through signAndSendExtrinsic, each using the API's auto-nonce; fired in parallel
|
|
7660
|
+
// (bids for orders on different chains, or several phantom orders in one interval) they would grab
|
|
7661
|
+
// the same nonce and all but one would fail. Concurrency 1 sequences them.
|
|
7662
|
+
submissionQueue = new PQueue({ concurrency: 1 });
|
|
7646
7663
|
/**
|
|
7647
7664
|
* Creates and connects an IntentsCoprocessor to a Hyperbridge node.
|
|
7648
7665
|
* This creates and manages its own API connection.
|
|
@@ -7695,14 +7712,17 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
|
|
|
7695
7712
|
}
|
|
7696
7713
|
}
|
|
7697
7714
|
/**
|
|
7698
|
-
* Creates a Substrate keypair from the configured private key
|
|
7699
|
-
* Supports
|
|
7715
|
+
* Creates a Substrate keypair from the configured private key.
|
|
7716
|
+
* Supports hex seed (with or without 0x), mnemonic phrases, and URI derivation paths (//Alice).
|
|
7700
7717
|
*/
|
|
7701
7718
|
getKeyPair() {
|
|
7702
7719
|
if (!this.substratePrivateKey) {
|
|
7703
7720
|
throw new Error("Substrate PrivateKey Required");
|
|
7704
7721
|
}
|
|
7705
7722
|
const keyring = new Keyring({ type: "sr25519" });
|
|
7723
|
+
if (this.substratePrivateKey.startsWith("//")) {
|
|
7724
|
+
return keyring.addFromUri(this.substratePrivateKey);
|
|
7725
|
+
}
|
|
7706
7726
|
if (this.substratePrivateKey.includes(" ")) {
|
|
7707
7727
|
return keyring.addFromMnemonic(this.substratePrivateKey);
|
|
7708
7728
|
}
|
|
@@ -7711,10 +7731,19 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
|
|
|
7711
7731
|
return keyring.addFromSeed(seedBytes);
|
|
7712
7732
|
}
|
|
7713
7733
|
/**
|
|
7714
|
-
* Signs and sends an extrinsic
|
|
7715
|
-
*
|
|
7734
|
+
* Signs and sends an extrinsic. Submissions are serialised through {@link submissionQueue} so
|
|
7735
|
+
* concurrent calls never collide on the substrate account nonce — each extrinsic reaches a block
|
|
7736
|
+
* before the next is signed.
|
|
7716
7737
|
*/
|
|
7717
7738
|
async signAndSendExtrinsic(extrinsic, maxRetries = 3, timeoutMs = 3e4) {
|
|
7739
|
+
const result = await this.submissionQueue.add(() => this.sendExtrinsicWithRetries(extrinsic, maxRetries, timeoutMs));
|
|
7740
|
+
return result ?? { success: false, error: "Submission queue returned no result" };
|
|
7741
|
+
}
|
|
7742
|
+
/**
|
|
7743
|
+
* Signs and sends an extrinsic, handling status updates and errors.
|
|
7744
|
+
* Implements retry logic with progressive tip increases for stuck transactions.
|
|
7745
|
+
*/
|
|
7746
|
+
async sendExtrinsicWithRetries(extrinsic, maxRetries, timeoutMs) {
|
|
7718
7747
|
const keyPair = this.getKeyPair();
|
|
7719
7748
|
let baseTip = 500000000000n;
|
|
7720
7749
|
let attempt = 0;
|
|
@@ -7759,20 +7788,34 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
|
|
|
7759
7788
|
}, timeoutMs);
|
|
7760
7789
|
extrinsic.signAndSend(keyPair, { tip }, (result) => {
|
|
7761
7790
|
if (resolved) return;
|
|
7762
|
-
if (result.status.isInBlock || result.status.isFinalized) {
|
|
7791
|
+
if (result.dispatchError && (result.status.isInBlock || result.status.isFinalized)) {
|
|
7763
7792
|
resolved = true;
|
|
7764
7793
|
clearTimeout(timeoutId);
|
|
7794
|
+
let errorMsg;
|
|
7795
|
+
if (result.dispatchError.isModule) {
|
|
7796
|
+
const decoded = this.api.registry.findMetaError(result.dispatchError.asModule);
|
|
7797
|
+
errorMsg = `Dispatch error: ${decoded.section}::${decoded.name}`;
|
|
7798
|
+
} else {
|
|
7799
|
+
errorMsg = `Dispatch error: ${result.dispatchError.toString()}`;
|
|
7800
|
+
}
|
|
7765
7801
|
resolve({
|
|
7766
|
-
success:
|
|
7767
|
-
|
|
7768
|
-
extrinsicHash: extrinsic.hash.toHex()
|
|
7802
|
+
success: false,
|
|
7803
|
+
error: errorMsg
|
|
7769
7804
|
});
|
|
7770
|
-
} else if (result.
|
|
7805
|
+
} else if (result.status.isDropped || result.status.isInvalid || result.status.isUsurped || result.status.isFinalityTimeout) {
|
|
7771
7806
|
resolved = true;
|
|
7772
7807
|
clearTimeout(timeoutId);
|
|
7773
7808
|
resolve({
|
|
7774
7809
|
success: false,
|
|
7775
|
-
error: `
|
|
7810
|
+
error: `Transaction ${result.status.type.toLowerCase()}`
|
|
7811
|
+
});
|
|
7812
|
+
} else if (result.status.isInBlock || result.status.isFinalized) {
|
|
7813
|
+
resolved = true;
|
|
7814
|
+
clearTimeout(timeoutId);
|
|
7815
|
+
resolve({
|
|
7816
|
+
success: true,
|
|
7817
|
+
blockHash: (result.status.isInBlock ? result.status.asInBlock : result.status.asFinalized).toHex(),
|
|
7818
|
+
extrinsicHash: extrinsic.hash.toHex()
|
|
7776
7819
|
});
|
|
7777
7820
|
}
|
|
7778
7821
|
}).then((unsub) => {
|
|
@@ -7827,6 +7870,31 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
|
|
|
7827
7870
|
};
|
|
7828
7871
|
}
|
|
7829
7872
|
}
|
|
7873
|
+
/**
|
|
7874
|
+
* Retracts a previous bid and places a new one in a single transaction via utility.batch.
|
|
7875
|
+
* The retraction runs first, so the old deposit is reclaimed even if the new bid then fails
|
|
7876
|
+
* (batch is non-atomic — a failing call interrupts the batch without reverting the calls that
|
|
7877
|
+
* already succeeded, unlike batchAll which would roll the retraction back too).
|
|
7878
|
+
*
|
|
7879
|
+
* @param retractCommitment - The order commitment of the bid to retract (bytes32)
|
|
7880
|
+
* @param bidCommitment - The order commitment of the new bid (bytes32)
|
|
7881
|
+
* @param userOp - The encoded PackedUserOperation as hex string
|
|
7882
|
+
* @returns BidSubmissionResult with success status and block/extrinsic hash
|
|
7883
|
+
*/
|
|
7884
|
+
async submitBidWithRetraction(retractCommitment, bidCommitment, userOp) {
|
|
7885
|
+
try {
|
|
7886
|
+
const batch = this.api.tx.utility.batch([
|
|
7887
|
+
this.api.tx.intentsCoprocessor.retractBid(retractCommitment),
|
|
7888
|
+
this.api.tx.intentsCoprocessor.placeBid(bidCommitment, userOp)
|
|
7889
|
+
]);
|
|
7890
|
+
return await this.signAndSendExtrinsic(batch);
|
|
7891
|
+
} catch (error) {
|
|
7892
|
+
return {
|
|
7893
|
+
success: false,
|
|
7894
|
+
error: error instanceof Error ? error.message : "Unknown error"
|
|
7895
|
+
};
|
|
7896
|
+
}
|
|
7897
|
+
}
|
|
7830
7898
|
/**
|
|
7831
7899
|
* Fetches all bid storage entries for a given order commitment.
|
|
7832
7900
|
* Returns the on-chain data only (filler addresses and deposits).
|
|
@@ -7911,6 +7979,80 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
|
|
|
7911
7979
|
buildOffchainBidKey(commitment, filler) {
|
|
7912
7980
|
return u8aConcat(OFFCHAIN_BID_PREFIX, hexToU8a(commitment), decodeAddress(filler));
|
|
7913
7981
|
}
|
|
7982
|
+
/**
|
|
7983
|
+
* Fetches the ABI-encoded phantom order from offchain storage and decodes it
|
|
7984
|
+
* into an `Order` object. The pallet writes the order bytes under the key
|
|
7985
|
+
* `intents::phantom::order::<commitment>` when it calls `on_initialize`.
|
|
7986
|
+
*
|
|
7987
|
+
* Returns `null` if the key is absent (e.g. the node is not an offchain worker
|
|
7988
|
+
* or the commitment has expired and been cleared).
|
|
7989
|
+
*/
|
|
7990
|
+
async fetchPhantomOrder(commitment) {
|
|
7991
|
+
const key = u8aConcat(OFFCHAIN_PHANTOM_PREFIX, hexToU8a(commitment));
|
|
7992
|
+
const result = await this.api.rpc.offchain.localStorageGet("PERSISTENT", u8aToHex(key));
|
|
7993
|
+
if (!result || result.isNone) return null;
|
|
7994
|
+
const rawHex = result.unwrap().toHex();
|
|
7995
|
+
if (rawHex === "0x" || rawHex === "0x00") return null;
|
|
7996
|
+
const placeOrderAbi = IntentGatewayV2_default.ABI.find(
|
|
7997
|
+
(item) => item.type === "function" && item.name === "placeOrder"
|
|
7998
|
+
);
|
|
7999
|
+
const orderType = placeOrderAbi?.inputs?.[0];
|
|
8000
|
+
if (!orderType) return null;
|
|
8001
|
+
const [decoded] = decodeAbiParameters([orderType], rawHex);
|
|
8002
|
+
const d = decoded;
|
|
8003
|
+
const textDecoder = new TextDecoder();
|
|
8004
|
+
return {
|
|
8005
|
+
id: commitment,
|
|
8006
|
+
user: d.user,
|
|
8007
|
+
source: textDecoder.decode(hexToBytes(d.source)),
|
|
8008
|
+
destination: textDecoder.decode(hexToBytes(d.destination)),
|
|
8009
|
+
deadline: d.deadline,
|
|
8010
|
+
nonce: d.nonce,
|
|
8011
|
+
fees: d.fees,
|
|
8012
|
+
session: d.session,
|
|
8013
|
+
predispatch: {
|
|
8014
|
+
assets: d.predispatch.assets.map((a) => ({
|
|
8015
|
+
token: a.token,
|
|
8016
|
+
amount: a.amount
|
|
8017
|
+
})),
|
|
8018
|
+
call: d.predispatch.call
|
|
8019
|
+
},
|
|
8020
|
+
inputs: d.inputs.map((i) => ({
|
|
8021
|
+
token: i.token,
|
|
8022
|
+
amount: i.amount
|
|
8023
|
+
})),
|
|
8024
|
+
output: {
|
|
8025
|
+
beneficiary: d.output.beneficiary,
|
|
8026
|
+
assets: d.output.assets.map((a) => ({
|
|
8027
|
+
token: a.token,
|
|
8028
|
+
amount: a.amount
|
|
8029
|
+
})),
|
|
8030
|
+
call: d.output.call
|
|
8031
|
+
}
|
|
8032
|
+
};
|
|
8033
|
+
}
|
|
8034
|
+
/**
|
|
8035
|
+
* Subscribes to PhantomOrderRegistered events from the intents coprocessor pallet.
|
|
8036
|
+
* Calls the callback for each new phantom order as blocks arrive.
|
|
8037
|
+
* Returns an unsubscribe function to stop the subscription.
|
|
8038
|
+
*/
|
|
8039
|
+
async subscribePhantomOrders(callback) {
|
|
8040
|
+
const unsub = await this.api.query.system.events((records) => {
|
|
8041
|
+
for (const { event } of records) {
|
|
8042
|
+
if (event.section !== "intentsCoprocessor" || event.method !== "PhantomOrderRegistered") continue;
|
|
8043
|
+
const [commitment, chain, createdAt, tokenA, tokenB, standardAmount] = event.data;
|
|
8044
|
+
callback({
|
|
8045
|
+
commitment: commitment.toHex(),
|
|
8046
|
+
chain: new TextDecoder().decode(hexToU8a(chain.toHex())),
|
|
8047
|
+
createdAt: createdAt.toNumber(),
|
|
8048
|
+
tokenA: tokenA.toHex(),
|
|
8049
|
+
tokenB: tokenB.toHex(),
|
|
8050
|
+
standardAmount: BigInt(standardAmount.toString())
|
|
8051
|
+
});
|
|
8052
|
+
}
|
|
8053
|
+
});
|
|
8054
|
+
return unsub;
|
|
8055
|
+
}
|
|
7914
8056
|
};
|
|
7915
8057
|
var TronChain = class _TronChain {
|
|
7916
8058
|
constructor(params, evm) {
|
|
@@ -14663,16 +14805,6 @@ var CryptoUtils = class _CryptoUtils {
|
|
|
14663
14805
|
}
|
|
14664
14806
|
}
|
|
14665
14807
|
};
|
|
14666
|
-
var FEE_TOKEN_CACHE_TTL_MS = 5 * 60 * 1e3;
|
|
14667
|
-
async function getFeeToken(ctx, chainId, chain) {
|
|
14668
|
-
const cached = ctx.feeTokenCache.get(chainId);
|
|
14669
|
-
if (cached && Date.now() - cached.cachedAt < FEE_TOKEN_CACHE_TTL_MS) {
|
|
14670
|
-
return cached;
|
|
14671
|
-
}
|
|
14672
|
-
const fresh = await chain.getFeeTokenWithDecimals();
|
|
14673
|
-
ctx.feeTokenCache.set(chainId, { ...fresh, cachedAt: Date.now() });
|
|
14674
|
-
return fresh;
|
|
14675
|
-
}
|
|
14676
14808
|
function encodeERC7821ExecuteBatch(calls) {
|
|
14677
14809
|
const executionData = encodeAbiParameters(
|
|
14678
14810
|
[{ type: "tuple[]", components: erc7281_default.ABI[1].components }],
|
|
@@ -14684,6 +14816,36 @@ function encodeERC7821ExecuteBatch(calls) {
|
|
|
14684
14816
|
args: [ERC7821_BATCH_MODE, executionData]
|
|
14685
14817
|
});
|
|
14686
14818
|
}
|
|
14819
|
+
function decodeERC7821ExecuteBatch(callData) {
|
|
14820
|
+
try {
|
|
14821
|
+
const decoded = decodeFunctionData({ abi: erc7281_default.ABI, data: callData });
|
|
14822
|
+
if (decoded.functionName !== "execute" || !decoded.args || decoded.args.length < 2) return null;
|
|
14823
|
+
const executionData = decoded.args[1];
|
|
14824
|
+
const [calls] = decodeAbiParameters(
|
|
14825
|
+
[{ type: "tuple[]", components: erc7281_default.ABI[1].components }],
|
|
14826
|
+
executionData
|
|
14827
|
+
);
|
|
14828
|
+
return calls.map((call) => ({
|
|
14829
|
+
target: call.target,
|
|
14830
|
+
value: call.value,
|
|
14831
|
+
data: call.data
|
|
14832
|
+
}));
|
|
14833
|
+
} catch {
|
|
14834
|
+
return null;
|
|
14835
|
+
}
|
|
14836
|
+
}
|
|
14837
|
+
|
|
14838
|
+
// src/protocols/intents/utils.ts
|
|
14839
|
+
var FEE_TOKEN_CACHE_TTL_MS = 5 * 60 * 1e3;
|
|
14840
|
+
async function getFeeToken(ctx, chainId, chain) {
|
|
14841
|
+
const cached = ctx.feeTokenCache.get(chainId);
|
|
14842
|
+
if (cached && Date.now() - cached.cachedAt < FEE_TOKEN_CACHE_TTL_MS) {
|
|
14843
|
+
return cached;
|
|
14844
|
+
}
|
|
14845
|
+
const fresh = await chain.getFeeTokenWithDecimals();
|
|
14846
|
+
ctx.feeTokenCache.set(chainId, { ...fresh, cachedAt: Date.now() });
|
|
14847
|
+
return fresh;
|
|
14848
|
+
}
|
|
14687
14849
|
async function fetchSourceProof(commitment, source, sourceStateMachine, sourceConsensusStateId, sourceHeight) {
|
|
14688
14850
|
const { slot1, slot2 } = requestCommitmentKey(commitment);
|
|
14689
14851
|
const proofHex = await source.queryStateProof(sourceHeight, [slot1, slot2]);
|
|
@@ -18563,6 +18725,11 @@ var HyperFungibleTokenABI = [
|
|
|
18563
18725
|
name: "context",
|
|
18564
18726
|
type: "bytes",
|
|
18565
18727
|
internalType: "bytes"
|
|
18728
|
+
},
|
|
18729
|
+
{
|
|
18730
|
+
name: "payer",
|
|
18731
|
+
type: "address",
|
|
18732
|
+
internalType: "address"
|
|
18566
18733
|
}
|
|
18567
18734
|
]
|
|
18568
18735
|
}
|
|
@@ -19684,6 +19851,11 @@ var WrappedHyperFungibleTokenABI = [
|
|
|
19684
19851
|
name: "context",
|
|
19685
19852
|
type: "bytes",
|
|
19686
19853
|
internalType: "bytes"
|
|
19854
|
+
},
|
|
19855
|
+
{
|
|
19856
|
+
name: "payer",
|
|
19857
|
+
type: "address",
|
|
19858
|
+
internalType: "address"
|
|
19687
19859
|
}
|
|
19688
19860
|
]
|
|
19689
19861
|
}
|
|
@@ -21521,6 +21693,11 @@ var ABI8 = [
|
|
|
21521
21693
|
internalType: "bytes",
|
|
21522
21694
|
name: "context",
|
|
21523
21695
|
type: "bytes"
|
|
21696
|
+
},
|
|
21697
|
+
{
|
|
21698
|
+
internalType: "address",
|
|
21699
|
+
name: "payer",
|
|
21700
|
+
type: "address"
|
|
21524
21701
|
}
|
|
21525
21702
|
],
|
|
21526
21703
|
internalType: "struct DispatchGet",
|
|
@@ -21789,6 +21966,11 @@ var ABI8 = [
|
|
|
21789
21966
|
internalType: "bytes",
|
|
21790
21967
|
name: "context",
|
|
21791
21968
|
type: "bytes"
|
|
21969
|
+
},
|
|
21970
|
+
{
|
|
21971
|
+
internalType: "address",
|
|
21972
|
+
name: "payer",
|
|
21973
|
+
type: "address"
|
|
21792
21974
|
}
|
|
21793
21975
|
],
|
|
21794
21976
|
internalType: "struct DispatchGet",
|
|
@@ -22151,6 +22333,6 @@ async function teleportDot(param_) {
|
|
|
22151
22333
|
return stream;
|
|
22152
22334
|
}
|
|
22153
22335
|
|
|
22154
|
-
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, IsmpClient, MOCK_ADDRESS, ORDER_V2_PARAM_TYPE, OrderStatus, OrderStatusChecker, PACKED_USEROP_TYPEHASH, PLACE_ORDER_SELECTOR, 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, 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, normalizeEvmChainId, normalizeStateMachineId, orderCommitment, parseStateMachineId, pharosAtlantic, pharosMainnet, polkadotAssetHubPaseo, polkadotHubMainnet, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, quoteUniswap, requestCommitmentKey, responseCommitmentKey, retryPromise, teleport, teleportDot, transformOrderForContract, tronChainIds, tronNile };
|
|
22336
|
+
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, IsmpClient, MOCK_ADDRESS, ORDER_V2_PARAM_TYPE, OrderStatus, OrderStatusChecker, PACKED_USEROP_TYPEHASH, PLACE_ORDER_SELECTOR, 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, normalizeEvmChainId, normalizeStateMachineId, orderCommitment, parseStateMachineId, pharosAtlantic, pharosMainnet, polkadotAssetHubPaseo, polkadotHubMainnet, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, quoteUniswap, requestCommitmentKey, responseCommitmentKey, retryPromise, teleport, teleportDot, transformOrderForContract, tronChainIds, tronNile };
|
|
22155
22337
|
//# sourceMappingURL=index.js.map
|
|
22156
22338
|
//# sourceMappingURL=index.js.map
|