Skip to content
This repository was archived by the owner on Nov 10, 2023. It is now read-only.

Conversation

@DiogoSoaress
Copy link
Contributor

@DiogoSoaress DiogoSoaress commented Dec 20, 2021

What it solves

Resolves #3190

How this PR fixes it

Uses the estimations endpoint v2 to fetch the next recommended txNonce

A Cancel transaction is used if we are only interested in fetching the recommendedNonce
POST body:

{
    "to": "0xc1e55e565a40BB76686C94E0688be8F00cbE9d60",
    "value": "0",
    "data": "0x",
    "operation": 0
}

@github-actions
Copy link

CLA Assistant Lite All Contributors have signed the CLA.

@DiogoSoaress
Copy link
Contributor Author

Waiting for the safe-react-gateway-sdk to publish a new version.

@github-actions
Copy link

github-actions bot commented Dec 20, 2021

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 1 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

@coveralls
Copy link

coveralls commented Dec 20, 2021

Pull Request Test Coverage Report for Build 1610849559

  • 5 of 18 (27.78%) changed or added relevant lines in 5 files are covered.
  • 13 unchanged lines in 5 files lost coverage.
  • Overall coverage increased (+0.1%) to 32.197%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/logic/safe/api/fetchSafeTxGasEstimation.ts 3 4 75.0%
src/logic/safe/transactions/gas.ts 0 2 0.0%
src/routes/safe/container/hooks/useTransactionParameters.ts 2 4 50.0%
src/logic/safe/store/actions/createTransaction.ts 0 4 0.0%
src/logic/safe/store/actions/processTransaction.ts 0 4 0.0%
Files with Coverage Reduction New Missed Lines %
src/logic/safe/store/actions/createTransaction.ts 1 3.23%
src/logic/safe/store/actions/processTransaction.ts 1 1.08%
src/logic/notifications/store/reducer/notifications.ts 3 6.9%
src/routes/safe/components/Apps/hooks/appList/useRemoteSafeApps.ts 3 75.0%
src/logic/notifications/store/actions/enqueueSnackbar.tsx 5 27.27%
Totals Coverage Status
Change from base Build 1610811340: 0.1%
Covered Lines: 3080
Relevant Lines: 8496

💛 - Coveralls

@github-actions
Copy link

Deployment links

🟠 Safe Rinkeby Safe Mainnet 🟣 Safe Polygon 🟡 Safe BSC Safe Arbitrum 🟢 Safe xDai

@github-actions
Copy link

github-actions bot commented Dec 20, 2021

E2E Tests Failed
Check the results here: https://github.com/gnosis/safe-react-e2e-tests/actions/runs/1610779796

Failed tests:

  • ❌ Read-only transaction creation and review Read-only transaction creation and review

({ safeTxGas }) => safeTxGas,
)
}: FetchSafeTxGasEstimationProps): Promise<SafeTransactionEstimationV2> => {
return postSafeGasEstimationV2(GATEWAY_URL, _getChainId(), checksumAddress(safeAddress), body).then((data) => data)
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need the then() method here.

import {
postSafeGasEstimationV2,
SafeTransactionEstimationRequest,
SafeTransactionEstimationV2,
Copy link
Member

Choose a reason for hiding this comment

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

This V2 looks off. Let's rename the old one to SafeTransactionEstimationV1 and call the new one simply SafeTransactionEstimation.

Copy link
Contributor

@mmv08 mmv08 Dec 21, 2021

Choose a reason for hiding this comment

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

Is SafeTransactionEstimation v0 or v2? I'd stay as explicit as possible or rename old v1 to something else

Copy link
Contributor

Choose a reason for hiding this comment

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

We are only using what is now v2 in frontend. Do you think it would be necessary to keep the 'legacy' function/type? Our docs would only show the v2 response, from my understanding.

@DiogoSoaress DiogoSoaress marked this pull request as ready for review December 21, 2021 11:55
safeAddress,
value: '0',
operation: Operation.CALL,
// Workaround: use a cancellation transaction to fetch only the recommendedNonce
Copy link
Member

Choose a reason for hiding this comment

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

In future, we should make just one request – to fetch the actual safeTxGas and the nonce. They are displayed on the same Review screen.

const nextNonce = await getNewTxNonce(lastTxNonce, safeInstance)
let nextNonce: string
try {
nextNonce = (await getRecommendedNonce(safeAddress)).toString()
Copy link
Member

Choose a reason for hiding this comment

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

There's already a toString() on line 128.

Copy link
Member

@katspaugh katspaugh left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@katspaugh katspaugh changed the title Use estimations v2 endpoint for tx nonce Fix: use estimations v2 endpoint for tx nonce Dec 22, 2021
@katspaugh
Copy link
Member

I'll merge this to dev because it's broken after Safe Apps were moved to the SDK. This new version fixes it.

@iamacook iamacook linked an issue Dec 22, 2021 that may be closed by this pull request
@DiogoSoaress DiogoSoaress changed the base branch from main to dev December 22, 2021 09:54
@DiogoSoaress DiogoSoaress merged commit 7c4b469 into dev Dec 22, 2021
@DiogoSoaress DiogoSoaress deleted the use-estimations-v2-endpoint-for-tx-nonce branch December 22, 2021 10:26
@github-actions github-actions bot locked and limited conversation to collaborators Dec 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect nonce after transaction submission

6 participants