How to use the @waves/marshall.schemas.txFields function in @waves/marshall

To help you get started, we’ve selected a few @waves/marshall examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wavesplatform / waves-transactions / src / requests / custom-data.ts View on Github external
export function serializeCustomData(d: TCustomData){
  if (d.version === 1) {
    return concat([255, 255, 255, 1], serializePrimitives.BASE64_STRING(d.binary))
  } else if (d.version === 2) {
    const ser = binary.serializerFromSchema(schemas.txFields.data[1])
    return concat([255, 255, 255, 2], ser(d.data))
  } else {
    throw new Error(`Invalid CustomData version: ${d!.version}`)
  }
}
github wavesplatform / waves-transactions / src / proto-serialize.ts View on Github external
IMassTransferItem,
  IMassTransferTransaction,
  IOrder,
  IReissueTransaction, ISetAssetScriptTransaction,
  ISetScriptTransaction, ISponsorshipTransaction,
  ITransaction,
  ITransferTransaction,
  TOrder, TRANSACTION_TYPE, TTransactionType,
  TTx, TTypedData, IUpdateAssetInfoTransaction, TDeleteRequest
} from './transactions'
import { base64Prefix, chainIdFromRecipient, fee, isOrder } from './generic'
import Long from 'long'
import { lease } from './transactions/lease'

const invokeScriptCallSchema = {
  ...schemas.txFields.functionCall[1], withLength: {
    toBytes: serializePrimitives.SHORT,
    fromBytes: parsePrimitives.P_SHORT
  }
}

const recipientFromProto = (recipient: wavesProto.waves.IRecipient, chainId: number): string => {
  if (recipient.alias) {
    return `alias:${String.fromCharCode(chainId)}:${recipient.alias}`
  }
  const rawAddress = concat([1], [chainId], recipient!.publicKeyHash!)
  const checkSum = keccak(blake2b(rawAddress)).slice(0, 4)
  return base58Encode(concat(rawAddress, checkSum))
}

const attachmentFromProto = (a: wavesProto.waves.IAttachment | undefined | null, preProtoVersion: boolean) => {
  if (a == null) return