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

generate address from private key #2

Merged
merged 2 commits into from
Sep 21, 2023
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
15 changes: 6 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,19 @@
1. prepare your env_file

```
ETHERSCAN_ARBITRUM_KEY=...
ETHERSCAN_PANGOLIN_KEY=...
PRIVATE_KEY=0x...
# this is the private key you used to deploy oracle and relayer contracts
PRIVATE_KEY=...
```

2. run command:

```bash
docker run --rm \
--env-file /path/to/env_file
-it ghcr.io/dcdao/oracle-relayer:v0.1.0 \
"<DEPLOY_ADDRESS>" \
"<YOUR_RELAYER_ADDRESS>" # this is the address you used to run ormpipe
--env-file /path/to/env_file \
-it ghcr.io/dcdao/oracle-relayer:v0.1.x \
"<RELAY_ADDRESS>" # this is the address you used to send transaction in ormpipe
```

Note:

1. `DEPLOY_ADDRESS` is the address of `PRIVATE_KEY`.
2. `YOUR_RELAYER_ADDRESS` should have enough gas fee on all chains. Currently, `arbitrum-goerli` and `pangolin` are supported.
* `PRIVATE_KEY` should have enough gas fee on all chains. Currently, `arbitrum-goerli` and `pangolin` are supported.
46 changes: 30 additions & 16 deletions bin/run.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
#!/bin/bash

# how to use:
# source ./bin/run.sh <DEPLOY_ADDRESS> <RELAYER_ADDRESS>
# source ./bin/run.sh <RELAY_ADDRESS>

set -eo pipefail

# 检查参数数量
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <DEPLOY_ADDRESS> <RELAYER_ADDRESS>"
exit 1
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <RELAY_ADDRESS>"
exit 1
fi

DEPLOY_ADDRESS=$1
RELAYER_ADDRESS=$2
DEPLOY_ADDRESS=$(cast wallet address $PRIVATE_KEY)
RELAY_ADDRESS=$1

# 编译
forge build

# 调用salt.sh并将结果存储到一个变量中
echo "Generate oracle and relayer address..."
echo "++++++++++++++++++++++++++++++++++++++++++++++++"
echo "+ Generate oracle and relayer addresses."
echo "++++++++++++++++++++++++++++++++++++++++++++++++"
OUTPUT=$(./bin/salt.sh $DEPLOY_ADDRESS)

# 使用正则表达式解析结果
Expand All @@ -28,11 +30,15 @@ RELAYER_ADDR=$(echo "$OUTPUT" | grep "Relayer:" -A 1 | grep "Address:" | awk '{p
RELAYER_SALT=$(echo "$OUTPUT" | grep "Relayer:" -A 2 | grep "Salt:" | awk '{print $2}')

# 打印结果
echo " Oracle Address : $ORACLE_ADDR"
echo " Oracle Salt : $ORACLE_SALT"
echo " Relayer Address : $RELAYER_ADDR"
echo " Relayer Salt : $RELAYER_SALT"
echo "Oracle Address : $ORACLE_ADDR"
echo "Oracle Salt : $ORACLE_SALT"
echo "Relayer Address : $RELAYER_ADDR"
echo "Relayer Salt : $RELAYER_SALT"

echo ""
echo "++++++++++++++++++++++++++++++++++++++++++++++++"
echo "+ Modify Deploy.s.sol and deploy.c.json."
echo "++++++++++++++++++++++++++++++++++++++++++++++++"
# 替换Deploy.s.sol文件中的内容
sed -i "s/address immutable ORACLE_ADDR = .*/address immutable ORACLE_ADDR = $ORACLE_ADDR;/g" ./script/Deploy.s.sol
sed -i "s/bytes32 immutable ORACLE_SALT = .*/bytes32 immutable ORACLE_SALT = $ORACLE_SALT;/g" ./script/Deploy.s.sol
Expand All @@ -44,19 +50,27 @@ echo "File Deploy.s.sol has been modified successfully."
# 替换deploy.c.json文件中的内容
sed -i 's/"DAO":.*/"DAO": "'$DEPLOY_ADDRESS'",/' ./script/input/43/deploy.c.json
sed -i 's/"DEPLOYER":.*/"DEPLOYER": "'$DEPLOY_ADDRESS'",/' ./script/input/43/deploy.c.json
sed -i 's/"ORACLE_OPERATOR":.*/"ORACLE_OPERATOR": "'$RELAYER_ADDRESS'",/' ./script/input/43/deploy.c.json
sed -i 's/"RELAYER_OPERATOR":.*/"RELAYER_OPERATOR": "'$RELAYER_ADDRESS'"/' ./script/input/43/deploy.c.json
sed -i 's/"ORACLE_OPERATOR":.*/"ORACLE_OPERATOR": "'$RELAY_ADDRESS'",/' ./script/input/43/deploy.c.json
sed -i 's/"RELAYER_OPERATOR":.*/"RELAYER_OPERATOR": "'$RELAY_ADDRESS'"/' ./script/input/43/deploy.c.json

sed -i 's/"DAO":.*/"DAO": "'$DEPLOY_ADDRESS'",/' ./script/input/421613/deploy.c.json
sed -i 's/"DEPLOYER":.*/"DEPLOYER": "'$DEPLOY_ADDRESS'",/' ./script/input/421613/deploy.c.json
sed -i 's/"ORACLE_OPERATOR":.*/"ORACLE_OPERATOR": "'$RELAYER_ADDRESS'",/' ./script/input/421613/deploy.c.json
sed -i 's/"RELAYER_OPERATOR":.*/"RELAYER_OPERATOR": "'$RELAYER_ADDRESS'"/' ./script/input/421613/deploy.c.json
sed -i 's/"ORACLE_OPERATOR":.*/"ORACLE_OPERATOR": "'$RELAY_ADDRESS'",/' ./script/input/421613/deploy.c.json
sed -i 's/"RELAYER_OPERATOR":.*/"RELAYER_OPERATOR": "'$RELAY_ADDRESS'"/' ./script/input/421613/deploy.c.json

echo "File deploy.c.json has been modified successfully."

# 部署
echo "Deploying..."
echo ""
echo "++++++++++++++++++++++++++++++++++++++++++++++++"
echo "+ Deploy: arbitrum oracle and relayer contracts."
echo "++++++++++++++++++++++++++++++++++++++++++++++++"
forge script ./script/Deploy.s.sol:DeployScript --private-key $PRIVATE_KEY --chain-id 421613 --broadcast --verify

echo ""
echo "++++++++++++++++++++++++++++++++++++++++++++++++"
echo "+ Deploy: pangolin oracle and relayer contracts."
echo "++++++++++++++++++++++++++++++++++++++++++++++++"
forge script ./script/Deploy.s.sol:DeployScript --private-key $PRIVATE_KEY --chain-id 43 --broadcast --verify

echo "Deployed successfully."