aftermath-ts-sdk - v3.3.3
    Preparing search index...

    Adapts SuiGrpcClient response shapes to the JSON-RPC-shaped types exposed by this SDK.

    These methods only reshape values. They do not perform network I/O or mutate their inputs. Fields that gRPC cannot supply are omitted or represented by the documented compatibility value.

    Index
    • Decodes a vector<u8> Move field into a number array.

      gRPC's json view base64-encodes byte vectors ("CQk="), where JSON-RPC returned a number array ([9, 9]). Indexing the gRPC form directly yields a one-character string, so Number(...) of it is NaN, a silently wrong value rather than an error. Always route a byte vector through here.

      A number array or Uint8Array is copied with Array.from, so JSON-RPC-shaped fixtures work without sharing the input array.

      Parameters

      • value: string | Uint8Array<ArrayBufferLike> | number[]

        A gRPC base64 string or an already decoded byte collection.

      Returns number[]

      A new array of byte numbers.

      When a base64 string cannot be decoded.

    • Decodes a base64 string into BCS bytes.

      Parameters

      • base64: string

        The base64-encoded byte string.

      Returns Uint8Array

      A new Uint8Array containing the decoded bytes.

      When base64 is not valid base64.

    • Reshapes a gRPC Coin into a JSON-RPC-shaped CoinStruct.

      coinType is the substring between the first < and the last > in coin.type. A non-generic type is returned unchanged, and any address padding inside the extracted type is preserved. The gRPC coin does not provide previousTransaction, so the returned field is always "".

      Parameters

      • coin: Coin

        The gRPC coin to reshape.

      Returns CoinStruct

      A JSON-RPC-shaped coin struct. The input is not mutated.

    • Reshapes a gRPC Display into a JSON-RPC-shaped display response.

      String values in output become data fields. Non-string values are dropped. Per-field entries in errors do not populate the whole-object error while output exists. When output is absent, all error entries are joined as field: message pairs in an error with code displayError. A null or undefined display returns { data: null, error: null }.

      Parameters

      • display: Display | null | undefined

        The gRPC display response, or null or undefined when no display template or display data is available.

      Returns DisplayFieldsResponse

      The JSON-RPC-shaped display response.

    • Reshapes a gRPC DynamicFieldEntry into a JSON-RPC-shaped DynamicFieldInfo.

      Field mapping (verified live against a real parent object):

      • fieldId -> objectId
      • valueType -> objectType
      • $kind -> type ("DynamicField" | "DynamicObject")
      • name.bcs -> bcsName (base64), bcsEncoding: "base64"

      name.value and bcsName contain the base64 encoding of name.bcs; gRPC does not provide the parsed JSON value. version and digest are omitted because the list response does not provide them.

      Parameters

      • entry: DynamicFieldEntry

        The gRPC dynamic-field entry to reshape.

      Returns DynamicFieldInfo

      The JSON-RPC-shaped dynamic-field information.

    • Builds a SuiObjectResponse from a gRPC object's BCS content.

      The returned data.bcs.bcsBytes is the base64 encoding of content, which is the field consumed by Casting.castObjectBcs. The result includes the object's ID, version, digest, type, owner, and a moveObject BCS record. hasPublicTransfer is omitted because gRPC does not provide it.

      Parameters

      • object: Object<{ content: true }>

        A gRPC object requested with include.content: true.

      Returns SuiObjectResponse

      A JSON-RPC-shaped object response containing the BCS bytes.

    • Reads the transaction out of a gRPC simulateTransaction / executeTransaction result.

      The result is a $kind-discriminated union: a simulation that fails on-chain still returns effects, but under FailedTransaction rather than Transaction. Reading only the success arm silently drops the gas estimate exactly when the caller most needs it. The method returns the arm selected by $kind and does not clone or mutate the transaction result.

      Type Parameters

      • Include extends SimulateTransactionInclude

      Parameters

      • result: SimulateTransactionResult<Include>

        The $kind-discriminated gRPC transaction result.

      Returns Transaction<Include>

      The successful or failed transaction arm.

    • Unwraps a nested Move struct out of JSON-RPC's { type, fields } envelope.

      gRPC's json view returns nested structs bare, such as { value: "..." }, where JSON-RPC returned { type: "0x2::balance::Supply<…>", fields: { value: "…" } }. The type gRPC drops is not recoverable from the nested value itself; where a caster needs it, take it from the enclosing object's own type parameters via Helpers.getObjectType.

      Any non-null object with a fields property whose value is not undefined is unwrapped. Bare structs, primitives, null, and envelopes with an undefined fields value pass through unchanged.

      Type Parameters

      • T

      Parameters

      • value: T | { fields: T }

        The bare struct or JSON-RPC-shaped envelope.

      Returns T

      The nested fields or the original value.

    • Reads a Move UID as a bare object id.

      gRPC's json view flattens UID to a plain string, where JSON-RPC nested it as { id: "0x…" } (and, one level up, { id: { id: "0x…" } }). The method recursively follows id properties until it reaches a string. It does not normalize the address or validate malformed runtime values.

      Parameters

      • value: string | { id: string } | { id: { id: string } }

        A bare ID or a one- or two-level UID envelope.

      Returns string

      The extracted object ID.