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

Add method createRejectionTransaction #38

Merged
merged 7 commits into from
Jun 15, 2021
Merged

Add method createRejectionTransaction #38

merged 7 commits into from
Jun 15, 2021

Conversation

germartinez
Copy link
Member

@germartinez germartinez commented Jun 14, 2021

Adds the method rejectTransaction that invalidates a pending Safe transaction.

@germartinez germartinez requested a review from mmv08 June 14, 2021 13:03
@github-actions
Copy link

CLA Assistant Lite All Contributors have signed the CLA.

@germartinez germartinez requested a review from rmeissner June 14, 2021 13:04
@germartinez germartinez linked an issue Jun 14, 2021 that may be closed by this pull request
* @param safeTransaction - The pending Safe transaction to be invalidated
* @returns The Safe transaction that invalidates the pending Safe transaction
*/
async rejectTransaction(safeTransaction: SafeTransaction): Promise<SafeTransaction> {
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if the name should be createRejectionTransaction. This fits more to the existing createTransaction and in my opinion closer to what is happening.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe in the SDK, we'd also want API to be about replacing a transaction. In the UI it was simplified to "cancelation", but maybe in the SDK, we can be more realistic about what's happening behind the scenes. The API can be way simpler too: .replaceTransaction(nonce)

Copy link
Member Author

Choose a reason for hiding this comment

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

I like createRejectionTransaction(nonce). Using the word "replace" is not my favourite option because it is true that we are replacing a transaction, but always with an empty transaction, not a custom one.

@@ -197,21 +212,60 @@ describe('Transactions execution', () => {
.expect(safeInitialBalance.toString())
.to.be.eq(safeFinalBalance.add(BigNumber.from(tx.data.value).toString()))
})

it('should fail if a transaction that was rejected is executed', async () => {
Copy link
Member

@mmv08 mmv08 Jun 15, 2021

Choose a reason for hiding this comment

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

I found this test description hard to understand, I think something like should fail if you try to execute replaced transaction. Maybe I'm nitpicking, but I had to read the test to understand what's happening

Copy link
Member Author

Choose a reason for hiding this comment

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

What do you think about should fail if the user tries to execute a transaction that was invalidated?

Copy link
Member

@mmv08 mmv08 Jun 15, 2021

Choose a reason for hiding this comment

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

I don't like it because we don't really use invalidated, if you replace it with rejected then it sounds good to me. The description I suggested is even simpler because it doesn't contain passive voice

@germartinez germartinez changed the title Add method rejectTransaction Add method createRejectionTransaction Jun 15, 2021
@germartinez germartinez merged commit b43403e into main Jun 15, 2021
@germartinez germartinez deleted the reject-tx branch June 15, 2021 17:18
@github-actions github-actions bot locked and limited conversation to collaborators Jun 15, 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.

Add rejectTransaction method to the Safe Core SDK
3 participants