Class ConnectedMeteorWalletAccount

Near Account implementation which makes use of MeteorWallet when no local key is available.

Generally won't be created directly- can be obtained by using account

Example

const account = meteorWallet.account();

// uses Meteor Wallet to sign the transaction using this account
const response = await account.requestSignTransaction({
actions: transactionActions,
receiverId: "my-contract"
});

Hierarchy

  • Account
    • ConnectedMeteorWalletAccount

Properties

accountId: string
connection: Connection

Accessors

ready

Methods

  • accessKeyForTransaction(receiverId: string, actions: Action[], localKey?: PublicKey): Promise<any>
  • Helper function returning the access key (if it exists) to the receiver that grants the designated permission

    Returns

    Promise

    Parameters

    • receiverId: string

      The NEAR account seeking the access key for a transaction

    • actions: Action[]

      The action(s) sought to gain access to

    • Optional localKey: PublicKey

      A local public key provided to check for access

    Returns Promise<any>

  • accessKeyMatchesTransaction(accessKey: any, receiverId: string, actions: Action[]): Promise<boolean>
  • Check if given access key allows the function call or method attempted in transaction

    Parameters

    • accessKey: any

      Array of {access_key: AccessKey, public_key: PublicKey} items

    • receiverId: string

      The NEAR account attempting to have access

    • actions: Action[]

      The action(s) needed to be checked for access

    Returns Promise<boolean>

  • addKey(publicKey: string | PublicKey, contractId?: string, methodNames?: string | string[], amount?: BN): Promise<FinalExecutionOutcome>
  • See

    https://docs.near.org/docs/concepts/account#access-keys

    Todo

    expand this API to support more options.

    Parameters

    • publicKey: string | PublicKey

      A public key to be associated with the contract

    • Optional contractId: string

      NEAR account where the contract is deployed

    • Optional methodNames: string | string[]

      The method names on the contract that should be allowed to be called. Pass null for no method names and '' or [] for any method names.

    • Optional amount: BN

      Payment in yoctoⓃ that is sent to the contract during this function call

    Returns Promise<FinalExecutionOutcome>

  • createAccount(newAccountId: string, publicKey: string | PublicKey, amount: BN): Promise<FinalExecutionOutcome>
  • Parameters

    • newAccountId: string

      NEAR account name to be created

    • publicKey: string | PublicKey

      A public key created from the masterAccount

    • amount: BN

    Returns Promise<FinalExecutionOutcome>

  • createAndDeployContract(contractId: string, publicKey: string | PublicKey, data: Uint8Array, amount: BN): Promise<Account>
  • Create a new account and deploy a contract to it

    Parameters

    • contractId: string

      NEAR account where the contract is deployed

    • publicKey: string | PublicKey

      The public key to add to the created contract account

    • data: Uint8Array

      The compiled contract code

    • amount: BN

      of NEAR to transfer to the created contract account. Transfer enough to pay for storage https://docs.near.org/docs/concepts/storage-staking

    Returns Promise<Account>

  • deleteAccount(beneficiaryId: string): Promise<FinalExecutionOutcome>
  • Parameters

    • beneficiaryId: string

      The NEAR account that will receive the remaining Ⓝ balance from the account being deleted

    Returns Promise<FinalExecutionOutcome>

  • deleteKey(publicKey: string | PublicKey): Promise<FinalExecutionOutcome>
  • Returns

    Parameters

    • publicKey: string | PublicKey

      The public key to be deleted

    Returns Promise<FinalExecutionOutcome>

  • deployContract(data: Uint8Array): Promise<FinalExecutionOutcome>
  • Parameters

    • data: Uint8Array

      The compiled contract code

    Returns Promise<FinalExecutionOutcome>

  • fetchState(): Promise<void>
  • Returns Promise<void>

  • findAccessKey(receiverId: string, actions: Action[]): Promise<{ accessKey: AccessKeyView; publicKey: PublicKey }>
  • Finds the AccessKeyView associated with the accounts PublicKey stored in the KeyStore.

    Todo

    Find matching access key based on transaction (i.e. receiverId and actions)

    Returns

    { publicKey PublicKey; accessKey: AccessKeyView }

    Parameters

    • receiverId: string

      currently unused (see todo)

    • actions: Action[]

      currently unused (see todo)

    Returns Promise<{ accessKey: AccessKeyView; publicKey: PublicKey }>

  • functionCall(props: FunctionCallOptions): Promise<FinalExecutionOutcome>
  • functionCall(contractId: string, methodName: string, args: any, gas?: BN, amount?: BN): Promise<FinalExecutionOutcome>
  • Parameters

    • props: FunctionCallOptions

    Returns Promise<FinalExecutionOutcome>

  • Deprecated

    Returns

    Parameters

    • contractId: string

      NEAR account where the contract is deployed

    • methodName: string

      The method name on the contract as it is written in the contract code

    • args: any

      arguments to pass to method. Can be either plain JS object which gets serialized as JSON automatically or Uint8Array instance which represents bytes passed as is.

    • Optional gas: BN

      max amount of gas that method call can use

    • Optional amount: BN

      amount of NEAR (in yoctoNEAR) to send together with the call

    Returns Promise<FinalExecutionOutcome>

  • getAccessKeys(): Promise<AccessKeyInfoView[]>
  • getAccountBalance(): Promise<AccountBalance>
  • Returns calculated account balance

    Returns Promise<AccountBalance>

  • getAccountDetails(): Promise<{ authorizedApps: AccountAuthorizedApp[] }>
  • Returns a list of authorized apps

    Todo

    update the response value to return all the different keys, not just app keys.

    Returns Promise<{ authorizedApps: AccountAuthorizedApp[] }>

  • sendMoney(receiverId: string, amount: BN): Promise<FinalExecutionOutcome>
  • Parameters

    • receiverId: string

      NEAR account receiving Ⓝ

    • amount: BN

      Amount to send in yoctoⓃ

    Returns Promise<FinalExecutionOutcome>

  • signAndSendTransaction(...args: any[]): Promise<FinalExecutionOutcome>
  • Sign a transaction using Meteor Wallet. Overrides the Near Account API method of the same name, makes use of signAndSendTransaction_direct

    Parameters

    • Rest ...args: any[]

    Returns Promise<FinalExecutionOutcome>

  • signTransaction(receiverId: string, actions: Action[]): Promise<[Uint8Array, SignedTransaction]>
  • Create a signed transaction which can be broadcast to the network

    See

    JsonRpcProvider.sendTransaction

    Parameters

    • receiverId: string

      NEAR account receiving the transaction

    • actions: Action[]

      list of actions to perform as part of the transaction

    Returns Promise<[Uint8Array, SignedTransaction]>

  • stake(publicKey: string | PublicKey, amount: BN): Promise<FinalExecutionOutcome>
  • state(): Promise<AccountView>
  • viewFunction(contractId: string, methodName: string, args?: any, __namedParameters?: { parse?: ((response: Uint8Array) => any); stringify?: ((input: any) => Buffer) }): Promise<any>
  • Invoke a contract view function using the RPC API.

    See

    https://docs.near.org/docs/develop/front-end/rpc#call-a-contract-function

    Returns

    Parameters

    • contractId: string

      NEAR account where the contract is deployed

    • methodName: string

      The view-only method (no state mutations) name on the contract as it is written in the contract code

    • Optional args: any

      Any arguments to the view contract method, wrapped in JSON

    • Optional __namedParameters: { parse?: ((response: Uint8Array) => any); stringify?: ((input: any) => Buffer) }
      • Optional parse?: ((response: Uint8Array) => any)
          • (response: Uint8Array): any
          • Parameters

            • response: Uint8Array

            Returns any

      • Optional stringify?: ((input: any) => Buffer)
          • (input: any): Buffer
          • Parameters

            • input: any

            Returns Buffer

    Returns Promise<any>

  • viewState(prefix: string | Uint8Array, blockQuery?: { blockId: BlockId } | { finality: Finality }): Promise<{ key: Buffer; value: Buffer }[]>
  • Returns the state (key value pairs) of this account's contract based on the key prefix. Pass an empty string for prefix if you would like to return the entire state.

    See

    https://docs.near.org/docs/develop/front-end/rpc#view-contract-state

    Parameters

    • prefix: string | Uint8Array

      allows to filter which keys should be returned. Empty prefix means all keys. String prefix is utf-8 encoded.

    • Optional blockQuery: { blockId: BlockId } | { finality: Finality }

      specifies which block to query state at. By default returns last "optimistic" block (i.e. not necessarily finalized).

    Returns Promise<{ key: Buffer; value: Buffer }[]>

Generated using TypeDoc