@hyperbridge/sdk 1.4.9 → 1.4.10
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 +9 -0
- package/dist/browser/index.js +34 -0
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.d.ts +9 -0
- package/dist/node/index.js +34 -0
- package/dist/node/index.js.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.d.ts
CHANGED
|
@@ -3079,6 +3079,15 @@ declare class IntentGateway {
|
|
|
3079
3079
|
* @returns True if the order has been filled, false otherwise
|
|
3080
3080
|
*/
|
|
3081
3081
|
isOrderFilled(order: Order): Promise<boolean>;
|
|
3082
|
+
/**
|
|
3083
|
+
* Checks if an order has been refunded by verifying the escrowed token amounts on-chain.
|
|
3084
|
+
* Reads the storage slots for the `_orders` mapping on the source chain (where the escrow is held).
|
|
3085
|
+
* An order is considered refunded when all input token amounts in the `_orders` mapping are 0.
|
|
3086
|
+
*
|
|
3087
|
+
* @param order - The order to check
|
|
3088
|
+
* @returns True if the order has been refunded (all token amounts are 0), false otherwise
|
|
3089
|
+
*/
|
|
3090
|
+
isOrderRefunded(order: Order): Promise<boolean>;
|
|
3082
3091
|
private submitAndConfirmReceipt;
|
|
3083
3092
|
/**
|
|
3084
3093
|
* Returns the native token amount required to dispatch a cancellation GET request for the given order.
|
package/dist/browser/index.js
CHANGED
|
@@ -12883,6 +12883,40 @@ var IntentGateway = class {
|
|
|
12883
12883
|
});
|
|
12884
12884
|
return filledStatus !== "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
12885
12885
|
}
|
|
12886
|
+
/**
|
|
12887
|
+
* Checks if an order has been refunded by verifying the escrowed token amounts on-chain.
|
|
12888
|
+
* Reads the storage slots for the `_orders` mapping on the source chain (where the escrow is held).
|
|
12889
|
+
* An order is considered refunded when all input token amounts in the `_orders` mapping are 0.
|
|
12890
|
+
*
|
|
12891
|
+
* @param order - The order to check
|
|
12892
|
+
* @returns True if the order has been refunded (all token amounts are 0), false otherwise
|
|
12893
|
+
*/
|
|
12894
|
+
async isOrderRefunded(order) {
|
|
12895
|
+
order = transformOrder(order);
|
|
12896
|
+
const intentGatewayAddress = this.destIntentGatewayAddress ?? this.source.configService.getIntentGatewayAddress(order.sourceChain);
|
|
12897
|
+
const commitment = order.id;
|
|
12898
|
+
const ORDERS_MAPPING_SLOT = 4n;
|
|
12899
|
+
const firstLevelSlot = keccak256(
|
|
12900
|
+
encodeAbiParameters([{ type: "bytes32" }, { type: "uint256" }], [commitment, ORDERS_MAPPING_SLOT])
|
|
12901
|
+
);
|
|
12902
|
+
for (const input of order.inputs) {
|
|
12903
|
+
const tokenAddress = bytes32ToBytes20(input.token);
|
|
12904
|
+
const storageSlot = keccak256(
|
|
12905
|
+
encodeAbiParameters(
|
|
12906
|
+
[{ type: "address" }, { type: "bytes32" }],
|
|
12907
|
+
[tokenAddress, firstLevelSlot]
|
|
12908
|
+
)
|
|
12909
|
+
);
|
|
12910
|
+
const escrowedAmount = await this.source.client.getStorageAt({
|
|
12911
|
+
address: intentGatewayAddress,
|
|
12912
|
+
slot: storageSlot
|
|
12913
|
+
});
|
|
12914
|
+
if (escrowedAmount !== "0x0000000000000000000000000000000000000000000000000000000000000000") {
|
|
12915
|
+
return false;
|
|
12916
|
+
}
|
|
12917
|
+
}
|
|
12918
|
+
return true;
|
|
12919
|
+
}
|
|
12886
12920
|
async submitAndConfirmReceipt(hyperbridge, commitment, message) {
|
|
12887
12921
|
let storageValue = await hyperbridge.queryRequestReceipt(commitment);
|
|
12888
12922
|
if (!storageValue) {
|