Skip to content

Commit

Permalink
Merge pull request #159 from kodadot/main
Browse files Browse the repository at this point in the history
Speck v9
  • Loading branch information
vikiival authored Dec 11, 2023
2 parents 4436cac + f95a86d commit 8103214
Show file tree
Hide file tree
Showing 15 changed files with 61 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ DB_NAME=squid
DB_PORT=23798
PROCESSOR_PROMETHEUS_PORT=3000
GQL_PORT=4350
SQD_DEBUG=*
SQD_DEBUG=squid:log
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@
# IDE files
/.idea
/suite
/.vscode
/.vscode

# Local env files
.env
11 changes: 11 additions & 0 deletions db/migrations/1702294404882-Data.js
Original file line number Diff line number Diff line change
@@ -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"`)
}
}
1 change: 1 addition & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ type MetadataEntity @entity {
attributes: [Attribute!]
animationUrl: String
type: String
banner: String
}

type Attribute @jsonField {
Expand Down
2 changes: 1 addition & 1 deletion speck.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 1 addition & 1 deletion squid.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
4 changes: 2 additions & 2 deletions src/mappings/nfts/getters/statemint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ function getSetAttributeEvent(ctx: Context): SetAttribute {
collectionId: classId.toString(),
sn: instanceId?.toString(),
trait: key.toString(),
value: value.toString(),
value,
}
}

Expand All @@ -286,7 +286,7 @@ function getSetAttributeEvent(ctx: Context): SetAttribute {
collectionId: classId.toString(),
sn: instanceId?.toString(),
trait: key.toString(),
value: value.toString(),
value,
}
}

Expand Down
8 changes: 7 additions & 1 deletion src/mappings/nfts/setAttribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -21,7 +22,12 @@ export async function handleAttributeSet(context: Context): Promise<void> {
}

if ('recipient' in final && event.trait === 'recipient') {
final.recipient = final.recipient ?? 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) {
Expand Down
2 changes: 1 addition & 1 deletion src/mappings/nfts/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export type SetMetadata = Omit<BaseTokenEvent, 'sn'> &
export type SetAttribute = Omit<BaseTokenEvent, 'sn'> & {
sn?: string
trait: string
value?: string
value?: string | Uint8Array
}

export type ChangeCollectionTeam = WithId & {
Expand Down
3 changes: 2 additions & 1 deletion src/mappings/shared/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export async function handleMetadata(id: string, store: Store): Promise<Optional
const start = Date.now()
const logId = id.split('/').slice(-1).at(0)
logger.info(`▶️ [META] ${logId}`)
const metadata = await fetchMetadata<TokenMetadata>(id)
const metadata = await fetchMetadata<TokenMetadata & { banner?: string }>(id)
if (isEmpty(metadata)) {
return undefined
}
Expand All @@ -29,6 +29,7 @@ export async function handleMetadata(id: string, store: Store): Promise<Optional
attributes: metadata.attributes?.map(attributeFrom) || [],
name: metadata.name || '',
type: metadata.type || '',
banner: metadata.banner || '',
}

const final = create<Metadata>(Metadata, id, partial)
Expand Down
6 changes: 3 additions & 3 deletions src/mappings/uniques/getters/statemine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -364,7 +364,7 @@ function getSetAttributeEvent(ctx: Context): SetAttribute {
collectionId: idOf(classId, U),
sn: instanceId?.toString(),
trait: key.toString(),
value: value.toString(),
value,
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/mappings/uniques/getters/statemint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -364,7 +364,7 @@ function getSetAttributeEvent(ctx: Context): SetAttribute {
collectionId: idOf(classId, U),
sn: instanceId?.toString(),
trait: key.toString(),
value: value.toString(),
value,
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/mappings/uniques/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export type SetMetadata = Omit<BaseTokenEvent, 'sn'> &
export type SetAttribute = Omit<BaseTokenEvent, 'sn'> & {
sn?: string
trait: string
value?: string
value?: string | Uint8Array
}

export type ChangeCollectionTeam = WithId & {
Expand Down
3 changes: 3 additions & 0 deletions src/model/generated/metadataEntity.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,7 @@ export class MetadataEntity {

@Column_("text", {nullable: true})
type!: string | undefined | null

@Column_("text", {nullable: true})
banner!: string | undefined | null
}

0 comments on commit 8103214

Please sign in to comment.