Skip to content

Commit

Permalink
Don't expose RichDecodedInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
iamacook committed Oct 25, 2024
1 parent 3f344bb commit caa9267
Show file tree
Hide file tree
Showing 31 changed files with 76 additions and 291 deletions.
13 changes: 13 additions & 0 deletions src/domain/common/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,16 @@ export function getNumberString(value: number): string {
useGrouping: false,
});
}

/**
* Truncates an address with a specific lengthed prefix and suffix
* @param {`0x${string}`} address to truncate
* @param {number} [length] of the prefix and suffix, minus hex prefix
* @returns {`0x${string}`} truncated address
*/
export function truncateAddress(
address: `0x${string}`,
length: number = 4,
): `0x${string}` {
return `${address.slice(0, length + 2)}...${address.slice(-length)}` as `0x${string}`;
}
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ describe('Get by id - Transactions Controller (Unit)', () => {
value: moduleTransaction.value,
},
humanDescription: null,
richDecodedInfo: null,
},
txData: {
to: expect.objectContaining({ value: contract.address }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ describe('Preview transaction - CoW Swap - Transactions Controller (Unit)', () =
txInfo: {
type: 'SwapOrder',
humanDescription: null,
richDecodedInfo: null,
uid: order.uid,
status: order.status,
kind: order.kind,
Expand Down Expand Up @@ -300,7 +299,6 @@ describe('Preview transaction - CoW Swap - Transactions Controller (Unit)', () =
txInfo: {
type: 'SwapOrder',
humanDescription: null,
richDecodedInfo: null,
uid: order.uid,
status: order.status,
kind: order.kind,
Expand Down Expand Up @@ -780,7 +778,6 @@ describe('Preview transaction - CoW Swap - Transactions Controller (Unit)', () =
txInfo: {
type: 'TwapOrder',
humanDescription: null,
richDecodedInfo: null,
status: 'presignaturePending',
kind: 'sell',
class: 'limit',
Expand Down Expand Up @@ -917,7 +914,6 @@ describe('Preview transaction - CoW Swap - Transactions Controller (Unit)', () =
txInfo: {
type: 'TwapOrder',
humanDescription: null,
richDecodedInfo: null,
status: 'presignaturePending',
kind: 'sell',
class: 'limit',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ describe('Preview transaction - Kiln - Transactions Controller (Unit)', () => {
txInfo: {
type: 'NativeStakingDeposit',
humanDescription: null,
richDecodedInfo: null,
status: 'NOT_STAKED',
estimatedEntryTime:
networkStats.estimated_entry_time_seconds * 1_000,
Expand Down Expand Up @@ -348,7 +347,6 @@ describe('Preview transaction - Kiln - Transactions Controller (Unit)', () => {
txInfo: {
type: 'NativeStakingDeposit',
humanDescription: null,
richDecodedInfo: null,
status: 'NOT_STAKED',
estimatedEntryTime:
networkStats.estimated_entry_time_seconds * 1_000,
Expand Down Expand Up @@ -960,7 +958,6 @@ describe('Preview transaction - Kiln - Transactions Controller (Unit)', () => {
txInfo: {
type: 'NativeStakingValidatorsExit',
humanDescription: null,
richDecodedInfo: null,
status: 'ACTIVE',
estimatedExitTime:
networkStats.estimated_exit_time_seconds * 1_000,
Expand Down Expand Up @@ -1112,7 +1109,6 @@ describe('Preview transaction - Kiln - Transactions Controller (Unit)', () => {
txInfo: {
type: 'NativeStakingValidatorsExit',
humanDescription: null,
richDecodedInfo: null,
status: 'ACTIVE',
estimatedExitTime:
networkStats.estimated_exit_time_seconds * 1_000,
Expand Down Expand Up @@ -1712,7 +1708,6 @@ describe('Preview transaction - Kiln - Transactions Controller (Unit)', () => {
txInfo: {
type: 'NativeStakingWithdraw',
humanDescription: null,
richDecodedInfo: null,
value: (
+stakes[0].net_claimable_consensus_rewards! +
+stakes[1].net_claimable_consensus_rewards!
Expand Down Expand Up @@ -1863,7 +1858,6 @@ describe('Preview transaction - Kiln - Transactions Controller (Unit)', () => {
txInfo: {
type: 'NativeStakingWithdraw',
humanDescription: null,
richDecodedInfo: null,
value: (
+stakes[0].net_claimable_consensus_rewards! +
+stakes[1].net_claimable_consensus_rewards!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ describe('Preview transaction - Transactions Controller (Unit)', () => {
actionCount: null,
isCancellation: false,
humanDescription: null,
richDecodedInfo: null,
},
txData: {
hexData: previewTransactionDto.data,
Expand Down Expand Up @@ -207,7 +206,6 @@ describe('Preview transaction - Transactions Controller (Unit)', () => {
actionCount: null,
isCancellation: false,
humanDescription: null,
richDecodedInfo: null,
},
txData: {
hexData: previewTransactionDto.data,
Expand Down Expand Up @@ -273,7 +271,6 @@ describe('Preview transaction - Transactions Controller (Unit)', () => {
actionCount: null,
isCancellation: false,
humanDescription: null,
richDecodedInfo: null,
},
txData: {
hexData: previewTransactionDto.data,
Expand Down Expand Up @@ -354,7 +351,6 @@ describe('Preview transaction - Transactions Controller (Unit)', () => {
actionCount: null,
isCancellation: false,
humanDescription: null,
richDecodedInfo: null,
},
txData: {
hexData: previewTransactionDto.data,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class CreationTransactionInfo extends TransactionInfo {
factory: AddressInfo | null,
saltNonce: string | null,
) {
super(TransactionInfoType.Creation, null, null);
super(TransactionInfoType.Creation, null);
this.creator = creator;
this.transactionHash = transactionHash;
this.implementation = implementation;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { AddressInfo } from '@/routes/common/entities/address-info.entity';
import { RichDecodedInfo } from '@/routes/transactions/entities/human-description.entity';
import {
TransactionInfo,
TransactionInfoType,
Expand Down Expand Up @@ -28,9 +27,8 @@ export class CustomTransactionInfo extends TransactionInfo {
actionCount: number | null,
isCancellation: boolean,
humanDescription: string | null,
richDecodedInfo: RichDecodedInfo | null,
) {
super(TransactionInfoType.Custom, humanDescription, richDecodedInfo);
super(TransactionInfoType.Custom, humanDescription);
this.to = to;
this.dataSize = dataSize;
this.value = value;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { DataDecoded } from '@/routes/data-decode/entities/data-decoded.entity';
import { RichDecodedInfo } from '@/routes/transactions/entities/human-description.entity';
import { SettingsChange } from '@/routes/transactions/entities/settings-changes/settings-change.entity';
import {
TransactionInfo,
Expand All @@ -17,13 +16,8 @@ export class SettingsChangeTransaction extends TransactionInfo {
dataDecoded: DataDecoded,
settingsInfo: SettingsChange | null,
humanDescription: string | null,
richDecodedInfo: RichDecodedInfo | null,
) {
super(
TransactionInfoType.SettingsChange,
humanDescription,
richDecodedInfo,
);
super(TransactionInfoType.SettingsChange, humanDescription);
this.dataDecoded = dataDecoded;
this.settingsInfo = settingsInfo;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class NativeStakingDepositTransactionInfo
tokenInfo: TokenInfo;
validators: Array<`0x${string}`> | null;
}) {
super(TransactionInfoType.NativeStakingDeposit, null, null);
super(TransactionInfoType.NativeStakingDeposit, null);
this.status = args.status;
this.estimatedEntryTime = args.estimatedEntryTime;
this.estimatedExitTime = args.estimatedExitTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class NativeStakingValidatorsExitTransactionInfo extends TransactionInfo
tokenInfo: TokenInfo;
validators: Array<`0x${string}`>;
}) {
super(TransactionInfoType.NativeStakingValidatorsExit, null, null);
super(TransactionInfoType.NativeStakingValidatorsExit, null);
this.status = args.status;
this.estimatedExitTime = args.estimatedExitTime;
this.estimatedWithdrawalTime = args.estimatedWithdrawalTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class NativeStakingWithdrawTransactionInfo extends TransactionInfo {
tokenInfo: TokenInfo;
validators: Array<`0x${string}`>;
}) {
super(TransactionInfoType.NativeStakingWithdraw, null, null);
super(TransactionInfoType.NativeStakingWithdraw, null);
this.value = args.value;
this.tokenInfo = args.tokenInfo;
this.validators = args.validators;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export class SwapOrderTransactionInfo
owner: `0x${string}`;
fullAppData: Record<string, unknown> | null;
}) {
super(TransactionInfoType.SwapOrder, null, null);
super(TransactionInfoType.SwapOrder, null);
this.uid = args.uid;
this.status = args.orderStatus;
this.kind = args.kind;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export class TwapOrderTransactionInfo
durationOfPart: DurationOfPart;
startTime: StartTime;
}) {
super(TransactionInfoType.SwapOrder, null, null);
super(TransactionInfoType.SwapOrder, null);
this.status = args.status;
this.kind = args.kind;
this.class = args.class;
Expand Down
5 changes: 0 additions & 5 deletions src/routes/transactions/entities/transaction-info.entity.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { RichDecodedInfo } from '@/routes/transactions/entities/human-description.entity';

export enum TransactionInfoType {
Creation = 'Creation',
Expand All @@ -19,16 +18,12 @@ export class TransactionInfo {
type: TransactionInfoType;
@ApiPropertyOptional({ type: String, nullable: true })
humanDescription: string | null;
@ApiPropertyOptional({ type: RichDecodedInfo, nullable: true })
richDecodedInfo: RichDecodedInfo | null;

protected constructor(
type: TransactionInfoType,
humanDescription: string | null,
richDecodedInfo: RichDecodedInfo | null,
) {
this.type = type;
this.humanDescription = humanDescription;
this.richDecodedInfo = richDecodedInfo;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ApiProperty } from '@nestjs/swagger';
import { AddressInfo } from '@/routes/common/entities/address-info.entity';
import { RichDecodedInfo } from '@/routes/transactions/entities/human-description.entity';
import {
TransactionInfo,
TransactionInfoType,
Expand Down Expand Up @@ -29,9 +28,8 @@ export class TransferTransactionInfo extends TransactionInfo {
direction: TransferDirection,
transferInfo: Transfer,
humanDescription: string | null,
richDecodedInfo: RichDecodedInfo | null,
) {
super(TransactionInfoType.Transfer, humanDescription, richDecodedInfo);
super(TransactionInfoType.Transfer, humanDescription);
this.sender = sender;
this.recipient = recipient;
this.direction = direction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
import type { AddressInfoHelper } from '@/routes/common/address-info/address-info.helper';
import { NULL_ADDRESS } from '@/routes/common/constants';
import { AddressInfo } from '@/routes/common/entities/address-info.entity';
import { buildHumanDescription } from '@/routes/transactions/entities/__tests__/human-description.builder';
import { CustomTransactionInfo } from '@/routes/transactions/entities/custom-transaction.entity';
import { CustomTransactionMapper } from '@/routes/transactions/mappers/common/custom-transaction.mapper';
import { getAddress } from 'viem';
Expand Down Expand Up @@ -38,7 +37,6 @@ describe('Multisig Custom Transaction mapper (Unit)', () => {
dataSize,
chainId,
null,
null,
);

expect(customTransaction).toBeInstanceOf(CustomTransactionInfo);
Expand Down Expand Up @@ -67,7 +65,6 @@ describe('Multisig Custom Transaction mapper (Unit)', () => {
dataSize,
chainId,
null,
null,
);

expect(customTransaction).toBeInstanceOf(CustomTransactionInfo);
Expand Down Expand Up @@ -96,7 +93,6 @@ describe('Multisig Custom Transaction mapper (Unit)', () => {
dataSize,
chainId,
null,
null,
);

expect(customTransaction).toBeInstanceOf(CustomTransactionInfo);
Expand Down Expand Up @@ -140,7 +136,6 @@ describe('Multisig Custom Transaction mapper (Unit)', () => {
dataSize,
chainId,
null,
null,
);

expect(customTransaction).toBeInstanceOf(CustomTransactionInfo);
Expand Down Expand Up @@ -179,7 +174,6 @@ describe('Multisig Custom Transaction mapper (Unit)', () => {
dataSize,
chainId,
null,
null,
);

expect(customTransaction).toBeInstanceOf(CustomTransactionInfo);
Expand All @@ -200,16 +194,12 @@ describe('Multisig Custom Transaction mapper (Unit)', () => {
const chainId = faker.string.numeric();
const transaction = multisigTransactionBuilder().build();
const humanDescription = 'Send 10 ETH to vitalik.eth';
const richDecodedInfo = {
fragments: buildHumanDescription(),
};

const customTransaction = await mapper.mapCustomTransaction(
transaction,
dataSize,
chainId,
humanDescription,
richDecodedInfo,
);

expect(customTransaction).toBeInstanceOf(CustomTransactionInfo);
Expand All @@ -218,8 +208,5 @@ describe('Multisig Custom Transaction mapper (Unit)', () => {
humanDescription,
}),
);
expect(customTransaction).toEqual(
expect.objectContaining({ richDecodedInfo }),
);
});
});
Loading

0 comments on commit caa9267

Please sign in to comment.