Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump(deps) to matrix v1000 #726

Merged
merged 1 commit into from
Nov 30, 2023
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,7 @@ type FuelTankRuleSet @entity {

#for ease
isPermittedExtrinsicsEmpty: Boolean!
isPermittedExtrinsicsNull: Boolean!

whitelistedCallers: [String!]
whitelistedCollections: [String]
Expand Down
4 changes: 4 additions & 0 deletions src/mappings/fuelTanks/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ export function getTankDataFromCall(ctx: CommonContext, call: Call) {
data = new FuelTanksDispatchAndTouchCall(ctx, call)
}

if (data.isMatrixEnjinV1000) {
return data.asMatrixEnjinV1000
}

if (data.isMatrixEnjinV603) {
return data.asMatrixEnjinV603
}
Expand Down
4 changes: 4 additions & 0 deletions src/mappings/fuelTanks/events/accountAdded.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import { getOrCreateAccount } from '../../util/entities'
function getEventData(ctx: CommonContext, event: Event) {
const data = new FuelTanksAccountAddedEvent(ctx, event)

if (data.isMatrixEnjinV1000) {
return data.asMatrixEnjinV1000
}

if (data.isMatrixEnjinV603) {
return data.asMatrixEnjinV603
}
Expand Down
4 changes: 4 additions & 0 deletions src/mappings/fuelTanks/events/accountRuleDataRemoved.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import { CommonContext } from '../../types/contexts'
function getEventData(ctx: CommonContext, event: Event) {
const data = new FuelTanksAccountRuleDataRemovedEvent(ctx, event)

if (data.isMatrixEnjinV1000) {
return data.asMatrixEnjinV1000
}

if (data.isMatrixEnjinV603) {
return data.asMatrixEnjinV603
}
Expand Down
4 changes: 4 additions & 0 deletions src/mappings/fuelTanks/events/fuelTankCreated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ function getCallData(ctx: CommonContext, call: Call) {
}
}

if (data.isMatrixEnjinV1000) {
return data.asMatrixEnjinV1000
}

if (data.isMatrixEnjinV603) {
return data.asMatrixEnjinV603
}
Expand Down
5 changes: 5 additions & 0 deletions src/mappings/fuelTanks/events/ruleSetInserted.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ function getEventData(ctx: CommonContext, event: Event) {
function getCallData(ctx: CommonContext, call: Call) {
const data = new FuelTanksInsertRuleSetCall(ctx, call)

if (data.isMatrixEnjinV1000) {
return data.asMatrixEnjinV1000
}

if (data.isMatrixEnjinV603) {
return data.asMatrixEnjinV603
}

if (data.isV1000) {
return data.asV1000
}
Expand Down
4 changes: 2 additions & 2 deletions src/mappings/multiTokens/events/claim_tokens_completed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { Sns } from '../../../common/sns'
function getEventData(ctx: CommonContext, event: Event) {
const data = new MultiTokensClaimTokensCompletedEvent(ctx, event)

if (data.isV1000) {
return data.asV1000
if (data.isMatrixEnjinV1000) {
return data.asMatrixEnjinV1000
}
throw new UnknownVersionError(data.constructor.name)
}
Expand Down
4 changes: 2 additions & 2 deletions src/mappings/multiTokens/events/claim_tokens_initiated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { Sns } from '../../../common/sns'
function getEventData(ctx: CommonContext, event: Event) {
const data = new MultiTokensClaimTokensInitiatedEvent(ctx, event)

if (data.isV1000) {
return data.asV1000
if (data.isMatrixEnjinV1000) {
return data.asMatrixEnjinV1000
}
throw new UnknownVersionError(data.constructor.name)
}
Expand Down
36 changes: 28 additions & 8 deletions src/mappings/multiTokens/events/collection_created.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ async function getCallData(ctx: CommonContext, call: Call) {
}

if (
data.isV1000 &&
data.asV1000.call.__kind === 'MultiTokens' &&
data.asV1000.call.value.__kind === 'create_collection'
data.isMatrixEnjinV1000 &&
data.asMatrixEnjinV1000.call.__kind === 'MultiTokens' &&
data.asMatrixEnjinV1000.call.value.__kind === 'create_collection'
) {
const { descriptor } = data.asV1000.call.value
const { descriptor } = data.asMatrixEnjinV1000.call.value
const { maxTokenCount, maxTokenSupply, forceSingleMint } = descriptor.policy.mint
const royalty = descriptor.policy.market?.royalty
const market = royalty ? await getMarket(ctx, royalty) : null
Expand Down Expand Up @@ -130,17 +130,37 @@ async function getCallData(ctx: CommonContext, call: Call) {
}
}

if (
data.isV1000 &&
data.asV1000.call.__kind === 'MultiTokens' &&
data.asV1000.call.value.__kind === 'create_collection'
) {
const { descriptor } = data.asV1000.call.value
const { maxTokenCount, maxTokenSupply, forceSingleMint } = descriptor.policy.mint
const royalty = descriptor.policy.market?.royalty
const market = royalty ? await getMarket(ctx, royalty) : null
const { explicitRoyaltyCurrencies } = descriptor

return {
maxTokenCount,
maxTokenSupply,
forceSingleMint,
market,
explicitRoyaltyCurrencies,
}
}

throw new UnknownVersionError(data.constructor.name)
}

if (call.name === 'MultiTokens.force_create_ethereum_collection') {
const data = new MultiTokensForceCreateEthereumCollectionCall(ctx, call)

if (data.isV1000) {
const { maxTokenCount, maxTokenSupply, forceSingleMint } = data.asV1000.descriptor.policy.mint
const royalty = data.asV1000.descriptor.policy.market?.royalty
if (data.isMatrixEnjinV1000) {
const { maxTokenCount, maxTokenSupply, forceSingleMint } = data.asMatrixEnjinV1000.descriptor.policy.mint
const royalty = data.asMatrixEnjinV1000.descriptor.policy.market?.royalty
const market = royalty ? await getMarket(ctx, royalty) : null
const { explicitRoyaltyCurrencies } = data.asV1000.descriptor
const { explicitRoyaltyCurrencies } = data.asMatrixEnjinV1000.descriptor

return {
maxTokenCount,
Expand Down
70 changes: 70 additions & 0 deletions src/mappings/multiTokens/events/token_created.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,39 @@ async function getCallData(ctx: CommonContext, call: Call, event: ReturnType<typ
data = new FuelTanksDispatchAndTouchCall(ctx, call)
}

if (
data.isMatrixEnjinV1000 &&
data.asMatrixEnjinV1000.call.__kind === 'MultiTokens' &&
(data.asMatrixEnjinV1000.call.value.__kind === 'mint' || data.asMatrixEnjinV1000.call.value.__kind === 'force_mint')
) {
const { collectionId } = data.asMatrixEnjinV1000.call.value
const recipient = data.asMatrixEnjinV1000.call.value.recipient.value as Uint8Array
const params = data.asMatrixEnjinV1000.call.value.params as DefaultMintParamsCreateToken_v500
const cap = params.cap ? getCapType(params.cap) : null
const behavior = params.behavior ? await getBehavior(ctx, params.behavior) : null
const freezeState = params.freezeState ? getFreezeState(params.freezeState) : null
let unitPrice: bigint | null = 10_000_000_000_000_000n
let minimumBalance = 1n

if (params.sufficiency.__kind === 'Sufficient') {
minimumBalance = (params.sufficiency as SufficiencyParam_Sufficient).minimumBalance
unitPrice = null
}

return {
recipient,
collectionId,
tokenId: params.tokenId,
initialSupply: params.initialSupply,
minimumBalance,
unitPrice,
cap,
behavior,
freezeState,
listingForbidden: params.listingForbidden ?? false,
}
}

if (
data.isMatrixEnjinV603 &&
data.asMatrixEnjinV603.call.__kind === 'MultiTokens' &&
Expand Down Expand Up @@ -404,6 +437,43 @@ async function getCallData(ctx: CommonContext, call: Call, event: ReturnType<typ
}
}

if (
data.isMatrixEnjinV1000 &&
data.asMatrixEnjinV1000.call.__kind === 'MultiTokens' &&
data.asMatrixEnjinV1000.call.value.__kind === 'batch_mint'
) {
const { collectionId, recipients } = data.asMatrixEnjinV1000.call.value
const recipientCall = recipients.find((r) => r.params.tokenId === event.tokenId && r.params.__kind === 'CreateToken')

if (recipientCall) {
const recipient = recipientCall.accountId
const params = recipientCall.params as DefaultMintParamsCreateToken_Enjin_v603
const cap = params.cap ? getCapType(params.cap) : null
const behavior = params.behavior ? await getBehavior(ctx, params.behavior) : null
const freezeState = params.freezeState ? getFreezeState(params.freezeState) : null
let unitPrice: bigint | null = 10_000_000_000_000_000n
let minimumBalance = 1n

if (params.sufficiency.__kind === 'Sufficient') {
minimumBalance = (params.sufficiency as SufficiencyParam_Sufficient).minimumBalance
unitPrice = null
}

return {
recipient,
collectionId,
tokenId: params.tokenId,
initialSupply: params.initialSupply,
minimumBalance,
unitPrice,
cap,
behavior,
freezeState,
listingForbidden: params.listingForbidden ?? false,
}
}
}

if (
data.isMatrixEnjinV603 &&
data.asMatrixEnjinV603.call.__kind === 'MultiTokens' &&
Expand Down
18 changes: 14 additions & 4 deletions src/mappings/xcm/events/attempted.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ async function getCallData(ctx: CommonContext, call: Call) {
} else {
data = new FuelTanksDispatchAndTouchCall(ctx, call)
}

if (
data.isV1000 &&
data.asV1000.call.__kind === 'PolkadotXcm' &&
(data.asV1000.call.value.__kind === 'teleport_assets' || data.asV1000.call.value.__kind === 'limited_teleport_assets')
data.isMatrixEnjinV1000 &&
data.asMatrixEnjinV1000.call.__kind === 'PolkadotXcm' &&
(data.asMatrixEnjinV1000.call.value.__kind === 'teleport_assets' ||
data.asMatrixEnjinV1000.call.value.__kind === 'limited_teleport_assets')
) {
return data.asV1000.call.value
return data.asMatrixEnjinV1000.call.value
}

if (
Expand All @@ -52,6 +54,14 @@ async function getCallData(ctx: CommonContext, call: Call) {
return data.asMatrixEnjinV603.call.value
}

if (
data.isV1000 &&
data.asV1000.call.__kind === 'PolkadotXcm' &&
(data.asV1000.call.value.__kind === 'teleport_assets' || data.asV1000.call.value.__kind === 'limited_teleport_assets')
) {
return data.asV1000.call.value
}

throw new UnknownVersionError(data.constructor.name)
} else if (call.name === 'PolkadotXcm.limited_reserve_transfer_assets') {
const data = new PolkadotXcmLimitedReserveTransferAssetsCall(ctx, call)
Expand Down
Loading