import { transactions } from 'near-api-js'; import type { IGetOptions, IGrantWritePermissionWithAccountIdOptions, IGrantWritePermissionWithPublicKeyOptions, IIsWritePermissionGrantedWithAccountIdOptions, IIsWritePermissionGrantedWithPublicKeyOptions, INewSocialOptions, ISetOptions, IStorageDepositOptions, IStorageWithdrawOptions, IKeysOptions, IIndexOptions } from "../types"; export default class Social { private readonly _contractId; private readonly _provider; private readonly _apiServer?; constructor(options?: INewSocialOptions); /** * private static methods */ /** * Initializes the provider with the supplied network options. If the network options are empty, the default mainnet * is used. * @param {string | IRPCOptions} networkIDOrRPCOptions - [optional] a network ID or the RPC options to initialize a * provider. * @returns {providers.JsonRpcProvider} an initialized provider to query the network with. * @throws {UnknownNetworkError} if a network ID is supplied, but is not known. * @private * @static */ private static _initializeProvider; /** * private methods */ /** * Gets the access key view. * @param {IAccount} account - the account ID and public key of the account. * @returns {Promise} a promise that resolves to the access key view or null if the access key * for the given public key does not exist. * @private */ private _accessKeyView; /** * Queries the node to get the latest block hash. * @returns {Promise} a promise that resolves to the latest block hash. The hash will be a base58 encoded string. * @private */ private _latestBlockHash; private _storageBalanceOf; private _isStorageBalance; private _uniqueAccountIdsFromKeys; /** * public methods */ /** * Reads the data for given set of keys. * @param {IGetOptions} options - the set of keys to read and other options. * @returns {Promise>} a promise that resolves to the given data. * @public */ get({ keys, blockHeight, returnDeleted, withBlockHeight, withNodeId, withTimestamp, useApiServer, }: IGetOptions): Promise>; /** * Retrieves a list of keys that match the specified path pattern. * This method is useful for querying data structure without reading actual values. * @param {IKeysOptions} options - The options for querying keys. * @param {string[]} options.keys - The set of key patterns to match. * @param {number} [options.blockHeight] - The block height to query from (optional). * @param {boolean} [options.returnDeleted] - Whether to include deleted keys in the result (optional). * @param {string} [options.returnType] - Specifies the type of data to return (optional). * @param {boolean} [options.valuesOnly] - If true, returns only values without keys (optional). * @param {boolean} [options.useApiServer=true] - Whether to use the API server or view function using RPC (default: true). * @returns {Promise>} A promise that resolves to the matching keys and their metadata. */ keys({ keys, blockHeight, returnDeleted, returnType, valuesOnly, useApiServer, }: IKeysOptions): Promise>; /** * Retrieves indexed values based on specified criteria from the Social API server. * This function allows querying of indexed data, which can be used * for efficient lookups of social interactions or custom indexed data. It supports * filtering by action type (e.g., likes, follows), specific keys, and optionally by * account IDs. The results can be ordered and paginated for flexible data retrieval. * * Use cases include: * - Fetching all 'like' actions for a specific post * - Retrieving recent 'follow' actions for a user * - Querying custom indexed data based on application-specific schemas * * @param {IIndexOptions} options - The options for querying indexed values. * @param {string} options.action - The index_type from the standard (e.g., 'like' in the path 'index/like'). * @param {string} options.key - The inner indexed value from the standard. * @param {string|string[]} [options.accountId] - Optional. A string or array of account IDs to filter values. * @param {'asc'|'desc'} [options.order='asc'] - Optional. The order of results. Either 'asc' or 'desc'. * @param {number} [options.limit=100] - Optional. The number of values to return. * @param {number} [options.from] - Optional. The starting point for fetching results. Defaults to 0 or Max depending on order. * @returns {Promise>} A promise that resolves to an array of matched indexed values, ordered by blockHeight. */ index({ action, key, accountId, order, limit, from, }: IIndexOptions): Promise>; /** * Gets the current version of the social contract. * @returns {Promise} a promise that resolves to the current version of the contract. * @public */ getVersion(): Promise; /** * Grants permission for a set of keys and an account, specified by the `options.granteeAccountId`. * The `options.signer` must be the owner of the set of keys. * @param {IGrantWritePermissionWithAccountIdOptions | IGrantWritePermissionWithPublicKeyOptions} options - the list of keys and the grantee account ID. * @returns {Promise} a promise that resolves to a transaction that is ready to be signed * and sent to the network. * @throws {InvalidAccountIdError} if the grantee account ID or the account ID specified in the keys is invalid. * @throws {KeyNotAllowedError} if account IDs specified in the keys does not match the signer (granter) account ID. * @public */ grantWritePermission(options: IGrantWritePermissionWithAccountIdOptions | IGrantWritePermissionWithPublicKeyOptions): Promise; /** * Checks if an account, specified in `options.granteeAccountId`, has been granted write access for a key. If the * signer and the supplied `options.granteeAccountId` match, true will be returned. * @param {IIsWritePermissionGrantedWithAccountIdOptions | IIsWritePermissionGrantedWithPublicKeyOptions} options - the key and the grantee account ID. * @returns {Promise} a promise that resolves to true, if the grantee account ID has write access for the * given key, or false. * @throws {InvalidAccountIdError} if the grantee account ID is not a valid account ID. * @public */ isWritePermissionGranted(options: IIsWritePermissionGrantedWithAccountIdOptions | IIsWritePermissionGrantedWithPublicKeyOptions): Promise; /** * Stores some data to the contract for a given set of keys. The `options.data`'s top-level key should be an account * ID to which the nested data is stored. The signer's public key should have permission to write to the keys. * @param {ISetOptions} options - the necessary options to set some data. * @returns {Promise} a promise that resolves to a transaction that is ready to be signed * and sent to the network. * @public */ set({ account, blockHash, data, nonce, refundUnusedDeposit, }: ISetOptions): Promise; /** * Deposit NEAR to the social DB contract for covering storage for the given account_id or the signer if acount_id is not provided. * It also let you choose the option to pay bare minimum deposit for registering the account in the Social DB contract without any additional storage fees. * @param {IStorageDepositOptions} options - the necessary options to deposit NEAR for covering storage for the account_id or the signer. * @returns {Promise} a promise that resolves to a transaction that is ready to be signed * and sent to the network. * @public */ storageDeposit({ account, blockHash, nonce, registrationOnly, accountId, deposit, }: IStorageDepositOptions): Promise; /** * Withdraw available NEAR from the social DB contract for covering storage. * If amount is not specified than all available NEAR is withdrawn. * @param {IStorageWithdrawOptions} options - define the amount to be withdrawn. * @returns {Promise} a promise that resolves to a transaction that is ready to be signed * and sent to the network. * @public */ storageWithdraw({ account, blockHash, amount, nonce, }: IStorageWithdrawOptions): Promise; } //# sourceMappingURL=Social.d.ts.map