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

dex/networks/eth: ETH fidelity bonds contract #2717

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
47 changes: 47 additions & 0 deletions dex/networks/eth/bondcontracts/updatecontract.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash
# This script does 3 things:
#
# 1. Updates contract.go to reflect updated solidity code.
# 2. Generates the runtime bytecoode. This is used to compare against the runtime
# bytecode on chain in order to verify that the expected contract is deployed.
# 3. Updates the bytecode in the harness test.

if [ "$#" -ne 1 ]
then
echo "Usage: $0 version" >&2
exit 1
fi

VERSION=$1
PKG_NAME=v${VERSION}
CONTRACT_NAME=ETHBond
SOLIDITY_FILE=./v${VERSION}/contracts/${CONTRACT_NAME}V${VERSION}.sol
if [ ! -f ${SOLIDITY_FILE} ]
then
echo "${SOLIDITY_FILE} does not exist" >&2
exit 1
fi

mkdir temp

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 ${CONTRACT_NAME}RuntimeBin = "${BYTECODE}"
EOF

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

BYTECODE=$(<./temp/${CONTRACT_NAME}.bin)
sed -i.tmp "s/BOND_V${VERSION}=.*/BOND_V${VERSION}=\"${BYTECODE}\"/" ../../../testing/eth/harness.sh
# mac needs a temp file specified above.
rm ../../../testing/eth/harness.sh.tmp

rm -fr temp
12 changes: 12 additions & 0 deletions dex/networks/eth/bondcontracts/v0/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# dependencies
/node_modules
/typechain-types

# build artifacts
/artifacts
/cache

# local network
/.hardhat

package-lock.json
6 changes: 6 additions & 0 deletions dex/networks/eth/bondcontracts/v0/BinRuntimeV0.go

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