Skip to content

Commit

Permalink
Don't expose rich fragments (#2061)
Browse files Browse the repository at this point in the history
Removes the exposure of rich fragments and the associated feature flag:

- Don't expose richDecodedInfo
- Remove feature flag
- Remove potential undefined type throughout project
  • Loading branch information
iamacook authored Oct 25, 2024
1 parent dcff225 commit 0352324
Show file tree
Hide file tree
Showing 33 changed files with 76 additions and 304 deletions.
1 change: 0 additions & 1 deletion src/config/entities/__tests__/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ export default (): ReturnType<typeof configuration> => ({
},
express: { jsonLimit: '1mb' },
features: {
richFragments: true,
email: false,
zerionBalancesChainIds: ['137'],
debugLogs: false,
Expand Down
1 change: 0 additions & 1 deletion src/config/entities/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ export default () => ({
jsonLimit: process.env.EXPRESS_JSON_LIMIT ?? '1mb',
},
features: {
richFragments: process.env.FF_RICH_FRAGMENTS?.toLowerCase() === 'true',
email: process.env.FF_EMAIL?.toLowerCase() === 'true',
zerionBalancesChainIds:
process.env.FF_ZERION_BALANCES_CHAIN_IDS?.split(',') ?? [],
Expand Down
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 | undefined,
) {
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 | undefined,
) {
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
6 changes: 0 additions & 6 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,17 +18,12 @@ export class TransactionInfo {
type: TransactionInfoType;
@ApiPropertyOptional({ type: String, nullable: true })
humanDescription: string | null;
// TODO: Remove nullable once the feature flag is removed, allow returning an empty array instead
@ApiPropertyOptional({ type: RichDecodedInfo, nullable: true })
richDecodedInfo: RichDecodedInfo | null | undefined;

protected constructor(
type: TransactionInfoType,
humanDescription: string | null,
richDecodedInfo: RichDecodedInfo | null | undefined,
) {
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 | undefined,
) {
super(TransactionInfoType.Transfer, humanDescription, richDecodedInfo);
super(TransactionInfoType.Transfer, humanDescription);
this.sender = sender;
this.recipient = recipient;
this.direction = direction;
Expand Down
Loading

0 comments on commit 0352324

Please sign in to comment.