import { ApolloClient, ApolloQueryResult, NormalizedCacheObject, OperationVariables, QueryOptions } from '@apollo/client/core'; import { ApiPromise } from '@polkadot/api'; import { Codec, DetectCodec, Signer as PolkadotSigner } from '@polkadot/types/types'; import { SigningManager } from '@polymeshassociation/signing-manager-types'; import BigNumber from 'bignumber.js'; import { HistoricPolyxTransaction } from '../api/entities/Account/types'; import { Account, FungibleAsset, Identity } from '../internal'; import { Query } from '../middleware/types'; import { AccountBalance, ClaimData, ClaimTypeInput, DistributionWithDetails, MiddlewareMetadata, PolkadotConfig, ProtocolFees, ResultSet, SubCallback, SubsidyWithAllowance, TransactionArgument, TxTag, UnsubCallback } from '../types'; /** * @hidden * * Context in which the SDK is being used * * - Holds the polkadot API instance * - Holds the middleware API instance (if any) * - Holds the middleware V2 API instance (if any) * - Holds the Signing Manager (if any) */ export declare class Context { private isDisconnected; polymeshApi: ApiPromise; ss58Format: BigNumber; private readonly _middlewareApi; private _signingManager?; private signingAddress?; private nonce?; private _isArchiveNodeResult?; specVersion: number; specName: string; private readonly unsubChainVersion; /** * @hidden */ private constructor(); /** * @hidden * * Create the Context instance */ static create(params: { polymeshApi: ApiPromise; middlewareApiV2: ApolloClient | null; signingManager?: SigningManager; polkadot?: PolkadotConfig; }): Promise; /** * @hidden * * checks if current node is archive by querying the balance at genesis block * * @note caches first successful result to avoid repeated network calls */ isCurrentNodeArchive(): Promise; /** * @hidden * * @note the signing Account will be set to the Signing Manager's first Account. If the Signing Manager has * no Accounts yet, the signing Account will be left empty */ setSigningManager(signingManager: SigningManager | null): Promise; /** * @hidden */ private get signingManager(); /** * @hidden * * Retrieve a list of Accounts that can sign transactions */ getSigningAccounts(): Promise; /** * @hidden * * Set the signing Account from among the existing ones in the Signing Manager * * @throws if the passed address isn't valid */ setSigningAddress(signingAddress: string): void; /** * @hidden * * @throws if the passed address isn't present in the signing manager */ assertHasSigningAddress(address: string): Promise; /** * @hidden * * Retrieve the Account POLYX balance * * @note can be subscribed to, if connected to node using a web socket */ accountBalance(account?: string | Account): Promise; accountBalance(account: string | Account | undefined, callback: SubCallback): Promise; /** * @hidden * * Retrieve the Account subsidizer relationship. If there is no such relationship, return null * * @note can be subscribed to, if connected to node using a web socket */ accountSubsidy(account?: string | Account): Promise; accountSubsidy(account: string | Account | undefined, callback: SubCallback): Promise; /** * @hidden * * Retrieve all pending subsidies for approval */ getPendingSubsidies(beneficiaryAccount?: string | Account, payingAccounts?: (string | Account)[]): Promise; /** * @hidden * * Retrieve the account that will sign the transaction * * @throws if there is no signing Account associated to the SDK instance */ getSigningAccount(): Account; /** * @hidden * * Retrieve the account that is acting. Like `getSigningAccount`, except this method will consider MultiSig signers * and return the acting MultiSig account instead. This should be used when the account is involved in the extrinsic, * such as accepting a "join identity" authorization. * * @throws if there is no signing Account associated to the SDK instance */ getActingAccount(): Promise; /** * @hidden * * Retrieve the signing Identity * * @throws if there is no Identity associated to the signing Account (or there is no signing Account associated to the SDK instance) */ getSigningIdentity(): Promise; /** * @hidden * * Retrieve the polkadot.js promise client */ getPolymeshApi(): ApiPromise; /** * @hidden * * Retrieve the signing address * * @throws if there is no signing Account associated to the SDK instance */ getSigningAddress(): string; /** * @hidden * * Retrieve the external signer from the Signing Manager */ getExternalSigner(): PolkadotSigner | undefined; /** * @hidden * * Check whether a set of Identities exist */ getInvalidDids(identities: (string | Identity)[]): Promise; /** * @hidden * * Returns an Identity when given a DID string * * @throws if the Identity does not exist */ getIdentity(identity: Identity | string): Promise; /** * @hidden * * Retrieve the protocol fees associated with running specific transactions * * @param tags - list of transaction tags (e.g. [TxTags.asset.CreateAsset, TxTags.asset.RegisterUniqueTicker] or ["asset.createAsset", "asset.registerTicker"]) * @param blockHash - optional hash of the block to get the protocol fees at that block */ getProtocolFees({ tags, blockHash, }: { tags: TxTag[]; blockHash?: string; }): Promise; /** * @hidden * * Return whether the passed transaction can be subsidized */ supportsSubsidy({ tag }: { tag: TxTag; }): boolean; /** * Retrieve the types of arguments that a certain transaction requires to be run * * @param args.tag - tag associated with the transaction that will be executed if the proposal passes */ getTransactionArguments({ tag }: { tag: TxTag; }): TransactionArgument[]; /** * @hidden */ getDividendDistributionsForAssets(args: { assets: FungibleAsset[]; }): Promise; /** * @hidden * * @note no claimTypes value means ALL claim types */ getIdentityClaimsFromChain(args: { targets: (string | Identity)[]; claimTypes?: ClaimTypeInput[] | undefined; trustedClaimIssuers?: (string | Identity)[] | undefined; includeExpired: boolean; }): Promise; /** * @hidden */ getIdentityClaimsFromMiddleware(args: { targets?: (string | Identity)[] | undefined; trustedClaimIssuers?: (string | Identity)[] | undefined; claimTypes?: ClaimTypeInput[] | undefined; includeExpired?: boolean | undefined; size?: BigNumber | undefined; start?: BigNumber | undefined; }): Promise>; /** * @hidden * * Retrieve a list of claims. Can be filtered using parameters * * @param opts.targets - Identities (or Identity IDs) for which to fetch claims (targets). Defaults to all targets * @param opts.trustedClaimIssuers - Identity IDs of claim issuers. Defaults to all claim issuers * @param opts.claimTypes - types of the claims to fetch. Defaults to any type * @param opts.includeExpired - whether to include expired claims. Defaults to true * @param opts.size - page size * @param opts.start - page offset * * @note uses the middleware V2 (optional) */ issuedClaims(opts?: { targets?: (string | Identity)[]; trustedClaimIssuers?: (string | Identity)[]; claimTypes?: ClaimTypeInput[]; includeExpired?: boolean; size?: BigNumber; start?: BigNumber; }): Promise>; /** * Retrieve the middleware client * * @throws if the middleware V2 is not enabled */ get middlewareApi(): ApolloClient; /** * @hidden * * Make a query to the middleware V2 server using the apollo client */ queryMiddleware>(query: QueryOptions): Promise>; /** * @hidden * * Return whether the middleware V2 was enabled at startup */ isMiddlewareEnabled(): boolean; /** * @hidden * * Return whether the middleware V2 is enabled and online */ isMiddlewareAvailable(): Promise; /** * @hidden * * Retrieve the number of the latest finalized block */ getLatestBlock(): Promise; /** * @hidden * * Retrieve the network version */ getNetworkVersion(): Promise; /** * @hidden * * Disconnect the Polkadot API, middleware, and render this instance unusable * * @note after disconnecting, trying to access any property in this object will result * in an error */ disconnect(): Promise; /** * @hidden * * Returns a (shallow) clone of this instance. Useful for providing a separate * Context to Procedures with different signing Accounts */ clone(): Context; /** * @hidden * * Creates an instance of a type as registered in the polymeshApi instance */ createType(type: K, params: unknown): DetectCodec; /** * @hidden * * Set the nonce value */ setNonce(nonce?: BigNumber): void; /** * @hidden * * Retrieve the nonce value */ getNonce(): BigNumber; /** * Retrieve middleware metadata. * Returns null if middleware V2 is disabled * * @note uses the middleware V2 */ getMiddlewareMetadata(): Promise; /** * @hidden * * Retrieve POLYX transactions for a given identity or list of accounts * * @note uses the middleware V2 * @note supports pagination */ getPolyxTransactions(args: { identity?: string | Identity; accounts?: (string | Account)[]; size?: BigNumber; start?: BigNumber; }): Promise>; /** * @hidden */ supportsSubscription(): boolean; /** * @hidden */ assertSupportsSubscription(): void; /** * Get signature for a raw payload string */ getSignature(args: { rawPayload: `0x${string}`; signer?: string | Account | undefined; }): Promise<`0x${string}`>; } //# sourceMappingURL=Context.d.ts.map