@harmony-js/utils
Advanced tools
Comparing version 0.0.21 to 0.0.22
@@ -0,0 +0,0 @@ export declare const enum ChainType { |
@@ -0,0 +0,0 @@ export * from './validators'; |
@@ -0,0 +0,0 @@ import BN from 'bn.js'; |
@@ -0,0 +0,0 @@ export declare const enum AssertType { |
@@ -23,2 +23,5 @@ "use strict"; | ||
isBlockNumber: [validators_1.isBlockNumber], | ||
isBech32Address: [validators_1.isBech32Address], | ||
isBech32TestNetAddress: [validators_1.isBech32TestNetAddress], | ||
isValidAddress: [validators_1.isValidAddress], | ||
}; | ||
@@ -25,0 +28,0 @@ function validateArgs(args, requiredArgs, optionalArgs) { |
@@ -114,2 +114,14 @@ export declare const isKeyString: { | ||
}; | ||
export declare const isBech32Address: { | ||
(raw: string): boolean; | ||
validator: string; | ||
}; | ||
export declare const isBech32TestNetAddress: { | ||
(raw: string): boolean; | ||
validator: string; | ||
}; | ||
export declare const isValidAddress: { | ||
(address: string): boolean; | ||
validator: string; | ||
}; | ||
//# sourceMappingURL=validators.d.ts.map |
@@ -144,2 +144,24 @@ "use strict"; | ||
exports.isBlockNumber.validator = 'isBlockNumber'; | ||
exports.isBech32Address = function (raw) { | ||
return !!raw.match(/^hmy1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{38}/); | ||
}; | ||
exports.isBech32Address.validator = 'isBech32Address'; | ||
exports.isBech32TestNetAddress = function (raw) { | ||
return !!raw.match(/^thmy1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{38}/); | ||
}; | ||
exports.isBech32TestNetAddress.validator = 'isBech32TestNetAddress'; | ||
exports.isValidAddress = function (address) { | ||
if (!exports.isString(address)) { | ||
throw new Error(address + " is not string"); | ||
} | ||
if (exports.isAddress(address) || | ||
exports.isBech32Address(address) || | ||
exports.isBech32TestNetAddress(address)) { | ||
return true; | ||
} | ||
else { | ||
return false; | ||
} | ||
}; | ||
exports.isValidAddress.validator = 'isValidAddress'; | ||
//# sourceMappingURL=validators.js.map |
{ | ||
"name": "@harmony-js/utils", | ||
"version": "0.0.21", | ||
"version": "0.0.22", | ||
"description": "utils for harmony", | ||
@@ -24,3 +24,3 @@ "main": "dist/index.js", | ||
}, | ||
"gitHead": "7a51fd2bcccc294bd32f991181f755fdbc88f6e8" | ||
"gitHead": "5c53415c333ab12d727fc1808be2e603d40489e0" | ||
} |
@@ -13,2 +13,5 @@ import { | ||
isAddress, | ||
isBech32Address, | ||
isBech32TestNetAddress, | ||
isValidAddress, | ||
isHash, | ||
@@ -37,2 +40,5 @@ isBlockNumber, | ||
isBlockNumber: [isBlockNumber], | ||
isBech32Address: [isBech32Address], | ||
isBech32TestNetAddress: [isBech32TestNetAddress], | ||
isValidAddress: [isValidAddress], | ||
}; | ||
@@ -39,0 +45,0 @@ |
@@ -162,1 +162,27 @@ export const isKeyString = (keyString: string, lengh: number): boolean => { | ||
isBlockNumber.validator = 'isBlockNumber'; | ||
export const isBech32Address = (raw: string): boolean => { | ||
return !!raw.match(/^hmy1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{38}/); | ||
}; | ||
isBech32Address.validator = 'isBech32Address'; | ||
export const isBech32TestNetAddress = (raw: string): boolean => { | ||
return !!raw.match(/^thmy1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{38}/); | ||
}; | ||
isBech32TestNetAddress.validator = 'isBech32TestNetAddress'; | ||
export const isValidAddress = (address: string): boolean => { | ||
if (!isString(address)) { | ||
throw new Error(`${address} is not string`); | ||
} | ||
if ( | ||
isAddress(address) || | ||
isBech32Address(address) || | ||
isBech32TestNetAddress(address) | ||
) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
}; | ||
isValidAddress.validator = 'isValidAddress'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
286992
3865