Skip to content

Commit f685a0d

Browse files
committed
chore: add manager update
1 parent db8fa7b commit f685a0d

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*global process*/
2+
3+
const { expect } = require("chai");
4+
const { ethers } = require("hardhat");
5+
const { LedgerSigner } = require("@anders-t/ethers-ledger");
6+
7+
async function main() {
8+
const fs = require("fs");
9+
const globalsFile = "globals.json";
10+
const dataFromJSON = fs.readFileSync(globalsFile, "utf8");
11+
let parsedData = JSON.parse(dataFromJSON);
12+
const useLedger = parsedData.useLedger;
13+
const derivationPath = parsedData.derivationPath;
14+
const providerName = parsedData.providerName;
15+
const agentRegistryAddress = parsedData.agentRegistryAddress;
16+
const agentFactoryAddress = parsedData.agentFactoryAddress;
17+
let EOA;
18+
19+
let networkURL;
20+
if (providerName === "gnosis") {
21+
if (!process.env.GNOSIS_CHAIN_API_KEY) {
22+
console.log("set GNOSIS_CHAIN_API_KEY env variable");
23+
return;
24+
}
25+
networkURL = "https://rpc.gnosischain.com";
26+
} else if (providerName === "chiado") {
27+
networkURL = "https://rpc.chiadochain.net";
28+
} else {
29+
console.log("Unknown network provider", providerName);
30+
return;
31+
}
32+
33+
const provider = new ethers.providers.JsonRpcProvider(networkURL);
34+
const signers = await ethers.getSigners();
35+
36+
if (useLedger) {
37+
EOA = new LedgerSigner(provider, derivationPath);
38+
} else {
39+
EOA = signers[0];
40+
}
41+
// EOA address
42+
const deployer = await EOA.getAddress();
43+
console.log("EOA is:", deployer);
44+
45+
// Get all the contracts
46+
const agentRegistry = await ethers.getContractAt("AgentRegistry", agentRegistryAddress);
47+
48+
// Transaction signing and execution
49+
// 3. EOA to change the manager of AgentRegistry via `changeManager(AgentRegistry)`;
50+
console.log("You are signing the following transaction: agentRegistry.connect(EOA).changeManager()");
51+
let result = await agentRegistry.connect(EOA).changeManager(agentFactoryAddress);
52+
// Transaction details
53+
console.log("Contract deployment: AgentRegistry");
54+
console.log("Contract address:", agentRegistryAddress);
55+
console.log("Transaction:", result.hash);
56+
}
57+
58+
main()
59+
.then(() => process.exit(0))
60+
.catch((error) => {
61+
console.error(error);
62+
process.exit(1);
63+
});

0 commit comments

Comments
 (0)