Skip to content

Commit

Permalink
Added config option.
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanIliev545 committed Sep 28, 2023
1 parent 7d61329 commit 2a88acd
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const l1Accs = await layer1.getNamedAccounts();

const messageBusAddress = process.env.MESSAGE_BUS_ADDRESS!!
const prefundAmountStr = process.env.PREFUND_FAUCET_AMOUNT || "10000"
const prefundAmountStr = process.env.PREFUND_FAUCET_AMOUNT!!

if (prefundAmountStr == "0") {
return;
}

const messageBus = (await hre.ethers.getContractFactory('MessageBus')).attach(messageBusAddress)
const prefundAmount = hre.ethers.utils.parseEther(prefundAmountStr);
Expand Down
3 changes: 3 additions & 0 deletions testnet/launcher/l2contractdeployer/cmd/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type L2ContractDeployerConfigCLI struct {
l2PrivateKey string
l2HOCPrivateKey string
l2POCPrivateKey string
faucetFunding string
}

// ParseConfigCLI returns a NodeConfigCLI based the cli params and defaults.
Expand All @@ -31,6 +32,7 @@ func ParseConfigCLI() *L2ContractDeployerConfigCLI {
l2PrivateKey := flag.String(l2privateKeyFlag, "", flagUsageMap[l2privateKeyFlag])
l2HOCPrivateKey := flag.String(l2HOCPrivateKeyFlag, "", flagUsageMap[l2HOCPrivateKeyFlag])
l2POCPrivateKey := flag.String(l2POCPrivateKeyFlag, "", flagUsageMap[l2POCPrivateKeyFlag])
faucetFunds := flag.String(faucetFundingFlag, "0", flagUsageMap[faucetFundingFlag])

flag.Parse()

Expand All @@ -43,6 +45,7 @@ func ParseConfigCLI() *L2ContractDeployerConfigCLI {
cfg.l2PrivateKey = *l2PrivateKey
cfg.l2HOCPrivateKey = *l2POCPrivateKey
cfg.l2POCPrivateKey = *l2HOCPrivateKey
cfg.faucetFunding = *faucetFunds

return cfg
}
2 changes: 2 additions & 0 deletions testnet/launcher/l2contractdeployer/cmd/cli_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const (
l2privateKeyFlag = "l2_private_key"
l2HOCPrivateKeyFlag = "l2_hoc_private_key"
l2POCPrivateKeyFlag = "l2_poc_private_key"
faucetFundingFlag = "faucet_funds"
)

// Returns a map of the flag usages.
Expand All @@ -26,5 +27,6 @@ func getFlagUsageMap() map[string]string {
l2privateKeyFlag: "Layer 2 private key",
l2HOCPrivateKeyFlag: "Layer 2 HOC contract private key",
l2POCPrivateKeyFlag: "Layer 2 POC contract private key",
faucetFundingFlag: "How much funds should the faucet account receive",
}
}
29 changes: 19 additions & 10 deletions testnet/launcher/l2contractdeployer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@ type Option = func(c *Config)

// Config holds the properties that configure the package
type Config struct {
l1HTTPURL string
l1privateKey string
l2Port int
l2Host string
l2PrivateKey string
hocPKString string
pocPKString string
messageBusAddress string
dockerImage string
l1HTTPURL string
l1privateKey string
l2Port int
l2Host string
l2PrivateKey string
hocPKString string
pocPKString string
messageBusAddress string
dockerImage string
faucetPrefundAmount string
}

func NewContractDeployerConfig(opts ...Option) *Config {
defaultConfig := &Config{}
defaultConfig := &Config{
faucetPrefundAmount: "10000",
}

for _, opt := range opts {
opt(defaultConfig)
Expand Down Expand Up @@ -79,3 +82,9 @@ func WithPocPKString(s string) Option {
c.pocPKString = s
}
}

func WithFaucetFunds(f string) Option {
return func(c *Config) {
c.faucetPrefundAmount = f
}
}

0 comments on commit 2a88acd

Please sign in to comment.