@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/node/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/node/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { createConsola, LogLevels } from 'consola';
|
|
|
5
5
|
import { flatten, zip, capitalize, maxBy, isNil } from 'lodash-es';
|
|
6
6
|
import { toHex, hexToBytes, encodePacked, keccak256, encodeAbiParameters, bytesToHex, concatHex, createPublicClient, http, encodeFunctionData, erc20Abi, bytesToBigInt, pad, toBytes, maxUint256, formatUnits, parseUnits, hexToString as hexToString$1 } from 'viem';
|
|
7
7
|
import mergeRace from '@async-generator/merge-race';
|
|
8
|
-
import { gnosisChiado, gnosis, bscTestnet, bsc, soneium, baseSepolia, base, optimismSepolia, optimism, arbitrumSepolia, arbitrum, mainnet,
|
|
8
|
+
import { unichain, polygon, gnosisChiado, gnosis, bscTestnet, bsc, soneium, baseSepolia, base, optimismSepolia, optimism, arbitrumSepolia, arbitrum, mainnet, sepolia } from 'viem/chains';
|
|
9
9
|
import { hasWindow, isNode, env } from 'std-env';
|
|
10
10
|
import { Vector, u8, Struct, Tuple, Enum, _void, u64, u32, Option, bool, u128, Bytes } from 'scale-ts';
|
|
11
11
|
import { match } from 'ts-pattern';
|
|
@@ -4594,7 +4594,9 @@ var chains = {
|
|
|
4594
4594
|
[bsc.id]: bsc,
|
|
4595
4595
|
[bscTestnet.id]: bscTestnet,
|
|
4596
4596
|
[gnosis.id]: gnosis,
|
|
4597
|
-
[gnosisChiado.id]: gnosisChiado
|
|
4597
|
+
[gnosisChiado.id]: gnosisChiado,
|
|
4598
|
+
[polygon.id]: polygon,
|
|
4599
|
+
[unichain.id]: unichain
|
|
4598
4600
|
};
|
|
4599
4601
|
var DEFAULT_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
4600
4602
|
var EvmChain = class {
|
|
@@ -12374,7 +12376,7 @@ var IntentGateway = class {
|
|
|
12374
12376
|
proof: proofHex,
|
|
12375
12377
|
stateMachine: destStateMachine
|
|
12376
12378
|
};
|
|
12377
|
-
yield { status: "DESTINATION_FINALIZED", data: { proof: destIProof
|
|
12379
|
+
yield { status: "DESTINATION_FINALIZED", data: { proof: destIProof } };
|
|
12378
12380
|
}
|
|
12379
12381
|
const getRequest = storedData?.getRequest ?? (yield { status: "AWAITING_GET_REQUEST" });
|
|
12380
12382
|
if (!getRequest) throw new Error("[Cancel Order]: Get Request not provided");
|
|
@@ -12382,34 +12384,74 @@ var IntentGateway = class {
|
|
|
12382
12384
|
const sourceStatusStream = indexerClient.getRequestStatusStream(commitment);
|
|
12383
12385
|
for await (const statusUpdate of sourceStatusStream) {
|
|
12384
12386
|
if (statusUpdate.status === RequestStatus.SOURCE_FINALIZED) {
|
|
12385
|
-
|
|
12386
|
-
|
|
12387
|
-
|
|
12388
|
-
|
|
12389
|
-
|
|
12390
|
-
|
|
12391
|
-
|
|
12392
|
-
height: sourceHeight,
|
|
12393
|
-
stateMachine: sourceStateMachine,
|
|
12394
|
-
consensusStateId: sourceConsensusStateId,
|
|
12395
|
-
proof
|
|
12387
|
+
let sourceHeight = BigInt(statusUpdate.metadata.blockNumber);
|
|
12388
|
+
let proof;
|
|
12389
|
+
const checkIfAlreadyDelivered = async () => {
|
|
12390
|
+
const currentStatus = await indexerClient.queryGetRequestWithStatus(commitment);
|
|
12391
|
+
return currentStatus?.statuses.some(
|
|
12392
|
+
(status) => status.status === RequestStatus.HYPERBRIDGE_DELIVERED
|
|
12393
|
+
) ?? false;
|
|
12396
12394
|
};
|
|
12397
|
-
|
|
12398
|
-
|
|
12399
|
-
|
|
12400
|
-
|
|
12401
|
-
|
|
12402
|
-
|
|
12403
|
-
|
|
12404
|
-
|
|
12405
|
-
|
|
12406
|
-
|
|
12407
|
-
|
|
12408
|
-
|
|
12409
|
-
|
|
12395
|
+
while (true) {
|
|
12396
|
+
try {
|
|
12397
|
+
proof = await this.source.queryProof(
|
|
12398
|
+
{ Requests: [commitment] },
|
|
12399
|
+
hyperbridgeConfig.stateMachineId,
|
|
12400
|
+
sourceHeight
|
|
12401
|
+
);
|
|
12402
|
+
break;
|
|
12403
|
+
} catch {
|
|
12404
|
+
const failedHeight = sourceHeight;
|
|
12405
|
+
while (sourceHeight <= failedHeight) {
|
|
12406
|
+
if (await checkIfAlreadyDelivered()) {
|
|
12407
|
+
break;
|
|
12408
|
+
}
|
|
12409
|
+
const nextHeight = await retryPromise(
|
|
12410
|
+
() => hyperbridge.latestStateMachineHeight({
|
|
12411
|
+
stateId: parseStateMachineId(sourceStateMachine).stateId,
|
|
12412
|
+
consensusStateId: sourceConsensusStateId
|
|
12413
|
+
}),
|
|
12414
|
+
{
|
|
12415
|
+
maxRetries: 5,
|
|
12416
|
+
backoffMs: 5e3,
|
|
12417
|
+
logMessage: "Failed to fetch latest state machine height (post-source-proof failure)"
|
|
12418
|
+
}
|
|
12419
|
+
);
|
|
12420
|
+
if (nextHeight <= failedHeight) {
|
|
12421
|
+
await sleep(1e4);
|
|
12422
|
+
continue;
|
|
12423
|
+
}
|
|
12424
|
+
sourceHeight = nextHeight;
|
|
12425
|
+
}
|
|
12426
|
+
if (await checkIfAlreadyDelivered()) {
|
|
12427
|
+
break;
|
|
12428
|
+
}
|
|
12410
12429
|
}
|
|
12411
|
-
}
|
|
12412
|
-
|
|
12430
|
+
}
|
|
12431
|
+
if (proof) {
|
|
12432
|
+
const sourceIProof = {
|
|
12433
|
+
height: sourceHeight,
|
|
12434
|
+
stateMachine: sourceStateMachine,
|
|
12435
|
+
consensusStateId: sourceConsensusStateId,
|
|
12436
|
+
proof
|
|
12437
|
+
};
|
|
12438
|
+
yield { status: "SOURCE_PROOF_RECEIVED", data: sourceIProof };
|
|
12439
|
+
const getRequestMessage = {
|
|
12440
|
+
kind: "GetRequest",
|
|
12441
|
+
requests: [getRequest],
|
|
12442
|
+
source: sourceIProof,
|
|
12443
|
+
response: destIProof,
|
|
12444
|
+
signer: pad("0x")
|
|
12445
|
+
};
|
|
12446
|
+
await waitForChallengePeriod(hyperbridge, {
|
|
12447
|
+
height: sourceHeight,
|
|
12448
|
+
id: {
|
|
12449
|
+
stateId: parseStateMachineId(sourceStateMachine).stateId,
|
|
12450
|
+
consensusStateId: sourceConsensusStateId
|
|
12451
|
+
}
|
|
12452
|
+
});
|
|
12453
|
+
await this.submitAndConfirmReceipt(hyperbridge, commitment, getRequestMessage);
|
|
12454
|
+
}
|
|
12413
12455
|
}
|
|
12414
12456
|
yield statusUpdate;
|
|
12415
12457
|
}
|