From f126eb309ad7baf68cdbcbc02f8918c3a9ffecaa Mon Sep 17 00:00:00 2001 From: Marc-Aurele Besner <82244926+marc-aurele-besner@users.noreply.github.com> Date: Thu, 1 Aug 2024 10:17:38 -0400 Subject: [PATCH] fix rpc data following domains states changes --- explorer/src/hooks/useConsensusData.ts | 15 ++++++++------- explorer/src/states/consensus.ts | 14 ++++++++------ explorer/src/types/consensus.ts | 8 ++------ 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/explorer/src/hooks/useConsensusData.ts b/explorer/src/hooks/useConsensusData.ts index 241d64cdf..231cbc103 100644 --- a/explorer/src/hooks/useConsensusData.ts +++ b/explorer/src/hooks/useConsensusData.ts @@ -2,7 +2,7 @@ import useWallet from 'hooks/useWallet' import { useCallback } from 'react' import { useConsensusStates } from 'states/consensus' import { - ConfirmedDomainBlock, + ConfirmedDomainExecutionReceipt, DomainRegistry, DomainStakingSummary, PendingStakingOperationCount, @@ -17,7 +17,7 @@ export const useConsensusData = () => { setSystem, setDomainRegistry, setDomainStakingSummary, - setLatestConfirmedDomainBlock, + setLatestConfirmedDomainExecutionReceipt, setNominatorCount, setOperatorIdOwner, setOperators, @@ -41,7 +41,7 @@ export const useConsensusData = () => { // domains domainRegistry, domainStakingSummary, - latestConfirmedDomainBlock, + latestConfirmedDomainExecutionReceipt, nominatorCount, operatorIdOwner, operators, @@ -53,9 +53,10 @@ export const useConsensusData = () => { // system api.rpc.system.chain(), api.rpc.system.name(), + // domains api.query.domains.domainRegistry.entries(), api.query.domains.domainStakingSummary.entries(), - api.query.domains.latestConfirmedDomainBlock.entries(), + api.query.domains.latestConfirmedDomainExecutionReceipt.entries(), api.query.domains.nominatorCount.entries(), api.query.domains.operatorIdOwner.entries(), api.query.domains.operators.entries(), @@ -106,10 +107,10 @@ export const useConsensusData = () => { setDomainStakingSummary( domainStakingSummary.map((domain) => domain[1].toJSON() as DomainStakingSummary), ) - setLatestConfirmedDomainBlock( - latestConfirmedDomainBlock.map((domainBlock) => ({ + setLatestConfirmedDomainExecutionReceipt( + latestConfirmedDomainExecutionReceipt.map((domainBlock) => ({ id: parseInt((domainBlock[0].toHuman() as string[])[0]), - ...(domainBlock[1].toJSON() as Omit), + ...(domainBlock[1].toJSON() as Omit), })), ) setNominatorCount( diff --git a/explorer/src/states/consensus.ts b/explorer/src/states/consensus.ts index 84dc83f86..3dbd37d48 100644 --- a/explorer/src/states/consensus.ts +++ b/explorer/src/states/consensus.ts @@ -1,6 +1,6 @@ import type { Deposit, Withdrawal } from '@autonomys/auto-consensus' import { - ConfirmedDomainBlock, + ConfirmedDomainExecutionReceipt, Domain, DomainRegistry, DomainStakingSummary, @@ -28,7 +28,7 @@ export interface ConsensusDefaultState { // domains domainRegistry: DomainRegistry[] domainStakingSummary: DomainStakingSummary[] - latestConfirmedDomainBlock: ConfirmedDomainBlock[] + latestConfirmedDomainExecutionReceipt: ConfirmedDomainExecutionReceipt[] // latestSubmittedER: LatestSubmittedER[] nominatorCount: NominatorCount[] operatorIdOwner: OperatorIdOwner[] @@ -51,7 +51,9 @@ interface ConsensusState extends ConsensusDefaultState { setSystem: (params: { chain: string; name: string }) => void setDomainRegistry: (domainRegistry: DomainRegistry[]) => void setDomainStakingSummary: (domainStakingSummary: DomainStakingSummary[]) => void - setLatestConfirmedDomainBlock: (latestConfirmedDomainBlock: ConfirmedDomainBlock[]) => void + setLatestConfirmedDomainExecutionReceipt: ( + latestConfirmedDomainExecutionReceipt: ConfirmedDomainExecutionReceipt[], + ) => void setNominatorCount: (nominatorCount: NominatorCount[]) => void setOperatorIdOwner: (operatorIdOwner: OperatorIdOwner[]) => void setOperators: (operators: Operators[]) => void @@ -77,7 +79,7 @@ const initialState: ConsensusDefaultState = { // domains domainRegistry: [], domainStakingSummary: [], - latestConfirmedDomainBlock: [], + latestConfirmedDomainExecutionReceipt: [], // latestSubmittedER: [], nominatorCount: [], operatorIdOwner: [], @@ -104,8 +106,8 @@ export const useConsensusStates = create()( setSystem: (params) => set(() => ({ chain: params.chain, name: params.name })), setDomainRegistry: (domainRegistry) => set(() => ({ domainRegistry })), setDomainStakingSummary: (domainStakingSummary) => set(() => ({ domainStakingSummary })), - setLatestConfirmedDomainBlock: (latestConfirmedDomainBlock) => - set(() => ({ latestConfirmedDomainBlock })), + setLatestConfirmedDomainExecutionReceipt: (latestConfirmedDomainExecutionReceipt) => + set(() => ({ latestConfirmedDomainExecutionReceipt })), setNominatorCount: (nominatorCount) => set(() => ({ nominatorCount })), setOperatorIdOwner: (operatorIdOwner) => set(() => ({ operatorIdOwner })), setOperators: (operators) => set(() => ({ operators })), diff --git a/explorer/src/types/consensus.ts b/explorer/src/types/consensus.ts index f0c8fe1c1..8355738f9 100644 --- a/explorer/src/types/consensus.ts +++ b/explorer/src/types/consensus.ts @@ -56,13 +56,9 @@ export type DomainStakingSummary = { } } -export type ConfirmedDomainBlock = { +export type ConfirmedDomainExecutionReceipt = { id: number - blockNumber: number - blockHash: string - parentBlockReceiptHash: string - stateRoot: string - extrinsicsRoot: string + domainBlockNumber: number } export type NominatorCount = {