Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
644c9042
Unverified
Commit
644c9042
authored
Oct 26, 2021
by
Maurelian
Committed by
Kelvin Fichter
Nov 10, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(contracts): Replace two arrays with a single array of structs
parent
af445ece
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
32 deletions
+31
-32
AddressDictator.sol
...tracts/contracts/libraries/deployment/AddressDictator.sol
+17
-12
006-OVM_L1CrossDomainMessenger.deploy.ts
...contracts/deploy/006-OVM_L1CrossDomainMessenger.deploy.ts
+1
-4
009-OVM_L1StandardBridge.deploy.ts
packages/contracts/deploy/009-OVM_L1StandardBridge.deploy.ts
+4
-1
011-set-addresses.ts
packages/contracts/deploy/011-set-addresses.ts
+5
-4
013-finalize.ts
packages/contracts/deploy/013-finalize.ts
+4
-11
No files found.
packages/contracts/contracts/libraries/deployment/AddressDictator.sol
View file @
644c9042
...
@@ -7,14 +7,22 @@ import { Lib_AddressManager } from "../resolver/Lib_AddressManager.sol";
...
@@ -7,14 +7,22 @@ import { Lib_AddressManager } from "../resolver/Lib_AddressManager.sol";
* @title AddressDictator
* @title AddressDictator
*/
*/
contract AddressDictator {
contract AddressDictator {
/*********
* Types *
*********/
struct NamedAddress {
string name;
address addr;
}
/*************
/*************
* Variables *
* Variables *
*************/
*************/
Lib_AddressManager public manager;
Lib_AddressManager public manager;
address public finalOwner;
address public finalOwner;
string[] public names;
NamedAddress[] namedAddresses;
address[] public addresses;
/***************
/***************
* Constructor *
* Constructor *
...
@@ -41,8 +49,9 @@ contract AddressDictator {
...
@@ -41,8 +49,9 @@ contract AddressDictator {
_names.length == _addresses.length,
_names.length == _addresses.length,
"AddressDictator: Must provide an equal number of names and addresses."
"AddressDictator: Must provide an equal number of names and addresses."
);
);
names = _names;
for (uint256 i = 0; i < _names.length; i++) {
addresses = _addresses;
namedAddresses.push(NamedAddress({ name: _names[i], addr: _addresses[i] }));
}
}
}
/********************
/********************
...
@@ -50,8 +59,8 @@ contract AddressDictator {
...
@@ -50,8 +59,8 @@ contract AddressDictator {
********************/
********************/
function setAddresses() external {
function setAddresses() external {
for (uint256 i = 0; i < names.length; i++) {
for (uint256 i = 0; i < name
dAddresse
s.length; i++) {
manager.setAddress(name
s[i], addresses[i]
);
manager.setAddress(name
dAddresses[i].name, namedAddresses[i].addr
);
}
}
// note that this will revert if _finalOwner == currentOwner
// note that this will revert if _finalOwner == currentOwner
manager.transferOwnership(finalOwner);
manager.transferOwnership(finalOwner);
...
@@ -69,11 +78,7 @@ contract AddressDictator {
...
@@ -69,11 +78,7 @@ contract AddressDictator {
* View Functions *
* View Functions *
******************/
******************/
function getNames() external view returns (string[] memory) {
function getNamedAddresses() external view returns (NamedAddress[] memory) {
return names;
return namedAddresses;
}
function getAddresses() external view returns (address[] memory) {
return addresses;
}
}
}
}
packages/contracts/deploy/006-OVM_L1CrossDomainMessenger.deploy.ts
View file @
644c9042
...
@@ -10,10 +10,7 @@ import {
...
@@ -10,10 +10,7 @@ import {
}
from
'
../src/hardhat-deploy-ethers
'
}
from
'
../src/hardhat-deploy-ethers
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
Lib_AddressManager
=
await
getLiveContract
(
const
Lib_AddressManager
=
await
getLiveContract
(
hre
,
'
Lib_AddressManager
'
)
hre
,
'
Lib_AddressManager
'
)
await
deployAndPostDeploy
({
await
deployAndPostDeploy
({
hre
,
hre
,
...
...
packages/contracts/deploy/009-OVM_L1StandardBridge.deploy.ts
View file @
644c9042
...
@@ -62,7 +62,10 @@ const deployFn: DeployFunction = async (hre) => {
...
@@ -62,7 +62,10 @@ const deployFn: DeployFunction = async (hre) => {
// Next we need to set the `messenger` address by executing a setStorage operation. We'll
// Next we need to set the `messenger` address by executing a setStorage operation. We'll
// check that this operation was correctly executed by calling `messenger()` and checking
// check that this operation was correctly executed by calling `messenger()` and checking
// that the result matches the value we initialized.
// that the result matches the value we initialized.
const
l1CrossDomainMessenger
=
await
getLiveContract
(
hre
,
'
Proxy__OVM_L1CrossDomainMessenger
'
)
const
l1CrossDomainMessenger
=
await
getLiveContract
(
hre
,
'
Proxy__OVM_L1CrossDomainMessenger
'
)
const
l1CrossDomainMessengerAddress
=
l1CrossDomainMessenger
.
address
const
l1CrossDomainMessengerAddress
=
l1CrossDomainMessenger
.
address
// Critical error, should never happen.
// Critical error, should never happen.
...
...
packages/contracts/deploy/011-set-addresses.ts
View file @
644c9042
...
@@ -12,8 +12,7 @@ const deployFn: DeployFunction = async (hre) => {
...
@@ -12,8 +12,7 @@ const deployFn: DeployFunction = async (hre) => {
signerOrProvider
:
deployer
,
signerOrProvider
:
deployer
,
})
})
const
libAddressManager
=
await
getLiveContract
(
hre
,
'
Lib_AddressManager
'
)
const
libAddressManager
=
await
getLiveContract
(
hre
,
'
Lib_AddressManager
'
)
const
names
=
await
addressDictator
.
getNames
()
const
namedAddresses
=
await
addressDictator
.
getNamedAddresses
()
const
addresses
=
await
addressDictator
.
getAddresses
()
const
finalOwner
=
await
addressDictator
.
finalOwner
()
const
finalOwner
=
await
addressDictator
.
finalOwner
()
let
currentOwner
=
await
libAddressManager
.
owner
()
let
currentOwner
=
await
libAddressManager
.
owner
()
...
@@ -21,8 +20,10 @@ const deployFn: DeployFunction = async (hre) => {
...
@@ -21,8 +20,10 @@ const deployFn: DeployFunction = async (hre) => {
'
\n
'
,
'
\n
'
,
'
An Address Dictator contract has been deployed, with the following name/address pairs:
'
'
An Address Dictator contract has been deployed, with the following name/address pairs:
'
)
)
for
(
let
i
=
0
;
i
<
names
.
length
;
i
++
)
{
for
(
const
namedAddress
of
namedAddresses
)
{
console
.
log
(
`
${
addresses
[
i
]}
<=>
${
names
[
i
]}
`
)
// Set alignment for readability
const
padding
=
'
'
.
repeat
(
40
-
namedAddress
.
name
.
length
)
console
.
log
(
`
${
namedAddress
.
name
}${
padding
}
${
namedAddress
.
addr
}
`
)
}
}
console
.
log
(
console
.
log
(
'
\n
'
,
'
\n
'
,
...
...
packages/contracts/deploy/013-finalize.ts
View file @
644c9042
...
@@ -3,20 +3,13 @@ import { DeployFunction } from 'hardhat-deploy/dist/types'
...
@@ -3,20 +3,13 @@ import { DeployFunction } from 'hardhat-deploy/dist/types'
import
{
hexStringEquals
}
from
'
@eth-optimism/core-utils
'
import
{
hexStringEquals
}
from
'
@eth-optimism/core-utils
'
/* Imports: Internal */
/* Imports: Internal */
import
{
import
{
getLiveContract
,
waitUntilTrue
}
from
'
../src/hardhat-deploy-ethers
'
getLiveContract
,
waitUntilTrue
,
}
from
'
../src/hardhat-deploy-ethers
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
{
deployer
}
=
await
hre
.
getNamedAccounts
()
const
{
deployer
}
=
await
hre
.
getNamedAccounts
()
const
Lib_AddressManager
=
await
getLiveContract
(
const
Lib_AddressManager
=
await
getLiveContract
(
hre
,
'
Lib_AddressManager
'
,
{
hre
,
signerOrProvider
:
deployer
,
'
Lib_AddressManager
'
,
})
{
signerOrProvider
:
deployer
,
}
)
const
owner
=
(
hre
as
any
).
deployConfig
.
ovmAddressManagerOwner
const
owner
=
(
hre
as
any
).
deployConfig
.
ovmAddressManagerOwner
const
remoteOwner
=
await
Lib_AddressManager
.
owner
()
const
remoteOwner
=
await
Lib_AddressManager
.
owner
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment