Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardocustodio committed Feb 27, 2025
1 parent c2b2bfe commit b177b26
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 14 deletions.
11 changes: 7 additions & 4 deletions src/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@ const commonEvents: string[] = [
]

const ignoreEvents: string[] = [
events.multiTokens.nextCollectionIdUpdated.name,
events.multiTokens.migrationStep.name,
events.multiTokens.tokenAccountDepositUpdated.name,
events.claims.ethereumBlocksProcessed.name,
events.fuelTanks.callDispatched.name,
events.fuelTanks.dispatchFailed.name,
events.fuelTanks.migrationStep.name,
events.claims.ethereumBlocksProcessed.name,
events.marketplace.migrationStep.name,
events.multiTokens.nextCollectionIdUpdated.name,
events.multiTokens.migrationStep.name,
events.multiTokens.tokenAccountDepositUpdated.name,
events.polkadotXcm.versionNotifyStarted.name,
events.polkadotXcm.feesPaid.name,
events.polkadotXcm.sent.name,
]

const eventItems: string[] = [
Expand Down
51 changes: 41 additions & 10 deletions src/processors/multi-tokens/token-created.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { throwError } from '../../utils/errors'
import { Collection, Event as EventModel, NativeTokenMetadata, Token } from '../../model'
import { BlockHeader, CommonContext, EventItem } from '../../contexts'
import * as mappings from './../../mappings'
import { DefaultMintParams_CreateToken } from '../../mappings/common/types'

export async function tokenCreated(
ctx: CommonContext,
Expand Down Expand Up @@ -36,9 +35,41 @@ export async function tokenCreated(
}

const call = mappings.multiTokens.utils.anyMint(item.call, event.collectionId, event.tokenId)
const params = call.params as DefaultMintParams_CreateToken
const minBalance = params.sufficiency?.__kind === 'Sufficient' ? params.sufficiency.minimumBalance : 1n
const unitPrice = params.sufficiency?.__kind === 'Insufficient' ? (params.sufficiency.unitPrice ?? 1n) : 1n

// TODO: This needs to be refactored
let minBalance = 1n
let unitPrice = 1n
let listingForbidden = false
let accountDepositCount = 0
let anyoneCanInfuse = false
let nativeMetadata = null
let infusion = 0n

if ('sufficiency' in call.params) {
minBalance = call.params.sufficiency?.__kind === 'Sufficient' ? call.params.sufficiency.minimumBalance : 1n
unitPrice =
call.params.sufficiency?.__kind === 'Insufficient' ? (call.params.sufficiency.unitPrice ?? 1n) : 1n
}

if ('listingForbidden' in call.params) {
listingForbidden = call.params.listingForbidden
}

if ('accountDepositCount' in call.params) {
accountDepositCount = call.params.accountDepositCount ?? 0
}

if ('anyoneCanInfuse' in call.params) {
anyoneCanInfuse = call.params.anyoneCanInfuse === undefined ? false : call.params.anyoneCanInfuse
}

if ('metadata' in call.params) {
nativeMetadata = call.params.metadata !== undefined ? new NativeTokenMetadata(call.params.metadata) : null
}

if ('infusion' in call.params) {
infusion = call.params.infusion ?? 0n
}

const token = new Token({
id: `${event.collectionId}-${event.tokenId}`,
Expand All @@ -50,17 +81,17 @@ export async function tokenCreated(
// TODO: Fix this
freezeState: null, // params.freezeState != undefined ? FreezeState[params.freezeState.__kind] : null,
minimumBalance: minBalance,
unitPrice: unitPrice,
unitPrice,
mintDeposit: 0n, // TODO: Fixed for now
attributeCount: 0,
collection,
metadata: null,
nonFungible: false,
listingForbidden: params.listingForbidden,
accountDepositCount: params.accountDepositCount ?? 0,
anyoneCanInfuse: params.anyoneCanInfuse ?? false,
nativeMetadata: params.metadata !== undefined ? new NativeTokenMetadata(params.metadata) : null,
infusion: params.infusion ?? 0n,
listingForbidden,
accountDepositCount,
anyoneCanInfuse,
nativeMetadata,
infusion,
createdAt: new Date(block.timestamp ?? 0),
})

Expand Down

0 comments on commit b177b26

Please sign in to comment.