-
Notifications
You must be signed in to change notification settings - Fork 360
Fix: use estimations v2 endpoint for tx nonce #3201
Conversation
|
CLA Assistant Lite All Contributors have signed the CLA. |
|
Waiting for the |
ESLint Summary View Full Report
Report generated by eslint-plus-action |
Deployment links
|
|
E2E Tests Failed Failed tests:
|
| ({ safeTxGas }) => safeTxGas, | ||
| ) | ||
| }: FetchSafeTxGasEstimationProps): Promise<SafeTransactionEstimationV2> => { | ||
| return postSafeGasEstimationV2(GATEWAY_URL, _getChainId(), checksumAddress(safeAddress), body).then((data) => data) |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
| safeAddress, | ||
| value: '0', | ||
| operation: Operation.CALL, | ||
| // Workaround: use a cancellation transaction to fetch only the recommendedNonce |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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.
katspaugh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
|
I'll merge this to dev because it's broken after Safe Apps were moved to the SDK. This new version fixes it. |
What it solves
Resolves #3190
How this PR fixes it
Uses the
estimationsendpoint v2 to fetch the next recommendedtxNonceA
Cancel transactionis used if we are only interested in fetching therecommendedNoncePOST body: