@hyperbridge/sdk 1.3.13 → 1.3.15
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 +0 -12
- package/dist/browser/index.js +71 -29
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.d.ts +0 -12
- package/dist/node/index.js +71 -29
- package/dist/node/index.js.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.d.ts
CHANGED
|
@@ -2761,7 +2761,6 @@ declare class IntentGateway {
|
|
|
2761
2761
|
failedHeight?: undefined;
|
|
2762
2762
|
error?: undefined;
|
|
2763
2763
|
deadline?: undefined;
|
|
2764
|
-
height?: undefined;
|
|
2765
2764
|
};
|
|
2766
2765
|
} | {
|
|
2767
2766
|
status: string;
|
|
@@ -2772,7 +2771,6 @@ declare class IntentGateway {
|
|
|
2772
2771
|
proof?: undefined;
|
|
2773
2772
|
failedHeight?: undefined;
|
|
2774
2773
|
error?: undefined;
|
|
2775
|
-
height?: undefined;
|
|
2776
2774
|
};
|
|
2777
2775
|
} | {
|
|
2778
2776
|
status: string;
|
|
@@ -2781,16 +2779,6 @@ declare class IntentGateway {
|
|
|
2781
2779
|
error: string;
|
|
2782
2780
|
deadline: bigint;
|
|
2783
2781
|
proof?: undefined;
|
|
2784
|
-
height?: undefined;
|
|
2785
|
-
};
|
|
2786
|
-
} | {
|
|
2787
|
-
status: string;
|
|
2788
|
-
data: {
|
|
2789
|
-
proof: `0x${string}`;
|
|
2790
|
-
height: bigint;
|
|
2791
|
-
failedHeight?: undefined;
|
|
2792
|
-
error?: undefined;
|
|
2793
|
-
deadline?: undefined;
|
|
2794
2782
|
};
|
|
2795
2783
|
} | {
|
|
2796
2784
|
status: string;
|
package/dist/browser/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { createConsola, LogLevels } from 'consola';
|
|
|
2
2
|
import { flatten, zip, capitalize, maxBy, isNil } from 'lodash-es';
|
|
3
3
|
import { toHex, hexToBytes, encodePacked, keccak256, encodeAbiParameters, bytesToHex, concatHex, createPublicClient, http, encodeFunctionData, erc20Abi, bytesToBigInt, pad, toBytes, maxUint256, formatUnits, parseUnits, hexToString as hexToString$1 } from 'viem';
|
|
4
4
|
import mergeRace from '@async-generator/merge-race';
|
|
5
|
-
import { gnosisChiado, gnosis, bscTestnet, bsc, soneium, baseSepolia, base, optimismSepolia, optimism, arbitrumSepolia, arbitrum, mainnet,
|
|
5
|
+
import { unichain, polygon, gnosisChiado, gnosis, bscTestnet, bsc, soneium, baseSepolia, base, optimismSepolia, optimism, arbitrumSepolia, arbitrum, mainnet, sepolia } from 'viem/chains';
|
|
6
6
|
import { hasWindow, isNode, env } from 'std-env';
|
|
7
7
|
import { Vector, u8, Struct, Tuple, Enum, _void, u64, u32, Option, bool, u128, Bytes } from 'scale-ts';
|
|
8
8
|
import { match } from 'ts-pattern';
|
|
@@ -4643,7 +4643,9 @@ var chains = {
|
|
|
4643
4643
|
[bsc.id]: bsc,
|
|
4644
4644
|
[bscTestnet.id]: bscTestnet,
|
|
4645
4645
|
[gnosis.id]: gnosis,
|
|
4646
|
-
[gnosisChiado.id]: gnosisChiado
|
|
4646
|
+
[gnosisChiado.id]: gnosisChiado,
|
|
4647
|
+
[polygon.id]: polygon,
|
|
4648
|
+
[unichain.id]: unichain
|
|
4647
4649
|
};
|
|
4648
4650
|
var DEFAULT_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
4649
4651
|
var EvmChain = class {
|
|
@@ -12423,7 +12425,7 @@ var IntentGateway = class {
|
|
|
12423
12425
|
proof: proofHex,
|
|
12424
12426
|
stateMachine: destStateMachine
|
|
12425
12427
|
};
|
|
12426
|
-
yield { status: "DESTINATION_FINALIZED", data: { proof: destIProof
|
|
12428
|
+
yield { status: "DESTINATION_FINALIZED", data: { proof: destIProof } };
|
|
12427
12429
|
}
|
|
12428
12430
|
const getRequest = storedData?.getRequest ?? (yield { status: "AWAITING_GET_REQUEST" });
|
|
12429
12431
|
if (!getRequest) throw new Error("[Cancel Order]: Get Request not provided");
|
|
@@ -12431,34 +12433,74 @@ var IntentGateway = class {
|
|
|
12431
12433
|
const sourceStatusStream = indexerClient.getRequestStatusStream(commitment);
|
|
12432
12434
|
for await (const statusUpdate of sourceStatusStream) {
|
|
12433
12435
|
if (statusUpdate.status === RequestStatus.SOURCE_FINALIZED) {
|
|
12434
|
-
|
|
12435
|
-
|
|
12436
|
-
|
|
12437
|
-
|
|
12438
|
-
|
|
12439
|
-
|
|
12440
|
-
|
|
12441
|
-
height: sourceHeight,
|
|
12442
|
-
stateMachine: sourceStateMachine,
|
|
12443
|
-
consensusStateId: sourceConsensusStateId,
|
|
12444
|
-
proof
|
|
12436
|
+
let sourceHeight = BigInt(statusUpdate.metadata.blockNumber);
|
|
12437
|
+
let proof;
|
|
12438
|
+
const checkIfAlreadyDelivered = async () => {
|
|
12439
|
+
const currentStatus = await indexerClient.queryGetRequestWithStatus(commitment);
|
|
12440
|
+
return currentStatus?.statuses.some(
|
|
12441
|
+
(status) => status.status === RequestStatus.HYPERBRIDGE_DELIVERED
|
|
12442
|
+
) ?? false;
|
|
12445
12443
|
};
|
|
12446
|
-
|
|
12447
|
-
|
|
12448
|
-
|
|
12449
|
-
|
|
12450
|
-
|
|
12451
|
-
|
|
12452
|
-
|
|
12453
|
-
|
|
12454
|
-
|
|
12455
|
-
|
|
12456
|
-
|
|
12457
|
-
|
|
12458
|
-
|
|
12444
|
+
while (true) {
|
|
12445
|
+
try {
|
|
12446
|
+
proof = await this.source.queryProof(
|
|
12447
|
+
{ Requests: [commitment] },
|
|
12448
|
+
hyperbridgeConfig.stateMachineId,
|
|
12449
|
+
sourceHeight
|
|
12450
|
+
);
|
|
12451
|
+
break;
|
|
12452
|
+
} catch {
|
|
12453
|
+
const failedHeight = sourceHeight;
|
|
12454
|
+
while (sourceHeight <= failedHeight) {
|
|
12455
|
+
if (await checkIfAlreadyDelivered()) {
|
|
12456
|
+
break;
|
|
12457
|
+
}
|
|
12458
|
+
const nextHeight = await retryPromise(
|
|
12459
|
+
() => hyperbridge.latestStateMachineHeight({
|
|
12460
|
+
stateId: parseStateMachineId(sourceStateMachine).stateId,
|
|
12461
|
+
consensusStateId: sourceConsensusStateId
|
|
12462
|
+
}),
|
|
12463
|
+
{
|
|
12464
|
+
maxRetries: 5,
|
|
12465
|
+
backoffMs: 5e3,
|
|
12466
|
+
logMessage: "Failed to fetch latest state machine height (post-source-proof failure)"
|
|
12467
|
+
}
|
|
12468
|
+
);
|
|
12469
|
+
if (nextHeight <= failedHeight) {
|
|
12470
|
+
await sleep(1e4);
|
|
12471
|
+
continue;
|
|
12472
|
+
}
|
|
12473
|
+
sourceHeight = nextHeight;
|
|
12474
|
+
}
|
|
12475
|
+
if (await checkIfAlreadyDelivered()) {
|
|
12476
|
+
break;
|
|
12477
|
+
}
|
|
12459
12478
|
}
|
|
12460
|
-
}
|
|
12461
|
-
|
|
12479
|
+
}
|
|
12480
|
+
if (proof) {
|
|
12481
|
+
const sourceIProof = {
|
|
12482
|
+
height: sourceHeight,
|
|
12483
|
+
stateMachine: sourceStateMachine,
|
|
12484
|
+
consensusStateId: sourceConsensusStateId,
|
|
12485
|
+
proof
|
|
12486
|
+
};
|
|
12487
|
+
yield { status: "SOURCE_PROOF_RECEIVED", data: sourceIProof };
|
|
12488
|
+
const getRequestMessage = {
|
|
12489
|
+
kind: "GetRequest",
|
|
12490
|
+
requests: [getRequest],
|
|
12491
|
+
source: sourceIProof,
|
|
12492
|
+
response: destIProof,
|
|
12493
|
+
signer: pad("0x")
|
|
12494
|
+
};
|
|
12495
|
+
await waitForChallengePeriod(hyperbridge, {
|
|
12496
|
+
height: sourceHeight,
|
|
12497
|
+
id: {
|
|
12498
|
+
stateId: parseStateMachineId(sourceStateMachine).stateId,
|
|
12499
|
+
consensusStateId: sourceConsensusStateId
|
|
12500
|
+
}
|
|
12501
|
+
});
|
|
12502
|
+
await this.submitAndConfirmReceipt(hyperbridge, commitment, getRequestMessage);
|
|
12503
|
+
}
|
|
12462
12504
|
}
|
|
12463
12505
|
yield statusUpdate;
|
|
12464
12506
|
}
|