Skip to content

Commit

Permalink
Added timezone validation
Browse files Browse the repository at this point in the history
  • Loading branch information
jclapis committed May 26, 2021
1 parent db98685 commit 6e72501
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"math/big"
"sync"
"time"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -300,6 +301,10 @@ func EstimateSetTimezoneLocationGas(rp *rocketpool.RocketPool, timezoneLocation
if err != nil {
return rocketpool.GasInfo{}, err
}
_, err = time.LoadLocation(timezoneLocation)
if err != nil {
return rocketpool.GasInfo{}, fmt.Errorf("Could not parse timezone [%s]: %w", timezoneLocation, err)
}
return rocketNodeManager.GetTransactionGasInfo(opts, "setTimezoneLocation", timezoneLocation)
}

Expand All @@ -310,6 +315,10 @@ func SetTimezoneLocation(rp *rocketpool.RocketPool, timezoneLocation string, opt
if err != nil {
return common.Hash{}, err
}
_, err = time.LoadLocation(timezoneLocation)
if err != nil {
return common.Hash{}, fmt.Errorf("Could not parse timezone [%s]: %w", timezoneLocation, err)
}
hash, err := rocketNodeManager.Transact(opts, "setTimezoneLocation", timezoneLocation)
if err != nil {
return common.Hash{}, fmt.Errorf("Could not set node timezone location: %w", err)
Expand Down

0 comments on commit 6e72501

Please sign in to comment.