Docs
chromia.com

Interface

Session

On this page

An object which allows the user to interact with an account by both querying and submitting signed transactions.

interface Session {
    account: AuthenticatedAccount;
    blockchainRid: Buffer;
    call: (
        ...operations: Operation[],
    ) => Web3PromiEvent<
        TransactionWithReceipt,
        { built: SignedTransaction; sent: Buffer },
    >;
    callWithoutNop: (
        ...operations: Operation[],
    ) => Web3PromiEvent<
        TransactionWithReceipt,
        { built: SignedTransaction; sent: Buffer },
    >;
    client: IClient;
    getAccountAuthDescriptorsFiltered: (
        accountAuthDescriptorFilter?: AccountAuthDescriptorFilter,
        limit?: number,
        cursor?: OptionalPageCursor,
    ) => Promise<PaginatedEntity<AnyAuthDescriptor>>;
    getAccountById: (accountId: BufferId) => Promise<Account | null>;
    getAccountCreationTransfersFiltered: (
        accountCreationTransferFilter?: AccountCreationTransferFilter,
        limit?: number,
        cursor?: OptionalPageCursor,
    ) => Promise<PaginatedEntity<AccountCreationTransfer>>;
    getAccountLinksFiltered: (
        accountLinkFilter?: AccountLinkFilter,
        limit?: number,
        cursor?: OptionalPageCursor,
    ) => Promise<PaginatedEntity<{ account: Account; secondary: Account }>>;
    getAccountsByAuthDescriptorId: (
        id: BufferId,
        limit?: number,
        cursor?: OptionalPageCursor,
    ) => Promise<PaginatedEntity<Account>>;
    getAccountsBySigner: (
        signer: BufferId,
        limit?: number,
        cursor?: OptionalPageCursor,
    ) => Promise<PaginatedEntity<Account>>;
    getAccountsByType: (
        type: string,
        limit?: number,
        cursor?: OptionalPageCursor,
    ) => Promise<PaginatedEntity<Account>>;
    getAccountsFiltered: (
        accountFilter?: AccountFilter,
        limit?: number,
        cursor?: OptionalPageCursor,
    ) => Promise<PaginatedEntity<Account>>;
    getAllAssets: (
        limit?: number,
        cursor?: OptionalPageCursor,
    ) => Promise<PaginatedEntity<Asset>>;
    getApiVersion: () => Promise<number>;
    getAppliedTransfersFiltered: (
        appliedTransferFilter?: TransferFilter,
        limit?: number,
        cursor?: OptionalPageCursor,
    ) => Promise<PaginatedEntity<AppliedTransfer>>;
    getAssetById: (assetId: BufferId) => Promise<Asset | null>;
    getAssetOriginFiltered: (
        assetOriginFilter?: AssetOriginFilter,
        limit?: number,
        cursor?: OptionalPageCursor,
    ) => Promise<PaginatedEntity<AssetOrigin>>;
    getAssetsByName: (
        name: string,
        limit?: number,
        cursor?: OptionalPageCursor,
    ) => Promise<PaginatedEntity<Asset>>;
    getAssetsBySymbol: (
        symbol: string,
        limit?: number,
        cursor?: OptionalPageCursor,
    ) => Promise<PaginatedEntity<Asset>>;
    getAssetsByType: (
        type: string,
        limit?: number,
        cursor?: OptionalPageCursor,
    ) => Promise<PaginatedEntity<Asset>>;
    getAssetsFiltered: (
        assetFilter?: AssetFilter,
        limit?: number,
        cursor?: OptionalPageCursor,
    ) => Promise<PaginatedEntity<Asset>>;
    getAuthDescriptorSignersFiltered: (
        authDescriptorSignerFilter?: AuthDescriptorSignerFilter,
        limit?: number,
        cursor?: OptionalPageCursor,
    ) => Promise<PaginatedEntity<AuthDescriptorSigner>>;
    getAuthDescriptorValidator: (useCache: boolean) => AuthDescriptorValidator;
    getBalancesFiltered: (
        balanceFilter?: BalanceFilter,
        limit?: number,
        cursor?: OptionalPageCursor,
    ) => Promise<PaginatedEntity<Balance>>;
    getBlockHeight: () => Promise<number>;
    getCanceledTransfersFiltered: (
        canceledTransferFilter?: TransferFilter,
        limit?: number,
        cursor?: OptionalPageCursor,
    ) => Promise<PaginatedEntity<Transfer>>;
    getConfig: () => Promise<Config>;
    getCrosschainTransferHistoryEntriesFiltered: (
        crosschainTransferHistoryEntryFilter?: CrosschainTransferHistoryEntryFilter,
        limit?: number,
        cursor?: OptionalPageCursor,
    ) => Promise<PaginatedEntity<CrosschainTransferHistoryEntry>>;
    getEnabledRegistrationStrategies: () => Promise<string[]>;
    getMainAuthDescriptorsFiltered: (
        mainAccountAuthDescriptorFilter?: MainAccountAuthDescriptorFilter,
        limit?: number,
        cursor?: OptionalPageCursor,
    ) => Promise<PaginatedEntity<AnyAuthDescriptor>>;
    getPendingTransfersFiltered: (
        pendingTransferFilter?: PendingTransferFilter,
        limit?: number,
        cursor?: OptionalPageCursor,
    ) => Promise<PaginatedEntity<PendingTransfer>>;
    getRecalledTransfersFiltered: (
        recalledTransferFilter?: TransferFilter,
        limit?: number,
        cursor?: OptionalPageCursor,
    ) => Promise<PaginatedEntity<Transfer>>;
    getRevertedTransfersFiltered: (
        revertedTransferFilter?: TransferFilter,
        limit?: number,
        cursor?: OptionalPageCursor,
    ) => Promise<PaginatedEntity<Transfer>>;
    getRlStatesFiltered: (
        rlStateFilter?: RlStateFilter,
        limit?: number,
        cursor?: OptionalPageCursor,
    ) => Promise<PaginatedEntity<RlState>>;
    getSubscriptionsFiltered: (
        subscriptionFilter?: SubscriptionFilter,
        limit?: number,
        cursor?: OptionalPageCursor,
    ) => Promise<PaginatedEntity<Subscription>>;
    getTransferDetails: (
        txRid: BufferId,
        opIndex: number,
    ) => Promise<TransferDetail[]>;
    getTransferDetailsByAsset: (
        txRid: BufferId,
        opIndex: number,
        assetId: BufferId,
    ) => Promise<TransferDetail[]>;
    getTransferHistoryEntriesFiltered: (
        transferHistoryEntryFilter?: TransferHistoryEntryFilter,
        limit?: number,
        cursor?: OptionalPageCursor,
    ) => Promise<PaginatedEntity<TransferHistoryEntry>>;
    getUnappliedTransfersFiltered: (
        unappliedTransferFilter?: TransferFilter,
        limit?: number,
        cursor?: OptionalPageCursor,
    ) => Promise<PaginatedEntity<Transfer>>;
    getVersion: () => Promise<string>;
    sign: (tx: RawGtx | GTX | SignedTransaction) => Promise<SignedTransaction>;
    signAndSend: (
        tx: RawGtx | GTX | SignedTransaction,
    ) => Promise<TransactionReceipt>;
    transactionBuilder: () => TransactionBuilder;
}

