Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

smack snek #173

Merged
merged 2 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/mappings/utils/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,20 @@ import {
export function getCreateCollectionEvent(ctx: Context): CreateCollectionEvent {
if (isNewUnique(ctx, Event.createCollection)) {
const event = new NftCollectionCreatedEvent(ctx);
if (event.isV81) {
const {
collectionId: classId, owner, collectionType: classType, metadata,
} = event.asV81;
return {
id: classId.toString(), caller: addressOf(owner), metadata: metadata.toString(), type: classType.__kind,
};
}

const {
collectionId: classId, owner, collectionType: classType,
} = event.asV81;
collectionId: classId, owner, collectionType: classType, metadata,
} = event.asV92;
return {
id: classId.toString(), caller: addressOf(owner), metadata: undefined, type: classType.__kind,
id: classId.toString(), caller: addressOf(owner), metadata: metadata.toString(), type: classType.__kind,
};
}

Expand Down Expand Up @@ -253,4 +262,4 @@ export function getAcceptOfferEvent(ctx: Context): AcceptOfferEvent {
return {
collectionId: classId.toString(), sn: instanceId.toString(), caller: addressOf(caller), amount, maker: addressOf(maker),
};
}
}
16 changes: 16 additions & 0 deletions src/types/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as v55 from './v55'
import * as v62 from './v62'
import * as v71 from './v71'
import * as v81 from './v81'
import * as v92 from './v92'

export class AssetRegistryMetadataSetEvent {
private readonly _chain: Chain
Expand Down Expand Up @@ -711,6 +712,21 @@ export class NftCollectionCreatedEvent {
assert(this.isV81)
return this._chain.decodeEvent(this.event)
}

/**
* A collection was created
*/
get isV92(): boolean {
return this._chain.getEventHash('NFT.CollectionCreated') === '801df79a18d00e56f22b9269f4ab884baab643358045e07fb2fd388ae577534f'
}

/**
* A collection was created
*/
get asV92(): {owner: Uint8Array, collectionId: bigint, collectionType: v92.CollectionType, metadata: Uint8Array} {
assert(this.isV92)
return this._chain.decodeEvent(this.event)
}
}

export class NftCollectionDestroyedEvent {
Expand Down
11 changes: 11 additions & 0 deletions src/types/v92.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type {Result, Option} from './support'

export type CollectionType = CollectionType_Marketplace | CollectionType_LiquidityMining

export interface CollectionType_Marketplace {
__kind: 'Marketplace'
}

export interface CollectionType_LiquidityMining {
__kind: 'LiquidityMining'
}