forked from decred/dcrdex
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dex/networks/eth: ETH fidelity bonds contract
This diff introduces the solidity contract that supports posting fidelity bonds on ETH.
- Loading branch information
Showing
10 changed files
with
1,174 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.