From b9dd5698574cc4cb648cdc4e0ad993f8ef7af517 Mon Sep 17 00:00:00 2001 From: Pierre Troger Date: Fri, 11 Oct 2024 16:30:41 +0200 Subject: [PATCH] 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) {}