Skip to content

Commit

Permalink
address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jlaveracll committed Nov 19, 2024
1 parent 9c2398d commit b5b95e1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion deployment/address_book.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ type AddressBookMap struct {
}

// Save will save an address for a given chain selector. It will error if there is a conflicting existing address.
func (m *AddressBookMap) Save(chainSelector uint64, address string, typeAndVersion TypeAndVersion) error {
func (m *AddressBookMap) save(chainSelector uint64, address string, typeAndVersion TypeAndVersion) error {
family, err := chainsel.GetSelectorFamily(chainSelector)
if err != nil {
return errors.Wrapf(ErrInvalidChainSelector, "chain selector %d", chainSelector)
Expand All @@ -110,6 +110,9 @@ func (m *AddressBookMap) Save(chainSelector uint64, address string, typeAndVersi
return errors.Wrapf(ErrInvalidAddress, "address %s is not a valid Ethereum address, only Ethereum addresses supported for EVM chains", address)
}
}

// TODO NONEVM-960: Add validation for non-EVM chain addresses

if typeAndVersion.Type == "" {
return fmt.Errorf("type cannot be empty")
}
Expand Down
4 changes: 4 additions & 0 deletions deployment/address_book_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ func TestAddressBook_Save(t *testing.T) {
err = ab.Save(chainsel.TEST_90000001.Selector, common.HexToAddress("0x0").Hex(), onRamp100)
require.Error(t, err)

// Zero address but non evm chain
err = NewMemoryAddressBook().Save(chainsel.APTOS_MAINNET.Selector, common.HexToAddress("0x0").Hex(), onRamp100)
require.NoError(t, err)

// Distinct address same TV will not
err = ab.Save(chainsel.TEST_90000001.Selector, addr2, onRamp100)
require.NoError(t, err)
Expand Down

0 comments on commit b5b95e1

Please sign in to comment.