Skip to content

Commit

Permalink
fixed merge conflicts for the registry merge & further cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
SurfingNerd committed Nov 20, 2024
2 parents 9ce67d4 + 3227c4f commit 261cd16
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 55 deletions.
19 changes: 5 additions & 14 deletions tasks/make_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ task("make_spec_hbbft", "used to make a spec file")
const contractName = initialContracts.core[i].name!;

console.log("Preparing contract: ", contractName);

const initializerArgs = initialContracts.getContractInitializerArgs(contractName, networkConfig);

await initialContracts.core[i].compileContract(hre);
console.log("compiled: ", contractName);

let initializerDataHex = await initialContracts.core[i].compileProxy(
hre,
ProxyContractName,
Expand All @@ -68,30 +68,21 @@ task("make_spec_hbbft", "used to make a spec file")
blocscoutVerificationScript += `echo "verifying proxy for ${contractName} on ${proxyAddress}"\n`;
blocscoutVerificationScript += `npx hardhat verify --network alpha3 ${proxyAddress} ${implementationAddress} ${networkConfig.owner} ${initializerDataHex}\n`;

console.log("generating spec for ", contractName);
const contractSpec = initialContracts.core[i].toSpecAccount(taskArgs.useUpgradeProxy, 0);

spec.accounts = {
...spec.accounts,
...contractSpec
};
}
console.log("Spec preparation done.");

//spec.engine.hbbft.params.randomnessContractAddress = RANDOM_CONTRACT;
spec.engine.hbbft.params.blockRewardContractAddress = initialContracts.getAddress("BlockRewardHbbft");
spec.params.transactionPermissionContract = initialContracts.getAddress("TxPermissionHbbft");
spec.params.transactionPermissionContractTransition = '0x0';

// spec.params.registrar = initialContracts.registry?.address;


// await initialContracts.registry!.compileContract(
// hre,
// [
// initialContracts.getAddress("CertifierHbbft"),
// networkConfig.owner
// ]
// );

spec.accounts = {
...spec.accounts
};
Expand Down
76 changes: 35 additions & 41 deletions tasks/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,37 +166,41 @@ export class NetworkConfiguration {
}
}

export class SpecialContract {
public name?: string;
public address?: string;
public bytecode?: string;

public constructor(
name?: string,
address?: string,
bytecode?: string
) {
this.name = name;
this.address = address;
this.bytecode = bytecode;
}

async compileContract(hre: HardhatRuntimeEnvironment, args: any[]) {
const factory = await hre.ethers.getContractFactory(this.name!);
const tx = await factory.getDeployTransaction(...args);

this.bytecode = tx.data;
}

toSpecAccount(balance: number) {
return {
[this.address!]: {
balance: balance.toString(),
constructor: this.bytecode!
}
};
}
}
// SpecialContract has been used for the Registry.
// It is not used anymore.
// kept for reference if any other special contracts show up int he future.

// export class SpecialContract {
// public name?: string;
// public address?: string;
// public bytecode?: string;

// public constructor(
// name?: string,
// address?: string,
// bytecode?: string
// ) {
// this.name = name;
// this.address = address;
// this.bytecode = bytecode;
// }

// async compileContract(hre: HardhatRuntimeEnvironment, args: any[]) {
// const factory = await hre.ethers.getContractFactory(this.name!);
// const tx = await factory.getDeployTransaction(...args);

// this.bytecode = tx.data;
// }

// toSpecAccount(balance: number) {
// return {
// [this.address!]: {
// balance: balance.toString(),
// constructor: this.bytecode!
// }
// };
// }
// }

export class CoreContract {
public name?: string;
Expand Down Expand Up @@ -274,7 +278,6 @@ export class CoreContract {

export class InitialContractsConfiguration {
public core: CoreContract[] = [];
public registry?: SpecialContract;

static fromJSON(json: any): InitialContractsConfiguration {
const instance = new InitialContractsConfiguration();
Expand All @@ -283,10 +286,6 @@ export class InitialContractsConfiguration {
if (key == 'core') {
instance[key] = (value as Array<any>).map(x => new CoreContract(...(Object.values(x as any) as [])));
}

if (key == 'registry') {
instance[key] = new SpecialContract(...(Object.values(value as any) as []));
}
}


Expand Down Expand Up @@ -388,11 +387,6 @@ export class InitialContractsConfiguration {
this.getAddress('ConnectivityTrackerHbbft'),
this.getAddress('StakingHbbft'),
];
case 'Registry':
return [
this.getAddress('CertifierHbbft'),
config.owner
];
default:
return [];
}
Expand Down

0 comments on commit 261cd16

Please sign in to comment.