Skip to content

Commit

Permalink
feat: improve address validation for evm accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
tarrencev committed Oct 27, 2021
1 parent dfe41f0 commit 9507f71
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions account.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,14 @@ func UnsafeEVMAccountID(chainID ChainID, address string) EVMAccountID {
return EVMAccountID{AccountID: aID}
}

func (a EVMAccountID) Validate() error {
if ok := common.IsHexAddress(a.AccountID.Address); !ok {
return fmt.Errorf("invalid eth address: %s", a.AccountID.Address)
}

return a.AccountID.Validate()
}

func (a EVMAccountID) Address() common.Address {
return common.HexToAddress(a.AccountID.Address)
}

0 comments on commit 9507f71

Please sign in to comment.