Skip to content

Commit

Permalink
0.10 contracts deploy on devnet (#91)
Browse files Browse the repository at this point in the history
* removed old artifacts, deployed new on to devnet

* fixed playbook

* moved DAODistributor to the root

* changeset

* logs to deploy script

* updated deploy artifacts

* changeset typo

* docstrings update

* added helper script to parse instantiate evt for rankify

* adding distributions now uses EDS named functionality

* scripts updated to use named distribution pattern

* organize script index

* add gameState getter, remove unused code, fix tests to use named exports of scripts

* changeset

* added tbg settings params to getGameState

* comment out playbooks

* fixing compilation

* linter

* updated deployment artifacts

* Update weak-vans-occur.md

* Delete .changeset/shy-beds-hide.md

* Update weak-vans-occur.md
  • Loading branch information
peersky authored Dec 5, 2024
1 parent c3488fb commit df675d8
Show file tree
Hide file tree
Showing 72 changed files with 4,265 additions and 11,313 deletions.
9 changes: 9 additions & 0 deletions .changeset/weak-vans-occur.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'rankify-contracts': minor
---

- added deployment artifacts for 0.10.0 release
- added getGameState getter to rankify main facet
- added helper functions in scripts
- implemented named distributions from newest EDS release
- added more documentation strings
51 changes: 44 additions & 7 deletions deploy/mao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { CodeIndex } from '@peeramid-labs/eds/types';
import CodeIndexAbi from '@peeramid-labs/eds/abi/src/CodeIndex.sol/CodeIndex.json';
import { MintSettingsStruct } from '../types/src/tokens/DistributableGovernanceERC20.sol/DistributableGovernanceERC20';
import { ArguableVotingTournament } from '../types/src/distributions/ArguableVotingTournament';

const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
const { deployments, getNamedAccounts } = hre;
const { deploy } = deployments;
Expand All @@ -24,6 +25,14 @@ const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
patch: 0,
};

const log = (message: string) => {
if (process.env.NODE_ENV !== 'TEST') {
console.log(`[MAO Deploy] ${message}`);
}
};

log('Starting MAO deployment...');

const SACMDeployment = await deployments.get('SimpleAccessManager');
const accessManagerCode = await hre.ethers.provider.getCode(SACMDeployment.address);
const accessManagerId = ethers.utils.keccak256(accessManagerCode);
Expand All @@ -38,24 +47,34 @@ const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
],
});

log('RankToken deployed, registering code...');

const rankTokenCode = await hre.ethers.provider.getCode(rankTokenDeployment.address);
const rankTokenCodeId = ethers.utils.keccak256(rankTokenCode);
const registerAddress = await codeIndexContract.get(rankTokenCodeId);
if (registerAddress === ethers.constants.AddressZero) {
await codeIndexContract.register(rankTokenDeployment.address);
log('Registering RankToken in CodeIndex...');
(await codeIndexContract.register(rankTokenDeployment.address)).wait(1);
} else {
log('RankToken already registered in CodeIndex');
}

const initializerDeployment = await deploy('RankifyInstanceInit', {
from: deployer,
skipIfAlreadyDeployed: true,
});

log('Deploying RankifyInstanceInit...');

const initializerDeploymentCode = await hre.ethers.provider.getCode(initializerDeployment.address);
const initializerDeploymentCodeId = ethers.utils.keccak256(initializerDeploymentCode);
const initializerDeploymentCodeIdAddress = await codeIndexContract.get(initializerDeploymentCodeId);
if (initializerDeploymentCodeIdAddress === ethers.constants.AddressZero) {
await (await codeIndexContract.register(initializerDeployment.address)).wait(1);
} else {
log('Initializer already registered in CodeIndex');
}

const initializerAdr = initializerDeployment.address;
const initializerSelector = '0x00000000';

Expand Down Expand Up @@ -112,6 +131,9 @@ const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
skipIfAlreadyDeployed: true,
args: [initializerAdr, initializerSelector, distributionName, version, addresses],
});

log('Deploying ArguableVotingTournament...');

const arguableVotingTournamentDeploymentCode = await hre.ethers.provider.getCode(
arguableVotingTournamentDeployment.address,
);
Expand All @@ -120,8 +142,12 @@ const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
arguableVotingTournamentDeploymentCodeId,
);
if (arguableVotingTournamentDeploymentRegisterAddress === ethers.constants.AddressZero) {
await codeIndexContract.register(arguableVotingTournamentDeployment.address);
log('Registering ArguableVotingTournament in CodeIndex...');
await (await codeIndexContract.register(arguableVotingTournamentDeployment.address)).wait(1);
} else {
log('ArguableVotingTournament already registered in CodeIndex');
}

const arguableVotingTournamentCode = await hre.ethers.provider.getCode(arguableVotingTournamentDeployment.address);
const arguableVotingTournamentCodeId = ethers.utils.keccak256(arguableVotingTournamentCode);
const mintSettings: MintSettingsStruct = {
Expand All @@ -134,14 +160,18 @@ const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
args: ['TokenName', 'tkn', mintSettings, ethers.constants.AddressZero],
});

log('Deploying GovernanceToken...');

const govTokenDeploymentCode = await hre.ethers.provider.getCode(govTokenDeployment.address);
const govTokenDeploymentCodeId = ethers.utils.keccak256(govTokenDeploymentCode);
const govTokenDeploymentCodeIdAddress = await codeIndexContract.get(govTokenDeploymentCodeId);
if (govTokenDeploymentCodeIdAddress === ethers.constants.AddressZero) {
await codeIndexContract.register(govTokenDeployment.address);
log('Registering GovernanceToken in CodeIndex...');
await (await codeIndexContract.register(govTokenDeployment.address)).wait(1);
} else {
log('GovernanceToken already registered in CodeIndex');
}
const govTokenCode = await hre.ethers.provider.getCode(govTokenDeployment.address);
const govTokenCodeId = ethers.utils.keccak256(govTokenCode);

const rankifyToken = await deployments.get('Rankify');
const result = await deploy('MAODistribution', {
from: deployer,
Expand All @@ -153,19 +183,26 @@ const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
rankTokenCodeId,
arguableVotingTournamentCodeId,
accessManagerId,
govTokenCodeId,
govTokenDeploymentCodeId,
_distributionName,
_distributionVersion,
],
});

log('Deploying MAODistribution...');

const MaoDistrCode = await hre.ethers.provider.getCode(result.address);
const MaoDistrCodeId = ethers.utils.keccak256(MaoDistrCode);
const MaoDistrCodeIdAddress = await codeIndexContract.get(MaoDistrCodeId);
if (MaoDistrCodeIdAddress === ethers.constants.AddressZero) {
await codeIndexContract.register(result.address);
log('Registering MAODistribution in CodeIndex...');
await (await codeIndexContract.register(result.address)).wait(1);
} else {
log('MAODistribution already registered in CodeIndex');
}

log('MAO deployment completed successfully!');

return;
};

Expand Down
147 changes: 78 additions & 69 deletions deployments/anvil/ArguableVotingTournament.json

Large diffs are not rendered by default.

Loading

0 comments on commit df675d8

Please sign in to comment.