Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
"schema:hasura": "pnpm exec squid-hasura-configuration apply",
"schema:regenerate": "pnpm exec squid-hasura-configuration regenerate",
"metadata:init": "pnpm run metadata:fetch && pnpm run metadata:typegen",
"metadata:typegen": "pnpm excec metadata:merge && pnpm exec squid-substrate-typegen typegen/typegen.json",
"metadata:merge": "rm -rf typegen/chain-specs.jsonl && cat typegen/enjin-matrixchain.jsonl typegen/canary-matrixchain.jsonl typegen/enjin-relaychain.jsonl typegen/canary-relaychain.jsonl > typegen/chain-specs.jsonl",
"metadata:typegen": "pnpm run metadata:merge && pnpm exec squid-substrate-typegen typegen/typegen.json",
"metadata:merge": "rm -rf typegen/chain-specs.jsonl && cat typegen/enjin-matrixchain.jsonl typegen/canary-matrixchain.jsonl typegen/enjin-relaychain.jsonl typegen/canary-relaychain.jsonl typegen/internal-matrixchain.jsonl typegen/internal-relaychain.jsonl > typegen/chain-specs.jsonl",
"metadata:fetch": "pnpm run metadata:matrix && pnpm run metadata:relay",
"metadata:matrix": "pnpm run metadata:enjin-matrix && pnpm run metadata:canary-matrix",
"metadata:relay": "pnpm run metadata:enjin-relay && pnpm run metadata:canary-relay",
Expand Down
5 changes: 3 additions & 2 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1315,8 +1315,9 @@ type NominationPoolsRewardPaid {
era: Int!
validatorStash: Account!
reward: BigInt!
bonus: BigInt!
bonus: BigInt # Removed on v1060
poolId: String!
commission: CommissionPayment # Added on v1060
}

