Skip to content

Commit 86050d3

Browse files
chore(contracts): renamed config contract to address book
1 parent afa5f0a commit 86050d3

9 files changed

Lines changed: 261 additions & 38 deletions

File tree

contracts/.env.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,6 @@ export PRECOMMIT_DELAY_BLOCKS=21600
8888
# For this example, we are using test account 0 as the owner
8989
export RANDOM_OWNER=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
9090

91-
# Owner of the Config contract
91+
# Owner of the AdressBook contract
9292
# For this example, we are using test account 0 as the owner
93-
export CONFIG_OWNER=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
93+
export ADDRESS_BOOK_OWNER=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266

contracts/Makefile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -365,9 +365,4 @@ deploy-random: ## Deploys the randomness contracts and saves the deployment.
365365
make deploy DEPLOY_SCRIPT=DeployRandom.s.sol
366366
.PHONY: deploy-random
367367

368-
deploy-config: ## Deploys the config contract.
369-
$(eval $(call set-deployment-name,config))
370-
make deploy DEPLOY_SCRIPT=DeployConfig.s.sol
371-
.PHONY: deploy-config
372-
373368
####################################################################################################
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2+
"AddressBook": "AddressBook",
23
"Random": "Random"
34
}

contracts/deployments/anvil/random/abis.json

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,122 @@
11
{
2+
"AddressBook": [
3+
{
4+
"type": "constructor",
5+
"inputs": [
6+
{
7+
"name": "_owner",
8+
"type": "address",
9+
"internalType": "address"
10+
},
11+
{
12+
"name": "_random",
13+
"type": "address",
14+
"internalType": "address"
15+
}
16+
],
17+
"stateMutability": "nonpayable"
18+
},
19+
{
20+
"type": "function",
21+
"name": "owner",
22+
"inputs": [],
23+
"outputs": [
24+
{
25+
"name": "",
26+
"type": "address",
27+
"internalType": "address"
28+
}
29+
],
30+
"stateMutability": "view"
31+
},
32+
{
33+
"type": "function",
34+
"name": "random",
35+
"inputs": [],
36+
"outputs": [
37+
{
38+
"name": "",
39+
"type": "address",
40+
"internalType": "address"
41+
}
42+
],
43+
"stateMutability": "view"
44+
},
45+
{
46+
"type": "function",
47+
"name": "renounceOwnership",
48+
"inputs": [],
49+
"outputs": [],
50+
"stateMutability": "nonpayable"
51+
},
52+
{
53+
"type": "function",
54+
"name": "setRandom",
55+
"inputs": [
56+
{
57+
"name": "_random",
58+
"type": "address",
59+
"internalType": "address"
60+
}
61+
],
62+
"outputs": [],
63+
"stateMutability": "nonpayable"
64+
},
65+
{
66+
"type": "function",
67+
"name": "transferOwnership",
68+
"inputs": [
69+
{
70+
"name": "newOwner",
71+
"type": "address",
72+
"internalType": "address"
73+
}
74+
],
75+
"outputs": [],
76+
"stateMutability": "nonpayable"
77+
},
78+
{
79+
"type": "event",
80+
"name": "OwnershipTransferred",
81+
"inputs": [
82+
{
83+
"name": "previousOwner",
84+
"type": "address",
85+
"indexed": true,
86+
"internalType": "address"
87+
},
88+
{
89+
"name": "newOwner",
90+
"type": "address",
91+
"indexed": true,
92+
"internalType": "address"
93+
}
94+
],
95+
"anonymous": false
96+
},
97+
{
98+
"type": "error",
99+
"name": "OwnableInvalidOwner",
100+
"inputs": [
101+
{
102+
"name": "owner",
103+
"type": "address",
104+
"internalType": "address"
105+
}
106+
]
107+
},
108+
{
109+
"type": "error",
110+
"name": "OwnableUnauthorizedAccount",
111+
"inputs": [
112+
{
113+
"name": "account",
114+
"type": "address",
115+
"internalType": "address"
116+
}
117+
]
118+
}
119+
],
2120
"Random": [
3121
{
4122
"type": "constructor",

contracts/deployments/anvil/random/abis.ts

Lines changed: 121 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,124 @@ import type { Address } from "viem"
44

55

66
const contractToAbi = ({
7+
"AddressBook": [
8+
{
9+
"type": "constructor",
10+
"inputs": [
11+
{
12+
"name": "_owner",
13+
"type": "address",
14+
"internalType": "address"
15+
},
16+
{
17+
"name": "_random",
18+
"type": "address",
19+
"internalType": "address"
20+
}
21+
],
22+
"stateMutability": "nonpayable"
23+
},
24+
{
25+
"type": "function",
26+
"name": "owner",
27+
"inputs": [],
28+
"outputs": [
29+
{
30+
"name": "",
31+
"type": "address",
32+
"internalType": "address"
33+
}
34+
],
35+
"stateMutability": "view"
36+
},
37+
{
38+
"type": "function",
39+
"name": "random",
40+
"inputs": [],
41+
"outputs": [
42+
{
43+
"name": "",
44+
"type": "address",
45+
"internalType": "address"
46+
}
47+
],
48+
"stateMutability": "view"
49+
},
50+
{
51+
"type": "function",
52+
"name": "renounceOwnership",
53+
"inputs": [],
54+
"outputs": [],
55+
"stateMutability": "nonpayable"
56+
},
57+
{
58+
"type": "function",
59+
"name": "setRandom",
60+
"inputs": [
61+
{
62+
"name": "_random",
63+
"type": "address",
64+
"internalType": "address"
65+
}
66+
],
67+
"outputs": [],
68+
"stateMutability": "nonpayable"
69+
},
70+
{
71+
"type": "function",
72+
"name": "transferOwnership",
73+
"inputs": [
74+
{
75+
"name": "newOwner",
76+
"type": "address",
77+
"internalType": "address"
78+
}
79+
],
80+
"outputs": [],
81+
"stateMutability": "nonpayable"
82+
},
83+
{
84+
"type": "event",
85+
"name": "OwnershipTransferred",
86+
"inputs": [
87+
{
88+
"name": "previousOwner",
89+
"type": "address",
90+
"indexed": true,
91+
"internalType": "address"
92+
},
93+
{
94+
"name": "newOwner",
95+
"type": "address",
96+
"indexed": true,
97+
"internalType": "address"
98+
}
99+
],
100+
"anonymous": false
101+
},
102+
{
103+
"type": "error",
104+
"name": "OwnableInvalidOwner",
105+
"inputs": [
106+
{
107+
"name": "owner",
108+
"type": "address",
109+
"internalType": "address"
110+
}
111+
]
112+
},
113+
{
114+
"type": "error",
115+
"name": "OwnableUnauthorizedAccount",
116+
"inputs": [
117+
{
118+
"name": "account",
119+
"type": "address",
120+
"internalType": "address"
121+
}
122+
]
123+
}
124+
],
7125
"Random": [
8126
{
9127
"type": "constructor",
@@ -640,11 +758,13 @@ const contractToAbi = ({
640758
) as const
641759

642760
const aliasToContract = ({
761+
"AddressBook": "AddressBook",
643762
"Random": "Random"
644763
}) as const
645764

646765
export const deployment = ({
647-
"Random": "0xa3Eb22202dc131F4D40c9A7d5028BC2D4134A6bF"
766+
"AddressBook": "0xA015df073de672522b948418F14baD5999e70eba",
767+
"Random": "0xe3364591EcFAb34e743830B6Ce165AFb699Ff18a"
648768
}) as const
649769

650770
export type ContractToAbi = typeof contractToAbi
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"Random": "0xa3Eb22202dc131F4D40c9A7d5028BC2D4134A6bF"
2+
"AddressBook": "0xA015df073de672522b948418F14baD5999e70eba",
3+
"Random": "0xe3364591EcFAb34e743830B6Ce165AFb699Ff18a"
34
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pragma solidity ^0.8.20;
33

44
import {Ownable} from "openzeppelin/access/Ownable.sol";
55

6-
contract Config is Ownable {
6+
contract AddressBook is Ownable {
77
address public random;
88

99
constructor(address _owner, address _random) Ownable(_owner) {

contracts/src/deploy/DeployConfig.s.sol

Lines changed: 0 additions & 22 deletions
This file was deleted.

contracts/src/deploy/DeployRandom.s.sol

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ pragma solidity ^0.8.20;
33

44
import {BaseDeployScript} from "./BaseDeployScript.sol";
55
import {Random} from "../randomness/Random.sol";
6-
6+
import {AddressBook} from "../AddressBook.sol";
77
/**
88
* @dev Deploys the Randomness contract.
99
*/
10+
1011
contract DeployRandom is BaseDeployScript {
11-
bytes32 public constant DEPLOYMENT_SALT = bytes32(uint256(0));
12+
bytes32 public constant RANDOM_DEPLOYMENT_SALT = bytes32(uint256(0));
13+
bytes32 public constant CONFIG_DEPLOYMENT_SALT = bytes32(uint256(1));
1214
Random public random;
13-
15+
AddressBook public addressBook;
1416
/*
1517
* To understand these values. Please refer to the following link:
1618
* https://docs.anyrand.com/diy/quickstart
@@ -33,16 +35,24 @@ contract DeployRandom is BaseDeployScript {
3335

3436
function deploy() internal override {
3537
uint256 precommitDelayBlocks = vm.envUint("PRECOMMIT_DELAY_BLOCKS");
36-
address owner = vm.envAddress("RANDOM_OWNER");
38+
address randomOwner = vm.envAddress("RANDOM_OWNER");
3739
(address _random,) = deployDeterministic(
3840
"Random",
3941
type(Random).creationCode,
4042
abi.encode(
41-
owner, drandPublicKey, DRAND_GENESIS_TIMESTAMP_SECONDS, DRAND_PERIOD_SECONDS, precommitDelayBlocks
43+
randomOwner, drandPublicKey, DRAND_GENESIS_TIMESTAMP_SECONDS, DRAND_PERIOD_SECONDS, precommitDelayBlocks
4244
),
43-
DEPLOYMENT_SALT
45+
RANDOM_DEPLOYMENT_SALT
4446
);
4547
random = Random(_random);
4648
deployed("Random", address(random));
49+
50+
address addressBookOwner = vm.envAddress("ADDRESS_BOOK_OWNER");
51+
(address _addressBook,) = deployDeterministic(
52+
"AddressBook", type(AddressBook).creationCode, abi.encode(addressBookOwner, _random), CONFIG_DEPLOYMENT_SALT
53+
);
54+
addressBook = AddressBook(_addressBook);
55+
56+
deployed("AddressBook", address(addressBook));
4757
}
4858
}

0 commit comments

Comments
 (0)