From 1a93ca11ec7b62667334a17d6303c2deae02b071 Mon Sep 17 00:00:00 2001 From: Hugo Trentesaux <hugo.trentesaux@lilo.org> Date: Mon, 19 Feb 2024 16:50:25 +0100 Subject: [PATCH] fix change owner key previous account (nodes/duniter-squid!15) * bump v0.1.2 * fetch account relation of identity --- package-lock.json | 2 ++ package.json | 2 +- src/data_handler.ts | 12 ++++++++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index e20456c..0cb1a90 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,10 +1,12 @@ { "name": "squid", + "version": "0.1.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "squid", + "version": "0.1.2", "dependencies": { "@belopash/typeorm-store": "^1.2.1", "@subsquid/archive-registry": "^3.3.0", diff --git a/package.json b/package.json index ac14c3b..2bc5911 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "squid", - "version": "0.1.1", + "version": "0.1.2", "private": true, "engines": { "node": ">=20" diff --git a/src/data_handler.ts b/src/data_handler.ts index ecd173e..fefb663 100644 --- a/src/data_handler.ts +++ b/src/data_handler.ts @@ -130,8 +130,7 @@ export class DataHandler { // Process identity owner key changes for (const idtyChange of newData.idtyChangedOwnerKey) { - const idty = await this.getIdtyByIndexOrFail(ctx, idtyChange.index); - + const idty = await this.getIdtyWithAccountByIndexOrFail(ctx, idtyChange.index); const new_account = await this.getOrCreateAccount(ctx, idtyChange.accountId); // add change owner key event this.data.changeOwnerKey.push( @@ -532,4 +531,13 @@ export class DataHandler { ctx.store.findOneByOrFail(Identity, { index }) ); } + + async getIdtyWithAccountByIndexOrFail(ctx: Ctx, index: IdtyIndex): Promise<Identity> { + return ( + this.data.identities.get(index) ?? + await ctx.store.findOneOrFail(Identity, { + relations: { account: true }, + where: { index: index }, + })) + } } -- GitLab