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

eosio.erc2o contract implementation #5

Merged
merged 14 commits into from
Sep 5, 2023
Merged

eosio.erc2o contract implementation #5

merged 14 commits into from
Sep 5, 2023

Conversation

taokayan
Copy link
Contributor

@taokayan taokayan commented Aug 28, 2023

Resolves #612, based on @yarkinwho 's work.

list of actions:

  • upgrade: deploy the implementation contract on EVM side
  • regtoken: deploy and initialize the proxy contract on EVM side with parameters (symbol, precision... etc), setup the linkage between EOS token contract and EVM ERC-20 contract.
  • transfer(notifier): implemention of EOS token->EVM ERC20 bridging
  • onbridgemsg: implementation of EVM ERC20 -> EOS token
  • addegress: add white list to accounts with contracts
  • removeegress: remove white listed accounts;

example commands:

echo "=== deploy eosio.erc2o contract & register bridge ==="
./cleos set code eosio.erc2o ~/workspaces/evm-bridge-contracts/erc20.wasm
./cleos set abi eosio.erc2o ~/workspaces/evm-bridge-contracts/erc20.abi
./cleos push action eosio.evm bridgereg '["eosio.erc2o","eosio.erc2o","0.0100 EOS"]' -p eosio.erc2o -p eosio.evm@owner
./cleos transfer a123 eosio.evm "100.0000 EOS" "eosio.erc2o"
./cleos set account permission eosio.erc2o active --add-code

echo "=== link USDT EVM bridge (usdt <==> 0x4ea3b729669bf6c34f7b80e5d6c17db71f89f21f) ==="
./cleos push action eosio.erc2o upgrade '[]' -p eosio.erc2o

./cleos push action eosio.erc2o regtoken '["usdt","EVM USDT Token","WUSDT","0.0100 USDT","0.0100 EOS",6]' -p eosio.erc2o

echo "=== the USDT-ERC20 contract should be 3a13a4653761299d8b9d0d5dcac100d0c961938b ==="

echo "=== transfer USDT (EOS->EVM) ==="
./cleos get currency balance usdt usdt
./cleos transfer usdt eosio.erc2o "1000.0000 USDT" "0x2787b98fc4e731d0456b3941f0b3fe2e01439961" -c usdt
./cleos get currency balance usdt usdt

echo "=== call bridge Transfer (EVM 0x278...->EOS a123) 12 USDT to account ==="
python3 ./send_data_via_cleos.py 0x2787B98fC4e731d0456b3941f0B3fe2e01439961 0x3A13A4653761299D8b9D0D5DCaC100D0c961938B 10000000000000000 73761828000000000000000000000000bbbbbbbbbbbbbbbbbbbbbbbb30443000000000000000000000000000000000000000000000000000000000000000000000b71b000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000f6b6179616e6b6179616e6b6179616e0000000000000000000000000000000000 3

echo "=== a123 now should have some USDT ==="
./cleos get currency balance usdt a123

solidity_contracts/erc20/contract.sol Show resolved Hide resolved
antelope_contracts/contracts/erc20/src/erc20.cpp Outdated Show resolved Hide resolved
antelope_contracts/contracts/erc20/src/erc20.cpp Outdated Show resolved Hide resolved
@arhag
Copy link
Member

arhag commented Aug 30, 2023

Make sure tests work with other token symbol names other than USDT (and also other precisions).

Copy link
Member

@arhag arhag left a comment

Choose a reason for hiding this comment

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

Also needs more tests with different symbol names and precisions (including greater precision for ERC20 than native token). As well as testing the various limits on amounts that are being enforced in the code.

antelope_contracts/contracts/erc20/include/erc20/erc20.hpp Outdated Show resolved Hide resolved
antelope_contracts/contracts/erc20/include/erc20/erc20.hpp Outdated Show resolved Hide resolved
solidity_contracts/erc20/proxy.sol Show resolved Hide resolved
antelope_contracts/contracts/erc20/include/erc20/erc20.hpp Outdated Show resolved Hide resolved
antelope_contracts/contracts/erc20/src/erc20.cpp Outdated Show resolved Hide resolved
antelope_contracts/contracts/erc20/src/erc20.cpp Outdated Show resolved Hide resolved
antelope_contracts/contracts/erc20/src/erc20.cpp Outdated Show resolved Hide resolved
antelope_contracts/contracts/erc20/src/erc20.cpp Outdated Show resolved Hide resolved
antelope_contracts/contracts/erc20/src/erc20.cpp Outdated Show resolved Hide resolved
antelope_contracts/contracts/erc20/src/erc20.cpp Outdated Show resolved Hide resolved
@arhag
Copy link
Member

arhag commented Sep 1, 2023

Also:

@arhag arhag linked an issue Sep 1, 2023 that may be closed by this pull request
@taokayan
Copy link
Contributor Author

taokayan commented Sep 1, 2023

Also:

Done

Copy link
Member

@arhag arhag left a comment

Choose a reason for hiding this comment

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

Unit tests are still light and even those need to be fixed. See my comment from #5 (review). The only issue is can you do any of these tests without bringing in the actual EOS EVM Contract. If so, that's more of an integration test which is tracked by #12.

antelope_contracts/contracts/erc20/src/erc20.cpp Outdated Show resolved Hide resolved
antelope_contracts/contracts/erc20/include/erc20/erc20.hpp Outdated Show resolved Hide resolved
antelope_contracts/contracts/erc20/src/erc20.cpp Outdated Show resolved Hide resolved
antelope_contracts/contracts/erc20/src/erc20.cpp Outdated Show resolved Hide resolved
@taokayan taokayan requested a review from arhag September 4, 2023 03:33
Copy link
Contributor

@yarkinwho yarkinwho left a comment

Choose a reason for hiding this comment

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

Need to call bridgereg() somewhere

and record the receiver in the table. receiver should be part of the unique key as well.

Copy link
Contributor

@yarkinwho yarkinwho left a comment

Choose a reason for hiding this comment

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

Sol contracts needs some modification.

solidity_contracts/erc20/contract.sol Show resolved Hide resolved
solidity_contracts/erc20/contract.sol Show resolved Hide resolved
@taokayan taokayan requested a review from arhag September 4, 2023 05:42
@taokayan taokayan merged commit 287a2a4 into main Sep 5, 2023
4 checks passed
@taokayan taokayan deleted the kayan_erc20 branch September 5, 2023 03:20
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