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

    Fetches, paginates, casts, and builds transactions around Sui objects.

    Object reads use the configured SuiGrpcClient and therefore perform network I/O unless a method is explicitly described as a local transaction builder. gRPC object views expose JSON under json; request withDisplay when a caster reads the object's Display output. The helper keeps the SDK's JSON-RPC-shaped return types where the public API requires them and documents the conversions on those methods.

    Index
    • Adds a transaction command that transfers an object to the zero address.

      This is a local transaction builder and performs no network I/O. It mutates tx; the caller must still set gas details, sign, and execute the returned transaction. The object is transferred to 0x0, which is the SDK's burn destination.

      Parameters

      • inputs: { object: TransactionObjectArgument; tx: Transaction }

        The transaction being built and the object argument to burn.

      Returns Promise<TransactionObjectArgument>

      The transaction argument returned by transferObjects.

      Errors from the Sui transaction builder when the object argument is invalid.

    • Fetches one object and converts it with a caller-provided caster.

      The fetch performs gRPC network I/O through fetchObject. The caster runs locally after the request and receives the gRPC object view, not the old JSON-RPC SuiObjectResponse envelope.

      Type Parameters

      • ObjectType

      Parameters

      • inputs: {
            objectFromSuiObjectResponse: (object: SuiObjectView) => ObjectType;
            objectId: string;
            withDisplay?: boolean;
        }

        The object ID, caster, and optional Display flag.

      Returns Promise<ObjectType>

      The value produced by objectFromSuiObjectResponse.

      Errors from the gRPC fetch or the caster.

    • Fetches an object batch and casts each successful object locally.

      The fetch performs parallel gRPC network I/O through fetchObjectBatch. Per-object errors dropped by that method never reach the caster.

      Type Parameters

      • ObjectType

      Parameters

      • inputs: {
            include?: ObjectInclude;
            objectFromSuiObjectResponse: (object: SuiObjectView) => ObjectType;
            objectIds: string[];
            withDisplay?: boolean;
        }

        The object IDs, caster, and optional gRPC include or Display flags.

      Returns Promise<ObjectType[]>

      The caster output for each object returned by gRPC.

      Errors from a batch request or the caster.

    • Fetches an object's BCS bytes and converts them with a caller-provided BCS type and deserializer.

      The method performs gRPC network I/O through fetchObjectBcs. It decodes the base64 payload with bcsType.fromBase64 and then calls fromDeserialized locally.

      Type Parameters

      • T
      • U

      Parameters

      • inputs: {
            bcsType: BcsType<U>;
            fromDeserialized: (deserialized: U) => T;
            objectId: string;
        }

        The object ID, BCS schema, and conversion callback. U is the value produced by bcsType; T is the public result.

      Returns Promise<T>

      The value returned by fromDeserialized.

      import { bcs } from "@mysten/sui/bcs";
      import { AftermathApi } from "aftermath-ts-sdk";

      declare const api: AftermathApi;
      const objectId = "0x0000000000000000000000000000000000000000000000000000000000000002";
      const value = await api.Objects().fetchCastObjectBcs({
      objectId,
      bcsType: bcs.u64(),
      fromDeserialized: (amount) => amount,
      });

      Errors from the gRPC fetch, BCS decoding, or the conversion callback.

    • Fetches one object with custom include flags and converts it with a caster.

      The fetch performs gRPC network I/O through fetchObjectGeneral. The caster runs locally and receives the gRPC object view returned by that method.

      Type Parameters

      • ObjectType

      Parameters

      • inputs: {
            include?: ObjectInclude;
            objectFromSuiObjectResponse: (object: SuiObjectView) => ObjectType;
            objectId: string;
        }

        The object ID, caster, and gRPC include flags.

      Returns Promise<ObjectType>

      The value produced by objectFromSuiObjectResponse.

      Errors from the gRPC fetch or the caster.

    • Fetches all owned objects of a Move type and casts them locally.

      The fetch performs paginated gRPC network I/O through fetchObjectsOfTypeOwnedByAddress. The caster receives each successful gRPC object view in page order.

      Type Parameters

      • ObjectType

      Parameters

      • inputs: {
            include?: ObjectInclude;
            objectFromSuiObjectResponse: (object: SuiObjectView) => ObjectType;
            objectType: string;
            walletAddress: string;
            withDisplay?: boolean;
        }

        The owner address, exact Move type, caster, and optional Display or compatibility include flags.

      Returns Promise<ObjectType[]>

      The caster output for every matching owned object.

      Errors from the gRPC client or the caster.

    • Checks whether an object or package can be fetched from the gRPC fullnode.

      This method performs network I/O through getObject. It returns false for any fetch error, including a missing object and an unavailable node, so it does not distinguish absence from transport failure.

      Parameters

      • objectId: string

        The Sui object ID or published package ID to check.

      Returns Promise<boolean>

      true when getObject succeeds, otherwise false.

    • Checks whether an object is owned by an address owner or an object owner.

      The method performs network I/O by fetching the object through gRPC. It returns false when the object has no supported owner arm or when its owner differs from walletAddress.

      Parameters

      • inputs: { objectId: string; walletAddress: string }

        The object ID and wallet or parent-object address to compare with the object's owner.

      Returns Promise<boolean>

      true when either gRPC owner form equals walletAddress.

      An Error when the object fetch fails.

    • Fetches one object with the JSON view required by SDK casters.

      This method performs gRPC network I/O through getObject. It always asks for json: true and requests Display output only when withDisplay is true. The helper wraps a fullnode error in a new Error whose message starts with an error occured fetching object:.

      Parameters

      • inputs: { objectId: string; withDisplay?: boolean }

        The object ID and optional Display flag.

      Returns Promise<SuiObjectView>

      The gRPC object view. A caster that reads Display fields requires withDisplay: true.

      An Error when the fullnode cannot return the object.

    • Fetches objects in gRPC batches of at most 50 IDs.

      This method performs network I/O through getObjects. Requests run in parallel by batch. Each per-object Error arm is dropped, while a request failure for an entire batch rejects the method. When include is omitted, the helper requests json: true and sets display from withDisplay.

      Parameters

      • inputs: { include?: ObjectInclude; objectIds: string[]; withDisplay?: boolean }

        The object IDs and optional gRPC include or Display flags. objectIds are split into requests of 50 IDs or fewer.

      Returns Promise<SuiObjectView[]>

      Successful object views in batch and server order. Missing or otherwise failed individual objects are absent from the result.

      gRPC's getObjects returns (Object | Error)[] — a per-object error arm JSON-RPC's multiGetObjects did not have, delivered as real Error instances. Those entries are dropped rather than handed to a caster: spreading one into objectFromSuiObjectResponse would throw deep inside the cast with a message that names neither the batch nor the missing id.

      This is a deliberate behaviour change and the more forgiving one. Previously a single missing object in a batch threw from inside the caster and lost the whole batch; now the surviving objects are returned. nftsFromSuiObjects already filtered its input, so the app-visible result is unchanged.

      Errors when a batch request fails.

    • Fetches an object's Move contents as BCS and reshapes the response to the SDK's JSON-RPC SuiObjectResponse type.

      This method performs gRPC network I/O through getObject({ content: true }). The returned BCS payload is base64 in data.bcs.bcsBytes; it is not a decoded JavaScript value. gRPC errors are wrapped in an Error whose message starts with an error occured fetching object:.

      Parameters

      • objectId: string

        The object ID to read.

      Returns Promise<SuiObjectResponse>

      A JSON-RPC-shaped response containing the object's identity, owner, Move type, version, and base64 BCS bytes.

      An Error when the fullnode cannot return BCS content.

    • Fetches one object with caller-selected gRPC include flags.

      This method performs gRPC network I/O through getObject. When include is omitted, it requests the JSON view and no Display output. Include flags that a caster reads must be present in the request; missing JSON or Display data is returned as undefined by gRPC rather than synthesized locally. Fullnode failures are wrapped in an Error with the same an error occured fetching object: prefix as fetchObject.

      Parameters

      • inputs: { include?: ObjectInclude; objectId: string }

        The object ID and optional gRPC include flags.

      Returns Promise<SuiObjectView>

      The object view returned by gRPC.

      An Error when the fullnode cannot return the object.

    • Fetches all objects of one Move type owned by an address.

      This method performs paginated gRPC network I/O through listOwnedObjects. It is the typed wrapper around fetchOwnedObjects and uses the fixed object-type filter supplied in objectType. The helper always requests the JSON view and sets the display flag from withDisplay; the include field is accepted for compatibility but is not used to replace those caster flags.

      Parameters

      • inputs: {
            include?: ObjectInclude;
            objectType: string;
            walletAddress: string;
            withDisplay?: boolean;
        }

        The owner address, exact Move object type, optional display request, and compatibility include value. withDisplay controls whether gRPC returns Display output.

      Returns Promise<SuiObjectView[]>

      All matching object views across every page.

      Errors from the gRPC client.

    • Fetches every object owned by an address, optionally filtered by Move type.

      The method performs paginated gRPC network I/O. Each request uses a limit of 50 objects and follows the returned cursor while hasNextPage is true. An empty page, a false hasNextPage, or a missing cursor ends pagination. The helper requests json: true and requests display only when withDisplay is true; the optional include value is not used to override these flags.

      Parameters

      • inputs: {
            include?: ObjectInclude;
            objectType?: string;
            walletAddress: string;
            withDisplay?: boolean;
        }

        The owner address, optional exact Move type filter, display flag, and compatibility include value.

      Returns Promise<SuiObjectView[]>

      All object views returned by the fullnode in page order.

      Errors from the gRPC client.

    • Adds a 0x2::transfer::public_share_object Move call to a transaction.

      This is a local transaction builder and performs no network I/O. It mutates tx; the caller must sign and execute the transaction. objectType is passed as the call's single Move type argument.

      Parameters

      • inputs: { object: TransactionObjectArgument; objectType: string; tx: Transaction }

        The transaction, object argument, and fully qualified Move type of the object.

      Returns Promise<TransactionObjectArgument>

      The transaction argument returned by moveCall.

      Errors from the Sui transaction builder when the object or type is invalid.