@hyperbridge/sdk 1.6.4 → 1.6.5
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 +31 -1
- package/dist/browser/index.js +84 -16
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.d.ts +31 -1
- package/dist/node/index.js +84 -16
- package/dist/node/index.js.map +1 -1
- package/package.json +1 -1
package/dist/node/index.d.ts
CHANGED
|
@@ -3948,6 +3948,7 @@ declare class IntentsV2 {
|
|
|
3948
3948
|
private readonly orderPlacer;
|
|
3949
3949
|
private readonly orderExecutor;
|
|
3950
3950
|
private readonly orderCanceller;
|
|
3951
|
+
private readonly orderStatusChecker;
|
|
3951
3952
|
private readonly bidManager;
|
|
3952
3953
|
private readonly gasEstimator;
|
|
3953
3954
|
private constructor();
|
|
@@ -3985,6 +3986,35 @@ declare class IntentsV2 {
|
|
|
3985
3986
|
estimateFillOrderV2(params: EstimateFillOrderV2Params): Promise<FillOrderEstimateV2>;
|
|
3986
3987
|
encodeERC7821Execute(calls: ERC7821Call[]): HexString;
|
|
3987
3988
|
decodeERC7821Execute(callData: HexString): ERC7821Call[] | null;
|
|
3989
|
+
isOrderFilled(order: OrderV2): Promise<boolean>;
|
|
3990
|
+
isOrderRefunded(order: OrderV2): Promise<boolean>;
|
|
3991
|
+
}
|
|
3992
|
+
|
|
3993
|
+
declare class OrderStatusChecker {
|
|
3994
|
+
private readonly ctx;
|
|
3995
|
+
constructor(ctx: IntentsV2Context);
|
|
3996
|
+
/**
|
|
3997
|
+
* Checks if a V2 order has been filled by reading the commitment storage slot on the destination chain.
|
|
3998
|
+
*
|
|
3999
|
+
* Reads the storage slot returned by `calculateCommitmentSlotHash` on the IntentGatewayV2 contract.
|
|
4000
|
+
* A non-zero value at that slot means the solver has called `fillOrder` and the order is complete
|
|
4001
|
+
* from the user's perspective (the beneficiary has received their tokens).
|
|
4002
|
+
*
|
|
4003
|
+
* @param order - The V2 order to check. `order.id` is used as the commitment; if not set it is computed.
|
|
4004
|
+
* @returns True if the order has been filled on the destination chain, false otherwise.
|
|
4005
|
+
*/
|
|
4006
|
+
isOrderFilled(order: OrderV2): Promise<boolean>;
|
|
4007
|
+
/**
|
|
4008
|
+
* Checks if a V2 order has been refunded by reading the `_orders` mapping on the source chain.
|
|
4009
|
+
*
|
|
4010
|
+
* Calls `_orders(commitment, tokenAddress)` for each input token. When the order is placed the
|
|
4011
|
+
* escrowed amounts are stored there. After a successful refund the contract zeroes them out.
|
|
4012
|
+
* An order is considered refunded when all escrowed input amounts have been returned (i.e. are 0).
|
|
4013
|
+
*
|
|
4014
|
+
* @param order - The V2 order to check. `order.id` is used as the commitment; if not set it is computed.
|
|
4015
|
+
* @returns True if all escrowed inputs have been returned to the user on the source chain, false otherwise.
|
|
4016
|
+
*/
|
|
4017
|
+
isOrderRefunded(order: OrderV2): Promise<boolean>;
|
|
3988
4018
|
}
|
|
3989
4019
|
|
|
3990
4020
|
/**
|
|
@@ -4461,4 +4491,4 @@ declare const getChainId: (stateMachineId: string) => number | undefined;
|
|
|
4461
4491
|
declare const getViemChain: (chainId: number) => Chain | undefined;
|
|
4462
4492
|
declare const hyperbridgeAddress = "";
|
|
4463
4493
|
|
|
4464
|
-
export { ADDRESS_ZERO, type AllStatusKey, type AssetTeleported, type AssetTeleportedResponse, type BidStorageEntry, type BidSubmissionResult, type BlockMetadata, type BundlerGasEstimate, BundlerMethod, type CancelEvent, type CancelEventMap, type CancelOptions, type ChainConfig, type ChainConfigData, ChainConfigService, Chains, type ClientConfig, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DOMAIN_TYPEHASH, DUMMY_PRIVATE_KEY, type DecodedOrderPlacedLog, type DecodedOrderV2PlacedLog, type DecodedPostRequestEvent, type DecodedPostResponseEvent, type DispatchGet, type DispatchInfoV2, type DispatchPost, ERC20Method, type ERC7821Call, ERC7821_BATCH_MODE, type EstimateFillOrderV2Params, type EstimateGasCallData, EvmChain, type EvmChainParams, EvmLanguage, type ExecuteIntentOrderOptions, type ExecutionResult, type FillOptions, type FillOptionsV2, type FillOrderEstimateV2, type FillerBid, type FillerConfig, type GetRequestResponse, type GetRequestWithStatus, type GetResponseByRequestIdResponse, type GetResponseStorageValues, type HexString, type HostParams, HyperClientStatus, type HyperbridgeTxEvents, type IChain, type IConfig, type IEvmChain, type IEvmConfig, type IGetRequest, type IGetRequestMessage, type IGetResponse, type IGetResponseMessage, type IHyperbridgeConfig, type IIsmpMessage, type IMessage, type IPostRequest, type IPostResponse, type IProof, type IRequestMessage, type ISubstrateConfig, type ITimeoutPostRequestMessage, IndexerClient, type IndexerQueryClient, IntentGateway, type IntentGatewayParams, IntentOrderStatus, type IntentOrderStatusKey, type IntentOrderStatusMetadata, type IntentOrderStatusUpdate, IntentsCoprocessor, IntentsV2, type IntentsV2Context, type IsmpRequest, MOCK_ADDRESS, type NewDeployment, ORDER_V2_PARAM_TYPE, type Order, type OrderResponse, OrderStatus, type OrderStatusMetadata, type OrderV2, type OrderWithStatus, PACKED_USEROP_TYPEHASH, PLACE_ORDER_SELECTOR, type PackedUserOperation, type Params, type PaymentInfo, type PaymentInfoV2, type PostRequestStatus, type PostRequestTimeoutStatus, type PostRequestWithStatus, type QuoteNativeResult, 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 RetryConfig, SELECT_SOLVER_TYPEHASH, STATE_COMMITMENTS_SLOT, type SelectBidResult, type SelectOptions, type StateMachineHeight, 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 TokenInfoV2, type TokenPrice, type TokenPricesResponse, type TokenRegistry, type TokenRegistryResponse, type Transaction, TronChain, type TronChainParams, USE_ETHERSCAN_CHAINS, type XcmGatewayParams, __test, adjustDecimals, bytes20ToBytes32, bytes32ToBytes20, calculateAllowanceMappingLocation, calculateBalanceMappingLocation, chainConfigs, constructRedeemEscrowRequestBody, constructRefundEscrowRequestBody, convertCodecToIGetRequest, convertCodecToIProof, convertIGetRequestToCodec, convertIProofToCodec, convertStateIdToStateMachineId, convertStateMachineEnumToString, convertStateMachineIdToEnum, createChain, createEvmChain, createIndexerClient, createQueryClient, decodeUserOpScale, encodeERC7821ExecuteBatch, encodeISMPMessage, encodeUserOpScale, encodeWithdrawalRequest, estimateGasForPost, fetchPrice, fetchSourceProof, generateRootWithProof, getChain, getChainId, getConfigByStateMachineId, getContractCallInput, getEvmChain, getGasPriceFromEtherscan, getOrFetchStorageSlot, getOrderPlacedFromTx, getPostRequestEventFromTx, getPostResponseEventFromTx, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, getSubstrateChain, getViemChain, hexToString, hyperbridgeAddress, maxBigInt, orderCommitment, orderV2Commitment, parseStateMachineId, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, requestCommitmentKey, retryPromise, teleport, teleportDot, transformOrderForContract, tronChainIds, tronNile };
|
|
4494
|
+
export { ADDRESS_ZERO, type AllStatusKey, type AssetTeleported, type AssetTeleportedResponse, type BidStorageEntry, type BidSubmissionResult, type BlockMetadata, type BundlerGasEstimate, BundlerMethod, type CancelEvent, type CancelEventMap, type CancelOptions, type ChainConfig, type ChainConfigData, ChainConfigService, Chains, type ClientConfig, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DOMAIN_TYPEHASH, DUMMY_PRIVATE_KEY, type DecodedOrderPlacedLog, type DecodedOrderV2PlacedLog, type DecodedPostRequestEvent, type DecodedPostResponseEvent, type DispatchGet, type DispatchInfoV2, type DispatchPost, ERC20Method, type ERC7821Call, ERC7821_BATCH_MODE, type EstimateFillOrderV2Params, type EstimateGasCallData, EvmChain, type EvmChainParams, EvmLanguage, type ExecuteIntentOrderOptions, type ExecutionResult, type FillOptions, type FillOptionsV2, type FillOrderEstimateV2, type FillerBid, type FillerConfig, type GetRequestResponse, type GetRequestWithStatus, type GetResponseByRequestIdResponse, type GetResponseStorageValues, type HexString, type HostParams, HyperClientStatus, type HyperbridgeTxEvents, type IChain, type IConfig, type IEvmChain, type IEvmConfig, type IGetRequest, type IGetRequestMessage, type IGetResponse, type IGetResponseMessage, type IHyperbridgeConfig, type IIsmpMessage, type IMessage, type IPostRequest, type IPostResponse, type IProof, type IRequestMessage, type ISubstrateConfig, type ITimeoutPostRequestMessage, IndexerClient, type IndexerQueryClient, IntentGateway, type IntentGatewayParams, IntentOrderStatus, type IntentOrderStatusKey, type IntentOrderStatusMetadata, type IntentOrderStatusUpdate, IntentsCoprocessor, IntentsV2, type IntentsV2Context, type IsmpRequest, MOCK_ADDRESS, type NewDeployment, ORDER_V2_PARAM_TYPE, type Order, type OrderResponse, OrderStatus, OrderStatusChecker, type OrderStatusMetadata, type OrderV2, type OrderWithStatus, PACKED_USEROP_TYPEHASH, PLACE_ORDER_SELECTOR, type PackedUserOperation, type Params, type PaymentInfo, type PaymentInfoV2, type PostRequestStatus, type PostRequestTimeoutStatus, type PostRequestWithStatus, type QuoteNativeResult, 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 RetryConfig, SELECT_SOLVER_TYPEHASH, STATE_COMMITMENTS_SLOT, type SelectBidResult, type SelectOptions, type StateMachineHeight, 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 TokenInfoV2, type TokenPrice, type TokenPricesResponse, type TokenRegistry, type TokenRegistryResponse, type Transaction, TronChain, type TronChainParams, USE_ETHERSCAN_CHAINS, type XcmGatewayParams, __test, adjustDecimals, bytes20ToBytes32, bytes32ToBytes20, calculateAllowanceMappingLocation, calculateBalanceMappingLocation, chainConfigs, constructRedeemEscrowRequestBody, constructRefundEscrowRequestBody, convertCodecToIGetRequest, convertCodecToIProof, convertIGetRequestToCodec, convertIProofToCodec, convertStateIdToStateMachineId, convertStateMachineEnumToString, convertStateMachineIdToEnum, createChain, createEvmChain, createIndexerClient, createQueryClient, decodeUserOpScale, encodeERC7821ExecuteBatch, encodeISMPMessage, encodeUserOpScale, encodeWithdrawalRequest, estimateGasForPost, fetchPrice, fetchSourceProof, generateRootWithProof, getChain, getChainId, getConfigByStateMachineId, getContractCallInput, getEvmChain, getGasPriceFromEtherscan, getOrFetchStorageSlot, getOrderPlacedFromTx, getPostRequestEventFromTx, getPostResponseEventFromTx, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, getSubstrateChain, getViemChain, hexToString, hyperbridgeAddress, maxBigInt, orderCommitment, orderV2Commitment, parseStateMachineId, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, requestCommitmentKey, retryPromise, teleport, teleportDot, transformOrderForContract, tronChainIds, tronNile };
|
package/dist/node/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { join } from 'path';
|
|
|
3
3
|
import { TextDecoder as TextDecoder$1, TextEncoder as TextEncoder$1 } from 'util';
|
|
4
4
|
import { createConsola, LogLevels } from 'consola';
|
|
5
5
|
import { flatten, zip, capitalize, maxBy, isNil } from 'lodash-es';
|
|
6
|
-
import { defineChain, keccak256, toHex, hexToBytes, encodePacked, encodeAbiParameters, bytesToHex, createPublicClient, http, encodeFunctionData, erc20Abi, bytesToBigInt, pad, toBytes, numberToBytes, maxUint256, parseAbiParameters, parseAbiItem, formatUnits, parseUnits, concatHex, hexToString as hexToString$1, parseEventLogs, concat, decodeFunctionData, decodeAbiParameters
|
|
6
|
+
import { defineChain, keccak256, toHex, hexToBytes, encodePacked, encodeAbiParameters, bytesToHex, createPublicClient, http, encodeFunctionData, erc20Abi, bytesToBigInt, pad, toBytes, numberToBytes, maxUint256, parseAbiParameters, parseAbiItem, formatUnits, parseUnits, concatHex, hexToString as hexToString$1, parseEventLogs, isHex, concat, decodeFunctionData, decodeAbiParameters } from 'viem';
|
|
7
7
|
import mergeRace from '@async-generator/merge-race';
|
|
8
8
|
import { polygonAmoy, unichain, polygon, base, arbitrum, bsc, mainnet, sepolia, gnosisChiado, bscTestnet, tron, gnosis, soneium, baseSepolia, optimismSepolia, optimism, arbitrumSepolia } from 'viem/chains';
|
|
9
9
|
import { TronWeb } from 'tronweb';
|
|
@@ -389,11 +389,13 @@ var chainConfigs = {
|
|
|
389
389
|
WETH: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
|
|
390
390
|
DAI: "0x6b175474e89094c44da98b954eedeac495271d0f",
|
|
391
391
|
USDC: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
|
392
|
-
USDT: "0xdac17f958d2ee523a2206206994597c13d831ec7"
|
|
392
|
+
USDT: "0xdac17f958d2ee523a2206206994597c13d831ec7",
|
|
393
|
+
cNGN: "0x17CDB2a01e7a34CbB3DD4b83260B05d0274C8dab"
|
|
393
394
|
},
|
|
394
395
|
tokenDecimals: {
|
|
395
396
|
USDC: 6,
|
|
396
|
-
USDT: 6
|
|
397
|
+
USDT: 6,
|
|
398
|
+
cNGN: 6
|
|
397
399
|
},
|
|
398
400
|
tokenStorageSlots: {
|
|
399
401
|
USDT: { balanceSlot: 2, allowanceSlot: 5 },
|
|
@@ -546,12 +548,12 @@ var chainConfigs = {
|
|
|
546
548
|
DAI: "0x50c5725949a6f0c72e6c4a641f24049a917db0cb",
|
|
547
549
|
USDC: "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
|
|
548
550
|
USDT: "0xfde4c96c8593536e31f229ea8f37b2ada2699bb2",
|
|
549
|
-
|
|
551
|
+
cNGN: "0x46C85152bFe9f96829aA94755D9f915F9B10EF5F"
|
|
550
552
|
},
|
|
551
553
|
tokenDecimals: {
|
|
552
554
|
USDC: 6,
|
|
553
555
|
USDT: 6,
|
|
554
|
-
|
|
556
|
+
cNGN: 6
|
|
555
557
|
},
|
|
556
558
|
tokenStorageSlots: {
|
|
557
559
|
USDT: { balanceSlot: 0, allowanceSlot: 1 },
|
|
@@ -598,12 +600,12 @@ var chainConfigs = {
|
|
|
598
600
|
DAI: "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063",
|
|
599
601
|
USDC: "0x3c499c542cef5e3811e1192ce70d8cc03d5c3359",
|
|
600
602
|
USDT: "0xc2132d05d31c914a87c6611c10748aeb04b58e8f",
|
|
601
|
-
|
|
603
|
+
cNGN: "0x52828daa48C1a9A06F37500882b42daf0bE04C3B"
|
|
602
604
|
},
|
|
603
605
|
tokenDecimals: {
|
|
604
606
|
USDC: 6,
|
|
605
607
|
USDT: 6,
|
|
606
|
-
|
|
608
|
+
cNGN: 6
|
|
607
609
|
},
|
|
608
610
|
tokenStorageSlots: {
|
|
609
611
|
USDT: { balanceSlot: 0, allowanceSlot: 1 },
|
|
@@ -16299,13 +16301,11 @@ var GasEstimator = class {
|
|
|
16299
16301
|
const { order } = params;
|
|
16300
16302
|
const solverPrivateKey = generatePrivateKey();
|
|
16301
16303
|
const solverAccountAddress = privateKeyToAddress(solverPrivateKey);
|
|
16302
|
-
const
|
|
16304
|
+
const souceStateMachineId = isHex(order.source) ? hexToString$1(order.source) : order.source;
|
|
16303
16305
|
const destStateMachineId = isHex(order.destination) ? hexToString$1(order.destination) : order.destination;
|
|
16304
16306
|
const intentGatewayV2Address = this.ctx.dest.configService.getIntentGatewayV2Address(destStateMachineId);
|
|
16305
16307
|
const entryPointAddress = this.ctx.dest.configService.getEntryPointV08Address(destStateMachineId);
|
|
16306
|
-
const chainId = BigInt(
|
|
16307
|
-
this.ctx.dest.client.chain?.id ?? Number.parseInt(this.ctx.dest.config.stateMachineId.split("-")[1])
|
|
16308
|
-
);
|
|
16308
|
+
const chainId = BigInt(Number.parseInt(destStateMachineId.split("-")[1]));
|
|
16309
16309
|
const totalEthValue = order.output.assets.filter((output) => bytes32ToBytes20(output.token) === ADDRESS_ZERO).reduce((sum, output) => sum + output.amount, 0n);
|
|
16310
16310
|
const sourceFeeToken = await getFeeToken(this.ctx, this.ctx.source.config.stateMachineId, this.ctx.source);
|
|
16311
16311
|
const destFeeToken = await getFeeToken(this.ctx, this.ctx.dest.config.stateMachineId, this.ctx.dest);
|
|
@@ -16322,7 +16322,7 @@ var GasEstimator = class {
|
|
|
16322
16322
|
intentGatewayV2Address,
|
|
16323
16323
|
entryPointAddress
|
|
16324
16324
|
});
|
|
16325
|
-
const isSameChain =
|
|
16325
|
+
const isSameChain = souceStateMachineId === destStateMachineId;
|
|
16326
16326
|
let postRequestFeeInDestFeeToken = 0n;
|
|
16327
16327
|
let protocolFeeInNativeToken = 0n;
|
|
16328
16328
|
if (!isSameChain) {
|
|
@@ -16331,7 +16331,7 @@ var GasEstimator = class {
|
|
|
16331
16331
|
this.ctx,
|
|
16332
16332
|
postRequestGas,
|
|
16333
16333
|
"source",
|
|
16334
|
-
|
|
16334
|
+
souceStateMachineId
|
|
16335
16335
|
);
|
|
16336
16336
|
postRequestFeeInDestFeeToken = adjustDecimals(
|
|
16337
16337
|
postRequestFeeInSourceFeeToken,
|
|
@@ -16340,12 +16340,12 @@ var GasEstimator = class {
|
|
|
16340
16340
|
);
|
|
16341
16341
|
const postRequest = {
|
|
16342
16342
|
source: destStateMachineId,
|
|
16343
|
-
dest:
|
|
16343
|
+
dest: souceStateMachineId,
|
|
16344
16344
|
body: constructRedeemEscrowRequestBody({ ...order, id: orderV2Commitment(order) }, MOCK_ADDRESS),
|
|
16345
16345
|
timeoutTimestamp: 0n,
|
|
16346
16346
|
nonce: await this.ctx.source.getHostNonce(),
|
|
16347
16347
|
from: this.ctx.source.configService.getIntentGatewayV2Address(destStateMachineId),
|
|
16348
|
-
to: this.ctx.source.configService.getIntentGatewayV2Address(
|
|
16348
|
+
to: this.ctx.source.configService.getIntentGatewayV2Address(souceStateMachineId)
|
|
16349
16349
|
};
|
|
16350
16350
|
protocolFeeInNativeToken = await this.quoteNative(postRequest, postRequestFeeInDestFeeToken).catch(
|
|
16351
16351
|
() => this.ctx.dest.quoteNative(postRequest, postRequestFeeInDestFeeToken).catch(() => 0n)
|
|
@@ -16596,6 +16596,66 @@ var GasEstimator = class {
|
|
|
16596
16596
|
});
|
|
16597
16597
|
}
|
|
16598
16598
|
};
|
|
16599
|
+
var OrderStatusChecker = class {
|
|
16600
|
+
constructor(ctx) {
|
|
16601
|
+
this.ctx = ctx;
|
|
16602
|
+
}
|
|
16603
|
+
/**
|
|
16604
|
+
* Checks if a V2 order has been filled by reading the commitment storage slot on the destination chain.
|
|
16605
|
+
*
|
|
16606
|
+
* Reads the storage slot returned by `calculateCommitmentSlotHash` on the IntentGatewayV2 contract.
|
|
16607
|
+
* A non-zero value at that slot means the solver has called `fillOrder` and the order is complete
|
|
16608
|
+
* from the user's perspective (the beneficiary has received their tokens).
|
|
16609
|
+
*
|
|
16610
|
+
* @param order - The V2 order to check. `order.id` is used as the commitment; if not set it is computed.
|
|
16611
|
+
* @returns True if the order has been filled on the destination chain, false otherwise.
|
|
16612
|
+
*/
|
|
16613
|
+
async isOrderFilled(order) {
|
|
16614
|
+
const commitment = order.id ?? orderV2Commitment(order);
|
|
16615
|
+
const destStateMachineId = isHex(order.destination) ? hexToString$1(order.destination) : order.destination;
|
|
16616
|
+
const intentGatewayV2Address = this.ctx.dest.configService.getIntentGatewayV2Address(destStateMachineId);
|
|
16617
|
+
const filledSlot = await this.ctx.dest.client.readContract({
|
|
16618
|
+
abi: ABI3,
|
|
16619
|
+
address: intentGatewayV2Address,
|
|
16620
|
+
functionName: "calculateCommitmentSlotHash",
|
|
16621
|
+
args: [commitment]
|
|
16622
|
+
});
|
|
16623
|
+
const filledStatus = await this.ctx.dest.client.getStorageAt({
|
|
16624
|
+
address: intentGatewayV2Address,
|
|
16625
|
+
slot: filledSlot
|
|
16626
|
+
});
|
|
16627
|
+
return filledStatus !== "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
16628
|
+
}
|
|
16629
|
+
/**
|
|
16630
|
+
* Checks if a V2 order has been refunded by reading the `_orders` mapping on the source chain.
|
|
16631
|
+
*
|
|
16632
|
+
* Calls `_orders(commitment, tokenAddress)` for each input token. When the order is placed the
|
|
16633
|
+
* escrowed amounts are stored there. After a successful refund the contract zeroes them out.
|
|
16634
|
+
* An order is considered refunded when all escrowed input amounts have been returned (i.e. are 0).
|
|
16635
|
+
*
|
|
16636
|
+
* @param order - The V2 order to check. `order.id` is used as the commitment; if not set it is computed.
|
|
16637
|
+
* @returns True if all escrowed inputs have been returned to the user on the source chain, false otherwise.
|
|
16638
|
+
*/
|
|
16639
|
+
async isOrderRefunded(order) {
|
|
16640
|
+
if (!order.inputs || order.inputs.length === 0) return false;
|
|
16641
|
+
const commitment = order.id ?? orderV2Commitment(order);
|
|
16642
|
+
const sourceStateMachineId = isHex(order.source) ? hexToString$1(order.source) : order.source;
|
|
16643
|
+
const intentGatewayV2Address = this.ctx.source.configService.getIntentGatewayV2Address(sourceStateMachineId);
|
|
16644
|
+
for (const input of order.inputs) {
|
|
16645
|
+
const tokenAddress = bytes32ToBytes20(input.token);
|
|
16646
|
+
const escrowedAmount = await this.ctx.source.client.readContract({
|
|
16647
|
+
abi: ABI3,
|
|
16648
|
+
address: intentGatewayV2Address,
|
|
16649
|
+
functionName: "_orders",
|
|
16650
|
+
args: [commitment, tokenAddress]
|
|
16651
|
+
});
|
|
16652
|
+
if (escrowedAmount !== 0n) {
|
|
16653
|
+
return false;
|
|
16654
|
+
}
|
|
16655
|
+
}
|
|
16656
|
+
return true;
|
|
16657
|
+
}
|
|
16658
|
+
};
|
|
16599
16659
|
|
|
16600
16660
|
// src/protocols/intentsV2/IntentsV2.ts
|
|
16601
16661
|
var IntentsV2 = class _IntentsV2 {
|
|
@@ -16608,6 +16668,7 @@ var IntentsV2 = class _IntentsV2 {
|
|
|
16608
16668
|
orderPlacer;
|
|
16609
16669
|
orderExecutor;
|
|
16610
16670
|
orderCanceller;
|
|
16671
|
+
orderStatusChecker;
|
|
16611
16672
|
bidManager;
|
|
16612
16673
|
gasEstimator;
|
|
16613
16674
|
constructor(source, dest, intentsCoprocessor, bundlerUrl) {
|
|
@@ -16637,6 +16698,7 @@ var IntentsV2 = class _IntentsV2 {
|
|
|
16637
16698
|
this.orderPlacer = new OrderPlacer(this.ctx);
|
|
16638
16699
|
this.orderExecutor = new OrderExecutor(this.ctx, bidManager);
|
|
16639
16700
|
this.orderCanceller = new OrderCanceller(this.ctx);
|
|
16701
|
+
this.orderStatusChecker = new OrderStatusChecker(this.ctx);
|
|
16640
16702
|
this.bidManager = bidManager;
|
|
16641
16703
|
this.gasEstimator = gasEstimator;
|
|
16642
16704
|
this._crypto = crypto;
|
|
@@ -16732,6 +16794,12 @@ var IntentsV2 = class _IntentsV2 {
|
|
|
16732
16794
|
decodeERC7821Execute(callData) {
|
|
16733
16795
|
return this._crypto.decodeERC7821Execute(callData);
|
|
16734
16796
|
}
|
|
16797
|
+
async isOrderFilled(order) {
|
|
16798
|
+
return this.orderStatusChecker.isOrderFilled(order);
|
|
16799
|
+
}
|
|
16800
|
+
async isOrderRefunded(order) {
|
|
16801
|
+
return this.orderStatusChecker.isOrderRefunded(order);
|
|
16802
|
+
}
|
|
16735
16803
|
};
|
|
16736
16804
|
var TokenGateway = class {
|
|
16737
16805
|
source;
|
|
@@ -17183,6 +17251,6 @@ async function teleportDot(param_) {
|
|
|
17183
17251
|
return stream;
|
|
17184
17252
|
}
|
|
17185
17253
|
|
|
17186
|
-
export { ADDRESS_ZERO, BundlerMethod, ChainConfigService, Chains, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DOMAIN_TYPEHASH, DUMMY_PRIVATE_KEY, ERC20Method, ERC7821_BATCH_MODE, EvmChain, EvmLanguage, HyperClientStatus, IndexerClient, IntentGateway, IntentOrderStatus, IntentsCoprocessor, IntentsV2, MOCK_ADDRESS, ORDER_V2_PARAM_TYPE, OrderStatus, PACKED_USEROP_TYPEHASH, PLACE_ORDER_SELECTOR, 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, __test, adjustDecimals, bytes20ToBytes32, bytes32ToBytes20, calculateAllowanceMappingLocation, calculateBalanceMappingLocation, chainConfigs, constructRedeemEscrowRequestBody, constructRefundEscrowRequestBody, convertCodecToIGetRequest, convertCodecToIProof, convertIGetRequestToCodec, convertIProofToCodec, convertStateIdToStateMachineId, convertStateMachineEnumToString, convertStateMachineIdToEnum, createChain, createEvmChain, createIndexerClient, createQueryClient, decodeUserOpScale, encodeERC7821ExecuteBatch, encodeISMPMessage, encodeUserOpScale, encodeWithdrawalRequest, estimateGasForPost, fetchPrice, fetchSourceProof2 as fetchSourceProof, generateRootWithProof, getChain, getChainId, getConfigByStateMachineId, getContractCallInput, getEvmChain, getGasPriceFromEtherscan, getOrFetchStorageSlot, getOrderPlacedFromTx, getPostRequestEventFromTx, getPostResponseEventFromTx, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, getSubstrateChain, getViemChain, hexToString, hyperbridgeAddress, maxBigInt, orderCommitment, orderV2Commitment, parseStateMachineId, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, requestCommitmentKey, retryPromise, teleport, teleportDot, transformOrderForContract, tronChainIds, tronNile };
|
|
17254
|
+
export { ADDRESS_ZERO, BundlerMethod, ChainConfigService, Chains, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DOMAIN_TYPEHASH, DUMMY_PRIVATE_KEY, ERC20Method, ERC7821_BATCH_MODE, EvmChain, EvmLanguage, HyperClientStatus, IndexerClient, IntentGateway, IntentOrderStatus, IntentsCoprocessor, IntentsV2, MOCK_ADDRESS, ORDER_V2_PARAM_TYPE, OrderStatus, OrderStatusChecker, PACKED_USEROP_TYPEHASH, PLACE_ORDER_SELECTOR, 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, __test, adjustDecimals, bytes20ToBytes32, bytes32ToBytes20, calculateAllowanceMappingLocation, calculateBalanceMappingLocation, chainConfigs, constructRedeemEscrowRequestBody, constructRefundEscrowRequestBody, convertCodecToIGetRequest, convertCodecToIProof, convertIGetRequestToCodec, convertIProofToCodec, convertStateIdToStateMachineId, convertStateMachineEnumToString, convertStateMachineIdToEnum, createChain, createEvmChain, createIndexerClient, createQueryClient, decodeUserOpScale, encodeERC7821ExecuteBatch, encodeISMPMessage, encodeUserOpScale, encodeWithdrawalRequest, estimateGasForPost, fetchPrice, fetchSourceProof2 as fetchSourceProof, generateRootWithProof, getChain, getChainId, getConfigByStateMachineId, getContractCallInput, getEvmChain, getGasPriceFromEtherscan, getOrFetchStorageSlot, getOrderPlacedFromTx, getPostRequestEventFromTx, getPostResponseEventFromTx, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, getSubstrateChain, getViemChain, hexToString, hyperbridgeAddress, maxBigInt, orderCommitment, orderV2Commitment, parseStateMachineId, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, requestCommitmentKey, retryPromise, teleport, teleportDot, transformOrderForContract, tronChainIds, tronNile };
|
|
17187
17255
|
//# sourceMappingURL=index.js.map
|
|
17188
17256
|
//# sourceMappingURL=index.js.map
|