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

refactor: call onCrossChainCall when depositing to a contract #1226

Merged
merged 14 commits into from
Oct 6, 2023

Conversation

lumtis
Copy link
Member

@lumtis lumtis commented Oct 3, 2023

Description

Simplify the method HandleEVMDeposit, to is replaced by the parsed address in the message if any (previously we separated the parsed address into another variable but to was not used anymore which added more argument to the ZRC20DepositAndCallContract function than needed)

Check if to is a contract in ZRC20DepositAndCallContract and use DepositZRC20AndCallContract when it is the case.

The PR also introduces a fix for #1234 since depositing the zrc20 into the asset address could result into the loss of tokens

Closes: #1216

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Include instructions and any relevant details so others can reproduce.

  • Tested CCTX in localnet
  • Tested in development environment
  • Go unit tests
  • Go integration tests
  • Tested via GitHub Actions

Checklist:

  • I have added unit tests that prove my fix feature works

@lumtis lumtis self-assigned this Oct 3, 2023
}
if parsedAddress != (ethcommon.Address{}) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious why we need allow parsedAddress == ethcommon.Address{} ?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the fallback when no address is read from the message, it only contains data. So to will not be updated and will remains msg.Receiver

Currently the fallback is to use msg.Asset but it doesn't seem valid to me since msg.Asset represents an address on the external chain and not ZetaChain #1234

Copy link
Contributor

@kingpinXD kingpinXD left a comment

Choose a reason for hiding this comment

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

looks good, left a minor comment

@lumtis lumtis requested a review from kingpinXD October 4, 2023 21:35
@lumtis lumtis linked an issue Oct 5, 2023 that may be closed by this pull request
Copy link
Collaborator

@brewmaster012 brewmaster012 left a comment

Choose a reason for hiding this comment

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

LGTM
minor suggest for change

x/fungible/keeper/deposits.go Show resolved Hide resolved
@lumtis lumtis merged commit 8137bb0 into develop Oct 6, 2023
13 checks passed
@lumtis lumtis deleted the feat/deposit-onCrossChainCall2 branch October 6, 2023 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants