Skip to content

Commit

Permalink
Merge pull request #1 from mnaamani/patch-nara-freeze-pallet-proposal
Browse files Browse the repository at this point in the history
Patch to fix query-node and integration tests build
  • Loading branch information
freakstatic authored Nov 2, 2023
2 parents 16f6d89 + 62f99f8 commit 4b46c64
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
16 changes: 12 additions & 4 deletions query-node/mappings/src/proposals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
eslint-disable @typescript-eslint/naming-convention
*/
import { SubstrateEvent, DatabaseManager, EventContext, StoreContext } from '@joystream/hydra-common'
import { PalletProposalsCodexProposalDetails as RuntimeProposalDetails } from '@polkadot/types/lookup'
import BN from 'bn.js'
import {
Proposal,
Expand Down Expand Up @@ -70,12 +69,16 @@ import {
} from './common'
import {
ProposalsCodex_ProposalCreatedEvent_V1001 as ProposalCreatedEvent_V1001,
ProposalsCodex_ProposalCreatedEvent_V2002 as ProposalCreatedEvent_V2002,
ProposalsEngine_ProposalCancelledEvent_V1001 as ProposalCancelledEvent_V1001,
ProposalsEngine_ProposalDecisionMadeEvent_V1001 as ProposalDecisionMadeEvent_V1001,
ProposalsEngine_ProposalExecutedEvent_V1001 as ProposalExecutedEvent_V1001,
ProposalsEngine_ProposalStatusUpdatedEvent_V1001 as ProposalStatusUpdatedEvent_V1001,
ProposalsEngine_VotedEvent_V1001 as ProposalVotedEvent_V1001,
} from '../generated/types'
import { PalletProposalsCodexProposalDetails as RuntimeProposalDetails_V1001 } from '../generated/types/1001/types-lookup'
import { PalletProposalsCodexProposalDetails as RuntimeProposalDetails_V2002 } from '../generated/types/2002/types-lookup'

import { createWorkingGroupOpeningMetadata } from './workingGroups'
import { blake2AsHex } from '@polkadot/util-crypto'
import { Bytes } from '@polkadot/types'
Expand Down Expand Up @@ -105,7 +108,7 @@ async function getOrCreateRuntimeWasmBytecode(store: DatabaseManager, bytecode:
async function parseProposalDetails(
event: SubstrateEvent,
store: DatabaseManager,
proposalDetails: RuntimeProposalDetails
proposalDetails: RuntimeProposalDetails_V1001 | RuntimeProposalDetails_V2002
): Promise<typeof ProposalDetails> {
const eventTime = new Date(event.blockTimestamp)

Expand Down Expand Up @@ -333,9 +336,14 @@ async function handleRuntimeUpgradeProposalExecution(event: SubstrateEvent, stor
)
}

export async function proposalsCodex_ProposalCreated({ store, event }: EventContext & StoreContext): Promise<void> {
export async function proposalsCodex_ProposalCreated({
store,
event,
block,
}: EventContext & StoreContext): Promise<void> {
const { specVersion } = block.runtimeVersion
const [proposalId, generalProposalParameters, runtimeProposalDetails, proposalThreadId] =
new ProposalCreatedEvent_V1001(event).params
specVersion === 1001 ? new ProposalCreatedEvent_V1001(event).params : new ProposalCreatedEvent_V2002(event).params
const eventTime = new Date(event.blockTimestamp)
const proposalDetails = await parseProposalDetails(event, store, runtimeProposalDetails)

Expand Down
1 change: 1 addition & 0 deletions tests/network-tests/src/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export const proposalTypeToProposalParamsKey = {
'VetoProposal': 'vetoProposalProposalParameters',
'UpdateGlobalNftLimit': 'updateGlobalNftLimitProposalParameters',
'UpdateChannelPayouts': 'updateChannelPayoutsProposalParameters',
'FreezePallet': 'setInvitationCountProposalParameters',
} as const

type ProposalTypeToProposalParamsKeyMap = { [K in ProposalType]: keyof AugmentedConsts<'promise'>['proposalsCodex'] }
Expand Down

0 comments on commit 4b46c64

Please sign in to comment.