Documentation
    Preparing search index...

    Interface AccountFetcher<T, AccountFetchOptions>

    Interface for fetching and caching on-chain accounts

    interface AccountFetcher<T, AccountFetchOptions> {
        getAccount: <U>(
            address: Address,
            parser: ParsableEntity<U>,
            opts?: AccountFetchOptions,
        ) => Promise<null | U>;
        getAccounts: <U>(
            address: Address[],
            parser: ParsableEntity<U>,
            opts?: AccountFetchOptions,
        ) => Promise<ReadonlyMap<string, null | U>>;
        getAccountsAsArray: <U>(
            address: Address[],
            parser: ParsableEntity<U>,
            opts?: AccountFetchOptions,
        ) => Promise<readonly (null | U)[]>;
        populateAccounts: <U>(
            accounts: ReadonlyMap<string, null | U>,
            parser: ParsableEntity<U>,
            now: number,
        ) => void;
    }

    Type Parameters

    • T
    • AccountFetchOptions

    Implemented by

    Index

    Properties

    getAccount: <U>(
        address: Address,
        parser: ParsableEntity<U>,
        opts?: AccountFetchOptions,
    ) => Promise<null | U>

    Fetch an account from the cache or from the network

    Type declaration

    getAccounts: <U>(
        address: Address[],
        parser: ParsableEntity<U>,
        opts?: AccountFetchOptions,
    ) => Promise<ReadonlyMap<string, null | U>>

    Fetch multiple accounts from the cache or from the network

    Type declaration

      • <U>(
            address: Address[],
            parser: ParsableEntity<U>,
            opts?: AccountFetchOptions,
        ): Promise<ReadonlyMap<string, null | U>>
      • Type Parameters

        • U

        Parameters

        • address: Address[]

          A list of account addresses to fetch from cache or network

        • parser: ParsableEntity<U>

          The parser to used for theses accounts

        • Optionalopts: AccountFetchOptions

          Options when fetching the accounts

        Returns Promise<ReadonlyMap<string, null | U>>

        a Map of addresses to accounts. The ordering of the Map iteration is the same as the ordering of the input addresses.

    getAccountsAsArray: <U>(
        address: Address[],
        parser: ParsableEntity<U>,
        opts?: AccountFetchOptions,
    ) => Promise<readonly (null | U)[]>

    Fetch multiple accounts from the cache or from the network and return as an array

    Type declaration

      • <U>(
            address: Address[],
            parser: ParsableEntity<U>,
            opts?: AccountFetchOptions,
        ): Promise<readonly (null | U)[]>
      • Type Parameters

        • U

        Parameters

        • address: Address[]

          A list of account addresses to fetch from cache or network

        • parser: ParsableEntity<U>

          The parser to used for theses accounts

        • Optionalopts: AccountFetchOptions

          Options when fetching the accounts

        Returns Promise<readonly (null | U)[]>

        an array of accounts. The ordering of the array is the same as the ordering of the input addresses.

    populateAccounts: <U>(
        accounts: ReadonlyMap<string, null | U>,
        parser: ParsableEntity<U>,
        now: number,
    ) => void

    Populate the cache with the given accounts.

    Type declaration

      • <U>(
            accounts: ReadonlyMap<string, null | U>,
            parser: ParsableEntity<U>,
            now: number,
        ): void
      • Type Parameters

        • U

        Parameters

        • accounts: ReadonlyMap<string, null | U>

          A list of accounts addresses to fetched accounts to populate the cache with

        • parser: ParsableEntity<U>

          The parser that was used to parse theses accounts

        • now: number

          The timestamp to use for the cache entries

        Returns void