Skip to content
Snippets Groups Projects
Unverified Commit 274a781e authored by xermicus's avatar xermicus Committed by GitHub
Browse files

[pallet-revive] do not trap the caller on instantiations with duplicate contracts (#7414)


This PR changes the behavior of `instantiate` when the resulting
contract address already exists (because the caller tried to instantiate
the same contract with the same salt multiple times): Instead of
trapping the caller, return an error code.

Solidity allows `catch`ing this, which doesn't work if we are trapping
the caller. For example, the change makes the following snippet work:

```Solidity
try new Foo{salt: hex"00"}() returns (Foo) {
    // Instantiation was successful (contract address was free and constructor did not revert)
} catch {
    // This branch is expected to be taken if the instantiation failed because of a duplicate salt
}
```

`revive` PR: https://github.com/paritytech/revive/pull/188

---------

Signed-off-by: default avatarCyrill Leutwiler <bigcyrill@hotmail.com>
Co-authored-by: default avatarcmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
parent 4f4f6f82
No related merge requests found
Pipeline #514086 waiting for manual action with stages
in 35 minutes and 17 seconds
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment