@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/browser/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/browser/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createConsola, LogLevels } from 'consola';
|
|
2
2
|
import { flatten, zip, capitalize, maxBy, isNil } from 'lodash-es';
|
|
3
|
-
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
|
|
3
|
+
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';
|
|
4
4
|
import mergeRace from '@async-generator/merge-race';
|
|
5
5
|
import { polygonAmoy, unichain, polygon, base, arbitrum, bsc, mainnet, sepolia, gnosisChiado, bscTestnet, tron, gnosis, soneium, baseSepolia, optimismSepolia, optimism, arbitrumSepolia } from 'viem/chains';
|
|
6
6
|
import { TronWeb } from 'tronweb';
|
|
@@ -439,11 +439,13 @@ var chainConfigs = {
|
|
|
439
439
|
WETH: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
|
|
440
440
|
DAI: "0x6b175474e89094c44da98b954eedeac495271d0f",
|
|
441
441
|
USDC: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
|
442
|
-
USDT: "0xdac17f958d2ee523a2206206994597c13d831ec7"
|
|
442
|
+
USDT: "0xdac17f958d2ee523a2206206994597c13d831ec7",
|
|
443
|
+
cNGN: "0x17CDB2a01e7a34CbB3DD4b83260B05d0274C8dab"
|
|
443
444
|
},
|
|
444
445
|
tokenDecimals: {
|
|
445
446
|
USDC: 6,
|
|
446
|
-
USDT: 6
|
|
447
|
+
USDT: 6,
|
|
448
|
+
cNGN: 6
|
|
447
449
|
},
|
|
448
450
|
tokenStorageSlots: {
|
|
449
451
|
USDT: { balanceSlot: 2, allowanceSlot: 5 },
|
|
@@ -596,12 +598,12 @@ var chainConfigs = {
|
|
|
596
598
|
DAI: "0x50c5725949a6f0c72e6c4a641f24049a917db0cb",
|
|
597
599
|
USDC: "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
|
|
598
600
|
USDT: "0xfde4c96c8593536e31f229ea8f37b2ada2699bb2",
|
|
599
|
-
|
|
601
|
+
cNGN: "0x46C85152bFe9f96829aA94755D9f915F9B10EF5F"
|
|
600
602
|
},
|
|
601
603
|
tokenDecimals: {
|
|
602
604
|
USDC: 6,
|
|
603
605
|
USDT: 6,
|
|
604
|
-
|
|
606
|
+
cNGN: 6
|
|
605
607
|
},
|
|
606
608
|
tokenStorageSlots: {
|
|
607
609
|
USDT: { balanceSlot: 0, allowanceSlot: 1 },
|
|
@@ -648,12 +650,12 @@ var chainConfigs = {
|
|
|
648
650
|
DAI: "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063",
|
|
649
651
|
USDC: "0x3c499c542cef5e3811e1192ce70d8cc03d5c3359",
|
|
650
652
|
USDT: "0xc2132d05d31c914a87c6611c10748aeb04b58e8f",
|
|
651
|
-
|
|
653
|
+
cNGN: "0x52828daa48C1a9A06F37500882b42daf0bE04C3B"
|
|
652
654
|
},
|
|
653
655
|
tokenDecimals: {
|
|
654
656
|
USDC: 6,
|
|
655
657
|
USDT: 6,
|
|
656
|
-
|
|
658
|
+
cNGN: 6
|
|
657
659
|
},
|
|
658
660
|
tokenStorageSlots: {
|
|
659
661
|
USDT: { balanceSlot: 0, allowanceSlot: 1 },
|
|
@@ -16359,13 +16361,11 @@ var GasEstimator = class {
|
|
|
16359
16361
|
const { order } = params;
|
|
16360
16362
|
const solverPrivateKey = generatePrivateKey();
|
|
16361
16363
|
const solverAccountAddress = privateKeyToAddress(solverPrivateKey);
|
|
16362
|
-
const
|
|
16364
|
+
const souceStateMachineId = isHex(order.source) ? hexToString$1(order.source) : order.source;
|
|
16363
16365
|
const destStateMachineId = isHex(order.destination) ? hexToString$1(order.destination) : order.destination;
|
|
16364
16366
|
const intentGatewayV2Address = this.ctx.dest.configService.getIntentGatewayV2Address(destStateMachineId);
|
|
16365
16367
|
const entryPointAddress = this.ctx.dest.configService.getEntryPointV08Address(destStateMachineId);
|
|
16366
|
-
const chainId = BigInt(
|
|
16367
|
-
this.ctx.dest.client.chain?.id ?? Number.parseInt(this.ctx.dest.config.stateMachineId.split("-")[1])
|
|
16368
|
-
);
|
|
16368
|
+
const chainId = BigInt(Number.parseInt(destStateMachineId.split("-")[1]));
|
|
16369
16369
|
const totalEthValue = order.output.assets.filter((output) => bytes32ToBytes20(output.token) === ADDRESS_ZERO).reduce((sum, output) => sum + output.amount, 0n);
|
|
16370
16370
|
const sourceFeeToken = await getFeeToken(this.ctx, this.ctx.source.config.stateMachineId, this.ctx.source);
|
|
16371
16371
|
const destFeeToken = await getFeeToken(this.ctx, this.ctx.dest.config.stateMachineId, this.ctx.dest);
|
|
@@ -16382,7 +16382,7 @@ var GasEstimator = class {
|
|
|
16382
16382
|
intentGatewayV2Address,
|
|
16383
16383
|
entryPointAddress
|
|
16384
16384
|
});
|
|
16385
|
-
const isSameChain =
|
|
16385
|
+
const isSameChain = souceStateMachineId === destStateMachineId;
|
|
16386
16386
|
let postRequestFeeInDestFeeToken = 0n;
|
|
16387
16387
|
let protocolFeeInNativeToken = 0n;
|
|
16388
16388
|
if (!isSameChain) {
|
|
@@ -16391,7 +16391,7 @@ var GasEstimator = class {
|
|
|
16391
16391
|
this.ctx,
|
|
16392
16392
|
postRequestGas,
|
|
16393
16393
|
"source",
|
|
16394
|
-
|
|
16394
|
+
souceStateMachineId
|
|
16395
16395
|
);
|
|
16396
16396
|
postRequestFeeInDestFeeToken = adjustDecimals(
|
|
16397
16397
|
postRequestFeeInSourceFeeToken,
|
|
@@ -16400,12 +16400,12 @@ var GasEstimator = class {
|
|
|
16400
16400
|
);
|
|
16401
16401
|
const postRequest = {
|
|
16402
16402
|
source: destStateMachineId,
|
|
16403
|
-
dest:
|
|
16403
|
+
dest: souceStateMachineId,
|
|
16404
16404
|
body: constructRedeemEscrowRequestBody({ ...order, id: orderV2Commitment(order) }, MOCK_ADDRESS),
|
|
16405
16405
|
timeoutTimestamp: 0n,
|
|
16406
16406
|
nonce: await this.ctx.source.getHostNonce(),
|
|
16407
16407
|
from: this.ctx.source.configService.getIntentGatewayV2Address(destStateMachineId),
|
|
16408
|
-
to: this.ctx.source.configService.getIntentGatewayV2Address(
|
|
16408
|
+
to: this.ctx.source.configService.getIntentGatewayV2Address(souceStateMachineId)
|
|
16409
16409
|
};
|
|
16410
16410
|
protocolFeeInNativeToken = await this.quoteNative(postRequest, postRequestFeeInDestFeeToken).catch(
|
|
16411
16411
|
() => this.ctx.dest.quoteNative(postRequest, postRequestFeeInDestFeeToken).catch(() => 0n)
|
|
@@ -16656,6 +16656,66 @@ var GasEstimator = class {
|
|
|
16656
16656
|
});
|
|
16657
16657
|
}
|
|
16658
16658
|
};
|
|
16659
|
+
var OrderStatusChecker = class {
|
|
16660
|
+
constructor(ctx) {
|
|
16661
|
+
this.ctx = ctx;
|
|
16662
|
+
}
|
|
16663
|
+
/**
|
|
16664
|
+
* Checks if a V2 order has been filled by reading the commitment storage slot on the destination chain.
|
|
16665
|
+
*
|
|
16666
|
+
* Reads the storage slot returned by `calculateCommitmentSlotHash` on the IntentGatewayV2 contract.
|
|
16667
|
+
* A non-zero value at that slot means the solver has called `fillOrder` and the order is complete
|
|
16668
|
+
* from the user's perspective (the beneficiary has received their tokens).
|
|
16669
|
+
*
|
|
16670
|
+
* @param order - The V2 order to check. `order.id` is used as the commitment; if not set it is computed.
|
|
16671
|
+
* @returns True if the order has been filled on the destination chain, false otherwise.
|
|
16672
|
+
*/
|
|
16673
|
+
async isOrderFilled(order) {
|
|
16674
|
+
const commitment = order.id ?? orderV2Commitment(order);
|
|
16675
|
+
const destStateMachineId = isHex(order.destination) ? hexToString$1(order.destination) : order.destination;
|
|
16676
|
+
const intentGatewayV2Address = this.ctx.dest.configService.getIntentGatewayV2Address(destStateMachineId);
|
|
16677
|
+
const filledSlot = await this.ctx.dest.client.readContract({
|
|
16678
|
+
abi: ABI3,
|
|
16679
|
+
address: intentGatewayV2Address,
|
|
16680
|
+
functionName: "calculateCommitmentSlotHash",
|
|
16681
|
+
args: [commitment]
|
|
16682
|
+
});
|
|
16683
|
+
const filledStatus = await this.ctx.dest.client.getStorageAt({
|
|
16684
|
+
address: intentGatewayV2Address,
|
|
16685
|
+
slot: filledSlot
|
|
16686
|
+
});
|
|
16687
|
+
return filledStatus !== "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
16688
|
+
}
|
|
16689
|
+
/**
|
|
16690
|
+
* Checks if a V2 order has been refunded by reading the `_orders` mapping on the source chain.
|
|
16691
|
+
*
|
|
16692
|
+
* Calls `_orders(commitment, tokenAddress)` for each input token. When the order is placed the
|
|
16693
|
+
* escrowed amounts are stored there. After a successful refund the contract zeroes them out.
|
|
16694
|
+
* An order is considered refunded when all escrowed input amounts have been returned (i.e. are 0).
|
|
16695
|
+
*
|
|
16696
|
+
* @param order - The V2 order to check. `order.id` is used as the commitment; if not set it is computed.
|
|
16697
|
+
* @returns True if all escrowed inputs have been returned to the user on the source chain, false otherwise.
|
|
16698
|
+
*/
|
|
16699
|
+
async isOrderRefunded(order) {
|
|
16700
|
+
if (!order.inputs || order.inputs.length === 0) return false;
|
|
16701
|
+
const commitment = order.id ?? orderV2Commitment(order);
|
|
16702
|
+
const sourceStateMachineId = isHex(order.source) ? hexToString$1(order.source) : order.source;
|
|
16703
|
+
const intentGatewayV2Address = this.ctx.source.configService.getIntentGatewayV2Address(sourceStateMachineId);
|
|
16704
|
+
for (const input of order.inputs) {
|
|
16705
|
+
const tokenAddress = bytes32ToBytes20(input.token);
|
|
16706
|
+
const escrowedAmount = await this.ctx.source.client.readContract({
|
|
16707
|
+
abi: ABI3,
|
|
16708
|
+
address: intentGatewayV2Address,
|
|
16709
|
+
functionName: "_orders",
|
|
16710
|
+
args: [commitment, tokenAddress]
|
|
16711
|
+
});
|
|
16712
|
+
if (escrowedAmount !== 0n) {
|
|
16713
|
+
return false;
|
|
16714
|
+
}
|
|
16715
|
+
}
|
|
16716
|
+
return true;
|
|
16717
|
+
}
|
|
16718
|
+
};
|
|
16659
16719
|
|
|
16660
16720
|
// src/protocols/intentsV2/IntentsV2.ts
|
|
16661
16721
|
var IntentsV2 = class _IntentsV2 {
|
|
@@ -16668,6 +16728,7 @@ var IntentsV2 = class _IntentsV2 {
|
|
|
16668
16728
|
orderPlacer;
|
|
16669
16729
|
orderExecutor;
|
|
16670
16730
|
orderCanceller;
|
|
16731
|
+
orderStatusChecker;
|
|
16671
16732
|
bidManager;
|
|
16672
16733
|
gasEstimator;
|
|
16673
16734
|
constructor(source, dest, intentsCoprocessor, bundlerUrl) {
|
|
@@ -16697,6 +16758,7 @@ var IntentsV2 = class _IntentsV2 {
|
|
|
16697
16758
|
this.orderPlacer = new OrderPlacer(this.ctx);
|
|
16698
16759
|
this.orderExecutor = new OrderExecutor(this.ctx, bidManager);
|
|
16699
16760
|
this.orderCanceller = new OrderCanceller(this.ctx);
|
|
16761
|
+
this.orderStatusChecker = new OrderStatusChecker(this.ctx);
|
|
16700
16762
|
this.bidManager = bidManager;
|
|
16701
16763
|
this.gasEstimator = gasEstimator;
|
|
16702
16764
|
this._crypto = crypto;
|
|
@@ -16792,6 +16854,12 @@ var IntentsV2 = class _IntentsV2 {
|
|
|
16792
16854
|
decodeERC7821Execute(callData) {
|
|
16793
16855
|
return this._crypto.decodeERC7821Execute(callData);
|
|
16794
16856
|
}
|
|
16857
|
+
async isOrderFilled(order) {
|
|
16858
|
+
return this.orderStatusChecker.isOrderFilled(order);
|
|
16859
|
+
}
|
|
16860
|
+
async isOrderRefunded(order) {
|
|
16861
|
+
return this.orderStatusChecker.isOrderRefunded(order);
|
|
16862
|
+
}
|
|
16795
16863
|
};
|
|
16796
16864
|
var TokenGateway = class {
|
|
16797
16865
|
source;
|
|
@@ -17243,6 +17311,6 @@ async function teleportDot(param_) {
|
|
|
17243
17311
|
return stream;
|
|
17244
17312
|
}
|
|
17245
17313
|
|
|
17246
|
-
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 };
|
|
17314
|
+
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 };
|
|
17247
17315
|
//# sourceMappingURL=index.js.map
|
|
17248
17316
|
//# sourceMappingURL=index.js.map
|