@@ -3,17 +3,17 @@ import { Logger } from "@nestjs/common";
33import { BinaryUtils } from "./binary.utils" ;
44
55export class AddressUtils {
6- static bech32Encode ( publicKey : string ) {
7- return Address . fromHex ( publicKey ) . bech32 ( ) ;
6+ static bech32Encode ( publicKey : string , hrp ?: string ) {
7+ return Address . fromHex ( publicKey , hrp ) . bech32 ( ) ;
88 }
99
1010 static bech32Decode ( address : string ) {
11- return Address . fromBech32 ( address ) . hex ( ) ;
11+ return Address . newFromBech32 ( address ) . hex ( ) ;
1212 }
1313
1414 static isAddressValid ( address : string ) : boolean {
1515 try {
16- Address . fromBech32 ( address ) ;
16+ Address . newFromBech32 ( address ) ;
1717 return true ;
1818 } catch ( error ) {
1919 return false ;
@@ -55,7 +55,7 @@ export class AddressUtils {
5555 return shard ;
5656 }
5757
58- static isSmartContractAddress ( address : string ) : boolean {
58+ static isSmartContractAddress ( address : string , hrp ?: string ) : boolean {
5959 if ( address . toLowerCase ( ) === 'metachain' ) {
6060 return true ;
6161 }
@@ -65,7 +65,7 @@ export class AddressUtils {
6565 }
6666
6767 try {
68- return new Address ( address ) . isContractAddress ( ) ;
68+ return new Address ( address , hrp ) . isContractAddress ( ) ;
6969 } catch ( error ) {
7070 const logger = new Logger ( AddressUtils . name ) ;
7171 logger . error ( `Error when determining whether address '${ address } ' is a smart contract address` ) ;
0 commit comments