Class Args

Storage and serialization class for remote function call arguments.

Remarks

This class can serialize typescript native types into bytes, in order to make smart-contract function call easier. It also can deserialize bytes.

Constructors

  • Constructor to either serialize or deserialize data passed from/to DApps and remote Smart contracts.

    Parameters

    • serialized: Uint8Array = ...

      The optional serialized arguments to deserialize.

    • offset: number = DEFAULT_OFFSET

      The optional offset to start deserializing from.

    Returns Args

Properties

argsList: IParam[] = []
offset: number = DEFAULT_OFFSET

The optional offset to start deserializing from.

serialized: Uint8Array = ...

The optional serialized arguments to deserialize.

Methods

  • Adds an array of objects to the serialized arguments.

    Parameters

    Returns this

    the serialized arguments to be able to chain add method calls.

    Remarks

    If the type of the values of the array is not native type, this will serialize the pointers, which is certainly not what you want! You can only serialize properly array of native types or array of Serializable object.

    See

    addSerializableObjectArray

  • Adds a boolean to the serialized arguments.

    Parameters

    • value: boolean

      the boolean to add.

    Returns this

    the serialized arguments to be able to chain add method calls.

  • Adds a floating number to the serialized arguments.

    Parameters

    • value: number

      the number to add.

    Returns this

    the serialized arguments to be able to chain add method calls.

  • Adds a long floating number to the serialized arguments.

    Parameters

    • value: number

      the number to add.

    Returns this

    the serialized arguments to be able to chain add method calls.

  • Adds a signed long integer to the serialized arguments.

    Parameters

    • value: bigint

      the number to add.

    Returns this

    the serialized arguments to be able to chain add method calls.

  • Adds a signed short integer to the serialized arguments.

    Parameters

    • value: bigint

      the number to add.

    Returns this

    the serialized arguments to be able to chain add method calls.

  • Adds a signed long integer to the serialized arguments.

    Parameters

    • value: bigint

      the number to add.

    Returns this

    the serialized arguments to be able to chain add method calls.

  • Adds a signed integer to the serialized arguments.

    Parameters

    • value: bigint

      the number to add.

    Returns this

    the serialized arguments to be able to chain add method calls.

  • Adds a signed long integer to the serialized arguments.

    Parameters

    • value: bigint

      the number to add.

    Returns this

    the serialized arguments to be able to chain add method calls.

  • Adds a signed byte to the serialized arguments.

    Parameters

    • value: bigint

      the number to add.

    Returns this

    the serialized arguments to be able to chain add method calls.

  • Adds a serializable object to the serialized arguments.

    Type Parameters

    • T

    Parameters

    Returns this

    the serialized arguments to be able to chain add method calls.

    Remarks

    The object must implement the ISerializable interface

    See

    ISerializable

  • Adds an array of serializable objects to the serialized arguments.

    Type Parameters

    Parameters

    • arg: T[]

      the argument to add

    Returns this

    the serialized arguments to be able to chain add method calls.

    Remarks

    Each object must implement the ISerializable interface. This will perform a deep copy of your objects thanks to the ISerializable.serialize method you define in your class.

    See

    ISerializable

  • Adds a string to the serialized arguments.

    Parameters

    • value: string

      the number to add.

    Returns this

    the serialized arguments to be able to chain add method calls.

    Remarks

    Works only if the argument is an instance of a handled type (String of 4294967295 characters maximum)

  • Adds an unsigned long integer to the serialized arguments.

    Parameters

    • bigInt: bigint

    Returns this

    the serialized arguments to be able to chain add method calls.

  • Adds an unsigned long integer to the serialized arguments.

    Parameters

    • bigInt: bigint

    Returns this

    the serialized arguments to be able to chain add method calls.

  • Adds an unsigned integer to the serialized arguments.

    Parameters

    • value: bigint

      the number to add.

    Returns this

    the serialized arguments to be able to chain add method calls.

  • Adds an unsigned long integer to the serialized arguments.

    Parameters

    • value: bigint

      the number to add.

    Returns this

    the serialized arguments to be able to chain add method calls.

  • Adds a unsigned byte to the serialized arguments.

    Parameters

    • value: bigint

      the number to add.

    Returns this

    the serialized arguments to be able to chain add method calls.

  • Adds a byte array integer to the serialized arguments.

    Parameters

    • array: Uint8Array

      the array to add.

    Returns this

    the serialized arguments to be able to chain add method calls.

  • Returns the data of requested size for current offset

    Parameters

    • size: number

      The data size

    Returns Uint8Array

    the slice of the serialized internal buffer

  • Returns the current deserialization offset of the serialized byte array.

    Returns number

    the current offset

  • Returns the next array of ArgTypes objects in the serialized byte array

    Type Parameters

    • T

    Parameters

    • type: ArrayTypes

      the type of the elements in the array.

    Returns T[]

    the next array of object that are native type

    Remarks

    Increments to offset to point the data after the one that as been deserialized in the byte array.

  • Returns the next boolean in the serialized byte array.

    Returns boolean

    the deserialized boolean.

    Remarks

    Increments to offset to point the data after the one that as been deserialized in the byte array.

  • Returns the next floating number in the serialized byte array.

    Returns number

    the deserialized number.

    Remarks

    Increments to offset to point the data after the one that as been deserialized in the byte array.

  • Returns the next long floating number in the serialized byte array.

    Returns number

    the deserialized number.

    Remarks

    Increments to offset to point the data after the one that as been deserialized in the byte array.

  • Returns the next signed long integer in the serialized byte array.

    Returns bigint

    the deserialized number.

    Remarks

    Increments to offset to point the data after the one that as been deserialized in the byte array.

  • Returns the next signed short integer in the serialized byte array.

    Returns bigint

    the deserialized number.

    Remarks

    Increments to offset to point the data after the one that as been deserialized in the byte array.

  • Returns the next signed long integer in the serialized byte array.

    Returns bigint

    the deserialized number.

    Remarks

    Increments to offset to point the data after the one that as been deserialized in the byte array.

  • Returns the next signed integer in the serialized byte array.

    Returns bigint

    the deserialized number.

    Remarks

    Increments to offset to point the data after the one that as been deserialized in the byte array.

  • Returns the next signed long integer in the serialized byte array.

    Returns bigint

    the deserialized number.

    Remarks

    Increments to offset to point the data after the one that as been deserialized in the byte array.

  • Returns the next signed byte in the serialized byte array.

    Returns bigint

    the deserialized number.

    Remarks

    Increments to offset to point the data after the one that as been deserialized in the byte array.

  • Parameters

    • extractor: ((buffer, offset) => {
          offset: number;
          value: bigint;
      })
        • (buffer, offset): {
              offset: number;
              value: bigint;
          }
        • Parameters

          • buffer: Uint8Array
          • offset: number

          Returns {
              offset: number;
              value: bigint;
          }

          • offset: number
          • value: bigint

    Returns bigint

  • Returns the next ISerializable object in the serialized byte array

    Type Parameters

    Parameters

    • ctor: (new () => T)

      the class constructor prototype T.prototype

        • new (): T
        • Returns T

    Returns T

    the deserialized object T

    Remarks

    Increments to offset to point the data after the one that as been deserialized in the byte array.

  • Returns the next array of ISerializable objects in the serialized byte array

    Type Parameters

    Parameters

    • ctor: (new () => T)

      the class constructor prototype T.prototype

        • new (): T
        • Returns T

    Returns T[]

    the deserialized array of object that implement ISerializable

    Remarks

    Increments to offset to point the data after the one that as been deserialized in the byte array.

  • Returns the next string in the serialized byte array.

    Returns string

    the deserialized string

    Remarks

    Increments to offset to point the data after the one that as been deserialized in the byte array.

  • Returns the next uint128 in the serialized byte array.

    Returns bigint

    the deserialized number.

    Remarks

    Increments to offset to point the data after the one that as been deserialized in the byte array.

  • Returns the next unsigned short integer in the serialized byte array.

    Returns bigint

    the deserialized number.

    Remarks

    Increments to offset to point the data after the one that as been deserialized in the byte array.

  • Returns the next uint256 in the serialized byte array.

    Returns bigint

    the deserialized number.

    Remarks

    Increments to offset to point the data after the one that as been deserialized in the byte array.

  • Returns the next unsigned integer in the serialized byte array.

    Returns bigint

    the deserialized number

    Remarks

    Increments to offset to point the data after the one that as been deserialized in the byte array.

  • Returns the next long integer in the serialized byte array.

    Returns bigint

    the deserialized number.

    Remarks

    Increments to offset to point the data after the one that as been deserialized in the byte array.

  • Returns the next unsigned byte in the serialized byte array.

    Returns bigint

    the deserialized number.

    Remarks

    Increments to offset to point the data after the one that as been deserialized in the byte array.

  • Returns the next sub byte array in the serialized byte array.

    Returns Uint8Array

    the deserialized byte array.

    Remarks

    Increments to offset to point the data after the one that as been deserialized in the byte array.

  • Internal function to concat to Uint8Array.

    Parameters

    • a: Uint8Array

      first array to concat

    • b: Uint8Array

      second array to concat

    Returns Uint8Array

    the concatenated array