import { Account, AddressString, Block, ClaimTransaction, Hash256String, InvocationTransaction, NetworkType, RawCallReceipt, SmartContractDefinition, Transaction, TransactionOptions, TransactionReceipt, TransactionResult, Transfer, UpdateAccountNameOptions, UserAccount, UserAccountID, UserAccountProvider, UserAccountProviders } from '@neo-one/client-common-esnext-esm'; import { Monitor } from '@neo-one/monitor-esnext-esm'; import BigNumber from 'bignumber.js'; import { BehaviorSubject, Observable } from 'rxjs'; import { AsyncParallelHook } from 'tapable'; import { SmartContract, SmartContractAny } from './types'; /** * Object which contains the points that can be hooked into on the `Client`. */ export interface ClientHooks { /** * Called before the `Transaction` is relayed. */ readonly beforeRelay: AsyncParallelHook; /** * Called when there is an `Error` thrown during relaying a `Transaction`. */ readonly relayError: AsyncParallelHook; /** * Called after successfully relaying a `Transaction`. */ readonly afterRelay: AsyncParallelHook; /** * Called when the `confirmed` method of a `TransactionResult` is invoked. */ readonly beforeConfirmed: AsyncParallelHook; /** * Called when there is an `Error` thrown during the `confirmed` method of a `TransactionResult`. */ readonly confirmedError: AsyncParallelHook; /** * Called after the `confirmed` method of a `TransactionResult` resolves. */ readonly afterConfirmed: AsyncParallelHook; /** * Called after a constant method is invoked. */ readonly afterCall: AsyncParallelHook; /** * Called when an `Error` is thrown from a constant method invocation. */ readonly callError: AsyncParallelHook; } /** * Properties represent features that a given `UserAccountID` supports. */ export interface UserAccountFeatures { /** * `true` if the `UserAccountID` can be deleted. */ readonly delete: boolean; /** * `true` if the `name` of the `UserAccount` associated with the `UserAccountID` can be updated. */ readonly updateName: boolean; } /** * `Client#block$` `Observable` item. */ export interface BlockEntry { /** * Emitted block. */ readonly block: Block; /** * Network of the block. */ readonly network: NetworkType; } /** * `Client#accountState$` `Observable` item. */ export interface AccountStateEntry { /** * Currently selected `UserAccount` */ readonly currentUserAccount: UserAccount; /** * Blockchain account info for `currentUserAccount` */ readonly account: Account; } /** * Main entrypoint to the `@neo-one/client` APIs. The `Client` class abstracts away user accounts and even how those accounts are provided to your dapp, for example, they might come from an extension like NEX, dapp browser like nOS or through some other integration. * * See the [Client APIs](https://neo-one.io/docs/client-apis) chapter of the main guide for more information. */ export declare class Client = any> { /** * Hook into the lifecycle of various requests. Can be used to automatically add logging, or parameter transformations across the application, for example. */ readonly hooks: ClientHooks; /** * Emits a value whenever a new user account is selected. * * Immediately emits the latest value when subscribed to. */ readonly currentUserAccount$: Observable; /** * Emits a value whenever a new list of user accounts is available. * * Immediately emits the latest value when subscribed to. */ readonly userAccounts$: Observable>; /** * Emits a value whenever a new network is selected. * * Immediately emits the latest value when subscribed to. */ readonly currentNetwork$: Observable; /** * Emits a value whenever a new list of networks user account is available. * * Immediately emits the latest value when subscribed to. */ readonly networks$: Observable>; protected readonly providers$: BehaviorSubject; protected readonly selectedProvider$: BehaviorSubject; private readonly currentNetworkInternal$; private readonly reset$; /** * Emits a value whenever a block is persisted to the blockchain. * * Immediately emits the latest block/network when subscribed to. */ readonly block$: Observable; /** * Emits a value whenever a new user account is selected and whenever a block is persisted to the blockchain. * * Immediately emits the latest value when subscribed to. */ readonly accountState$: Observable; constructor(providersIn: TUserAccountProviders); /** * The configured `UserAccountProvider`s for this `Client` instance. */ readonly providers: TUserAccountProviders; /** * Get the details of the `UserAccount` for a given `UserAccountID`. * * @param idIn `UserAccountID` to find the `UserAccount` for * @returns `UserAccount` or throws an `UnknownAccountError` if one could not be found. */ getUserAccount(idIn: UserAccountID): UserAccount; /** * Sets a `UserAccountID` as the currently selected `UserAccountID`. * * @param idIn `UserAccountID` to select, or `undefined` to deselect the current `UserAccountID`. */ selectUserAccount(idIn?: UserAccountID): Promise; /** * Sets a `NetworkType` as the currently selected `NetworkType`. * * @param networkIn `NetworkType` to select. */ selectNetwork(networkIn: NetworkType): Promise; /** * @returns `Promise` which resolves to the `UserAccountFeatures` supported by the given `UserAccountID`. */ getSupportedFeatures(idIn: UserAccountID): Promise; /** * Deletes the `UserAccountID` from its underlying provider. Throws an `DeleteUserAccountUnsupportedError` if the operation is unsupported. * * Users should check `getSupportedFeatures` before calling this method. */ deleteUserAccount(idIn: UserAccountID): Promise; /** * Updates the name of the `UserAccountID` in the underlying provider. Throws an `UpdateUserAccountUnsupportedError` if the operation is unsupported. * * Users should check `getSupportedFeatures` before calling this method. */ updateUserAccountName(options: UpdateAccountNameOptions): Promise; /** * @returns the currently selected `UserAccount` or `undefined` if there are no `UserAccount`s. */ getCurrentUserAccount(): UserAccount | undefined; /** * @returns the currently selected `NetworkType` */ getCurrentNetwork(): NetworkType; /** * @returns a list of all available `UserAccount`s */ getUserAccounts(): ReadonlyArray; /** * @returns a list of all available `NetworkType`s */ getNetworks(): ReadonlyArray; /** * Constructs a `SmartContract` instance for the provided `definition` backed by this `Client` instance. */ smartContract = SmartContractAny>(definition: SmartContractDefinition): T; /** * Transfer native assets in the specified amount(s) to the specified Address(es). * * Accepts either a single transfer or an array of transfer objects. * * Note that we use an `InvocationTransaction` for transfers in order to reduce the overall bundle size since they can be used equivalently to `ContractTransaction`s. * * @returns `Promise>`. */ transfer(amount: BigNumber, asset: Hash256String, to: AddressString, options?: TransactionOptions): Promise>; transfer(transfers: ReadonlyArray, options?: TransactionOptions): Promise; /** * Claim all available unclaimed `GAS` for the currently selected account (or the specified `from` `UserAccountID`). */ claim(optionsIn?: TransactionOptions): Promise>; /** * @returns `Promise` which resolves to an `Account` object for the provided `UserAccountID`. */ getAccount(id: UserAccountID, monitor?: Monitor): Promise; protected getProvider(options?: TransactionOptions): TUserAccountProvider; protected getNetworkProvider(network: NetworkType): TUserAccountProvider; protected applyBeforeRelayHook(options: TransactionOptions): Promise; protected addTransactionHooks(res: Promise): Promise; protected getTransfersOptions(argsIn: ReadonlyArray): { readonly transfers: ReadonlyArray; readonly options: TransactionOptions; }; }