Skip to main content

validator

Index

Namespaces

utils

utils:

abiSchemaToJsonSchema

codePointToInt

  • codePointToInt(codePoint: number): number
  • Code points to int


    Parameters

    • codePoint: number

    Returns number

ethAbiToJsonSchema

fetchArrayElement

  • fetchArrayElement(data: unknown[], level: number): unknown
  • Parameters

    • data: unknown[]
    • level: number

    Returns unknown

hexToNumber

  • hexToNumber(value: string): number | bigint
  • Converts value to it’s number representation


    Parameters

    • value: string

    Returns number | bigint

numberToHex

  • Converts value to it’s hex representation


    Parameters

    Returns string

padLeft

  • padLeft(value: ValidInputTypes, characterAmount: number, sign?: string): string
  • Adds a padding on the left of a string, if value is a integer or bigInt will be converted to a hex string.


    Parameters

    Returns string

parseBaseType

  • parseBaseType<T>(type: string): { arraySizes: number[]; baseType?: T; baseTypeSize: undefined | number; isArray: boolean }
  • Type parameters

    • T = string

    Parameters

    • type: string

    Returns { arraySizes: number[]; baseType?: T; baseTypeSize: undefined | number; isArray: boolean }

    • arraySizes: number[]
    • optionalbaseType?: T
    • baseTypeSize: undefined | number
    • isArray: boolean

transformJsonDataToAbiFormat

  • transformJsonDataToAbiFormat(abis: FullValidationSchema, data: Record<string, unknown> | readonly unknown[], transformedData?: unknown[]): unknown[]
  • Parameters

    • abis: FullValidationSchema
    • data: Record<string, unknown> | readonly unknown[]
    • optionaltransformedData: unknown[]

    Returns unknown[]

Classes

Web3Validator

Web3Validator:

constructor

validate

validateJSONSchema

Web3ValidatorError

Web3ValidatorError:

constructor

code

code: number

readonlyerrors

innerError

innerError: undefined | Error | Error[]

readonlyname

name: string

stack

stack: undefined | string

toJSON

  • toJSON(): { code: number; innerError: undefined | Error | Error[]; message: string; name: string }
  • Returns { code: number; innerError: undefined | Error | Error[]; message: string; name: string }

    • code: number
    • innerError: undefined | Error | Error[]
    • message: string
    • name: string

staticconvertToString

  • convertToString(value: unknown, unquotValue?: boolean): string
  • Parameters

    • value: unknown
    • optionalunquotValue: boolean

    Returns string

Type Aliases

EthBaseTypes

EthBaseTypes: bool | bytes | string | uint | int | address | tuple

EthBaseTypesWithMeta

EthBaseTypesWithMeta: `string${string}` | `string${string}[${number}]` | `bytes${string}` | `bytes${string}[${number}]` | `address[${number}]` | `bool[${number}]` | `int${string}` | `int${string}[${number}]` | `uint${string}` | `uint${string}[${number}]` | tuple[] | `tuple[${number}]`

EthExtendedTypes

EthExtendedTypes: hex | number | blockNumber | blockNumberOrTag | filter | bloom

FullValidationSchema

FullValidationSchema: ReadonlyArray<AbiParameter>

JsonSchema

JsonSchema: Optional<SomeJSONSchema, type> & { eth?: string }

ShortValidationSchema

ValidInputTypes

ValidInputTypes: ArrayBuffer | Buffer | bigint | string | number | boolean

ValidationSchemaInput

Web3ValidationErrorObject

Web3ValidationErrorObject: ErrorObject

Web3ValidationOptions

Web3ValidationOptions: { silent: boolean }

Type declaration

  • readonlysilent: boolean

Variables

constVALID_ETH_BASE_TYPES

VALID_ETH_BASE_TYPES: string[]

constvalidator

validator: Web3Validator

Functions

checkAddressCheckSum

  • checkAddressCheckSum(data: string): boolean
  • Checks the checksum of a given address. Will also return false on non-checksum addresses.


    Parameters

    • data: string

    Returns boolean

isAddress

  • Checks if a given string is a valid Ethereum address. It will also check the checksum, if the address has upper and lowercase letters.


    Parameters

    Returns boolean

isBigInt

  • Checks if a given value is a valid big int


    Parameters

    Returns boolean

