Skip to content

Commit

Permalink
Remove transaction confirmation view endpoint (#2276)
Browse files Browse the repository at this point in the history
This removes the deprecated transaction confirmation view (`/v1/chains/:chainId/safes/:safeAddress/views/transaction-confirmation`) endpoint:

- Remove transaction confirmation view: module, controller, service and entities
- Simplify `KilnDecoder` methods that were dependant on the above
- Update tests accordingly
  • Loading branch information
iamacook authored Jan 27, 2025
1 parent 68a226e commit 31a1b6d
Show file tree
Hide file tree
Showing 13 changed files with 8 additions and 3,706 deletions.
2 changes: 0 additions & 2 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ import { RelayControllerModule } from '@/routes/relay/relay.controller.module';
import { ZodErrorFilter } from '@/routes/common/filters/zod-error.filter';
import { CacheControlInterceptor } from '@/routes/common/interceptors/cache-control.interceptor';
import { AuthModule } from '@/routes/auth/auth.module';
import { TransactionsViewControllerModule } from '@/routes/transactions/transactions-view.controller';
import { DelegatesV2Module } from '@/routes/delegates/v2/delegates.v2.module';
import { AccountsModule } from '@/routes/accounts/accounts.module';
import { NotificationsModuleV2 } from '@/routes/notifications/v2/notifications.module';
Expand Down Expand Up @@ -111,7 +110,6 @@ export class AppModule implements NestModule {
SafesModule,
TargetedMessagingModule,
TransactionsModule,
TransactionsViewControllerModule,
...(isUsersFeatureEnabled ? [UsersModule] : []),
// common
CacheModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,42 +23,12 @@ describe('KilnDecoder', () => {
kilnDecoder = new KilnDecoder(mockLoggingService);
});

describe('decodeDeposit', () => {
it('decodes a deposit function call correctly', () => {
const data = depositEncoder().encode();
expect(kilnDecoder.decodeDeposit(data)).toEqual({
method: 'deposit',
parameters: [],
});
});

it('returns null if the data is not a deposit function call', () => {
const data = faker.string.hexadecimal({ length: 1 }) as `0x${string}`;
expect(kilnDecoder.decodeDeposit(data)).toBeNull();
});

it('returns null if the data is another Kiln function call', () => {
const data = requestValidatorsExitEncoder().encode();
expect(kilnDecoder.decodeDeposit(data)).toBeNull();
});
});

describe('decodeValidatorsExit', () => {
it('decodes a requestValidatorsExit function call correctly', () => {
const requestValidatorsExist = requestValidatorsExitEncoder();
const { _publicKeys } = requestValidatorsExist.build();
const data = requestValidatorsExist.encode();
expect(kilnDecoder.decodeValidatorsExit(data)).toEqual({
method: 'requestValidatorsExit',
parameters: [
{
name: '_publicKeys',
type: 'bytes',
value: _publicKeys,
valueDecoded: null,
},
],
});
expect(kilnDecoder.decodeValidatorsExit(data)).toEqual(_publicKeys);
});

it('returns null if the data is not a requestValidatorsExit function call', () => {
Expand All @@ -77,17 +47,7 @@ describe('KilnDecoder', () => {
const decodeBatchWithdrawCLFee = batchWithdrawCLFeeEncoder();
const { _publicKeys } = decodeBatchWithdrawCLFee.build();
const data = decodeBatchWithdrawCLFee.encode();
expect(kilnDecoder.decodeBatchWithdrawCLFee(data)).toEqual({
method: 'batchWithdrawCLFee',
parameters: [
{
name: '_publicKeys',
type: 'bytes',
value: _publicKeys,
valueDecoded: null,
},
],
});
expect(kilnDecoder.decodeBatchWithdrawCLFee(data)).toEqual(_publicKeys);
});

it('returns null if the data is not a batchWithdrawCLFee function call', () => {
Expand Down
61 changes: 4 additions & 57 deletions src/domain/staking/contracts/decoders/kiln-decoder.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,7 @@ export class KilnDecoder extends AbiDecoder<typeof KilnAbi> {
super(KilnAbi);
}

// TODO: When confirmation view endpoint is removed, remove this
// and use this.helpers.isDeposit instead
decodeDeposit(
data: `0x${string}`,
): { method: string; parameters: [] } | null {
if (!this.helpers.isDeposit(data)) {
return null;
}
try {
const decoded = this.decodeFunctionData({ data });
if (decoded.functionName !== 'deposit') {
throw new Error('Data is not of deposit type');
}
return {
method: decoded.functionName,
parameters: [],
};
} catch (e) {
this.loggingService.debug(e);
return null;
}
}

// TODO: When confirmation view endpoint is removed, return only
// publicKeys and don't format it like DataDecoded
decodeValidatorsExit(data: `0x${string}`): {
method: string;
parameters: Array<KilnRequestValidatorsExitParameters>;
} | null {
decodeValidatorsExit(data: `0x${string}`): `0x${string}` | null {
if (!this.helpers.isRequestValidatorsExit(data)) {
return null;
}
Expand All @@ -66,29 +38,14 @@ export class KilnDecoder extends AbiDecoder<typeof KilnAbi> {
if (decoded.functionName !== 'requestValidatorsExit') {
throw new Error('Data is not of requestValidatorsExit type');
}
return {
method: decoded.functionName,
parameters: [
{
name: '_publicKeys',
type: 'bytes',
value: decoded.args[0],
valueDecoded: null,
},
],
};
return decoded.args[0];
} catch (e) {
this.loggingService.debug(e);
return null;
}
}

// TODO: When confirmation view endpoint is removed, return only
// publicKeys and don't format it like DataDecoded
decodeBatchWithdrawCLFee(data: `0x${string}`): {
method: string;
parameters: Array<KilnBatchWithdrawCLFeeParameters>;
} | null {
decodeBatchWithdrawCLFee(data: `0x${string}`): `0x${string}` | null {
if (!this.helpers.isBatchWithdrawCLFee(data)) {
return null;
}
Expand All @@ -97,17 +54,7 @@ export class KilnDecoder extends AbiDecoder<typeof KilnAbi> {
if (decoded.functionName !== 'batchWithdrawCLFee') {
throw new Error('Data is not of batchWithdrawCLFee type');
}
return {
method: decoded.functionName,
parameters: [
{
name: '_publicKeys',
type: 'bytes',
value: decoded.args[0],
valueDecoded: null,
},
],
};
return decoded.args[0];
} catch (e) {
this.loggingService.debug(e);
return null;
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 31a1b6d

Please sign in to comment.