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

Get public keys from DepositEvent #1957

Merged
merged 6 commits into from
Sep 25, 2024
Merged

Get public keys from DepositEvent #1957

merged 6 commits into from
Sep 25, 2024

Conversation

iamacook
Copy link
Member

Summary

In order to return the status of a given staking transaction, we fetch the Stakes from Kiln via validator keys. Generally, this is extracted from the DataDecoded. However, deposit transactions have no _publicKeys parameter.

This fetches the transaction status of a deposit transaction via it's transaction hash and, from it, decodes the public keys of the related validators. With that, the aforementioned status mapping is done.

Changes

  • Add KilnDecoder['decodeDepositEvent'].
  • Decode public keys from deposit transaction status.
  • Add/update tests accordingly.

@iamacook iamacook self-assigned this Sep 24, 2024
@@ -15,7 +15,6 @@ export function stakeBuilder(): IBuilder<Stake> {
}) as `0x${string}`,
)
.with('state', faker.helpers.arrayElement(Object.values(StakeState)))
.with('effective_balance', faker.string.numeric())
Copy link
Member Author

Choose a reason for hiding this comment

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

effective_balance was removed from the entity because it is not returned when a Stake is not yet active, meaning it would fail validation. The value, in general, is also not used.

Comment on lines -345 to -348
const isConfirmed =
'confirmations' in transaction &&
!!transaction.confirmations &&
transaction.confirmations.length >= transaction.confirmationsRequired;
Copy link
Member Author

Choose a reason for hiding this comment

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

The general txStatus signifies if a transaction is awaiting signatures/executions. The txInfo.status of a staking transaction is inherently staking specific, e.g. NOT_STAKED, DEPOSIT_IN_PROGRESS, etc.

@coveralls
Copy link

coveralls commented Sep 24, 2024

Pull Request Test Coverage Report for Build 11031317793

Details

  • 26 of 29 (89.66%) changed or added relevant lines in 2 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.003%) to 90.796%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/domain/staking/contracts/decoders/kiln-decoder.helper.ts 8 9 88.89%
src/routes/transactions/mappers/common/native-staking.mapper.ts 18 20 90.0%
Files with Coverage Reduction New Missed Lines %
src/routes/transactions/mappers/common/transaction-info.mapper.ts 1 56.25%
Totals Coverage Status
Change from base Build 11031275722: 0.003%
Covered Lines: 8363
Relevant Lines: 8840

💛 - Coveralls

@iamacook iamacook marked this pull request as ready for review September 24, 2024 17:47
@iamacook iamacook requested a review from a team as a code owner September 24, 2024 17:47
@iamacook iamacook linked an issue Sep 25, 2024 that may be closed by this pull request
@@ -13,6 +14,7 @@ const mockLoggingService = {
warn: jest.fn(),
} as jest.MockedObjectDeep<ILoggingService>;

// TODO: Move function encoding to kiln-encoder.builder.ts
Copy link
Member Author

Choose a reason for hiding this comment

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

This is covered in #1959, which I've marked as a draft until this is merged.

return [];
}

// There is only one DepositEvent per transaction
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Do you think it would be useful to emit a warning log line if this condition is not met for some reason?

Copy link
Member Author

Choose a reason for hiding this comment

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

As the contracts are immutable, this should inherently never happen. However, on the off chance it does, warning makes sense. I added a warn and a comment in 0fe91cd.

hectorgomezv
hectorgomezv previously approved these changes Sep 25, 2024
compojoom added a commit to safe-global/safe-gateway-typescript-sdk that referenced this pull request Sep 25, 2024
Instead of having multiple statuses we are now opting for one stake
status. Aligning with the changes on cgw in this PR:
safe-global/safe-client-gateway#1957
Base automatically changed from kiln-tx-status to main September 25, 2024 10:34
@iamacook iamacook dismissed hectorgomezv’s stale review September 25, 2024 10:34

The base branch was changed.

@iamacook iamacook merged commit 9bd181c into main Sep 25, 2024
18 checks passed
@iamacook iamacook deleted the deposit-status branch September 25, 2024 12:05
compojoom added a commit to safe-global/safe-gateway-typescript-sdk that referenced this pull request Sep 26, 2024
Instead of having multiple statuses we are now opting for one stake
status. Aligning with the changes on cgw in this PR:
safe-global/safe-client-gateway#1957
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.

Staking deposit transactions status incorrect
3 participants