Hierarchy (View Summary)

Properties

account

blockchainRid

blockchainRid: Buffer

Inherited from Connection.blockchainRid

call

call: (
    ...operations: Operation[],
) => Web3PromiEvent<
    TransactionWithReceipt,
    { built: SignedTransaction; sent: Buffer },
>

Builds and sends a transaction containing the specified operations. This method will also make sure to perform the appropriate authentication and signing of each operation, as well as inserting a nop operation at the end to make each transaction unique. If you don't want the tx to include a nop use callWithoutNop instead.

Type Declaration

    • (
          ...operations: Operation[],
      ): Web3PromiEvent<
          TransactionWithReceipt,
          { built: SignedTransaction; sent: Buffer },
      >
    • Parameters

      • ...operations: Operation[]

        the operations to include in the transaction

      Returns Web3PromiEvent<
          TransactionWithReceipt,
          { built: SignedTransaction; sent: Buffer },
      >

callWithoutNop

callWithoutNop: (
    ...operations: Operation[],
) => Web3PromiEvent<
    TransactionWithReceipt,
    { built: SignedTransaction; sent: Buffer },
>

Same as call but it does not include a nop at the end. Meaning that subsequent calls to this function with the same arguments is likely to be rejected.

Type Declaration

    • (
          ...operations: Operation[],
      ): Web3PromiEvent<
          TransactionWithReceipt,
          { built: SignedTransaction; sent: Buffer },
      >
    • Parameters

      • ...operations: Operation[]

        the operations to include in the transaction

      Returns Web3PromiEvent<
          TransactionWithReceipt,
          { built: SignedTransaction; sent: Buffer },
      >

