-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
db8fa7b
commit f685a0d
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |