Options
All
  • Public
  • Public/Protected
  • All
Menu

Type Parameters

  • TValue

Hierarchy

  • Obj

Index

Constructors

  • new Obj<TValue>(contractId: Uint8Array, spaceId: number, valueDecoder: ((reader: Reader, length: number) => TValue), valueEncoder: ((message: TValue, writer: Writer) => void), defaultValue?: null | (() => null | TValue), system?: bool): Obj<TValue>
  • Initialize a Space object with TKey the type of the keys and TValue the type of the values

    example
    const contractId = Base58.decode('1DQzuCcTKacbs9GGScFTU1Hc8BsyARTPqe');
    const SUPPLY_ID = 1;
    const supply = new Storage.Obj(
    contractId,
    SUPPLY_ID,
    token.uint64.decode,
    token.uint64.encode,
    () => new token.uint64(0)
    );

    Type Parameters

    • TValue

    Parameters

    • contractId: Uint8Array

      the id of the contract

    • spaceId: number

      the id of the space

    • valueDecoder: ((reader: Reader, length: number) => TValue)

      the protobuf decoder for the values

        • (reader: Reader, length: number): TValue
        • Parameters

          • reader: Reader
          • length: number

          Returns TValue

    • valueEncoder: ((message: TValue, writer: Writer) => void)

      the protobuf encoder for the values

        • (message: TValue, writer: Writer): void
        • Parameters

          • message: TValue
          • writer: Writer

          Returns void

    • defaultValue: null | (() => null | TValue) = null

      arrow function that returns the default value

    • system: bool = false

      is system space

    Returns Obj<TValue>

Properties

defaultValue: null | (() => null | TValue)
valueDecoder: ((reader: Reader, length: number) => TValue)

Type declaration

    • (reader: Reader, length: number): TValue
    • Parameters

      • reader: Reader
      • length: number

      Returns TValue

valueEncoder: ((message: TValue, writer: Writer) => void)

Type declaration

    • (message: TValue, writer: Writer): void
    • Parameters

      • message: TValue
      • writer: Writer

      Returns void

Methods

  • get(): null | TValue
  • Get the object from the space

    example
    const myobj = obj.get();
    

    Returns null | TValue

    the object if exists, or the defaultValue if exists, null otherwise

  • put(object: TValue): void
  • Put an object in the space

    example
    obj.put(new test_object(42));
    

    Parameters

    • object: TValue

      object to put

    Returns void

  • remove(): void

Generated using TypeDoc