client

client: IClient

Inherited from Connection.client

getAccountAuthDescriptorsFiltered

getAccountAuthDescriptorsFiltered: (
    accountAuthDescriptorFilter?: AccountAuthDescriptorFilter,
    limit?: number,
    cursor?: OptionalPageCursor,
) => Promise<PaginatedEntity<AnyAuthDescriptor>>

Fetches all AccountAuthDescriptors with satisfy the accountAuthDescriptor filter, paginated

Type Declaration

Inherited from Connection.getAccountAuthDescriptorsFiltered

getAccountById

getAccountById: (accountId: BufferId) => Promise<Account | null>

Fetches the account with the specified id

Type Declaration

    • (accountId: BufferId): Promise<Account | null>
    • Parameters

      • accountId: BufferId

        the id of the account to fetch

      Returns Promise<Account | null>

      the account with the specified id, or null if no account with that id exists

Inherited from Connection.getAccountById

getAccountCreationTransfersFiltered

getAccountCreationTransfersFiltered: (
    accountCreationTransferFilter?: AccountCreationTransferFilter,
    limit?: number,
    cursor?: OptionalPageCursor,
) => Promise<PaginatedEntity<AccountCreationTransfer>>

Fetches all AccountCreationTransfers with satisfy the accountCreationTransferFilter filter, paginated

Type Declaration

Inherited from Connection.getAccountCreationTransfersFiltered

getAccountLinksFiltered

getAccountLinksFiltered: (
    accountLinkFilter?: AccountLinkFilter,
    limit?: number,
    cursor?: OptionalPageCursor,
) => Promise<PaginatedEntity<{ account: Account; secondary: Account }>>

Fetches all AccountLinks with satisfy the accountLinkFilter filter, paginated

Type Declaration

Inherited from Connection.getAccountLinksFiltered

getAccountsByAuthDescriptorId

getAccountsByAuthDescriptorId: (
    id: BufferId,
    limit?: number,
    cursor?: OptionalPageCursor,
) => Promise<PaginatedEntity<Account>>

Fetches all accounts with which the auth descriptor with the specified id is associated

Type Declaration

Inherited from Connection.getAccountsByAuthDescriptorId

getAccountsBySigner

getAccountsBySigner: (
    signer: BufferId,
    limit?: number,
    cursor?: OptionalPageCursor,
) => Promise<PaginatedEntity<Account>>

Fetches all accounts with which the provided signer has at least one associated auth descriptor

Type Declaration

Inherited from Connection.getAccountsBySigner

getAccountsByType

getAccountsByType: (
    type: string,
    limit?: number,
    cursor?: OptionalPageCursor,
) => Promise<PaginatedEntity<Account>>

Returns all accounts of the specified type that is registered on the blockchain as a paginated entity

Type Declaration

Inherited from Connection.getAccountsByType

getAccountsFiltered

getAccountsFiltered: (
    accountFilter?: AccountFilter,
    limit?: number,
    cursor?: OptionalPageCursor,
) => Promise<PaginatedEntity<Account>>

Fetches all accounts with satisfy the account filter, paginated

Type Declaration

