From 008349878bfa16f5ed25c9cbadb93e423abff51d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hector=20G=C3=B3mez=20Varela?= Date: Thu, 7 Mar 2024 10:41:12 +0100 Subject: [PATCH 1/4] Make CreateDelegateDto.safe nullable --- src/datasources/transaction-api/transaction-api.service.ts | 2 +- src/domain/delegate/delegate.repository.interface.ts | 2 +- src/domain/delegate/delegate.repository.ts | 2 +- src/domain/interfaces/transaction-api.interface.ts | 2 +- src/routes/delegates/delegates.controller.spec.ts | 4 ++-- src/routes/delegates/entities/create-delegate.dto.entity.ts | 2 +- .../delegates/entities/schemas/create-delegate.dto.schema.ts | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/datasources/transaction-api/transaction-api.service.ts b/src/datasources/transaction-api/transaction-api.service.ts index bfa375a66a..78d2a2e417 100644 --- a/src/datasources/transaction-api/transaction-api.service.ts +++ b/src/datasources/transaction-api/transaction-api.service.ts @@ -200,7 +200,7 @@ export class TransactionApi implements ITransactionApi { } async postDelegate(args: { - safeAddress?: string; + safeAddress: string | null; delegate?: string; delegator?: string; signature?: string; diff --git a/src/domain/delegate/delegate.repository.interface.ts b/src/domain/delegate/delegate.repository.interface.ts index 8ae47f0061..8b5155b634 100644 --- a/src/domain/delegate/delegate.repository.interface.ts +++ b/src/domain/delegate/delegate.repository.interface.ts @@ -16,7 +16,7 @@ export interface IDelegateRepository { postDelegate(args: { chainId: string; - safeAddress?: string; + safeAddress: string | null; delegate?: string; delegator?: string; signature?: string; diff --git a/src/domain/delegate/delegate.repository.ts b/src/domain/delegate/delegate.repository.ts index ce2cff8cd2..6c8cc5c0bb 100644 --- a/src/domain/delegate/delegate.repository.ts +++ b/src/domain/delegate/delegate.repository.ts @@ -39,7 +39,7 @@ export class DelegateRepository implements IDelegateRepository { async postDelegate(args: { chainId: string; - safeAddress?: string; + safeAddress: string | null; delegate?: string; delegator?: string; signature?: string; diff --git a/src/domain/interfaces/transaction-api.interface.ts b/src/domain/interfaces/transaction-api.interface.ts index 3d8a287979..56d5658944 100644 --- a/src/domain/interfaces/transaction-api.interface.ts +++ b/src/domain/interfaces/transaction-api.interface.ts @@ -42,7 +42,7 @@ export interface ITransactionApi { }): Promise>; postDelegate(args: { - safeAddress?: string; + safeAddress: string | null; delegate?: string; delegator?: string; signature?: string; diff --git a/src/routes/delegates/delegates.controller.spec.ts b/src/routes/delegates/delegates.controller.spec.ts index db24638d4c..c278705204 100644 --- a/src/routes/delegates/delegates.controller.spec.ts +++ b/src/routes/delegates/delegates.controller.spec.ts @@ -190,9 +190,9 @@ describe('Delegates controller', () => { }); }); - it('Success with safe undefined', async () => { + it('Success with null safe', async () => { const createDelegateDto = createDelegateDtoBuilder().build(); - createDelegateDto.safe = undefined; + createDelegateDto.safe = null; const chain = chainBuilder().build(); networkService.get.mockImplementation((url) => url === `${safeConfigUrl}/api/v1/chains/${chain.chainId}` diff --git a/src/routes/delegates/entities/create-delegate.dto.entity.ts b/src/routes/delegates/entities/create-delegate.dto.entity.ts index f806617922..3aafceb8bf 100644 --- a/src/routes/delegates/entities/create-delegate.dto.entity.ts +++ b/src/routes/delegates/entities/create-delegate.dto.entity.ts @@ -6,7 +6,7 @@ export class CreateDelegateDto implements z.infer { @ApiPropertyOptional() - safe?: `0x${string}`; + safe!: `0x${string}` | null; @ApiProperty() delegate!: `0x${string}`; @ApiProperty() diff --git a/src/routes/delegates/entities/schemas/create-delegate.dto.schema.ts b/src/routes/delegates/entities/schemas/create-delegate.dto.schema.ts index e0c6fea202..06a3d05a99 100644 --- a/src/routes/delegates/entities/schemas/create-delegate.dto.schema.ts +++ b/src/routes/delegates/entities/schemas/create-delegate.dto.schema.ts @@ -2,7 +2,7 @@ import { z } from 'zod'; import { AddressSchema } from '@/validation/entities/schemas/address.schema'; export const CreateDelegateDtoSchema = z.object({ - safe: AddressSchema.optional(), + safe: AddressSchema.optional().nullable().default(null), delegate: AddressSchema, delegator: AddressSchema, signature: z.string(), From e5e9131407538ab01cf832984b5a613cc306a814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hector=20G=C3=B3mez=20Varela?= Date: Thu, 7 Mar 2024 10:51:04 +0100 Subject: [PATCH 2/4] Adjust POST /delegate required fields --- .../transaction-api/transaction-api.service.ts | 8 ++++---- src/domain/delegate/delegate.repository.interface.ts | 8 ++++---- src/domain/delegate/delegate.repository.ts | 8 ++++---- src/domain/interfaces/transaction-api.interface.ts | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/datasources/transaction-api/transaction-api.service.ts b/src/datasources/transaction-api/transaction-api.service.ts index 78d2a2e417..cf2864e3ff 100644 --- a/src/datasources/transaction-api/transaction-api.service.ts +++ b/src/datasources/transaction-api/transaction-api.service.ts @@ -201,10 +201,10 @@ export class TransactionApi implements ITransactionApi { async postDelegate(args: { safeAddress: string | null; - delegate?: string; - delegator?: string; - signature?: string; - label?: string; + delegate: string; + delegator: string; + signature: string; + label: string; }): Promise { try { const url = `${this.baseUrl}/api/v1/delegates/`; diff --git a/src/domain/delegate/delegate.repository.interface.ts b/src/domain/delegate/delegate.repository.interface.ts index 8b5155b634..31c19ea85e 100644 --- a/src/domain/delegate/delegate.repository.interface.ts +++ b/src/domain/delegate/delegate.repository.interface.ts @@ -17,10 +17,10 @@ export interface IDelegateRepository { postDelegate(args: { chainId: string; safeAddress: string | null; - delegate?: string; - delegator?: string; - signature?: string; - label?: string; + delegate: string; + delegator: string; + signature: string; + label: string; }): Promise; deleteDelegate(args: { diff --git a/src/domain/delegate/delegate.repository.ts b/src/domain/delegate/delegate.repository.ts index 6c8cc5c0bb..e730f8024b 100644 --- a/src/domain/delegate/delegate.repository.ts +++ b/src/domain/delegate/delegate.repository.ts @@ -40,10 +40,10 @@ export class DelegateRepository implements IDelegateRepository { async postDelegate(args: { chainId: string; safeAddress: string | null; - delegate?: string; - delegator?: string; - signature?: string; - label?: string; + delegate: string; + delegator: string; + signature: string; + label: string; }): Promise { const transactionService = await this.transactionApiManager.getTransactionApi(args.chainId); diff --git a/src/domain/interfaces/transaction-api.interface.ts b/src/domain/interfaces/transaction-api.interface.ts index 56d5658944..2b319cbe4e 100644 --- a/src/domain/interfaces/transaction-api.interface.ts +++ b/src/domain/interfaces/transaction-api.interface.ts @@ -43,10 +43,10 @@ export interface ITransactionApi { postDelegate(args: { safeAddress: string | null; - delegate?: string; - delegator?: string; - signature?: string; - label?: string; + delegate: string; + delegator: string; + signature: string; + label: string; }): Promise; deleteDelegate(args: { From e324e4841868485cb0737cd888022863a55df515 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hector=20G=C3=B3mez=20Varela?= Date: Mon, 11 Mar 2024 12:51:20 +0100 Subject: [PATCH 3/4] Narrow POST /delegates types --- .../transaction-api.service.spec.ts | 13 ++- .../transaction-api.service.ts | 6 +- src/domain.module.ts | 2 - .../delegate/delegate.repository.interface.ts | 6 +- src/domain/delegate/delegate.repository.ts | 11 ++- src/domain/delegate/delegate.validator.ts | 34 -------- .../entities/__tests__/delegate.builder.ts | 7 +- .../delegate/entities/delegate.entity.ts | 10 +-- .../schemas/__tests__/delegate.schema.spec.ts | 80 +++++++++++++++++++ .../entities/schemas/delegate.schema.ts | 27 ++----- .../interfaces/transaction-api.interface.ts | 6 +- .../delegates/delegates.controller.spec.ts | 16 ++-- .../schemas/create-delegate.dto.schema.ts | 2 +- 13 files changed, 130 insertions(+), 90 deletions(-) delete mode 100644 src/domain/delegate/delegate.validator.ts create mode 100644 src/domain/delegate/entities/schemas/__tests__/delegate.schema.spec.ts diff --git a/src/datasources/transaction-api/transaction-api.service.spec.ts b/src/datasources/transaction-api/transaction-api.service.spec.ts index bd23b0f248..b76a831b1d 100644 --- a/src/datasources/transaction-api/transaction-api.service.spec.ts +++ b/src/datasources/transaction-api/transaction-api.service.spec.ts @@ -23,6 +23,7 @@ import { messageBuilder } from '@/domain/messages/entities/__tests__/message.bui import { proposeTransactionDtoBuilder } from '@/routes/transactions/entities/__tests__/propose-transaction.dto.builder'; import { erc20TransferBuilder } from '@/domain/safe/entities/__tests__/erc20-transfer.builder'; import { DeviceType } from '@/domain/notifications/entities/device.entity'; +import { getAddress } from 'viem'; const dataSource = { get: jest.fn(), @@ -473,9 +474,11 @@ describe('TransactionApi', () => { }); await service.postDelegate({ - ...delegate, - safeAddress: delegate.safe!, + safeAddress: getAddress(delegate.safe!), + delegate: getAddress(delegate.delegate), + delegator: getAddress(delegate.delegator), signature, + label: delegate.label, }); expect(networkService.post).toHaveBeenCalledTimes(1); @@ -509,9 +512,11 @@ describe('TransactionApi', () => { await expect( service.postDelegate({ - ...delegate, - safeAddress: delegate.safe!, + safeAddress: getAddress(delegate.safe!), + delegate: getAddress(delegate.delegate), + delegator: getAddress(delegate.delegator), signature, + label: delegate.label, }), ).rejects.toThrow(expected); diff --git a/src/datasources/transaction-api/transaction-api.service.ts b/src/datasources/transaction-api/transaction-api.service.ts index cf2864e3ff..15107af948 100644 --- a/src/datasources/transaction-api/transaction-api.service.ts +++ b/src/datasources/transaction-api/transaction-api.service.ts @@ -200,9 +200,9 @@ export class TransactionApi implements ITransactionApi { } async postDelegate(args: { - safeAddress: string | null; - delegate: string; - delegator: string; + safeAddress: `0x${string}` | null; + delegate: `0x${string}`; + delegator: `0x${string}`; signature: string; label: string; }): Promise { diff --git a/src/domain.module.ts b/src/domain.module.ts index 6271bd7176..4c8593b99d 100644 --- a/src/domain.module.ts +++ b/src/domain.module.ts @@ -18,7 +18,6 @@ import { SafeValidator } from '@/domain/safe/safe.validator'; import { IContractsRepository } from '@/domain/contracts/contracts.repository.interface'; import { ContractsRepository } from '@/domain/contracts/contracts.repository'; import { ContractsValidator } from '@/domain/contracts/contracts.validator'; -import { DelegateValidator } from '@/domain/delegate/delegate.validator'; import { IDelegateRepository } from '@/domain/delegate/delegate.repository.interface'; import { DelegateRepository } from '@/domain/delegate/delegate.repository'; import { IDataDecodedRepository } from '@/domain/data-decoder/data-decoded.repository.interface'; @@ -82,7 +81,6 @@ import { BalancesApiModule } from '@/datasources/balances-api/balances-api.modul ContractsValidator, CreationTransactionValidator, DataDecodedValidator, - DelegateValidator, EstimationsValidator, SingletonValidator, MessageValidator, diff --git a/src/domain/delegate/delegate.repository.interface.ts b/src/domain/delegate/delegate.repository.interface.ts index 31c19ea85e..b4f2e09dc1 100644 --- a/src/domain/delegate/delegate.repository.interface.ts +++ b/src/domain/delegate/delegate.repository.interface.ts @@ -16,9 +16,9 @@ export interface IDelegateRepository { postDelegate(args: { chainId: string; - safeAddress: string | null; - delegate: string; - delegator: string; + safeAddress: `0x${string}` | null; + delegate: `0x${string}`; + delegator: `0x${string}`; signature: string; label: string; }): Promise; diff --git a/src/domain/delegate/delegate.repository.ts b/src/domain/delegate/delegate.repository.ts index e730f8024b..d0bb88593c 100644 --- a/src/domain/delegate/delegate.repository.ts +++ b/src/domain/delegate/delegate.repository.ts @@ -1,16 +1,15 @@ import { Inject, Injectable } from '@nestjs/common'; import { IDelegateRepository } from '@/domain/delegate/delegate.repository.interface'; -import { DelegateValidator } from '@/domain/delegate/delegate.validator'; import { Delegate } from '@/domain/delegate/entities/delegate.entity'; import { Page } from '@/domain/entities/page.entity'; import { ITransactionApiManager } from '@/domain/interfaces/transaction-api.manager.interface'; +import { DelegateSchema } from '@/domain/delegate/entities/schemas/delegate.schema'; @Injectable() export class DelegateRepository implements IDelegateRepository { constructor( @Inject(ITransactionApiManager) private readonly transactionApiManager: ITransactionApiManager, - private readonly delegateValidator: DelegateValidator, ) {} async getDelegates(args: { @@ -33,15 +32,15 @@ export class DelegateRepository implements IDelegateRepository { offset: args.offset, }); - page?.results.map((result) => this.delegateValidator.validate(result)); + page?.results.map((result) => DelegateSchema.parse(result)); return page; } async postDelegate(args: { chainId: string; - safeAddress: string | null; - delegate: string; - delegator: string; + safeAddress: `0x${string}` | null; + delegate: `0x${string}`; + delegator: `0x${string}`; signature: string; label: string; }): Promise { diff --git a/src/domain/delegate/delegate.validator.ts b/src/domain/delegate/delegate.validator.ts deleted file mode 100644 index f245c29ce7..0000000000 --- a/src/domain/delegate/delegate.validator.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { Injectable } from '@nestjs/common'; -import { DefinedError, ValidateFunction } from 'ajv'; -import { Delegate } from '@/domain/delegate/entities/delegate.entity'; -import { - DELEGATE_SCHEMA_ID, - delegateSchema, -} from '@/domain/delegate/entities/schemas/delegate.schema'; -import { IValidator } from '@/domain/interfaces/validator.interface'; -import { JsonSchemaService } from '@/validation/providers/json-schema.service'; -import { ValidationErrorFactory } from '@/validation/providers/validation-error-factory'; - -@Injectable() -export class DelegateValidator implements IValidator { - private readonly isValidDelegate: ValidateFunction; - - constructor( - private readonly validationErrorFactory: ValidationErrorFactory, - private readonly jsonSchemaService: JsonSchemaService, - ) { - this.isValidDelegate = this.jsonSchemaService.getSchema( - DELEGATE_SCHEMA_ID, - delegateSchema, - ); - } - - validate(data: unknown): Delegate { - if (!this.isValidDelegate(data)) { - const errors = this.isValidDelegate.errors as DefinedError[]; - throw this.validationErrorFactory.from(errors); - } - - return data as Delegate; - } -} diff --git a/src/domain/delegate/entities/__tests__/delegate.builder.ts b/src/domain/delegate/entities/__tests__/delegate.builder.ts index b8bcc3c174..bffb5fd931 100644 --- a/src/domain/delegate/entities/__tests__/delegate.builder.ts +++ b/src/domain/delegate/entities/__tests__/delegate.builder.ts @@ -1,11 +1,12 @@ import { faker } from '@faker-js/faker'; import { Builder, IBuilder } from '@/__tests__/builder'; import { Delegate } from '@/domain/delegate/entities/delegate.entity'; +import { getAddress } from 'viem'; export function delegateBuilder(): IBuilder { return new Builder() - .with('safe', faker.finance.ethereumAddress()) - .with('delegate', faker.finance.ethereumAddress()) - .with('delegator', faker.finance.ethereumAddress()) + .with('safe', getAddress(faker.finance.ethereumAddress())) + .with('delegate', getAddress(faker.finance.ethereumAddress())) + .with('delegator', getAddress(faker.finance.ethereumAddress())) .with('label', faker.word.sample()); } diff --git a/src/domain/delegate/entities/delegate.entity.ts b/src/domain/delegate/entities/delegate.entity.ts index 4327db8503..02bc721e34 100644 --- a/src/domain/delegate/entities/delegate.entity.ts +++ b/src/domain/delegate/entities/delegate.entity.ts @@ -1,6 +1,4 @@ -export interface Delegate { - safe: string | null; - delegate: string; - delegator: string; - label: string; -} +import { DelegateSchema } from '@/domain/delegate/entities/schemas/delegate.schema'; +import { z } from 'zod'; + +export type Delegate = z.infer; diff --git a/src/domain/delegate/entities/schemas/__tests__/delegate.schema.spec.ts b/src/domain/delegate/entities/schemas/__tests__/delegate.schema.spec.ts new file mode 100644 index 0000000000..8e7058c267 --- /dev/null +++ b/src/domain/delegate/entities/schemas/__tests__/delegate.schema.spec.ts @@ -0,0 +1,80 @@ +import { delegateBuilder } from '@/domain/delegate/entities/__tests__/delegate.builder'; +import { DelegateSchema } from '@/domain/delegate/entities/schemas/delegate.schema'; +import { faker } from '@faker-js/faker'; +import { getAddress } from 'viem'; +import { ZodError } from 'zod'; + +describe('DelegateSchema', () => { + it('should validate a valid delegate', () => { + const delegate = delegateBuilder().build(); + + const result = DelegateSchema.safeParse(delegate); + + expect(result.success).toBe(true); + }); + + it('should allow optional safe, defaulting to null', () => { + const delegate = delegateBuilder().build(); + // @ts-expect-error - inferred type doesn't allow optional properties + delete delegate.safe; + + const result = DelegateSchema.safeParse(delegate); + + expect(result.success && result.data.safe).toBe(null); + }); + + it('should checksum safe, delegate and delegator', () => { + const nonChecksummedAddress = faker.finance + .ethereumAddress() + .toLowerCase() as `0x${string}`; + const delegate = delegateBuilder() + .with('safe', nonChecksummedAddress) + .with('delegate', nonChecksummedAddress) + .with('delegator', nonChecksummedAddress) + .build(); + + const result = DelegateSchema.safeParse(delegate); + + expect(result.success && result.data.safe).toBe( + getAddress(nonChecksummedAddress), + ); + expect(result.success && result.data.delegate).toBe( + getAddress(nonChecksummedAddress), + ); + expect(result.success && result.data.delegator).toBe( + getAddress(nonChecksummedAddress), + ); + }); + + it('should not allow invalid delegates', () => { + const delegate = { invalid: 'delegate' }; + + const result = DelegateSchema.safeParse(delegate); + + expect(!result.success && result.error).toStrictEqual( + new ZodError([ + { + code: 'invalid_type', + expected: 'string', + received: 'undefined', + path: ['delegate'], + message: 'Required', + }, + { + code: 'invalid_type', + expected: 'string', + received: 'undefined', + path: ['delegator'], + message: 'Required', + }, + { + code: 'invalid_type', + expected: 'string', + received: 'undefined', + path: ['label'], + message: 'Required', + }, + ]), + ); + }); +}); diff --git a/src/domain/delegate/entities/schemas/delegate.schema.ts b/src/domain/delegate/entities/schemas/delegate.schema.ts index 85a35677d3..7b7b146cd3 100644 --- a/src/domain/delegate/entities/schemas/delegate.schema.ts +++ b/src/domain/delegate/entities/schemas/delegate.schema.ts @@ -1,20 +1,9 @@ -import { JSONSchemaType } from 'ajv'; -import { Delegate } from '@/domain/delegate/entities/delegate.entity'; +import { z } from 'zod'; +import { AddressSchema } from '@/validation/entities/schemas/address.schema'; -export const DELEGATE_SCHEMA_ID = - 'https://safe-client.safe.global/schemas/delegates/delegate.json'; - -export const delegateSchema: JSONSchemaType = { - $id: DELEGATE_SCHEMA_ID, - type: 'object', - properties: { - safe: { - oneOf: [{ type: 'string' }, { type: 'null', nullable: true }], - default: null, - }, - delegate: { type: 'string' }, - delegator: { type: 'string' }, - label: { type: 'string' }, - }, - required: ['delegate', 'delegator', 'label'], -}; +export const DelegateSchema = z.object({ + safe: AddressSchema.nullish().default(null), + delegate: AddressSchema, + delegator: AddressSchema, + label: z.string(), +}); diff --git a/src/domain/interfaces/transaction-api.interface.ts b/src/domain/interfaces/transaction-api.interface.ts index 2b319cbe4e..e3a1bb38b3 100644 --- a/src/domain/interfaces/transaction-api.interface.ts +++ b/src/domain/interfaces/transaction-api.interface.ts @@ -42,9 +42,9 @@ export interface ITransactionApi { }): Promise>; postDelegate(args: { - safeAddress: string | null; - delegate: string; - delegator: string; + safeAddress: `0x${string}` | null; + delegate: `0x${string}`; + delegator: `0x${string}`; signature: string; label: string; }): Promise; diff --git a/src/routes/delegates/delegates.controller.spec.ts b/src/routes/delegates/delegates.controller.spec.ts index 47bfb6f9a0..d95265b45f 100644 --- a/src/routes/delegates/delegates.controller.spec.ts +++ b/src/routes/delegates/delegates.controller.spec.ts @@ -26,6 +26,7 @@ import { deleteSafeDelegateDtoBuilder } from '@/routes/delegates/entities/__test import { NetworkResponseError } from '@/datasources/network/entities/network.error.entity'; import { AccountDataSourceModule } from '@/datasources/account/account.datasource.module'; import { TestAccountDataSourceModule } from '@/datasources/account/__tests__/test.account.datasource.module'; +import { getAddress } from 'viem'; describe('Delegates controller', () => { let app: INestApplication; @@ -58,7 +59,7 @@ describe('Delegates controller', () => { describe('GET delegates for a Safe', () => { it('Success', async () => { - const safe = faker.finance.ethereumAddress(); + const safe = getAddress(faker.finance.ethereumAddress()); const chain = chainBuilder().build(); const delegatesPage = pageBuilder() .with('count', 2) @@ -86,7 +87,7 @@ describe('Delegates controller', () => { }); it('Should return a validation error', async () => { - const safe = faker.finance.ethereumAddress(); + const safe = getAddress(faker.finance.ethereumAddress()); const chain = chainBuilder().build(); const delegatesPage = pageBuilder() .with('count', 2) @@ -109,11 +110,14 @@ describe('Delegates controller', () => { await request(app.getHttpServer()) .get(`/v1/chains/${chain.chainId}/delegates?safe=${safe}`) - .expect(500) + .expect(422) .expect({ - message: 'Validation failed', - code: 42, - arguments: [], + statusCode: 422, + code: 'invalid_type', + expected: 'string', + received: 'boolean', + path: ['label'], + message: 'Expected string, received boolean', }); }); diff --git a/src/routes/delegates/entities/schemas/create-delegate.dto.schema.ts b/src/routes/delegates/entities/schemas/create-delegate.dto.schema.ts index 06a3d05a99..c7e77c12b2 100644 --- a/src/routes/delegates/entities/schemas/create-delegate.dto.schema.ts +++ b/src/routes/delegates/entities/schemas/create-delegate.dto.schema.ts @@ -2,7 +2,7 @@ import { z } from 'zod'; import { AddressSchema } from '@/validation/entities/schemas/address.schema'; export const CreateDelegateDtoSchema = z.object({ - safe: AddressSchema.optional().nullable().default(null), + safe: AddressSchema.nullish().default(null), delegate: AddressSchema, delegator: AddressSchema, signature: z.string(), From a1c3ac9c6de239112bf787a7403c33efb4732144 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hector=20G=C3=B3mez=20Varela?= Date: Mon, 11 Mar 2024 17:22:09 +0100 Subject: [PATCH 4/4] Remove redundant address checksum --- .../transaction-api/transaction-api.service.spec.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/datasources/transaction-api/transaction-api.service.spec.ts b/src/datasources/transaction-api/transaction-api.service.spec.ts index b76a831b1d..bd23b0f248 100644 --- a/src/datasources/transaction-api/transaction-api.service.spec.ts +++ b/src/datasources/transaction-api/transaction-api.service.spec.ts @@ -23,7 +23,6 @@ import { messageBuilder } from '@/domain/messages/entities/__tests__/message.bui import { proposeTransactionDtoBuilder } from '@/routes/transactions/entities/__tests__/propose-transaction.dto.builder'; import { erc20TransferBuilder } from '@/domain/safe/entities/__tests__/erc20-transfer.builder'; import { DeviceType } from '@/domain/notifications/entities/device.entity'; -import { getAddress } from 'viem'; const dataSource = { get: jest.fn(), @@ -474,11 +473,9 @@ describe('TransactionApi', () => { }); await service.postDelegate({ - safeAddress: getAddress(delegate.safe!), - delegate: getAddress(delegate.delegate), - delegator: getAddress(delegate.delegator), + ...delegate, + safeAddress: delegate.safe!, signature, - label: delegate.label, }); expect(networkService.post).toHaveBeenCalledTimes(1); @@ -512,11 +509,9 @@ describe('TransactionApi', () => { await expect( service.postDelegate({ - safeAddress: getAddress(delegate.safe!), - delegate: getAddress(delegate.delegate), - delegator: getAddress(delegate.delegator), + ...delegate, + safeAddress: delegate.safe!, signature, - label: delegate.label, }), ).rejects.toThrow(expected);