Skip to content

Commit 3142544

Browse files
committed
updated to support domain names in address book from ledger
Signed-off-by: Jeromy Cannon <[email protected]>
1 parent 464ddf6 commit 3142544

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/core/account_manager.mjs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -585,14 +585,17 @@ export class AccountManager {
585585
// ensure serviceEndpoint.ipAddressV4 value for all nodes in the addressBook is a 4 bytes array instead of string
586586
// See: https://github.com/hashgraph/hedera-protobufs/blob/main/services/basic_types.proto#L1309
587587
const addressBook = HashgraphProto.proto.NodeAddressBook.decode(addressBookBytes)
588+
const hasAlphaRegEx = /[a-zA-Z]+/
588589
let modified = false
589590
for (const nodeAddress of addressBook.nodeAddress) {
590-
// overwrite ipAddressV4 as 4 bytes array if required
591-
if (nodeAddress.serviceEndpoint[0].ipAddressV4.byteLength !== 4) {
592-
const ipAddress = nodeAddress.serviceEndpoint[0].ipAddressV4.toString()
593-
const parts = ipAddress.split('.')
591+
const address = nodeAddress.serviceEndpoint[0].ipAddressV4.toString()
592+
593+
// overwrite ipAddressV4 as 4 bytes array if required, unless there is alpha, which means it is a domain name
594+
if (nodeAddress.serviceEndpoint[0].ipAddressV4.byteLength !== 4 && !hasAlphaRegEx.test(address)) {
595+
const parts = address.split('.')
596+
594597
if (parts.length !== 4) {
595-
throw new FullstackTestingError(`expected node IP address to have 4 parts, found ${parts.length}: ${ipAddress}`)
598+
throw new FullstackTestingError(`expected node IP address to have 4 parts, found ${parts.length}: ${address}`)
596599
}
597600

598601
nodeAddress.serviceEndpoint[0].ipAddressV4 = Uint8Array.from(parts)

0 commit comments

Comments
 (0)