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

fix return types in asset erc20 and refactor asseterc20precompileset #990

Conversation

girazoki
Copy link
Collaborator

@girazoki girazoki commented Nov 14, 2021

What does it do?

It solves some issues found in assets-erc20-precompiles when being called form a smart contract. IN particular:

  • DelegateCalls where not working, since we were fetching the assetId from execution_address, but delegateCalls take the calling smart contract as execution_address. I made a refactor to avoid this situation, and I think the code looks cleaner now.

  • Calls from a SC to transfer, approve, TransferFrom were not working, as we were not returning a boolean as the execution result. This is required by the ERC-20 standard, so I added this fixing the corresponding tests.

  • Added a ton of typescript tests regarding delegateCalls and smart contract calls cases. I think I have covered most of the stuff now

What important points reviewers should know?

Is there something left for follow-up PRs?

What alternative implementations were considered?

Are there relevant PRs or issues in other repositories (Substrate, Polkadot, Frontier, Cumulus)?

What value does it bring to the blockchain users?

@girazoki girazoki changed the title Girazoki fix return types in asset erc20 and refactor asseterc20precompileset fix return types in asset erc20 and refactor asseterc20precompileset Nov 14, 2021
@girazoki girazoki added the B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes label Nov 15, 2021
precompiles/assets-erc20/src/lib.rs Outdated Show resolved Hide resolved
tests/contracts/sources.ts Outdated Show resolved Hide resolved
@girazoki girazoki added the C7-high Elevates a release containing this PR to "high priority". label Nov 15, 2021
@@ -194,7 +194,7 @@ fn export_current_state() {

// Let it produce some blocks.
// This fails if is not a minimum of 25
thread::sleep(Duration::from_secs(25));
thread::sleep(Duration::from_secs(35));
Copy link
Collaborator

Choose a reason for hiding this comment

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

why ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I guess because of the JIT compilation issue. but the CI was complaining:(

Copy link
Contributor

Choose a reason for hiding this comment

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

This can [hopefully] be reverted once 993 is merged.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

indeed

@girazoki girazoki merged commit 60c3a17 into master Nov 17, 2021
@girazoki girazoki deleted the girazoki-fix-return-types-in-asset-erc20-and-refactor-asseterc20precompileset branch November 17, 2021 09:03
girazoki added a commit that referenced this pull request Nov 17, 2021
…990)

* Fix return type matching the open zeppeling ERC20 and the way to access AssetId in PrecompileSet

* Start typescrypt testing this

* Fix typescript integration tests

* Check if caller is same as from

* add delgeate calls to contract instance

* add more cases considering delegate and normal calls

* Add contract compiled

* Increment node wake up time yet again

* Increment the proper timeout

* Add PR suggestions
girazoki added a commit that referenced this pull request Nov 17, 2021
* fix return types in asset erc20 and refactor asseterc20precompileset (#990)

* Fix return type matching the open zeppeling ERC20 and the way to access AssetId in PrecompileSet

* Start typescrypt testing this

* Fix typescript integration tests

* Check if caller is same as from

* add delgeate calls to contract instance

* add more cases considering delegate and normal calls

* Add contract compiled

* Increment node wake up time yet again

* Increment the proper timeout

* Add PR suggestions

* Bump specs to 902 in moonbase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes C7-high Elevates a release containing this PR to "high priority".
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants