Skip to content

Commit

Permalink
Add enjin matrix metadata (#601)
Browse files Browse the repository at this point in the history
Add mainnet matrix metadata
  • Loading branch information
leonardocustodio authored Sep 8, 2023
1 parent 0aad5f5 commit 4dcdb8c
Show file tree
Hide file tree
Showing 40 changed files with 23,510 additions and 10,228 deletions.
4 changes: 2 additions & 2 deletions src/mappings/balances/events/transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ interface EventData {
function getEventData(ctx: CommonContext, event: Event): EventData {
const data = new BalancesTransferEvent(ctx, event)

if (data.isEfinityV3014) {
const { from, to, amount } = data.asEfinityV3014
if (data.isMatrixV603) {
const { from, to, amount } = data.asMatrixV603
return { from, to, amount }
}

Expand Down
4 changes: 2 additions & 2 deletions src/mappings/balances/events/withdraw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { CommonContext } from '../../types/contexts'
function getEventData(ctx: CommonContext, event: Event): bigint {
const data = new BalancesWithdrawEvent(ctx, event)

if (data.isEfinityV3014) {
const { amount } = data.asEfinityV3014
if (data.isMatrixV603) {
const { amount } = data.asMatrixV603
return amount
}

Expand Down
44 changes: 22 additions & 22 deletions src/mappings/balances/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ import { fetchAccountsDetail } from '../util/marketplace'
function getDustLostAccount(ctx: CommonContext, event: Event) {
const data = new BalancesDustLostEvent(ctx, event)

if (data.isEfinityV3014) {
return data.asEfinityV3014.account
if (data.isMatrixV603) {
return data.asMatrixV603.account
}
throw new UnknownVersionError(data.constructor.name)
}

function getBalanceSetAccount(ctx: CommonContext, event: Event) {
const data = new BalancesBalanceSetEvent(ctx, event)

if (data.isEfinityV3014) {
return data.asEfinityV3014.who
if (data.isMatrixV603) {
return data.asMatrixV603.who
}
if (data.isV602) {
return data.asV602.who
Expand All @@ -48,71 +48,71 @@ function getBalanceSetAccount(ctx: CommonContext, event: Event) {
function getTransferAccounts(ctx: CommonContext, event: Event): [Uint8Array, Uint8Array] {
const data = new BalancesTransferEvent(ctx, event)

if (data.isEfinityV3014) {
return [data.asEfinityV3014.from, data.asEfinityV3014.to]
if (data.isMatrixV603) {
return [data.asMatrixV603.from, data.asMatrixV603.to]
}
throw new UnknownVersionError(data.constructor.name)
}

function getEndowedAccount(ctx: CommonContext, event: Event) {
const data = new BalancesEndowedEvent(ctx, event)

if (data.isEfinityV3014) {
return data.asEfinityV3014.account
if (data.isMatrixV603) {
return data.asMatrixV603.account
}
throw new UnknownVersionError(data.constructor.name)
}

function getDepositAccount(ctx: CommonContext, event: Event) {
const data = new BalancesDepositEvent(ctx, event)

if (data.isEfinityV3014) {
return data.asEfinityV3014.who
if (data.isMatrixV603) {
return data.asMatrixV603.who
}
throw new UnknownVersionError(data.constructor.name)
}

function getReservedAccount(ctx: CommonContext, event: Event) {
const data = new BalancesReservedEvent(ctx, event)

if (data.isEfinityV3014) {
return data.asEfinityV3014.who
if (data.isMatrixV603) {
return data.asMatrixV603.who
}
throw new UnknownVersionError(data.constructor.name)
}

function getUnreservedAccount(ctx: CommonContext, event: Event) {
const data = new BalancesUnreservedEvent(ctx, event)

if (data.isEfinityV3014) {
return data.asEfinityV3014.who
if (data.isMatrixV603) {
return data.asMatrixV603.who
}
throw new UnknownVersionError(data.constructor.name)
}

function getWithdrawAccount(ctx: CommonContext, event: Event) {
const data = new BalancesWithdrawEvent(ctx, event)

if (data.isEfinityV3014) {
return data.asEfinityV3014.who
if (data.isMatrixV603) {
return data.asMatrixV603.who
}
throw new UnknownVersionError(data.constructor.name)
}

function getSlashedAccount(ctx: CommonContext, event: Event) {
const data = new BalancesSlashedEvent(ctx, event)

if (data.isEfinityV3014) {
return data.asEfinityV3014.who
if (data.isMatrixV603) {
return data.asMatrixV603.who
}
throw new UnknownVersionError(data.constructor.name)
}

function getReserveRepatriatedAccounts(ctx: CommonContext, event: Event): [Uint8Array, Uint8Array] {
const data = new BalancesReserveRepatriatedEvent(ctx, event)

if (data.isEfinityV3014) {
return [data.asEfinityV3014.from, data.asEfinityV3014.to]
if (data.isMatrixV603) {
return [data.asMatrixV603.from, data.asMatrixV603.to]
}
throw new UnknownVersionError(data.constructor.name)
}
Expand All @@ -121,8 +121,8 @@ async function getSystemAccountBalances(ctx: CommonContext, block: SubstrateBloc
const storage = new SystemAccountStorage(ctx, block)
if (!storage.isExists) return undefined

if (storage.isEfinityV3014) {
return storage.asEfinityV3014.getMany(accounts)
if (storage.isMatrixV603) {
return storage.asMatrixV603.getMany(accounts)
}
if (storage.isV602) {
return storage.asV602.getMany(accounts)
Expand Down
4 changes: 2 additions & 2 deletions src/mappings/marketplace/events/auction_finalized.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import { getBestListing } from '../../util/entities'
function getEventData(ctx: CommonContext, event: Event) {
const data = new MarketplaceAuctionFinalizedEvent(ctx, event)

if (data.isEfinityV3014) {
const { listingId, winningBid, protocolFee, royalty } = data.asEfinityV3014
if (data.isMatrixV603) {
const { listingId, winningBid, protocolFee, royalty } = data.asMatrixV603
return { listingId, winningBid, protocolFee, royalty }
}
throw new UnknownVersionError(data.constructor.name)
Expand Down
4 changes: 2 additions & 2 deletions src/mappings/marketplace/events/bid_placed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import { getBestListing, getOrCreateAccount } from '../../util/entities'
function getEventData(ctx: CommonContext, event: Event) {
const data = new MarketplaceBidPlacedEvent(ctx, event)

if (data.isEfinityV3014) {
return data.asEfinityV3014
if (data.isMatrixV603) {
return data.asMatrixV603
}
throw new UnknownVersionError(data.constructor.name)
}
Expand Down
4 changes: 2 additions & 2 deletions src/mappings/marketplace/events/listing_cancelled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import { getBestListing } from '../../util/entities'
function getEventData(ctx: CommonContext, event: Event) {
const data = new MarketplaceListingCancelledEvent(ctx, event)

if (data.isEfinityV3014) {
return data.asEfinityV3014
if (data.isMatrixV603) {
return data.asMatrixV603
}
throw new UnknownVersionError(data.constructor.name)
}
Expand Down
4 changes: 2 additions & 2 deletions src/mappings/marketplace/events/listing_created.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import { getOrCreateAccount } from '../../util/entities'
function getEventData(ctx: CommonContext, event: Event) {
const data = new MarketplaceListingCreatedEvent(ctx, event)

if (data.isEfinityV3014) {
return data.asEfinityV3014
if (data.isMatrixV603) {
return data.asMatrixV603
}
throw new UnknownVersionError(data.constructor.name)
}
Expand Down
4 changes: 2 additions & 2 deletions src/mappings/marketplace/events/listing_filled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import { getBestListing } from '../../util/entities'
function getEventData(ctx: CommonContext, event: Event) {
const data = new MarketplaceListingFilledEvent(ctx, event)

if (data.isEfinityV3014) {
return data.asEfinityV3014
if (data.isMatrixV603) {
return data.asMatrixV603
}
throw new UnknownVersionError(data.constructor.name)
}
Expand Down
4 changes: 2 additions & 2 deletions src/mappings/multiTokens/events/approved.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import { CommonContext } from '../../types/contexts'
function getEventData(ctx: CommonContext, event: Event) {
const data = new MultiTokensApprovedEvent(ctx, event)

if (data.isEfinityV3014) {
return data.asEfinityV3014
if (data.isMatrixV603) {
return data.asMatrixV603
}

throw new UnknownVersionError(data.constructor.name)
Expand Down
4 changes: 2 additions & 2 deletions src/mappings/multiTokens/events/attribute_removed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ function metadataParser(metadata: Metadata, attribute: Attribute) {
function getEventData(ctx: CommonContext, event: Event): EventData {
const data = new MultiTokensAttributeRemovedEvent(ctx, event)

if (data.asEfinityV3014) {
return data.asEfinityV3014
if (data.asMatrixV603) {
return data.asMatrixV603
}
throw new UnknownVersionError(data.constructor.name)
}
Expand Down
4 changes: 2 additions & 2 deletions src/mappings/multiTokens/events/attribute_set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import { computeTraits } from '../../../jobs/compute-traits'
function getEventData(ctx: CommonContext, event: Event) {
const data = new MultiTokensAttributeSetEvent(ctx, event)

if (data.isEfinityV3014) {
return data.asEfinityV3014
if (data.isMatrixV603) {
return data.asMatrixV603
}
throw new UnknownVersionError(data.constructor.name)
}
Expand Down
4 changes: 2 additions & 2 deletions src/mappings/multiTokens/events/burned.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ interface EventData {
function getEventData(ctx: CommonContext, event: Event): EventData {
const data = new MultiTokensBurnedEvent(ctx, event)

if (data.isEfinityV3014) {
return data.asEfinityV3014
if (data.isMatrixV603) {
return data.asMatrixV603
}

throw new UnknownVersionError(data.constructor.name)
Expand Down
4 changes: 2 additions & 2 deletions src/mappings/multiTokens/events/collection_account_created.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ interface EventData {
function getEventData(ctx: CommonContext, event: Event): EventData {
const data = new MultiTokensCollectionAccountCreatedEvent(ctx, event)

if (data.isEfinityV3014) {
return data.asEfinityV3014
if (data.isMatrixV603) {
return data.asMatrixV603
}
throw new UnknownVersionError(data.constructor.name)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ interface EventData {
function getEventData(ctx: CommonContext, event: Event): EventData {
const data = new MultiTokensCollectionAccountDestroyedEvent(ctx, event)

if (data.isEfinityV3014) {
return data.asEfinityV3014
if (data.isMatrixV603) {
return data.asMatrixV603
}
throw new UnknownVersionError(data.constructor.name)
}
Expand Down
20 changes: 10 additions & 10 deletions src/mappings/multiTokens/events/collection_created.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ async function getMarket(ctx: CommonContext, royalty: DefaultRoyalty) {
async function getCallData(ctx: CommonContext, call: Call) {
if (call.name === 'MultiTokens.force_create_collection') {
const data = new MultiTokensForceCreateCollectionCall(ctx, call)
if (data.isEfinityV3014) {
const { maxTokenCount, maxTokenSupply, forceSingleMint } = data.asEfinityV3014.descriptor.policy.mint
const royalty = data.asEfinityV3014.descriptor.policy.market?.royalty
if (data.isMatrixV603) {
const { maxTokenCount, maxTokenSupply, forceSingleMint } = data.asMatrixV603.descriptor.policy.mint
const royalty = data.asMatrixV603.descriptor.policy.market?.royalty
const market = royalty ? await getMarket(ctx, royalty) : null
const { explicitRoyaltyCurrencies } = data.asEfinityV3014.descriptor
const { explicitRoyaltyCurrencies } = data.asMatrixV603.descriptor

return {
maxTokenCount,
Expand All @@ -58,11 +58,11 @@ async function getCallData(ctx: CommonContext, call: Call) {
} else {
const data = new MultiTokensCreateCollectionCall(ctx, call)

if (data.isEfinityV3014) {
const { maxTokenCount, maxTokenSupply, forceSingleMint } = data.asEfinityV3014.descriptor.policy.mint
const royalty = data.asEfinityV3014.descriptor.policy.market?.royalty
if (data.isMatrixV603) {
const { maxTokenCount, maxTokenSupply, forceSingleMint } = data.asMatrixV603.descriptor.policy.mint
const royalty = data.asMatrixV603.descriptor.policy.market?.royalty
const market = royalty ? await getMarket(ctx, royalty) : null
const { explicitRoyaltyCurrencies } = data.asEfinityV3014.descriptor
const { explicitRoyaltyCurrencies } = data.asMatrixV603.descriptor

return {
maxTokenCount,
Expand All @@ -80,8 +80,8 @@ async function getCallData(ctx: CommonContext, call: Call) {
function getEventData(ctx: CommonContext, event: Event): EventData {
const data = new MultiTokensCollectionCreatedEvent(ctx, event)

if (data.isEfinityV3014) {
return data.asEfinityV3014
if (data.isMatrixV603) {
return data.asMatrixV603
}
throw new UnknownVersionError(event.constructor.name)
}
Expand Down
4 changes: 2 additions & 2 deletions src/mappings/multiTokens/events/collection_destroyed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ interface EventData {
function getEventData(ctx: CommonContext, event: Event): EventData {
const data = new MultiTokensCollectionDestroyedEvent(ctx, event)

if (data.isEfinityV3014) {
const { collectionId, caller } = data.asEfinityV3014
if (data.isMatrixV603) {
const { collectionId, caller } = data.asMatrixV603
return { collectionId, caller }
}
throw new UnknownVersionError(data.constructor.name)
Expand Down
4 changes: 2 additions & 2 deletions src/mappings/multiTokens/events/collection_mutated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import { DefaultRoyalty } from '../../../types/generated/efinityV3014'
function getEventData(ctx: CommonContext, event: Event) {
const data = new MultiTokensCollectionMutatedEvent(ctx, event)

if (data.isEfinityV3014) {
const { collectionId, mutation } = data.asEfinityV3014
if (data.isMatrixV603) {
const { collectionId, mutation } = data.asMatrixV603

return {
collectionId,
Expand Down
4 changes: 2 additions & 2 deletions src/mappings/multiTokens/events/frozen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import { Event } from '../../../types/generated/support'
function getEventData(ctx: CommonContext, event: Event) {
const data = new MultiTokensFrozenEvent(ctx, event)

if (data.isEfinityV3014) {
const { collectionId, freezeType } = data.asEfinityV3014
if (data.isMatrixV603) {
const { collectionId, freezeType } = data.asMatrixV603

if (freezeType.__kind === 'Collection') {
return {
Expand Down
4 changes: 2 additions & 2 deletions src/mappings/multiTokens/events/minted.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ interface EventData {
function getEventData(ctx: CommonContext, event: Event): EventData {
const data = new MultiTokensMintedEvent(ctx, event)

if (data.isEfinityV3014) {
const { collectionId, tokenId, issuer, recipient, amount } = data.asEfinityV3014
if (data.isMatrixV603) {
const { collectionId, tokenId, issuer, recipient, amount } = data.asMatrixV603
if (issuer.__kind === 'Signed') {
return { collectionId, tokenId, issuer: issuer.value, recipient, amount }
}
Expand Down
4 changes: 2 additions & 2 deletions src/mappings/multiTokens/events/reserved.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { CommonContext } from '../../types/contexts'
function getEventData(ctx: CommonContext, eventItem: Event) {
const event = new MultiTokensReservedEvent(ctx, eventItem)

if (event.isEfinityV3014) {
return event.asEfinityV3014
if (event.isMatrixV603) {
return event.asMatrixV603
}

return null
Expand Down
4 changes: 2 additions & 2 deletions src/mappings/multiTokens/events/thawed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import { FreezeType_Token as FreezeTypeToken_v500 } from '../../../types/generat
function getEventData(ctx: CommonContext, event: Event) {
const data = new MultiTokensThawedEvent(ctx, event)

if (data.isEfinityV3014) {
const { collectionId, freezeType } = data.asEfinityV3014
if (data.isMatrixV603) {
const { collectionId, freezeType } = data.asMatrixV603

if (freezeType.__kind === 'Collection') {
return {
Expand Down
4 changes: 2 additions & 2 deletions src/mappings/multiTokens/events/token_account_created.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import { getOrCreateAccount } from '../../util/entities'
function getEventData(ctx: CommonContext, event: Event) {
const data = new MultiTokensTokenAccountCreatedEvent(ctx, event)

if (data.isEfinityV3014) {
return data.asEfinityV3014
if (data.isMatrixV603) {
return data.asMatrixV603
}
throw new UnknownVersionError(data.constructor.name)
}
Expand Down
4 changes: 2 additions & 2 deletions src/mappings/multiTokens/events/token_account_destroyed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ interface EventData {
function getEventData(ctx: CommonContext, event: Event): EventData {
const data = new MultiTokensTokenAccountDestroyedEvent(ctx, event)

if (data.isEfinityV3014) {
return data.asEfinityV3014
if (data.isMatrixV603) {
return data.asMatrixV603
}
throw new UnknownVersionError(data.constructor.name)
}
Expand Down
Loading

0 comments on commit 4dcdb8c

Please sign in to comment.