Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate /transaction-confirmation endpoint #1973

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Conversation

iamacook
Copy link
Member

@iamacook iamacook commented Sep 27, 2024

Summary

Resolves #1927

Currently, the /transaction-confirmation returns a TransactionInfo-like entity for the client to render details about swaps and TWAPs. We equally have the /preview endpoint that returns a TransactionInfo entity.

This adds swap and staking test coverage to the /preview endpoint to ensure usage of it can replace the /transaction-confirmation one (migrated from the latter's suite), fixing any found issues.

Changes

  • Decode staking transaction data instead of using dataDecoded (because of batches).
  • Correct types for /preview endpoint.
  • Add swap/staking test coverage to /preview endpoint.
  • Update other tests according.

@iamacook iamacook self-assigned this Sep 27, 2024
@coveralls
Copy link

coveralls commented Sep 27, 2024

Pull Request Test Coverage Report for Build 11106369405

Details

  • 40 of 40 (100.0%) changed or added relevant lines in 6 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+1.1%) to 91.988%

Totals Coverage Status
Change from base Build 11105212077: 1.1%
Covered Lines: 8482
Relevant Lines: 8886

💛 - Coveralls

Comment on lines 21 to 63
public findDepositTransaction(args: {
chainId: string;
to?: `0x${string}`;
data: `0x${string}`;
}): Promise<{ to: `0x${string}`; data: `0x${string}` } | null> {
return this.findNativeStakingTransaction({
signature: KilnNativeStakingHelper.VALIDATORS_EXIT_SIGNATURE,
...args,
});
value: string;
}): { to?: `0x${string}`; data: `0x${string}`; value: string } | null {
const selector = toFunctionSelector(
KilnNativeStakingHelper.DEPOSIT_SIGNATURE,
);
return this.transactionFinder.findTransaction(
(transaction) => transaction.data.startsWith(selector),
args,
);
}

public async findWithdrawTransaction(args: {
public findValidatorsExitTransaction(args: {
chainId: string;
to?: `0x${string}`;
data: `0x${string}`;
}): Promise<{ to: `0x${string}`; data: `0x${string}` } | null> {
return this.findNativeStakingTransaction({
signature: KilnNativeStakingHelper.WITHDRAW_SIGNATURE,
...args,
});
value: string;
}): { to?: `0x${string}`; data: `0x${string}`; value: string } | null {
const selector = toFunctionSelector(
KilnNativeStakingHelper.VALIDATORS_EXIT_SIGNATURE,
);
return this.transactionFinder.findTransaction(
(transaction) => transaction.data.startsWith(selector),
args,
);
}

private async findNativeStakingTransaction(args: {
signature: string;
public findWithdrawTransaction(args: {
chainId: string;
to?: `0x${string}`;
data: `0x${string}`;
}): Promise<{ to: `0x${string}`; data: `0x${string}` } | null> {
const transaction = this.transactionFinder.findTransaction(
(transaction) =>
transaction.data.startsWith(toFunctionSelector(args.signature)),
value: string;
}): { to?: `0x${string}`; data: `0x${string}`; value: string } | null {
const selector = toFunctionSelector(
KilnNativeStakingHelper.WITHDRAW_SIGNATURE,
);
return this.transactionFinder.findTransaction(
(transaction) => transaction.data.startsWith(selector),
args,
);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When writing the tests, I realised we also check the deployment when mapping and fallback to a "standard" transaction there. This is therefore unnecessary, and now covered by tests.

args.dataDecoded,
);
const publicKeys = this.kilnNativeStakingHelper.splitPublicKeys(
this.kilnDecoder.decodeValidatorsExit(args.data)!.parameters[0].value,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a TODO added to the KilnDecoder to simplify this after deprecating the /transaction-confirmations endpoint.

return [];
}): Promise<Array<`0x${string}`> | null> {
if (!args.txHash) {
return null;
Copy link
Member Author

@iamacook iamacook Sep 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have looked through the client codebase and this will not affect the current implementation. The validators are only mapped on exit transactions, when we know the values.

@iamacook iamacook changed the title Add swap and staking tests to preview endpoint Deprecate /transaction-confirmation endpoint Sep 30, 2024
@iamacook iamacook marked this pull request as ready for review September 30, 2024 07:35
@iamacook iamacook requested a review from a team as a code owner September 30, 2024 07:35
@iamacook iamacook linked an issue Sep 30, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Investigate using mappers for transaction-confirmation endpoint
2 participants