Skip to content

Commit

Permalink
feat: implement escrow contract in solidity for zksync (#171)
Browse files Browse the repository at this point in the history
* feat: move ethereum submodules

* refactor: contracts/solidity to contracts/ethereum

* refactor: contracts/cairo to contracts/starknet

* feat(wip): zksync escrow contract

* fet(wip): compile+deploy contract

* feat: yarn compile + yarn deploy working for Escrow.sol

* feat: zksync make targets for clean, build, deploy

* feat: Escrow.sol is ownable, upgradeable, pausable. Bugs with ownable

* feat(wip): make escrow.sol UUPS Proxy upgradeable

* fix: make deps

* remove: upgradeable from escrow.sol, will be implemented in a later commit

* feat: set_order(Order) on escrow.sol

* feat: add: getters, setters, pause, unpause

* feat: untested l2 handler claim_payment

* fix: removed unused var from l2 handler

* feat(wip): claimPaymentZKSync + refactor variables

* feat: chainID on TransferInfo Struct

* feat: claimPaymentZKSync advances + deploy_and_connect_zksync make target script

* feat: claimPaymentZKSync advances, only missing "byes data" for msg to L2

* feat: msg to L2, UNTESTED

* feat: add era-contracts in PaymentRegistry lib

* fix: .sol to version compatible with era-contracts

* feat(wip): call to L2, having trouble building calldata

* refactor: separate claimPaymentZKSync from claimPayment(starknet)

* fix: adapted previous test to new yab.init() and yab.transfer() formats

* fix: ZKSync messaging (mailbox) variable name

* feat: make zksync-deploy + make zksync-deploy-and-connect

* feat: zksync init after deploy

* fix: sending eth funds to escrow

* test(wip): yarn test init (trying to refactor to forge test)

* chore: forge init

* forge install: forge-std

v1.7.6

* remove: zksync using forge, zkforge is not ready for usage

* test: yarn hardhat test working

* test: run them on local dockerized blockchains (L1 and L2)

* refactor: escrow.sol set_order no longer recieves amount, + fix event set order

* test: initial setOrder test

* test(wip): using L1 for more tests

* test(wip): deploying PaymentRegistry in local blockchain for zksync tests

* fix: add packageManager in package.json + auto-generated file in .gitignore

* test: separated integration test from unit tests

* test: ZKSync, Pausable and Ownable unit tests

* feat: add zksync-test to make test

* fix: appropriate name for sol tests (naame.t.sol)

* test: fix old tests to new version of PaymentRegistry

* test: refactor test and file names for better understanding and simpler adding new tests

* test: started unit tests of PaymentRegistry for ZKSync cases

* remove: old generated files from upgradeable ZKSync

* test: PaymentRegistry unit tests for ZKSync

* test: add mock calls to ZKSync mailbox

* test: add PaymentRegistry ACL tests for ZKsync

* test: add TransferNotFound for wrong chain and wrong tx id

* remove: 'amount' parameter on PaymentRegistry.transfer

* feat: add target make zksync-connect

* feat: L1 -> L2 message arrives. new bug: from_address != L1 contract

* feat: correct selector for L1-L2

* feat(wip): apply mask for L1->L2

* fix: update .gitignore to help branch-switching , temporary until PR#170 is resolved

* test: added test for contract variables setter functions

* test: add pending order test

* test: PaymentRegistry setters ACL

* test: set and get for PaymentRegistry setter functions

* test: add assert in escrow test to make an extra check transfer has transferred funds

* refactor: removed unnecesarry comments

* refactor: removed unnecesarry vars from escrow (native_token_eth_in_zksync, mm_ethereum_wallet)

* feat: new make targets to deploy: ETH+ZKSYNC or ETH+SN

* fix: make deploys for eth and zksync

* feat: add display info after deploy-eth-and-zks

* docs: added some details to zksync/readme.md

* feat: integration test deploys eth in local, using same deploy script as non-tests

* fix: tests ZKSync were failing to old escrow.init() signature

* fix: changed ZKSyncMailbox to appropriate ZKSyncDiamondProxy

* test: removed tests of removed functions

* fix: removed wrong todo comments

* feat: deploy ZKS Escrow on devnet

* feat: do setOrder on integration test

* feat: do transfer in integration test

* feat(wip): do claimPayment on integration test + refactor .env vars usage for tests

* test: detail advances on integration test

* perf: gas usage optimization on PaymentRegistry

* fix: env.example ZKSYNC_DIAMOND_PROXY_ADDRESS

* fix(wip): new diamondProxy address for integration tests. cant execute a function but there is a contract

* test: add --gas-report to eth-test + cast call to verify address is a contract in set_order.sh

* Fix: env vars from merge conflict

* fix: add export ZKSYNC_DIAMOND_PROXY_ADDRESS in CI

* fix: change file names in CI

* fix: various fixes for CI, made previously but stepped over in merge

* fix: env var names in CI

* fix: another .env var in CI

* fix: data type in transfer in CI

* fix: data type in claimPayment CI

* refactor: \n at EOF + STARKNET_CHAIN_ID variable name

* refactor: style + uncommented existing code

* refactor: Update contracts/ethereum/.env.example

Co-authored-by: Julian Arce <[email protected]>

* feat: add new make target with eth-test-gas-report

* fix: rolled back eth/.env.test file

* remove: unnecesarry comment

* remove: wrong comment

* refactor: add \n at EOF

* fix: print with colors using printf in SN/deploy.sh

* fix: print with printf in SN/deploy.sh

* fix: make sn-deploy-and-connect target

* refactor: make targets to && \ format, removed .ONESHELL format

* fix: wrongly named "ETH_RPC_URL" and "ETH_PRIVATE_KEY" env variables

* refactor: TransferInfo setting in transfers[index] rolled back to previous version

* refactor: PRIVATE_ADDRESS var changed to PRIVATE_KEY

* refactor: rolled back SKIP_VERIFY variable in eth/deploy.sh

* fix: ${{vars.ETHEREUM_RPC}} in CI to access env var

* refactor: style \n at EOF

* remove: worngfully pushed comment

* docs: update zksync .env.example

* fix: add new line

---------

Co-authored-by: Julian Arce <[email protected]>
  • Loading branch information
uri-99 and JuArce authored Mar 22, 2024
1 parent 40dc365 commit 4b84383
Show file tree
Hide file tree
Showing 41 changed files with 5,393 additions and 173 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ jobs:
cd starknet-messaging-dev/solidity
cp anvil.env .env
source .env
forge script script/LocalTesting.s.sol:LocalSetup --broadcast --rpc-url ${ETH_RPC_URL}
forge script script/LocalTesting.s.sol:LocalSetup --broadcast --rpc-url ${{vars.ETHEREUM_RPC}}
# Run Katana
- name: Run Katana
Expand Down Expand Up @@ -157,15 +157,16 @@ jobs:
export ETHEREUM_PRIVATE_KEY=${{vars.ETHEREUM_PRIVATE_KEY}}
export STARKNET_MESSAGING_ADDRESS=${{vars.STARKNET_MESSAGING_ADDRESS}}
export MM_ETHEREUM_WALLET_ADDRESS=${{vars.MM_ETHEREUM_WALLET_ADDRESS}}
export ZKSYNC_DIAMOND_PROXY_ADDRESS=${{vars.ZKSYNC_DIAMOND_PROXY_ADDRESS}}
export SKIP_VERIFY=true
. ./contracts/ethereum/deploy.sh
export STARKNET_RPC=${{vars.STARKNET_RPC}}
source ./contracts/starknet/.env.test
. ./contracts/starknet/deploy.sh
. ./contracts/ethereum/set_escrow.sh
. ./contracts/ethereum/set_claim_payment_selector.sh
. ./contracts/ethereum/set_starknet_escrow.sh
. ./contracts/ethereum/set_starknet_claim_payment_selector.sh
export AMOUNT=1000000000000000000
. ./.github/workflows/scripts/set_order.sh
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/scripts/claim_payment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

. contracts/utils/colors.sh #for ANSI colors

echo -e "${GREEN}\n=> [SN] Making withdraw${COLOR_RESET}" # 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 -> 642829559307850963015472508762062935916233390536
DESTINATION_ADDRESS=0x70997970C51812dc3A010C7d01b50e0d17dc79C8

echo -e "${GREEN}\n=> [SN] Making ClaimPayment${COLOR_RESET}" # 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 -> 642829559307850963015472508762062935916233390536

ESCROW_INITIAL_BALANCE=$(starkli balance $ESCROW_CONTRACT_ADDRESS)
MM_INITIAL_BALANCE=$(starkli balance $MM_STARKNET_WALLET_ADDRESS)
Expand All @@ -12,7 +14,7 @@ echo "Initial MM balance: $MM_INITIAL_BALANCE"
echo "Withdrawing $AMOUNT"
cast send --rpc-url $ETHEREUM_RPC --private-key $ETHEREUM_PRIVATE_KEY \
$PAYMENT_REGISTRY_PROXY_ADDRESS "claimPayment(uint256, uint256, uint256)" \
"0" "642829559307850963015472508762062935916233390536" "$AMOUNT" \
"0" $DESTINATION_ADDRESS "$AMOUNT" \
--value $AMOUNT >> /dev/null

sleep 15
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/scripts/set_order.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
FEE=25000000000000
APPROVE_AMOUNT=$((${AMOUNT}+${FEE}))

echo -e "${GREEN}\n=> [SN] Making transfer to Escrow${COLOR_RESET}"
echo -e "${GREEN}\n=> [SN] Making SetOrder on Escrow${COLOR_RESET}"

starkli invoke \
$NATIVE_TOKEN_ETH_STARKNET approve $ESCROW_CONTRACT_ADDRESS u256:$APPROVE_AMOUNT \
/ $ESCROW_CONTRACT_ADDRESS set_order 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 \
u256:$AMOUNT u256:$FEE --private-key $STARKNET_PRIVATE_KEY --account $STARKNET_ACCOUNT

6 changes: 3 additions & 3 deletions .github/workflows/scripts/transfer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
. contracts/utils/colors.sh #for ANSI colors

DESTINATION_ADDRESS=0x70997970C51812dc3A010C7d01b50e0d17dc79C8
DESTINATION_ADDRESS_UINT=642829559307850963015472508762062935916233390536
STARKNET_CHAIN_ID="0"

echo -e "${GREEN}\n=> [SN] Making transfer to Destination account${COLOR_RESET}" # 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 -> 642829559307850963015472508762062935916233390536

Expand All @@ -14,8 +14,8 @@ echo "Initial Destination balance: $DESTINATION_INITIAL_BALANCE"

echo "Transferring $AMOUNT to $DESTINATION_ADDRESS"
cast send --rpc-url $ETHEREUM_RPC --private-key $ETHEREUM_PRIVATE_KEY \
$PAYMENT_REGISTRY_PROXY_ADDRESS "transfer(uint256, uint256, uint256)" \
"0" "$DESTINATION_ADDRESS_UINT" "$AMOUNT" \
$PAYMENT_REGISTRY_PROXY_ADDRESS "transfer(uint256, uint256, uint8)" \
"0" $DESTINATION_ADDRESS $STARKNET_CHAIN_ID \
--value $AMOUNT >> /dev/null

MM_FINAL_BALANCE=$(cast balance --rpc-url $ETHEREUM_RPC --ether $MM_ETHEREUM_WALLET_ADDRESS)
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.idea
.env
.DS_Store
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@
[submodule "contracts/ethereum/lib/openzeppelin-contracts-upgradeable"]
path = contracts/ethereum/lib/openzeppelin-contracts-upgradeable
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
[submodule "contracts/ethereum/lib/era-contracts"]
path = contracts/ethereum/lib/era-contracts
url = https://github.com/matter-labs/era-contracts
[submodule "contracts/zksync_forge/lib/forge-std"]
path = contracts/zksync_forge/lib/forge-std
url = https://github.com/foundry-rs/forge-std
120 changes: 99 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
deps: install-scarb install-starkli install-starknet-foundry install-ethereum-foundry
### SETUP ###

deps: install-scarb install-starkli install-starknet-foundry install-ethereum-foundry install-zksync

install-scarb:
curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | sh -s -- -v 2.4.1
Expand All @@ -13,6 +15,12 @@ install-starknet-foundry:
install-ethereum-foundry:
curl -L https://foundry.paradigm.xyz | bash && foundryup

install-zksync:
cd ./contracts/zksync/ && yarn install


### ETHEREUM ###

ethereum-clean:
@cd ./contracts/ethereum/ && forge clean

Expand All @@ -22,17 +30,23 @@ ethereum-build: ethereum-clean
ethereum-test: ethereum-clean
@cd ./contracts/ethereum/ && forge test

ethereum-test-gas-report: ethereum-clean
@cd ./contracts/ethereum/ && forge test --gas-report

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

ethereum-upgrade: ethereum-build
@. ./contracts/ethereum/.env && . ./contracts/ethereum/upgrade.sh

ethereum-set-escrow:
@. ./contracts/ethereum/.env && . ./contracts/ethereum/set_escrow.sh
@. ./contracts/ethereum/.env && . ./contracts/ethereum/set_starknet_escrow.sh

ethereum-set-claim-payment-selector:
@. ./contracts/ethereum/.env && . ./contracts/starknet/.env && . ./contracts/ethereum/set_claim_payment_selector.sh
@. ./contracts/ethereum/.env && . ./contracts/starknet/.env && . ./contracts/ethereum/set_starknet_claim_payment_selector.sh


### STARKNET ###

starknet-clean:
@cd ./contracts/starknet/ && scarb clean
Expand All @@ -46,6 +60,12 @@ starknet-test: starknet-clean
starknet-deploy: starknet-build
@. ./contracts/starknet/.env && . ./contracts/starknet/deploy.sh

starknet-deploy-and-connect: starknet-build
@. ./contracts/ethereum/.env && . ./contracts/starknet/.env && \
. ./contracts/starknet/deploy.sh && \
. ./contracts/ethereum/set_starknet_escrow.sh && \
. ./contracts/ethereum/set_starknet_claim_payment_selector.sh

starknet-upgrade: starknet-build
@. ./contracts/starknet/.env && . ./contracts/starknet/upgrade.sh

Expand All @@ -55,24 +75,82 @@ starknet-pause:
starknet-unpause:
@. ./contracts/starknet/.env && ./contracts/starknet/change_pause_state.sh unpause

test:
make starknet-test
make ethereum-test

.ONESHELL:
starknet-deploy-and-connect: starknet-build
@. ./contracts/ethereum/.env && . ./contracts/starknet/.env
@. ./contracts/starknet/deploy.sh
@. ./contracts/ethereum/set_escrow.sh
@. ./contracts/ethereum/set_claim_payment_selector.sh
### ZKSYNC ###

zksync-clean:
@cd ./contracts/zksync/ && yarn clean

zksync-build: zksync-clean
@cd ./contracts/zksync/ && yarn compile

zksync-deploy: zksync-build
@. ./contracts/zksync/.env && . ./contracts/zksync/deploy.sh

zksync-connect:
@. ./contracts/ethereum/.env && . ./contracts/zksync/.env && \
. ./contracts/ethereum/set_zksync_escrow.sh

zksync-deploy-and-connect: zksync-build
@. ./contracts/ethereum/.env && . ./contracts/zksync/.env && \
. ./contracts/zksync/deploy.sh && \
. ./contracts/ethereum/set_zksync_escrow.sh


zksync-test: zksync-build
@cd ./contracts/zksync/ && yarn test

#wip:
zksync-test-integration:
@make ethereum-build && make zksync-build && \
. ./contracts/ethereum/test/.env.test && . ./contracts/zksync/test/.env.test && \
. ./contracts/ethereum/deploy.sh && \
. ./contracts/zksync/deploy.sh && \
. ./contracts/ethereum/set_zksync_escrow.sh && \
. ./contracts/zksync/test/set_order.sh && \
. ./contracts/zksync/test/transfer.sh && \
. ./contracts/zksync/test/claim_payment.sh

# zksync-upgrade: WIP


### MULTI ###

ethereum-and-zksync-deploy:
@. ./contracts/ethereum/.env && \
. ./contracts/zksync/.env && \
make ethereum-build && \
make zksync-build && \
. ./contracts/ethereum/deploy.sh && \
. ./contracts/zksync/deploy.sh && \
. ./contracts/ethereum/set_zksync_escrow.sh && \
. ./contracts/utils/display_info.sh

ethereum-and-starknet-deploy:
@. ./contracts/ethereum/.env && \
. ./contracts/starknet/.env && \
make ethereum-build && \
make starknet-build && \
. ./contracts/ethereum/deploy.sh && \
. ./contracts/starknet/deploy.sh && \
. ./contracts/ethereum/set_starknet_escrow.sh && \
. ./contracts/ethereum/set_starknet_claim_payment_selector.sh && \
. ./contracts/utils/display_info.sh

.ONESHELL:
deploy-all:
@. ./contracts/ethereum/.env && . ./contracts/starknet/.env
@make ethereum-build
@. ./contracts/ethereum/deploy.sh
@make starknet-build
@. ./contracts/starknet/deploy.sh
@. ./contracts/ethereum/set_escrow.sh
@. ./contracts/ethereum/set_claim_payment_selector.sh
@. ./contracts/utils/display_info.sh
@. ./contracts/ethereum/.env && . ./contracts/starknet/.env && . ./contracts/zksync/.env && \
make ethereum-build && \
. ./contracts/ethereum/deploy.sh && \
make starknet-build && \
. ./contracts/starknet/deploy.sh && \
. ./contracts/ethereum/set_starknet_escrow.sh && \
. ./contracts/ethereum/set_starknet_claim_payment_selector.sh && \
. ./contracts/utils/display_info.sh && \
make zksync-build && \
. ./contracts/zksync/deploy.sh && \
. ./contracts/ethereum/set_zksync_escrow.sh

test:
make starknet-test
make ethereum-test
make zksync-test
2 changes: 2 additions & 0 deletions contracts/ethereum/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ ETHERSCAN_API_KEY=<etherscan_api_key> #as given by etherscan
ETHEREUM_PRIVATE_KEY=<ethereum_private_key> #in hexa with the 0x prefix
STARKNET_MESSAGING_ADDRESS=<0xde29d060D45901Fb19ED6C6e959EB22d8626708e|0xE2Bb56ee936fd6433DC0F6e7e3b8365C906AA057|0xc662c410C0ECf747543f5bA90660f6ABeBD9C8c4> # Goerli | Sepolia | Mainnet
MM_ETHEREUM_WALLET_ADDRESS=<MarketMaker_ethereum_contract_address> #in hexa with the 0x prefix

ZKSYNC_DIAMOND_PROXY_ADDRESS=<0x9A6DE0f62Aa270A8bCB1e2610078650D539B1Ef9> # Sepolia
7 changes: 6 additions & 1 deletion contracts/ethereum/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ cd contracts/ethereum

printf "${GREEN}\n=> [ETH] Deploying ERC1967Proxy & PaymentRegistry ${COLOR_RESET}\n"


export ETHEREUM_PRIVATE_KEY=$ETHEREUM_PRIVATE_KEY

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

Expand All @@ -26,8 +29,10 @@ fi
printf "${GREEN}\n=> [ETH] Deployed Proxy address: $PAYMENT_REGISTRY_PROXY_ADDRESS ${COLOR_RESET}\n"
printf "${GREEN}\n=> [ETH] Deployed PaymentRegistry address: $PAYMENT_REGISTRY_ADDRESS ${COLOR_RESET}\n"

echo "\nIf you now wish to deploy SN Escrow, you will need to run the following commands:"
echo "\nIf you now wish to deploy an Escrow, you will need to run the following commands:"
echo "export PAYMENT_REGISTRY_PROXY_ADDRESS=$PAYMENT_REGISTRY_PROXY_ADDRESS"
echo "make starknet-deploy"
echo "OR"
echo "make zksync-deploy"

cd ../.. #to reset working directory
5 changes: 4 additions & 1 deletion contracts/ethereum/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ src = "src"
out = "out"
libs = ["lib"]
gas_reports = ["*"]
remappings = ["@openzeppelin/contracts-upgradeable=lib/openzeppelin-contracts-upgradeable/contracts"]
remappings = [
"@openzeppelin/contracts-upgradeable=lib/openzeppelin-contracts-upgradeable/contracts",
"@matterlabs/interfaces=lib/era-contracts/l1-contracts/contracts/zksync/interfaces",
]

[rpc_endpoints]
goerli = "${GOERLI_RPC_URL}"
Expand Down
1 change: 1 addition & 0 deletions contracts/ethereum/lib/era-contracts
Submodule era-contracts added at 2dd389
5 changes: 3 additions & 2 deletions contracts/ethereum/script/Deploy.s.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.21;
pragma solidity ^0.8.20;

import {Script} from "forge-std/Script.sol";
import {PaymentRegistry} from "../src/PaymentRegistry.sol";
Expand All @@ -14,10 +14,11 @@ contract Deploy is Script {
uint256 snEscrowAddress = 0x0; // this value is set in a call to the smart contract, once deployed
uint256 snClaimPaymentSelector = 0x0; // this value is set in a call to the smart contract, once deployed
address marketMaker = vm.envAddress("MM_ETHEREUM_WALLET_ADDRESS");
address ZKSYNC_DIAMOND_PROXY_ADDRESS = vm.envAddress("ZKSYNC_DIAMOND_PROXY_ADDRESS");

PaymentRegistry yab = new PaymentRegistry();
ERC1967Proxy proxy = new ERC1967Proxy(address(yab), "");
PaymentRegistry(address(proxy)).initialize(snMessagingAddress, snEscrowAddress, snClaimPaymentSelector, marketMaker);
PaymentRegistry(address(proxy)).initialize(snMessagingAddress, snEscrowAddress, snClaimPaymentSelector, marketMaker, ZKSYNC_DIAMOND_PROXY_ADDRESS);

vm.stopBroadcast();

Expand Down
2 changes: 1 addition & 1 deletion contracts/ethereum/script/Upgrade.s.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;
pragma solidity ^0.8.20;

import {console} from "../lib/forge-std/src/console.sol";
import {Script} from "forge-std/Script.sol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ echo "Smart contract being modified:" $PAYMENT_REGISTRY_PROXY_ADDRESS
CLAIM_PAYMENT_SELECTOR=$(starkli selector $CLAIM_PAYMENT_NAME)
echo "New ClaimPayment Selector: ${CLAIM_PAYMENT_SELECTOR}"

cast send --rpc-url $ETHEREUM_RPC --private-key $ETHEREUM_PRIVATE_KEY $PAYMENT_REGISTRY_PROXY_ADDRESS "setEscrowClaimPaymentSelector(uint256)" "${CLAIM_PAYMENT_SELECTOR}" | grep "transactionHash"
cast send --rpc-url $ETHEREUM_RPC --private-key $ETHEREUM_PRIVATE_KEY $PAYMENT_REGISTRY_PROXY_ADDRESS "setStarknetClaimPaymentSelector(uint256)" "${CLAIM_PAYMENT_SELECTOR}" | grep "transactionHash"
echo "Done setting ClaimPayment selector"
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ printf "${GREEN}\n=> [ETH] Setting Starknet Escrow Address on ETH Smart Contract
echo "Smart contract being modified:" $PAYMENT_REGISTRY_PROXY_ADDRESS
echo "New Escrow address:" $ESCROW_CONTRACT_ADDRESS

cast send --rpc-url $ETHEREUM_RPC --private-key $ETHEREUM_PRIVATE_KEY $PAYMENT_REGISTRY_PROXY_ADDRESS "setEscrowAddress(uint256)" $ESCROW_CONTRACT_ADDRESS | grep "transactionHash"
cast send --rpc-url $ETHEREUM_RPC --private-key $ETHEREUM_PRIVATE_KEY $PAYMENT_REGISTRY_PROXY_ADDRESS "setStarknetEscrowAddress(uint256)" $ESCROW_CONTRACT_ADDRESS | grep "transactionHash"
echo "Done setting escrow address"
29 changes: 29 additions & 0 deletions contracts/ethereum/set_zksync_escrow.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash
. contracts/utils/colors.sh #for ANSI colors

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


printf "${GREEN}\n=> [ETH] Setting ZKSync Escrow Address on ETH Smart Contract${COLOR_RESET}\n"

echo "Smart contract being modified:" $PAYMENT_REGISTRY_PROXY_ADDRESS
echo "New ZKSync Escrow address:" $ZKSYNC_ESCROW_CONTRACT_ADDRESS

cast send --rpc-url $ETHEREUM_RPC --private-key $ETHEREUM_PRIVATE_KEY $PAYMENT_REGISTRY_PROXY_ADDRESS "setZKSyncEscrowAddress(address)" $ZKSYNC_ESCROW_CONTRACT_ADDRESS | grep "transactionHash "
echo "Done setting escrow address"
Loading

0 comments on commit 4b84383

Please sign in to comment.