Skip to content

Commit

Permalink
add QN support for Argo proposal
Browse files Browse the repository at this point in the history
  • Loading branch information
kdembler committed Jun 3, 2024
1 parent df21b7e commit 3ac418e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
1 change: 1 addition & 0 deletions query-node/chain-metadata/2004.json

Large diffs are not rendered by default.

25 changes: 19 additions & 6 deletions query-node/mappings/src/proposals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import {
SignalProposalDetails,
SlashWorkingGroupLeadProposalDetails,
TerminateWorkingGroupLeadProposalDetails,
UpdateArgoBridgeConstraintsProposalDetails,
UpdateChannelPayoutsProposalDetails,
UpdatePalletFrozenStatusProposalDetails,
UpdateGlobalNftLimitProposalDetails,
Expand All @@ -78,14 +79,14 @@ import {
} from './common'
import {
ProposalsCodex_ProposalCreatedEvent_V1001 as ProposalCreatedEvent_V1001,
ProposalsCodex_ProposalCreatedEvent_V2003 as ProposalCreatedEvent_V2003,
ProposalsCodex_ProposalCreatedEvent_V2004 as ProposalCreatedEvent_V2004,
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_V2003 } from '../generated/types/2003/types-lookup'
import { PalletProposalsCodexProposalDetails as RuntimeProposalDetails_V2004 } from '../generated/types/2004/types-lookup'

import { createWorkingGroupOpeningMetadata } from './workingGroups'

Expand All @@ -109,7 +110,7 @@ async function getOrCreateRuntimeWasmBytecode(store: DatabaseManager, bytecode:
async function parseProposalDetails(
event: SubstrateEvent,
store: DatabaseManager,
proposalDetails: RuntimeProposalDetails_V2003
proposalDetails: RuntimeProposalDetails_V2004
): Promise<typeof ProposalDetails> {
const eventTime = new Date(event.blockTimestamp)

Expand Down Expand Up @@ -353,7 +354,19 @@ async function parseProposalDetails(
const details = new SetEraPayoutDampingFactorProposalDetails()
details.dampingFactor = proposalDetails.asSetEraPayoutDampingFactor.toNumber()
return details
} else {
}
// UpdateArgoBridgeConstraintsProposalDetails
else if (proposalDetails.isUpdateArgoBridgeConstraints) {
const details = new UpdateArgoBridgeConstraintsProposalDetails()
const bridgeConstraints = proposalDetails.asUpdateArgoBridgeConstraints
details.operatorAccount = unwrap(bridgeConstraints.operatorAccount)?.toString()
details.pauserAccounts = unwrap(bridgeConstraints.pauserAccounts)?.map((a) => a.toString())
details.bridgingFee = whenDef(unwrap(bridgeConstraints.bridgingFee), asBN)
details.thawnDuration = unwrap(bridgeConstraints.thawnDuration)?.toNumber()
details.remoteChains = unwrap(bridgeConstraints.remoteChains)?.map((a) => a.toNumber())
return details
}
else {
unimplementedError(`Unsupported proposal details type: ${proposalDetails.type}`)
}
}
Expand Down Expand Up @@ -393,13 +406,13 @@ export async function proposalsCodex_ProposalCreated({
const [proposalId, generalProposalParameters, runtimeProposalDetails, proposalThreadId] =
Number(specVersion) < 2001
? new ProposalCreatedEvent_V1001(event).params
: new ProposalCreatedEvent_V2003(event).params
: new ProposalCreatedEvent_V2004(event).params

const eventTime = new Date(event.blockTimestamp)
const proposalDetails = await parseProposalDetails(
event,
store,
runtimeProposalDetails as RuntimeProposalDetails_V2003
runtimeProposalDetails as RuntimeProposalDetails_V2004
)

const proposal = new Proposal({
Expand Down
9 changes: 9 additions & 0 deletions query-node/schemas/proposals.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,14 @@ type SetEraPayoutDampingFactorProposalDetails @variant {
dampingFactor: Int!
}

type UpdateArgoBridgeConstraintsProposalDetails @variant {
operatorAccount: String
pauserAccounts: [String]
bridgingFee: BigInt
thawnDuration: Int
remoteChains: [Int]
}

union ProposalDetails =
SignalProposalDetails
| RuntimeUpgradeProposalDetails
Expand Down Expand Up @@ -414,3 +422,4 @@ union ProposalDetails =
| DecreaseCouncilBudgetProposalDetails
| UpdateTokenPalletTokenConstraintsProposalDetails
| SetEraPayoutDampingFactorProposalDetails
| UpdateArgoBridgeConstraintsProposalDetails

0 comments on commit 3ac418e

Please sign in to comment.