UserAccountProvider

Interface
UserAccountProviders power Client instances. Multiple UserAccountProviders may be provided, and the Client abstracts over them to provide a common layer of functionality independent of the underlying UserAccountProviders.
export interface UserAccountProvider { 
  readonly currentUserAccount$: Observable<UserAccount | undefined>; 
  readonly userAccounts$: Observable<readonly UserAccount[]>; 
  readonly networks$: Observable<readonly NetworkType[]>; 
  readonly getCurrentUserAccount: () => UserAccount | undefined; 
  readonly getUserAccounts: () => readonly UserAccount[]; 
  readonly getNetworks: () => readonly NetworkType[]; 
  readonly selectUserAccount: (id?: UserAccountID) => Promise<void>; 
  readonly deleteUserAccount?: (id: UserAccountID) => Promise<void>; 
  readonly updateUserAccountName?: (options: UpdateAccountNameOptions) => Promise<void>; 
  readonly getBlockCount: (network: NetworkType) => Promise<number>; 
  readonly getAccount: (network: NetworkType, address: AddressString) => Promise<Account>; 
  readonly iterBlocks: (network: NetworkType, options?: IterOptions) => AsyncIterable<Block>; 
  readonly iterActionsRaw?: (network: NetworkType, options?: IterOptions) => AsyncIterable<RawAction>; 
  readonly transfer: ( 
    transfers: readonly Transfer[], 
    options?: TransactionOptions, 
  ) => Promise<TransactionResult<TransactionReceipt, InvocationTransaction | ContractTransaction>>; 
  readonly claim: (options?: TransactionOptions) => Promise<TransactionResult<TransactionReceipt, ClaimTransaction>>; 
  readonly invoke: ( 
    contract: AddressString, 
    method: string, 
    params: ReadonlyArray<ScriptBuilderParam | undefined>, 
    paramsZipped: ReadonlyArray<readonly [string, Param | undefined]>, 
    verify: boolean, 
    options?: InvokeSendUnsafeReceiveTransactionOptions, 
    sourceMaps?: SourceMaps, 
  ) => Promise<TransactionResult<RawInvokeReceipt, InvocationTransaction>>; 
  readonly invokeSend: ( 
    contract: AddressString, 
    method: string, 
    params: ReadonlyArray<ScriptBuilderParam | undefined>, 
    paramsZipped: ReadonlyArray<readonly [string, Param | undefined]>, 
    transfer: Transfer, 
    options?: TransactionOptions, 
    sourceMaps?: SourceMaps, 
  ) => Promise<TransactionResult<RawInvokeReceipt, InvocationTransaction>>; 
  readonly invokeCompleteSend: ( 
    contract: AddressString, 
    method: string, 
    params: ReadonlyArray<ScriptBuilderParam | undefined>, 
    paramsZipped: ReadonlyArray<readonly [string, Param | undefined]>, 
    hash: Hash256String, 
    options?: TransactionOptions, 
    sourceMaps?: SourceMaps, 
  ) => Promise<TransactionResult<RawInvokeReceipt, InvocationTransaction>>; 
  readonly invokeRefundAssets: ( 
    contract: AddressString, 
    method: string, 
    params: ReadonlyArray<ScriptBuilderParam | undefined>, 
    paramsZipped: ReadonlyArray<readonly [string, Param | undefined]>, 
    hash: Hash256String, 
    options?: TransactionOptions, 
    sourceMaps?: SourceMaps, 
  ) => Promise<TransactionResult<RawInvokeReceipt, InvocationTransaction>>; 
  readonly invokeClaim: ( 
    contract: AddressString, 
    method: string, 
    params: ReadonlyArray<ScriptBuilderParam | undefined>, 
    paramsZipped: ReadonlyArray<readonly [string, Param | undefined]>, 
    options?: TransactionOptions, 
    sourceMaps?: SourceMaps, 
  ) => Promise<TransactionResult<TransactionReceipt, ClaimTransaction>>; 
  readonly call: ( 
    network: NetworkType, 
    contract: AddressString, 
    method: string, 
    params: ReadonlyArray<ScriptBuilderParam | undefined>, 
  ) => Promise<RawCallReceipt>; 
} 

Properties

currentUserAccount$
Observable<UserAccount | undefined>
An Observable that emits the currently selected UserAccount
userAccounts$
Observable<readonly UserAccount[]>
An Observable that emits the available UserAccounts
networks$
Observable<readonly NetworkType[]>
An Observable that emits the available networks this UserAccountProvider knows how to function with.

Methods

getCurrentUserAccount

() => UserAccount | undefined 

getUserAccounts

() => readonly UserAccount[] 

getNetworks

() => readonly NetworkType[] 