Inherited from Connection.getAccountsFiltered

getAllAssets

getAllAssets: (
    limit?: number,
    cursor?: OptionalPageCursor,
) => Promise<PaginatedEntity<Asset>>

Retrieves all assets that are registered on a blockchain as a paginated entity

Type Declaration

Inherited from Connection.getAllAssets

getApiVersion

getApiVersion: () => Promise<number>

Returns the API version of ft library installed on the blockchain. It will be an integer.

Inherited from Connection.getApiVersion

getAppliedTransfersFiltered

getAppliedTransfersFiltered: (
    appliedTransferFilter?: TransferFilter,
    limit?: number,
    cursor?: OptionalPageCursor,
) => Promise<PaginatedEntity<AppliedTransfer>>

Retrieves applied transfers based on the selected filter of TransferFilter, paginated

Type Declaration

Returns

paginated results of applied transfers based on the filter selection

Available since ApiVersion 1

Inherited from Connection.getAppliedTransfersFiltered

getAssetById

getAssetById: (assetId: BufferId) => Promise<Asset | null>

Retrieves asset information using its id

Type Declaration

    • (assetId: BufferId): Promise<Asset | null>
    • Parameters

      • assetId: BufferId

        the id of the asset to fetch

      Returns Promise<Asset | null>

Returns

The asset details, or null if no asset with the specified id was found

Inherited from Connection.getAssetById

getAssetOriginFiltered

getAssetOriginFiltered: (
    assetOriginFilter?: AssetOriginFilter,
    limit?: number,
    cursor?: OptionalPageCursor,
) => Promise<PaginatedEntity<AssetOrigin>>

Retrieves assets origin based on the selected filter of AssetOriginFilter, paginated

Type Declaration

Returns

paginated results of assets origin based on the filter selection

Available since ApiVersion 1

Inherited from Connection.getAssetOriginFiltered

getAssetsByName

getAssetsByName: (
    name: string,
    limit?: number,
    cursor?: OptionalPageCursor,
) => Promise<PaginatedEntity<Asset>>

Retrieves asset information using its name. As there can be multiple assets with the same name, the information is returned as a paginated entity.

Type Declaration

Inherited from Connection.getAssetsByName

getAssetsBySymbol

getAssetsBySymbol: (
    symbol: string,
    limit?: number,
    cursor?: OptionalPageCursor,
) => Promise<PaginatedEntity<Asset>>

Retrieves asset information using its symbol. As there can be multiple assets with the same symbol, the information is returned as a paginated entity.

Type Declaration

Inherited from Connection.getAssetsBySymbol

getAssetsByType

getAssetsByType: (
    type: string,
    limit?: number,
    cursor?: OptionalPageCursor,
) => Promise<PaginatedEntity<Asset>>

Retrieves all assets of a specific type, e.g., "ft4", as a paginated entity

Type Declaration

Inherited from Connection.getAssetsByType

getAssetsFiltered

getAssetsFiltered: (
    assetFilter?: AssetFilter,
    limit?: number,
    cursor?: OptionalPageCursor,
) => Promise<PaginatedEntity<Asset>>

Retrieves all assets based on the filtering options provided in AssetFilter and that are registered on a blockchain as a paginated entity

Type Declaration

Inherited from Connection.getAssetsFiltered

getAuthDescriptorSignersFiltered

getAuthDescriptorSignersFiltered: (
    authDescriptorSignerFilter?: AuthDescriptorSignerFilter,
    limit?: number,
    cursor?: OptionalPageCursor,
) => Promise<PaginatedEntity<AuthDescriptorSigner>>

Fetches all AuthDescriptorSigners with satisfy the authDescriptorSigner filter, paginated

Type Declaration

Inherited from Connection.getAuthDescriptorSignersFiltered

getAuthDescriptorValidator

getAuthDescriptorValidator: (useCache: boolean) => AuthDescriptorValidator

Gets a validator instance that can be used to validate if an auth descriptor is valid or not

Type Declaration

Inherited from Connection.getAuthDescriptorValidator

getBalancesFiltered

