From 4de9c0f8b0a96cb1e79ab2961f003c0cf54154a2 Mon Sep 17 00:00:00 2001 From: Viki Val Date: Mon, 22 Jan 2024 16:46:44 +0100 Subject: [PATCH 01/13] :wrench: enable typegen of update_mint_settings call --- polkadot.json | 4 +++- typegen.json | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/polkadot.json b/polkadot.json index 6f89ca2..135bbae 100644 --- a/polkadot.json +++ b/polkadot.json @@ -91,7 +91,9 @@ "TransferApproved", "Transferred" ], - "calls": [], + "calls": [ + "update_mint_settings" + ], "storage": [ "Collection", "ItemMetadataOf" diff --git a/typegen.json b/typegen.json index 6a80159..2fe885a 100644 --- a/typegen.json +++ b/typegen.json @@ -91,7 +91,9 @@ "TransferApproved", "Transferred" ], - "calls": [], + "calls": [ + "update_mint_settings" + ], "storage": [ "Collection", "ItemMetadataOf" From 8ddaf93ff44c3e7b2cd29121326d709bf372380d Mon Sep 17 00:00:00 2001 From: Viki Val Date: Mon, 22 Jan 2024 16:48:28 +0100 Subject: [PATCH 02/13] :squid: Typegen for Kusama on call --- src/types/kusama/calls.ts | 1 + src/types/kusama/index.ts | 1 + src/types/kusama/nfts/calls.ts | 24 ++++++++++++++++++++ src/types/kusama/v9420.ts | 41 ++++++++++++++++++++++++++++++++++ 4 files changed, 67 insertions(+) create mode 100644 src/types/kusama/calls.ts create mode 100644 src/types/kusama/nfts/calls.ts diff --git a/src/types/kusama/calls.ts b/src/types/kusama/calls.ts new file mode 100644 index 0000000..4928f31 --- /dev/null +++ b/src/types/kusama/calls.ts @@ -0,0 +1 @@ +export * as nfts from './nfts/calls' diff --git a/src/types/kusama/index.ts b/src/types/kusama/index.ts index ddfdc16..eb79edd 100644 --- a/src/types/kusama/index.ts +++ b/src/types/kusama/index.ts @@ -6,4 +6,5 @@ export * as v9270 from './v9270' export * as v9420 from './v9420' export * as v9430 from './v9430' export * as events from './events' +export * as calls from './calls' export * as storage from './storage' diff --git a/src/types/kusama/nfts/calls.ts b/src/types/kusama/nfts/calls.ts new file mode 100644 index 0000000..6c829f7 --- /dev/null +++ b/src/types/kusama/nfts/calls.ts @@ -0,0 +1,24 @@ +import {sts, Block, Bytes, Option, Result, CallType, RuntimeCtx} from '../support' +import * as v9420 from '../v9420' + +export const updateMintSettings = { + name: 'Nfts.update_mint_settings', + /** + * Update mint settings. + * + * Origin must be either `ForceOrigin` or `Signed` and the sender should be the Issuer + * of the `collection`. + * + * - `collection`: The identifier of the collection to change. + * - `mint_settings`: The new mint settings. + * + * Emits `CollectionMintSettingsUpdated` event when successful. + */ + v9420: new CallType( + 'Nfts.update_mint_settings', + sts.struct({ + collection: sts.number(), + mintSettings: v9420.MintSettings, + }) + ), +} diff --git a/src/types/kusama/v9420.ts b/src/types/kusama/v9420.ts index bc3df6d..eb95f1b 100644 --- a/src/types/kusama/v9420.ts +++ b/src/types/kusama/v9420.ts @@ -46,6 +46,47 @@ export const Type_348: sts.Type = sts.struct(() => { } }) +export const MintSettings: sts.Type = sts.struct(() => { + return { + mintType: MintType, + price: sts.option(() => sts.bigint()), + startBlock: sts.option(() => sts.number()), + endBlock: sts.option(() => sts.number()), + defaultItemSettings: sts.bigint(), + } +}) + +export const MintType: sts.Type = sts.closedEnum(() => { + return { + HolderOf: sts.number(), + Issuer: sts.unit(), + Public: sts.unit(), + } +}) + +export type MintType = MintType_HolderOf | MintType_Issuer | MintType_Public + +export interface MintType_HolderOf { + __kind: 'HolderOf' + value: number +} + +export interface MintType_Issuer { + __kind: 'Issuer' +} + +export interface MintType_Public { + __kind: 'Public' +} + +export interface MintSettings { + mintType: MintType + price?: (bigint | undefined) + startBlock?: (number | undefined) + endBlock?: (number | undefined) + defaultItemSettings: bigint +} + export const PalletAttributes: sts.Type = sts.closedEnum(() => { return { UsedToClaim: sts.number(), From b03a63fcf64d020d6fe9a1e6e6e3280a1c88a82c Mon Sep 17 00:00:00 2001 From: Viki Val Date: Mon, 22 Jan 2024 16:48:46 +0100 Subject: [PATCH 03/13] :squid: Typegen for Polkadot on call --- src/types/polkadot/calls.ts | 1 + src/types/polkadot/index.ts | 1 + src/types/polkadot/nfts/calls.ts | 24 +++++++++++++++++++ src/types/polkadot/v9430.ts | 41 ++++++++++++++++++++++++++++++++ 4 files changed, 67 insertions(+) create mode 100644 src/types/polkadot/calls.ts create mode 100644 src/types/polkadot/nfts/calls.ts diff --git a/src/types/polkadot/calls.ts b/src/types/polkadot/calls.ts new file mode 100644 index 0000000..4928f31 --- /dev/null +++ b/src/types/polkadot/calls.ts @@ -0,0 +1 @@ +export * as nfts from './nfts/calls' diff --git a/src/types/polkadot/index.ts b/src/types/polkadot/index.ts index 208b78b..e19e89c 100644 --- a/src/types/polkadot/index.ts +++ b/src/types/polkadot/index.ts @@ -5,4 +5,5 @@ export * as v900 from './v900' export * as v9270 from './v9270' export * as v9430 from './v9430' export * as events from './events' +export * as calls from './calls' export * as storage from './storage' diff --git a/src/types/polkadot/nfts/calls.ts b/src/types/polkadot/nfts/calls.ts new file mode 100644 index 0000000..039027c --- /dev/null +++ b/src/types/polkadot/nfts/calls.ts @@ -0,0 +1,24 @@ +import {sts, Block, Bytes, Option, Result, CallType, RuntimeCtx} from '../support' +import * as v9430 from '../v9430' + +export const updateMintSettings = { + name: 'Nfts.update_mint_settings', + /** + * Update mint settings. + * + * Origin must be either `ForceOrigin` or `Signed` and the sender should be the Issuer + * of the `collection`. + * + * - `collection`: The identifier of the collection to change. + * - `mint_settings`: The new mint settings. + * + * Emits `CollectionMintSettingsUpdated` event when successful. + */ + v9430: new CallType( + 'Nfts.update_mint_settings', + sts.struct({ + collection: sts.number(), + mintSettings: v9430.MintSettings, + }) + ), +} diff --git a/src/types/polkadot/v9430.ts b/src/types/polkadot/v9430.ts index b8b32d0..c42c344 100644 --- a/src/types/polkadot/v9430.ts +++ b/src/types/polkadot/v9430.ts @@ -46,6 +46,47 @@ export const Type_353: sts.Type = sts.struct(() => { } }) +export const MintSettings: sts.Type = sts.struct(() => { + return { + mintType: MintType, + price: sts.option(() => sts.bigint()), + startBlock: sts.option(() => sts.number()), + endBlock: sts.option(() => sts.number()), + defaultItemSettings: sts.bigint(), + } +}) + +export const MintType: sts.Type = sts.closedEnum(() => { + return { + HolderOf: sts.number(), + Issuer: sts.unit(), + Public: sts.unit(), + } +}) + +export type MintType = MintType_HolderOf | MintType_Issuer | MintType_Public + +export interface MintType_HolderOf { + __kind: 'HolderOf' + value: number +} + +export interface MintType_Issuer { + __kind: 'Issuer' +} + +export interface MintType_Public { + __kind: 'Public' +} + +export interface MintSettings { + mintType: MintType + price?: (bigint | undefined) + startBlock?: (number | undefined) + endBlock?: (number | undefined) + defaultItemSettings: bigint +} + export const PalletAttributes: sts.Type = sts.closedEnum(() => { return { TransferDisabled: sts.unit(), From a49ee508942b02f413252fcd3a4eabbd8e064736 Mon Sep 17 00:00:00 2001 From: Viki Val Date: Mon, 22 Jan 2024 16:49:11 +0100 Subject: [PATCH 04/13] :wrench: NonFungibleCall are new processables --- src/processable.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/processable.ts b/src/processable.ts index 6d5f6ac..b600593 100644 --- a/src/processable.ts +++ b/src/processable.ts @@ -77,6 +77,10 @@ export enum NewNonFungible { sendTip = 'Nfts.TipSent', // can be used for marking royaltyPaid } +export enum NonFungibleCall { + updateMintSettings = 'Nfts.update_mint_settings', +} + export enum Asset { create = 'Assets.Created', destroy = 'Assets.Destroyed', From 3f57fa08e34792cacd826132e0cd2f1bd431ffaa Mon Sep 17 00:00:00 2001 From: Viki Val Date: Mon, 22 Jan 2024 17:09:24 +0100 Subject: [PATCH 05/13] :zap: update mint settings getter --- src/mappings/nfts/getters/index.ts | 5 +++++ src/mappings/nfts/getters/kusama.ts | 14 ++++++++++++-- src/mappings/nfts/getters/polkadot.ts | 12 +++++++++++- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/mappings/nfts/getters/index.ts b/src/mappings/nfts/getters/index.ts index 90580cc..4f66062 100644 --- a/src/mappings/nfts/getters/index.ts +++ b/src/mappings/nfts/getters/index.ts @@ -133,3 +133,8 @@ export function getChangeTeamEvent(_ctx: Context): ChangeCollectionTeam { const ctx = _ctx.event return proc.getChangeTeamEvent(ctx); } + +export function getUpdateMintCall(_ctx: Context): ChangeCollectionTeam { + const ctx = _ctx.call + return proc.getUpdateMintCall(ctx); +} diff --git a/src/mappings/nfts/getters/kusama.ts b/src/mappings/nfts/getters/kusama.ts index 0cbc355..12d9555 100644 --- a/src/mappings/nfts/getters/kusama.ts +++ b/src/mappings/nfts/getters/kusama.ts @@ -1,7 +1,8 @@ import { NonFungible } from '../../../processable' import { nfts as events } from '../../../types/kusama/events' -import { addressOf, unHex } from '../../utils/helper' -import { Event } from '../../utils/types' +import { nfts as calls } from '../../../types/kusama/calls' +import { addressOf, onlyValue, unHex } from '../../utils/helper' +import { Event, Call } from '../../utils/types' import { BurnTokenEvent, BuyTokenEvent, @@ -334,3 +335,12 @@ export function getChangeTeamEvent(ctx: Event): ChangeCollectionTeam { freezer: freezer ? addressOf(freezer) : '', } } + +export function getUpdateMintCall(ctx: Call) { + const call = calls.updateMintSettings + + if (call.v9420.is(ctx)) { + const { collection: classId, mintSettings: { mintType, startBlock, endBlock, price } } = call.v9420.decode(ctx) + return { id: classId.toString(), type: mintType, startBlock, endBlock, price } + } +} \ No newline at end of file diff --git a/src/mappings/nfts/getters/polkadot.ts b/src/mappings/nfts/getters/polkadot.ts index 7307810..7c3acf3 100644 --- a/src/mappings/nfts/getters/polkadot.ts +++ b/src/mappings/nfts/getters/polkadot.ts @@ -1,8 +1,9 @@ import { logger } from '@kodadot1/metasquid/logger' import { NonFungible } from '../../../processable' import { nfts as events } from '../../../types/polkadot/events' +import { nfts as calls } from '../../../types/polkadot/calls' import { addressOf, unHex } from '../../utils/helper' -import { Event } from '../../utils/types' +import { Event, Call } from '../../utils/types' import { BurnTokenEvent, BuyTokenEvent, @@ -338,3 +339,12 @@ export function getChangeTeamEvent(ctx: Event): ChangeCollectionTeam { freezer: freezer ? addressOf(freezer) : '', } } + +export function getUpdateMintCall(ctx: Call) { + const call = calls.updateMintSettings + + if (call.v9430.is(ctx)) { + const { collection: classId, mintSettings: { mintType, startBlock, endBlock, price } } = call.v9430.decode(ctx) + return { id: classId.toString(), type: mintType, startBlock, endBlock, price } + } +} From 75e7391cae3db816f6ea9c8b250ea857c62cef47 Mon Sep 17 00:00:00 2001 From: Viki Val Date: Mon, 22 Jan 2024 19:19:10 +0100 Subject: [PATCH 06/13] :label: update mint settings --- src/mappings/nfts/types.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/mappings/nfts/types.ts b/src/mappings/nfts/types.ts index 967c591..850e76c 100644 --- a/src/mappings/nfts/types.ts +++ b/src/mappings/nfts/types.ts @@ -1,4 +1,4 @@ -import { MetadataAttribute } from '@kodadot1/metasquid/types' +import { ArchiveCall, ArchiveCallWithOptionalValue, MetadataAttribute, Optional } from '@kodadot1/metasquid/types' import { Attribute } from '../../model' import { createTokenId } from '../utils/types' @@ -77,6 +77,15 @@ export type ChangeCollectionTeam = WithId & { freezer: string } +type MaybeArchiveCall = Pick & { value?: any } + +export type UpdateMintSettings = WithId & { + type: MaybeArchiveCall + startBlock: Optional, + endBlock: Optional, + price: Optional, +} + export const tokenIdOf = (base: BaseTokenEvent): string => createTokenId(base.collectionId, base.sn) export function attributeFrom(attribute: MetadataAttribute): Attribute { From 00fe58687da659dca11c1f98b9c79cfc0d058aa4 Mon Sep 17 00:00:00 2001 From: Viki Val Date: Mon, 22 Jan 2024 19:19:29 +0100 Subject: [PATCH 07/13] :tada: cool getter --- src/mappings/nfts/getters/index.ts | 3 ++- src/mappings/nfts/getters/kusama.ts | 6 +++++- src/mappings/nfts/getters/polkadot.ts | 6 +++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/mappings/nfts/getters/index.ts b/src/mappings/nfts/getters/index.ts index 4f66062..50fff3b 100644 --- a/src/mappings/nfts/getters/index.ts +++ b/src/mappings/nfts/getters/index.ts @@ -14,6 +14,7 @@ import { SetAttribute, SetMetadata, TransferTokenEvent, + UpdateMintSettings, } from '../types' // eslint-disable-next-line unicorn/prefer-module @@ -134,7 +135,7 @@ export function getChangeTeamEvent(_ctx: Context): ChangeCollectionTeam { return proc.getChangeTeamEvent(ctx); } -export function getUpdateMintCall(_ctx: Context): ChangeCollectionTeam { +export function getUpdateMintCall(_ctx: Context): UpdateMintSettings { const ctx = _ctx.call return proc.getUpdateMintCall(ctx); } diff --git a/src/mappings/nfts/getters/kusama.ts b/src/mappings/nfts/getters/kusama.ts index 12d9555..79f1b2d 100644 --- a/src/mappings/nfts/getters/kusama.ts +++ b/src/mappings/nfts/getters/kusama.ts @@ -17,6 +17,7 @@ import { SetAttribute, SetMetadata, TransferTokenEvent, + UpdateMintSettings, } from '../types' export function getCreateCollectionEvent(ctx: Event): CreateCollectionEvent { @@ -336,11 +337,14 @@ export function getChangeTeamEvent(ctx: Event): ChangeCollectionTeam { } } -export function getUpdateMintCall(ctx: Call) { +export function getUpdateMintCall(ctx: Call): UpdateMintSettings { const call = calls.updateMintSettings if (call.v9420.is(ctx)) { const { collection: classId, mintSettings: { mintType, startBlock, endBlock, price } } = call.v9420.decode(ctx) return { id: classId.toString(), type: mintType, startBlock, endBlock, price } } + + const { collection: classId, mintSettings: { mintType, startBlock, endBlock, price } } = call.v9420.decode(ctx) + return { id: classId.toString(), type: mintType, startBlock, endBlock, price } } \ No newline at end of file diff --git a/src/mappings/nfts/getters/polkadot.ts b/src/mappings/nfts/getters/polkadot.ts index 7c3acf3..b3c0bac 100644 --- a/src/mappings/nfts/getters/polkadot.ts +++ b/src/mappings/nfts/getters/polkadot.ts @@ -18,6 +18,7 @@ import { SetAttribute, SetMetadata, TransferTokenEvent, + UpdateMintSettings, } from '../types' import { debug } from '../../utils/logger' @@ -340,11 +341,14 @@ export function getChangeTeamEvent(ctx: Event): ChangeCollectionTeam { } } -export function getUpdateMintCall(ctx: Call) { +export function getUpdateMintCall(ctx: Call): UpdateMintSettings { const call = calls.updateMintSettings if (call.v9430.is(ctx)) { const { collection: classId, mintSettings: { mintType, startBlock, endBlock, price } } = call.v9430.decode(ctx) return { id: classId.toString(), type: mintType, startBlock, endBlock, price } } + + const { collection: classId, mintSettings: { mintType, startBlock, endBlock, price } } = call.v9430.decode(ctx) + return { id: classId.toString(), type: mintType, startBlock, endBlock, price } } From b2940377f69f37676e8648ff9d5befa0b3a9e8b0 Mon Sep 17 00:00:00 2001 From: Viki Val Date: Mon, 22 Jan 2024 19:32:47 +0100 Subject: [PATCH 08/13] :alien: collection type + settings --- schema.graphql | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/schema.graphql b/schema.graphql index 5e19899..496530d 100644 --- a/schema.graphql +++ b/schema.graphql @@ -26,6 +26,8 @@ type CollectionEntity @entity { updatedAt: DateTime! @index version: Int! volume: BigInt! @index + type: CollectionType + settings: CollectionSettings } type TokenEntity @entity { @@ -88,6 +90,13 @@ type Attribute @jsonField { value: String! } +type CollectionSettings @jsonField { + value: String + startBlock: BigInt + endBlock: BigInt + price: BigInt +} + interface EventType { id: ID! blockNumber: BigInt @@ -136,6 +145,12 @@ enum Interaction { CHANGEISSUER } +enum CollectionType { + HolderOf + Issuer + Public +} + type AssetEntity @entity { id: ID! name: String From 11e76704e2d2ffc0b28a7145514648a425558401 Mon Sep 17 00:00:00 2001 From: Viki Val Date: Mon, 22 Jan 2024 19:33:44 +0100 Subject: [PATCH 09/13] :squid: codgen on collection settings --- src/model/generated/_collectionSettings.ts | 60 +++++++++++++++++++ src/model/generated/_collectionType.ts | 5 ++ src/model/generated/collectionEntity.model.ts | 8 +++ src/model/generated/index.ts | 2 + 4 files changed, 75 insertions(+) create mode 100644 src/model/generated/_collectionSettings.ts create mode 100644 src/model/generated/_collectionType.ts diff --git a/src/model/generated/_collectionSettings.ts b/src/model/generated/_collectionSettings.ts new file mode 100644 index 0000000..bfb9f9c --- /dev/null +++ b/src/model/generated/_collectionSettings.ts @@ -0,0 +1,60 @@ +import assert from "assert" +import * as marshal from "./marshal" + +export class CollectionSettings { + private _value!: string | undefined | null + private _startBlock!: bigint | undefined | null + private _endBlock!: bigint | undefined | null + private _price!: bigint | undefined | null + + constructor(props?: Partial>, json?: any) { + Object.assign(this, props) + if (json != null) { + this._value = json.value == null ? undefined : marshal.string.fromJSON(json.value) + this._startBlock = json.startBlock == null ? undefined : marshal.bigint.fromJSON(json.startBlock) + this._endBlock = json.endBlock == null ? undefined : marshal.bigint.fromJSON(json.endBlock) + this._price = json.price == null ? undefined : marshal.bigint.fromJSON(json.price) + } + } + + get value(): string | undefined | null { + return this._value + } + + set value(value: string | undefined | null) { + this._value = value + } + + get startBlock(): bigint | undefined | null { + return this._startBlock + } + + set startBlock(value: bigint | undefined | null) { + this._startBlock = value + } + + get endBlock(): bigint | undefined | null { + return this._endBlock + } + + set endBlock(value: bigint | undefined | null) { + this._endBlock = value + } + + get price(): bigint | undefined | null { + return this._price + } + + set price(value: bigint | undefined | null) { + this._price = value + } + + toJSON(): object { + return { + value: this.value, + startBlock: this.startBlock == null ? undefined : marshal.bigint.toJSON(this.startBlock), + endBlock: this.endBlock == null ? undefined : marshal.bigint.toJSON(this.endBlock), + price: this.price == null ? undefined : marshal.bigint.toJSON(this.price), + } + } +} diff --git a/src/model/generated/_collectionType.ts b/src/model/generated/_collectionType.ts new file mode 100644 index 0000000..f5b1538 --- /dev/null +++ b/src/model/generated/_collectionType.ts @@ -0,0 +1,5 @@ +export enum CollectionType { + HolderOf = "HolderOf", + Issuer = "Issuer", + Public = "Public", +} diff --git a/src/model/generated/collectionEntity.model.ts b/src/model/generated/collectionEntity.model.ts index fece66a..455d655 100644 --- a/src/model/generated/collectionEntity.model.ts +++ b/src/model/generated/collectionEntity.model.ts @@ -4,6 +4,8 @@ import {Attribute} from "./_attribute" import {CollectionEvent} from "./collectionEvent.model" import {MetadataEntity} from "./metadataEntity.model" import {NFTEntity} from "./nftEntity.model" +import {CollectionType} from "./_collectionType" +import {CollectionSettings} from "./_collectionSettings" @Entity_() export class CollectionEntity { @@ -102,4 +104,10 @@ export class CollectionEntity { @Index_() @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) volume!: bigint + + @Column_("varchar", {length: 8, nullable: true}) + type!: CollectionType | undefined | null + + @Column_("jsonb", {transformer: {to: obj => obj == null ? undefined : obj.toJSON(), from: obj => obj == null ? undefined : new CollectionSettings(undefined, obj)}, nullable: true}) + settings!: CollectionSettings | undefined | null } diff --git a/src/model/generated/index.ts b/src/model/generated/index.ts index 2607bd6..1df398f 100644 --- a/src/model/generated/index.ts +++ b/src/model/generated/index.ts @@ -1,5 +1,7 @@ export * from "./collectionEntity.model" export * from "./_attribute" +export * from "./_collectionType" +export * from "./_collectionSettings" export * from "./tokenEntity.model" export * from "./nftEntity.model" export * from "./metadataEntity.model" From 1f93bd1b795e64cb96910fa3c7871e03562bc714 Mon Sep 17 00:00:00 2001 From: Viki Val Date: Mon, 22 Jan 2024 19:34:10 +0100 Subject: [PATCH 10/13] :zap: collectionSettingOf --- src/mappings/nfts/types.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/mappings/nfts/types.ts b/src/mappings/nfts/types.ts index 850e76c..a862f26 100644 --- a/src/mappings/nfts/types.ts +++ b/src/mappings/nfts/types.ts @@ -1,5 +1,5 @@ import { ArchiveCall, ArchiveCallWithOptionalValue, MetadataAttribute, Optional } from '@kodadot1/metasquid/types' -import { Attribute } from '../../model' +import { Attribute, CollectionSettings } from '../../model' import { createTokenId } from '../utils/types' export type WithId = { @@ -98,3 +98,16 @@ export function attributeFrom(attribute: MetadataAttribute): Attribute { } ) } + + +export function collectionSettingOf(settings: UpdateMintSettings): CollectionSettings { + return new CollectionSettings( + {}, + { + value: String(settings.type.value ?? ''), + startBlock: settings.startBlock, + endBlock: settings.endBlock, + price: settings.price, + } + ) +} \ No newline at end of file From 0d9dbfe96b17af1fe879b6fa3f4793e4bc7c7233 Mon Sep 17 00:00:00 2001 From: Viki Val Date: Mon, 22 Jan 2024 19:34:29 +0100 Subject: [PATCH 11/13] :tada: update mint settings --- src/mappings/nfts/index.ts | 1 + src/mappings/nfts/updateMintSettings.ts | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 src/mappings/nfts/updateMintSettings.ts diff --git a/src/mappings/nfts/index.ts b/src/mappings/nfts/index.ts index 58ab7c3..a420903 100644 --- a/src/mappings/nfts/index.ts +++ b/src/mappings/nfts/index.ts @@ -11,3 +11,4 @@ export * from './mint' export * from './setAttribute' export * from './setMetadata' export * from './transfer' +export * from './updateMintSettings' diff --git a/src/mappings/nfts/updateMintSettings.ts b/src/mappings/nfts/updateMintSettings.ts new file mode 100644 index 0000000..31f0c5e --- /dev/null +++ b/src/mappings/nfts/updateMintSettings.ts @@ -0,0 +1,25 @@ +import { getOrFail as get } from '@kodadot1/metasquid/entity' +import { CollectionEntity as CE } from '../../model' +import { unwrap } from '../utils/extract' +import { debug, pending, success } from '../utils/logger' +import { Context } from '../utils/types' +import { getUpdateMintCall } from './getters' +import { collectionSettingOf } from './types' + +const OPERATION = 'UPDATE' as any + +export async function handleCollectionMintUpdate(context: Context): Promise { + pending(OPERATION, `${context.block.height}`) + const event = unwrap(context, getUpdateMintCall) + debug(OPERATION, event) + + const entity = await get(context.store, CE, event.id) + + // TODO: update mint settings + entity.type = event.type.__kind as any + entity.settings = collectionSettingOf(event) + + success(OPERATION, `${event.id} by ${event.caller}`) + await context.store.save(entity) +} + \ No newline at end of file From a4a4872b6b2cc40ef20e5093d8c3d3fe20b3d7a9 Mon Sep 17 00:00:00 2001 From: Viki Val Date: Mon, 22 Jan 2024 19:35:24 +0100 Subject: [PATCH 12/13] :zap: update mint settings --- src/mappings/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mappings/index.ts b/src/mappings/index.ts index 3168e19..78a06bf 100644 --- a/src/mappings/index.ts +++ b/src/mappings/index.ts @@ -3,7 +3,7 @@ import { logger } from '@kodadot1/metasquid/logger' import { Store } from '@subsquid/typeorm-store' import { STARTING_BLOCK } from '../environment' import { NFTEntity as NE } from '../model' -import { Asset, NonFungible, Unique } from '../processable' +import { Asset, NonFungible, NonFungibleCall, Unique } from '../processable' import * as a from './assets' import * as n from './nfts' import * as u from './uniques' @@ -133,6 +133,9 @@ export async function nfts(item: T, ctx: Context): Prom case NonFungible.transfer: await n.handleTokenTransfer(ctx) break + case NonFungibleCall.updateMintSettings: + await n.handleCollectionMintUpdate(ctx) + break default: throw new Error(`Unknown event ${item.name}`) } From a92e09bed7c11fff78976a1dceae5390de498f3e Mon Sep 17 00:00:00 2001 From: Viki Val Date: Tue, 23 Jan 2024 11:36:05 +0100 Subject: [PATCH 13/13] :label: CollectionType on collection.type --- src/mappings/nfts/updateMintSettings.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/mappings/nfts/updateMintSettings.ts b/src/mappings/nfts/updateMintSettings.ts index 31f0c5e..d095a96 100644 --- a/src/mappings/nfts/updateMintSettings.ts +++ b/src/mappings/nfts/updateMintSettings.ts @@ -1,5 +1,5 @@ import { getOrFail as get } from '@kodadot1/metasquid/entity' -import { CollectionEntity as CE } from '../../model' +import { CollectionEntity as CE, CollectionType } from '../../model' import { unwrap } from '../utils/extract' import { debug, pending, success } from '../utils/logger' import { Context } from '../utils/types' @@ -15,8 +15,7 @@ export async function handleCollectionMintUpdate(context: Context): Promise