Skip to content

feat: override safe nonce and verify signatures#52

Merged
mdehoog merged 2 commits intobase:mainfrom
felipe-op:felipe/override-nonce
Nov 6, 2023
Merged

feat: override safe nonce and verify signatures#52
mdehoog merged 2 commits intobase:mainfrom
felipe-op:felipe/override-nonce

Conversation

@felipe-op
Copy link
Contributor

@felipe-op felipe-op commented Nov 6, 2023

This change adds a new environment variable called SAFE_NONCE which allow callers to override the Safe contract nonce.

This is useful when crafting future transactions ahead of time and collecting signatures.

It also provides a new function verify(bytes memory _signatures) to make sure the collected signatures are valid to execute the transaction.

It is intended to work as:

  1. Maintainer craft a transaction ahead of time
  2. Multiple signer parties are contacted and sign the transaction offline
  3. Maintainer collect and verify the presigned transactions
  4. Transaction with signatures are stored safely for later execution

uint256 nonce = safe.nonce();
console.log("Safe current nonce:", nonce);

uint256 nonceOverride = vm.envUint("SAFE_NONCE");
Copy link
Contributor

@tynes tynes Nov 6, 2023

Choose a reason for hiding this comment

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

uint256 nonce = vm.envOr("SAFE_NONCE", safe.nonce());

@mdehoog mdehoog merged commit 1f65318 into base:main Nov 6, 2023
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.

3 participants