From 54432e52cfe538f1bc19c773a0e5fd1dd3b72c0c Mon Sep 17 00:00:00 2001 From: roiLeo Date: Wed, 22 Nov 2023 09:26:33 +0100 Subject: [PATCH 01/10] =?UTF-8?q?=F0=9F=92=85=20metadata=20banner?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/migrations/1700640840193-Data.js | 17 +++++++++++++++++ schema.graphql | 1 + src/mappings/shared/metadata.ts | 3 ++- src/model/generated/metadataEntity.model.ts | 3 +++ src/types/statemine/events.ts | 15 +++++++++++++++ 5 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 db/migrations/1700640840193-Data.js diff --git a/db/migrations/1700640840193-Data.js b/db/migrations/1700640840193-Data.js new file mode 100644 index 00000000..a0310ebb --- /dev/null +++ b/db/migrations/1700640840193-Data.js @@ -0,0 +1,17 @@ +module.exports = class Data1700640840193 { + name = 'Data1700640840193' + + async up(db) { + await db.query(`ALTER TABLE "token_entity" DROP CONSTRAINT "FK_637db5c040f1d9f935817ae1e8a"`) + await db.query(`DROP INDEX "public"."IDX_637db5c040f1d9f935817ae1e8"`) + await db.query(`ALTER TABLE "token_entity" DROP COLUMN "cheapest_id"`) + await db.query(`ALTER TABLE "metadata_entity" ADD "banner" text`) + } + + async down(db) { + await db.query(`ALTER TABLE "token_entity" ADD CONSTRAINT "FK_637db5c040f1d9f935817ae1e8a" FOREIGN KEY ("cheapest_id") REFERENCES "nft_entity"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + await db.query(`CREATE INDEX "IDX_637db5c040f1d9f935817ae1e8" ON "token_entity" ("cheapest_id") `) + await db.query(`ALTER TABLE "token_entity" ADD "cheapest_id" character varying`) + await db.query(`ALTER TABLE "metadata_entity" DROP COLUMN "banner"`) + } +} diff --git a/schema.graphql b/schema.graphql index 3ea76741..6d993518 100644 --- a/schema.graphql +++ b/schema.graphql @@ -77,6 +77,7 @@ type MetadataEntity @entity { attributes: [Attribute!] animationUrl: String type: String + banner: String } type Attribute @jsonField { diff --git a/src/mappings/shared/metadata.ts b/src/mappings/shared/metadata.ts index 427b2be4..da22e95a 100644 --- a/src/mappings/shared/metadata.ts +++ b/src/mappings/shared/metadata.ts @@ -16,7 +16,7 @@ export async function handleMetadata(id: string, store: Store): Promise(id) + const metadata = await fetchMetadata(id) if (isEmpty(metadata)) { return undefined } @@ -29,6 +29,7 @@ export async function handleMetadata(id: string, store: Store): Promise(Metadata, id, partial) diff --git a/src/model/generated/metadataEntity.model.ts b/src/model/generated/metadataEntity.model.ts index 81229912..17e4601c 100644 --- a/src/model/generated/metadataEntity.model.ts +++ b/src/model/generated/metadataEntity.model.ts @@ -28,4 +28,7 @@ export class MetadataEntity { @Column_("text", {nullable: true}) type!: string | undefined | null + + @Column_("text", {nullable: true}) + banner!: string | undefined | null } diff --git a/src/types/statemine/events.ts b/src/types/statemine/events.ts index 9ea731d3..e1b10f0b 100644 --- a/src/types/statemine/events.ts +++ b/src/types/statemine/events.ts @@ -757,6 +757,21 @@ export class NftsNextCollectionIdIncrementedEvent { assert(this.isV9420) return this._chain.decodeEvent(this.event) } + + /** + * Event gets emitted when the `NextCollectionId` gets incremented. + */ + get isV1000000(): boolean { + return this._chain.getEventHash('Nfts.NextCollectionIdIncremented') === 'cd3fe8f02b8e066babd9b85bf60f6760d52be27f9e088f03bf00392c80d5fc5d' + } + + /** + * Event gets emitted when the `NextCollectionId` gets incremented. + */ + get asV1000000(): {nextId: (number | undefined)} { + assert(this.isV1000000) + return this._chain.decodeEvent(this.event) + } } export class NftsOwnerChangedEvent { From 7844cffd13eeb145ff08054a6b0cc0a81f88b0a5 Mon Sep 17 00:00:00 2001 From: Viki Val Date: Sat, 25 Nov 2023 14:31:29 +0100 Subject: [PATCH 02/10] Create feature_request.md --- .github/ISSUE_TEMPLATE/feature_request.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 00000000..329f5fc5 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature Request +about: What would you like to see in this indexer +title: '' +labels: '' +assignees: '@vikiival' + +--- + +**Describe the feature** +A clear and concise description of what the feature is. + +**Expected outcome** +A clear and concise description of what is your expected outcome. + +**Reference** +Have you seen it somewhere? Share a link/screenshot + +**Additional context** +Add any other context about the problem here. From 4aefe3d844807555d997abe08b67747d71006ab5 Mon Sep 17 00:00:00 2001 From: roiLeo Date: Tue, 5 Dec 2023 16:46:32 +0100 Subject: [PATCH 03/10] =?UTF-8?q?=F0=9F=94=A7=20collection=20royalty=20rec?= =?UTF-8?q?ipient?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 1 + .gitignore | 5 ++++- src/mappings/nfts/setAttribute.ts | 5 +++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.env b/.env index f68973ad..d688f9ab 100644 --- a/.env +++ b/.env @@ -3,3 +3,4 @@ DB_PORT=23798 PROCESSOR_PROMETHEUS_PORT=3000 GQL_PORT=4350 SQD_DEBUG=* +CHAIN=statemint diff --git a/.gitignore b/.gitignore index 72d350dd..f3f1727e 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,7 @@ # IDE files /.idea /suite -/.vscode \ No newline at end of file +/.vscode + +# Local env files +.env \ No newline at end of file diff --git a/src/mappings/nfts/setAttribute.ts b/src/mappings/nfts/setAttribute.ts index cd6e0d01..22611ac8 100644 --- a/src/mappings/nfts/setAttribute.ts +++ b/src/mappings/nfts/setAttribute.ts @@ -2,6 +2,7 @@ import { getOrFail as get } from '@kodadot1/metasquid/entity' import { CollectionEntity, NFTEntity } from '../../model' import { unwrap } from '../utils/extract' import { Context, isNFT } from '../utils/types' +import { addressOf } from '../utils/helper' import { getAttributeEvent } from './getters' import { attributeFrom, tokenIdOf } from './types' @@ -17,11 +18,11 @@ export async function handleAttributeSet(context: Context): Promise { } if ('royalty' in final && event.trait === 'royalty') { - final.royalty = final.royalty ?? Number.parseFloat(event.value as string) + final.royalty ??= Number.parseFloat(event.value as string) } if ('recipient' in final && event.trait === 'recipient') { - final.recipient = final.recipient ?? event.value as string + final.recipient ??= addressOf(event.value as string) } if (event.value === null) { From 6f01f15a5557ea5431daa6d47e238d7987a6fa04 Mon Sep 17 00:00:00 2001 From: roiLeo Date: Tue, 5 Dec 2023 19:01:23 +0100 Subject: [PATCH 04/10] =?UTF-8?q?=F0=9F=94=A7=20collection=20royalty=20typ?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mappings/nfts/getters/statemint.ts | 4 ++-- src/mappings/nfts/setAttribute.ts | 10 ++++++++-- src/mappings/nfts/types.ts | 2 +- src/mappings/uniques/getters/statemine.ts | 6 +++--- src/mappings/uniques/getters/statemint.ts | 6 +++--- src/mappings/uniques/types.ts | 2 +- 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/mappings/nfts/getters/statemint.ts b/src/mappings/nfts/getters/statemint.ts index fbe2ca97..bb1421c9 100644 --- a/src/mappings/nfts/getters/statemint.ts +++ b/src/mappings/nfts/getters/statemint.ts @@ -276,7 +276,7 @@ function getSetAttributeEvent(ctx: Context): SetAttribute { collectionId: classId.toString(), sn: instanceId?.toString(), trait: key.toString(), - value: value.toString(), + value, } } @@ -286,7 +286,7 @@ function getSetAttributeEvent(ctx: Context): SetAttribute { collectionId: classId.toString(), sn: instanceId?.toString(), trait: key.toString(), - value: value.toString(), + value, } } diff --git a/src/mappings/nfts/setAttribute.ts b/src/mappings/nfts/setAttribute.ts index 22611ac8..a39181c4 100644 --- a/src/mappings/nfts/setAttribute.ts +++ b/src/mappings/nfts/setAttribute.ts @@ -1,4 +1,5 @@ import { getOrFail as get } from '@kodadot1/metasquid/entity' +import { decodeHex } from '@subsquid/substrate-processor' import { CollectionEntity, NFTEntity } from '../../model' import { unwrap } from '../utils/extract' import { Context, isNFT } from '../utils/types' @@ -18,11 +19,16 @@ export async function handleAttributeSet(context: Context): Promise { } if ('royalty' in final && event.trait === 'royalty') { - final.royalty ??= Number.parseFloat(event.value as string) + final.royalty = final.royalty ?? Number.parseFloat(event.value as string) } if ('recipient' in final && event.trait === 'recipient') { - final.recipient ??= addressOf(event.value as string) + try { + final.recipient = final.recipient ?? addressOf(event.value as string) + } catch (error) { + console.log(error) + final.recipient = final.recipient ?? (event.value as string) + } } if (event.value === null) { diff --git a/src/mappings/nfts/types.ts b/src/mappings/nfts/types.ts index 967c591c..352b0665 100644 --- a/src/mappings/nfts/types.ts +++ b/src/mappings/nfts/types.ts @@ -68,7 +68,7 @@ export type SetMetadata = Omit & export type SetAttribute = Omit & { sn?: string trait: string - value?: string + value?: string | Uint8Array } export type ChangeCollectionTeam = WithId & { diff --git a/src/mappings/uniques/getters/statemine.ts b/src/mappings/uniques/getters/statemine.ts index e2b94b05..3b22c5bc 100644 --- a/src/mappings/uniques/getters/statemine.ts +++ b/src/mappings/uniques/getters/statemine.ts @@ -346,7 +346,7 @@ function getSetAttributeEvent(ctx: Context): SetAttribute { collectionId: idOf(classId, U), sn: instanceId?.toString(), trait: key.toString(), - value: value.toString(), + value, } } if (event.isV700) { @@ -355,7 +355,7 @@ function getSetAttributeEvent(ctx: Context): SetAttribute { collectionId: idOf(classId, U), sn: instanceId?.toString(), trait: key.toString(), - value: value.toString(), + value, } } if (event.isV9230) { @@ -364,7 +364,7 @@ function getSetAttributeEvent(ctx: Context): SetAttribute { collectionId: idOf(classId, U), sn: instanceId?.toString(), trait: key.toString(), - value: value.toString(), + value, } } diff --git a/src/mappings/uniques/getters/statemint.ts b/src/mappings/uniques/getters/statemint.ts index 7e296384..c547c831 100644 --- a/src/mappings/uniques/getters/statemint.ts +++ b/src/mappings/uniques/getters/statemint.ts @@ -346,7 +346,7 @@ function getSetAttributeEvent(ctx: Context): SetAttribute { collectionId: idOf(classId, U), sn: instanceId?.toString(), trait: key.toString(), - value: value.toString(), + value, } } if (event.isV700) { @@ -355,7 +355,7 @@ function getSetAttributeEvent(ctx: Context): SetAttribute { collectionId: idOf(classId, U), sn: instanceId?.toString(), trait: key.toString(), - value: value.toString(), + value, } } if (event.isV9230) { @@ -364,7 +364,7 @@ function getSetAttributeEvent(ctx: Context): SetAttribute { collectionId: idOf(classId, U), sn: instanceId?.toString(), trait: key.toString(), - value: value.toString(), + value, } } diff --git a/src/mappings/uniques/types.ts b/src/mappings/uniques/types.ts index 2ec094c0..59c3704f 100644 --- a/src/mappings/uniques/types.ts +++ b/src/mappings/uniques/types.ts @@ -68,7 +68,7 @@ export type SetMetadata = Omit & export type SetAttribute = Omit & { sn?: string trait: string - value?: string + value?: string | Uint8Array } export type ChangeCollectionTeam = WithId & { From 97e58e237a3edb5e72a7f05108b0f85706a3b43e Mon Sep 17 00:00:00 2001 From: roiLeo Date: Tue, 5 Dec 2023 19:02:46 +0100 Subject: [PATCH 05/10] =?UTF-8?q?=E2=9E=96=20unused=20import?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mappings/nfts/setAttribute.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mappings/nfts/setAttribute.ts b/src/mappings/nfts/setAttribute.ts index a39181c4..4c343fc8 100644 --- a/src/mappings/nfts/setAttribute.ts +++ b/src/mappings/nfts/setAttribute.ts @@ -1,5 +1,4 @@ import { getOrFail as get } from '@kodadot1/metasquid/entity' -import { decodeHex } from '@subsquid/substrate-processor' import { CollectionEntity, NFTEntity } from '../../model' import { unwrap } from '../utils/extract' import { Context, isNFT } from '../utils/types' From 660b383cc7717e4fb98dd1cb8d924741e848d2d8 Mon Sep 17 00:00:00 2001 From: Viki Val Date: Wed, 6 Dec 2023 14:14:07 +0100 Subject: [PATCH 06/10] :wrench: just squid log --- .env | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.env b/.env index d688f9ab..00e19f9e 100644 --- a/.env +++ b/.env @@ -2,5 +2,4 @@ DB_NAME=squid DB_PORT=23798 PROCESSOR_PROMETHEUS_PORT=3000 GQL_PORT=4350 -SQD_DEBUG=* -CHAIN=statemint +SQD_DEBUG=squid:log From 743b7815296bf8d5722bde4acd56620febca5e5e Mon Sep 17 00:00:00 2001 From: Viki Val Date: Mon, 11 Dec 2023 12:28:35 +0100 Subject: [PATCH 07/10] Update speck.yaml --- speck.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/speck.yaml b/speck.yaml index 51e2bec0..31c18851 100644 --- a/speck.yaml +++ b/speck.yaml @@ -1,6 +1,6 @@ manifestVersion: subsquid.io/v0.1 name: speck -version: 8 +version: 9 description: 'SubSquid indexer for Uniques and Assets on Statemint' build: deploy: From 671b533233a4e4d9be5433c4a8eeb074eb6dcaa3 Mon Sep 17 00:00:00 2001 From: Viki Val Date: Mon, 11 Dec 2023 12:28:55 +0100 Subject: [PATCH 08/10] =?UTF-8?q?=F0=9F=94=96=20Stick=20v8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- squid.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/squid.yaml b/squid.yaml index 37d24961..7a8477b3 100644 --- a/squid.yaml +++ b/squid.yaml @@ -1,6 +1,6 @@ manifestVersion: subsquid.io/v0.1 name: stick -version: 7 +version: 8 description: 'SubSquid indexer for Uniques and Assets on Statemine' build: deploy: From 92a5206022eed9be5745067b8d1e71052aa7d08a Mon Sep 17 00:00:00 2001 From: Viki Val Date: Mon, 11 Dec 2023 12:33:51 +0100 Subject: [PATCH 09/10] :truck: migration --- db/migrations/1700640840193-Data.js | 17 ----------------- db/migrations/1702294404882-Data.js | 11 +++++++++++ 2 files changed, 11 insertions(+), 17 deletions(-) delete mode 100644 db/migrations/1700640840193-Data.js create mode 100644 db/migrations/1702294404882-Data.js diff --git a/db/migrations/1700640840193-Data.js b/db/migrations/1700640840193-Data.js deleted file mode 100644 index a0310ebb..00000000 --- a/db/migrations/1700640840193-Data.js +++ /dev/null @@ -1,17 +0,0 @@ -module.exports = class Data1700640840193 { - name = 'Data1700640840193' - - async up(db) { - await db.query(`ALTER TABLE "token_entity" DROP CONSTRAINT "FK_637db5c040f1d9f935817ae1e8a"`) - await db.query(`DROP INDEX "public"."IDX_637db5c040f1d9f935817ae1e8"`) - await db.query(`ALTER TABLE "token_entity" DROP COLUMN "cheapest_id"`) - await db.query(`ALTER TABLE "metadata_entity" ADD "banner" text`) - } - - async down(db) { - await db.query(`ALTER TABLE "token_entity" ADD CONSTRAINT "FK_637db5c040f1d9f935817ae1e8a" FOREIGN KEY ("cheapest_id") REFERENCES "nft_entity"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) - await db.query(`CREATE INDEX "IDX_637db5c040f1d9f935817ae1e8" ON "token_entity" ("cheapest_id") `) - await db.query(`ALTER TABLE "token_entity" ADD "cheapest_id" character varying`) - await db.query(`ALTER TABLE "metadata_entity" DROP COLUMN "banner"`) - } -} diff --git a/db/migrations/1702294404882-Data.js b/db/migrations/1702294404882-Data.js new file mode 100644 index 00000000..143af6b7 --- /dev/null +++ b/db/migrations/1702294404882-Data.js @@ -0,0 +1,11 @@ +module.exports = class Data1702294404882 { + name = 'Data1702294404882' + + async up(db) { + await db.query(`ALTER TABLE "metadata_entity" ADD "banner" text`) + } + + async down(db) { + await db.query(`ALTER TABLE "metadata_entity" DROP COLUMN "banner"`) + } +} From b977658935bc052c70a46423d9718906b40c0700 Mon Sep 17 00:00:00 2001 From: Viki Val Date: Mon, 11 Dec 2023 12:34:15 +0100 Subject: [PATCH 10/10] :bug: :label: banner type --- src/mappings/shared/metadata.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mappings/shared/metadata.ts b/src/mappings/shared/metadata.ts index da22e95a..05ee67eb 100644 --- a/src/mappings/shared/metadata.ts +++ b/src/mappings/shared/metadata.ts @@ -16,7 +16,7 @@ export async function handleMetadata(id: string, store: Store): Promise(id) + const metadata = await fetchMetadata(id) if (isEmpty(metadata)) { return undefined }