getBalancesFiltered: (
    balanceFilter?: BalanceFilter,
    limit?: number,
    cursor?: OptionalPageCursor,
) => Promise<PaginatedEntity<Balance>>

Retrieves all balances based on the filtering options provided in BalanceFilter and that are registered on a blockchain as a paginated entity

Type Declaration

Inherited from Connection.getBalancesFiltered

getBlockHeight

getBlockHeight: () => Promise<number>

Returns the current block height of the underlying chain

Inherited from Connection.getBlockHeight

getCanceledTransfersFiltered

getCanceledTransfersFiltered: (
    canceledTransferFilter?: TransferFilter,
    limit?: number,
    cursor?: OptionalPageCursor,
) => Promise<PaginatedEntity<Transfer>>

Retrieves canceled transfers based on the selected filter of in TransferFilter, paginated

Type Declaration

Returns

paginated results of canceled transfers based on the filter selection

Available since ApiVersion 1

Inherited from Connection.getCanceledTransfersFiltered

getConfig

getConfig: () => Promise<Config>

Returns the ft config that is currently in effect

Inherited from Connection.getConfig

getCrosschainTransferHistoryEntriesFiltered

getCrosschainTransferHistoryEntriesFiltered: (
    crosschainTransferHistoryEntryFilter?: CrosschainTransferHistoryEntryFilter,
    limit?: number,
    cursor?: OptionalPageCursor,
) => Promise<PaginatedEntity<CrosschainTransferHistoryEntry>>

Retrieves all crosschain transfer history entries based on the filtering options provided in CrosschainTransferHistoryEntryFilter as a paginated entity

Type Declaration

Inherited from Connection.getCrosschainTransferHistoryEntriesFiltered

getEnabledRegistrationStrategies

getEnabledRegistrationStrategies: () => Promise<string[]>

Returns a list containing the name of all of the enabled strategies

Inherited from Connection.getEnabledRegistrationStrategies

getMainAuthDescriptorsFiltered

getMainAuthDescriptorsFiltered: (
    mainAccountAuthDescriptorFilter?: MainAccountAuthDescriptorFilter,
    limit?: number,
    cursor?: OptionalPageCursor,
) => Promise<PaginatedEntity<AnyAuthDescriptor>>

Fetches all MainAuthDescriptors with satisfy the mainAccountAuthDescriptor filter, paginated

Type Declaration

Inherited from Connection.getMainAuthDescriptorsFiltered

getPendingTransfersFiltered

getPendingTransfersFiltered: (
    pendingTransferFilter?: PendingTransferFilter,
    limit?: number,
    cursor?: OptionalPageCursor,
) => Promise<PaginatedEntity<PendingTransfer>>

Retrieves pending transfers based on the selected filter of PendingTransferFilter, paginated

Type Declaration

Returns

paginated results of pending transfers based on the filter selection

Available since ApiVersion 1

Inherited from Connection.getPendingTransfersFiltered

getRecalledTransfersFiltered

getRecalledTransfersFiltered: (
    recalledTransferFilter?: TransferFilter,
    limit?: number,
    cursor?: OptionalPageCursor,
) => Promise<PaginatedEntity<Transfer>>

Retrieves recalled transfers based on the selected filter of TransferFilter, paginated

Type Declaration

Returns

paginated results of recalled transfers based on the filter selection

Available since ApiVersion 1

Inherited from Connection.getRecalledTransfersFiltered

getRevertedTransfersFiltered

getRevertedTransfersFiltered: (
    revertedTransferFilter?: TransferFilter,
    limit?: number,
    cursor?: OptionalPageCursor,
) => Promise<PaginatedEntity<Transfer>>

Retrieves reverted transfers based on the selected filter of TransferFilter, paginated

Type Declaration

Returns

paginated results of reverted transfers based on the filter selection

Available since ApiVersion 1

Inherited from Connection.getRevertedTransfersFiltered

getRlStatesFiltered

getRlStatesFiltered: (
    rlStateFilter?: RlStateFilter,
    limit?: number,
    cursor?: OptionalPageCursor,
) => Promise<PaginatedEntity<RlState>>