isBlockNumber

  • isBlockNumber(value: string | number | bigint): boolean
  • Parameters

    • value: string | number | bigint

    Returns boolean

isBlockNumberOrTag

  • isBlockNumberOrTag(value: string | number | bigint): boolean
  • Returns true if given value is valid hex string and not negative, or is a valid BlockTag


    Parameters

    • value: string | number | bigint

    Returns boolean

isBlockTag

  • isBlockTag(value: string): boolean
  • Returns true if the given blockNumber is ‘latest’, ‘pending’, ‘earliest, ‘safe’ or ‘finalized’


    Parameters

    • value: string

    Returns boolean

isBloom

isBoolean

isBuffer

  • checks input if typeof data is valid buffer input


    Parameters

    Returns boolean

isBytes

  • isBytes(value: Uint8Array | number[] | ValidInputTypes, options?: { abiType: string; size?: undefined } | { abiType?: undefined; size: number }): boolean
  • Parameters

    • value: Uint8Array | number[] | ValidInputTypes
    • optionaloptions: { abiType: string; size?: undefined } | { abiType?: undefined; size: number }

    Returns boolean

isContractAddressInBloom

  • isContractAddressInBloom(bloom: string, contractAddress: string): boolean
  • Returns true if the contract address is part of the given bloom. note: false positives are possible.


    Parameters

    • bloom: string
    • contractAddress: string

    Returns boolean

isFilterObject

  • isFilterObject(value: Filter): boolean
  • First we check if all properties in the provided value are expected, then because all Filter properties are optional, we check if the expected properties are defined. If defined and they’re not the expected type, we immediately return false, otherwise we return true after all checks pass.


    Parameters

    Returns boolean

isHex

isHexStrict

isHexString32Bytes

  • isHexString32Bytes(value: string, prefixed?: boolean): boolean
  • Parameters

    • value: string
    • optionalprefixed: boolean

    Returns boolean

isHexString8Bytes

  • isHexString8Bytes(value: string, prefixed?: boolean): boolean
  • Parameters

    • value: string
    • optionalprefixed: boolean

    Returns boolean

isInBloom

  • isInBloom(bloom: string, value: string | Uint8Array): boolean
  • Returns true if the value is part of the given bloom note: false positives are possible.


    Parameters

    • bloom: string
    • value: string | Uint8Array

    Returns boolean

isInt

  • isInt(value: ValidInputTypes, options?: { abiType: string; bitSize?: undefined } | { abiType?: undefined; bitSize: number }): boolean
  • Parameters

    • value: ValidInputTypes
    • optionaloptions: { abiType: string; bitSize?: undefined } | { abiType?: undefined; bitSize: number }

    Returns boolean

isNullish

  • isNullish(item: unknown): item is undefined | null
  • Parameters

    • item: unknown

    Returns item is undefined | null

isNumber

isObject

  • isObject(item: unknown): item is Record<string, unknown>
  • Parameters

    • item: unknown

    Returns item is Record<string, unknown>

isString

  • checks input if typeof data is valid string input


    Parameters

    Returns boolean

isTopic

  • isTopic(topic: string): boolean
  • Checks if its a valid topic


    Parameters

    • topic: string

    Returns boolean

isTopicInBloom

  • isTopicInBloom(bloom: string, topic: string): boolean
  • Returns true if the topic is part of the given bloom. note: false positives are possible.


    Parameters

    • bloom: string
    • topic: string

    Returns boolean

isUInt

  • isUInt(value: ValidInputTypes, options?: { abiType: string; bitSize?: undefined } | { abiType?: undefined; bitSize: number }): boolean
  • Parameters

    • value: ValidInputTypes
    • optionaloptions: { abiType: string; bitSize?: undefined } | { abiType?: undefined; bitSize: number }

    Returns boolean

isUserEthereumAddressInBloom

  • isUserEthereumAddressInBloom(bloom: string, ethereumAddress: string): boolean
  • Returns true if the ethereum users address is part of the given bloom note: false positives are possible.


    Parameters

    • bloom: string
    • ethereumAddress: string

    Returns boolean

isValidEthBaseType

  • isValidEthBaseType(type: string): boolean
  • Parameters

    • type: string

    Returns boolean