From 9f333686d0be7836957c0b89e02580dc8d0ae078 Mon Sep 17 00:00:00 2001 From: Pierre Troger Date: Fri, 11 Oct 2024 15:57:27 +0200 Subject: [PATCH 1/3] add origin to publicaccount schema --- apps/vault/src/shared/type/domain.type.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/apps/vault/src/shared/type/domain.type.ts b/apps/vault/src/shared/type/domain.type.ts index f31d1fcae..ee438f024 100644 --- a/apps/vault/src/shared/type/domain.type.ts +++ b/apps/vault/src/shared/type/domain.type.ts @@ -63,13 +63,7 @@ export const PrivateAccount = z.object({ }) export type PrivateAccount = z.infer -export const PublicAccount = z.object({ - id: z.string().min(1), - address: z.string().min(1), - publicKey: hexSchema.refine((val) => val.length === 132, 'Invalid hex publicKey'), - keyId: z.string().min(1).optional(), - derivationPath: z.string().min(1).optional() -}) +export const PublicAccount = PrivateAccount.omit({ privateKey: true }) export type PublicAccount = z.infer export const LocalRootKey = z.object({ From b9dd5698574cc4cb648cdc4e0ad993f8ef7af517 Mon Sep 17 00:00:00 2001 From: Pierre Troger Date: Fri, 11 Oct 2024 16:30:41 +0200 Subject: [PATCH 2/3] switch import in account dto --- .../src/vault/__test__/e2e/account.spec.ts | 32 ++++++++++++------- .../src/vault/__test__/e2e/wallet.spec.ts | 6 ++-- .../src/vault/http/rest/dto/account.dto.ts | 2 +- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/apps/vault/src/vault/__test__/e2e/account.spec.ts b/apps/vault/src/vault/__test__/e2e/account.spec.ts index 43d75b962..eccfecbb5 100644 --- a/apps/vault/src/vault/__test__/e2e/account.spec.ts +++ b/apps/vault/src/vault/__test__/e2e/account.spec.ts @@ -23,7 +23,7 @@ import { Config, load } from '../../../main.config' import { REQUEST_HEADER_CLIENT_ID } from '../../../main.constant' import { TestPrismaService } from '../../../shared/module/persistence/service/test-prisma.service' import { getTestRawAesKeyring } from '../../../shared/testing/encryption.testing' -import { Client } from '../../../shared/type/domain.type' +import { Client, Origin } from '../../../shared/type/domain.type' import { AppService } from '../../core/service/app.service' const PRIVATE_KEY = '0x7cfef3303797cbc7515d9ce22ffe849c701b0f2812f999b0847229c47951fca5' @@ -210,7 +210,8 @@ describe('Accounts', () => { keyId, derivationPath: "m/44'/60'/0'/0/1", address: expect.any(String), - publicKey: expect.any(String) + publicKey: expect.any(String), + origin: Origin.GENERATED } ] }) @@ -258,21 +259,24 @@ describe('Accounts', () => { keyId, derivationPath: "m/44'/60'/0'/0/1", address: expect.any(String), - publicKey: expect.any(String) + publicKey: expect.any(String), + origin: Origin.GENERATED }, { id: expect.any(String), keyId, derivationPath: "m/44'/60'/0'/0/2", address: expect.any(String), - publicKey: expect.any(String) + publicKey: expect.any(String), + origin: Origin.GENERATED }, { id: expect.any(String), keyId, derivationPath: "m/44'/60'/0'/0/3", address: expect.any(String), - publicKey: expect.any(String) + publicKey: expect.any(String), + origin: Origin.GENERATED } ]) }) @@ -305,14 +309,16 @@ describe('Accounts', () => { keyId, derivationPath: "m/44'/60'/0'/0/4", address: expect.any(String), - publicKey: expect.any(String) + publicKey: expect.any(String), + origin: Origin.GENERATED }, { id: expect.any(String), keyId, derivationPath: "m/44'/60'/0'/0/5", address: expect.any(String), - publicKey: expect.any(String) + publicKey: expect.any(String), + origin: Origin.GENERATED } ]) }) @@ -346,14 +352,16 @@ describe('Accounts', () => { keyId, derivationPath: "m/44'/60'/0'/0/4", address: expect.any(String), - publicKey: expect.any(String) + publicKey: expect.any(String), + origin: Origin.GENERATED }, { id: expect.any(String), keyId, derivationPath: "m/44'/60'/0'/0/5", address: expect.any(String), - publicKey: expect.any(String) + publicKey: expect.any(String), + origin: Origin.GENERATED } ]) }) @@ -374,7 +382,8 @@ describe('Accounts', () => { expect(body).toEqual({ id: 'eip155:eoa:0x2c4895215973cbbd778c32c456c074b99daf8bf1', address: '0x2c4895215973CbBd778C32c456C074b99daF8Bf1', - publicKey: expect.any(String) + publicKey: expect.any(String), + origin: Origin.IMPORTED }) expect(status).toEqual(HttpStatus.CREATED) }) @@ -402,7 +411,8 @@ describe('Accounts', () => { expect(body).toEqual({ id: 'eip155:eoa:0x2c4895215973cbbd778c32c456c074b99daf8bf1', address: '0x2c4895215973CbBd778C32c456C074b99daF8Bf1', - publicKey: expect.any(String) + publicKey: expect.any(String), + origin: Origin.IMPORTED }) expect(status).toEqual(HttpStatus.CREATED) }) diff --git a/apps/vault/src/vault/__test__/e2e/wallet.spec.ts b/apps/vault/src/vault/__test__/e2e/wallet.spec.ts index 8feba69e6..f0b8f24dd 100644 --- a/apps/vault/src/vault/__test__/e2e/wallet.spec.ts +++ b/apps/vault/src/vault/__test__/e2e/wallet.spec.ts @@ -196,7 +196,8 @@ describe('Generate', () => { derivationPath: "m/44'/60'/0'/0/0", address: expect.any(String), publicKey: expect.any(String), - id: expect.any(String) + id: expect.any(String), + origin: Origin.GENERATED }) }) @@ -277,7 +278,8 @@ describe('Generate', () => { publicKey: expect.any(String), keyId: 'my-imported-rootKey', derivationPath: `m/44'/60'/0'/0/0`, - id: resourceId(body.account.address) + id: resourceId(body.account.address), + origin: Origin.GENERATED }, keyId: 'my-imported-rootKey' }) diff --git a/apps/vault/src/vault/http/rest/dto/account.dto.ts b/apps/vault/src/vault/http/rest/dto/account.dto.ts index 24711a46d..31e27f257 100644 --- a/apps/vault/src/vault/http/rest/dto/account.dto.ts +++ b/apps/vault/src/vault/http/rest/dto/account.dto.ts @@ -1,4 +1,4 @@ -import { PublicAccount } from '@narval/armory-sdk' +import { PublicAccount } from 'apps/vault/src/shared/type/domain.type' import { createZodDto } from 'nestjs-zod' export class AccountDto extends createZodDto(PublicAccount) {} From 36dce85fe2442f133924b601232e1755c9256a17 Mon Sep 17 00:00:00 2001 From: Pierre Troger Date: Fri, 11 Oct 2024 16:39:34 +0200 Subject: [PATCH 3/3] updated vault client in sdk --- .../src/vault/http/rest/dto/account.dto.ts | 2 +- .../src/lib/http/client/vault/api.ts | 24 ++++++++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/apps/vault/src/vault/http/rest/dto/account.dto.ts b/apps/vault/src/vault/http/rest/dto/account.dto.ts index 31e27f257..ba8d2aef0 100644 --- a/apps/vault/src/vault/http/rest/dto/account.dto.ts +++ b/apps/vault/src/vault/http/rest/dto/account.dto.ts @@ -1,4 +1,4 @@ -import { PublicAccount } from 'apps/vault/src/shared/type/domain.type' import { createZodDto } from 'nestjs-zod' +import { PublicAccount } from '../../../../shared/type/domain.type' export class AccountDto extends createZodDto(PublicAccount) {} diff --git a/packages/armory-sdk/src/lib/http/client/vault/api.ts b/packages/armory-sdk/src/lib/http/client/vault/api.ts index b9eedd163..a6893580c 100644 --- a/packages/armory-sdk/src/lib/http/client/vault/api.ts +++ b/packages/armory-sdk/src/lib/http/client/vault/api.ts @@ -37,16 +37,22 @@ export interface AccountDto { 'id': string; /** * - * @type {string} + * @type {any} * @memberof AccountDto */ - 'address': string; + 'publicKey': any; /** * * @type {any} * @memberof AccountDto */ - 'publicKey': any; + 'address': any; + /** + * + * @type {WalletsDtoWalletsInnerOrigin} + * @memberof AccountDto + */ + 'origin': WalletsDtoWalletsInnerOrigin; /** * * @type {string} @@ -1272,16 +1278,22 @@ export interface WalletDtoAccount { 'id': string; /** * - * @type {string} + * @type {any} * @memberof WalletDtoAccount */ - 'address': string; + 'publicKey': any; /** * * @type {any} * @memberof WalletDtoAccount */ - 'publicKey': any; + 'address': any; + /** + * + * @type {WalletsDtoWalletsInnerOrigin} + * @memberof WalletDtoAccount + */ + 'origin': WalletsDtoWalletsInnerOrigin; /** * * @type {string}