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

feat: bridge ERC20 tokens #234

Open
wants to merge 49 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
6bada98
feat(wip): adding support of ERC20 tokens.
uri-99 Apr 12, 2024
2e1d6d5
feat: function transferERC20() so MM can transfer an ERC20
uri-99 Apr 15, 2024
cca48b9
feat: claimPaymentZKSyncERC20 in PaymentRegistry
uri-99 Apr 15, 2024
54f7ebb
feat: claim_payment_erc20 in zksync
uri-99 Apr 15, 2024
1c3eb37
feat: set_order_erc20 in ZKSync escrow
uri-99 Apr 15, 2024
075960d
feat: erc20 for L1 and L2
uri-99 Apr 16, 2024
ec2f529
feat: L1 erc20 compatibility
uri-99 Apr 16, 2024
85ec54a
test: add new init values to tests
uri-99 Apr 16, 2024
90179d5
feat: ZKSync escrow erc20 compatibility
uri-99 Apr 16, 2024
7b0d5a0
refactor: comments for tidyness
uri-99 Apr 16, 2024
7a7ace4
refactor: ER20Order -> OrderERC20
uri-99 Apr 17, 2024
e4f962b
feat: add get_order_erc20 in ZKSync Escrow
uri-99 Apr 17, 2024
9b42c78
feat: set_order_erc20 in SN Escrow
uri-99 Apr 17, 2024
5ca92d1
feat: add fee to claimPaymentERC20 event
uri-99 Apr 17, 2024
d234e69
feat: claimPaymentERC20 in SN Escrow
uri-99 Apr 17, 2024
911afdf
fix: small bugs
uri-99 Apr 17, 2024
a1b5ca7
feat: deploy SN erc20
uri-99 Apr 17, 2024
d2ca63d
feat: add claimPaymentStarknetERC20 in PaymentRegistry
uri-99 Apr 18, 2024
9997744
fix: adapt PaymentRegistry unit tests
uri-99 Apr 18, 2024
d9ea794
feat: split 'amount' into 'amount_l1' and 'amount_l2' in ZKSync escrow
uri-99 Apr 18, 2024
741e911
feat: split 'amount' to 'amount_l2' + 'amount_l1' in SN escrow.cairo
uri-99 Apr 18, 2024
1842d4a
refactor: now make deploy-all builds everything before deploying
uri-99 Apr 18, 2024
ac245e9
refactor: escrow.cairo revert messages
uri-99 Apr 18, 2024
9840942
test: start ZKSync unit tests
uri-99 Apr 18, 2024
6a9251d
refactor: migrating ZKSync erc20 unit tests to its own ts file
uri-99 Apr 18, 2024
1eb2d52
feat: make zksync-test now runs the new test file as well
uri-99 Apr 18, 2024
7a8f372
test(wip): zksync unit tests
uri-99 Apr 18, 2024
fd0a786
test: finished zksync unit tests
uri-99 Apr 19, 2024
8ef3b03
test: added new 2 unit tests on non-erc20 unit tests
uri-99 Apr 19, 2024
9ad5e6e
fix: erc20_l2 name in some ZKSync unit tests
uri-99 Apr 19, 2024
ec8d88f
test: add first SN unit tests
uri-99 Apr 19, 2024
f5c3eb7
Merge commit '1900604ea2cdf727deb458efaa52bef49dc17c6e' into 231-feat…
uri-99 Apr 19, 2024
cae9223
feat: un-hardcode cairo erc20 params
uri-99 Apr 19, 2024
fee6905
feat: add cairo unit tests to lib.cairo
uri-99 Apr 19, 2024
3e1b57c
test: fix setup_with_erc20 function name
uri-99 Apr 19, 2024
6aea4b9
test: fix setup_with_erc20 return params
uri-99 Apr 19, 2024
36f6684
test: small fixes on cairo test
uri-99 Apr 19, 2024
18a26f9
fix: add new erc20 token allowance to escrow
uri-99 Apr 19, 2024
3561521
fix: avoid declaring twice an erc20 class hash
uri-99 Apr 19, 2024
b06978c
fix: deploy_erc20_2 name_2 parameter
uri-99 Apr 19, 2024
fbdb421
fix: add erc20 selectors to SN integration test
uri-99 Apr 19, 2024
a650373
fix: allowance for cairo escrow in test
uri-99 Apr 19, 2024
12f8a1d
test: added SN erc20 unit tests
uri-99 Apr 19, 2024
32dcbea
test: more SN erc20 unit tests
uri-99 Apr 19, 2024
07fe547
fix: repeated test name
uri-99 Apr 19, 2024
f2531df
test: sn erc20 unit test: wrong recipient address
uri-99 Apr 19, 2024
0546c8f
fix: test_fail_claim_erc20_wrong_erc20 unit test
uri-99 Apr 19, 2024
7717374
fix: import L1_ERC20_ADDRESS_2 var
uri-99 Apr 19, 2024
b262ca6
refactor: add ModifiedStarknetClaimPaymentERC20Selector event in Paym…
uri-99 Apr 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,10 @@ jobs:
export ZKSYNC_CHAIN_ID=${{vars.ZKSYNC_CHAIN_ID}}
export STARKNET_CLAIM_PAYMENT_SELECTOR=${{vars.STARKNET_CLAIM_PAYMENT_SELECTOR}}
export STARKNET_CLAIM_PAYMENT_BATCH_SELECTOR=${{vars.STARKNET_CLAIM_PAYMENT_BATCH_SELECTOR}}
export STARKNET_CLAIM_PAYMENT_ERC20_SELECTOR=${{vars.STARKNET_CLAIM_PAYMENT_ERC20_SELECTOR}}
export ZKSYNC_CLAIM_PAYMENT_SELECTOR=${{vars.ZKSYNC_CLAIM_PAYMENT_SELECTOR}}
export ZKSYNC_CLAIM_PAYMENT_BATCH_SELECTOR=${{vars.ZKSYNC_CLAIM_PAYMENT_BATCH_SELECTOR}}
export ZKSYNC_CLAIM_PAYMENT_ERC20_SELECTOR=${{vars.ZKSYNC_CLAIM_PAYMENT_ERC20_SELECTOR}}
export SKIP_VERIFY=true
. ./contracts/ethereum/deploy.sh

