Skip to content

Commit

Permalink
feat: use the AddressesProvider contract when registering root to all…
Browse files Browse the repository at this point in the history
…ow any local fork
  • Loading branch information
yum0e committed Jul 25, 2023
1 parent 16b9b16 commit fb450ab
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
14 changes: 11 additions & 3 deletions front/script/register-root/register-root.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
#!/bin/bash

availableRootsRegistryContractAddress=$1
lastRootOnGnosis=$2
lastRootOnGnosis=$1

# remove 0x prefix and leading zeros on a hex string
remove_zeros() {
awk '{sub(/^0x*/, "");}1' | awk '{sub(/^0*/, "");}1'
}

# get the available roots registry contract address
# by calling the get function of the sismoConnectAddressesProvider contract
availableRootsRegistryContractAddress=0x$(echo $(cast call 0x3Cd5334eB64ebBd4003b72022CC25465f1BFcEe6 "get(string)" "sismoConnectAvailableRootsRegistry") | remove_zeros)

# get the owner of the roots registry contract
# first remove the 0x prefix, then remove the leading zeros with awk
rootsRegistryContractOwner=$(echo $(cast call "$availableRootsRegistryContractAddress" "owner()") | awk '{sub(/^0x*/,"");}1' | awk '{sub(/^0*/,"");}1')
rootsRegistryContractOwner=0x$(echo $(cast call $availableRootsRegistryContractAddress "owner()") | remove_zeros)

# impersonate the owner of the roots registry contract
cast rpc anvil_impersonateAccount $rootsRegistryContractOwner
Expand Down
12 changes: 3 additions & 9 deletions front/script/register-root/register-root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,11 @@ const { readFileSync } = require("fs");
const { spawnSync } = require("child_process");
const fetchHubExports = require("./fetch-hub");

// on Mumbai
const availableRootsRegistryContractAddress = "0x51B3ec080D1459232dbea86B751F75b5204a4abC";

const registerRoot = (root: string) => {
const registerRootScriptPath = fetchHubExports.path.join(__dirname, "register-root.sh");
const child = spawnSync(
`${registerRootScriptPath} ${availableRootsRegistryContractAddress} ${root}`,
{
shell: true,
}
);
const child = spawnSync(`${registerRootScriptPath} ${root}`, {
shell: true,
});

if (child.status !== 0) {
console.error(child.stderr.toString());
Expand Down

0 comments on commit fb450ab

Please sign in to comment.