From 8205c9aee79f860badac841c8e8afcf562235c67 Mon Sep 17 00:00:00 2001 From: devchenyan Date: Thu, 6 Jun 2024 10:18:02 +0800 Subject: [PATCH 1/2] feat: mistake sync status --- packages/neuron-wallet/src/controllers/sync-api.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/neuron-wallet/src/controllers/sync-api.ts b/packages/neuron-wallet/src/controllers/sync-api.ts index 5207cc6ec4..dae575252d 100644 --- a/packages/neuron-wallet/src/controllers/sync-api.ts +++ b/packages/neuron-wallet/src/controllers/sync-api.ts @@ -108,8 +108,12 @@ export default class SyncApiController { const rpcService = new RpcService(network.remote, network.type) try { const syncState = await rpcService.getSyncState() + let bestKnownBlockNumber = parseInt(syncState.bestKnownBlockNumber, 16) + if (network.chain === 'ckb_dev') { + bestKnownBlockNumber = parseInt(await rpcService.getTipBlockNumber(), 16) + } return { - bestKnownBlockNumber: parseInt(syncState.bestKnownBlockNumber, 16), + bestKnownBlockNumber, bestKnownBlockTimestamp: +syncState.bestKnownBlockTimestamp, } } catch (error) { From 24edf8bca5ddaf58895de26787373a1176b2016d Mon Sep 17 00:00:00 2001 From: devchenyan Date: Fri, 7 Jun 2024 20:47:02 +0800 Subject: [PATCH 2/2] fix: comment --- packages/neuron-wallet/src/controllers/sync-api.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/neuron-wallet/src/controllers/sync-api.ts b/packages/neuron-wallet/src/controllers/sync-api.ts index dae575252d..69b9603f76 100644 --- a/packages/neuron-wallet/src/controllers/sync-api.ts +++ b/packages/neuron-wallet/src/controllers/sync-api.ts @@ -108,12 +108,10 @@ export default class SyncApiController { const rpcService = new RpcService(network.remote, network.type) try { const syncState = await rpcService.getSyncState() - let bestKnownBlockNumber = parseInt(syncState.bestKnownBlockNumber, 16) - if (network.chain === 'ckb_dev') { - bestKnownBlockNumber = parseInt(await rpcService.getTipBlockNumber(), 16) - } + const bestKnownBlockNumber = + network.chain === 'ckb_dev' ? await rpcService.getTipBlockNumber() : syncState.bestKnownBlockNumber return { - bestKnownBlockNumber, + bestKnownBlockNumber: parseInt(bestKnownBlockNumber, 16), bestKnownBlockTimestamp: +syncState.bestKnownBlockTimestamp, } } catch (error) {