From 0958a2054f910734f7dfc7e0d540487d7e94b3b7 Mon Sep 17 00:00:00 2001 From: Gabriel Martinez Rodriguez Date: Fri, 31 Jan 2025 16:08:11 +0100 Subject: [PATCH 1/7] feat(contracts): config contract --- contracts/Makefile | 5 + .../deployments/anvil/config/abiMap.json | 3 + contracts/deployments/anvil/config/abis.json | 115 ++++++++++++++ contracts/deployments/anvil/config/abis.ts | 149 ++++++++++++++++++ .../deployments/anvil/config/deployment.json | 3 + contracts/deployments/anvil/random/abis.json | 23 ++- contracts/deployments/anvil/random/abis.ts | 24 +-- .../deployments/anvil/random/deployment.json | 2 +- contracts/src/Config.sol | 16 ++ contracts/src/deploy/DeployConfig.s.sol | 21 +++ .../deployments/unknown/config/abiMap.json | 3 + .../deployments/unknown/config/abis.json | 115 ++++++++++++++ .../deployments/unknown/config/abis.ts | 148 +++++++++++++++++ .../unknown/config/deployment.json | 3 + .../unknown/random/deployment.json | 3 + 15 files changed, 608 insertions(+), 25 deletions(-) create mode 100644 contracts/deployments/anvil/config/abiMap.json create mode 100644 contracts/deployments/anvil/config/abis.json create mode 100644 contracts/deployments/anvil/config/abis.ts create mode 100644 contracts/deployments/anvil/config/deployment.json create mode 100644 contracts/src/Config.sol create mode 100644 contracts/src/deploy/DeployConfig.s.sol create mode 100644 packages/contracts/deployments/unknown/config/abiMap.json create mode 100644 packages/contracts/deployments/unknown/config/abis.json create mode 100644 packages/contracts/deployments/unknown/config/abis.ts create mode 100644 packages/contracts/deployments/unknown/config/deployment.json create mode 100644 packages/contracts/deployments/unknown/random/deployment.json diff --git a/contracts/Makefile b/contracts/Makefile index 8d899b8615..a9c4c96e80 100755 --- a/contracts/Makefile +++ b/contracts/Makefile @@ -365,4 +365,9 @@ deploy-random: ## Deploys the randomness contracts and saves the deployment. make deploy DEPLOY_SCRIPT=DeployRandom.s.sol .PHONY: deploy-random +deploy-config: ## Deploys the config contract. + $(eval $(call set-deployment-name,config)) + make deploy DEPLOY_SCRIPT=DeployConfig.s.sol +.PHONY: deploy-config + #################################################################################################### diff --git a/contracts/deployments/anvil/config/abiMap.json b/contracts/deployments/anvil/config/abiMap.json new file mode 100644 index 0000000000..574612816a --- /dev/null +++ b/contracts/deployments/anvil/config/abiMap.json @@ -0,0 +1,3 @@ +{ + "Config": "Config" +} \ No newline at end of file diff --git a/contracts/deployments/anvil/config/abis.json b/contracts/deployments/anvil/config/abis.json new file mode 100644 index 0000000000..989495e6f4 --- /dev/null +++ b/contracts/deployments/anvil/config/abis.json @@ -0,0 +1,115 @@ +{ + "Config": [ + { + "type": "constructor", + "inputs": [ + { + "name": "_random", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "owner", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "random", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "renounceOwnership", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setRandom", + "inputs": [ + { + "name": "_random", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "transferOwnership", + "inputs": [ + { + "name": "newOwner", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "event", + "name": "OwnershipTransferred", + "inputs": [ + { + "name": "previousOwner", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "newOwner", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "error", + "name": "OwnableInvalidOwner", + "inputs": [ + { + "name": "owner", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "OwnableUnauthorizedAccount", + "inputs": [ + { + "name": "account", + "type": "address", + "internalType": "address" + } + ] + } + ] +} diff --git a/contracts/deployments/anvil/config/abis.ts b/contracts/deployments/anvil/config/abis.ts new file mode 100644 index 0000000000..6e415831fb --- /dev/null +++ b/contracts/deployments/anvil/config/abis.ts @@ -0,0 +1,149 @@ +// This file is auto-generated by `make deploy` in `contracts/Makefile` +import type { MapTuple, ObjectFromTuples, UnionToTuple } from "@happy.tech/common" +import type { Address } from "viem" + + +const contractToAbi = ({ + "Config": [ + { + "type": "constructor", + "inputs": [ + { + "name": "_random", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "owner", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "random", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "renounceOwnership", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setRandom", + "inputs": [ + { + "name": "_random", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "transferOwnership", + "inputs": [ + { + "name": "newOwner", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "event", + "name": "OwnershipTransferred", + "inputs": [ + { + "name": "previousOwner", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "newOwner", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "error", + "name": "OwnableInvalidOwner", + "inputs": [ + { + "name": "owner", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "OwnableUnauthorizedAccount", + "inputs": [ + { + "name": "account", + "type": "address", + "internalType": "address" + } + ] + } + ] +} +) as const + +const aliasToContract = ({ + "Config": "Config" +}) as const + +export const deployment = ({ + "Config": "0xc4be33470748e83e6d8e55589A9F5A728Ab394Ca" +}) as const + +export type ContractToAbi = typeof contractToAbi +export type AliasToContract = typeof aliasToContract +export type ContractName = keyof ContractToAbi +export type ContractAlias = keyof AliasToContract +export type Deployment = Record + +type AliasTuple = UnionToTuple +type AbiValuesTuple = MapTuple, ContractToAbi> + +export type StaticAbis = ObjectFromTuples + +export const abis = {} as StaticAbis + +for (const [alias, contractName] of Object.entries(aliasToContract)) { + // biome-ignore lint/suspicious/noExplicitAny: safe generated code + abis[alias as ContractAlias] = contractToAbi[contractName as ContractName] as any +} + + diff --git a/contracts/deployments/anvil/config/deployment.json b/contracts/deployments/anvil/config/deployment.json new file mode 100644 index 0000000000..4c4aeb8f0d --- /dev/null +++ b/contracts/deployments/anvil/config/deployment.json @@ -0,0 +1,3 @@ +{ + "Config": "0xc4be33470748e83e6d8e55589A9F5A728Ab394Ca" +} \ No newline at end of file diff --git a/contracts/deployments/anvil/random/abis.json b/contracts/deployments/anvil/random/abis.json index 9b66bad5fb..80412c2376 100644 --- a/contracts/deployments/anvil/random/abis.json +++ b/contracts/deployments/anvil/random/abis.json @@ -72,20 +72,20 @@ }, { "type": "function", - "name": "DST", + "name": "DRAND_PK_0", "inputs": [], "outputs": [ { "name": "", - "type": "bytes", - "internalType": "bytes" + "type": "uint256", + "internalType": "uint256" } ], "stateMutability": "view" }, { "type": "function", - "name": "MIN_PRECOMMIT_TIME_SECONDS", + "name": "DRAND_PK_1", "inputs": [], "outputs": [ { @@ -98,7 +98,7 @@ }, { "type": "function", - "name": "PRECOMMIT_DELAY_BLOCKS", + "name": "DRAND_PK_2", "inputs": [], "outputs": [ { @@ -111,10 +111,9 @@ }, { "type": "function", - "name": "drandPK0", + "name": "DRAND_PK_3", "inputs": [], "outputs": [ - { "name": "", "type": "uint256", @@ -125,20 +124,20 @@ }, { "type": "function", - "name": "drandPK1", + "name": "DST", "inputs": [], "outputs": [ { "name": "", - "type": "uint256", - "internalType": "uint256" + "type": "bytes", + "internalType": "bytes" } ], "stateMutability": "view" }, { "type": "function", - "name": "drandPK2", + "name": "MIN_PRECOMMIT_TIME_SECONDS", "inputs": [], "outputs": [ { @@ -151,7 +150,7 @@ }, { "type": "function", - "name": "drandPK3", + "name": "PRECOMMIT_DELAY_BLOCKS", "inputs": [], "outputs": [ { diff --git a/contracts/deployments/anvil/random/abis.ts b/contracts/deployments/anvil/random/abis.ts index f60248c523..f6d9878ced 100644 --- a/contracts/deployments/anvil/random/abis.ts +++ b/contracts/deployments/anvil/random/abis.ts @@ -77,20 +77,20 @@ const contractToAbi = ({ }, { "type": "function", - "name": "DST", + "name": "DRAND_PK_0", "inputs": [], "outputs": [ { "name": "", - "type": "bytes", - "internalType": "bytes" + "type": "uint256", + "internalType": "uint256" } ], "stateMutability": "view" }, { "type": "function", - "name": "MIN_PRECOMMIT_TIME_SECONDS", + "name": "DRAND_PK_1", "inputs": [], "outputs": [ { @@ -103,7 +103,7 @@ const contractToAbi = ({ }, { "type": "function", - "name": "PRECOMMIT_DELAY_BLOCKS", + "name": "DRAND_PK_2", "inputs": [], "outputs": [ { @@ -116,7 +116,7 @@ const contractToAbi = ({ }, { "type": "function", - "name": "drandPK0", + "name": "DRAND_PK_3", "inputs": [], "outputs": [ { @@ -129,20 +129,20 @@ const contractToAbi = ({ }, { "type": "function", - "name": "drandPK1", + "name": "DST", "inputs": [], "outputs": [ { "name": "", - "type": "uint256", - "internalType": "uint256" + "type": "bytes", + "internalType": "bytes" } ], "stateMutability": "view" }, { "type": "function", - "name": "drandPK2", + "name": "MIN_PRECOMMIT_TIME_SECONDS", "inputs": [], "outputs": [ { @@ -155,7 +155,7 @@ const contractToAbi = ({ }, { "type": "function", - "name": "drandPK3", + "name": "PRECOMMIT_DELAY_BLOCKS", "inputs": [], "outputs": [ { @@ -644,7 +644,7 @@ const aliasToContract = ({ }) as const export const deployment = ({ - "Random": "0xEF648561456FEEa23B993747eB7B68d3B7332b6a" + "Random": "0xa3Eb22202dc131F4D40c9A7d5028BC2D4134A6bF" }) as const export type ContractToAbi = typeof contractToAbi diff --git a/contracts/deployments/anvil/random/deployment.json b/contracts/deployments/anvil/random/deployment.json index 08333469ff..00f9094170 100644 --- a/contracts/deployments/anvil/random/deployment.json +++ b/contracts/deployments/anvil/random/deployment.json @@ -1,3 +1,3 @@ { - "Random": "0xEF648561456FEEa23B993747eB7B68d3B7332b6a" + "Random": "0xa3Eb22202dc131F4D40c9A7d5028BC2D4134A6bF" } \ No newline at end of file diff --git a/contracts/src/Config.sol b/contracts/src/Config.sol new file mode 100644 index 0000000000..01fe58a6f0 --- /dev/null +++ b/contracts/src/Config.sol @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: BSD-3-Clause-Clear +pragma solidity ^0.8.20; + +import {Ownable} from "openzeppelin/access/Ownable.sol"; + +contract Config is Ownable { + address public random; + + constructor(address _random) Ownable(msg.sender) { + random = _random; + } + + function setRandom(address _random) external onlyOwner { + random = _random; + } +} diff --git a/contracts/src/deploy/DeployConfig.s.sol b/contracts/src/deploy/DeployConfig.s.sol new file mode 100644 index 0000000000..3a0cbff434 --- /dev/null +++ b/contracts/src/deploy/DeployConfig.s.sol @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: BSD-3-Clause-Clear +pragma solidity ^0.8.20; + +import {BaseDeployScript} from "./BaseDeployScript.sol"; +import {Config} from "../Config.sol"; + +/** + * @dev Deploys the Config contract. + */ +contract DeployConfig is BaseDeployScript { + bytes32 public constant DEPLOYMENT_SALT = bytes32(uint256(8)); + address public constant random = 0xd7D1be22f2d14327c07b6669C91773BB23aABa9c; + Config public config; + + function deploy() internal override { + (address _config,) = + deployDeterministic("Config", type(Config).creationCode, abi.encode(random), DEPLOYMENT_SALT); + config = Config(_config); + deployed("Config", address(config)); + } +} diff --git a/packages/contracts/deployments/unknown/config/abiMap.json b/packages/contracts/deployments/unknown/config/abiMap.json new file mode 100644 index 0000000000..574612816a --- /dev/null +++ b/packages/contracts/deployments/unknown/config/abiMap.json @@ -0,0 +1,3 @@ +{ + "Config": "Config" +} \ No newline at end of file diff --git a/packages/contracts/deployments/unknown/config/abis.json b/packages/contracts/deployments/unknown/config/abis.json new file mode 100644 index 0000000000..989495e6f4 --- /dev/null +++ b/packages/contracts/deployments/unknown/config/abis.json @@ -0,0 +1,115 @@ +{ + "Config": [ + { + "type": "constructor", + "inputs": [ + { + "name": "_random", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "owner", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "random", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "renounceOwnership", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setRandom", + "inputs": [ + { + "name": "_random", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "transferOwnership", + "inputs": [ + { + "name": "newOwner", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "event", + "name": "OwnershipTransferred", + "inputs": [ + { + "name": "previousOwner", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "newOwner", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "error", + "name": "OwnableInvalidOwner", + "inputs": [ + { + "name": "owner", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "OwnableUnauthorizedAccount", + "inputs": [ + { + "name": "account", + "type": "address", + "internalType": "address" + } + ] + } + ] +} diff --git a/packages/contracts/deployments/unknown/config/abis.ts b/packages/contracts/deployments/unknown/config/abis.ts new file mode 100644 index 0000000000..e497a15704 --- /dev/null +++ b/packages/contracts/deployments/unknown/config/abis.ts @@ -0,0 +1,148 @@ +// This file is auto-generated by `make deploy` in `packages/contracts/Makefile` +import type { MapTuple, ObjectFromTuples, UnionToTuple } from "@happychain/common" +import type { Address } from "viem" + +const contractToAbi = ({ + "Config": [ + { + "type": "constructor", + "inputs": [ + { + "name": "_random", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "owner", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "random", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "renounceOwnership", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setRandom", + "inputs": [ + { + "name": "_random", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "transferOwnership", + "inputs": [ + { + "name": "newOwner", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "event", + "name": "OwnershipTransferred", + "inputs": [ + { + "name": "previousOwner", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "newOwner", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "error", + "name": "OwnableInvalidOwner", + "inputs": [ + { + "name": "owner", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "OwnableUnauthorizedAccount", + "inputs": [ + { + "name": "account", + "type": "address", + "internalType": "address" + } + ] + } + ] +} +) as const + +const aliasToContract = ({ + "Config": "Config" +}) as const + +export const deployment = ({ + "Config": "0xc4be33470748e83e6d8e55589A9F5A728Ab394Ca" +}) as const + +export type ContractToAbi = typeof contractToAbi +export type AliasToContract = typeof aliasToContract +export type ContractName = keyof ContractToAbi +export type ContractAlias = keyof AliasToContract +export type Deployment = Record + +type AliasTuple = UnionToTuple +type AbiValuesTuple = MapTuple, ContractToAbi> + +export type StaticAbis = ObjectFromTuples + +export const abis = {} as StaticAbis + +for (const [alias, contractName] of Object.entries(aliasToContract)) { + // biome-ignore lint/suspicious/noExplicitAny: safe generated code + abis[alias as ContractAlias] = contractToAbi[contractName as ContractName] as any +} + + diff --git a/packages/contracts/deployments/unknown/config/deployment.json b/packages/contracts/deployments/unknown/config/deployment.json new file mode 100644 index 0000000000..4c4aeb8f0d --- /dev/null +++ b/packages/contracts/deployments/unknown/config/deployment.json @@ -0,0 +1,3 @@ +{ + "Config": "0xc4be33470748e83e6d8e55589A9F5A728Ab394Ca" +} \ No newline at end of file diff --git a/packages/contracts/deployments/unknown/random/deployment.json b/packages/contracts/deployments/unknown/random/deployment.json new file mode 100644 index 0000000000..ce85fef575 --- /dev/null +++ b/packages/contracts/deployments/unknown/random/deployment.json @@ -0,0 +1,3 @@ +{ + "Random": "0xd7D1be22f2d14327c07b6669C91773BB23aABa9c" +} \ No newline at end of file From e128f929725abcde79fb5daa57d87659e2365ec1 Mon Sep 17 00:00:00 2001 From: Gabriel Martinez Rodriguez Date: Mon, 3 Feb 2025 13:22:47 +0100 Subject: [PATCH 2/7] chore(contracts): remove unknown folder --- .../deployments/unknown/config/abiMap.json | 3 - .../deployments/unknown/config/abis.json | 115 -------------- .../deployments/unknown/config/abis.ts | 148 ------------------ .../unknown/config/deployment.json | 3 - .../unknown/random/deployment.json | 3 - 5 files changed, 272 deletions(-) delete mode 100644 packages/contracts/deployments/unknown/config/abiMap.json delete mode 100644 packages/contracts/deployments/unknown/config/abis.json delete mode 100644 packages/contracts/deployments/unknown/config/abis.ts delete mode 100644 packages/contracts/deployments/unknown/config/deployment.json delete mode 100644 packages/contracts/deployments/unknown/random/deployment.json diff --git a/packages/contracts/deployments/unknown/config/abiMap.json b/packages/contracts/deployments/unknown/config/abiMap.json deleted file mode 100644 index 574612816a..0000000000 --- a/packages/contracts/deployments/unknown/config/abiMap.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "Config": "Config" -} \ No newline at end of file diff --git a/packages/contracts/deployments/unknown/config/abis.json b/packages/contracts/deployments/unknown/config/abis.json deleted file mode 100644 index 989495e6f4..0000000000 --- a/packages/contracts/deployments/unknown/config/abis.json +++ /dev/null @@ -1,115 +0,0 @@ -{ - "Config": [ - { - "type": "constructor", - "inputs": [ - { - "name": "_random", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "owner", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "random", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "renounceOwnership", - "inputs": [], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "setRandom", - "inputs": [ - { - "name": "_random", - "type": "address", - "internalType": "address" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "transferOwnership", - "inputs": [ - { - "name": "newOwner", - "type": "address", - "internalType": "address" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "event", - "name": "OwnershipTransferred", - "inputs": [ - { - "name": "previousOwner", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "newOwner", - "type": "address", - "indexed": true, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "error", - "name": "OwnableInvalidOwner", - "inputs": [ - { - "name": "owner", - "type": "address", - "internalType": "address" - } - ] - }, - { - "type": "error", - "name": "OwnableUnauthorizedAccount", - "inputs": [ - { - "name": "account", - "type": "address", - "internalType": "address" - } - ] - } - ] -} diff --git a/packages/contracts/deployments/unknown/config/abis.ts b/packages/contracts/deployments/unknown/config/abis.ts deleted file mode 100644 index e497a15704..0000000000 --- a/packages/contracts/deployments/unknown/config/abis.ts +++ /dev/null @@ -1,148 +0,0 @@ -// This file is auto-generated by `make deploy` in `packages/contracts/Makefile` -import type { MapTuple, ObjectFromTuples, UnionToTuple } from "@happychain/common" -import type { Address } from "viem" - -const contractToAbi = ({ - "Config": [ - { - "type": "constructor", - "inputs": [ - { - "name": "_random", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "owner", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "random", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "renounceOwnership", - "inputs": [], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "setRandom", - "inputs": [ - { - "name": "_random", - "type": "address", - "internalType": "address" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "transferOwnership", - "inputs": [ - { - "name": "newOwner", - "type": "address", - "internalType": "address" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "event", - "name": "OwnershipTransferred", - "inputs": [ - { - "name": "previousOwner", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "newOwner", - "type": "address", - "indexed": true, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "error", - "name": "OwnableInvalidOwner", - "inputs": [ - { - "name": "owner", - "type": "address", - "internalType": "address" - } - ] - }, - { - "type": "error", - "name": "OwnableUnauthorizedAccount", - "inputs": [ - { - "name": "account", - "type": "address", - "internalType": "address" - } - ] - } - ] -} -) as const - -const aliasToContract = ({ - "Config": "Config" -}) as const - -export const deployment = ({ - "Config": "0xc4be33470748e83e6d8e55589A9F5A728Ab394Ca" -}) as const - -export type ContractToAbi = typeof contractToAbi -export type AliasToContract = typeof aliasToContract -export type ContractName = keyof ContractToAbi -export type ContractAlias = keyof AliasToContract -export type Deployment = Record - -type AliasTuple = UnionToTuple -type AbiValuesTuple = MapTuple, ContractToAbi> - -export type StaticAbis = ObjectFromTuples - -export const abis = {} as StaticAbis - -for (const [alias, contractName] of Object.entries(aliasToContract)) { - // biome-ignore lint/suspicious/noExplicitAny: safe generated code - abis[alias as ContractAlias] = contractToAbi[contractName as ContractName] as any -} - - diff --git a/packages/contracts/deployments/unknown/config/deployment.json b/packages/contracts/deployments/unknown/config/deployment.json deleted file mode 100644 index 4c4aeb8f0d..0000000000 --- a/packages/contracts/deployments/unknown/config/deployment.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "Config": "0xc4be33470748e83e6d8e55589A9F5A728Ab394Ca" -} \ No newline at end of file diff --git a/packages/contracts/deployments/unknown/random/deployment.json b/packages/contracts/deployments/unknown/random/deployment.json deleted file mode 100644 index ce85fef575..0000000000 --- a/packages/contracts/deployments/unknown/random/deployment.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "Random": "0xd7D1be22f2d14327c07b6669C91773BB23aABa9c" -} \ No newline at end of file From 23f9a16778a588f7dd3bf29acfb5a15df3257a8f Mon Sep 17 00:00:00 2001 From: Gabriel Martinez Rodriguez Date: Mon, 3 Feb 2025 13:25:22 +0100 Subject: [PATCH 3/7] chore(contracts): update abis for random contract --- contracts/deployments/happy-sepolia/random/deployment.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/deployments/happy-sepolia/random/deployment.json b/contracts/deployments/happy-sepolia/random/deployment.json index 0f0559d594..200266a52a 100644 --- a/contracts/deployments/happy-sepolia/random/deployment.json +++ b/contracts/deployments/happy-sepolia/random/deployment.json @@ -1,3 +1,3 @@ { - "Random": "0x02d41cE77B17f499300eD97C6AD19905c36ba556" + "Random": "0xF13b26BD65d4026818698d243195C0b2D09883c2" } \ No newline at end of file From 5c100b4872c20e8f10fb623b71b2b3604eaaa06a Mon Sep 17 00:00:00 2001 From: Gabriel Martinez Rodriguez Date: Mon, 3 Feb 2025 14:21:56 +0100 Subject: [PATCH 4/7] chore(contracts): added owner to config contract given that now it is deployed with deterministic deployer --- contracts/.env.example | 4 ++++ contracts/deployments/anvil/config/abis.json | 5 +++++ contracts/deployments/anvil/config/abis.ts | 7 ++++++- contracts/deployments/anvil/config/deployment.json | 2 +- contracts/src/Config.sol | 2 +- contracts/src/deploy/DeployConfig.s.sol | 5 +++-- 6 files changed, 20 insertions(+), 5 deletions(-) diff --git a/contracts/.env.example b/contracts/.env.example index 96ca657bba..bebe3153b8 100755 --- a/contracts/.env.example +++ b/contracts/.env.example @@ -87,3 +87,7 @@ export PRECOMMIT_DELAY_BLOCKS=21600 # Owner of the Random contract # For this example, we are using test account 0 as the owner export RANDOM_OWNER=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 + +# Owner of the Config contract +# For this example, we are using test account 0 as the owner +export CONFIG_OWNER=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 \ No newline at end of file diff --git a/contracts/deployments/anvil/config/abis.json b/contracts/deployments/anvil/config/abis.json index 989495e6f4..98d89f9f63 100644 --- a/contracts/deployments/anvil/config/abis.json +++ b/contracts/deployments/anvil/config/abis.json @@ -3,6 +3,11 @@ { "type": "constructor", "inputs": [ + { + "name": "_owner", + "type": "address", + "internalType": "address" + }, { "name": "_random", "type": "address", diff --git a/contracts/deployments/anvil/config/abis.ts b/contracts/deployments/anvil/config/abis.ts index 6e415831fb..f5fb4ad647 100644 --- a/contracts/deployments/anvil/config/abis.ts +++ b/contracts/deployments/anvil/config/abis.ts @@ -8,6 +8,11 @@ const contractToAbi = ({ { "type": "constructor", "inputs": [ + { + "name": "_owner", + "type": "address", + "internalType": "address" + }, { "name": "_random", "type": "address", @@ -125,7 +130,7 @@ const aliasToContract = ({ }) as const export const deployment = ({ - "Config": "0xc4be33470748e83e6d8e55589A9F5A728Ab394Ca" + "Config": "0x62957B5F237F0FD5B0af5B8F60111BBd69dccBFC" }) as const export type ContractToAbi = typeof contractToAbi diff --git a/contracts/deployments/anvil/config/deployment.json b/contracts/deployments/anvil/config/deployment.json index 4c4aeb8f0d..57f4758d64 100644 --- a/contracts/deployments/anvil/config/deployment.json +++ b/contracts/deployments/anvil/config/deployment.json @@ -1,3 +1,3 @@ { - "Config": "0xc4be33470748e83e6d8e55589A9F5A728Ab394Ca" + "Config": "0x62957B5F237F0FD5B0af5B8F60111BBd69dccBFC" } \ No newline at end of file diff --git a/contracts/src/Config.sol b/contracts/src/Config.sol index 01fe58a6f0..894aeb98ac 100644 --- a/contracts/src/Config.sol +++ b/contracts/src/Config.sol @@ -6,7 +6,7 @@ import {Ownable} from "openzeppelin/access/Ownable.sol"; contract Config is Ownable { address public random; - constructor(address _random) Ownable(msg.sender) { + constructor(address _owner, address _random) Ownable(_owner) { random = _random; } diff --git a/contracts/src/deploy/DeployConfig.s.sol b/contracts/src/deploy/DeployConfig.s.sol index 3a0cbff434..f8c6f54abb 100644 --- a/contracts/src/deploy/DeployConfig.s.sol +++ b/contracts/src/deploy/DeployConfig.s.sol @@ -9,12 +9,13 @@ import {Config} from "../Config.sol"; */ contract DeployConfig is BaseDeployScript { bytes32 public constant DEPLOYMENT_SALT = bytes32(uint256(8)); - address public constant random = 0xd7D1be22f2d14327c07b6669C91773BB23aABa9c; + address public constant random = 0xF13b26BD65d4026818698d243195C0b2D09883c2; Config public config; function deploy() internal override { + address owner = vm.envAddress("CONFIG_OWNER"); (address _config,) = - deployDeterministic("Config", type(Config).creationCode, abi.encode(random), DEPLOYMENT_SALT); + deployDeterministic("Config", type(Config).creationCode, abi.encode(owner, random), DEPLOYMENT_SALT); config = Config(_config); deployed("Config", address(config)); } From 17d59875d38a74daef7afa3116bae6957eceb55b Mon Sep 17 00:00:00 2001 From: Gabriel Martinez Rodriguez Date: Wed, 12 Feb 2025 14:59:33 +0100 Subject: [PATCH 5/7] chore(contracts): renamed config contract to address book --- contracts/.env.example | 4 +- contracts/Makefile | 5 - .../deployments/anvil/random/abiMap.json | 1 + contracts/deployments/anvil/random/abis.json | 118 +++++++++++++++++ contracts/deployments/anvil/random/abis.ts | 122 +++++++++++++++++- .../deployments/anvil/random/deployment.json | 3 +- contracts/src/{Config.sol => AddressBook.sol} | 2 +- contracts/src/deploy/DeployConfig.s.sol | 22 ---- contracts/src/deploy/DeployRandom.s.sol | 22 +++- 9 files changed, 261 insertions(+), 38 deletions(-) rename contracts/src/{Config.sol => AddressBook.sol} (91%) delete mode 100644 contracts/src/deploy/DeployConfig.s.sol diff --git a/contracts/.env.example b/contracts/.env.example index bebe3153b8..27b72a352f 100755 --- a/contracts/.env.example +++ b/contracts/.env.example @@ -88,6 +88,6 @@ export PRECOMMIT_DELAY_BLOCKS=21600 # For this example, we are using test account 0 as the owner export RANDOM_OWNER=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 -# Owner of the Config contract +# Owner of the AdressBook contract # For this example, we are using test account 0 as the owner -export CONFIG_OWNER=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 \ No newline at end of file +export ADDRESS_BOOK_OWNER=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 \ No newline at end of file diff --git a/contracts/Makefile b/contracts/Makefile index a9c4c96e80..8d899b8615 100755 --- a/contracts/Makefile +++ b/contracts/Makefile @@ -365,9 +365,4 @@ deploy-random: ## Deploys the randomness contracts and saves the deployment. make deploy DEPLOY_SCRIPT=DeployRandom.s.sol .PHONY: deploy-random -deploy-config: ## Deploys the config contract. - $(eval $(call set-deployment-name,config)) - make deploy DEPLOY_SCRIPT=DeployConfig.s.sol -.PHONY: deploy-config - #################################################################################################### diff --git a/contracts/deployments/anvil/random/abiMap.json b/contracts/deployments/anvil/random/abiMap.json index 3c0b222951..c3fd43ef8c 100644 --- a/contracts/deployments/anvil/random/abiMap.json +++ b/contracts/deployments/anvil/random/abiMap.json @@ -1,3 +1,4 @@ { + "AddressBook": "AddressBook", "Random": "Random" } \ No newline at end of file diff --git a/contracts/deployments/anvil/random/abis.json b/contracts/deployments/anvil/random/abis.json index 80412c2376..a34674bf51 100644 --- a/contracts/deployments/anvil/random/abis.json +++ b/contracts/deployments/anvil/random/abis.json @@ -1,4 +1,122 @@ { + "AddressBook": [ + { + "type": "constructor", + "inputs": [ + { + "name": "_owner", + "type": "address", + "internalType": "address" + }, + { + "name": "_random", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "owner", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "random", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "renounceOwnership", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setRandom", + "inputs": [ + { + "name": "_random", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "transferOwnership", + "inputs": [ + { + "name": "newOwner", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "event", + "name": "OwnershipTransferred", + "inputs": [ + { + "name": "previousOwner", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "newOwner", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "error", + "name": "OwnableInvalidOwner", + "inputs": [ + { + "name": "owner", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "OwnableUnauthorizedAccount", + "inputs": [ + { + "name": "account", + "type": "address", + "internalType": "address" + } + ] + } + ], "Random": [ { "type": "constructor", diff --git a/contracts/deployments/anvil/random/abis.ts b/contracts/deployments/anvil/random/abis.ts index f6d9878ced..22ec34bdbc 100644 --- a/contracts/deployments/anvil/random/abis.ts +++ b/contracts/deployments/anvil/random/abis.ts @@ -4,6 +4,124 @@ import type { Address } from "viem" const contractToAbi = ({ + "AddressBook": [ + { + "type": "constructor", + "inputs": [ + { + "name": "_owner", + "type": "address", + "internalType": "address" + }, + { + "name": "_random", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "owner", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "random", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "renounceOwnership", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setRandom", + "inputs": [ + { + "name": "_random", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "transferOwnership", + "inputs": [ + { + "name": "newOwner", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "event", + "name": "OwnershipTransferred", + "inputs": [ + { + "name": "previousOwner", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "newOwner", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "error", + "name": "OwnableInvalidOwner", + "inputs": [ + { + "name": "owner", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "OwnableUnauthorizedAccount", + "inputs": [ + { + "name": "account", + "type": "address", + "internalType": "address" + } + ] + } + ], "Random": [ { "type": "constructor", @@ -640,11 +758,13 @@ const contractToAbi = ({ ) as const const aliasToContract = ({ + "AddressBook": "AddressBook", "Random": "Random" }) as const export const deployment = ({ - "Random": "0xa3Eb22202dc131F4D40c9A7d5028BC2D4134A6bF" + "AddressBook": "0xA015df073de672522b948418F14baD5999e70eba", + "Random": "0xe3364591EcFAb34e743830B6Ce165AFb699Ff18a" }) as const export type ContractToAbi = typeof contractToAbi diff --git a/contracts/deployments/anvil/random/deployment.json b/contracts/deployments/anvil/random/deployment.json index 00f9094170..e19a425d29 100644 --- a/contracts/deployments/anvil/random/deployment.json +++ b/contracts/deployments/anvil/random/deployment.json @@ -1,3 +1,4 @@ { - "Random": "0xa3Eb22202dc131F4D40c9A7d5028BC2D4134A6bF" + "AddressBook": "0xA015df073de672522b948418F14baD5999e70eba", + "Random": "0xe3364591EcFAb34e743830B6Ce165AFb699Ff18a" } \ No newline at end of file diff --git a/contracts/src/Config.sol b/contracts/src/AddressBook.sol similarity index 91% rename from contracts/src/Config.sol rename to contracts/src/AddressBook.sol index 894aeb98ac..115e713e0e 100644 --- a/contracts/src/Config.sol +++ b/contracts/src/AddressBook.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.20; import {Ownable} from "openzeppelin/access/Ownable.sol"; -contract Config is Ownable { +contract AddressBook is Ownable { address public random; constructor(address _owner, address _random) Ownable(_owner) { diff --git a/contracts/src/deploy/DeployConfig.s.sol b/contracts/src/deploy/DeployConfig.s.sol deleted file mode 100644 index f8c6f54abb..0000000000 --- a/contracts/src/deploy/DeployConfig.s.sol +++ /dev/null @@ -1,22 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause-Clear -pragma solidity ^0.8.20; - -import {BaseDeployScript} from "./BaseDeployScript.sol"; -import {Config} from "../Config.sol"; - -/** - * @dev Deploys the Config contract. - */ -contract DeployConfig is BaseDeployScript { - bytes32 public constant DEPLOYMENT_SALT = bytes32(uint256(8)); - address public constant random = 0xF13b26BD65d4026818698d243195C0b2D09883c2; - Config public config; - - function deploy() internal override { - address owner = vm.envAddress("CONFIG_OWNER"); - (address _config,) = - deployDeterministic("Config", type(Config).creationCode, abi.encode(owner, random), DEPLOYMENT_SALT); - config = Config(_config); - deployed("Config", address(config)); - } -} diff --git a/contracts/src/deploy/DeployRandom.s.sol b/contracts/src/deploy/DeployRandom.s.sol index dfbe8fbc5f..a552c67007 100644 --- a/contracts/src/deploy/DeployRandom.s.sol +++ b/contracts/src/deploy/DeployRandom.s.sol @@ -3,14 +3,16 @@ pragma solidity ^0.8.20; import {BaseDeployScript} from "./BaseDeployScript.sol"; import {Random} from "../randomness/Random.sol"; - +import {AddressBook} from "../AddressBook.sol"; /** * @dev Deploys the Randomness contract. */ + contract DeployRandom is BaseDeployScript { - bytes32 public constant DEPLOYMENT_SALT = bytes32(uint256(0)); + bytes32 public constant RANDOM_DEPLOYMENT_SALT = bytes32(uint256(0)); + bytes32 public constant CONFIG_DEPLOYMENT_SALT = bytes32(uint256(1)); Random public random; - + AddressBook public addressBook; /* * To understand these values. Please refer to the following link: * https://docs.anyrand.com/diy/quickstart @@ -33,16 +35,24 @@ contract DeployRandom is BaseDeployScript { function deploy() internal override { uint256 precommitDelayBlocks = vm.envUint("PRECOMMIT_DELAY_BLOCKS"); - address owner = vm.envAddress("RANDOM_OWNER"); + address randomOwner = vm.envAddress("RANDOM_OWNER"); (address _random,) = deployDeterministic( "Random", type(Random).creationCode, abi.encode( - owner, drandPublicKey, DRAND_GENESIS_TIMESTAMP_SECONDS, DRAND_PERIOD_SECONDS, precommitDelayBlocks + randomOwner, drandPublicKey, DRAND_GENESIS_TIMESTAMP_SECONDS, DRAND_PERIOD_SECONDS, precommitDelayBlocks ), - DEPLOYMENT_SALT + RANDOM_DEPLOYMENT_SALT ); random = Random(_random); deployed("Random", address(random)); + + address addressBookOwner = vm.envAddress("ADDRESS_BOOK_OWNER"); + (address _addressBook,) = deployDeterministic( + "AddressBook", type(AddressBook).creationCode, abi.encode(addressBookOwner, _random), CONFIG_DEPLOYMENT_SALT + ); + addressBook = AddressBook(_addressBook); + + deployed("AddressBook", address(addressBook)); } } From 6f30d4ab3dfbece318f76febf247f51b25ad404c Mon Sep 17 00:00:00 2001 From: Gabriel Martinez Rodriguez Date: Fri, 14 Feb 2025 11:45:47 +0100 Subject: [PATCH 6/7] chore(contracts): added comments --- contracts/src/AddressBook.sol | 9 +++++++++ contracts/src/randomness/Random.sol | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/contracts/src/AddressBook.sol b/contracts/src/AddressBook.sol index 115e713e0e..f7306fbeb9 100644 --- a/contracts/src/AddressBook.sol +++ b/contracts/src/AddressBook.sol @@ -3,7 +3,16 @@ pragma solidity ^0.8.20; import {Ownable} from "openzeppelin/access/Ownable.sol"; +/** + * This contract is used to retrieve the random contract address from the sequencer while constructing a new block, + * in order to prioritize the transaction originating from the randomness owner and ensure that the reveal transaction + * is included as the first transaction of the block, thereby making the randomness available for all transactions. + */ contract AddressBook is Ownable { + /** + * It is very important that if we add new variables, we must maintain the `random` variable in the same storage slot. + * Currently, it is stored at 0x01 and that is the slot that the sequencer uses to retrieve the address of the random contract. + */ address public random; constructor(address _owner, address _random) Ownable(_owner) { diff --git a/contracts/src/randomness/Random.sol b/contracts/src/randomness/Random.sol index 24375fff92..7c4f9b0eb4 100644 --- a/contracts/src/randomness/Random.sol +++ b/contracts/src/randomness/Random.sol @@ -4,6 +4,12 @@ pragma solidity ^0.8.20; import {RandomCommitment} from "./RandomCommitment.sol"; import {Drand} from "./Drand.sol"; +/** + * This contract is checked by the sequencer to obtain its owner and to prioritize the owner's transaction, + * ensuring that it is included as the first transaction of the block. This ordering makes the randomness available + * for all transactions in the block. It is very important that if we add new variables, the `owner` variable remains + * in the same storage slot (currently 0x00), because that is the slot used by the sequencer to retrieve the owner's address. + */ contract Random is RandomCommitment, Drand { /* * The amount of time in seconds by which we delay reading the values from the Drand network. From 823c0fe252fa02dcfc344a019bd5ebcbe21450ba Mon Sep 17 00:00:00 2001 From: Gabriel Martinez Rodriguez Date: Fri, 14 Feb 2025 11:49:17 +0100 Subject: [PATCH 7/7] chore(randomness): regenerate abis --- .../deployments/anvil/config/abiMap.json | 3 - contracts/deployments/anvil/config/abis.json | 120 -------------- contracts/deployments/anvil/config/abis.ts | 154 ------------------ .../deployments/anvil/config/deployment.json | 3 - contracts/deployments/anvil/random/abis.ts | 4 +- .../deployments/anvil/random/deployment.json | 4 +- 6 files changed, 4 insertions(+), 284 deletions(-) delete mode 100644 contracts/deployments/anvil/config/abiMap.json delete mode 100644 contracts/deployments/anvil/config/abis.json delete mode 100644 contracts/deployments/anvil/config/abis.ts delete mode 100644 contracts/deployments/anvil/config/deployment.json diff --git a/contracts/deployments/anvil/config/abiMap.json b/contracts/deployments/anvil/config/abiMap.json deleted file mode 100644 index 574612816a..0000000000 --- a/contracts/deployments/anvil/config/abiMap.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "Config": "Config" -} \ No newline at end of file diff --git a/contracts/deployments/anvil/config/abis.json b/contracts/deployments/anvil/config/abis.json deleted file mode 100644 index 98d89f9f63..0000000000 --- a/contracts/deployments/anvil/config/abis.json +++ /dev/null @@ -1,120 +0,0 @@ -{ - "Config": [ - { - "type": "constructor", - "inputs": [ - { - "name": "_owner", - "type": "address", - "internalType": "address" - }, - { - "name": "_random", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "owner", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "random", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "renounceOwnership", - "inputs": [], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "setRandom", - "inputs": [ - { - "name": "_random", - "type": "address", - "internalType": "address" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "transferOwnership", - "inputs": [ - { - "name": "newOwner", - "type": "address", - "internalType": "address" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "event", - "name": "OwnershipTransferred", - "inputs": [ - { - "name": "previousOwner", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "newOwner", - "type": "address", - "indexed": true, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "error", - "name": "OwnableInvalidOwner", - "inputs": [ - { - "name": "owner", - "type": "address", - "internalType": "address" - } - ] - }, - { - "type": "error", - "name": "OwnableUnauthorizedAccount", - "inputs": [ - { - "name": "account", - "type": "address", - "internalType": "address" - } - ] - } - ] -} diff --git a/contracts/deployments/anvil/config/abis.ts b/contracts/deployments/anvil/config/abis.ts deleted file mode 100644 index f5fb4ad647..0000000000 --- a/contracts/deployments/anvil/config/abis.ts +++ /dev/null @@ -1,154 +0,0 @@ -// This file is auto-generated by `make deploy` in `contracts/Makefile` -import type { MapTuple, ObjectFromTuples, UnionToTuple } from "@happy.tech/common" -import type { Address } from "viem" - - -const contractToAbi = ({ - "Config": [ - { - "type": "constructor", - "inputs": [ - { - "name": "_owner", - "type": "address", - "internalType": "address" - }, - { - "name": "_random", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "owner", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "random", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "renounceOwnership", - "inputs": [], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "setRandom", - "inputs": [ - { - "name": "_random", - "type": "address", - "internalType": "address" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "transferOwnership", - "inputs": [ - { - "name": "newOwner", - "type": "address", - "internalType": "address" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "event", - "name": "OwnershipTransferred", - "inputs": [ - { - "name": "previousOwner", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "newOwner", - "type": "address", - "indexed": true, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "error", - "name": "OwnableInvalidOwner", - "inputs": [ - { - "name": "owner", - "type": "address", - "internalType": "address" - } - ] - }, - { - "type": "error", - "name": "OwnableUnauthorizedAccount", - "inputs": [ - { - "name": "account", - "type": "address", - "internalType": "address" - } - ] - } - ] -} -) as const - -const aliasToContract = ({ - "Config": "Config" -}) as const - -export const deployment = ({ - "Config": "0x62957B5F237F0FD5B0af5B8F60111BBd69dccBFC" -}) as const - -export type ContractToAbi = typeof contractToAbi -export type AliasToContract = typeof aliasToContract -export type ContractName = keyof ContractToAbi -export type ContractAlias = keyof AliasToContract -export type Deployment = Record - -type AliasTuple = UnionToTuple -type AbiValuesTuple = MapTuple, ContractToAbi> - -export type StaticAbis = ObjectFromTuples - -export const abis = {} as StaticAbis - -for (const [alias, contractName] of Object.entries(aliasToContract)) { - // biome-ignore lint/suspicious/noExplicitAny: safe generated code - abis[alias as ContractAlias] = contractToAbi[contractName as ContractName] as any -} - - diff --git a/contracts/deployments/anvil/config/deployment.json b/contracts/deployments/anvil/config/deployment.json deleted file mode 100644 index 57f4758d64..0000000000 --- a/contracts/deployments/anvil/config/deployment.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "Config": "0x62957B5F237F0FD5B0af5B8F60111BBd69dccBFC" -} \ No newline at end of file diff --git a/contracts/deployments/anvil/random/abis.ts b/contracts/deployments/anvil/random/abis.ts index 22ec34bdbc..b1453b4a7c 100644 --- a/contracts/deployments/anvil/random/abis.ts +++ b/contracts/deployments/anvil/random/abis.ts @@ -763,8 +763,8 @@ const aliasToContract = ({ }) as const export const deployment = ({ - "AddressBook": "0xA015df073de672522b948418F14baD5999e70eba", - "Random": "0xe3364591EcFAb34e743830B6Ce165AFb699Ff18a" + "AddressBook": "0x67f1f982515895d5186013E5035e3fd38B6eC446", + "Random": "0xC68804dfc148A221330fac653c01D9f254aDf39C" }) as const export type ContractToAbi = typeof contractToAbi diff --git a/contracts/deployments/anvil/random/deployment.json b/contracts/deployments/anvil/random/deployment.json index e19a425d29..92d10fdb1e 100644 --- a/contracts/deployments/anvil/random/deployment.json +++ b/contracts/deployments/anvil/random/deployment.json @@ -1,4 +1,4 @@ { - "AddressBook": "0xA015df073de672522b948418F14baD5999e70eba", - "Random": "0xe3364591EcFAb34e743830B6Ce165AFb699Ff18a" + "AddressBook": "0x67f1f982515895d5186013E5035e3fd38B6eC446", + "Random": "0xC68804dfc148A221330fac653c01D9f254aDf39C" } \ No newline at end of file