Options
All
  • Public
  • Public/Protected
  • All
Menu

Module muta-utils

Index

Variables

Const RECIDS

RECIDS: number[] = [0, 1, 2, 3]

Const safeParseJSON

safeParseJSON: parse = parse

A safe alternative to JSON.parse

Const safeStringifyJSON

safeStringifyJSON: stringify = stringify

A safe alternative to JSON.stringify

Functions

addressFromPublicKey

  • addressFromPublicKey(publicKey: Uint8Array | Buffer | Bytes, prefix?: undefined | string): Address

appendTransactionSignature

createTransactionSignature

decodeAddress

  • decodeAddress(addressBuf: Buffer, prefix?: string): Address

decodeEncryption

  • decode RPL encoded encryption

    example
    // decode signed transaction encryption
    const signedTransaction = signTransaction(...);
    const decoded1 = decodeEncryption(signedTransaction)
    
    // or just pass the signature and pubkey manually
    const decoded2 = decodeEncryption({
      signature: '0x...',
      pubkey: '0x...',
    }, toHex)
    throws

    Error

    Type parameters

    • T

    Parameters

    Returns DecodedEncryption<T>

decodeTransaction

encodeAddress

  • encodeAddress(address: Address): Buffer

encodeTransaction

hexToNum

  • hexToNum(x: string): number

isSignedTransaction

isUint8Array

  • isUint8Array(x: unknown): x is Uint8Array

isValidHexString

  • isValidHexString(x: unknown): boolean

isValidNumber

  • isValidNumber(x: number): boolean

keccak

  • keccak(buffer: Buffer): Buffer

pad0x

  • pad0x(x: string): string
  • pad a hex string to an even length

    example
    pad0x('1') // 0x01
    pad0x('001') // 0x0001
    pad0x('10') // 0x10

    Parameters

    • x: string

    Returns string

privateKeyToPublicKey

  • privateKeyToPublicKey(privateKey: Buffer | Uint8Array): Buffer

randomAddress

  • randomAddress(prefix?: undefined | string): Address

randomHex

  • randomHex(n: number): Bytes

randomNonce

rm0x

  • rm0x(hex: string): string
  • TRY to remove 0x from a hex string if no 0x starts, do nothing

    Parameters

    • hex: string

      string

    Returns string

separateOutEncryption

separateOutRawTransaction

signTransaction

startsWith0x

  • startsWith0x(x: string): boolean

toBuffer

  • toBuffer(x: string | Buffer | Uint8Array): Buffer
  • parse a hex string to buffer, if x is already a Buffer, do nothing

    Parameters

    • x: string | Buffer | Uint8Array

      , string or Buffer,

    Returns Buffer

toHex

  • toHex(x: Uint8Array | Buffer | number | string | BigNumber): string
  • convert a string to an even length hexadecimal representation string

    example
    toHex('0xff') // '0xff'
    toHex('0x000ff') // '0xff'
    toHex('0xfff') // '0x0fff'
    toHex('99') // '0x99'

    Parameters

    • x: Uint8Array | Buffer | number | string | BigNumber

    Returns string

toTxHash

toUint8Array

  • toUint8Array(x: Bytes | Buffer | Uint8Array): Uint8Array

verifyTransaction

  • verify a signature is signed by an address, will only verify the signature and the transaction when the address is not provided. This method only provides an offline signature verification algorithm, so it does not support scenarios like MultiSignatureService where weighted and weighted verification is handled on the server side.

    Parameters

    Returns boolean

Generated using TypeDoc