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

Asset transfer #904

Merged
merged 24 commits into from
Jul 28, 2023
Merged

Asset transfer #904

merged 24 commits into from
Jul 28, 2023

Conversation

alistair-singh
Copy link
Contributor

@alistair-singh alistair-singh commented Jul 26, 2023

Resolves: SNO-569
Cumulus companion: Snowfork/cumulus#52

TODO

  • Register token
  • Send token Eth -> Substrate
  • Send token back Substrate -> Eth

@codecov
Copy link

codecov bot commented Jul 26, 2023

Codecov Report

Patch coverage: 62.50% and project coverage change: -0.22% ⚠️

Comparison is base (996469a) 68.43% compared to head (ac710bd) 68.21%.
Report is 1 commits behind head on proxy-contracts.

❗ Current head ac710bd differs from pull request most recent head 28482ad. Consider uploading reports for the commit 28482ad to get more accurate results

Additional details and impacted files
@@                 Coverage Diff                 @@
##           proxy-contracts     #904      +/-   ##
===================================================
- Coverage            68.43%   68.21%   -0.22%     
===================================================
  Files                   42       42              
  Lines                 1774     1787      +13     
  Branches                72       72              
===================================================
+ Hits                  1214     1219       +5     
- Misses                 541      549       +8     
  Partials                19       19              
Flag Coverage Δ
rust 67.05% <52.00%> (-0.22%) ⬇️
solidity 73.15% <100.00%> (-0.16%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
parachain/primitives/core/src/lib.rs 16.92% <0.00%> (-1.42%) ⬇️
parachain/primitives/router/src/inbound/mod.rs 48.59% <ø> (ø)
parachain/primitives/router/src/outbound/mod.rs 87.96% <60.00%> (-1.80%) ⬇️
core/packages/contracts/src/AgentExecutor.sol 100.00% <100.00%> (ø)
core/packages/contracts/src/Assets.sol 67.85% <100.00%> (ø)
core/packages/contracts/src/Gateway.sol 74.30% <100.00%> (-0.36%) ⬇️
parachain/pallets/control/src/lib.rs 60.00% <100.00%> (+5.16%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@vgeddes vgeddes 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! Added a few minor comments

core/packages/contracts/src/Assets.sol Outdated Show resolved Hide resolved
core/packages/contracts/src/Assets.sol Outdated Show resolved Hide resolved
core/packages/contracts/src/Gateway.sol Outdated Show resolved Hide resolved
core/packages/contracts/src/Gateway.sol Outdated Show resolved Hide resolved
Copy link
Collaborator

@vgeddes vgeddes 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!

Token::Address(*token),
Token::Uint(U256::from(*amount)),
Token::Uint(self.index().into()),
Token::Bytes(ethabi::encode(&vec![Token::Tuple(vec![
Copy link
Collaborator

Choose a reason for hiding this comment

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

The Solidity side isn't expecting a tuple (struct) type though.

i.e abi.decode(data, (address, address, uint128)) is equivalent to:

ethabi::encode(&vec![Token::Address(*token), Token::Address(*recipient), Token::Uint(U256::from(*amount))]);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think implicitly it's encoded to the same thing because (address, address, uint128) is an implicit tuple. I have tested both versions and they work. The tuple and just a vec![Tokens]. I used the tuple version because it feels more correct. So I think this is more of style thing so which would you prefer?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I prefer the original form.

We can't say for sure whether they encode to the same thing for all input parameter types, without more investigation and testing. Also Token::Tuple was introduced purely to encode structs, and we're not using structs in this case.

@alistair-singh alistair-singh merged commit b0f922c into proxy-contracts Jul 28, 2023
2 of 3 checks passed
@alistair-singh alistair-singh deleted the alistair/asset-transfer branch July 28, 2023 12:32
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