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 revert handling #12

Merged
merged 5 commits into from
Aug 19, 2024
Merged

add revert handling #12

merged 5 commits into from
Aug 19, 2024

Conversation

skosito
Copy link
Contributor

@skosito skosito commented Aug 16, 2024

covering flow:

  • GatewayEVM.execute called with address of Hello contract from example-contracts
  • worker picks up Called event and forwards call to Hello contract's onCrossChainCall
  • onCrossChainCall reverts
  • worker calls GatewayEVM.executeRevert using RevertOptions from Called event

is this useful? also it seems localnet in general needs some modifications, for example currently it was broken because zrc20 contract was missing - in this case, onCrossChainCall expects zrc20 to be passed as arg, which zrc20 we would send if localnet doesn't deploy some?

@fadeev
Copy link
Member

fadeev commented Aug 19, 2024

@skosito I think deployProtocolContracts should deploy an ERC-20 (let's call it USDC) and an associated ZRC-20 USDC. It should also deploy ZRC-20 ETH. If EVM test contract sends native gas token, then ZRC-20 ETH is passed to the onCrossChainCall, if ERC-20 USDC is sent, then ZRC-20 USDC.

This way we mirror the behavior of the real environment allowing a developer to test both native gas and ERC-20 tokens.

@fadeev
Copy link
Member

fadeev commented Aug 19, 2024

For simplicity, we can just start with ETH & ZRC-20 ETH support. And possibly add ERC-20 later.

const testZRC20 = await zrc20Factory
.connect(fungibleModuleSigner)
.deploy(
"TOKEN",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"TOKEN",
"ZRC-20 ETH",

@fadeev
Copy link
Member

fadeev commented Aug 19, 2024

@skosito thanks for this PR! Now a example contract works when called from EVM! 🙌

@skosito
Copy link
Contributor Author

skosito commented Aug 19, 2024

@skosito I think deployProtocolContracts should deploy an ERC-20 (let's call it USDC) and an associated ZRC-20 USDC. It should also deploy ZRC-20 ETH. If EVM test contract sends native gas token, then ZRC-20 ETH is passed to the onCrossChainCall, if ERC-20 USDC is sent, then ZRC-20 USDC.

This way we mirror the behavior of the real environment allowing a developer to test both native gas and ERC-20 tokens.

sure i will try to update

@skosito
Copy link
Contributor Author

skosito commented Aug 19, 2024

adding just zrc-eth for now so we handle current flow we have, i think simpler approach is that we can extend with more zrc20s and other functionalities as we add examples, since atm we are not supporting all events anyways, and keeping localnet simple as possible would be nice - we can add issues as we go

i also added same revert handling on zevm side

@skosito skosito marked this pull request as ready for review August 19, 2024 11:55
@skosito skosito changed the title wip revert handling add revert handling Aug 19, 2024
@skosito skosito requested a review from fadeev August 19, 2024 12:48
Copy link
Member

@fadeev fadeev left a comment

Choose a reason for hiding this comment

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

Reverts are working now!

@fadeev fadeev merged commit 6cf7f5e into main Aug 19, 2024
3 checks passed
@fadeev
Copy link
Member

fadeev commented Aug 19, 2024

Closed #10 & #11

@skosito skosito deleted the revert-handling branch August 20, 2024 11:54
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.

2 participants