Skip to content

Commit

Permalink
chore: add manager update
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidMinarsch committed May 12, 2023
1 parent db8fa7b commit f685a0d
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions scripts/deployment/deploy_03_change_manager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*global process*/

const { expect } = require("chai");
const { ethers } = require("hardhat");
const { LedgerSigner } = require("@anders-t/ethers-ledger");

async function main() {
const fs = require("fs");
const globalsFile = "globals.json";
const dataFromJSON = fs.readFileSync(globalsFile, "utf8");
let parsedData = JSON.parse(dataFromJSON);
const useLedger = parsedData.useLedger;
const derivationPath = parsedData.derivationPath;
const providerName = parsedData.providerName;
const agentRegistryAddress = parsedData.agentRegistryAddress;
const agentFactoryAddress = parsedData.agentFactoryAddress;
let EOA;

let networkURL;
if (providerName === "gnosis") {
if (!process.env.GNOSIS_CHAIN_API_KEY) {
console.log("set GNOSIS_CHAIN_API_KEY env variable");
return;
}
networkURL = "https://rpc.gnosischain.com";
} else if (providerName === "chiado") {
networkURL = "https://rpc.chiadochain.net";
} else {
console.log("Unknown network provider", providerName);
return;
}

const provider = new ethers.providers.JsonRpcProvider(networkURL);
const signers = await ethers.getSigners();

if (useLedger) {
EOA = new LedgerSigner(provider, derivationPath);
} else {
EOA = signers[0];
}
// EOA address
const deployer = await EOA.getAddress();
console.log("EOA is:", deployer);

// Get all the contracts
const agentRegistry = await ethers.getContractAt("AgentRegistry", agentRegistryAddress);

// Transaction signing and execution
// 3. EOA to change the manager of AgentRegistry via `changeManager(AgentRegistry)`;
console.log("You are signing the following transaction: agentRegistry.connect(EOA).changeManager()");
let result = await agentRegistry.connect(EOA).changeManager(agentFactoryAddress);
// Transaction details
console.log("Contract deployment: AgentRegistry");
console.log("Contract address:", agentRegistryAddress);
console.log("Transaction:", result.hash);
}

main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});

0 comments on commit f685a0d

Please sign in to comment.