Expand Down
20 changes: 15 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ ethereum-upgrade: ethereum-build
ethereum-set-escrow:
@. ./contracts/ethereum/.env && . ./contracts/ethereum/set_starknet_escrow.sh

ethereum-deploy-erc20: ethereum-build
@. ./contracts/ethereum/.env && . ./contracts/ethereum/deploy_erc20.sh


### STARKNET ###

Expand Down Expand Up @@ -75,6 +78,9 @@ starknet-pause:
starknet-unpause:
@. ./contracts/starknet/.env && . ./contracts/starknet/scripts/change_pause_state.sh unpause

starknet-deploy-erc20: starknet-build
@. ./contracts/starknet/.env && . ./contracts/starknet/scripts/deploy_erc20.sh


### ZKSYNC ###

Expand Down Expand Up @@ -113,6 +119,10 @@ zksync-test-integration:
. ./contracts/zksync/test/transfer.sh && \
. ./contracts/zksync/test/claim_payment.sh

zksync-deploy-erc20:
@make zksync-build && \
. ./contracts/zksync/deploy_erc20.sh

# zksync-upgrade: WIP


Expand Down Expand Up @@ -141,15 +151,15 @@ ethereum-and-starknet-deploy:
deploy-all:
@. ./contracts/ethereum/.env && . ./contracts/starknet/.env && . ./contracts/zksync/.env && \
make ethereum-build && \
. ./contracts/ethereum/deploy.sh && \
make starknet-build && \
make zksync-build && \
. ./contracts/ethereum/deploy.sh && \
. ./contracts/starknet/scripts/deploy.sh && \
. ./contracts/ethereum/set_starknet_escrow.sh && \
. ./contracts/utils/display_info.sh && \
make zksync-build && \
. ./contracts/zksync/deploy.sh && \
. ./contracts/ethereum/set_zksync_escrow.sh

. ./contracts/ethereum/set_zksync_escrow.sh && \
. ./contracts/utils/display_info.sh

