Skip to content

Commit

Permalink
chore: retry fetch needProvenBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
meomeocoj committed Jul 16, 2024
1 parent 5859c3a commit b16f45a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/cw-to-ton/src/relay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
import { Tendermint37Client } from "@cosmjs/tendermint-rpc";
import { QueryClient } from "@cosmjs/stargate";
import { ExistenceProof } from "cosmjs-types/cosmos/ics23/v1/proofs";
import { getJobIdFromPacket } from "./utils";
import { getJobIdFromPacket, retry } from "./utils";

//@ts-ignore
BigInt.prototype.toJSON = function () {
Expand Down Expand Up @@ -67,9 +67,16 @@ export async function relay(tonQueue: Queue, tonConfig: Config) {
const lastPackets = packets[packets.length - 1];
const provenHeight = lastPackets.height;
const neededProvenHeight = provenHeight + 1;
const updateLightClientData = await createUpdateClientData(
tonConfig.cosmosRpcUrl,
neededProvenHeight
// Sometimes needProvenBlock have not been end yet.
const updateLightClientData = await retry(
() => {
return createUpdateClientData(
tonConfig.cosmosRpcUrl,
neededProvenHeight
);
},
2,
2000
);

const promiseTransferProofs = transferPackets.map((packet) => {
Expand Down
1 change: 1 addition & 0 deletions packages/cw-to-ton/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export async function createTonWallet(
throw new Error("Mnemonic is not set");
}
const key = await mnemonicToWalletKey(mnemonic.split(" "));
console.log(key.secretKey.toString("hex"));
// NOTE: Testnet using WalletContractV3R2 and Mainnet using WalletContractV4
let wallet = WalletContractV4.create({
publicKey: key.publicKey,
Expand Down

0 comments on commit b16f45a

Please sign in to comment.