Fetches all Rate limit states with satisfy the rlState filter, paginated

Type Declaration

Inherited from Connection.getRlStatesFiltered

getSubscriptionsFiltered

getSubscriptionsFiltered: (
    subscriptionFilter?: SubscriptionFilter,
    limit?: number,
    cursor?: OptionalPageCursor,
) => Promise<PaginatedEntity<Subscription>>

Fetches all Subscriptions with satisfy the subscriptionFilter filter, paginated

Type Declaration

Inherited from Connection.getSubscriptionsFiltered

getTransferDetails

getTransferDetails: (
    txRid: BufferId,
    opIndex: number,
) => Promise<TransferDetail[]>

Retrieves the details of a transfer

Type Declaration

    • (txRid: BufferId, opIndex: number): Promise<TransferDetail[]>
    • Parameters

      • txRid: BufferId

        the id of the transaction in which the transfer was made

      • opIndex: number

        the index of the transfer operation within the transaction

      Returns Promise<TransferDetail[]>

Returns

Details about the transfer

Inherited from Connection.getTransferDetails

getTransferDetailsByAsset

getTransferDetailsByAsset: (
    txRid: BufferId,
    opIndex: number,
    assetId: BufferId,
) => Promise<TransferDetail[]>

Retrieves details of a transfer but only the details that was made with a specific asset

Type Declaration

    • (txRid: BufferId, opIndex: number, assetId: BufferId): Promise<TransferDetail[]>
    • Parameters

      • txRid: BufferId

        the id of the transaction in which the transfer was made

      • opIndex: number

        the index of the transfer operation within the transaction

      • assetId: BufferId

        the asset id for which to return details

      Returns Promise<TransferDetail[]>

Returns

The transfer details

Inherited from Connection.getTransferDetailsByAsset

getTransferHistoryEntriesFiltered

getTransferHistoryEntriesFiltered: (
    transferHistoryEntryFilter?: TransferHistoryEntryFilter,
    limit?: number,
    cursor?: OptionalPageCursor,
) => Promise<PaginatedEntity<TransferHistoryEntry>>

Retrieves all transfer history entries based on the filtering options provided in TransferHistoryEntryFilter as a paginated entity

Type Declaration

Inherited from Connection.getTransferHistoryEntriesFiltered

getUnappliedTransfersFiltered

getUnappliedTransfersFiltered: (
    unappliedTransferFilter?: TransferFilter,
    limit?: number,
    cursor?: OptionalPageCursor,
) => Promise<PaginatedEntity<Transfer>>

Retrieves unapplied transfers based on the selected filter of TransferFilter, paginated

Type Declaration

Returns

paginated results of unapplied transfers based on the filter selection

Available since ApiVersion 1

Inherited from Connection.getUnappliedTransfersFiltered

getVersion

getVersion: () => Promise<string>

Returns the version of ft library installed on the blockchain with the format ..

Inherited from Connection.getVersion

sign

sign: (tx: RawGtx | GTX | SignedTransaction) => Promise<SignedTransaction>

Signs a transaction using an available key

Type Declaration

    • (tx: RawGtx | GTX | SignedTransaction): Promise<SignedTransaction>
    • Parameters

      • tx: RawGtx | GTX | SignedTransaction

        the transaction to sign

      Returns Promise<SignedTransaction>

      the original transaction with the appropriate signatures added

signAndSend

signAndSend: (
    tx: RawGtx | GTX | SignedTransaction,
) => Promise<TransactionReceipt>

Same as sign but it also submits the resulting transaction to the blockchain.

Type Declaration

    • (tx: RawGtx | GTX | SignedTransaction): Promise<TransactionReceipt>
    • Parameters

      • tx: RawGtx | GTX | SignedTransaction

        the transaction to sign and send

      Returns Promise<TransactionReceipt>

      a receipt with the result of submitting the transaction

transactionBuilder

transactionBuilder: () => TransactionBuilder

Returns a TransactionBuilder instance configured to use the same keys as enclosed in this Session instance.