Skip to content

Commit

Permalink
Merge pull request #317 from argentlabs/chore/verification
Browse files Browse the repository at this point in the history
chore: update verification script and documentation
  • Loading branch information
delaaxe authored Nov 18, 2022
2 parents c3176bc + c37cc27 commit 320e3d8
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
INFURA_KEY=
ALCHEMY_KEY=
ETHERSCAN_API_KEY=
S3_BUCKET_PREFIX=
S3_BUCKET_SUFFIXES=
S3_CONFIG_KEY=
Expand Down
5 changes: 4 additions & 1 deletion DEPLOYMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ If setting up a new environment `ENV_NAME` for the first time:
- Add a new AWS configuration locally
- Add it to `S3_BUCKET_SUFFIXES` in `.env`

## 2. Deploy the contracts:
## 2. Deploy and verify the contracts:

Run the four deployments scripts in order (you can find them in the `deployment/` directory).

```
./scripts/deploy.sh --no-compile ENV_NAME 1
./scripts/deploy.sh --no-compile ENV_NAME 2
./scripts/deploy.sh --no-compile ENV_NAME 3
./scripts/deploy.sh --no-compile ENV_NAME 4
./scripts/execute_script.sh --no-compile scripts/verify.js ENV_NAME
```

If you need to do some manual changes to the config file and reupload it to S3 you can do it like this:
Expand Down
10 changes: 9 additions & 1 deletion scripts/execute_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,12 @@ fi
NETWORK=$1
shift

AWS_PROFILE=argent-$NETWORK AWS_SDK_LOAD_CONFIG=true npx truffle exec $FILE --network $NETWORK "$@"
IS_AWS_VAULT_INSTALLED=$(command -v "aws-vault" || echo 0)
IS_PROFILE_AVAILABLE=$(aws-vault list | grep "argent-$NETWORK" || echo 0)

if [ "$IS_AWS_VAULT_INSTALLED" == "0" ] || [ "$IS_PROFILE_AVAILABLE" == "0" ];
then
AWS_PROFILE=argent-$NETWORK AWS_SDK_LOAD_CONFIG=true npx truffle exec $FILE --network $NETWORK "$@"
else
aws-vault exec argent-$NETWORK -- npx truffle exec $FILE --network $NETWORK "$@"
fi
14 changes: 10 additions & 4 deletions scripts/verify.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ const ConfiguratorLoader = require("../utils/configurator-loader.js");
const Configurator = require("../utils/configurator.js");

async function execVerify(contractName, contractAddress, network) {
const res = await exec(`npx truffle run verify ${contractName}@${contractAddress} --network ${network}`).catch((e) => e);
console.log(res.stdout);
try {
const res = await exec(`npx truffle run verify ${contractName}@${contractAddress} --network ${network}`);
console.log(res.stdout || res);
} catch (error) {
console.error(`Error verifying: ${error}`);
}
}

async function main() {
Expand All @@ -42,18 +46,20 @@ async function main() {
const configuration = configurator.copyConfig();

for (const [contractName, contractAddress] of Object.entries(configuration.contracts)) {
console.log(`Verifying contract ${contractName} at ${contractAddress} ...`);
await execVerify(contractName, contractAddress, network);
}

for (const [contractName, value] of Object.entries(configuration.filters)) {
for (const [contractName, value] of Object.entries(configuration.filters || {})) {
const contractAddresses = [].concat(...[value]); // value can be an address or array of addresses
for (const addr of contractAddresses) {
console.log(`Verifying ${contractName} at ${addr} ...`);
console.log(`Verifying filter ${contractName} at ${addr} ...`);
await execVerify(contractName, addr, network);
}
}

for (const [moduleName, moduleAddress] of Object.entries(configuration.modules)) {
console.log(`Verifying module ${moduleName} at ${moduleAddress} ...`);
await execVerify(moduleName, moduleAddress, network);
}
}
Expand Down

0 comments on commit 320e3d8

Please sign in to comment.