selectUserAccount

Set the given UserAccountID as the selected UserAccount. If the UserAccountProvider does not support programatically selecting a UserAccountID, it should only ever expose one available UserAccount and manage selecting other UserAccounts outside of the application.
(id?: UserAccountID) => Promise<void> 

deleteUserAccount

Optional support for deleting a UserAccount
(id: UserAccountID) => Promise<void> 

updateUserAccountName

Optional support for updating the name of a UserAccount
(options: UpdateAccountNameOptions) => Promise<void> 

getBlockCount

(network: NetworkType) => Promise<number> 

getAccount

(network: NetworkType, address: AddressString) => Promise<Account> 

iterBlocks

(network: NetworkType, options?: IterOptions) => AsyncIterable<Block> 

iterActionsRaw

While this method could be implemented simply as a function of iterBlocks, iterActionsRaw is provided in case the UserAccountProvider has a more efficient way of iterating over actions.
(network: NetworkType, options?: IterOptions) => AsyncIterable<RawAction> 

transfer

Transfers native assets.
(transfers: readonly Transfer[], options?: TransactionOptions) => Promise<TransactionResult<TransactionReceipt, InvocationTransaction | ContractTransaction>> 

claim

Claim all claimable GAS.
(options?: TransactionOptions) => Promise<TransactionResult<TransactionReceipt, ClaimTransaction>> 

invoke

Invoke the specified method with the given params on contract. `paramsZipped` contains the original parameters before processing with the ABI and are typically suitable for displaying to a user. `verify` will be true if the transaction should trigger verification for the contract `options` may specify additional native asset transfers to include with the transaction (either to or from the contract address).
(contract: AddressString, method: string, params: ReadonlyArray<ScriptBuilderParam | undefined>, paramsZipped: ReadonlyArray<readonly [string, Param | undefined]>, verify: boolean, options?: InvokeSendUnsafeReceiveTransactionOptions, sourceMaps?: SourceMaps) => Promise<TransactionResult<RawInvokeReceipt, InvocationTransaction>> 

invokeSend

Relays a transaction that is the first step of a two-step send process. The Transfer's to property represents the ultimate destination of the funds, but this transaction will be constructed such that those funds are marked for transfer, not actually transferred. Otherwise, parameters are the same as invoke.
(contract: AddressString, method: string, params: ReadonlyArray<ScriptBuilderParam | undefined>, paramsZipped: ReadonlyArray<readonly [string, Param | undefined]>, transfer: Transfer, options?: TransactionOptions, sourceMaps?: SourceMaps) => Promise<TransactionResult<RawInvokeReceipt, InvocationTransaction>> 

invokeCompleteSend

Relays a transaction that is the second step of a two-step send process. The hash is the transaction hash of the first step in the process and is used to determine the amount to transfer to the from address. Otherwise, parameters are the same as invoke.
(contract: AddressString, method: string, params: ReadonlyArray<ScriptBuilderParam | undefined>, paramsZipped: ReadonlyArray<readonly [string, Param | undefined]>, hash: Hash256String, options?: TransactionOptions, sourceMaps?: SourceMaps) => Promise<TransactionResult<RawInvokeReceipt, InvocationTransaction>> 

invokeRefundAssets

Refunds native assets that were not processed by the contract. The hash is the transaction hash that should be refunded and is used to construct the transfers for this transaction. Otherwise, parameters are the same as invoke.
(contract: AddressString, method: string, params: ReadonlyArray<ScriptBuilderParam | undefined>, paramsZipped: ReadonlyArray<readonly [string, Param | undefined]>, hash: Hash256String, options?: TransactionOptions, sourceMaps?: SourceMaps) => Promise<TransactionResult<RawInvokeReceipt, InvocationTransaction>> 

invokeClaim

Claims GAS. Currently only supports claiming all unclaimed GAS to the contract address. Otherwise, parameters are the same as invoke.
(contract: AddressString, method: string, params: ReadonlyArray<ScriptBuilderParam | undefined>, paramsZipped: ReadonlyArray<readonly [string, Param | undefined]>, options?: TransactionOptions, sourceMaps?: SourceMaps) => Promise<TransactionResult<TransactionReceipt, ClaimTransaction>> 

call

Invokes the constant method on contract with params on network.
(network: NetworkType, contract: AddressString, method: string, params: ReadonlyArray<ScriptBuilderParam | undefined>) => Promise<RawCallReceipt> 
  • @neo-one/client
  • @neo-one/smart-contract
DOCS
InstallationMain ConceptsAdvanced GuidesAPI ReferenceContributing
CHANNELS
GitHubStack OverflowDiscord ChatTwitterYouTube
COPYRIGHT © 2021 NEO•ONE