Skip to content
Prev Previous commit
Next Next commit
chore: removed traces of Neo in more scripts
  • Loading branch information
jaybuidl committed Sep 4, 2025
commit daa8bf944327075a403298a4bdf3f9a017a81db2
14 changes: 5 additions & 9 deletions contracts/deployments/contractsEthers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@ import {
KlerosCoreUniversity__factory,
SortitionModuleUniversity,
SortitionModuleUniversity__factory,
KlerosCoreNeo,
KlerosCoreNeo__factory,
SortitionModuleNeo,
SortitionModuleNeo__factory,
} from "../typechain-types";
import { type ContractConfig, type DeploymentName, deployments, getAddress } from "./utils";

Expand Down Expand Up @@ -171,8 +167,8 @@ function getCommonFactories(

export const getContracts = async (provider: ethers.Provider, deployment: DeploymentName) => {
const { chainId } = deployments[deployment];
let klerosCore: KlerosCore | KlerosCoreNeo | KlerosCoreUniversity;
let sortition: SortitionModule | SortitionModuleNeo | SortitionModuleUniversity;
let klerosCore: KlerosCore | KlerosCoreUniversity;
let sortition: SortitionModule | SortitionModuleUniversity;
let commonFactories: CommonFactories;

switch (deployment) {
Expand Down Expand Up @@ -247,9 +243,9 @@ export const getContracts = async (provider: ethers.Provider, deployment: Deploy
chainId
);
break;
case "mainnetNeo":
klerosCore = KlerosCoreNeo__factory.connect(getAddress(mainnetCoreConfig, chainId), provider);
sortition = SortitionModuleNeo__factory.connect(getAddress(mainnetSortitionConfig, chainId), provider);
case "mainnet":
klerosCore = KlerosCore__factory.connect(getAddress(mainnetCoreConfig, chainId), provider);
sortition = SortitionModule__factory.connect(getAddress(mainnetSortitionConfig, chainId), provider);
commonFactories = getCommonFactories(
{
dkClassicConfig: mainnetDkcConfig,
Expand Down
2 changes: 1 addition & 1 deletion contracts/deployments/contractsViem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export const getConfigs = ({ deployment }: { deployment: DeploymentName }): Cont
},
});

case "mainnetNeo":
case "mainnet":
return getCommonConfigs({
chainId,
configs: {
Expand Down
2 changes: 1 addition & 1 deletion contracts/deployments/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const deployments = {
testnet: {
chainId: arbitrumSepolia.id,
},
mainnetNeo: {
mainnet: {
chainId: arbitrum.id,
},
} as const;
Expand Down
4 changes: 2 additions & 2 deletions contracts/scripts/changeOwner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const { bold } = print.colors;

task("change-owner", "Changes the owner for all the contracts")
.addPositionalParam("newOwner", "The address of the new owner")
.addOptionalParam("coreType", "The type of core to use between base, neo, university (default: base)", Cores.BASE)
.addOptionalParam("coreType", "The type of core to use between base, university (default: base)", Cores.BASE)
.setAction(async (taskArgs, hre) => {
const newOwner = taskArgs.newOwner;
if (!isAddress(newOwner)) {
Expand All @@ -27,7 +27,7 @@ task("change-owner", "Changes the owner for all the contracts")

const coreType = Cores[taskArgs.coreType.toUpperCase() as keyof typeof Cores];
if (coreType === undefined) {
console.error("Invalid core type, must be one of base, neo, university");
console.error("Invalid core type, must be one of base, university");
return;
}
console.log("Using core type %s", coreType);
Expand Down
2 changes: 1 addition & 1 deletion contracts/scripts/generateDeploymentArtifact.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

if [[ $# < 2 ]]
if [[ $# -lt 2 ]]
then
echo "usage: $(basename $0) network address"
exit 1
Expand Down
1 change: 1 addition & 0 deletions contracts/scripts/generateDeploymentsMarkdown.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ IGNORED_ARTIFACTS=(
function generate() { #deploymentDir #explorerUrl
deploymentDir=$1
explorerUrl=$2
# shellcheck disable=SC2068
for f in $(ls -1 $deploymentDir/*.json 2>/dev/null | grep -v ${IGNORED_ARTIFACTS[@]/#/-e } | sort); do
contractName=$(basename $f .json)
address=$(cat $f | jq -r .address)
Expand Down
7 changes: 2 additions & 5 deletions contracts/scripts/keeperBot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
DisputeKitGatedShutter,
DisputeKitShutter,
SortitionModule,
SortitionModuleNeo,
} from "../typechain-types";
import env from "./utils/env";
import loggerFactory from "./utils/logger";
Expand Down Expand Up @@ -49,7 +48,7 @@ const getContracts = async () => {
throw new Error("University is not supported yet");
}
const contracts = await getContractsForCoreType(hre, coreType);
return { ...contracts, sortition: contracts.sortition as SortitionModule | SortitionModuleNeo };
return { ...contracts, sortition: contracts.sortition as SortitionModule };
};

type Contribution = {
Expand Down Expand Up @@ -277,9 +276,7 @@ const isRngReady = async () => {
return true;
}
} else if (currentRng === blockHashRNG?.target && blockHashRNG !== null) {
const requestBlock = await sortition.randomNumberRequestBlock();
const lookahead = await sortition.rngLookahead();
const n = await blockHashRNG.receiveRandomness.staticCall(requestBlock + lookahead);
const n = await blockHashRNG.receiveRandomness.staticCall();
if (Number(n) === 0) {
logger.info("BlockHashRNG is NOT ready yet");
return false;
Expand Down
5 changes: 2 additions & 3 deletions contracts/scripts/keeperBotShutter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import hre from "hardhat";
import { getBytes } from "ethers";
import { DisputeKitGatedShutter, DisputeKitShutter, SortitionModule, SortitionModuleNeo } from "../typechain-types";
import { DisputeKitGatedShutter, DisputeKitShutter } from "../typechain-types";
import { decrypt } from "./shutter";
import env from "./utils/env";
import loggerFactory from "./utils/logger";
Expand Down Expand Up @@ -312,8 +312,7 @@ const getContracts = async () => {
if (coreType === Cores.UNIVERSITY) {
throw new Error("University is not supported yet");
}
const contracts = await getContractsForCoreType(hre, coreType);
return { ...contracts, sortition: contracts.sortition as SortitionModule | SortitionModuleNeo };
return await getContractsForCoreType(hre, coreType);
};

async function main() {
Expand Down
18 changes: 9 additions & 9 deletions contracts/scripts/populateCourts.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { task, types } from "hardhat/config";
import { KlerosCore, KlerosCoreNeo, KlerosCoreUniversity } from "../typechain-types";
import { KlerosCore, KlerosCoreUniversity } from "../typechain-types";
import { BigNumberish, toBigInt, toNumber } from "ethers";
import courtsV1Mainnet from "../config/courts.v1.mainnet.json";
import courtsV1GnosisChain from "../config/courts.v1.gnosischain.json";
import courtsV2ArbitrumTestnet from "../config/courts.v2.testnet.json";
import courtsV2ArbitrumDevnet from "../config/courts.v2.devnet.json";
import courtsV2MainnetNeo from "../config/courts.v2.mainnet-neo.json";
import courtsV2Mainnet from "../config/courts.v2.mainnet.json";
import { isDevnet } from "../deploy/utils";
import { execute, writeTransactionBatch } from "./utils/execution";
import { getContracts, Cores } from "./utils/contracts";
Expand All @@ -21,7 +21,7 @@ enum Sources {
V1_GNOSIS,
V2_DEVNET,
V2_TESTNET,
V2_MAINNET_NEO,
V2_MAINNET,
}

type Court = {
Expand All @@ -43,7 +43,7 @@ const TEN_THOUSAND_GWEI = 10n ** 13n;
task("populate:courts", "Populates the courts and their parameters")
.addOptionalParam(
"from",
"The source of the policies between v1_mainnet, v1_gnosis, v2_devnet, v2_testnet, v2_mainnet_neo (default: auto depending on the network)",
"The source of the policies between v1_mainnet, v1_gnosis, v2_devnet, v2_testnet, v2_mainnet (default: auto depending on the network)",
undefined
)
.addOptionalParam("start", "The starting index for the courts to populate (default: 0)", 0, types.int)
Expand All @@ -53,7 +53,7 @@ task("populate:courts", "Populates the courts and their parameters")
undefined,
types.int
)
.addOptionalParam("coreType", "The type of core to use between base, neo, university (default: base)", Cores.BASE)
.addOptionalParam("coreType", "The type of core to use between base, university (default: base)", Cores.BASE)
.addFlag("reverse", "Iterates the courts in reverse order, useful to increase minStake in the child courts first")
.addFlag("forceV1ParametersToDev", "Use development values for the v1 courts parameters")
.setAction(async (taskArgs, hre) => {
Expand All @@ -74,7 +74,7 @@ task("populate:courts", "Populates the courts and their parameters")
if (taskArgs.from) {
from = Sources[taskArgs.from.toUpperCase() as keyof typeof Sources];
if (from === undefined) {
console.error("Invalid source, must be one of v1_mainnet, v1_gnosis, v2_devnet, v2_testnet, v2_mainnet_neo");
console.error("Invalid source, must be one of v1_mainnet, v1_gnosis, v2_devnet, v2_testnet, v2_mainnet");
return;
}
} else {
Expand All @@ -84,7 +84,7 @@ task("populate:courts", "Populates the courts and their parameters")

const coreType = Cores[taskArgs.coreType.toUpperCase() as keyof typeof Cores];
if (coreType === undefined) {
console.error("Invalid core type, must be one of base, neo, university");
console.error("Invalid core type, must be one of base, university");
return;
}
console.log("Using core type %s", coreType);
Expand Down Expand Up @@ -133,8 +133,8 @@ task("populate:courts", "Populates the courts and their parameters")
courtsV2 = courtsV2ArbitrumTestnet;
break;
}
case Sources.V2_MAINNET_NEO: {
courtsV2 = courtsV2MainnetNeo;
case Sources.V2_MAINNET: {
courtsV2 = courtsV2Mainnet;
break;
}
default:
Expand Down
12 changes: 6 additions & 6 deletions contracts/scripts/populatePolicyRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import policiesV1Mainnet from "../config/policies.v1.mainnet.json";
import policiesV1GnosisChain from "../config/policies.v1.gnosischain.json";
import policiesV2ArbitrumTestnet from "../config/policies.v2.testnet.json";
import policiesV2ArbitrumDevnet from "../config/policies.v2.devnet.json";
import policiesV2MainnetNeo from "../config/policies.v2.mainnet-neo.json";
import policiesV2Mainnet from "../config/policies.v2.mainnet.json";
import { isDevnet } from "../deploy/utils";
import { execute, writeTransactionBatch } from "./utils/execution";

Expand All @@ -19,13 +19,13 @@ enum Sources {
V1_GNOSIS,
V2_DEVNET,
V2_TESTNET,
V2_MAINNET_NEO,
V2_MAINNET,
}

task("populate:policy-registry", "Populates the policy registry for each court")
.addOptionalParam(
"from",
"The source of the policies between v1_mainnet, v1_gnosis, v2_devnet, v2_testnet, v2_mainnet_neo (default: auto depending on the network)",
"The source of the policies between v1_mainnet, v1_gnosis, v2_devnet, v2_testnet, v2_mainnet (default: auto depending on the network)",
undefined
)
.addOptionalParam("start", "The starting index for the courts to populate (default: 0)", 0, types.int)
Expand Down Expand Up @@ -53,7 +53,7 @@ task("populate:policy-registry", "Populates the policy registry for each court")
if (taskArgs.from) {
from = Sources[taskArgs.from.toUpperCase() as keyof typeof Sources];
if (from === undefined) {
console.error("Invalid source, must be one of v1_mainnet, v1_gnosis, v2_devnet, v2_testnet, v2_mainnet_neo");
console.error("Invalid source, must be one of v1_mainnet, v1_gnosis, v2_devnet, v2_testnet, v2_mainnet");
return;
}
} else {
Expand Down Expand Up @@ -88,8 +88,8 @@ task("populate:policy-registry", "Populates the policy registry for each court")
policiesV2 = policiesV2ArbitrumTestnet;
break;
}
case Sources.V2_MAINNET_NEO: {
policiesV2 = policiesV2MainnetNeo;
case Sources.V2_MAINNET: {
policiesV2 = policiesV2Mainnet;
break;
}
default:
Expand Down
40 changes: 10 additions & 30 deletions contracts/scripts/utils/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ import {
DisputeResolver,
DisputeTemplateRegistry,
KlerosCore,
KlerosCoreNeo,
KlerosCoreUniversity,
PNK,
PolicyRegistry,
RandomizerRNG,
SortitionModule,
SortitionModuleNeo,
SortitionModuleUniversity,
TransactionBatcher,
KlerosCoreSnapshotProxy,
Expand All @@ -24,28 +22,18 @@ import {

export const Cores = {
BASE: "BASE",
NEO: "NEO",
UNIVERSITY: "UNIVERSITY",
} as const;

export type Core = (typeof Cores)[keyof typeof Cores];

/**
* Get contract names by specifying the coreType (BASE, NEO, UNIVERSITY).
* Get contract names by specifying the coreType (BASE, UNIVERSITY).
* @param coreType - Core type
* @returns Contract names
*/
export const getContractNames = (coreType: Core) => {
const coreSpecificNames = {
[Cores.NEO]: {
core: "KlerosCoreNeo",
sortition: "SortitionModuleNeo",
disputeKitClassic: "DisputeKitClassicNeo",
disputeKitShutter: "DisputeKitShutterNeo",
disputeKitGated: "DisputeKitGatedNeo",
disputeKitGatedShutter: "DisputeKitGatedShutterNeo",
disputeResolver: "DisputeResolverNeo",
},
[Cores.BASE]: {
core: "KlerosCore",
sortition: "SortitionModule",
Expand All @@ -66,7 +54,7 @@ export const getContractNames = (coreType: Core) => {
},
};

if (!(coreType in coreSpecificNames)) throw new Error("Invalid core type, must be one of BASE, NEO, or UNIVERSITY");
if (!(coreType in coreSpecificNames)) throw new Error("Invalid core type, must be one of BASE, or UNIVERSITY");

return {
...coreSpecificNames[coreType],
Expand All @@ -83,20 +71,16 @@ export const getContractNames = (coreType: Core) => {
};

/**
* Get contracts by specifying the coreType (BASE, NEO, UNIVERSITY).
* Get contracts by specifying the coreType (BASE, UNIVERSITY).
* @param hre - Hardhat runtime environment
* @param coreType - Core type
* @returns Contracts
*/
export const getContracts = async (hre: HardhatRuntimeEnvironment, coreType: Core) => {
const { ethers } = hre;
let core: KlerosCore | KlerosCoreNeo | KlerosCoreUniversity;
let sortition: SortitionModule | SortitionModuleNeo | SortitionModuleUniversity;
let core: KlerosCore | KlerosCoreUniversity;
let sortition: SortitionModule | SortitionModuleUniversity;
switch (coreType) {
case Cores.NEO:
core = await ethers.getContract<KlerosCoreNeo>(getContractNames(coreType).core);
sortition = await ethers.getContract<SortitionModuleNeo>(getContractNames(coreType).sortition);
break;
case Cores.BASE:
core = await ethers.getContract<KlerosCore>(getContractNames(coreType).core);
sortition = await ethers.getContract<SortitionModule>(getContractNames(coreType).sortition);
Expand All @@ -106,7 +90,7 @@ export const getContracts = async (hre: HardhatRuntimeEnvironment, coreType: Cor
sortition = await ethers.getContract<SortitionModuleUniversity>(getContractNames(coreType).sortition);
break;
default:
throw new Error("Invalid core type, must be one of BASE, NEO, or UNIVERSITY");
throw new Error("Invalid core type, must be one of BASE, or UNIVERSITY");
}
const disputeKitClassic = await ethers.getContract<DisputeKitClassic>(getContractNames(coreType).disputeKitClassic);
const disputeKitShutter = await ethers.getContractOrNull<DisputeKitShutter>(
Expand Down Expand Up @@ -151,32 +135,28 @@ export const getContracts = async (hre: HardhatRuntimeEnvironment, coreType: Cor
};

/**
* Get contracts by inferring the coreType (BASE, NEO, UNIVERSITY) from the network, most convenient for most cases.
* Get contracts by inferring the coreType (BASE, UNIVERSITY) from the network, most convenient for most cases.
* @param hre - Hardhat runtime environment
* @returns Contracts
*/
export const getContractsFromNetwork = async (hre: HardhatRuntimeEnvironment) => {
const { network } = hre;
if (network.name === "arbitrumSepoliaDevnet" || network.name === "arbitrumSepolia") {
if (["arbitrumSepoliaDevnet", "arbitrumSepolia", "arbitrum"].includes(network.name)) {
return getContracts(hre, Cores.BASE);
} else if (network.name === "arbitrum") {
return getContracts(hre, Cores.NEO);
} else {
throw new Error("Invalid network");
}
};

/**
* Get contract names by inferring the coreType (BASE, NEO, UNIVERSITY) from the network, most convenient for most cases.
* Get contract names by inferring the coreType (BASE, UNIVERSITY) from the network, most convenient for most cases.
* @param hre - Hardhat runtime environment
* @returns Contract names
*/
export const getContractNamesFromNetwork = async (hre: HardhatRuntimeEnvironment) => {
const { network } = hre;
if (network.name === "arbitrumSepoliaDevnet" || network.name === "arbitrumSepolia") {
if (["arbitrumSepoliaDevnet", "arbitrumSepolia", "arbitrum"].includes(network.name)) {
return getContractNames(Cores.BASE);
} else if (network.name === "arbitrum") {
return getContractNames(Cores.NEO);
} else {
throw new Error("Invalid network");
}
Expand Down
Loading
Loading