Skip to content

Commit

Permalink
Modify rootchain command to use the provided private key to fund vali…
Browse files Browse the repository at this point in the history
…dators (0xPolygon#1540)

* Modified rootchain command to use the provided private key to fund validators
  • Loading branch information
dusan-maksimovic authored May 25, 2023
1 parent 1f16cbc commit 9040ca9
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions command/rootchain/fund/fund.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,16 @@ func runCommand(cmd *cobra.Command, _ []string) {
return
}

var (
deployerKey ethgo.Key
stakeTokenAddr types.Address
)
deployerKey, err := helper.GetRootchainPrivateKey(params.deployerPrivateKey)
if err != nil {
outputter.SetError(fmt.Errorf("failed to initialize deployer private key: %w", err))

if params.mintStakeToken {
deployerKey, err = helper.GetRootchainPrivateKey(params.deployerPrivateKey)
if err != nil {
outputter.SetError(fmt.Errorf("failed to initialize deployer private key: %w", err))
return
}

return
}
var stakeTokenAddr types.Address

if params.mintStakeToken {
stakeTokenAddr = types.StringToAddress(params.stakeTokenAddr)
}

Expand All @@ -126,7 +123,14 @@ func runCommand(cmd *cobra.Command, _ []string) {
Value: params.amountValues[i],
}

receipt, err := txRelayer.SendTransactionLocal(txn)
var receipt *ethgo.Receipt

if params.deployerPrivateKey != "" {
receipt, err = txRelayer.SendTransaction(txn, deployerKey)
} else {
receipt, err = txRelayer.SendTransactionLocal(txn)
}

if err != nil {
return fmt.Errorf("failed to send fund validator '%s' transaction: %w", validatorAddr, err)
}
Expand Down

0 comments on commit 9040ca9

Please sign in to comment.