(Bugfix) Fails to create transaction#1332
Conversation
|
CLA Assistant Lite All Contributors have signed the CLA. |
ESLint Summary View Full Report
Report generated by eslint-plus-action |
|
Travis automatic deployment: |
|
@fernandomg Agustine made a solution for this in his PR #1230, maybe you can take it from here to avoid conflicts in the future |
|
On the other hand, why did it stop working at development? This function has been working fine for ages. May it be that we're dealing with the consequences instead of solving the real problem? |
rmeissner
left a comment
There was a problem hiding this comment.
Please add a test for this to make sure that this doesn't happen again
I didn't know he was working on a particular bug that affects all the other PRs, in that particular one. Good to know.
That's the exact same question I asked myself. The bug was introduced here: https://github.com/gnosis/safe-react/pull/1301/files#diff-6c3bab67fc37510237bb32f6523ef7f9R19-R32 If you see, I think that this fix is more likely to keep the function behavior from before. The I just added the
Agree, but I'm still waiting for the #1230 to be merged to have the mocked services that help to test. |
The return type for the function is string, how could it force an invalid type? |
you're returning |
|
I do have tests for this on my test branch, don't lose time adding them here |
|
@fernandomg function's return type is |
That comment isn't adding any significant value to the discussion. Being a Thing is that the function "worked well for ages", and a bug was introduced due to enforced types. Check the old code: export const getNewTxNonce = async (txNonce, lastTx, safeInstance) => {
if (!Number.isInteger(Number.parseInt(txNonce, 10))) {
return lastTx === null
? // use current's safe nonce as fallback
(await safeInstance.nonce()).toString()
: `${lastTx.nonce + 1}`
}
return txNonce
}the bug was introduced here: export const getNewTxNonce = async (
txNonce: string | undefined,
lastTx: TxServiceModel | null,
safeInstance: GnosisSafe,
): Promise<string> => {
if (typeof txNonce === 'string' && !Number.isInteger(Number.parseInt(txNonce, 10))) {
return lastTx === null
? // use current's safe nonce as fallback
(await safeInstance.methods.nonce().call()).toString()
: `${lastTx.nonce + 1}`
}
return txNonce as string
}the solution I'm proposing is: if We can't keep the original code as to avoid confusions, what I'm proposing in this PR is: export const getNewTxNonce = async (
txNonce: string | undefined,
lastTx: TxServiceModel | null,
safeInstance: GnosisSafe,
): Promise<string> => {
if (!txNonce || !Number.isInteger(Number.parseInt(txNonce, 10))) {
return lastTx === null
? // use current's safe nonce as fallback
(await safeInstance.methods.nonce().call()).toString()
: `${lastTx.nonce + 1}`
}
return txNonce
} |
|
@fernandomg sorry, I mixed it up a little bit. But nevertheless, I like Agustine's solution more because it's easier to understand. |
|
@mikheevm, updated with Agus' code. @rmeissner, can you approve this? See: #1332 (comment) This bug is blocking those PRs who already merged Except that if #1230 is getting merged right away, this PR makes no sense after all and we can close it. |
|
Travis automatic deployment: |
|
closed, as it's no longer needed due to the revert at: #1335 |
This PR fixes an issue in
developmentwhere transactions are not being properly created due tononcenot being properly calculated.