type NominationPoolsPoolSlashed {
Expand Down Expand Up @@ -1558,7 +1559,7 @@ type EraReward @entity {
changeInRate: BigInt!
active: BigInt!
commission: CommissionPayment
bonus: BigInt!
bonus: BigInt
reinvested: BigInt!
apy: Float!
averageApy: Float!
Expand Down
23 changes: 17 additions & 6 deletions src/model/generated/_nominationPoolsRewardPaid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ import assert from "assert"
import * as marshal from "./marshal"
import {NominationPool} from "./nominationPool.model"
import {Account} from "./account.model"
import {CommissionPayment} from "./_commissionPayment"

export class NominationPoolsRewardPaid {
public readonly isTypeOf = 'NominationPoolsRewardPaid'
private _pool!: string
private _era!: number
private _validatorStash!: string
private _reward!: bigint
private _bonus!: bigint
private _bonus!: bigint | undefined | null
private _poolId!: string
private _commission!: CommissionPayment | undefined | null

constructor(props?: Partial<Omit<NominationPoolsRewardPaid, 'toJSON'>>, json?: any) {
Object.assign(this, props)
Expand All @@ -19,8 +21,9 @@ export class NominationPoolsRewardPaid {
this._era = marshal.int.fromJSON(json.era)
this._validatorStash = marshal.string.fromJSON(json.validatorStash)
this._reward = marshal.bigint.fromJSON(json.reward)
this._bonus = marshal.bigint.fromJSON(json.bonus)
this._bonus = json.bonus == null ? undefined : marshal.bigint.fromJSON(json.bonus)
this._poolId = marshal.string.fromJSON(json.poolId)
this._commission = json.commission == null ? undefined : new CommissionPayment(undefined, json.commission)
}
}

Expand Down Expand Up @@ -60,12 +63,11 @@ export class NominationPoolsRewardPaid {
this._reward = value
}

get bonus(): bigint {
assert(this._bonus != null, 'uninitialized access')
get bonus(): bigint | undefined | null {
return this._bonus
}

set bonus(value: bigint) {
set bonus(value: bigint | undefined | null) {
this._bonus = value
}

Expand All @@ -78,15 +80,24 @@ export class NominationPoolsRewardPaid {
this._poolId = value
}

get commission(): CommissionPayment | undefined | null {
return this._commission
}

set commission(value: CommissionPayment | undefined | null) {
this._commission = value
}

toJSON(): object {
return {
isTypeOf: this.isTypeOf,
pool: this.pool,
era: this.era,
validatorStash: this.validatorStash,
reward: marshal.bigint.toJSON(this.reward),
bonus: marshal.bigint.toJSON(this.bonus),
bonus: this.bonus == null ? undefined : marshal.bigint.toJSON(this.bonus),
poolId: this.poolId,
commission: this.commission == null ? undefined : this.commission.toJSON(),
}
}
}
4 changes: 2 additions & 2 deletions src/model/generated/eraReward.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export class EraReward {
@Column_("jsonb", {transformer: {to: obj => obj == null ? undefined : obj.toJSON(), from: obj => obj == null ? undefined : new CommissionPayment(undefined, obj)}, nullable: true})
commission!: CommissionPayment | undefined | null

@BigIntColumn_({nullable: false})
bonus!: bigint
@BigIntColumn_({nullable: true})
bonus!: bigint | undefined | null

@BigIntColumn_({nullable: false})
reinvested!: bigint
Expand Down
2 changes: 1 addition & 1 deletion src/model/generated/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export * from "./_validatorPrefsSet"
export * from "./_nominationPoolsWithdrawn"
export * from "./_nominationPoolsEraRewardsProcessed"
export * from "./_nominationPoolsRewardPaid"
export * from "./_commissionPayment"
export * from "./_nominationPoolsPoolSlashed"
export * from "./_nominationPoolsNominated"
export * from "./_nominationPoolsCreated"
Expand Down Expand Up @@ -189,7 +190,6 @@ export * from "./_poolSlash"
export * from "./earlyBirdShares.model"
export * from "./era.model"
export * from "./eraReward.model"
export * from "./_commissionPayment"
export * from "./stakeExchangeOffer.model"
export * from "./_stakeExchangeOfferState"
export * from "./poolsOffers.model"
Expand Down
12 changes: 11 additions & 1 deletion src/pallet/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ export interface ShouldMutate_AccountId32_SomeMutation {
}

export type PoolMutation = {
duration?: number
duration?: number // Removed on v1060
newCommission?: ShouldMutate_Perbill
maxCommission?: Perbill
changeRate?: CommissionChangeRate
Expand Down Expand Up @@ -458,6 +458,14 @@ type HoldReason_CollatorStaking = {
__kind: 'CollatorStaking'
}

type HoldReason_Council = {
__kind: 'Council'
}

type HoldReason_TechnicalCommittee = {
__kind: 'TechnicalCommittee'
}

export type RuntimeHoldReason =
| HoldReason_FuelTanks
| HoldReason_Marketplace
Expand All @@ -466,6 +474,8 @@ export type RuntimeHoldReason =
| HoldReason_SafeMode
| HoldReason_StakeExchange
| HoldReason_CollatorStaking
| HoldReason_Council // Added on matrixV1030
| HoldReason_TechnicalCommittee // Added on matrixV1030

type Root = {
__kind: 'Root'
Expand Down
8 changes: 8 additions & 0 deletions src/pallet/multi-tokens/storage/token-accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ export async function tokenAccounts(
() => multiTokens.tokenAccounts.matrixEnjinV603.is(block),
() => getTokenAccounts(multiTokens.tokenAccounts.matrixEnjinV603)
)
.when(
() => multiTokens.tokenAccounts.matrixV1030.is(block),
() => getTokenAccounts(multiTokens.tokenAccounts.matrixV1030)
)
.when(
() => multiTokens.tokenAccounts.matrixV1020.is(block),
() => getTokenAccounts(multiTokens.tokenAccounts.matrixV1020)
Expand All @@ -108,6 +112,10 @@ export async function tokenAccounts(
() => multiTokens.tokenAccounts.enjinV100.is(block),
() => getTokenAccounts(multiTokens.tokenAccounts.enjinV100)
)
.when(
() => multiTokens.tokenAccounts.v1060.is(block),
() => getTokenAccounts(multiTokens.tokenAccounts.v1060)
)
.when(
() => multiTokens.tokenAccounts.v1050.is(block),
() => getTokenAccounts(multiTokens.tokenAccounts.v1050)
Expand Down
2 changes: 1 addition & 1 deletion src/pallet/multi-tokens/storage/types/token-accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export type TokenAccount = {
lockedBalance: bigint
namedReserves?: [Bytes, bigint][] // Removed on v1050
holds?: TokenAccountReserve[] // Added on v1050
locks: [Bytes, bigint][]
locks?: [Bytes, bigint][] // removed on v1060
approvals: [AccountId32, Approval][]
isFrozen: boolean
deposit?: Deposit // Added on v1030
Expand Down
4 changes: 4 additions & 0 deletions src/pallet/nomination-pools/calls/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ export const create = withDispatchCheck((call: CallItem): CreatePool => {
() => calls.nominationPools.create.v101.is(call),
() => calls.nominationPools.create.v101.decode(call)
)
.when(
() => calls.nominationPools.create.v1060.is(call),
() => calls.nominationPools.create.v1060.decode(call)
)
.otherwise(() => {
throw new UnsupportedCallError(call)
})
Expand Down
2 changes: 1 addition & 1 deletion src/pallet/nomination-pools/calls/types/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export type CreatePool = {
tokenId: bigint
deposit: bigint
capacity: bigint
duration: number
duration?: number // Removed on v1060
root?: MultiAddress // Removed on v102 => Removed on v110
admin?: MultiAddress // Added on v102 => Removed on v110
nominator?: MultiAddress // Removed on v110
Expand Down
4 changes: 4 additions & 0 deletions src/pallet/nomination-pools/events/pool-mutated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ export function poolMutated(event: EventItem): PoolMutated {
() => nominationPools.poolMutated.v102.is(event),
() => nominationPools.poolMutated.v102.decode(event)
)
.when(
() => nominationPools.poolMutated.v1060.is(event),
() => nominationPools.poolMutated.v1060.decode(event)
)
.otherwise(() => {
throw new UnsupportedEventError(event)
})
Expand Down
27 changes: 27 additions & 0 deletions src/pallet/nomination-pools/events/reward-paid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { EventItem } from '~/contexts'
import { UnsupportedEventError } from '~/util/errors'
import { match } from 'ts-pattern'
import { RewardPaid } from '~/pallet/nomination-pools/events/types'
import { CommissionPayment, Event as EventModel, Extrinsic, NominationPoolsRewardPaid } from '~/model'

export function rewardPaid(event: EventItem): RewardPaid {
return match(event)
Expand All @@ -11,7 +12,33 @@ export function rewardPaid(event: EventItem): RewardPaid {
() => nominationPools.rewardPaid.enjinV100.is(event),
() => nominationPools.rewardPaid.enjinV100.decode(event)
)
.when(
() => nominationPools.rewardPaid.v1060.is(event),
() => nominationPools.rewardPaid.v1060.decode(event)
)
.otherwise(() => {
throw new UnsupportedEventError(event)
})
}

export function rewardPaidEventModel(item: EventItem, data: RewardPaid, validatorStash: string): EventModel {
return new EventModel({
id: item.id,
name: NominationPoolsRewardPaid.name,
extrinsic: item.extrinsic?.id ? new Extrinsic({ id: item.extrinsic.id }) : null,
data: new NominationPoolsRewardPaid({
pool: data.poolId.toString(),
poolId: data.poolId.toString(),
era: data.era,
reward: data.reward,
bonus: data.bonus ? data.bonus : undefined,
commission: data.commission
? new CommissionPayment({
beneficiary: data.commission.beneficiary,
amount: data.commission.amount,
})
: null,
validatorStash,
}),
})
}
5 changes: 3 additions & 2 deletions src/pallet/nomination-pools/events/types/reward-paid.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { AccountId32 } from '~/pallet/common/types'
import { AccountId32, CommissionPayment } from '~/pallet/common/types'

export type RewardPaid = {
poolId: number
era: number
validatorStash: AccountId32
reward: bigint
bonus: bigint
bonus?: bigint // Removed on v1060
commission?: CommissionPayment // Added on v1060
}
8 changes: 7 additions & 1 deletion src/pallet/nomination-pools/processors/created.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ export async function created(ctx: CommonContext, block: Block, item: EventItem)

const currentEraInfo = await getCurrentEra(ctx, block)

let duration = 300

if (callData.duration) {
duration = callData.duration // 300 era is the default duration // changed in v1060
}

if (!currentEraInfo) {
throw new Error('Active era info is not provided')
}
Expand Down Expand Up @@ -58,7 +64,7 @@ export async function created(ctx: CommonContext, block: Block, item: EventItem)
}),
bonusCycle: new BonusCycle({
start: currentEraInfo,
end: currentEraInfo + callData.duration,
end: currentEraInfo + duration,
}),
apy: 0,
rate: 1000_000_000_000_000_000n,
Expand Down
Loading
Loading