packageDocumentation module export const isKeyString = ( keyString , lengh ) : boolean => { return ! ! keyString . replace ( '0x' , '' ) . match ( `^[0-9a-fA-F]{${ lengh }}$` ) ; } ; isKeyString . validator = 'isKeyString' ; export const isAddress = ( address ) : boolean => { return isKeyString ( address , 40 ) ; } ; isAddress . validator = 'isAddress' ; export const isPrivateKey = ( privateKey ) : boolean => { return isKeyString ( privateKey , 64 ) ; } ; isPrivateKey . validator = 'isPrivateKey' ; export const isPublicKey = ( publicKey ) : boolean => { return isKeyString ( publicKey , 66 ) ; } ; isPublicKey . validator = 'isPublicKey' ; export const isHash = ( hash ) : boolean => { return isKeyString ( hash , 64 ) ; } ; isHash . validator = 'isHash' ; param { any } obj return { Boolean } export const isNumber = ( obj ) : boolean => { return obj === + obj ; } ; isNumber . validator = 'isNumber' ; param { any } obj return { boolean } export const isInt = ( obj ) : boolean => { return isNumber ( obj ) && Number . isInteger ( obj ) ; } ; isInt . validator = 'isInt' ; param { any } obj return { Boolean } export const isString = ( obj ) : boolean => { return obj === `${ obj }` ; } ; isString . validator = 'isString' ; param { any } obj return { Boolean } export const isBoolean = ( obj ) : boolean => { return obj === ! ! obj ; } ; isBoolean . validator = 'isBoolean' ; param { any } obj return { Boolean } export const isArray = ( obj ) : boolean => { return Array . isArray ( obj ) ; } ; isArray . validator = 'isArray' ; param { any } obj return { Boolean } export const isJsonString = ( obj ) : boolean => { try { return ! ! JSON . parse ( obj ) && isObject ( JSON . parse ( obj ) ) ; } catch ( e ) { return false ; } } ; isJsonString . validator = 'isJsonString' ; param { any } obj return { Boolean } export const isObject = ( obj ) : boolean => { return obj !== null && ! Array . isArray ( obj ) && typeof obj === 'object' ; } ; isObject . validator = 'isObject' ; param { any } obj return { Boolean } export const isFunction = ( obj ) : boolean => { return typeof obj === 'function' ; } ; isFunction . validator = 'isFunction' ; export const isHex = ( obj ) : boolean => { if ( ! isString ( obj ) ) { throw new Error ( `${ obj } is not string` ) ; } return ( ( obj . startsWith ( '0x' ) || obj . startsWith ( '-0x' ) ) && isNumber ( Number . parseInt ( `${ obj }` . toLowerCase ( ) . replace ( '0x' , '' ) , 16 ) ) ) ; } ; isHex . validator = 'isHex' ; export const isHttp = ( obj ) : boolean => { if ( ! isString ( obj ) ) { throw new Error ( `${ obj } is not valid url` ) ; } else { return obj . startsWith ( 'http://' ) || obj . startsWith ( 'https://' ) ; } } ; isHttp . validator = 'isHttp' ; export const isWs = ( obj ) : boolean => { if ( ! isString ( obj ) ) { throw new Error ( `${ obj } is not valid url` ) ; } else { return obj . startsWith ( 'ws://' ) || obj . startsWith ( 'wss://' ) ; } } ; isWs . validator = 'isWs' ; export enum DefaultBlockParams { earliest = 'earliest' , pending = 'pending' , latest = 'latest' } export const isBlockNumber = ( obj ) : boolean => { const blockParams = [ DefaultBlockParams . earliest , DefaultBlockParams . pending , DefaultBlockParams . latest , ] ; if ( ! isString ( obj ) ) { throw new Error ( `${ obj } is not valid blockNumber` ) ; } return isHex ( obj ) || blockParams . some ( ( val ) => val === obj ) ; } ; isBlockNumber . validator = 'isBlockNumber' ; export const isBech32Address = ( raw ) : boolean => { return ! ! raw . match ( /^one1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{38}/ ) ; } ; isBech32Address . validator = 'isBech32Address' ; export const isBech32TestNetAddress = ( raw ) : boolean => { return ! ! raw . match ( /^tone1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{38}/ ) ; } ; isBech32TestNetAddress . validator = 'isBech32TestNetAddress' ; export const isValidAddress = ( address ) : 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' ;