diff --git a/.github/workflows/subsquid.yml b/.github/workflows/subsquid.yml index 74e0785..c9d7d53 100644 --- a/.github/workflows/subsquid.yml +++ b/.github/workflows/subsquid.yml @@ -8,10 +8,10 @@ jobs: deploy: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: - node-version: 16 + node-version: 20 - name: install @subsquid/cli run: npm install --location=global @subsquid/cli - name: auth subsquid diff --git a/src/mappings/shared/token/tokenAPI.ts b/src/mappings/shared/token/tokenAPI.ts index 94737ac..e8b9f70 100644 --- a/src/mappings/shared/token/tokenAPI.ts +++ b/src/mappings/shared/token/tokenAPI.ts @@ -44,7 +44,11 @@ export class TokenAPI { debug(OPERATION, { removeNftFromToken: `Unlink NFT ${nft.id} from TOKEN ${token.id}` }) await emOf(this.store).update(NE, nft.id, { token: null }) - const updatedCount = token.count - 1 + const updatedCount = await emOf(this.store).countBy(NE, { + token: { + id: token.id, + }, + }) await emOf(this.store).update(TE, token.id, { supply: token.supply - 1, count: updatedCount, @@ -53,8 +57,14 @@ export class TokenAPI { if (updatedCount === 0) { debug(OPERATION, { deleteEmptyToken: `delete empty token ${token.id}` }) - - await emOf(this.store).delete(TE, token.id) + try { + await emOf(this.store).delete(TE, token.id) + } catch (error) { + debug(OPERATION, { + deleteEmptyToken: `Failed to delete token ${token.id}`, + error, + }) + } } } diff --git a/src/mappings/shared/token/utils.ts b/src/mappings/shared/token/utils.ts index 167c844..615c2ac 100644 --- a/src/mappings/shared/token/utils.ts +++ b/src/mappings/shared/token/utils.ts @@ -30,3 +30,4 @@ export const tokenName = (nftName: string | undefined | null, collectionId: stri return doNotAlter ? nftName : nftName.replace(/([#_]\d+$)/g, '') } +