From 621c7e462aca72ae1355ab7661a5039ebd32d742 Mon Sep 17 00:00:00 2001 From: Andy <67167307+aguzmant103@users.noreply.github.com> Date: Mon, 16 Oct 2023 14:40:29 -0600 Subject: [PATCH 1/7] feat: returning empty treeRoot --- apps/api/src/app/groups/entities/group.entity.ts | 6 ++++++ apps/api/src/app/groups/groups.utils.ts | 1 + database/seed.sql | 1 + 3 files changed, 8 insertions(+) diff --git a/apps/api/src/app/groups/entities/group.entity.ts b/apps/api/src/app/groups/entities/group.entity.ts index fc050bc4..e8de7a9d 100644 --- a/apps/api/src/app/groups/entities/group.entity.ts +++ b/apps/api/src/app/groups/entities/group.entity.ts @@ -28,6 +28,12 @@ export class Group { @Column({ name: "tree_depth" }) treeDepth: number + @Column({ + name: "tree_root", + nullable: true + }) + treeRoot: number + @Column({ name: "fingerprint_duration" }) fingerprintDuration: number diff --git a/apps/api/src/app/groups/groups.utils.ts b/apps/api/src/app/groups/groups.utils.ts index b9eb38b9..228229a9 100644 --- a/apps/api/src/app/groups/groups.utils.ts +++ b/apps/api/src/app/groups/groups.utils.ts @@ -10,6 +10,7 @@ export function mapGroupToResponseDTO( description: group.description, admin: group.adminId, treeDepth: group.treeDepth, + treeRoot: group.treeRoot, fingerprintDuration: group.fingerprintDuration, createdAt: group.createdAt, members: (group.members || []).map((m) => m.id), diff --git a/database/seed.sql b/database/seed.sql index c4326d27..c35e98ad 100644 --- a/database/seed.sql +++ b/database/seed.sql @@ -15,6 +15,7 @@ CREATE TABLE groups ( description character varying NOT NULL, admin_id character varying NOT NULL, tree_depth integer NOT NULL, + tree_root integer, /* TODO: make it NOT NULL */ fingerprint_duration integer NOT NULL, credentials text, api_enabled boolean NOT NULL DEFAULT false, From 309838dd1db61730379f571ac3ed46f3c2218b94 Mon Sep 17 00:00:00 2001 From: Andy <67167307+aguzmant103@users.noreply.github.com> Date: Fri, 20 Oct 2023 17:00:51 -0600 Subject: [PATCH 2/7] Revert "feat: returning empty treeRoot" This reverts commit 621c7e462aca72ae1355ab7661a5039ebd32d742. --- apps/api/src/app/groups/entities/group.entity.ts | 6 ------ apps/api/src/app/groups/groups.utils.ts | 1 - database/seed.sql | 1 - 3 files changed, 8 deletions(-) diff --git a/apps/api/src/app/groups/entities/group.entity.ts b/apps/api/src/app/groups/entities/group.entity.ts index e8de7a9d..fc050bc4 100644 --- a/apps/api/src/app/groups/entities/group.entity.ts +++ b/apps/api/src/app/groups/entities/group.entity.ts @@ -28,12 +28,6 @@ export class Group { @Column({ name: "tree_depth" }) treeDepth: number - @Column({ - name: "tree_root", - nullable: true - }) - treeRoot: number - @Column({ name: "fingerprint_duration" }) fingerprintDuration: number diff --git a/apps/api/src/app/groups/groups.utils.ts b/apps/api/src/app/groups/groups.utils.ts index 228229a9..b9eb38b9 100644 --- a/apps/api/src/app/groups/groups.utils.ts +++ b/apps/api/src/app/groups/groups.utils.ts @@ -10,7 +10,6 @@ export function mapGroupToResponseDTO( description: group.description, admin: group.adminId, treeDepth: group.treeDepth, - treeRoot: group.treeRoot, fingerprintDuration: group.fingerprintDuration, createdAt: group.createdAt, members: (group.members || []).map((m) => m.id), diff --git a/database/seed.sql b/database/seed.sql index c35e98ad..c4326d27 100644 --- a/database/seed.sql +++ b/database/seed.sql @@ -15,7 +15,6 @@ CREATE TABLE groups ( description character varying NOT NULL, admin_id character varying NOT NULL, tree_depth integer NOT NULL, - tree_root integer, /* TODO: make it NOT NULL */ fingerprint_duration integer NOT NULL, credentials text, api_enabled boolean NOT NULL DEFAULT false, From 18f433515f366953f4cc05bfd80005220644d020 Mon Sep 17 00:00:00 2001 From: Andres Guzman Date: Thu, 26 Oct 2023 09:54:54 -0600 Subject: [PATCH 3/7] feat: return TreeRoot in getGroup --- apps/api/src/app/groups/entities/group.entity.ts | 7 +++++++ apps/api/src/app/groups/groups.service.ts | 2 ++ apps/api/src/app/groups/groups.utils.ts | 2 ++ 3 files changed, 11 insertions(+) diff --git a/apps/api/src/app/groups/entities/group.entity.ts b/apps/api/src/app/groups/entities/group.entity.ts index fc050bc4..943d7c70 100644 --- a/apps/api/src/app/groups/entities/group.entity.ts +++ b/apps/api/src/app/groups/entities/group.entity.ts @@ -9,6 +9,7 @@ import { } from "typeorm" import { OAuthAccount } from "../../credentials/entities/credentials-account.entity" import { Member } from "./member.entity" +import { BigNumberish } from "ethers" @Entity("groups") export class Group { @@ -28,6 +29,12 @@ export class Group { @Column({ name: "tree_depth" }) treeDepth: number + @Column({ + name: "tree_root", + nullable: true /* TODO: remove this */ + }) + treeRoot: string + @Column({ name: "fingerprint_duration" }) fingerprintDuration: number diff --git a/apps/api/src/app/groups/groups.service.ts b/apps/api/src/app/groups/groups.service.ts index 42836a9c..127727e0 100644 --- a/apps/api/src/app/groups/groups.service.ts +++ b/apps/api/src/app/groups/groups.service.ts @@ -555,6 +555,8 @@ export class GroupsService { `Group with id '${groupId}' does not exist` ) } + /* group.treeRoot = BigNumber.from(this.cachedGroups.get(groupId).root).toNumber(); */ + group.treeRoot = this.cachedGroups.get(groupId).root.toString() return group } diff --git a/apps/api/src/app/groups/groups.utils.ts b/apps/api/src/app/groups/groups.utils.ts index b9eb38b9..905628c5 100644 --- a/apps/api/src/app/groups/groups.utils.ts +++ b/apps/api/src/app/groups/groups.utils.ts @@ -1,3 +1,4 @@ +import { Any } from "typeorm" import { Group } from "./entities/group.entity" export function mapGroupToResponseDTO( @@ -10,6 +11,7 @@ export function mapGroupToResponseDTO( description: group.description, admin: group.adminId, treeDepth: group.treeDepth, + treeRoot: group.treeRoot, fingerprintDuration: group.fingerprintDuration, createdAt: group.createdAt, members: (group.members || []).map((m) => m.id), From dc4ff9079ed5da9c261b458deceb48b17af60956 Mon Sep 17 00:00:00 2001 From: Andres Guzman Date: Thu, 26 Oct 2023 10:44:51 -0600 Subject: [PATCH 4/7] refactor: removing unused libs --- apps/api/src/app/groups/entities/group.entity.ts | 2 -- apps/api/src/app/groups/groups.utils.ts | 1 - 2 files changed, 3 deletions(-) diff --git a/apps/api/src/app/groups/entities/group.entity.ts b/apps/api/src/app/groups/entities/group.entity.ts index 943d7c70..4b0bcd34 100644 --- a/apps/api/src/app/groups/entities/group.entity.ts +++ b/apps/api/src/app/groups/entities/group.entity.ts @@ -9,7 +9,6 @@ import { } from "typeorm" import { OAuthAccount } from "../../credentials/entities/credentials-account.entity" import { Member } from "./member.entity" -import { BigNumberish } from "ethers" @Entity("groups") export class Group { @@ -31,7 +30,6 @@ export class Group { @Column({ name: "tree_root", - nullable: true /* TODO: remove this */ }) treeRoot: string diff --git a/apps/api/src/app/groups/groups.utils.ts b/apps/api/src/app/groups/groups.utils.ts index 905628c5..228229a9 100644 --- a/apps/api/src/app/groups/groups.utils.ts +++ b/apps/api/src/app/groups/groups.utils.ts @@ -1,4 +1,3 @@ -import { Any } from "typeorm" import { Group } from "./entities/group.entity" export function mapGroupToResponseDTO( From 3256fba607b8beaedaefd56906b8343052f82862 Mon Sep 17 00:00:00 2001 From: Andres Guzman Date: Thu, 26 Oct 2023 10:58:24 -0600 Subject: [PATCH 5/7] style: prettier --- apps/api/src/app/groups/entities/group.entity.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/api/src/app/groups/entities/group.entity.ts b/apps/api/src/app/groups/entities/group.entity.ts index 4b0bcd34..05d068ee 100644 --- a/apps/api/src/app/groups/entities/group.entity.ts +++ b/apps/api/src/app/groups/entities/group.entity.ts @@ -29,7 +29,7 @@ export class Group { treeDepth: number @Column({ - name: "tree_root", + name: "tree_root" }) treeRoot: string From bc2a3e4b133e810a923910fa3e562fe846a0040e Mon Sep 17 00:00:00 2001 From: Andres Guzman Date: Thu, 26 Oct 2023 11:27:09 -0600 Subject: [PATCH 6/7] style: style formatting --- apps/api/src/app/groups/entities/group.entity.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/api/src/app/groups/entities/group.entity.ts b/apps/api/src/app/groups/entities/group.entity.ts index 05d068ee..ac9223dd 100644 --- a/apps/api/src/app/groups/entities/group.entity.ts +++ b/apps/api/src/app/groups/entities/group.entity.ts @@ -29,7 +29,8 @@ export class Group { treeDepth: number @Column({ - name: "tree_root" + name: "tree_root", + nullable: true }) treeRoot: string From 145bf4aff475116002c7a34110827193d77042e9 Mon Sep 17 00:00:00 2001 From: Andres Guzman Date: Tue, 12 Dec 2023 22:40:34 -0600 Subject: [PATCH 7/7] style: "fingerprint instead of treeRoot" --- apps/api/src/app/groups/docSchemas/group.ts | 2 ++ apps/api/src/app/groups/groups.service.ts | 2 ++ apps/api/src/app/groups/groups.utils.ts | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/api/src/app/groups/docSchemas/group.ts b/apps/api/src/app/groups/docSchemas/group.ts index 36ae0626..494d5928 100644 --- a/apps/api/src/app/groups/docSchemas/group.ts +++ b/apps/api/src/app/groups/docSchemas/group.ts @@ -12,6 +12,8 @@ export class Group { @ApiProperty() treeDepth: number @ApiProperty() + fingerprint: string + @ApiProperty() fingerprintDuration: number @ApiProperty() createdAt: Date diff --git a/apps/api/src/app/groups/groups.service.ts b/apps/api/src/app/groups/groups.service.ts index 127727e0..963f8ce3 100644 --- a/apps/api/src/app/groups/groups.service.ts +++ b/apps/api/src/app/groups/groups.service.ts @@ -558,6 +558,8 @@ export class GroupsService { /* group.treeRoot = BigNumber.from(this.cachedGroups.get(groupId).root).toNumber(); */ group.treeRoot = this.cachedGroups.get(groupId).root.toString() + group.fingerprint = this.cachedGroups.get(groupId).root.toString() + return group } diff --git a/apps/api/src/app/groups/groups.utils.ts b/apps/api/src/app/groups/groups.utils.ts index 228229a9..6b3f15ac 100644 --- a/apps/api/src/app/groups/groups.utils.ts +++ b/apps/api/src/app/groups/groups.utils.ts @@ -10,7 +10,7 @@ export function mapGroupToResponseDTO( description: group.description, admin: group.adminId, treeDepth: group.treeDepth, - treeRoot: group.treeRoot, + fingerprint: group.fingerprint, fingerprintDuration: group.fingerprintDuration, createdAt: group.createdAt, members: (group.members || []).map((m) => m.id),