-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: allow governance execution without dao spoke contract
- Loading branch information
Showing
8 changed files
with
179 additions
and
40 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
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
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
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
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,37 @@ | ||
/* eslint-disable no-console */ | ||
import { ethers } from 'hardhat'; | ||
import dotenv from 'dotenv'; | ||
dotenv.config(); | ||
|
||
async function main() { | ||
// HMTDeployment | ||
// const HMToken = await ethers.getContractFactory( | ||
// 'contracts/HMToken.sol:HMToken' | ||
// ); | ||
// const HMTokenContract = await HMToken.deploy( | ||
// 1000000000, | ||
// 'HUMAN Token', | ||
// 18, | ||
// 'HMT' | ||
// ); | ||
// await HMTokenContract.waitForDeployment(); | ||
// console.log('HMToken Address: ', await HMTokenContract.getAddress()); | ||
|
||
const hmtTokenAddress = process.env.HMT_TOKEN_ADDRESS || ''; | ||
if (!hmtTokenAddress) { | ||
throw new Error('HMT Token Address is missing'); | ||
} | ||
|
||
//vHMT Deployment | ||
const VHMToken = await ethers.getContractFactory( | ||
'contracts/governance/vhm-token/VHMToken.sol:VHMToken' | ||
); | ||
const VHMTokenContract = await VHMToken.deploy(hmtTokenAddress); | ||
await VHMTokenContract.waitForDeployment(); | ||
console.log('VHMToken deployed to:', await VHMTokenContract.getAddress()); | ||
} | ||
|
||
main().catch((error) => { | ||
console.error(error); | ||
process.exitCode = 1; | ||
}); |
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,57 @@ | ||
import { ethers } from 'hardhat'; | ||
import dotenv from 'dotenv'; | ||
|
||
dotenv.config(); | ||
|
||
const abiCoder = ethers.AbiCoder.defaultAbiCoder(); | ||
|
||
export const getProposal = async () => { | ||
const deployerPrivateKey = process.env.PRIVATE_KEY; | ||
const governorAddress = process.env.GOVERNOR_ADDRESS || ''; | ||
const description = process.env.DESCRIPTION || ''; | ||
|
||
if (!deployerPrivateKey || !governorAddress || !description) { | ||
throw new Error('One or more required environment variables are missing.'); | ||
} | ||
|
||
const deployerSigner = new ethers.Wallet(deployerPrivateKey, ethers.provider); | ||
const governanceContract = await ethers.getContractAt( | ||
'MetaHumanGovernor', | ||
governorAddress, | ||
deployerSigner | ||
); | ||
|
||
const encodedCall = governanceContract.interface.encodeFunctionData( | ||
'setVotingPeriod', | ||
[86400] | ||
); | ||
|
||
// Proposal data | ||
const targets = [governorAddress]; | ||
const values = [0]; | ||
const calldatas = [encodedCall]; | ||
|
||
// Example inputs (replace with actual values) | ||
const descriptionHash = ethers.id(description); | ||
|
||
// Encode the data similar to Solidity's `abi.encode` | ||
const encodedData = abiCoder.encode( | ||
['address[]', 'uint256[]', 'bytes[]', 'bytes32'], | ||
[targets, values, calldatas, descriptionHash] | ||
); | ||
|
||
// Compute the keccak256 hash | ||
const hash = ethers.keccak256(encodedData); | ||
|
||
// Convert to uint256 (BigNumber) | ||
const proposalId = ethers.toBigInt(hash); | ||
|
||
return { | ||
proposalId, | ||
targets, | ||
values, | ||
calldatas, | ||
description, | ||
descriptionHash, | ||
}; | ||
}; |
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,42 @@ | ||
import { ethers } from 'hardhat'; | ||
import dotenv from 'dotenv'; | ||
import { getProposal } from './proposal'; | ||
|
||
dotenv.config(); | ||
|
||
async function main() { | ||
const deployerPrivateKey = process.env.PRIVATE_KEY; | ||
const governorAddress = process.env.GOVERNOR_ADDRESS || ''; | ||
|
||
if (!deployerPrivateKey || !governorAddress) { | ||
throw new Error('One or more required environment variables are missing.'); | ||
} | ||
|
||
const deployerSigner = new ethers.Wallet(deployerPrivateKey, ethers.provider); | ||
const governanceContract = await ethers.getContractAt( | ||
'MetaHumanGovernor', | ||
governorAddress, | ||
deployerSigner | ||
); | ||
|
||
const proposal = await getProposal(); | ||
|
||
const transactionResponse = await governanceContract.cancel( | ||
proposal.targets, | ||
proposal.values, | ||
proposal.calldatas, | ||
proposal.descriptionHash | ||
); | ||
|
||
console.log(transactionResponse); | ||
|
||
await transactionResponse.wait(); | ||
console.log('Proposal queued:'); | ||
} | ||
|
||
main() | ||
.then(() => process.exit(0)) | ||
.catch((error) => { | ||
console.error(error); | ||
process.exit(1); | ||
}); |
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