test:
make starknet-test
make ethereum-test
Expand Down
2 changes: 2 additions & 0 deletions contracts/ethereum/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ ZKSYNC_DIAMOND_PROXY_ADDRESS=<0x9A6DE0f62Aa270A8bCB1e2610078650D539B1Ef9> # Sepo

STARKNET_CLAIM_PAYMENT_SELECTOR=<0x03636c566f6409560d55d5f6d1eb4ee163b096b4698c503e69e210be79de2afa> #hex value of starknet's claim_payment selector
STARKNET_CLAIM_PAYMENT_BATCH_SELECTOR=<0x0354a01e49fe07e43306a97ed84dbd5de8238c7d8ff616caa3444630cfc559e6> #hex value of starknet's claim_payment_batch selector
STARKNET_CLAIM_PAYMENT_ERC20_SELECTOR=<0x0091ec2842317cd03601c3f46ee8ebc9b1dc6cdbc96cb7b0873cc6360538d754> #hex value of starknet's claim_payment_erc20 selector
ZKSYNC_CLAIM_PAYMENT_SELECTOR=<0xa5168739> #hex value of ZKSync's claim_payment selctor
ZKSYNC_CLAIM_PAYMENT_BATCH_SELECTOR=<0x156be1ae> #hex value of ZKSync's claim_payment_batch selctor
ZKSYNC_CLAIM_PAYMENT_ERC20_SELECTOR=<0xb9738dd6> #hex value of ZKSync's claim_payment_erc20 selctor

STARKNET_CHAIN_ID=<0x534e5f5345504f4c4941|0x534e5f4d41494e> #Sepolia | Mainnet
ZKSYNC_CHAIN_ID=<300|324> # Sepolia | Mainnet
3 changes: 3 additions & 0 deletions contracts/ethereum/.env.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ MM_ETHEREUM_ADDRESS=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
SKIP_VERIFY=true
STARKNET_CLAIM_PAYMENT_SELECTOR=0x03636c566f6409560d55d5f6d1eb4ee163b096b4698c503e69e210be79de2afa
STARKNET_CLAIM_PAYMENT_BATCH_SELECTOR=0x0354a01e49fe07e43306a97ed84dbd5de8238c7d8ff616caa3444630cfc559e6
STARKNET_CLAIM_PAYMENT_ERC20_SELECTOR=0x0091ec2842317cd03601c3f46ee8ebc9b1dc6cdbc96cb7b0873cc6360538d754
ZKSYNC_CLAIM_PAYMENT_SELECTOR=0xa5168739
ZKSYNC_CLAIM_PAYMENT_BATCH_SELECTOR=0x156be1ae
ZKSYNC_CLAIM_PAYMENT_ERC20_SELECTOR=0xb9738dd6

STARKNET_CHAIN_ID=0x534e5f5345504f4c4941
ZKSYNC_CHAIN_ID=300
25 changes: 25 additions & 0 deletions contracts/ethereum/deploy_erc20.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
. contracts/utils/colors.sh #for ANSI colors

cd contracts/ethereum

printf "${GREEN}\n=> [ETH] Deploying ERC20 ${COLOR_RESET}\n"


export ETHEREUM_PRIVATE_KEY=$ETHEREUM_PRIVATE_KEY

RESULT_LOG=$(forge script ./script/Deploy_ERC20.s.sol --rpc-url $ETHEREUM_RPC --broadcast ${SKIP_VERIFY:---verify})
# echo "$RESULT_LOG" #uncomment this line for debugging in detail

# Getting result addresses
ERC20_ADDRESS=$(echo "$RESULT_LOG" | grep -Eo '0: address ([^\n]+)' | awk '{print $NF}')

if [ -z "$ERC20_ADDRESS" ]; then
printf "\n${RED}ERROR:${COLOR_RESET}\n"
echo "ERC20_ADDRESS Variable is empty. Aborting execution.\n"
exit 1
fi

printf "${GREEN}\n=> [ETH] Deployed ERC20 address: $ERC20_ADDRESS ${COLOR_RESET}\n"

cd ../.. #to reset working directory
Loading
Loading