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

eth: update solc and abigen workflow #1626

Merged
merged 1 commit into from
May 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 1 addition & 1 deletion client/asset/eth/nodeclient_harness_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import (
"decred.org/dcrdex/dex/encode"
dexeth "decred.org/dcrdex/dex/networks/eth"
swapv0 "decred.org/dcrdex/dex/networks/eth/contracts/v0"
"decred.org/dcrdex/internal/eth/reentryattack"
"decred.org/dcrdex/dex/testing/eth/reentryattack"
"github.com/davecgh/go-spew/spew"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
Expand Down
15 changes: 8 additions & 7 deletions dex/networks/erc20/contracts/updatecontract.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ fi

VERSION=$1
PKG_NAME=v${VERSION}
SOLIDITY_FILE=./ERC20SwapV${VERSION}.sol
CONTRACT_NAME=ERC20Swap
SOLIDITY_FILE=./${CONTRACT_NAME}V${VERSION}.sol
TEST_TOKEN=./TestToken.sol
if [ ! -f ${SOLIDITY_FILE} ]
then
Expand All @@ -29,23 +30,23 @@ fi

mkdir temp

solc --bin-runtime --optimize ${SOLIDITY_FILE} -o ./temp/
BYTECODE=$(<./temp/ERC20Swap.bin-runtime)
solc --abi --bin --bin-runtime --overwrite --optimize ${SOLIDITY_FILE} -o ./temp/
BYTECODE=$(<./temp/${CONTRACT_NAME}.bin-runtime)

cat > "./${PKG_NAME}/BinRuntimeV${VERSION}.go" <<EOF
// Code generated - DO NOT EDIT.
// This file is a generated binding and any manual changes will be lost.

package ${PKG_NAME}

const ERC20SwapRuntimeBin = "${BYTECODE}"
const ${CONTRACT_NAME}RuntimeBin = "${BYTECODE}"
EOF

CONTRACT_FILE=./${PKG_NAME}/contract.go
abigen --sol ${SOLIDITY_FILE} --pkg ${PKG_NAME} --out ${CONTRACT_FILE}
abigen --abi ./temp/${CONTRACT_NAME}.abi --bin ./temp/${CONTRACT_NAME}.bin \
--pkg ${PKG_NAME} --type ${CONTRACT_NAME} --out ./${PKG_NAME}/contract.go

solc --bin --optimize ${SOLIDITY_FILE} -o ./temp
BYTECODE=$(<./temp/ERC20Swap.bin)
BYTECODE=$(<./temp/${CONTRACT_NAME}.bin)

solc --bin --optimize ${TEST_TOKEN} -o ./temp
TEST_TOKEN_BYTECODE=$(<./temp/TestToken.bin)
Expand Down
14 changes: 0 additions & 14 deletions dex/networks/erc20/contracts/v0/contract.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions dex/networks/eth/contracts/updatecontract.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ fi

VERSION=$1
PKG_NAME=v${VERSION}
SOLIDITY_FILE=./ETHSwapV${VERSION}.sol
CONTRACT_NAME=ETHSwap
SOLIDITY_FILE=./${CONTRACT_NAME}V${VERSION}.sol
if [ ! -f ${SOLIDITY_FILE} ]
then
echo "${SOLIDITY_FILE} does not exist" >&2
Expand All @@ -23,22 +24,22 @@ fi

mkdir temp

solc --bin-runtime --optimize ${SOLIDITY_FILE} -o ./temp/
BYTECODE=$(<./temp/ETHSwap.bin-runtime)
solc --abi --bin --bin-runtime --overwrite --optimize ${SOLIDITY_FILE} -o ./temp/
BYTECODE=$(<./temp/${CONTRACT_NAME}.bin-runtime)

cat > "./${PKG_NAME}/BinRuntimeV${VERSION}.go" <<EOF
// Code generated - DO NOT EDIT.
// This file is a generated binding and any manual changes will be lost.

package ${PKG_NAME}

const ETHSwapRuntimeBin = "${BYTECODE}"
const ${CONTRACT_NAME}RuntimeBin = "${BYTECODE}"
EOF

abigen --sol ${SOLIDITY_FILE} --pkg ${PKG_NAME} --out ./${PKG_NAME}/contract.go
abigen --abi ./temp/${CONTRACT_NAME}.abi --bin ./temp/${CONTRACT_NAME}.bin --pkg ${PKG_NAME} \
--type ${CONTRACT_NAME} --out ./${PKG_NAME}/contract.go

solc --bin --optimize ${SOLIDITY_FILE} -o ./temp
BYTECODE=$(<./temp/ETHSwap.bin)
BYTECODE=$(<./temp/${CONTRACT_NAME}.bin)
sed -i.tmp "s/ETH_SWAP_V${VERSION}=.*/ETH_SWAP_V${VERSION}=\"${BYTECODE}\"/" ../../../testing/eth/harness.sh
# mac needs a temp file specified above.
rm ../../../testing/eth/harness.sh.tmp
Expand Down
Loading