@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/node/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/node/index.js
CHANGED
|
@@ -12823,6 +12823,40 @@ var IntentGateway = class {
|
|
|
12823
12823
|
});
|
|
12824
12824
|
return filledStatus !== "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
12825
12825
|
}
|
|
12826
|
+
/**
|
|
12827
|
+
* Checks if an order has been refunded by verifying the escrowed token amounts on-chain.
|
|
12828
|
+
* Reads the storage slots for the `_orders` mapping on the source chain (where the escrow is held).
|
|
12829
|
+
* An order is considered refunded when all input token amounts in the `_orders` mapping are 0.
|
|
12830
|
+
*
|
|
12831
|
+
* @param order - The order to check
|
|
12832
|
+
* @returns True if the order has been refunded (all token amounts are 0), false otherwise
|
|
12833
|
+
*/
|
|
12834
|
+
async isOrderRefunded(order) {
|
|
12835
|
+
order = transformOrder(order);
|
|
12836
|
+
const intentGatewayAddress = this.destIntentGatewayAddress ?? this.source.configService.getIntentGatewayAddress(order.sourceChain);
|
|
12837
|
+
const commitment = order.id;
|
|
12838
|
+
const ORDERS_MAPPING_SLOT = 4n;
|
|
12839
|
+
const firstLevelSlot = keccak256(
|
|
12840
|
+
encodeAbiParameters([{ type: "bytes32" }, { type: "uint256" }], [commitment, ORDERS_MAPPING_SLOT])
|
|
12841
|
+
);
|
|
12842
|
+
for (const input of order.inputs) {
|
|
12843
|
+
const tokenAddress = bytes32ToBytes20(input.token);
|
|
12844
|
+
const storageSlot = keccak256(
|
|
12845
|
+
encodeAbiParameters(
|
|
12846
|
+
[{ type: "address" }, { type: "bytes32" }],
|
|
12847
|
+
[tokenAddress, firstLevelSlot]
|
|
12848
|
+
)
|
|
12849
|
+
);
|
|
12850
|
+
const escrowedAmount = await this.source.client.getStorageAt({
|
|
12851
|
+
address: intentGatewayAddress,
|
|
12852
|
+
slot: storageSlot
|
|
12853
|
+
});
|
|
12854
|
+
if (escrowedAmount !== "0x0000000000000000000000000000000000000000000000000000000000000000") {
|
|
12855
|
+
return false;
|
|
12856
|
+
}
|
|
12857
|
+
}
|
|
12858
|
+
return true;
|
|
12859
|
+
}
|
|
12826
12860
|
async submitAndConfirmReceipt(hyperbridge, commitment, message) {
|
|
12827
12861
|
let storageValue = await hyperbridge.queryRequestReceipt(commitment);
|
|
12828
12862
|
if (!storageValue) {
|