Sha256: 7e4158b8892d645d7b44c89e933c875d78422b672236241ad55bfa3aa0268215

Contents?: true

Size: 833 Bytes

Versions: 1

Compression:

Stored size: 833 Bytes

Contents

import {TRANSACTION_TYPE} from '@waves/ts-types'
import {
  isEq,
  orEq,
  isNumber,
  isNumberLike,
  isArray,
  getError,
  validateByShema,
  ifElse,
  defaultValue,
  isPublicKey,
  isValidData,
  isValidDeleteRequest, isNaturalNumberOrZeroLike,
} from './validators'



const dataScheme = {
  type: isEq(TRANSACTION_TYPE.DATA),
  senderPublicKey: isPublicKey,
  version: orEq([undefined, 1, 2]),
  data: (data: Array<unknown> ) =>
      isArray(data) &&
      data.every(item => isValidData(item) || isValidDeleteRequest(item)),
  fee: isNaturalNumberOrZeroLike,
  timestamp: isNumber,
  proofs: ifElse(isArray, defaultValue(true), orEq([ undefined ])),
}

export const dataFieldValidator = (item: unknown ) => isValidData(item) || isValidDeleteRequest(item)

export const dataValidator = validateByShema(dataScheme, getError)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
waves_lib-0.1.0 js/node_modules/@waves/waves-transactions/src/validators/data.ts