From 1f3030fab5f4c8a33026a1a852741050f6b381b7 Mon Sep 17 00:00:00 2001 From: Viki Val Date: Tue, 18 Jul 2023 15:47:54 +0200 Subject: [PATCH 1/5] :squid: typegen statemint --- src/types/statemint/events.ts | 2575 +++++++++++++++----------------- src/types/statemint/storage.ts | 184 ++- src/types/statemint/support.ts | 205 +-- src/types/statemint/v601.ts | 28 +- src/types/statemint/v9230.ts | 22 +- 5 files changed, 1423 insertions(+), 1591 deletions(-) diff --git a/src/types/statemint/events.ts b/src/types/statemint/events.ts index fbdf7bf..ff9638b 100644 --- a/src/types/statemint/events.ts +++ b/src/types/statemint/events.ts @@ -1,1451 +1,1286 @@ -import assert from 'node:assert' -import { Chain, ChainContext, EventContext, Event, Result, Option } from './support' +import assert from 'assert' +import {Chain, ChainContext, EventContext, Event, Result, Option} from './support' export class UniquesAttributeClearedEvent { - private readonly _chain: Chain - private readonly event: Event - - constructor(ctx: EventContext) - constructor(ctx: ChainContext, event: Event) - constructor(ctx: EventContext, event?: Event) { - event = event || ctx.event - assert(event.name === 'Uniques.AttributeCleared') - this._chain = ctx._chain - this.event = event - } - - /** - * Attribute metadata has been cleared for an asset class or instance. - * \[ class, maybe_instance, key, maybe_value \] - */ - get isV601(): boolean { - return ( - this._chain.getEventHash('Uniques.AttributeCleared') === - '885b4dbb6c48840d1cb04f9f8a73f65455ff8e630c9692e7b8efbb5abf341a92' - ) - } - - /** - * Attribute metadata has been cleared for an asset class or instance. - * \[ class, maybe_instance, key, maybe_value \] - */ - get asV601(): [number, number | undefined, Uint8Array] { - assert(this.isV601) - return this._chain.decodeEvent(this.event) - } - - /** - * Attribute metadata has been cleared for an asset class or instance. - */ - get isV700(): boolean { - return ( - this._chain.getEventHash('Uniques.AttributeCleared') === - '91aa106b700026eb59ef1d86cbd22766539a996d1d1d5cb5dbbdc18439ff1283' - ) - } - - /** - * Attribute metadata has been cleared for an asset class or instance. - */ - get asV700(): { class: number; maybeInstance: number | undefined; key: Uint8Array } { - assert(this.isV700) - return this._chain.decodeEvent(this.event) - } - - /** - * Attribute metadata has been cleared for a `collection` or `item`. - */ - get isV9230(): boolean { - return ( - this._chain.getEventHash('Uniques.AttributeCleared') === - 'c330ddd00fb87b92c796bc29cff6edf2ce546dd8eb98420ac23c5cbe7b0e11d1' - ) - } - - /** - * Attribute metadata has been cleared for a `collection` or `item`. - */ - get asV9230(): { collection: number; maybeItem: number | undefined; key: Uint8Array } { - assert(this.isV9230) - return this._chain.decodeEvent(this.event) - } + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Uniques.AttributeCleared') + this._chain = ctx._chain + this.event = event + } + + /** + * Attribute metadata has been cleared for an asset class or instance. + * \[ class, maybe_instance, key, maybe_value \] + */ + get isV601(): boolean { + return this._chain.getEventHash('Uniques.AttributeCleared') === '885b4dbb6c48840d1cb04f9f8a73f65455ff8e630c9692e7b8efbb5abf341a92' + } + + /** + * Attribute metadata has been cleared for an asset class or instance. + * \[ class, maybe_instance, key, maybe_value \] + */ + get asV601(): [number, (number | undefined), Uint8Array] { + assert(this.isV601) + return this._chain.decodeEvent(this.event) + } + + /** + * Attribute metadata has been cleared for an asset class or instance. + */ + get isV700(): boolean { + return this._chain.getEventHash('Uniques.AttributeCleared') === '91aa106b700026eb59ef1d86cbd22766539a996d1d1d5cb5dbbdc18439ff1283' + } + + /** + * Attribute metadata has been cleared for an asset class or instance. + */ + get asV700(): {class: number, maybeInstance: (number | undefined), key: Uint8Array} { + assert(this.isV700) + return this._chain.decodeEvent(this.event) + } + + /** + * Attribute metadata has been cleared for a `collection` or `item`. + */ + get isV9230(): boolean { + return this._chain.getEventHash('Uniques.AttributeCleared') === 'c330ddd00fb87b92c796bc29cff6edf2ce546dd8eb98420ac23c5cbe7b0e11d1' + } + + /** + * Attribute metadata has been cleared for a `collection` or `item`. + */ + get asV9230(): {collection: number, maybeItem: (number | undefined), key: Uint8Array} { + assert(this.isV9230) + return this._chain.decodeEvent(this.event) + } } export class UniquesAttributeSetEvent { - private readonly _chain: Chain - private readonly event: Event - - constructor(ctx: EventContext) - constructor(ctx: ChainContext, event: Event) - constructor(ctx: EventContext, event?: Event) { - event = event || ctx.event - assert(event.name === 'Uniques.AttributeSet') - this._chain = ctx._chain - this.event = event - } - - /** - * New attribute metadata has been set for an asset class or instance. - * \[ class, maybe_instance, key, value \] - */ - get isV601(): boolean { - return ( - this._chain.getEventHash('Uniques.AttributeSet') === - '135c19d2cf1f530340d3fe938fdcce6ca358d729cfc69ce595cc57b640136a76' - ) - } - - /** - * New attribute metadata has been set for an asset class or instance. - * \[ class, maybe_instance, key, value \] - */ - get asV601(): [number, number | undefined, Uint8Array, Uint8Array] { - assert(this.isV601) - return this._chain.decodeEvent(this.event) - } - - /** - * New attribute metadata has been set for an asset class or instance. - */ - get isV700(): boolean { - return ( - this._chain.getEventHash('Uniques.AttributeSet') === - '6ae49a979267c094bc35bda051f5467e62472724b598a2f5ee5720a5111b8623' - ) - } - - /** - * New attribute metadata has been set for an asset class or instance. - */ - get asV700(): { class: number; maybeInstance: number | undefined; key: Uint8Array; value: Uint8Array } { - assert(this.isV700) - return this._chain.decodeEvent(this.event) - } - - /** - * New attribute metadata has been set for a `collection` or `item`. - */ - get isV9230(): boolean { - return ( - this._chain.getEventHash('Uniques.AttributeSet') === - 'b7e65dbf62f10e9415ffa560bff4954ffeb28994c9cf350ecd59fe98850d8783' - ) - } - - /** - * New attribute metadata has been set for a `collection` or `item`. - */ - get asV9230(): { collection: number; maybeItem: number | undefined; key: Uint8Array; value: Uint8Array } { - assert(this.isV9230) - return this._chain.decodeEvent(this.event) - } + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Uniques.AttributeSet') + this._chain = ctx._chain + this.event = event + } + + /** + * New attribute metadata has been set for an asset class or instance. + * \[ class, maybe_instance, key, value \] + */ + get isV601(): boolean { + return this._chain.getEventHash('Uniques.AttributeSet') === '135c19d2cf1f530340d3fe938fdcce6ca358d729cfc69ce595cc57b640136a76' + } + + /** + * New attribute metadata has been set for an asset class or instance. + * \[ class, maybe_instance, key, value \] + */ + get asV601(): [number, (number | undefined), Uint8Array, Uint8Array] { + assert(this.isV601) + return this._chain.decodeEvent(this.event) + } + + /** + * New attribute metadata has been set for an asset class or instance. + */ + get isV700(): boolean { + return this._chain.getEventHash('Uniques.AttributeSet') === '6ae49a979267c094bc35bda051f5467e62472724b598a2f5ee5720a5111b8623' + } + + /** + * New attribute metadata has been set for an asset class or instance. + */ + get asV700(): {class: number, maybeInstance: (number | undefined), key: Uint8Array, value: Uint8Array} { + assert(this.isV700) + return this._chain.decodeEvent(this.event) + } + + /** + * New attribute metadata has been set for a `collection` or `item`. + */ + get isV9230(): boolean { + return this._chain.getEventHash('Uniques.AttributeSet') === 'b7e65dbf62f10e9415ffa560bff4954ffeb28994c9cf350ecd59fe98850d8783' + } + + /** + * New attribute metadata has been set for a `collection` or `item`. + */ + get asV9230(): {collection: number, maybeItem: (number | undefined), key: Uint8Array, value: Uint8Array} { + assert(this.isV9230) + return this._chain.decodeEvent(this.event) + } } export class UniquesBurnedEvent { - private readonly _chain: Chain - private readonly event: Event - - constructor(ctx: EventContext) - constructor(ctx: ChainContext, event: Event) - constructor(ctx: EventContext, event?: Event) { - event = event || ctx.event - assert(event.name === 'Uniques.Burned') - this._chain = ctx._chain - this.event = event - } - - /** - * An asset `instance` was destroyed. \[ class, instance, owner \] - */ - get isV601(): boolean { - return ( - this._chain.getEventHash('Uniques.Burned') === '7b53bb12306431c6ff23a3ea3466183ed1c7f4ecb417f6e8467ae0c63cbc2f88' - ) - } - - /** - * An asset `instance` was destroyed. \[ class, instance, owner \] - */ - get asV601(): [number, number, Uint8Array] { - assert(this.isV601) - return this._chain.decodeEvent(this.event) - } - - /** - * An asset `instance` was destroyed. - */ - get isV700(): boolean { - return ( - this._chain.getEventHash('Uniques.Burned') === '448723f6c40490fe04ab8e6d9e382432b7ce5c075d05af60c076b9f6a8a9e510' - ) - } - - /** - * An asset `instance` was destroyed. - */ - get asV700(): { class: number; instance: number; owner: Uint8Array } { - assert(this.isV700) - return this._chain.decodeEvent(this.event) - } - - /** - * An `item` was destroyed. - */ - get isV9230(): boolean { - return ( - this._chain.getEventHash('Uniques.Burned') === '281c96f4233cbe042ed549cfca1fafa833d625f8d832ed29682ac34cdceb017d' - ) - } - - /** - * An `item` was destroyed. - */ - get asV9230(): { collection: number; item: number; owner: Uint8Array } { - assert(this.isV9230) - return this._chain.decodeEvent(this.event) - } + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Uniques.Burned') + this._chain = ctx._chain + this.event = event + } + + /** + * An asset `instance` was destroyed. \[ class, instance, owner \] + */ + get isV601(): boolean { + return this._chain.getEventHash('Uniques.Burned') === '7b53bb12306431c6ff23a3ea3466183ed1c7f4ecb417f6e8467ae0c63cbc2f88' + } + + /** + * An asset `instance` was destroyed. \[ class, instance, owner \] + */ + get asV601(): [number, number, Uint8Array] { + assert(this.isV601) + return this._chain.decodeEvent(this.event) + } + + /** + * An asset `instance` was destroyed. + */ + get isV700(): boolean { + return this._chain.getEventHash('Uniques.Burned') === '448723f6c40490fe04ab8e6d9e382432b7ce5c075d05af60c076b9f6a8a9e510' + } + + /** + * An asset `instance` was destroyed. + */ + get asV700(): {class: number, instance: number, owner: Uint8Array} { + assert(this.isV700) + return this._chain.decodeEvent(this.event) + } + + /** + * An `item` was destroyed. + */ + get isV9230(): boolean { + return this._chain.getEventHash('Uniques.Burned') === '281c96f4233cbe042ed549cfca1fafa833d625f8d832ed29682ac34cdceb017d' + } + + /** + * An `item` was destroyed. + */ + get asV9230(): {collection: number, item: number, owner: Uint8Array} { + assert(this.isV9230) + return this._chain.decodeEvent(this.event) + } } export class UniquesClassFrozenEvent { - private readonly _chain: Chain - private readonly event: Event - - constructor(ctx: EventContext) - constructor(ctx: ChainContext, event: Event) - constructor(ctx: EventContext, event?: Event) { - event = event || ctx.event - assert(event.name === 'Uniques.ClassFrozen') - this._chain = ctx._chain - this.event = event - } - - /** - * Some asset `class` was frozen. \[ class \] - */ - get isV601(): boolean { - return ( - this._chain.getEventHash('Uniques.ClassFrozen') === - '0a0f30b1ade5af5fade6413c605719d59be71340cf4884f65ee9858eb1c38f6c' - ) - } - - /** - * Some asset `class` was frozen. \[ class \] - */ - get asV601(): number { - assert(this.isV601) - return this._chain.decodeEvent(this.event) - } - - /** - * Some asset `class` was frozen. - */ - get isV700(): boolean { - return ( - this._chain.getEventHash('Uniques.ClassFrozen') === - '4f045c4df2d4b9045175427f6f6aa548cd3ad56207f700b68254d3b77d944310' - ) - } - - /** - * Some asset `class` was frozen. - */ - get asV700(): { class: number } { - assert(this.isV700) - return this._chain.decodeEvent(this.event) - } + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Uniques.ClassFrozen') + this._chain = ctx._chain + this.event = event + } + + /** + * Some asset `class` was frozen. \[ class \] + */ + get isV601(): boolean { + return this._chain.getEventHash('Uniques.ClassFrozen') === '0a0f30b1ade5af5fade6413c605719d59be71340cf4884f65ee9858eb1c38f6c' + } + + /** + * Some asset `class` was frozen. \[ class \] + */ + get asV601(): number { + assert(this.isV601) + return this._chain.decodeEvent(this.event) + } + + /** + * Some asset `class` was frozen. + */ + get isV700(): boolean { + return this._chain.getEventHash('Uniques.ClassFrozen') === '4f045c4df2d4b9045175427f6f6aa548cd3ad56207f700b68254d3b77d944310' + } + + /** + * Some asset `class` was frozen. + */ + get asV700(): {class: number} { + assert(this.isV700) + return this._chain.decodeEvent(this.event) + } } export class UniquesClassMetadataClearedEvent { - private readonly _chain: Chain - private readonly event: Event - - constructor(ctx: EventContext) - constructor(ctx: ChainContext, event: Event) - constructor(ctx: EventContext, event?: Event) { - event = event || ctx.event - assert(event.name === 'Uniques.ClassMetadataCleared') - this._chain = ctx._chain - this.event = event - } - - /** - * Metadata has been cleared for an asset class. \[ class \] - */ - get isV601(): boolean { - return ( - this._chain.getEventHash('Uniques.ClassMetadataCleared') === - '0a0f30b1ade5af5fade6413c605719d59be71340cf4884f65ee9858eb1c38f6c' - ) - } - - /** - * Metadata has been cleared for an asset class. \[ class \] - */ - get asV601(): number { - assert(this.isV601) - return this._chain.decodeEvent(this.event) - } - - /** - * Metadata has been cleared for an asset class. - */ - get isV700(): boolean { - return ( - this._chain.getEventHash('Uniques.ClassMetadataCleared') === - '4f045c4df2d4b9045175427f6f6aa548cd3ad56207f700b68254d3b77d944310' - ) - } - - /** - * Metadata has been cleared for an asset class. - */ - get asV700(): { class: number } { - assert(this.isV700) - return this._chain.decodeEvent(this.event) - } + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Uniques.ClassMetadataCleared') + this._chain = ctx._chain + this.event = event + } + + /** + * Metadata has been cleared for an asset class. \[ class \] + */ + get isV601(): boolean { + return this._chain.getEventHash('Uniques.ClassMetadataCleared') === '0a0f30b1ade5af5fade6413c605719d59be71340cf4884f65ee9858eb1c38f6c' + } + + /** + * Metadata has been cleared for an asset class. \[ class \] + */ + get asV601(): number { + assert(this.isV601) + return this._chain.decodeEvent(this.event) + } + + /** + * Metadata has been cleared for an asset class. + */ + get isV700(): boolean { + return this._chain.getEventHash('Uniques.ClassMetadataCleared') === '4f045c4df2d4b9045175427f6f6aa548cd3ad56207f700b68254d3b77d944310' + } + + /** + * Metadata has been cleared for an asset class. + */ + get asV700(): {class: number} { + assert(this.isV700) + return this._chain.decodeEvent(this.event) + } } export class UniquesClassMetadataSetEvent { - private readonly _chain: Chain - private readonly event: Event - - constructor(ctx: EventContext) - constructor(ctx: ChainContext, event: Event) - constructor(ctx: EventContext, event?: Event) { - event = event || ctx.event - assert(event.name === 'Uniques.ClassMetadataSet') - this._chain = ctx._chain - this.event = event - } - - /** - * New metadata has been set for an asset class. \[ class, data, is_frozen \] - */ - get isV601(): boolean { - return ( - this._chain.getEventHash('Uniques.ClassMetadataSet') === - '5792f3fb3e6c02cd51090283e81fd6d6cf13fe8a50876dcc428a6b9314aa3f72' - ) - } - - /** - * New metadata has been set for an asset class. \[ class, data, is_frozen \] - */ - get asV601(): [number, Uint8Array, boolean] { - assert(this.isV601) - return this._chain.decodeEvent(this.event) - } - - /** - * New metadata has been set for an asset class. - */ - get isV700(): boolean { - return ( - this._chain.getEventHash('Uniques.ClassMetadataSet') === - '151c432def6b2dc27880b815773b729a1ceb58295a326de4c16e57901c2a9476' - ) - } - - /** - * New metadata has been set for an asset class. - */ - get asV700(): { class: number; data: Uint8Array; isFrozen: boolean } { - assert(this.isV700) - return this._chain.decodeEvent(this.event) - } + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Uniques.ClassMetadataSet') + this._chain = ctx._chain + this.event = event + } + + /** + * New metadata has been set for an asset class. \[ class, data, is_frozen \] + */ + get isV601(): boolean { + return this._chain.getEventHash('Uniques.ClassMetadataSet') === '5792f3fb3e6c02cd51090283e81fd6d6cf13fe8a50876dcc428a6b9314aa3f72' + } + + /** + * New metadata has been set for an asset class. \[ class, data, is_frozen \] + */ + get asV601(): [number, Uint8Array, boolean] { + assert(this.isV601) + return this._chain.decodeEvent(this.event) + } + + /** + * New metadata has been set for an asset class. + */ + get isV700(): boolean { + return this._chain.getEventHash('Uniques.ClassMetadataSet') === '151c432def6b2dc27880b815773b729a1ceb58295a326de4c16e57901c2a9476' + } + + /** + * New metadata has been set for an asset class. + */ + get asV700(): {class: number, data: Uint8Array, isFrozen: boolean} { + assert(this.isV700) + return this._chain.decodeEvent(this.event) + } } export class UniquesClassThawedEvent { - private readonly _chain: Chain - private readonly event: Event - - constructor(ctx: EventContext) - constructor(ctx: ChainContext, event: Event) - constructor(ctx: EventContext, event?: Event) { - event = event || ctx.event - assert(event.name === 'Uniques.ClassThawed') - this._chain = ctx._chain - this.event = event - } - - /** - * Some asset `class` was thawed. \[ class \] - */ - get isV601(): boolean { - return ( - this._chain.getEventHash('Uniques.ClassThawed') === - '0a0f30b1ade5af5fade6413c605719d59be71340cf4884f65ee9858eb1c38f6c' - ) - } - - /** - * Some asset `class` was thawed. \[ class \] - */ - get asV601(): number { - assert(this.isV601) - return this._chain.decodeEvent(this.event) - } - - /** - * Some asset `class` was thawed. - */ - get isV700(): boolean { - return ( - this._chain.getEventHash('Uniques.ClassThawed') === - '4f045c4df2d4b9045175427f6f6aa548cd3ad56207f700b68254d3b77d944310' - ) - } - - /** - * Some asset `class` was thawed. - */ - get asV700(): { class: number } { - assert(this.isV700) - return this._chain.decodeEvent(this.event) - } + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Uniques.ClassThawed') + this._chain = ctx._chain + this.event = event + } + + /** + * Some asset `class` was thawed. \[ class \] + */ + get isV601(): boolean { + return this._chain.getEventHash('Uniques.ClassThawed') === '0a0f30b1ade5af5fade6413c605719d59be71340cf4884f65ee9858eb1c38f6c' + } + + /** + * Some asset `class` was thawed. \[ class \] + */ + get asV601(): number { + assert(this.isV601) + return this._chain.decodeEvent(this.event) + } + + /** + * Some asset `class` was thawed. + */ + get isV700(): boolean { + return this._chain.getEventHash('Uniques.ClassThawed') === '4f045c4df2d4b9045175427f6f6aa548cd3ad56207f700b68254d3b77d944310' + } + + /** + * Some asset `class` was thawed. + */ + get asV700(): {class: number} { + assert(this.isV700) + return this._chain.decodeEvent(this.event) + } } export class UniquesCollectionFrozenEvent { - private readonly _chain: Chain - private readonly event: Event - - constructor(ctx: EventContext) - constructor(ctx: ChainContext, event: Event) - constructor(ctx: EventContext, event?: Event) { - event = event || ctx.event - assert(event.name === 'Uniques.CollectionFrozen') - this._chain = ctx._chain - this.event = event - } - - /** - * Some `collection` was frozen. - */ - get isV9230(): boolean { - return ( - this._chain.getEventHash('Uniques.CollectionFrozen') === - 'a84ae2f0e555d689a7b5b0ee2914bd693902b07afc4f268377240f6ac92495cb' - ) - } - - /** - * Some `collection` was frozen. - */ - get asV9230(): { collection: number } { - assert(this.isV9230) - return this._chain.decodeEvent(this.event) - } + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Uniques.CollectionFrozen') + this._chain = ctx._chain + this.event = event + } + + /** + * Some `collection` was frozen. + */ + get isV9230(): boolean { + return this._chain.getEventHash('Uniques.CollectionFrozen') === 'a84ae2f0e555d689a7b5b0ee2914bd693902b07afc4f268377240f6ac92495cb' + } + + /** + * Some `collection` was frozen. + */ + get asV9230(): {collection: number} { + assert(this.isV9230) + return this._chain.decodeEvent(this.event) + } } export class UniquesCollectionMaxSupplySetEvent { - private readonly _chain: Chain - private readonly event: Event - - constructor(ctx: EventContext) - constructor(ctx: ChainContext, event: Event) - constructor(ctx: EventContext, event?: Event) { - event = event || ctx.event - assert(event.name === 'Uniques.CollectionMaxSupplySet') - this._chain = ctx._chain - this.event = event - } - - /** - * Max supply has been set for a collection. - */ - get isV9230(): boolean { - return ( - this._chain.getEventHash('Uniques.CollectionMaxSupplySet') === - '165991456bc3c6a81994ce513fdf36c2303f5220829f5e8caafbf821233135b4' - ) - } - - /** - * Max supply has been set for a collection. - */ - get asV9230(): { collection: number; maxSupply: number } { - assert(this.isV9230) - return this._chain.decodeEvent(this.event) - } + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Uniques.CollectionMaxSupplySet') + this._chain = ctx._chain + this.event = event + } + + /** + * Max supply has been set for a collection. + */ + get isV9230(): boolean { + return this._chain.getEventHash('Uniques.CollectionMaxSupplySet') === '165991456bc3c6a81994ce513fdf36c2303f5220829f5e8caafbf821233135b4' + } + + /** + * Max supply has been set for a collection. + */ + get asV9230(): {collection: number, maxSupply: number} { + assert(this.isV9230) + return this._chain.decodeEvent(this.event) + } } export class UniquesCollectionMetadataClearedEvent { - private readonly _chain: Chain - private readonly event: Event - - constructor(ctx: EventContext) - constructor(ctx: ChainContext, event: Event) - constructor(ctx: EventContext, event?: Event) { - event = event || ctx.event - assert(event.name === 'Uniques.CollectionMetadataCleared') - this._chain = ctx._chain - this.event = event - } - - /** - * Metadata has been cleared for a `collection`. - */ - get isV9230(): boolean { - return ( - this._chain.getEventHash('Uniques.CollectionMetadataCleared') === - 'a84ae2f0e555d689a7b5b0ee2914bd693902b07afc4f268377240f6ac92495cb' - ) - } - - /** - * Metadata has been cleared for a `collection`. - */ - get asV9230(): { collection: number } { - assert(this.isV9230) - return this._chain.decodeEvent(this.event) - } + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Uniques.CollectionMetadataCleared') + this._chain = ctx._chain + this.event = event + } + + /** + * Metadata has been cleared for a `collection`. + */ + get isV9230(): boolean { + return this._chain.getEventHash('Uniques.CollectionMetadataCleared') === 'a84ae2f0e555d689a7b5b0ee2914bd693902b07afc4f268377240f6ac92495cb' + } + + /** + * Metadata has been cleared for a `collection`. + */ + get asV9230(): {collection: number} { + assert(this.isV9230) + return this._chain.decodeEvent(this.event) + } } export class UniquesCollectionMetadataSetEvent { - private readonly _chain: Chain - private readonly event: Event - - constructor(ctx: EventContext) - constructor(ctx: ChainContext, event: Event) - constructor(ctx: EventContext, event?: Event) { - event = event || ctx.event - assert(event.name === 'Uniques.CollectionMetadataSet') - this._chain = ctx._chain - this.event = event - } - - /** - * New metadata has been set for a `collection`. - */ - get isV9230(): boolean { - return ( - this._chain.getEventHash('Uniques.CollectionMetadataSet') === - '63ef75086da73b45ed287cac6640abbebd40222433fb8fae9e4fa1bfa173afc2' - ) - } - - /** - * New metadata has been set for a `collection`. - */ - get asV9230(): { collection: number; data: Uint8Array; isFrozen: boolean } { - assert(this.isV9230) - return this._chain.decodeEvent(this.event) - } + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Uniques.CollectionMetadataSet') + this._chain = ctx._chain + this.event = event + } + + /** + * New metadata has been set for a `collection`. + */ + get isV9230(): boolean { + return this._chain.getEventHash('Uniques.CollectionMetadataSet') === '63ef75086da73b45ed287cac6640abbebd40222433fb8fae9e4fa1bfa173afc2' + } + + /** + * New metadata has been set for a `collection`. + */ + get asV9230(): {collection: number, data: Uint8Array, isFrozen: boolean} { + assert(this.isV9230) + return this._chain.decodeEvent(this.event) + } } export class UniquesCollectionThawedEvent { - private readonly _chain: Chain - private readonly event: Event - - constructor(ctx: EventContext) - constructor(ctx: ChainContext, event: Event) - constructor(ctx: EventContext, event?: Event) { - event = event || ctx.event - assert(event.name === 'Uniques.CollectionThawed') - this._chain = ctx._chain - this.event = event - } - - /** - * Some `collection` was thawed. - */ - get isV9230(): boolean { - return ( - this._chain.getEventHash('Uniques.CollectionThawed') === - 'a84ae2f0e555d689a7b5b0ee2914bd693902b07afc4f268377240f6ac92495cb' - ) - } - - /** - * Some `collection` was thawed. - */ - get asV9230(): { collection: number } { - assert(this.isV9230) - return this._chain.decodeEvent(this.event) - } + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Uniques.CollectionThawed') + this._chain = ctx._chain + this.event = event + } + + /** + * Some `collection` was thawed. + */ + get isV9230(): boolean { + return this._chain.getEventHash('Uniques.CollectionThawed') === 'a84ae2f0e555d689a7b5b0ee2914bd693902b07afc4f268377240f6ac92495cb' + } + + /** + * Some `collection` was thawed. + */ + get asV9230(): {collection: number} { + assert(this.isV9230) + return this._chain.decodeEvent(this.event) + } } export class UniquesCreatedEvent { - private readonly _chain: Chain - private readonly event: Event - - constructor(ctx: EventContext) - constructor(ctx: ChainContext, event: Event) - constructor(ctx: EventContext, event?: Event) { - event = event || ctx.event - assert(event.name === 'Uniques.Created') - this._chain = ctx._chain - this.event = event - } - - /** - * An asset class was created. \[ class, creator, owner \] - */ - get isV601(): boolean { - return ( - this._chain.getEventHash('Uniques.Created') === 'f968eb148e0dc7739feb64d5c72eea0de823dbf44259d08f9a6218f8117bf19a' - ) - } - - /** - * An asset class was created. \[ class, creator, owner \] - */ - get asV601(): [number, Uint8Array, Uint8Array] { - assert(this.isV601) - return this._chain.decodeEvent(this.event) - } - - /** - * An asset class was created. - */ - get isV700(): boolean { - return ( - this._chain.getEventHash('Uniques.Created') === '7f77877d6861fb103cb861e568c28c6112b4f0daecbb1931ca2b5d4e733fdacd' - ) - } - - /** - * An asset class was created. - */ - get asV700(): { class: number; creator: Uint8Array; owner: Uint8Array } { - assert(this.isV700) - return this._chain.decodeEvent(this.event) - } - - /** - * A `collection` was created. - */ - get isV9230(): boolean { - return ( - this._chain.getEventHash('Uniques.Created') === 'a5c293082b1f3ffb16eaecc5b8d430ca1bb8c7bd090079ebcefcbf303cbfec61' - ) - } - - /** - * A `collection` was created. - */ - get asV9230(): { collection: number; creator: Uint8Array; owner: Uint8Array } { - assert(this.isV9230) - return this._chain.decodeEvent(this.event) - } + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Uniques.Created') + this._chain = ctx._chain + this.event = event + } + + /** + * An asset class was created. \[ class, creator, owner \] + */ + get isV601(): boolean { + return this._chain.getEventHash('Uniques.Created') === 'f968eb148e0dc7739feb64d5c72eea0de823dbf44259d08f9a6218f8117bf19a' + } + + /** + * An asset class was created. \[ class, creator, owner \] + */ + get asV601(): [number, Uint8Array, Uint8Array] { + assert(this.isV601) + return this._chain.decodeEvent(this.event) + } + + /** + * An asset class was created. + */ + get isV700(): boolean { + return this._chain.getEventHash('Uniques.Created') === '7f77877d6861fb103cb861e568c28c6112b4f0daecbb1931ca2b5d4e733fdacd' + } + + /** + * An asset class was created. + */ + get asV700(): {class: number, creator: Uint8Array, owner: Uint8Array} { + assert(this.isV700) + return this._chain.decodeEvent(this.event) + } + + /** + * A `collection` was created. + */ + get isV9230(): boolean { + return this._chain.getEventHash('Uniques.Created') === 'a5c293082b1f3ffb16eaecc5b8d430ca1bb8c7bd090079ebcefcbf303cbfec61' + } + + /** + * A `collection` was created. + */ + get asV9230(): {collection: number, creator: Uint8Array, owner: Uint8Array} { + assert(this.isV9230) + return this._chain.decodeEvent(this.event) + } } export class UniquesDestroyedEvent { - private readonly _chain: Chain - private readonly event: Event - - constructor(ctx: EventContext) - constructor(ctx: ChainContext, event: Event) - constructor(ctx: EventContext, event?: Event) { - event = event || ctx.event - assert(event.name === 'Uniques.Destroyed') - this._chain = ctx._chain - this.event = event - } - - /** - * An asset `class` was destroyed. \[ class \] - */ - get isV601(): boolean { - return ( - this._chain.getEventHash('Uniques.Destroyed') === - '0a0f30b1ade5af5fade6413c605719d59be71340cf4884f65ee9858eb1c38f6c' - ) - } - - /** - * An asset `class` was destroyed. \[ class \] - */ - get asV601(): number { - assert(this.isV601) - return this._chain.decodeEvent(this.event) - } - - /** - * An asset `class` was destroyed. - */ - get isV700(): boolean { - return ( - this._chain.getEventHash('Uniques.Destroyed') === - '4f045c4df2d4b9045175427f6f6aa548cd3ad56207f700b68254d3b77d944310' - ) - } - - /** - * An asset `class` was destroyed. - */ - get asV700(): { class: number } { - assert(this.isV700) - return this._chain.decodeEvent(this.event) - } - - /** - * A `collection` was destroyed. - */ - get isV9230(): boolean { - return ( - this._chain.getEventHash('Uniques.Destroyed') === - 'a84ae2f0e555d689a7b5b0ee2914bd693902b07afc4f268377240f6ac92495cb' - ) - } - - /** - * A `collection` was destroyed. - */ - get asV9230(): { collection: number } { - assert(this.isV9230) - return this._chain.decodeEvent(this.event) - } + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Uniques.Destroyed') + this._chain = ctx._chain + this.event = event + } + + /** + * An asset `class` was destroyed. \[ class \] + */ + get isV601(): boolean { + return this._chain.getEventHash('Uniques.Destroyed') === '0a0f30b1ade5af5fade6413c605719d59be71340cf4884f65ee9858eb1c38f6c' + } + + /** + * An asset `class` was destroyed. \[ class \] + */ + get asV601(): number { + assert(this.isV601) + return this._chain.decodeEvent(this.event) + } + + /** + * An asset `class` was destroyed. + */ + get isV700(): boolean { + return this._chain.getEventHash('Uniques.Destroyed') === '4f045c4df2d4b9045175427f6f6aa548cd3ad56207f700b68254d3b77d944310' + } + + /** + * An asset `class` was destroyed. + */ + get asV700(): {class: number} { + assert(this.isV700) + return this._chain.decodeEvent(this.event) + } + + /** + * A `collection` was destroyed. + */ + get isV9230(): boolean { + return this._chain.getEventHash('Uniques.Destroyed') === 'a84ae2f0e555d689a7b5b0ee2914bd693902b07afc4f268377240f6ac92495cb' + } + + /** + * A `collection` was destroyed. + */ + get asV9230(): {collection: number} { + assert(this.isV9230) + return this._chain.decodeEvent(this.event) + } } export class UniquesForceCreatedEvent { - private readonly _chain: Chain - private readonly event: Event - - constructor(ctx: EventContext) - constructor(ctx: ChainContext, event: Event) - constructor(ctx: EventContext, event?: Event) { - event = event || ctx.event - assert(event.name === 'Uniques.ForceCreated') - this._chain = ctx._chain - this.event = event - } - - /** - * An asset class was force-created. \[ class, owner \] - */ - get isV601(): boolean { - return ( - this._chain.getEventHash('Uniques.ForceCreated') === - '0379562584d6426ccff49705dfa9dba95ad94215b772fd97d0ad0c4ca0001c12' - ) - } - - /** - * An asset class was force-created. \[ class, owner \] - */ - get asV601(): [number, Uint8Array] { - assert(this.isV601) - return this._chain.decodeEvent(this.event) - } - - /** - * An asset class was force-created. - */ - get isV700(): boolean { - return ( - this._chain.getEventHash('Uniques.ForceCreated') === - 'd51b7ff0e8d25eeb64fd1351f5eafbd20c22e12baddedd443f9831da21e235ea' - ) - } - - /** - * An asset class was force-created. - */ - get asV700(): { class: number; owner: Uint8Array } { - assert(this.isV700) - return this._chain.decodeEvent(this.event) - } - - /** - * A `collection` was force-created. - */ - get isV9230(): boolean { - return ( - this._chain.getEventHash('Uniques.ForceCreated') === - '6059bcf1dd7c48dc760f017d00a2c7c6719e745b3de9bde2046cbe26347c562f' - ) - } - - /** - * A `collection` was force-created. - */ - get asV9230(): { collection: number; owner: Uint8Array } { - assert(this.isV9230) - return this._chain.decodeEvent(this.event) - } + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Uniques.ForceCreated') + this._chain = ctx._chain + this.event = event + } + + /** + * An asset class was force-created. \[ class, owner \] + */ + get isV601(): boolean { + return this._chain.getEventHash('Uniques.ForceCreated') === '0379562584d6426ccff49705dfa9dba95ad94215b772fd97d0ad0c4ca0001c12' + } + + /** + * An asset class was force-created. \[ class, owner \] + */ + get asV601(): [number, Uint8Array] { + assert(this.isV601) + return this._chain.decodeEvent(this.event) + } + + /** + * An asset class was force-created. + */ + get isV700(): boolean { + return this._chain.getEventHash('Uniques.ForceCreated') === 'd51b7ff0e8d25eeb64fd1351f5eafbd20c22e12baddedd443f9831da21e235ea' + } + + /** + * An asset class was force-created. + */ + get asV700(): {class: number, owner: Uint8Array} { + assert(this.isV700) + return this._chain.decodeEvent(this.event) + } + + /** + * A `collection` was force-created. + */ + get isV9230(): boolean { + return this._chain.getEventHash('Uniques.ForceCreated') === '6059bcf1dd7c48dc760f017d00a2c7c6719e745b3de9bde2046cbe26347c562f' + } + + /** + * A `collection` was force-created. + */ + get asV9230(): {collection: number, owner: Uint8Array} { + assert(this.isV9230) + return this._chain.decodeEvent(this.event) + } } export class UniquesFrozenEvent { - private readonly _chain: Chain - private readonly event: Event - - constructor(ctx: EventContext) - constructor(ctx: ChainContext, event: Event) - constructor(ctx: EventContext, event?: Event) { - event = event || ctx.event - assert(event.name === 'Uniques.Frozen') - this._chain = ctx._chain - this.event = event - } - - /** - * Some asset `instance` was frozen. \[ class, instance \] - */ - get isV601(): boolean { - return ( - this._chain.getEventHash('Uniques.Frozen') === 'a09602e40984745a7411a1855af06d133893a422fd68f7bdc4fb6a56bf1a3645' - ) - } - - /** - * Some asset `instance` was frozen. \[ class, instance \] - */ - get asV601(): [number, number] { - assert(this.isV601) - return this._chain.decodeEvent(this.event) - } - - /** - * Some asset `instance` was frozen. - */ - get isV700(): boolean { - return ( - this._chain.getEventHash('Uniques.Frozen') === '4aec04ec96e3cd667bd16926634d063c18da9922e4d645f33692574e196c20dc' - ) - } - - /** - * Some asset `instance` was frozen. - */ - get asV700(): { class: number; instance: number } { - assert(this.isV700) - return this._chain.decodeEvent(this.event) - } - - /** - * Some `item` was frozen. - */ - get isV9230(): boolean { - return ( - this._chain.getEventHash('Uniques.Frozen') === 'ac39ace3905de6db862660444374575fb7ed5f403845b475c7f2addc21c71f91' - ) - } - - /** - * Some `item` was frozen. - */ - get asV9230(): { collection: number; item: number } { - assert(this.isV9230) - return this._chain.decodeEvent(this.event) - } + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Uniques.Frozen') + this._chain = ctx._chain + this.event = event + } + + /** + * Some asset `instance` was frozen. \[ class, instance \] + */ + get isV601(): boolean { + return this._chain.getEventHash('Uniques.Frozen') === 'a09602e40984745a7411a1855af06d133893a422fd68f7bdc4fb6a56bf1a3645' + } + + /** + * Some asset `instance` was frozen. \[ class, instance \] + */ + get asV601(): [number, number] { + assert(this.isV601) + return this._chain.decodeEvent(this.event) + } + + /** + * Some asset `instance` was frozen. + */ + get isV700(): boolean { + return this._chain.getEventHash('Uniques.Frozen') === '4aec04ec96e3cd667bd16926634d063c18da9922e4d645f33692574e196c20dc' + } + + /** + * Some asset `instance` was frozen. + */ + get asV700(): {class: number, instance: number} { + assert(this.isV700) + return this._chain.decodeEvent(this.event) + } + + /** + * Some `item` was frozen. + */ + get isV9230(): boolean { + return this._chain.getEventHash('Uniques.Frozen') === 'ac39ace3905de6db862660444374575fb7ed5f403845b475c7f2addc21c71f91' + } + + /** + * Some `item` was frozen. + */ + get asV9230(): {collection: number, item: number} { + assert(this.isV9230) + return this._chain.decodeEvent(this.event) + } } export class UniquesIssuedEvent { - private readonly _chain: Chain - private readonly event: Event - - constructor(ctx: EventContext) - constructor(ctx: ChainContext, event: Event) - constructor(ctx: EventContext, event?: Event) { - event = event || ctx.event - assert(event.name === 'Uniques.Issued') - this._chain = ctx._chain - this.event = event - } - - /** - * An asset `instance` was issued. \[ class, instance, owner \] - */ - get isV601(): boolean { - return ( - this._chain.getEventHash('Uniques.Issued') === '7b53bb12306431c6ff23a3ea3466183ed1c7f4ecb417f6e8467ae0c63cbc2f88' - ) - } - - /** - * An asset `instance` was issued. \[ class, instance, owner \] - */ - get asV601(): [number, number, Uint8Array] { - assert(this.isV601) - return this._chain.decodeEvent(this.event) - } - - /** - * An asset `instance` was issued. - */ - get isV700(): boolean { - return ( - this._chain.getEventHash('Uniques.Issued') === '448723f6c40490fe04ab8e6d9e382432b7ce5c075d05af60c076b9f6a8a9e510' - ) - } - - /** - * An asset `instance` was issued. - */ - get asV700(): { class: number; instance: number; owner: Uint8Array } { - assert(this.isV700) - return this._chain.decodeEvent(this.event) - } - - /** - * An `item` was issued. - */ - get isV9230(): boolean { - return ( - this._chain.getEventHash('Uniques.Issued') === '281c96f4233cbe042ed549cfca1fafa833d625f8d832ed29682ac34cdceb017d' - ) - } - - /** - * An `item` was issued. - */ - get asV9230(): { collection: number; item: number; owner: Uint8Array } { - assert(this.isV9230) - return this._chain.decodeEvent(this.event) - } + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Uniques.Issued') + this._chain = ctx._chain + this.event = event + } + + /** + * An asset `instance` was issued. \[ class, instance, owner \] + */ + get isV601(): boolean { + return this._chain.getEventHash('Uniques.Issued') === '7b53bb12306431c6ff23a3ea3466183ed1c7f4ecb417f6e8467ae0c63cbc2f88' + } + + /** + * An asset `instance` was issued. \[ class, instance, owner \] + */ + get asV601(): [number, number, Uint8Array] { + assert(this.isV601) + return this._chain.decodeEvent(this.event) + } + + /** + * An asset `instance` was issued. + */ + get isV700(): boolean { + return this._chain.getEventHash('Uniques.Issued') === '448723f6c40490fe04ab8e6d9e382432b7ce5c075d05af60c076b9f6a8a9e510' + } + + /** + * An asset `instance` was issued. + */ + get asV700(): {class: number, instance: number, owner: Uint8Array} { + assert(this.isV700) + return this._chain.decodeEvent(this.event) + } + + /** + * An `item` was issued. + */ + get isV9230(): boolean { + return this._chain.getEventHash('Uniques.Issued') === '281c96f4233cbe042ed549cfca1fafa833d625f8d832ed29682ac34cdceb017d' + } + + /** + * An `item` was issued. + */ + get asV9230(): {collection: number, item: number, owner: Uint8Array} { + assert(this.isV9230) + return this._chain.decodeEvent(this.event) + } } export class UniquesItemBoughtEvent { - private readonly _chain: Chain - private readonly event: Event - - constructor(ctx: EventContext) - constructor(ctx: ChainContext, event: Event) - constructor(ctx: EventContext, event?: Event) { - event = event || ctx.event - assert(event.name === 'Uniques.ItemBought') - this._chain = ctx._chain - this.event = event - } - - /** - * An item was bought. - */ - get isV9270(): boolean { - return ( - this._chain.getEventHash('Uniques.ItemBought') === - 'db915144f3a96c73a3031d37c874507dcac06fd77bca9962f672bc9bfb557489' - ) - } - - /** - * An item was bought. - */ - get asV9270(): { collection: number; item: number; price: bigint; seller: Uint8Array; buyer: Uint8Array } { - assert(this.isV9270) - return this._chain.decodeEvent(this.event) - } + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Uniques.ItemBought') + this._chain = ctx._chain + this.event = event + } + + /** + * An item was bought. + */ + get isV9270(): boolean { + return this._chain.getEventHash('Uniques.ItemBought') === 'db915144f3a96c73a3031d37c874507dcac06fd77bca9962f672bc9bfb557489' + } + + /** + * An item was bought. + */ + get asV9270(): {collection: number, item: number, price: bigint, seller: Uint8Array, buyer: Uint8Array} { + assert(this.isV9270) + return this._chain.decodeEvent(this.event) + } } export class UniquesItemPriceRemovedEvent { - private readonly _chain: Chain - private readonly event: Event - - constructor(ctx: EventContext) - constructor(ctx: ChainContext, event: Event) - constructor(ctx: EventContext, event?: Event) { - event = event || ctx.event - assert(event.name === 'Uniques.ItemPriceRemoved') - this._chain = ctx._chain - this.event = event - } - - /** - * The price for the instance was removed. - */ - get isV9270(): boolean { - return ( - this._chain.getEventHash('Uniques.ItemPriceRemoved') === - 'ac39ace3905de6db862660444374575fb7ed5f403845b475c7f2addc21c71f91' - ) - } - - /** - * The price for the instance was removed. - */ - get asV9270(): { collection: number; item: number } { - assert(this.isV9270) - return this._chain.decodeEvent(this.event) - } + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Uniques.ItemPriceRemoved') + this._chain = ctx._chain + this.event = event + } + + /** + * The price for the instance was removed. + */ + get isV9270(): boolean { + return this._chain.getEventHash('Uniques.ItemPriceRemoved') === 'ac39ace3905de6db862660444374575fb7ed5f403845b475c7f2addc21c71f91' + } + + /** + * The price for the instance was removed. + */ + get asV9270(): {collection: number, item: number} { + assert(this.isV9270) + return this._chain.decodeEvent(this.event) + } } export class UniquesItemPriceSetEvent { - private readonly _chain: Chain - private readonly event: Event - - constructor(ctx: EventContext) - constructor(ctx: ChainContext, event: Event) - constructor(ctx: EventContext, event?: Event) { - event = event || ctx.event - assert(event.name === 'Uniques.ItemPriceSet') - this._chain = ctx._chain - this.event = event - } - - /** - * The price was set for the instance. - */ - get isV9270(): boolean { - return ( - this._chain.getEventHash('Uniques.ItemPriceSet') === - '10d4911c332080c5a5c1e6c248347d1174817ab96906747e2c40df18c5381944' - ) - } - - /** - * The price was set for the instance. - */ - get asV9270(): { collection: number; item: number; price: bigint; whitelistedBuyer: Uint8Array | undefined } { - assert(this.isV9270) - return this._chain.decodeEvent(this.event) - } + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Uniques.ItemPriceSet') + this._chain = ctx._chain + this.event = event + } + + /** + * The price was set for the instance. + */ + get isV9270(): boolean { + return this._chain.getEventHash('Uniques.ItemPriceSet') === '10d4911c332080c5a5c1e6c248347d1174817ab96906747e2c40df18c5381944' + } + + /** + * The price was set for the instance. + */ + get asV9270(): {collection: number, item: number, price: bigint, whitelistedBuyer: (Uint8Array | undefined)} { + assert(this.isV9270) + return this._chain.decodeEvent(this.event) + } } export class UniquesMetadataClearedEvent { - private readonly _chain: Chain - private readonly event: Event - - constructor(ctx: EventContext) - constructor(ctx: ChainContext, event: Event) - constructor(ctx: EventContext, event?: Event) { - event = event || ctx.event - assert(event.name === 'Uniques.MetadataCleared') - this._chain = ctx._chain - this.event = event - } - - /** - * Metadata has been cleared for an asset instance. \[ class, instance \] - */ - get isV601(): boolean { - return ( - this._chain.getEventHash('Uniques.MetadataCleared') === - 'a09602e40984745a7411a1855af06d133893a422fd68f7bdc4fb6a56bf1a3645' - ) - } - - /** - * Metadata has been cleared for an asset instance. \[ class, instance \] - */ - get asV601(): [number, number] { - assert(this.isV601) - return this._chain.decodeEvent(this.event) - } - - /** - * Metadata has been cleared for an asset instance. - */ - get isV700(): boolean { - return ( - this._chain.getEventHash('Uniques.MetadataCleared') === - '4aec04ec96e3cd667bd16926634d063c18da9922e4d645f33692574e196c20dc' - ) - } - - /** - * Metadata has been cleared for an asset instance. - */ - get asV700(): { class: number; instance: number } { - assert(this.isV700) - return this._chain.decodeEvent(this.event) - } - - /** - * Metadata has been cleared for an item. - */ - get isV9230(): boolean { - return ( - this._chain.getEventHash('Uniques.MetadataCleared') === - 'ac39ace3905de6db862660444374575fb7ed5f403845b475c7f2addc21c71f91' - ) - } - - /** - * Metadata has been cleared for an item. - */ - get asV9230(): { collection: number; item: number } { - assert(this.isV9230) - return this._chain.decodeEvent(this.event) - } + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Uniques.MetadataCleared') + this._chain = ctx._chain + this.event = event + } + + /** + * Metadata has been cleared for an asset instance. \[ class, instance \] + */ + get isV601(): boolean { + return this._chain.getEventHash('Uniques.MetadataCleared') === 'a09602e40984745a7411a1855af06d133893a422fd68f7bdc4fb6a56bf1a3645' + } + + /** + * Metadata has been cleared for an asset instance. \[ class, instance \] + */ + get asV601(): [number, number] { + assert(this.isV601) + return this._chain.decodeEvent(this.event) + } + + /** + * Metadata has been cleared for an asset instance. + */ + get isV700(): boolean { + return this._chain.getEventHash('Uniques.MetadataCleared') === '4aec04ec96e3cd667bd16926634d063c18da9922e4d645f33692574e196c20dc' + } + + /** + * Metadata has been cleared for an asset instance. + */ + get asV700(): {class: number, instance: number} { + assert(this.isV700) + return this._chain.decodeEvent(this.event) + } + + /** + * Metadata has been cleared for an item. + */ + get isV9230(): boolean { + return this._chain.getEventHash('Uniques.MetadataCleared') === 'ac39ace3905de6db862660444374575fb7ed5f403845b475c7f2addc21c71f91' + } + + /** + * Metadata has been cleared for an item. + */ + get asV9230(): {collection: number, item: number} { + assert(this.isV9230) + return this._chain.decodeEvent(this.event) + } } export class UniquesMetadataSetEvent { - private readonly _chain: Chain - private readonly event: Event - - constructor(ctx: EventContext) - constructor(ctx: ChainContext, event: Event) - constructor(ctx: EventContext, event?: Event) { - event = event || ctx.event - assert(event.name === 'Uniques.MetadataSet') - this._chain = ctx._chain - this.event = event - } - - /** - * New metadata has been set for an asset instance. - * \[ class, instance, data, is_frozen \] - */ - get isV601(): boolean { - return ( - this._chain.getEventHash('Uniques.MetadataSet') === - '7895150acb61111b7c6318ded185579b696175877e3d9b7bae2664d131eb3e65' - ) - } - - /** - * New metadata has been set for an asset instance. - * \[ class, instance, data, is_frozen \] - */ - get asV601(): [number, number, Uint8Array, boolean] { - assert(this.isV601) - return this._chain.decodeEvent(this.event) - } - - /** - * New metadata has been set for an asset instance. - */ - get isV700(): boolean { - return ( - this._chain.getEventHash('Uniques.MetadataSet') === - '8d2f67e787668073bdb66a4b7bbba97ea22da0860f46bce7884b446fd055419a' - ) - } - - /** - * New metadata has been set for an asset instance. - */ - get asV700(): { class: number; instance: number; data: Uint8Array; isFrozen: boolean } { - assert(this.isV700) - return this._chain.decodeEvent(this.event) - } - - /** - * New metadata has been set for an item. - */ - get isV9230(): boolean { - return ( - this._chain.getEventHash('Uniques.MetadataSet') === - 'dc2370253c17fe69445af313af0113a31f244cc51324e5a3b4b0b98804f91a6f' - ) - } - - /** - * New metadata has been set for an item. - */ - get asV9230(): { collection: number; item: number; data: Uint8Array; isFrozen: boolean } { - assert(this.isV9230) - return this._chain.decodeEvent(this.event) - } + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Uniques.MetadataSet') + this._chain = ctx._chain + this.event = event + } + + /** + * New metadata has been set for an asset instance. + * \[ class, instance, data, is_frozen \] + */ + get isV601(): boolean { + return this._chain.getEventHash('Uniques.MetadataSet') === '7895150acb61111b7c6318ded185579b696175877e3d9b7bae2664d131eb3e65' + } + + /** + * New metadata has been set for an asset instance. + * \[ class, instance, data, is_frozen \] + */ + get asV601(): [number, number, Uint8Array, boolean] { + assert(this.isV601) + return this._chain.decodeEvent(this.event) + } + + /** + * New metadata has been set for an asset instance. + */ + get isV700(): boolean { + return this._chain.getEventHash('Uniques.MetadataSet') === '8d2f67e787668073bdb66a4b7bbba97ea22da0860f46bce7884b446fd055419a' + } + + /** + * New metadata has been set for an asset instance. + */ + get asV700(): {class: number, instance: number, data: Uint8Array, isFrozen: boolean} { + assert(this.isV700) + return this._chain.decodeEvent(this.event) + } + + /** + * New metadata has been set for an item. + */ + get isV9230(): boolean { + return this._chain.getEventHash('Uniques.MetadataSet') === 'dc2370253c17fe69445af313af0113a31f244cc51324e5a3b4b0b98804f91a6f' + } + + /** + * New metadata has been set for an item. + */ + get asV9230(): {collection: number, item: number, data: Uint8Array, isFrozen: boolean} { + assert(this.isV9230) + return this._chain.decodeEvent(this.event) + } } export class UniquesOwnerChangedEvent { - private readonly _chain: Chain - private readonly event: Event - - constructor(ctx: EventContext) - constructor(ctx: ChainContext, event: Event) - constructor(ctx: EventContext, event?: Event) { - event = event || ctx.event - assert(event.name === 'Uniques.OwnerChanged') - this._chain = ctx._chain - this.event = event - } - - /** - * The owner changed \[ class, new_owner \] - */ - get isV601(): boolean { - return ( - this._chain.getEventHash('Uniques.OwnerChanged') === - '0379562584d6426ccff49705dfa9dba95ad94215b772fd97d0ad0c4ca0001c12' - ) - } - - /** - * The owner changed \[ class, new_owner \] - */ - get asV601(): [number, Uint8Array] { - assert(this.isV601) - return this._chain.decodeEvent(this.event) - } - - /** - * The owner changed. - */ - get isV700(): boolean { - return ( - this._chain.getEventHash('Uniques.OwnerChanged') === - '7f21331ba73970553e198c5598e55e9857317b38adaa7f293e914882bdd7385c' - ) - } - - /** - * The owner changed. - */ - get asV700(): { class: number; newOwner: Uint8Array } { - assert(this.isV700) - return this._chain.decodeEvent(this.event) - } - - /** - * The owner changed. - */ - get isV9230(): boolean { - return ( - this._chain.getEventHash('Uniques.OwnerChanged') === - '0331b0b161c2f2db690f574540ade7765af19f5306dc65443561fbaa5825f323' - ) - } - - /** - * The owner changed. - */ - get asV9230(): { collection: number; newOwner: Uint8Array } { - assert(this.isV9230) - return this._chain.decodeEvent(this.event) - } + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Uniques.OwnerChanged') + this._chain = ctx._chain + this.event = event + } + + /** + * The owner changed \[ class, new_owner \] + */ + get isV601(): boolean { + return this._chain.getEventHash('Uniques.OwnerChanged') === '0379562584d6426ccff49705dfa9dba95ad94215b772fd97d0ad0c4ca0001c12' + } + + /** + * The owner changed \[ class, new_owner \] + */ + get asV601(): [number, Uint8Array] { + assert(this.isV601) + return this._chain.decodeEvent(this.event) + } + + /** + * The owner changed. + */ + get isV700(): boolean { + return this._chain.getEventHash('Uniques.OwnerChanged') === '7f21331ba73970553e198c5598e55e9857317b38adaa7f293e914882bdd7385c' + } + + /** + * The owner changed. + */ + get asV700(): {class: number, newOwner: Uint8Array} { + assert(this.isV700) + return this._chain.decodeEvent(this.event) + } + + /** + * The owner changed. + */ + get isV9230(): boolean { + return this._chain.getEventHash('Uniques.OwnerChanged') === '0331b0b161c2f2db690f574540ade7765af19f5306dc65443561fbaa5825f323' + } + + /** + * The owner changed. + */ + get asV9230(): {collection: number, newOwner: Uint8Array} { + assert(this.isV9230) + return this._chain.decodeEvent(this.event) + } } export class UniquesOwnershipAcceptanceChangedEvent { - private readonly _chain: Chain - private readonly event: Event - - constructor(ctx: EventContext) - constructor(ctx: ChainContext, event: Event) - constructor(ctx: EventContext, event?: Event) { - event = event || ctx.event - assert(event.name === 'Uniques.OwnershipAcceptanceChanged') - this._chain = ctx._chain - this.event = event - } - - /** - * Ownership acceptance has changed for an account. - */ - get isV900(): boolean { - return ( - this._chain.getEventHash('Uniques.OwnershipAcceptanceChanged') === - '78fde0ff8f56c4ebcc47231a34e394471cbf03f4b56f9fa6854cecafab37242d' - ) - } - - /** - * Ownership acceptance has changed for an account. - */ - get asV900(): { who: Uint8Array; maybeClass: number | undefined } { - assert(this.isV900) - return this._chain.decodeEvent(this.event) - } - - /** - * Ownership acceptance has changed for an account. - */ - get isV9230(): boolean { - return ( - this._chain.getEventHash('Uniques.OwnershipAcceptanceChanged') === - '62f0a146ea419b03ef3bb5c912782af0253639ca8fc47ff318396bedef2230cc' - ) - } - - /** - * Ownership acceptance has changed for an account. - */ - get asV9230(): { who: Uint8Array; maybeCollection: number | undefined } { - assert(this.isV9230) - return this._chain.decodeEvent(this.event) - } + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Uniques.OwnershipAcceptanceChanged') + this._chain = ctx._chain + this.event = event + } + + /** + * Ownership acceptance has changed for an account. + */ + get isV900(): boolean { + return this._chain.getEventHash('Uniques.OwnershipAcceptanceChanged') === '78fde0ff8f56c4ebcc47231a34e394471cbf03f4b56f9fa6854cecafab37242d' + } + + /** + * Ownership acceptance has changed for an account. + */ + get asV900(): {who: Uint8Array, maybeClass: (number | undefined)} { + assert(this.isV900) + return this._chain.decodeEvent(this.event) + } + + /** + * Ownership acceptance has changed for an account. + */ + get isV9230(): boolean { + return this._chain.getEventHash('Uniques.OwnershipAcceptanceChanged') === '62f0a146ea419b03ef3bb5c912782af0253639ca8fc47ff318396bedef2230cc' + } + + /** + * Ownership acceptance has changed for an account. + */ + get asV9230(): {who: Uint8Array, maybeCollection: (number | undefined)} { + assert(this.isV9230) + return this._chain.decodeEvent(this.event) + } } export class UniquesTeamChangedEvent { - private readonly _chain: Chain - private readonly event: Event - - constructor(ctx: EventContext) - constructor(ctx: ChainContext, event: Event) - constructor(ctx: EventContext, event?: Event) { - event = event || ctx.event - assert(event.name === 'Uniques.TeamChanged') - this._chain = ctx._chain - this.event = event - } - - /** - * The management team changed \[ class, issuer, admin, freezer \] - */ - get isV601(): boolean { - return ( - this._chain.getEventHash('Uniques.TeamChanged') === - '608cf8b84887966db26c958a6b826fd41d8e098263ce7eaae9a421f1f8b1bd56' - ) - } - - /** - * The management team changed \[ class, issuer, admin, freezer \] - */ - get asV601(): [number, Uint8Array, Uint8Array, Uint8Array] { - assert(this.isV601) - return this._chain.decodeEvent(this.event) - } - - /** - * The management team changed. - */ - get isV700(): boolean { - return ( - this._chain.getEventHash('Uniques.TeamChanged') === - 'ed55b7c512c680f9a9b8f35a0e603e101cd439e8b1c07373e1b6b2ca40d032f7' - ) - } - - /** - * The management team changed. - */ - get asV700(): { class: number; issuer: Uint8Array; admin: Uint8Array; freezer: Uint8Array } { - assert(this.isV700) - return this._chain.decodeEvent(this.event) - } - - /** - * The management team changed. - */ - get isV9230(): boolean { - return ( - this._chain.getEventHash('Uniques.TeamChanged') === - '152cd89e42995f09fd841e2eeec18a6a0ca02740e481dc98e45b182742b5172e' - ) - } - - /** - * The management team changed. - */ - get asV9230(): { collection: number; issuer: Uint8Array; admin: Uint8Array; freezer: Uint8Array } { - assert(this.isV9230) - return this._chain.decodeEvent(this.event) - } + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Uniques.TeamChanged') + this._chain = ctx._chain + this.event = event + } + + /** + * The management team changed \[ class, issuer, admin, freezer \] + */ + get isV601(): boolean { + return this._chain.getEventHash('Uniques.TeamChanged') === '608cf8b84887966db26c958a6b826fd41d8e098263ce7eaae9a421f1f8b1bd56' + } + + /** + * The management team changed \[ class, issuer, admin, freezer \] + */ + get asV601(): [number, Uint8Array, Uint8Array, Uint8Array] { + assert(this.isV601) + return this._chain.decodeEvent(this.event) + } + + /** + * The management team changed. + */ + get isV700(): boolean { + return this._chain.getEventHash('Uniques.TeamChanged') === 'ed55b7c512c680f9a9b8f35a0e603e101cd439e8b1c07373e1b6b2ca40d032f7' + } + + /** + * The management team changed. + */ + get asV700(): {class: number, issuer: Uint8Array, admin: Uint8Array, freezer: Uint8Array} { + assert(this.isV700) + return this._chain.decodeEvent(this.event) + } + + /** + * The management team changed. + */ + get isV9230(): boolean { + return this._chain.getEventHash('Uniques.TeamChanged') === '152cd89e42995f09fd841e2eeec18a6a0ca02740e481dc98e45b182742b5172e' + } + + /** + * The management team changed. + */ + get asV9230(): {collection: number, issuer: Uint8Array, admin: Uint8Array, freezer: Uint8Array} { + assert(this.isV9230) + return this._chain.decodeEvent(this.event) + } } export class UniquesThawedEvent { - private readonly _chain: Chain - private readonly event: Event - - constructor(ctx: EventContext) - constructor(ctx: ChainContext, event: Event) - constructor(ctx: EventContext, event?: Event) { - event = event || ctx.event - assert(event.name === 'Uniques.Thawed') - this._chain = ctx._chain - this.event = event - } - - /** - * Some asset `instance` was thawed. \[ class, instance \] - */ - get isV601(): boolean { - return ( - this._chain.getEventHash('Uniques.Thawed') === 'a09602e40984745a7411a1855af06d133893a422fd68f7bdc4fb6a56bf1a3645' - ) - } - - /** - * Some asset `instance` was thawed. \[ class, instance \] - */ - get asV601(): [number, number] { - assert(this.isV601) - return this._chain.decodeEvent(this.event) - } - - /** - * Some asset `instance` was thawed. - */ - get isV700(): boolean { - return ( - this._chain.getEventHash('Uniques.Thawed') === '4aec04ec96e3cd667bd16926634d063c18da9922e4d645f33692574e196c20dc' - ) - } - - /** - * Some asset `instance` was thawed. - */ - get asV700(): { class: number; instance: number } { - assert(this.isV700) - return this._chain.decodeEvent(this.event) - } - - /** - * Some `item` was thawed. - */ - get isV9230(): boolean { - return ( - this._chain.getEventHash('Uniques.Thawed') === 'ac39ace3905de6db862660444374575fb7ed5f403845b475c7f2addc21c71f91' - ) - } - - /** - * Some `item` was thawed. - */ - get asV9230(): { collection: number; item: number } { - assert(this.isV9230) - return this._chain.decodeEvent(this.event) - } + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Uniques.Thawed') + this._chain = ctx._chain + this.event = event + } + + /** + * Some asset `instance` was thawed. \[ class, instance \] + */ + get isV601(): boolean { + return this._chain.getEventHash('Uniques.Thawed') === 'a09602e40984745a7411a1855af06d133893a422fd68f7bdc4fb6a56bf1a3645' + } + + /** + * Some asset `instance` was thawed. \[ class, instance \] + */ + get asV601(): [number, number] { + assert(this.isV601) + return this._chain.decodeEvent(this.event) + } + + /** + * Some asset `instance` was thawed. + */ + get isV700(): boolean { + return this._chain.getEventHash('Uniques.Thawed') === '4aec04ec96e3cd667bd16926634d063c18da9922e4d645f33692574e196c20dc' + } + + /** + * Some asset `instance` was thawed. + */ + get asV700(): {class: number, instance: number} { + assert(this.isV700) + return this._chain.decodeEvent(this.event) + } + + /** + * Some `item` was thawed. + */ + get isV9230(): boolean { + return this._chain.getEventHash('Uniques.Thawed') === 'ac39ace3905de6db862660444374575fb7ed5f403845b475c7f2addc21c71f91' + } + + /** + * Some `item` was thawed. + */ + get asV9230(): {collection: number, item: number} { + assert(this.isV9230) + return this._chain.decodeEvent(this.event) + } } export class UniquesTransferredEvent { - private readonly _chain: Chain - private readonly event: Event - - constructor(ctx: EventContext) - constructor(ctx: ChainContext, event: Event) - constructor(ctx: EventContext, event?: Event) { - event = event || ctx.event - assert(event.name === 'Uniques.Transferred') - this._chain = ctx._chain - this.event = event - } - - /** - * An asset `instance` was transferred. \[ class, instance, from, to \] - */ - get isV601(): boolean { - return ( - this._chain.getEventHash('Uniques.Transferred') === - '5d3fa4f2b87c3626df0e27d53288bc8519502854bcd4a4f83b5b48102417e8d1' - ) - } - - /** - * An asset `instance` was transferred. \[ class, instance, from, to \] - */ - get asV601(): [number, number, Uint8Array, Uint8Array] { - assert(this.isV601) - return this._chain.decodeEvent(this.event) - } - - /** - * An asset `instance` was transferred. - */ - get isV700(): boolean { - return ( - this._chain.getEventHash('Uniques.Transferred') === - '62805427bf03dcd5763c135e667e4d08319c26623a7eecd16e8463cac99132b0' - ) - } - - /** - * An asset `instance` was transferred. - */ - get asV700(): { class: number; instance: number; from: Uint8Array; to: Uint8Array } { - assert(this.isV700) - return this._chain.decodeEvent(this.event) - } - - /** - * An `item` was transferred. - */ - get isV9230(): boolean { - return ( - this._chain.getEventHash('Uniques.Transferred') === - 'ac8c1c5a1df2a464e3447d13d6c43a813112a33c144f93775b934b08c086bf7a' - ) - } - - /** - * An `item` was transferred. - */ - get asV9230(): { collection: number; item: number; from: Uint8Array; to: Uint8Array } { - assert(this.isV9230) - return this._chain.decodeEvent(this.event) - } + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Uniques.Transferred') + this._chain = ctx._chain + this.event = event + } + + /** + * An asset `instance` was transferred. \[ class, instance, from, to \] + */ + get isV601(): boolean { + return this._chain.getEventHash('Uniques.Transferred') === '5d3fa4f2b87c3626df0e27d53288bc8519502854bcd4a4f83b5b48102417e8d1' + } + + /** + * An asset `instance` was transferred. \[ class, instance, from, to \] + */ + get asV601(): [number, number, Uint8Array, Uint8Array] { + assert(this.isV601) + return this._chain.decodeEvent(this.event) + } + + /** + * An asset `instance` was transferred. + */ + get isV700(): boolean { + return this._chain.getEventHash('Uniques.Transferred') === '62805427bf03dcd5763c135e667e4d08319c26623a7eecd16e8463cac99132b0' + } + + /** + * An asset `instance` was transferred. + */ + get asV700(): {class: number, instance: number, from: Uint8Array, to: Uint8Array} { + assert(this.isV700) + return this._chain.decodeEvent(this.event) + } + + /** + * An `item` was transferred. + */ + get isV9230(): boolean { + return this._chain.getEventHash('Uniques.Transferred') === 'ac8c1c5a1df2a464e3447d13d6c43a813112a33c144f93775b934b08c086bf7a' + } + + /** + * An `item` was transferred. + */ + get asV9230(): {collection: number, item: number, from: Uint8Array, to: Uint8Array} { + assert(this.isV9230) + return this._chain.decodeEvent(this.event) + } } diff --git a/src/types/statemint/storage.ts b/src/types/statemint/storage.ts index e8c8840..bd3b859 100644 --- a/src/types/statemint/storage.ts +++ b/src/types/statemint/storage.ts @@ -1,128 +1,124 @@ -import assert from 'node:assert' -import { Block, BlockContext, Chain, ChainContext, Option, Result, StorageBase } from './support' +import assert from 'assert' +import {Block, BlockContext, Chain, ChainContext, Option, Result, StorageBase} from './support' import * as v601 from './v601' import * as v9230 from './v9230' export class UniquesClassStorage extends StorageBase { - protected getPrefix() { - return 'Uniques' - } + protected getPrefix() { + return 'Uniques' + } - protected getName() { - return 'Class' - } + protected getName() { + return 'Class' + } - /** - * Details of an asset class. - */ - get isV601(): boolean { - return this.getTypeHash() === '1e1179cfd57216efc5c1637c0aa0a4ae6eff2649845c501f9d404542ba254ed4' - } + /** + * Details of an asset class. + */ + get isV601(): boolean { + return this.getTypeHash() === '1e1179cfd57216efc5c1637c0aa0a4ae6eff2649845c501f9d404542ba254ed4' + } - /** - * Details of an asset class. - */ - get asV601(): UniquesClassStorageV601 { - assert(this.isV601) - return this as any - } + /** + * Details of an asset class. + */ + get asV601(): UniquesClassStorageV601 { + assert(this.isV601) + return this as any + } - /** - * Details of a collection. - */ - get isV9230(): boolean { - return this.getTypeHash() === '7d8bf59996f2d3901df3ccd9b19fb3c13d435bb2d2b67820e7ee13c594f1cb1b' - } + /** + * Details of a collection. + */ + get isV9230(): boolean { + return this.getTypeHash() === '7d8bf59996f2d3901df3ccd9b19fb3c13d435bb2d2b67820e7ee13c594f1cb1b' + } - /** - * Details of a collection. - */ - get asV9230(): UniquesClassStorageV9230 { - assert(this.isV9230) - return this as any - } + /** + * Details of a collection. + */ + get asV9230(): UniquesClassStorageV9230 { + assert(this.isV9230) + return this as any + } } /** * Details of an asset class. */ export interface UniquesClassStorageV601 { - get(key: number): Promise - getAll(): Promise - getMany(keys: number[]): Promise<(v601.ClassDetails | undefined)[]> - getKeys(): Promise - getKeys(key: number): Promise - getKeysPaged(pageSize: number): AsyncIterable - getKeysPaged(pageSize: number, key: number): AsyncIterable - getPairs(): Promise<[k: number, v: v601.ClassDetails][]> - getPairs(key: number): Promise<[k: number, v: v601.ClassDetails][]> - getPairsPaged(pageSize: number): AsyncIterable<[k: number, v: v601.ClassDetails][]> - getPairsPaged(pageSize: number, key: number): AsyncIterable<[k: number, v: v601.ClassDetails][]> + get(key: number): Promise<(v601.ClassDetails | undefined)> + getAll(): Promise + getMany(keys: number[]): Promise<(v601.ClassDetails | undefined)[]> + getKeys(): Promise + getKeys(key: number): Promise + getKeysPaged(pageSize: number): AsyncIterable + getKeysPaged(pageSize: number, key: number): AsyncIterable + getPairs(): Promise<[k: number, v: v601.ClassDetails][]> + getPairs(key: number): Promise<[k: number, v: v601.ClassDetails][]> + getPairsPaged(pageSize: number): AsyncIterable<[k: number, v: v601.ClassDetails][]> + getPairsPaged(pageSize: number, key: number): AsyncIterable<[k: number, v: v601.ClassDetails][]> } /** * Details of a collection. */ export interface UniquesClassStorageV9230 { - get(key: number): Promise - getAll(): Promise - getMany(keys: number[]): Promise<(v9230.CollectionDetails | undefined)[]> - getKeys(): Promise - getKeys(key: number): Promise - getKeysPaged(pageSize: number): AsyncIterable - getKeysPaged(pageSize: number, key: number): AsyncIterable - getPairs(): Promise<[k: number, v: v9230.CollectionDetails][]> - getPairs(key: number): Promise<[k: number, v: v9230.CollectionDetails][]> - getPairsPaged(pageSize: number): AsyncIterable<[k: number, v: v9230.CollectionDetails][]> - getPairsPaged(pageSize: number, key: number): AsyncIterable<[k: number, v: v9230.CollectionDetails][]> + get(key: number): Promise<(v9230.CollectionDetails | undefined)> + getAll(): Promise + getMany(keys: number[]): Promise<(v9230.CollectionDetails | undefined)[]> + getKeys(): Promise + getKeys(key: number): Promise + getKeysPaged(pageSize: number): AsyncIterable + getKeysPaged(pageSize: number, key: number): AsyncIterable + getPairs(): Promise<[k: number, v: v9230.CollectionDetails][]> + getPairs(key: number): Promise<[k: number, v: v9230.CollectionDetails][]> + getPairsPaged(pageSize: number): AsyncIterable<[k: number, v: v9230.CollectionDetails][]> + getPairsPaged(pageSize: number, key: number): AsyncIterable<[k: number, v: v9230.CollectionDetails][]> } export class UniquesInstanceMetadataOfStorage extends StorageBase { - protected getPrefix() { - return 'Uniques' - } + protected getPrefix() { + return 'Uniques' + } - protected getName() { - return 'InstanceMetadataOf' - } + protected getName() { + return 'InstanceMetadataOf' + } - /** - * Metadata of an asset instance. - */ - get isV601(): boolean { - return this.getTypeHash() === '36776a13816cab10cc18dd56fcac5cb2817f77f7b82bf520cc24f74ac55e6f6d' - } + /** + * Metadata of an asset instance. + */ + get isV601(): boolean { + return this.getTypeHash() === '36776a13816cab10cc18dd56fcac5cb2817f77f7b82bf520cc24f74ac55e6f6d' + } - /** - * Metadata of an asset instance. - */ - get asV601(): UniquesInstanceMetadataOfStorageV601 { - assert(this.isV601) - return this as any - } + /** + * Metadata of an asset instance. + */ + get asV601(): UniquesInstanceMetadataOfStorageV601 { + assert(this.isV601) + return this as any + } } /** * Metadata of an asset instance. */ export interface UniquesInstanceMetadataOfStorageV601 { - get(key1: number, key2: number): Promise - getAll(): Promise - getMany(keys: [number, number][]): Promise<(v601.InstanceMetadata | undefined)[]> - getKeys(): Promise<[number, number][]> - getKeys(key1: number): Promise<[number, number][]> - getKeys(key1: number, key2: number): Promise<[number, number][]> - getKeysPaged(pageSize: number): AsyncIterable<[number, number][]> - getKeysPaged(pageSize: number, key1: number): AsyncIterable<[number, number][]> - getKeysPaged(pageSize: number, key1: number, key2: number): AsyncIterable<[number, number][]> - getPairs(): Promise<[k: [number, number], v: v601.InstanceMetadata][]> - getPairs(key1: number): Promise<[k: [number, number], v: v601.InstanceMetadata][]> - getPairs(key1: number, key2: number): Promise<[k: [number, number], v: v601.InstanceMetadata][]> - getPairsPaged(pageSize: number): AsyncIterable<[k: [number, number], v: v601.InstanceMetadata][]> - getPairsPaged(pageSize: number, key1: number): AsyncIterable<[k: [number, number], v: v601.InstanceMetadata][]> - getPairsPaged( - pageSize: number, - key1: number, - key2: number - ): AsyncIterable<[k: [number, number], v: v601.InstanceMetadata][]> + get(key1: number, key2: number): Promise<(v601.InstanceMetadata | undefined)> + getAll(): Promise + getMany(keys: [number, number][]): Promise<(v601.InstanceMetadata | undefined)[]> + getKeys(): Promise<[number, number][]> + getKeys(key1: number): Promise<[number, number][]> + getKeys(key1: number, key2: number): Promise<[number, number][]> + getKeysPaged(pageSize: number): AsyncIterable<[number, number][]> + getKeysPaged(pageSize: number, key1: number): AsyncIterable<[number, number][]> + getKeysPaged(pageSize: number, key1: number, key2: number): AsyncIterable<[number, number][]> + getPairs(): Promise<[k: [number, number], v: v601.InstanceMetadata][]> + getPairs(key1: number): Promise<[k: [number, number], v: v601.InstanceMetadata][]> + getPairs(key1: number, key2: number): Promise<[k: [number, number], v: v601.InstanceMetadata][]> + getPairsPaged(pageSize: number): AsyncIterable<[k: [number, number], v: v601.InstanceMetadata][]> + getPairsPaged(pageSize: number, key1: number): AsyncIterable<[k: [number, number], v: v601.InstanceMetadata][]> + getPairsPaged(pageSize: number, key1: number, key2: number): AsyncIterable<[k: [number, number], v: v601.InstanceMetadata][]> } diff --git a/src/types/statemint/support.ts b/src/types/statemint/support.ts index db6ebc3..56d0049 100644 --- a/src/types/statemint/support.ts +++ b/src/types/statemint/support.ts @@ -1,130 +1,131 @@ -export type Result = - | { - __kind: 'Ok' - value: T - } - | { - __kind: 'Err' - value: E - } -export type Option = - | { - __kind: 'Some' - value: T - } - | { - __kind: 'None' - } +export type Result = { + __kind: 'Ok' + value: T +} | { + __kind: 'Err' + value: E +} + + +export type Option = { + __kind: 'Some', + value: T +} | { + __kind: 'None' +} + export interface Chain { - getEventHash(eventName: string): string - decodeEvent(event: Event): any - getCallHash(name: string): string - decodeCall(call: Call): any - getStorageItemTypeHash(prefix: string, name: string): string | undefined - getStorage(blockHash: string, prefix: string, name: string, ...args: any[]): Promise - queryStorage2(blockHash: string, prefix: string, name: string, keyList?: any[]): Promise - getKeys(blockHash: string, prefix: string, name: string, ...args: any[]): Promise - getPairs(blockHash: string, prefix: string, name: string, ...args: any[]): Promise - getKeysPaged(pageSize: number, blockHash: string, prefix: string, name: string, ...args: any[]): AsyncIterable - getPairsPaged( - pageSize: number, - blockHash: string, - prefix: string, - name: string, - ...args: any[] - ): AsyncIterable<[key: any, value: any][]> - getConstantTypeHash(pallet: string, name: string): string | undefined - getConstant(pallet: string, name: string): any + getEventHash(eventName: string): string + decodeEvent(event: Event): any + getCallHash(name: string): string + decodeCall(call: Call): any + getStorageItemTypeHash(prefix: string, name: string): string | undefined + getStorage(blockHash: string, prefix: string, name: string, ...args: any[]): Promise + queryStorage2(blockHash: string, prefix: string, name: string, keyList?: any[]): Promise + getKeys(blockHash: string, prefix: string, name: string, ...args: any[]): Promise + getPairs(blockHash: string, prefix: string, name: string, ...args: any[]): Promise + getKeysPaged(pageSize: number, blockHash: string, prefix: string, name: string, ...args: any[]): AsyncIterable + getPairsPaged(pageSize: number, blockHash: string, prefix: string, name: string, ...args: any[]): AsyncIterable<[key: any, value: any][]> + getConstantTypeHash(pallet: string, name: string): string | undefined + getConstant(pallet: string, name: string): any } + export interface ChainContext { - _chain: Chain + _chain: Chain } + export interface Event { - name: string - args: any + name: string + args: any } + export interface EventContext extends ChainContext { - event: Event + event: Event } + export interface Call { - name: string - args: any + name: string + args: any } + export interface CallContext extends ChainContext { - call: Call + call: Call } + export interface BlockContext extends ChainContext { - block: Block + block: Block } + export interface Block { - hash: string + hash: string } + export class StorageBase { - protected readonly _chain: Chain - protected readonly blockHash: string - - constructor(ctx: BlockContext) - constructor(ctx: ChainContext, block: Block) - constructor(ctx: BlockContext, block?: Block) { - block = block || ctx.block - this.blockHash = block.hash - this._chain = ctx._chain - } - - protected getPrefix(): string { - throw new Error('Not implemented') - } - - protected getName(): string { - throw new Error('Not implemented') - } - - protected getTypeHash(): string | undefined { - return this._chain.getStorageItemTypeHash(this.getPrefix(), this.getName()) - } - - /** - * Checks whether the storage item is defined for the current chain version. - */ - get isExists(): boolean { - return this.getTypeHash() != null - } - - protected get(...args: any[]): Promise { - return this._chain.getStorage(this.blockHash, this.getPrefix(), this.getName(), ...args) - } - - protected getMany(keyList: any[]): Promise { - return this._chain.queryStorage2(this.blockHash, this.getPrefix(), this.getName(), keyList) - } - - protected getAll(): Promise { - return this._chain.queryStorage2(this.blockHash, this.getPrefix(), this.getName()) - } - - protected getKeys(...args: any[]): Promise { - return this._chain.getKeys(this.blockHash, this.getPrefix(), this.getName(), ...args) - } - - protected getKeysPaged(pageSize: number, ...args: any[]): AsyncIterable { - return this._chain.getKeysPaged(pageSize, this.blockHash, this.getPrefix(), this.getName(), ...args) - } - - protected getPairs(...args: any[]): Promise<[k: any, v: any][]> { - return this._chain.getPairs(this.blockHash, this.getPrefix(), this.getName(), ...args) - } - - protected getPairsPaged(pageSize: number, ...args: any[]): AsyncIterable<[k: any, v: any][]> { - return this._chain.getPairsPaged(pageSize, this.blockHash, this.getPrefix(), this.getName(), ...args) - } + protected readonly _chain: Chain + protected readonly blockHash: string + + constructor(ctx: BlockContext) + constructor(ctx: ChainContext, block: Block) + constructor(ctx: BlockContext, block?: Block) { + block = block || ctx.block + this.blockHash = block.hash + this._chain = ctx._chain + } + + protected getPrefix(): string { + throw new Error('Not implemented') + } + + protected getName(): string { + throw new Error('Not implemented') + } + + protected getTypeHash(): string | undefined { + return this._chain.getStorageItemTypeHash(this.getPrefix(), this.getName()) + } + + /** + * Checks whether the storage item is defined for the current chain version. + */ + get isExists(): boolean { + return this.getTypeHash() != null + } + + protected get(...args: any[]): Promise { + return this._chain.getStorage(this.blockHash, this.getPrefix(), this.getName(), ...args) + } + + protected getMany(keyList: any[]): Promise { + return this._chain.queryStorage2(this.blockHash, this.getPrefix(), this.getName(), keyList) + } + + protected getAll(): Promise { + return this._chain.queryStorage2(this.blockHash, this.getPrefix(), this.getName()) + } + + protected getKeys(...args: any[]): Promise { + return this._chain.getKeys(this.blockHash, this.getPrefix(), this.getName(), ...args) + } + + protected getKeysPaged(pageSize: number, ...args: any[]): AsyncIterable { + return this._chain.getKeysPaged(pageSize, this.blockHash, this.getPrefix(), this.getName(), ...args) + } + + protected getPairs(...args: any[]): Promise<[k: any, v: any][]> { + return this._chain.getPairs(this.blockHash, this.getPrefix(), this.getName(), ...args) + } + + protected getPairsPaged(pageSize: number, ...args: any[]): AsyncIterable<[k: any, v: any][]> { + return this._chain.getPairsPaged(pageSize, this.blockHash, this.getPrefix(), this.getName(), ...args) + } } diff --git a/src/types/statemint/v601.ts b/src/types/statemint/v601.ts index 299f91c..df7c5dd 100644 --- a/src/types/statemint/v601.ts +++ b/src/types/statemint/v601.ts @@ -1,20 +1,20 @@ -import type { Result, Option } from './support' +import type {Result, Option} from './support' export interface ClassDetails { - owner: Uint8Array - issuer: Uint8Array - admin: Uint8Array - freezer: Uint8Array - totalDeposit: bigint - freeHolding: boolean - instances: number - instanceMetadatas: number - attributes: number - isFrozen: boolean + owner: Uint8Array + issuer: Uint8Array + admin: Uint8Array + freezer: Uint8Array + totalDeposit: bigint + freeHolding: boolean + instances: number + instanceMetadatas: number + attributes: number + isFrozen: boolean } export interface InstanceMetadata { - deposit: bigint - data: Uint8Array - isFrozen: boolean + deposit: bigint + data: Uint8Array + isFrozen: boolean } diff --git a/src/types/statemint/v9230.ts b/src/types/statemint/v9230.ts index 01a0854..489a86b 100644 --- a/src/types/statemint/v9230.ts +++ b/src/types/statemint/v9230.ts @@ -1,14 +1,14 @@ -import type { Result, Option } from './support' +import type {Result, Option} from './support' export interface CollectionDetails { - owner: Uint8Array - issuer: Uint8Array - admin: Uint8Array - freezer: Uint8Array - totalDeposit: bigint - freeHolding: boolean - items: number - itemMetadatas: number - attributes: number - isFrozen: boolean + owner: Uint8Array + issuer: Uint8Array + admin: Uint8Array + freezer: Uint8Array + totalDeposit: bigint + freeHolding: boolean + items: number + itemMetadatas: number + attributes: number + isFrozen: boolean } From 01eb032be28a2a8271f7fef9b0fc9f572f3030e4 Mon Sep 17 00:00:00 2001 From: Viki Val Date: Tue, 18 Jul 2023 15:50:43 +0200 Subject: [PATCH 2/5] :wrench: enable statemint nfts pallet --- statemint.json | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/statemint.json b/statemint.json index beb4607..0c5b591 100644 --- a/statemint.json +++ b/statemint.json @@ -28,11 +28,50 @@ "Uniques.OwnershipAcceptanceChanged", "Uniques.TeamChanged", "Uniques.Thawed", - "Uniques.Transferred" + "Uniques.Transferred", + "Nfts.AllApprovalsCancelled", + "Nfts.ApprovalCancelled", + "Nfts.AttributeCleared", + "Nfts.AttributeSet", + "Nfts.Burned", + "Nfts.CollectionConfigChanged", + "Nfts.CollectionLocked", + "Nfts.CollectionMaxSupplySet", + "Nfts.CollectionMetadataCleared", + "Nfts.CollectionMetadataSet", + "Nfts.CollectionMintSettingsUpdated", + "Nfts.Created", + "Nfts.Destroyed", + "Nfts.ForceCreated", + "Nfts.Issued", + "Nfts.ItemAttributesApprovalAdded", + "Nfts.ItemAttributesApprovalRemoved", + "Nfts.ItemBought", + "Nfts.ItemMetadataCleared", + "Nfts.ItemMetadataSet", + "Nfts.ItemPriceRemoved", + "Nfts.ItemPriceSet", + "Nfts.ItemPropertiesLocked", + "Nfts.ItemTransferLocked", + "Nfts.ItemTransferUnlocked", + "Nfts.NextCollectionIdIncremented", + "Nfts.OwnerChanged", + "Nfts.OwnershipAcceptanceChanged", + "Nfts.PalletAttributeSet", + "Nfts.PreSignedAttributesSet", + "Nfts.SwapCancelled", + "Nfts.SwapClaimed", + "Nfts.SwapCreated", + "Nfts.TeamChanged", + "Nfts.TipSent", + "Nfts.TransferApproved", + "Nfts.Transferred" ], "calls": [], "storage": [ "Uniques.Class", - "Uniques.InstanceMetadataOf" + "Uniques.InstanceMetadataOf", + "Nfts.Collection", + "Nfts.ItemMetadataOf" ] } From 09103f3a4ccee9029aebe61263c0d6978c4bed84 Mon Sep 17 00:00:00 2001 From: Viki Val Date: Tue, 18 Jul 2023 15:50:54 +0200 Subject: [PATCH 3/5] :squid: typegen statemint nfts --- src/types/statemint/events.ts | 1080 ++++++++++++++++++++++++++++++++ src/types/statemint/storage.ts | 89 +++ src/types/statemint/v9430.ts | 65 ++ 3 files changed, 1234 insertions(+) create mode 100644 src/types/statemint/v9430.ts diff --git a/src/types/statemint/events.ts b/src/types/statemint/events.ts index ff9638b..abd5630 100644 --- a/src/types/statemint/events.ts +++ b/src/types/statemint/events.ts @@ -1,5 +1,1085 @@ import assert from 'assert' import {Chain, ChainContext, EventContext, Event, Result, Option} from './support' +import * as v9430 from './v9430' + +export class NftsAllApprovalsCancelledEvent { + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Nfts.AllApprovalsCancelled') + this._chain = ctx._chain + this.event = event + } + + /** + * All approvals of an item got cancelled. + */ + get isV9430(): boolean { + return this._chain.getEventHash('Nfts.AllApprovalsCancelled') === '281c96f4233cbe042ed549cfca1fafa833d625f8d832ed29682ac34cdceb017d' + } + + /** + * All approvals of an item got cancelled. + */ + get asV9430(): {collection: number, item: number, owner: Uint8Array} { + assert(this.isV9430) + return this._chain.decodeEvent(this.event) + } +} + +export class NftsApprovalCancelledEvent { + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Nfts.ApprovalCancelled') + this._chain = ctx._chain + this.event = event + } + + /** + * An approval for a `delegate` account to transfer the `item` of an item + * `collection` was cancelled by its `owner`. + */ + get isV9430(): boolean { + return this._chain.getEventHash('Nfts.ApprovalCancelled') === '28e2099402db057489fed1d463d382a488f95bb3d119379aef54f500296b1d83' + } + + /** + * An approval for a `delegate` account to transfer the `item` of an item + * `collection` was cancelled by its `owner`. + */ + get asV9430(): {collection: number, item: number, owner: Uint8Array, delegate: Uint8Array} { + assert(this.isV9430) + return this._chain.decodeEvent(this.event) + } +} + +export class NftsAttributeClearedEvent { + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Nfts.AttributeCleared') + this._chain = ctx._chain + this.event = event + } + + /** + * Attribute metadata has been cleared for a `collection` or `item`. + */ + get isV9430(): boolean { + return this._chain.getEventHash('Nfts.AttributeCleared') === '4d246c14b51f1093b2b931b12ca433d89593c617b09ce2082dfc43ef8671765e' + } + + /** + * Attribute metadata has been cleared for a `collection` or `item`. + */ + get asV9430(): {collection: number, maybeItem: (number | undefined), key: Uint8Array, namespace: v9430.AttributeNamespace} { + assert(this.isV9430) + return this._chain.decodeEvent(this.event) + } +} + +export class NftsAttributeSetEvent { + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Nfts.AttributeSet') + this._chain = ctx._chain + this.event = event + } + + /** + * New attribute metadata has been set for a `collection` or `item`. + */ + get isV9430(): boolean { + return this._chain.getEventHash('Nfts.AttributeSet') === 'df375b4dee7b64ffeab47159334313f546d6fbe1d31d90f2253a667f6ac2799f' + } + + /** + * New attribute metadata has been set for a `collection` or `item`. + */ + get asV9430(): {collection: number, maybeItem: (number | undefined), key: Uint8Array, value: Uint8Array, namespace: v9430.AttributeNamespace} { + assert(this.isV9430) + return this._chain.decodeEvent(this.event) + } +} + +export class NftsBurnedEvent { + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Nfts.Burned') + this._chain = ctx._chain + this.event = event + } + + /** + * An `item` was destroyed. + */ + get isV9430(): boolean { + return this._chain.getEventHash('Nfts.Burned') === '281c96f4233cbe042ed549cfca1fafa833d625f8d832ed29682ac34cdceb017d' + } + + /** + * An `item` was destroyed. + */ + get asV9430(): {collection: number, item: number, owner: Uint8Array} { + assert(this.isV9430) + return this._chain.decodeEvent(this.event) + } +} + +export class NftsCollectionConfigChangedEvent { + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Nfts.CollectionConfigChanged') + this._chain = ctx._chain + this.event = event + } + + /** + * A `collection` has had its config changed by the `Force` origin. + */ + get isV9430(): boolean { + return this._chain.getEventHash('Nfts.CollectionConfigChanged') === 'a84ae2f0e555d689a7b5b0ee2914bd693902b07afc4f268377240f6ac92495cb' + } + + /** + * A `collection` has had its config changed by the `Force` origin. + */ + get asV9430(): {collection: number} { + assert(this.isV9430) + return this._chain.decodeEvent(this.event) + } +} + +export class NftsCollectionLockedEvent { + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Nfts.CollectionLocked') + this._chain = ctx._chain + this.event = event + } + + /** + * Some `collection` was locked. + */ + get isV9430(): boolean { + return this._chain.getEventHash('Nfts.CollectionLocked') === 'a84ae2f0e555d689a7b5b0ee2914bd693902b07afc4f268377240f6ac92495cb' + } + + /** + * Some `collection` was locked. + */ + get asV9430(): {collection: number} { + assert(this.isV9430) + return this._chain.decodeEvent(this.event) + } +} + +export class NftsCollectionMaxSupplySetEvent { + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Nfts.CollectionMaxSupplySet') + this._chain = ctx._chain + this.event = event + } + + /** + * Max supply has been set for a collection. + */ + get isV9430(): boolean { + return this._chain.getEventHash('Nfts.CollectionMaxSupplySet') === '165991456bc3c6a81994ce513fdf36c2303f5220829f5e8caafbf821233135b4' + } + + /** + * Max supply has been set for a collection. + */ + get asV9430(): {collection: number, maxSupply: number} { + assert(this.isV9430) + return this._chain.decodeEvent(this.event) + } +} + +export class NftsCollectionMetadataClearedEvent { + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Nfts.CollectionMetadataCleared') + this._chain = ctx._chain + this.event = event + } + + /** + * Metadata has been cleared for a `collection`. + */ + get isV9430(): boolean { + return this._chain.getEventHash('Nfts.CollectionMetadataCleared') === 'a84ae2f0e555d689a7b5b0ee2914bd693902b07afc4f268377240f6ac92495cb' + } + + /** + * Metadata has been cleared for a `collection`. + */ + get asV9430(): {collection: number} { + assert(this.isV9430) + return this._chain.decodeEvent(this.event) + } +} + +export class NftsCollectionMetadataSetEvent { + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Nfts.CollectionMetadataSet') + this._chain = ctx._chain + this.event = event + } + + /** + * New metadata has been set for a `collection`. + */ + get isV9430(): boolean { + return this._chain.getEventHash('Nfts.CollectionMetadataSet') === 'fbd84faf888505e9d8faf18bd544737c4436c745e6318c812a3065bb1a666c44' + } + + /** + * New metadata has been set for a `collection`. + */ + get asV9430(): {collection: number, data: Uint8Array} { + assert(this.isV9430) + return this._chain.decodeEvent(this.event) + } +} + +export class NftsCollectionMintSettingsUpdatedEvent { + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Nfts.CollectionMintSettingsUpdated') + this._chain = ctx._chain + this.event = event + } + + /** + * Mint settings for a collection had changed. + */ + get isV9430(): boolean { + return this._chain.getEventHash('Nfts.CollectionMintSettingsUpdated') === 'a84ae2f0e555d689a7b5b0ee2914bd693902b07afc4f268377240f6ac92495cb' + } + + /** + * Mint settings for a collection had changed. + */ + get asV9430(): {collection: number} { + assert(this.isV9430) + return this._chain.decodeEvent(this.event) + } +} + +export class NftsCreatedEvent { + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Nfts.Created') + this._chain = ctx._chain + this.event = event + } + + /** + * A `collection` was created. + */ + get isV9430(): boolean { + return this._chain.getEventHash('Nfts.Created') === 'a5c293082b1f3ffb16eaecc5b8d430ca1bb8c7bd090079ebcefcbf303cbfec61' + } + + /** + * A `collection` was created. + */ + get asV9430(): {collection: number, creator: Uint8Array, owner: Uint8Array} { + assert(this.isV9430) + return this._chain.decodeEvent(this.event) + } +} + +export class NftsDestroyedEvent { + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Nfts.Destroyed') + this._chain = ctx._chain + this.event = event + } + + /** + * A `collection` was destroyed. + */ + get isV9430(): boolean { + return this._chain.getEventHash('Nfts.Destroyed') === 'a84ae2f0e555d689a7b5b0ee2914bd693902b07afc4f268377240f6ac92495cb' + } + + /** + * A `collection` was destroyed. + */ + get asV9430(): {collection: number} { + assert(this.isV9430) + return this._chain.decodeEvent(this.event) + } +} + +export class NftsForceCreatedEvent { + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Nfts.ForceCreated') + this._chain = ctx._chain + this.event = event + } + + /** + * A `collection` was force-created. + */ + get isV9430(): boolean { + return this._chain.getEventHash('Nfts.ForceCreated') === '6059bcf1dd7c48dc760f017d00a2c7c6719e745b3de9bde2046cbe26347c562f' + } + + /** + * A `collection` was force-created. + */ + get asV9430(): {collection: number, owner: Uint8Array} { + assert(this.isV9430) + return this._chain.decodeEvent(this.event) + } +} + +export class NftsIssuedEvent { + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Nfts.Issued') + this._chain = ctx._chain + this.event = event + } + + /** + * An `item` was issued. + */ + get isV9430(): boolean { + return this._chain.getEventHash('Nfts.Issued') === '281c96f4233cbe042ed549cfca1fafa833d625f8d832ed29682ac34cdceb017d' + } + + /** + * An `item` was issued. + */ + get asV9430(): {collection: number, item: number, owner: Uint8Array} { + assert(this.isV9430) + return this._chain.decodeEvent(this.event) + } +} + +export class NftsItemAttributesApprovalAddedEvent { + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Nfts.ItemAttributesApprovalAdded') + this._chain = ctx._chain + this.event = event + } + + /** + * A new approval to modify item attributes was added. + */ + get isV9430(): boolean { + return this._chain.getEventHash('Nfts.ItemAttributesApprovalAdded') === '16137639784e12ee57d143b35251349ede19f9139a7b372c2c033564309a1aaa' + } + + /** + * A new approval to modify item attributes was added. + */ + get asV9430(): {collection: number, item: number, delegate: Uint8Array} { + assert(this.isV9430) + return this._chain.decodeEvent(this.event) + } +} + +export class NftsItemAttributesApprovalRemovedEvent { + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Nfts.ItemAttributesApprovalRemoved') + this._chain = ctx._chain + this.event = event + } + + /** + * A new approval to modify item attributes was removed. + */ + get isV9430(): boolean { + return this._chain.getEventHash('Nfts.ItemAttributesApprovalRemoved') === '16137639784e12ee57d143b35251349ede19f9139a7b372c2c033564309a1aaa' + } + + /** + * A new approval to modify item attributes was removed. + */ + get asV9430(): {collection: number, item: number, delegate: Uint8Array} { + assert(this.isV9430) + return this._chain.decodeEvent(this.event) + } +} + +export class NftsItemBoughtEvent { + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Nfts.ItemBought') + this._chain = ctx._chain + this.event = event + } + + /** + * An item was bought. + */ + get isV9430(): boolean { + return this._chain.getEventHash('Nfts.ItemBought') === 'db915144f3a96c73a3031d37c874507dcac06fd77bca9962f672bc9bfb557489' + } + + /** + * An item was bought. + */ + get asV9430(): {collection: number, item: number, price: bigint, seller: Uint8Array, buyer: Uint8Array} { + assert(this.isV9430) + return this._chain.decodeEvent(this.event) + } +} + +export class NftsItemMetadataClearedEvent { + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Nfts.ItemMetadataCleared') + this._chain = ctx._chain + this.event = event + } + + /** + * Metadata has been cleared for an item. + */ + get isV9430(): boolean { + return this._chain.getEventHash('Nfts.ItemMetadataCleared') === 'ac39ace3905de6db862660444374575fb7ed5f403845b475c7f2addc21c71f91' + } + + /** + * Metadata has been cleared for an item. + */ + get asV9430(): {collection: number, item: number} { + assert(this.isV9430) + return this._chain.decodeEvent(this.event) + } +} + +export class NftsItemMetadataSetEvent { + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Nfts.ItemMetadataSet') + this._chain = ctx._chain + this.event = event + } + + /** + * New metadata has been set for an item. + */ + get isV9430(): boolean { + return this._chain.getEventHash('Nfts.ItemMetadataSet') === '83275a0de68e1c50aff60fe3090e27ba46bb68a77375edc5172d160af095826d' + } + + /** + * New metadata has been set for an item. + */ + get asV9430(): {collection: number, item: number, data: Uint8Array} { + assert(this.isV9430) + return this._chain.decodeEvent(this.event) + } +} + +export class NftsItemPriceRemovedEvent { + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Nfts.ItemPriceRemoved') + this._chain = ctx._chain + this.event = event + } + + /** + * The price for the item was removed. + */ + get isV9430(): boolean { + return this._chain.getEventHash('Nfts.ItemPriceRemoved') === 'ac39ace3905de6db862660444374575fb7ed5f403845b475c7f2addc21c71f91' + } + + /** + * The price for the item was removed. + */ + get asV9430(): {collection: number, item: number} { + assert(this.isV9430) + return this._chain.decodeEvent(this.event) + } +} + +export class NftsItemPriceSetEvent { + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Nfts.ItemPriceSet') + this._chain = ctx._chain + this.event = event + } + + /** + * The price was set for the item. + */ + get isV9430(): boolean { + return this._chain.getEventHash('Nfts.ItemPriceSet') === '10d4911c332080c5a5c1e6c248347d1174817ab96906747e2c40df18c5381944' + } + + /** + * The price was set for the item. + */ + get asV9430(): {collection: number, item: number, price: bigint, whitelistedBuyer: (Uint8Array | undefined)} { + assert(this.isV9430) + return this._chain.decodeEvent(this.event) + } +} + +export class NftsItemPropertiesLockedEvent { + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Nfts.ItemPropertiesLocked') + this._chain = ctx._chain + this.event = event + } + + /** + * `item` metadata or attributes were locked. + */ + get isV9430(): boolean { + return this._chain.getEventHash('Nfts.ItemPropertiesLocked') === 'b6965c94a3e24b173446abb1e12a56b541de3d666894c46f3753c4d9029db290' + } + + /** + * `item` metadata or attributes were locked. + */ + get asV9430(): {collection: number, item: number, lockMetadata: boolean, lockAttributes: boolean} { + assert(this.isV9430) + return this._chain.decodeEvent(this.event) + } +} + +export class NftsItemTransferLockedEvent { + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Nfts.ItemTransferLocked') + this._chain = ctx._chain + this.event = event + } + + /** + * An `item` became non-transferable. + */ + get isV9430(): boolean { + return this._chain.getEventHash('Nfts.ItemTransferLocked') === 'ac39ace3905de6db862660444374575fb7ed5f403845b475c7f2addc21c71f91' + } + + /** + * An `item` became non-transferable. + */ + get asV9430(): {collection: number, item: number} { + assert(this.isV9430) + return this._chain.decodeEvent(this.event) + } +} + +export class NftsItemTransferUnlockedEvent { + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Nfts.ItemTransferUnlocked') + this._chain = ctx._chain + this.event = event + } + + /** + * An `item` became transferable. + */ + get isV9430(): boolean { + return this._chain.getEventHash('Nfts.ItemTransferUnlocked') === 'ac39ace3905de6db862660444374575fb7ed5f403845b475c7f2addc21c71f91' + } + + /** + * An `item` became transferable. + */ + get asV9430(): {collection: number, item: number} { + assert(this.isV9430) + return this._chain.decodeEvent(this.event) + } +} + +export class NftsNextCollectionIdIncrementedEvent { + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Nfts.NextCollectionIdIncremented') + this._chain = ctx._chain + this.event = event + } + + /** + * Event gets emitted when the `NextCollectionId` gets incremented. + */ + get isV9430(): boolean { + return this._chain.getEventHash('Nfts.NextCollectionIdIncremented') === '637ef8f6ab36ea6441937975da16ec6128d3ac503fd8ae7bc04131ff93640dc2' + } + + /** + * Event gets emitted when the `NextCollectionId` gets incremented. + */ + get asV9430(): {nextId: number} { + assert(this.isV9430) + return this._chain.decodeEvent(this.event) + } +} + +export class NftsOwnerChangedEvent { + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Nfts.OwnerChanged') + this._chain = ctx._chain + this.event = event + } + + /** + * The owner changed. + */ + get isV9430(): boolean { + return this._chain.getEventHash('Nfts.OwnerChanged') === '0331b0b161c2f2db690f574540ade7765af19f5306dc65443561fbaa5825f323' + } + + /** + * The owner changed. + */ + get asV9430(): {collection: number, newOwner: Uint8Array} { + assert(this.isV9430) + return this._chain.decodeEvent(this.event) + } +} + +export class NftsOwnershipAcceptanceChangedEvent { + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Nfts.OwnershipAcceptanceChanged') + this._chain = ctx._chain + this.event = event + } + + /** + * Ownership acceptance has changed for an account. + */ + get isV9430(): boolean { + return this._chain.getEventHash('Nfts.OwnershipAcceptanceChanged') === '62f0a146ea419b03ef3bb5c912782af0253639ca8fc47ff318396bedef2230cc' + } + + /** + * Ownership acceptance has changed for an account. + */ + get asV9430(): {who: Uint8Array, maybeCollection: (number | undefined)} { + assert(this.isV9430) + return this._chain.decodeEvent(this.event) + } +} + +export class NftsPalletAttributeSetEvent { + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Nfts.PalletAttributeSet') + this._chain = ctx._chain + this.event = event + } + + /** + * A new attribute in the `Pallet` namespace was set for the `collection` or an `item` + * within that `collection`. + */ + get isV9430(): boolean { + return this._chain.getEventHash('Nfts.PalletAttributeSet') === '468a1a89b31826460104c40759efeb63ceefdd69a6f12d9f82160b20376b0cb6' + } + + /** + * A new attribute in the `Pallet` namespace was set for the `collection` or an `item` + * within that `collection`. + */ + get asV9430(): {collection: number, item: (number | undefined), attribute: v9430.PalletAttributes, value: Uint8Array} { + assert(this.isV9430) + return this._chain.decodeEvent(this.event) + } +} + +export class NftsPreSignedAttributesSetEvent { + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Nfts.PreSignedAttributesSet') + this._chain = ctx._chain + this.event = event + } + + /** + * New attributes have been set for an `item` of the `collection`. + */ + get isV9430(): boolean { + return this._chain.getEventHash('Nfts.PreSignedAttributesSet') === '3187a106d1f5607c0c25a6deef04d48112079b32dd61370affb8b10ee21bdca5' + } + + /** + * New attributes have been set for an `item` of the `collection`. + */ + get asV9430(): {collection: number, item: number, namespace: v9430.AttributeNamespace} { + assert(this.isV9430) + return this._chain.decodeEvent(this.event) + } +} + +export class NftsSwapCancelledEvent { + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Nfts.SwapCancelled') + this._chain = ctx._chain + this.event = event + } + + /** + * The swap was cancelled. + */ + get isV9430(): boolean { + return this._chain.getEventHash('Nfts.SwapCancelled') === '203695181f6ad5b8cfab290f9b1f5673a0bfbdc9ad4b967b47d2f74b981865da' + } + + /** + * The swap was cancelled. + */ + get asV9430(): {offeredCollection: number, offeredItem: number, desiredCollection: number, desiredItem: (number | undefined), price: (v9430.PriceWithDirection | undefined), deadline: number} { + assert(this.isV9430) + return this._chain.decodeEvent(this.event) + } +} + +export class NftsSwapClaimedEvent { + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Nfts.SwapClaimed') + this._chain = ctx._chain + this.event = event + } + + /** + * The swap has been claimed. + */ + get isV9430(): boolean { + return this._chain.getEventHash('Nfts.SwapClaimed') === 'a32b04673263c9758fac7dc7b2ee372deba818fe72f157dd9a3baa5b02f6d66e' + } + + /** + * The swap has been claimed. + */ + get asV9430(): {sentCollection: number, sentItem: number, sentItemOwner: Uint8Array, receivedCollection: number, receivedItem: number, receivedItemOwner: Uint8Array, price: (v9430.PriceWithDirection | undefined), deadline: number} { + assert(this.isV9430) + return this._chain.decodeEvent(this.event) + } +} + +export class NftsSwapCreatedEvent { + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Nfts.SwapCreated') + this._chain = ctx._chain + this.event = event + } + + /** + * An `item` swap intent was created. + */ + get isV9430(): boolean { + return this._chain.getEventHash('Nfts.SwapCreated') === '203695181f6ad5b8cfab290f9b1f5673a0bfbdc9ad4b967b47d2f74b981865da' + } + + /** + * An `item` swap intent was created. + */ + get asV9430(): {offeredCollection: number, offeredItem: number, desiredCollection: number, desiredItem: (number | undefined), price: (v9430.PriceWithDirection | undefined), deadline: number} { + assert(this.isV9430) + return this._chain.decodeEvent(this.event) + } +} + +export class NftsTeamChangedEvent { + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Nfts.TeamChanged') + this._chain = ctx._chain + this.event = event + } + + /** + * The management team changed. + */ + get isV9430(): boolean { + return this._chain.getEventHash('Nfts.TeamChanged') === '7d04eb24156118efda8b963ba4549a6d4ad4a1af762296e453e42e231805cd54' + } + + /** + * The management team changed. + */ + get asV9430(): {collection: number, issuer: (Uint8Array | undefined), admin: (Uint8Array | undefined), freezer: (Uint8Array | undefined)} { + assert(this.isV9430) + return this._chain.decodeEvent(this.event) + } +} + +export class NftsTipSentEvent { + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Nfts.TipSent') + this._chain = ctx._chain + this.event = event + } + + /** + * A tip was sent. + */ + get isV9430(): boolean { + return this._chain.getEventHash('Nfts.TipSent') === '6508b276e46d4188520e47ddb8bf0513b8c2e8b4e9dea63e25496bc5ca934424' + } + + /** + * A tip was sent. + */ + get asV9430(): {collection: number, item: number, sender: Uint8Array, receiver: Uint8Array, amount: bigint} { + assert(this.isV9430) + return this._chain.decodeEvent(this.event) + } +} + +export class NftsTransferApprovedEvent { + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Nfts.TransferApproved') + this._chain = ctx._chain + this.event = event + } + + /** + * An `item` of a `collection` has been approved by the `owner` for transfer by + * a `delegate`. + */ + get isV9430(): boolean { + return this._chain.getEventHash('Nfts.TransferApproved') === '71620a6e85bb8bb5d9e315805e790e3baae8f271dee82324db43d472e2a8d860' + } + + /** + * An `item` of a `collection` has been approved by the `owner` for transfer by + * a `delegate`. + */ + get asV9430(): {collection: number, item: number, owner: Uint8Array, delegate: Uint8Array, deadline: (number | undefined)} { + assert(this.isV9430) + return this._chain.decodeEvent(this.event) + } +} + +export class NftsTransferredEvent { + private readonly _chain: Chain + private readonly event: Event + + constructor(ctx: EventContext) + constructor(ctx: ChainContext, event: Event) + constructor(ctx: EventContext, event?: Event) { + event = event || ctx.event + assert(event.name === 'Nfts.Transferred') + this._chain = ctx._chain + this.event = event + } + + /** + * An `item` was transferred. + */ + get isV9430(): boolean { + return this._chain.getEventHash('Nfts.Transferred') === 'ac8c1c5a1df2a464e3447d13d6c43a813112a33c144f93775b934b08c086bf7a' + } + + /** + * An `item` was transferred. + */ + get asV9430(): {collection: number, item: number, from: Uint8Array, to: Uint8Array} { + assert(this.isV9430) + return this._chain.decodeEvent(this.event) + } +} export class UniquesAttributeClearedEvent { private readonly _chain: Chain diff --git a/src/types/statemint/storage.ts b/src/types/statemint/storage.ts index bd3b859..a2b7420 100644 --- a/src/types/statemint/storage.ts +++ b/src/types/statemint/storage.ts @@ -2,6 +2,95 @@ import assert from 'assert' import {Block, BlockContext, Chain, ChainContext, Option, Result, StorageBase} from './support' import * as v601 from './v601' import * as v9230 from './v9230' +import * as v9430 from './v9430' + +export class NftsCollectionStorage extends StorageBase { + protected getPrefix() { + return 'Nfts' + } + + protected getName() { + return 'Collection' + } + + /** + * Details of a collection. + */ + get isV9430(): boolean { + return this.getTypeHash() === '2048922b0682bb5b7de7ca9a7e01264f12386f5c3cad9a3e84b1e5a81cd69913' + } + + /** + * Details of a collection. + */ + get asV9430(): NftsCollectionStorageV9430 { + assert(this.isV9430) + return this as any + } +} + +/** + * Details of a collection. + */ +export interface NftsCollectionStorageV9430 { + get(key: number): Promise<(v9430.Type_353 | undefined)> + getAll(): Promise + getMany(keys: number[]): Promise<(v9430.Type_353 | undefined)[]> + getKeys(): Promise + getKeys(key: number): Promise + getKeysPaged(pageSize: number): AsyncIterable + getKeysPaged(pageSize: number, key: number): AsyncIterable + getPairs(): Promise<[k: number, v: v9430.Type_353][]> + getPairs(key: number): Promise<[k: number, v: v9430.Type_353][]> + getPairsPaged(pageSize: number): AsyncIterable<[k: number, v: v9430.Type_353][]> + getPairsPaged(pageSize: number, key: number): AsyncIterable<[k: number, v: v9430.Type_353][]> +} + +export class NftsItemMetadataOfStorage extends StorageBase { + protected getPrefix() { + return 'Nfts' + } + + protected getName() { + return 'ItemMetadataOf' + } + + /** + * Metadata of an item. + */ + get isV9430(): boolean { + return this.getTypeHash() === 'a2ef643060836070ede73871794a2c9da331285c79b5e9e6f9935723f37af9c6' + } + + /** + * Metadata of an item. + */ + get asV9430(): NftsItemMetadataOfStorageV9430 { + assert(this.isV9430) + return this as any + } +} + +/** + * Metadata of an item. + */ +export interface NftsItemMetadataOfStorageV9430 { + get(key1: number, key2: number): Promise<(v9430.Type_363 | undefined)> + getAll(): Promise + getMany(keys: [number, number][]): Promise<(v9430.Type_363 | undefined)[]> + getKeys(): Promise<[number, number][]> + getKeys(key1: number): Promise<[number, number][]> + getKeys(key1: number, key2: number): Promise<[number, number][]> + getKeysPaged(pageSize: number): AsyncIterable<[number, number][]> + getKeysPaged(pageSize: number, key1: number): AsyncIterable<[number, number][]> + getKeysPaged(pageSize: number, key1: number, key2: number): AsyncIterable<[number, number][]> + getPairs(): Promise<[k: [number, number], v: v9430.Type_363][]> + getPairs(key1: number): Promise<[k: [number, number], v: v9430.Type_363][]> + getPairs(key1: number, key2: number): Promise<[k: [number, number], v: v9430.Type_363][]> + getPairsPaged(pageSize: number): AsyncIterable<[k: [number, number], v: v9430.Type_363][]> + getPairsPaged(pageSize: number, key1: number): AsyncIterable<[k: [number, number], v: v9430.Type_363][]> + getPairsPaged(pageSize: number, key1: number, key2: number): AsyncIterable<[k: [number, number], v: v9430.Type_363][]> +} export class UniquesClassStorage extends StorageBase { protected getPrefix() { diff --git a/src/types/statemint/v9430.ts b/src/types/statemint/v9430.ts new file mode 100644 index 0000000..d4842c1 --- /dev/null +++ b/src/types/statemint/v9430.ts @@ -0,0 +1,65 @@ +import type {Result, Option} from './support' + +export type AttributeNamespace = AttributeNamespace_Pallet | AttributeNamespace_CollectionOwner | AttributeNamespace_ItemOwner | AttributeNamespace_Account + +export interface AttributeNamespace_Pallet { + __kind: 'Pallet' +} + +export interface AttributeNamespace_CollectionOwner { + __kind: 'CollectionOwner' +} + +export interface AttributeNamespace_ItemOwner { + __kind: 'ItemOwner' +} + +export interface AttributeNamespace_Account { + __kind: 'Account' + value: Uint8Array +} + +export type PalletAttributes = PalletAttributes_UsedToClaim | PalletAttributes_TransferDisabled + +export interface PalletAttributes_UsedToClaim { + __kind: 'UsedToClaim' + value: number +} + +export interface PalletAttributes_TransferDisabled { + __kind: 'TransferDisabled' +} + +export interface PriceWithDirection { + amount: bigint + direction: PriceDirection +} + +export interface Type_353 { + owner: Uint8Array + ownerDeposit: bigint + items: number + itemMetadatas: number + itemConfigs: number + attributes: number +} + +export interface Type_363 { + deposit: ItemMetadataDeposit + data: Uint8Array +} + +export type PriceDirection = PriceDirection_Send | PriceDirection_Receive + +export interface PriceDirection_Send { + __kind: 'Send' +} + +export interface PriceDirection_Receive { + __kind: 'Receive' +} + +export interface ItemMetadataDeposit { + account: (Uint8Array | undefined) + amount: bigint +} From 21dd174d02203951ffe2850f556ebb2dc37de358 Mon Sep 17 00:00:00 2001 From: Viki Val Date: Tue, 18 Jul 2023 16:03:27 +0200 Subject: [PATCH 4/5] :wrench: dynamic reflection of nfts_pallet --- src/mappings/nfts/getters/index.ts | 284 +++------------------ src/mappings/nfts/getters/statemine.ts | 338 +++++++++++++++++++++++++ src/mappings/nfts/getters/statemint.ts | 338 +++++++++++++++++++++++++ 3 files changed, 705 insertions(+), 255 deletions(-) create mode 100644 src/mappings/nfts/getters/statemine.ts create mode 100644 src/mappings/nfts/getters/statemint.ts diff --git a/src/mappings/nfts/getters/index.ts b/src/mappings/nfts/getters/index.ts index 55703c2..8e30b46 100644 --- a/src/mappings/nfts/getters/index.ts +++ b/src/mappings/nfts/getters/index.ts @@ -1,8 +1,4 @@ -import { Interaction } from '../../../model' -import { NonFungible as Event } from '../../../processable' -import * as events from '../../../types/statemine/events' -import { addressOf } from '../../utils/helper' -import { warn } from '../../utils/logger' +import { isProd } from '../../../environment' import { Context } from '../../utils/types' import { BurnTokenEvent, @@ -20,319 +16,97 @@ import { TransferTokenEvent, } from '../types' -export function getCreateCollectionEvent(ctx: Context): CreateCollectionEvent { - const event = new events.NftsCreatedEvent(ctx) +// eslint-disable-next-line unicorn/prefer-module +const proc = isProd ? require('./statemine') : require('./statemint') - if (event.isV9420) { - const { collection: classId, creator, owner } = event.asV9420 - return { id: classId.toString(), caller: addressOf(creator), owner: addressOf(owner) } - } - warn(Interaction.CREATE, 'USING UNSAFE GETTER! PLS UPDATE TYPES!') - const { collection: classId, creator, owner } = ctx._chain.decodeEvent(ctx.event) - return { id: classId.toString(), caller: addressOf(creator), owner: addressOf(owner) } +export function getCreateCollectionEvent(ctx: Context): CreateCollectionEvent { + return proc.getCreateCollectionEvent(ctx); } export function getForceCreateCollectionEvent(ctx: Context): ForceCreateCollectionEvent { - const event = new events.NftsForceCreatedEvent(ctx) - - if (event.isV9420) { - const { collection: classId, owner } = event.asV9420 - return { id: classId.toString(), owner: addressOf(owner) } - } - ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') - const { collection: classId, owner } = ctx._chain.decodeEvent(ctx.event) - return { id: classId.toString(), owner: addressOf(owner) } + return proc.getForceCreateCollectionEvent(ctx); } export function getCreateTokenEvent(ctx: Context): CreateTokenEvent { - const event = new events.NftsIssuedEvent(ctx) - - if (event.isV9420) { - const { collection: classId, item: instanceId, owner } = event.asV9420 - return { collectionId: classId.toString(), owner: addressOf(owner), sn: instanceId.toString() } - } - ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') - const { collection: classId, item: instanceId, owner } = ctx._chain.decodeEvent(ctx.event) - return { collectionId: classId.toString(), owner: addressOf(owner), sn: instanceId.toString() } + return proc.getCreateTokenEvent(ctx); } export function getTransferTokenEvent(ctx: Context): TransferTokenEvent { - const event = new events.NftsTransferredEvent(ctx) - - if (event.isV9420) { - const { collection: classId, item: instanceId, from, to } = event.asV9420 - return { collectionId: classId.toString(), caller: addressOf(from), sn: instanceId.toString(), to: addressOf(to) } - } - ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') - const { collection: classId, item: instanceId, from, to } = ctx._chain.decodeEvent(ctx.event) - return { collectionId: classId.toString(), caller: addressOf(from), sn: instanceId.toString(), to: addressOf(to) } + return proc.getTransferTokenEvent(ctx); } export function getBurnTokenEvent(ctx: Context): BurnTokenEvent { - const event = new events.NftsBurnedEvent(ctx) - - if (event.isV9420) { - const { collection: classId, item: instanceId, owner } = event.asV9420 - return { collectionId: classId.toString(), owner: addressOf(owner), sn: instanceId.toString() } - } - ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') - const { collection: classId, item: instanceId, owner } = ctx._chain.decodeEvent(ctx.event) - return { collectionId: classId.toString(), owner: addressOf(owner), sn: instanceId.toString() } + return proc.getBurnTokenEvent(ctx); } export function getDestroyCollectionEvent(ctx: Context): DestroyCollectionEvent { - const event = new events.NftsDestroyedEvent(ctx) - - if (event.isV9420) { - const { collection: classId } = event.asV9420 - return { id: classId.toString() } - } - - ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') - const { collection: classId } = ctx._chain.decodeEvent(ctx.event) - return { id: classId.toString() } + return proc.getDestroyCollectionEvent(ctx); } export function getListTokenEvent(ctx: Context): ListTokenEvent { - const event = new events.NftsItemPriceSetEvent(ctx) - - if (event.isV9420) { - const { collection: classId, item: instanceId, price } = event.asV9420 - return { collectionId: classId.toString(), sn: instanceId.toString(), price } - } - - ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') - const { collection: classId, item: instanceId, price } = ctx._chain.decodeEvent(ctx.event) - return { collectionId: classId.toString(), sn: instanceId.toString(), price } + return proc.getListTokenEvent(ctx); } export function getUnListTokenEvent(ctx: Context): ListTokenEvent { - const event = new events.NftsItemPriceRemovedEvent(ctx) - - if (event.isV9420) { - const { collection: classId, item: instanceId } = event.asV9420 - return { collectionId: classId.toString(), sn: instanceId.toString(), price: 0n } - } - - ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') - const { collection: classId, item: instanceId, price } = ctx._chain.decodeEvent(ctx.event) - return { collectionId: classId.toString(), sn: instanceId.toString(), price: 0n } + return proc.getUnListTokenEvent(ctx); } export function getPriceTokenEvent(ctx: Context): ListTokenEvent { - if (ctx.event.name === Event.setPrice) { - return getListTokenEvent(ctx) - } - - return getUnListTokenEvent(ctx) + return proc.getPriceTokenEvent(ctx); } export function getBuyTokenEvent(ctx: Context): BuyTokenEvent { - const event = new events.NftsItemBoughtEvent(ctx) - - if (event.isV9420) { - const { collection: classId, item: instanceId, price, seller, buyer } = event.asV9420 - return { - collectionId: classId.toString(), - caller: addressOf(buyer), - sn: instanceId.toString(), - price: BigInt(price ?? 0), - currentOwner: addressOf(seller), - } - } - ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') - const { collection: classId, item: instanceId, price, seller, buyer } = ctx._chain.decodeEvent(ctx.event) - return { - collectionId: classId.toString(), - caller: addressOf(buyer), - sn: instanceId.toString(), - price: BigInt(price ?? 0), - currentOwner: addressOf(seller), - } + return proc.getBuyTokenEvent(ctx); } export function getLockCollectionEvent(ctx: Context): LockCollectionEvent { - const event = new events.NftsCollectionMaxSupplySetEvent(ctx) - if (event.isV9420) { - const { collection: classId, maxSupply: max } = event.asV9420 - return { id: classId.toString(), max } - } - ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') - const { collection: classId, mamaxSupply: max } = ctx._chain.decodeEvent(ctx.event) - return { id: classId.toString(), max } + return proc.getLockCollectionEvent(ctx); } export function getChangeCollectionOwnerEvent(ctx: Context): ChangeCollectionOwnerEvent { - const event = new events.NftsOwnerChangedEvent(ctx) - - if (event.isV9420) { - const { collection: classId, newOwner } = event.asV9420 - return { id: classId.toString(), owner: addressOf(newOwner) } - } - - ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') - const { collection: classId, newOwner } = ctx._chain.decodeEvent(ctx.event) - return { id: classId.toString(), owner: addressOf(newOwner) } + return proc.getChangeCollectionOwnerEvent(ctx); } export function getClearCollectionMetadataEvent(ctx: Context): SetMetadata { - const event = new events.NftsCollectionMetadataClearedEvent(ctx) - - if (event.isV9420) { - const { collection: classId } = event.asV9420 - return { collectionId: classId.toString() } - } - - ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') - const { collection: classId } = ctx._chain.decodeEvent(ctx.event) - return { collectionId: classId.toString() } + return proc.getClearCollectionMetadataEvent(ctx); } export function getCreateCollectionMetadataEvent(ctx: Context): SetMetadata { - const event = new events.NftsCollectionMetadataSetEvent(ctx) - - if (event.isV9420) { - const { collection: classId, data } = event.asV9420 - return { collectionId: classId.toString(), metadata: data.toString() } - } - - ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') - const { class: classId, data, isFrozen } = ctx._chain.decodeEvent(ctx.event) - return { collectionId: classId.toString(), metadata: data.toString() } + return proc.getCreateCollectionMetadataEvent(ctx); } export function getClearClassMetadataEvent(ctx: Context): SetMetadata { - const event = new events.NftsCollectionMetadataSetEvent(ctx) - - if (event.isV9420) { - const { collection: classId, data } = event.asV9420 - return { collectionId: classId.toString() } - } - - ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') - const { class: classId } = ctx._chain.decodeEvent(ctx.event) - return { collectionId: classId.toString() } + return proc.getClearClassMetadataEvent(ctx); } export function getCreateClassMetadataEvent(ctx: Context): SetMetadata { - const event = new events.NftsCollectionMetadataSetEvent(ctx) - - if (event.isV9420) { - const { collection: classId, data } = event.asV9420 - return { collectionId: classId.toString(), metadata: data.toString() } - } - - ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') - const { class: classId, data, isFrozen } = ctx._chain.decodeEvent(ctx.event) - return { collectionId: classId.toString(), metadata: data.toString() } + return proc.getCreateClassMetadataEvent(ctx); } export function getCreateMetadataEvent(ctx: Context): SetMetadata { - const event = new events.NftsItemMetadataSetEvent(ctx) - - if (event.isV9420) { - const { collection: classId, item: instanceId, data } = event.asV9420 - return { collectionId: classId.toString(), sn: instanceId.toString(), metadata: data.toString() } - } - - ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') - const { collection: classId, item: instanceId, data, isFrozen } = ctx._chain.decodeEvent(ctx.event) - return { collectionId: classId.toString(), sn: instanceId.toString(), metadata: data.toString() } + return proc.getCreateMetadataEvent(ctx); } export function getClearMetadataEvent(ctx: Context): SetMetadata { - const event = new events.NftsItemMetadataClearedEvent(ctx) - - if (event.isV9420) { - const { collection: classId, item: instanceId } = event.asV9420 - return { collectionId: classId.toString(), sn: instanceId.toString() } - } - - ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') - const { collection: classId, item: instanceId } = ctx._chain.decodeEvent(ctx.event) - return { collectionId: classId.toString(), sn: instanceId.toString() } + return proc.getClearMetadataEvent(ctx); } export function getMetadataEvent(ctx: Context): SetMetadata { - switch (ctx.event.name) { - case Event.setCollectionMetadata: - return getCreateCollectionMetadataEvent(ctx) - case Event.clearCollectionMetadata: - return getClearCollectionMetadataEvent(ctx) - case Event.setMetadata: - return getCreateMetadataEvent(ctx) - case Event.clearMetadata: - return getClearMetadataEvent(ctx) - default: - throw new Error('Unsupported event') - } + return proc.getMetadataEvent(ctx); } -function getSetAttributeEvent(ctx: Context): SetAttribute { - const event = new events.NftsAttributeSetEvent(ctx) - if (event.isV9420) { - const { collection: classId, maybeItem: instanceId, key, value } = event.asV9420 - return { - collectionId: classId.toString(), - sn: instanceId?.toString(), - trait: key.toString(), - value: value.toString(), - } - } - - ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') - const { collection: classId, maybeItem: instanceId, key, value } = ctx._chain.decodeEvent(ctx.event) - return { - collectionId: classId.toString(), - sn: instanceId?.toString(), - trait: key.toString(), - value: value.toString(), - } +export function getSetAttributeEvent(ctx: Context): SetAttribute { + return proc.getSetAttributeEvent(ctx); } -function getClearAttributeEvent(ctx: Context): SetAttribute { - const event = new events.NftsAttributeClearedEvent(ctx) - - if (event.isV9420) { - const { collection: classId, maybeItem: instanceId, key } = event.asV9420 - return { collectionId: classId.toString(), sn: instanceId?.toString(), trait: key.toString() } - } - - ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') - const { collection: classId, maybeItem: instanceId, key } = ctx._chain.decodeEvent(ctx.event) - return { collectionId: classId.toString(), sn: instanceId?.toString(), trait: key.toString() } +export function getClearAttributeEvent(ctx: Context): SetAttribute { + return proc.getClearAttributeEvent(ctx); } export function getAttributeEvent(ctx: Context): SetAttribute { - switch (ctx.event.name) { - case Event.setAttribute: - return getSetAttributeEvent(ctx) - case Event.clearAttribute: - return getClearAttributeEvent(ctx) - default: - throw new Error('Unsupported event') - } + return proc.getAttributeEvent(ctx); } export function getChangeTeamEvent(ctx: Context): ChangeCollectionTeam { - const event = new events.NftsTeamChangedEvent(ctx) - - if (event.isV9420) { - const { collection: classId, issuer, admin, freezer } = event.asV9420 - return { - id: classId.toString(), - issuer: addressOf(issuer || ''), - admin: addressOf(admin || ''), - freezer: addressOf(freezer || ''), - } - } - - ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') - const { collection: classId, issuer, admin, freezer } = ctx._chain.decodeEvent(ctx.event) - return { - id: classId.toString(), - issuer: addressOf(issuer || ''), - admin: addressOf(admin || ''), - freezer: addressOf(freezer || ''), - } + return proc.getChangeTeamEvent(ctx); } diff --git a/src/mappings/nfts/getters/statemine.ts b/src/mappings/nfts/getters/statemine.ts new file mode 100644 index 0000000..55703c2 --- /dev/null +++ b/src/mappings/nfts/getters/statemine.ts @@ -0,0 +1,338 @@ +import { Interaction } from '../../../model' +import { NonFungible as Event } from '../../../processable' +import * as events from '../../../types/statemine/events' +import { addressOf } from '../../utils/helper' +import { warn } from '../../utils/logger' +import { Context } from '../../utils/types' +import { + BurnTokenEvent, + BuyTokenEvent, + ChangeCollectionOwnerEvent, + ChangeCollectionTeam, + CreateCollectionEvent, + CreateTokenEvent, + DestroyCollectionEvent, + ForceCreateCollectionEvent, + ListTokenEvent, + LockCollectionEvent, + SetAttribute, + SetMetadata, + TransferTokenEvent, +} from '../types' + +export function getCreateCollectionEvent(ctx: Context): CreateCollectionEvent { + const event = new events.NftsCreatedEvent(ctx) + + if (event.isV9420) { + const { collection: classId, creator, owner } = event.asV9420 + return { id: classId.toString(), caller: addressOf(creator), owner: addressOf(owner) } + } + warn(Interaction.CREATE, 'USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { collection: classId, creator, owner } = ctx._chain.decodeEvent(ctx.event) + return { id: classId.toString(), caller: addressOf(creator), owner: addressOf(owner) } +} + +export function getForceCreateCollectionEvent(ctx: Context): ForceCreateCollectionEvent { + const event = new events.NftsForceCreatedEvent(ctx) + + if (event.isV9420) { + const { collection: classId, owner } = event.asV9420 + return { id: classId.toString(), owner: addressOf(owner) } + } + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { collection: classId, owner } = ctx._chain.decodeEvent(ctx.event) + return { id: classId.toString(), owner: addressOf(owner) } +} + +export function getCreateTokenEvent(ctx: Context): CreateTokenEvent { + const event = new events.NftsIssuedEvent(ctx) + + if (event.isV9420) { + const { collection: classId, item: instanceId, owner } = event.asV9420 + return { collectionId: classId.toString(), owner: addressOf(owner), sn: instanceId.toString() } + } + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { collection: classId, item: instanceId, owner } = ctx._chain.decodeEvent(ctx.event) + return { collectionId: classId.toString(), owner: addressOf(owner), sn: instanceId.toString() } +} + +export function getTransferTokenEvent(ctx: Context): TransferTokenEvent { + const event = new events.NftsTransferredEvent(ctx) + + if (event.isV9420) { + const { collection: classId, item: instanceId, from, to } = event.asV9420 + return { collectionId: classId.toString(), caller: addressOf(from), sn: instanceId.toString(), to: addressOf(to) } + } + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { collection: classId, item: instanceId, from, to } = ctx._chain.decodeEvent(ctx.event) + return { collectionId: classId.toString(), caller: addressOf(from), sn: instanceId.toString(), to: addressOf(to) } +} + +export function getBurnTokenEvent(ctx: Context): BurnTokenEvent { + const event = new events.NftsBurnedEvent(ctx) + + if (event.isV9420) { + const { collection: classId, item: instanceId, owner } = event.asV9420 + return { collectionId: classId.toString(), owner: addressOf(owner), sn: instanceId.toString() } + } + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { collection: classId, item: instanceId, owner } = ctx._chain.decodeEvent(ctx.event) + return { collectionId: classId.toString(), owner: addressOf(owner), sn: instanceId.toString() } +} + +export function getDestroyCollectionEvent(ctx: Context): DestroyCollectionEvent { + const event = new events.NftsDestroyedEvent(ctx) + + if (event.isV9420) { + const { collection: classId } = event.asV9420 + return { id: classId.toString() } + } + + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { collection: classId } = ctx._chain.decodeEvent(ctx.event) + return { id: classId.toString() } +} + +export function getListTokenEvent(ctx: Context): ListTokenEvent { + const event = new events.NftsItemPriceSetEvent(ctx) + + if (event.isV9420) { + const { collection: classId, item: instanceId, price } = event.asV9420 + return { collectionId: classId.toString(), sn: instanceId.toString(), price } + } + + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { collection: classId, item: instanceId, price } = ctx._chain.decodeEvent(ctx.event) + return { collectionId: classId.toString(), sn: instanceId.toString(), price } +} + +export function getUnListTokenEvent(ctx: Context): ListTokenEvent { + const event = new events.NftsItemPriceRemovedEvent(ctx) + + if (event.isV9420) { + const { collection: classId, item: instanceId } = event.asV9420 + return { collectionId: classId.toString(), sn: instanceId.toString(), price: 0n } + } + + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { collection: classId, item: instanceId, price } = ctx._chain.decodeEvent(ctx.event) + return { collectionId: classId.toString(), sn: instanceId.toString(), price: 0n } +} + +export function getPriceTokenEvent(ctx: Context): ListTokenEvent { + if (ctx.event.name === Event.setPrice) { + return getListTokenEvent(ctx) + } + + return getUnListTokenEvent(ctx) +} + +export function getBuyTokenEvent(ctx: Context): BuyTokenEvent { + const event = new events.NftsItemBoughtEvent(ctx) + + if (event.isV9420) { + const { collection: classId, item: instanceId, price, seller, buyer } = event.asV9420 + return { + collectionId: classId.toString(), + caller: addressOf(buyer), + sn: instanceId.toString(), + price: BigInt(price ?? 0), + currentOwner: addressOf(seller), + } + } + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { collection: classId, item: instanceId, price, seller, buyer } = ctx._chain.decodeEvent(ctx.event) + return { + collectionId: classId.toString(), + caller: addressOf(buyer), + sn: instanceId.toString(), + price: BigInt(price ?? 0), + currentOwner: addressOf(seller), + } +} + +export function getLockCollectionEvent(ctx: Context): LockCollectionEvent { + const event = new events.NftsCollectionMaxSupplySetEvent(ctx) + if (event.isV9420) { + const { collection: classId, maxSupply: max } = event.asV9420 + return { id: classId.toString(), max } + } + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { collection: classId, mamaxSupply: max } = ctx._chain.decodeEvent(ctx.event) + return { id: classId.toString(), max } +} + +export function getChangeCollectionOwnerEvent(ctx: Context): ChangeCollectionOwnerEvent { + const event = new events.NftsOwnerChangedEvent(ctx) + + if (event.isV9420) { + const { collection: classId, newOwner } = event.asV9420 + return { id: classId.toString(), owner: addressOf(newOwner) } + } + + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { collection: classId, newOwner } = ctx._chain.decodeEvent(ctx.event) + return { id: classId.toString(), owner: addressOf(newOwner) } +} + +export function getClearCollectionMetadataEvent(ctx: Context): SetMetadata { + const event = new events.NftsCollectionMetadataClearedEvent(ctx) + + if (event.isV9420) { + const { collection: classId } = event.asV9420 + return { collectionId: classId.toString() } + } + + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { collection: classId } = ctx._chain.decodeEvent(ctx.event) + return { collectionId: classId.toString() } +} + +export function getCreateCollectionMetadataEvent(ctx: Context): SetMetadata { + const event = new events.NftsCollectionMetadataSetEvent(ctx) + + if (event.isV9420) { + const { collection: classId, data } = event.asV9420 + return { collectionId: classId.toString(), metadata: data.toString() } + } + + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { class: classId, data, isFrozen } = ctx._chain.decodeEvent(ctx.event) + return { collectionId: classId.toString(), metadata: data.toString() } +} + +export function getClearClassMetadataEvent(ctx: Context): SetMetadata { + const event = new events.NftsCollectionMetadataSetEvent(ctx) + + if (event.isV9420) { + const { collection: classId, data } = event.asV9420 + return { collectionId: classId.toString() } + } + + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { class: classId } = ctx._chain.decodeEvent(ctx.event) + return { collectionId: classId.toString() } +} + +export function getCreateClassMetadataEvent(ctx: Context): SetMetadata { + const event = new events.NftsCollectionMetadataSetEvent(ctx) + + if (event.isV9420) { + const { collection: classId, data } = event.asV9420 + return { collectionId: classId.toString(), metadata: data.toString() } + } + + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { class: classId, data, isFrozen } = ctx._chain.decodeEvent(ctx.event) + return { collectionId: classId.toString(), metadata: data.toString() } +} + +export function getCreateMetadataEvent(ctx: Context): SetMetadata { + const event = new events.NftsItemMetadataSetEvent(ctx) + + if (event.isV9420) { + const { collection: classId, item: instanceId, data } = event.asV9420 + return { collectionId: classId.toString(), sn: instanceId.toString(), metadata: data.toString() } + } + + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { collection: classId, item: instanceId, data, isFrozen } = ctx._chain.decodeEvent(ctx.event) + return { collectionId: classId.toString(), sn: instanceId.toString(), metadata: data.toString() } +} + +export function getClearMetadataEvent(ctx: Context): SetMetadata { + const event = new events.NftsItemMetadataClearedEvent(ctx) + + if (event.isV9420) { + const { collection: classId, item: instanceId } = event.asV9420 + return { collectionId: classId.toString(), sn: instanceId.toString() } + } + + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { collection: classId, item: instanceId } = ctx._chain.decodeEvent(ctx.event) + return { collectionId: classId.toString(), sn: instanceId.toString() } +} + +export function getMetadataEvent(ctx: Context): SetMetadata { + switch (ctx.event.name) { + case Event.setCollectionMetadata: + return getCreateCollectionMetadataEvent(ctx) + case Event.clearCollectionMetadata: + return getClearCollectionMetadataEvent(ctx) + case Event.setMetadata: + return getCreateMetadataEvent(ctx) + case Event.clearMetadata: + return getClearMetadataEvent(ctx) + default: + throw new Error('Unsupported event') + } +} + +function getSetAttributeEvent(ctx: Context): SetAttribute { + const event = new events.NftsAttributeSetEvent(ctx) + if (event.isV9420) { + const { collection: classId, maybeItem: instanceId, key, value } = event.asV9420 + return { + collectionId: classId.toString(), + sn: instanceId?.toString(), + trait: key.toString(), + value: value.toString(), + } + } + + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { collection: classId, maybeItem: instanceId, key, value } = ctx._chain.decodeEvent(ctx.event) + return { + collectionId: classId.toString(), + sn: instanceId?.toString(), + trait: key.toString(), + value: value.toString(), + } +} + +function getClearAttributeEvent(ctx: Context): SetAttribute { + const event = new events.NftsAttributeClearedEvent(ctx) + + if (event.isV9420) { + const { collection: classId, maybeItem: instanceId, key } = event.asV9420 + return { collectionId: classId.toString(), sn: instanceId?.toString(), trait: key.toString() } + } + + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { collection: classId, maybeItem: instanceId, key } = ctx._chain.decodeEvent(ctx.event) + return { collectionId: classId.toString(), sn: instanceId?.toString(), trait: key.toString() } +} + +export function getAttributeEvent(ctx: Context): SetAttribute { + switch (ctx.event.name) { + case Event.setAttribute: + return getSetAttributeEvent(ctx) + case Event.clearAttribute: + return getClearAttributeEvent(ctx) + default: + throw new Error('Unsupported event') + } +} + +export function getChangeTeamEvent(ctx: Context): ChangeCollectionTeam { + const event = new events.NftsTeamChangedEvent(ctx) + + if (event.isV9420) { + const { collection: classId, issuer, admin, freezer } = event.asV9420 + return { + id: classId.toString(), + issuer: addressOf(issuer || ''), + admin: addressOf(admin || ''), + freezer: addressOf(freezer || ''), + } + } + + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { collection: classId, issuer, admin, freezer } = ctx._chain.decodeEvent(ctx.event) + return { + id: classId.toString(), + issuer: addressOf(issuer || ''), + admin: addressOf(admin || ''), + freezer: addressOf(freezer || ''), + } +} diff --git a/src/mappings/nfts/getters/statemint.ts b/src/mappings/nfts/getters/statemint.ts new file mode 100644 index 0000000..a577bd6 --- /dev/null +++ b/src/mappings/nfts/getters/statemint.ts @@ -0,0 +1,338 @@ +import { Interaction } from '../../../model' +import { NonFungible as Event } from '../../../processable' +import * as events from '../../../types/statemint/events' +import { addressOf } from '../../utils/helper' +import { warn } from '../../utils/logger' +import { Context } from '../../utils/types' +import { + BurnTokenEvent, + BuyTokenEvent, + ChangeCollectionOwnerEvent, + ChangeCollectionTeam, + CreateCollectionEvent, + CreateTokenEvent, + DestroyCollectionEvent, + ForceCreateCollectionEvent, + ListTokenEvent, + LockCollectionEvent, + SetAttribute, + SetMetadata, + TransferTokenEvent, +} from '../types' + +export function getCreateCollectionEvent(ctx: Context): CreateCollectionEvent { + const event = new events.NftsCreatedEvent(ctx) + + if (event.isV9430) { + const { collection: classId, creator, owner } = event.asV9430 + return { id: classId.toString(), caller: addressOf(creator), owner: addressOf(owner) } + } + warn(Interaction.CREATE, 'USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { collection: classId, creator, owner } = ctx._chain.decodeEvent(ctx.event) + return { id: classId.toString(), caller: addressOf(creator), owner: addressOf(owner) } +} + +export function getForceCreateCollectionEvent(ctx: Context): ForceCreateCollectionEvent { + const event = new events.NftsForceCreatedEvent(ctx) + + if (event.isV9430) { + const { collection: classId, owner } = event.asV9430 + return { id: classId.toString(), owner: addressOf(owner) } + } + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { collection: classId, owner } = ctx._chain.decodeEvent(ctx.event) + return { id: classId.toString(), owner: addressOf(owner) } +} + +export function getCreateTokenEvent(ctx: Context): CreateTokenEvent { + const event = new events.NftsIssuedEvent(ctx) + + if (event.isV9430) { + const { collection: classId, item: instanceId, owner } = event.asV9430 + return { collectionId: classId.toString(), owner: addressOf(owner), sn: instanceId.toString() } + } + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { collection: classId, item: instanceId, owner } = ctx._chain.decodeEvent(ctx.event) + return { collectionId: classId.toString(), owner: addressOf(owner), sn: instanceId.toString() } +} + +export function getTransferTokenEvent(ctx: Context): TransferTokenEvent { + const event = new events.NftsTransferredEvent(ctx) + + if (event.isV9430) { + const { collection: classId, item: instanceId, from, to } = event.asV9430 + return { collectionId: classId.toString(), caller: addressOf(from), sn: instanceId.toString(), to: addressOf(to) } + } + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { collection: classId, item: instanceId, from, to } = ctx._chain.decodeEvent(ctx.event) + return { collectionId: classId.toString(), caller: addressOf(from), sn: instanceId.toString(), to: addressOf(to) } +} + +export function getBurnTokenEvent(ctx: Context): BurnTokenEvent { + const event = new events.NftsBurnedEvent(ctx) + + if (event.isV9430) { + const { collection: classId, item: instanceId, owner } = event.asV9430 + return { collectionId: classId.toString(), owner: addressOf(owner), sn: instanceId.toString() } + } + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { collection: classId, item: instanceId, owner } = ctx._chain.decodeEvent(ctx.event) + return { collectionId: classId.toString(), owner: addressOf(owner), sn: instanceId.toString() } +} + +export function getDestroyCollectionEvent(ctx: Context): DestroyCollectionEvent { + const event = new events.NftsDestroyedEvent(ctx) + + if (event.isV9430) { + const { collection: classId } = event.asV9430 + return { id: classId.toString() } + } + + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { collection: classId } = ctx._chain.decodeEvent(ctx.event) + return { id: classId.toString() } +} + +export function getListTokenEvent(ctx: Context): ListTokenEvent { + const event = new events.NftsItemPriceSetEvent(ctx) + + if (event.isV9430) { + const { collection: classId, item: instanceId, price } = event.asV9430 + return { collectionId: classId.toString(), sn: instanceId.toString(), price } + } + + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { collection: classId, item: instanceId, price } = ctx._chain.decodeEvent(ctx.event) + return { collectionId: classId.toString(), sn: instanceId.toString(), price } +} + +export function getUnListTokenEvent(ctx: Context): ListTokenEvent { + const event = new events.NftsItemPriceRemovedEvent(ctx) + + if (event.isV9430) { + const { collection: classId, item: instanceId } = event.asV9430 + return { collectionId: classId.toString(), sn: instanceId.toString(), price: 0n } + } + + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { collection: classId, item: instanceId, price } = ctx._chain.decodeEvent(ctx.event) + return { collectionId: classId.toString(), sn: instanceId.toString(), price: 0n } +} + +export function getPriceTokenEvent(ctx: Context): ListTokenEvent { + if (ctx.event.name === Event.setPrice) { + return getListTokenEvent(ctx) + } + + return getUnListTokenEvent(ctx) +} + +export function getBuyTokenEvent(ctx: Context): BuyTokenEvent { + const event = new events.NftsItemBoughtEvent(ctx) + + if (event.isV9430) { + const { collection: classId, item: instanceId, price, seller, buyer } = event.asV9430 + return { + collectionId: classId.toString(), + caller: addressOf(buyer), + sn: instanceId.toString(), + price: BigInt(price ?? 0), + currentOwner: addressOf(seller), + } + } + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { collection: classId, item: instanceId, price, seller, buyer } = ctx._chain.decodeEvent(ctx.event) + return { + collectionId: classId.toString(), + caller: addressOf(buyer), + sn: instanceId.toString(), + price: BigInt(price ?? 0), + currentOwner: addressOf(seller), + } +} + +export function getLockCollectionEvent(ctx: Context): LockCollectionEvent { + const event = new events.NftsCollectionMaxSupplySetEvent(ctx) + if (event.isV9430) { + const { collection: classId, maxSupply: max } = event.asV9430 + return { id: classId.toString(), max } + } + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { collection: classId, mamaxSupply: max } = ctx._chain.decodeEvent(ctx.event) + return { id: classId.toString(), max } +} + +export function getChangeCollectionOwnerEvent(ctx: Context): ChangeCollectionOwnerEvent { + const event = new events.NftsOwnerChangedEvent(ctx) + + if (event.isV9430) { + const { collection: classId, newOwner } = event.asV9430 + return { id: classId.toString(), owner: addressOf(newOwner) } + } + + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { collection: classId, newOwner } = ctx._chain.decodeEvent(ctx.event) + return { id: classId.toString(), owner: addressOf(newOwner) } +} + +export function getClearCollectionMetadataEvent(ctx: Context): SetMetadata { + const event = new events.NftsCollectionMetadataClearedEvent(ctx) + + if (event.isV9430) { + const { collection: classId } = event.asV9430 + return { collectionId: classId.toString() } + } + + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { collection: classId } = ctx._chain.decodeEvent(ctx.event) + return { collectionId: classId.toString() } +} + +export function getCreateCollectionMetadataEvent(ctx: Context): SetMetadata { + const event = new events.NftsCollectionMetadataSetEvent(ctx) + + if (event.isV9430) { + const { collection: classId, data } = event.asV9430 + return { collectionId: classId.toString(), metadata: data.toString() } + } + + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { class: classId, data, isFrozen } = ctx._chain.decodeEvent(ctx.event) + return { collectionId: classId.toString(), metadata: data.toString() } +} + +export function getClearClassMetadataEvent(ctx: Context): SetMetadata { + const event = new events.NftsCollectionMetadataSetEvent(ctx) + + if (event.isV9430) { + const { collection: classId, data } = event.asV9430 + return { collectionId: classId.toString() } + } + + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { class: classId } = ctx._chain.decodeEvent(ctx.event) + return { collectionId: classId.toString() } +} + +export function getCreateClassMetadataEvent(ctx: Context): SetMetadata { + const event = new events.NftsCollectionMetadataSetEvent(ctx) + + if (event.isV9430) { + const { collection: classId, data } = event.asV9430 + return { collectionId: classId.toString(), metadata: data.toString() } + } + + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { class: classId, data, isFrozen } = ctx._chain.decodeEvent(ctx.event) + return { collectionId: classId.toString(), metadata: data.toString() } +} + +export function getCreateMetadataEvent(ctx: Context): SetMetadata { + const event = new events.NftsItemMetadataSetEvent(ctx) + + if (event.isV9430) { + const { collection: classId, item: instanceId, data } = event.asV9430 + return { collectionId: classId.toString(), sn: instanceId.toString(), metadata: data.toString() } + } + + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { collection: classId, item: instanceId, data, isFrozen } = ctx._chain.decodeEvent(ctx.event) + return { collectionId: classId.toString(), sn: instanceId.toString(), metadata: data.toString() } +} + +export function getClearMetadataEvent(ctx: Context): SetMetadata { + const event = new events.NftsItemMetadataClearedEvent(ctx) + + if (event.isV9430) { + const { collection: classId, item: instanceId } = event.asV9430 + return { collectionId: classId.toString(), sn: instanceId.toString() } + } + + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { collection: classId, item: instanceId } = ctx._chain.decodeEvent(ctx.event) + return { collectionId: classId.toString(), sn: instanceId.toString() } +} + +export function getMetadataEvent(ctx: Context): SetMetadata { + switch (ctx.event.name) { + case Event.setCollectionMetadata: + return getCreateCollectionMetadataEvent(ctx) + case Event.clearCollectionMetadata: + return getClearCollectionMetadataEvent(ctx) + case Event.setMetadata: + return getCreateMetadataEvent(ctx) + case Event.clearMetadata: + return getClearMetadataEvent(ctx) + default: + throw new Error('Unsupported event') + } +} + +function getSetAttributeEvent(ctx: Context): SetAttribute { + const event = new events.NftsAttributeSetEvent(ctx) + if (event.isV9430) { + const { collection: classId, maybeItem: instanceId, key, value } = event.asV9430 + return { + collectionId: classId.toString(), + sn: instanceId?.toString(), + trait: key.toString(), + value: value.toString(), + } + } + + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { collection: classId, maybeItem: instanceId, key, value } = ctx._chain.decodeEvent(ctx.event) + return { + collectionId: classId.toString(), + sn: instanceId?.toString(), + trait: key.toString(), + value: value.toString(), + } +} + +function getClearAttributeEvent(ctx: Context): SetAttribute { + const event = new events.NftsAttributeClearedEvent(ctx) + + if (event.isV9430) { + const { collection: classId, maybeItem: instanceId, key } = event.asV9430 + return { collectionId: classId.toString(), sn: instanceId?.toString(), trait: key.toString() } + } + + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { collection: classId, maybeItem: instanceId, key } = ctx._chain.decodeEvent(ctx.event) + return { collectionId: classId.toString(), sn: instanceId?.toString(), trait: key.toString() } +} + +export function getAttributeEvent(ctx: Context): SetAttribute { + switch (ctx.event.name) { + case Event.setAttribute: + return getSetAttributeEvent(ctx) + case Event.clearAttribute: + return getClearAttributeEvent(ctx) + default: + throw new Error('Unsupported event') + } +} + +export function getChangeTeamEvent(ctx: Context): ChangeCollectionTeam { + const event = new events.NftsTeamChangedEvent(ctx) + + if (event.isV9430) { + const { collection: classId, issuer, admin, freezer } = event.asV9430 + return { + id: classId.toString(), + issuer: addressOf(issuer || ''), + admin: addressOf(admin || ''), + freezer: addressOf(freezer || ''), + } + } + + ctx.log.warn('USING UNSAFE GETTER! PLS UPDATE TYPES!') + const { collection: classId, issuer, admin, freezer } = ctx._chain.decodeEvent(ctx.event) + return { + id: classId.toString(), + issuer: addressOf(issuer || ''), + admin: addressOf(admin || ''), + freezer: addressOf(freezer || ''), + } +} From 8a41841483a98da73f802b846574a7be9e2860eb Mon Sep 17 00:00:00 2001 From: Viki Val Date: Tue, 18 Jul 2023 16:15:22 +0200 Subject: [PATCH 5/5] :wrench: V2 of speck --- speck.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/speck.yaml b/speck.yaml index 0c37449..3bf624f 100644 --- a/speck.yaml +++ b/speck.yaml @@ -1,6 +1,6 @@ manifestVersion: subsquid.io/v0.1 name: speck -version: 1 +version: 2 description: 'SubSquid indexer for Uniques and Assets on Statemint' build: deploy: