From 001bb822c4960ff5a56f6ca4c47abcbd15cc6881 Mon Sep 17 00:00:00 2001 From: Yuanchao Sun Date: Thu, 16 Feb 2023 12:27:54 +0800 Subject: [PATCH] Update polkadot/api to 9.6.2 --- package.json | 4 ++-- src/app.ts | 6 +++--- src/commitments.ts | 7 ++++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index d114b44..cbcfc34 100644 --- a/package.json +++ b/package.json @@ -16,8 +16,8 @@ "author": "", "license": "ISC", "dependencies": { - "@polkadot/api": "7.15.1", - "@polkadot/types": "7.15.1", + "@polkadot/api": "9.6.2", + "@polkadot/types": "9.6.2", "chalk": "^4.1.1", "db-migrate": "^0.11.13", "db-migrate-sqlite3": "^0.4.0", diff --git a/src/app.ts b/src/app.ts index d5648b3..19901f9 100644 --- a/src/app.ts +++ b/src/app.ts @@ -47,7 +47,7 @@ const BLOCK_LOG_SIZE = 100; async function start() { await initDb(); const account = await initNearRpc(); - const wsProvider = new WsProvider2(appchainSetting.wsRpcEndpoint); + const wsProvider = new WsProvider2(appchainSetting.wsRpcEndpoint, 300 * 1000, undefined, 180 * 1000); const exitTimer = setTimeout(() => { console.error("init polkadotjs expired: always pending"); @@ -298,8 +298,8 @@ async function handleSignedCommitment( console.log("blockNumber======", blockNumber.toNumber()) logJSON("currBlockHash", currBlockHash); - const rawMmrProofWrapper = await appchain.rpc.mmr.generateProof( - Number(decodedSignedCommitment.commitment.blockNumber) - 1, + const rawMmrProofWrapper = await appchain.rpc.mmr.generateBatchProof( + [Number(decodedSignedCommitment.commitment.blockNumber) - 1], currBlockHash ); logJSON("rawMmrProofWrapper", rawMmrProofWrapper.toJSON()); diff --git a/src/commitments.ts b/src/commitments.ts index f2e53ae..618a0b3 100644 --- a/src/commitments.ts +++ b/src/commitments.ts @@ -81,8 +81,9 @@ async function handleCommitment(commitment: Commitment, appchain: ApiPromise) { appchain, commitment.commitment ); + console.log("encoded_messages: ", encoded_messages); const decoded_messages: any = decodeMessages(encoded_messages); - console.log("decoded_messages", util.inspect(decoded_messages.toJSON(), { showHidden: false, depth: null, colors: true })); + console.log("decoded_messages: ", util.inspect(decoded_messages.toString(), { showHidden: false, depth: null, colors: true })); let rawProof: MmrLeafProof | undefined = undefined; let messageProofWithState: MessageProofWithLightClientState | undefined = undefined; @@ -116,8 +117,8 @@ async function handleCommitment(commitment: Commitment, appchain: ApiPromise) { const mmrRootBlockHash = await appchain.rpc.chain.getBlockHash( decodedSignedCommitment.commitment.blockNumber ); - rawProof = await appchain.rpc.mmr.generateProof( - commitment.height, + rawProof = await appchain.rpc.mmr.generateBatchProof( + [commitment.height], mmrRootBlockHash ); logJSON("rawProof", rawProof);