Class: ConnectedWalletAccount
walletAccount.ConnectedWalletAccount
Account implementation which redirects to wallet using WalletConnection when no local key is available.
Hierarchy
↳
ConnectedWalletAccount
Constructors
constructor
new ConnectedWalletAccount(walletConnection
, connection
, accountId
)
Parameters
Name | Type |
---|---|
walletConnection | WalletConnection |
connection | Connection |
accountId | string |
Overrides
Defined in
Properties
accountId
Readonly
accountId: string
Inherited from
Defined in
connection
Readonly
connection: Connection
Inherited from
Defined in
walletConnection
walletConnection: WalletConnection
Defined in
Methods
accessKeyForTransaction
accessKeyForTransaction(receiverId
, actions
, localKey?
): Promise
<any
>
Helper function returning the access key (if it exists) to the receiver that grants the designated permission
Parameters
Name | Type | Description |
---|---|---|
receiverId | string | The NEAR account seeking the access key for a transaction |
actions | Action [] | The action(s) sought to gain access to |
localKey? | PublicKey | A local public key provided to check for access |
Returns
Promise
<any
>
Defined in
accessKeyMatchesTransaction
accessKeyMatchesTransaction(accessKey
, receiverId
, actions
): Promise
<boolean
>
Check if given access key allows the function call or method attempted in transaction
Parameters
Name | Type | Description |
---|---|---|
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
>
Defined in
addKey
addKey(publicKey
, contractId?
, methodNames?
, amount?
): Promise
<FinalExecutionOutcome
>
See
https://docs.near.org/concepts/basics/accounts/access-keys
Todo
expand this API to support more options.
Parameters
Name | Type | Description |
---|---|---|
publicKey | string | PublicKey | A public key to be associated with the contract |
contractId? | string | NEAR account where the contract is deployed |
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. |
amount? | BN | Payment in yoctoⓃ that is sent to the contract during this function call |
Returns
Promise
<FinalExecutionOutcome
>
Inherited from
Defined in
createAccount
createAccount(newAccountId
, publicKey
, amount
): Promise
<FinalExecutionOutcome
>
Parameters
Name | Type | Description |
---|---|---|
newAccountId | string | NEAR account name to be created |
publicKey | string | PublicKey | A public key created from the masterAccount |
amount | BN | - |
Returns
Promise
<FinalExecutionOutcome
>
Inherited from
Defined in
createAndDeployContract
createAndDeployContract(contractId
, publicKey
, data
, amount
): Promise
<Account
>
Create a new account and deploy a contract to it
Parameters
Name | Type | Description |
---|---|---|
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
>
Inherited from
Account.createAndDeployContract
Defined in
deleteAccount
deleteAccount(beneficiaryId
): Promise
<FinalExecutionOutcome
>
Parameters
Name | Type | Description |
---|---|---|
beneficiaryId | string | The NEAR account that will receive the remaining Ⓝ balance from the account being deleted |
Returns
Promise
<FinalExecutionOutcome
>
Inherited from
Defined in
deleteKey
deleteKey(publicKey
): Promise
<FinalExecutionOutcome
>
Parameters
Name | Type | Description |
---|---|---|
publicKey | string | PublicKey | The public key to be deleted |
Returns
Promise
<FinalExecutionOutcome
>
Inherited from
Defined in
deployContract
deployContract(data
): Promise
<FinalExecutionOutcome
>
Parameters
Name | Type | Description |
---|---|---|
data | Uint8Array | The compiled contract code |
Returns
Promise
<FinalExecutionOutcome
>
Inherited from
Defined in
findAccessKey
findAccessKey(receiverId
, actions
): 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)
Parameters
Name | Type | Description |
---|---|---|
receiverId | string | currently unused (see todo) |
actions | Action [] | currently unused (see todo) |
Returns
Promise
<{ accessKey
: AccessKeyView
; publicKey
: PublicKey
}>
{ publicKey PublicKey; accessKey: AccessKeyView }
Inherited from
Defined in
functionCall
functionCall(__namedParameters
): Promise
<FinalExecutionOutcome
>
Execute function call
Parameters
Name | Type |
---|---|
__namedParameters | ChangeFunctionCallOptions |
Returns
Promise
<FinalExecutionOutcome
>
Inherited from
Defined in
getAccessKeys
getAccessKeys(): Promise
<AccessKeyInfoView
[]>
Get all access keys for the account
See
https://docs.near.org/api/rpc/access-keys#view-access-key-list
Returns
Promise
<AccessKeyInfoView
[]>
Inherited from
Defined in
getAccountBalance
getAccountBalance(): Promise
<AccountBalance
>
Returns calculated account balance
Returns
Promise
<AccountBalance
>
Inherited from
Defined in
getAccountDetails
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
[] }>
Inherited from
Defined in
getActiveDelegatedStakeBalance
getActiveDelegatedStakeBalance(): Promise
<ActiveDelegatedStakeBalance
>
Returns the NEAR tokens balance and validators of a given account that is delegated to the staking pools that are part of the validators set in the current epoch.
NOTE: If the tokens are delegated to a staking pool that is currently on pause or does not have enough tokens to participate in validation, they won't be accounted for.
Returns
Promise
<ActiveDelegatedStakeBalance
>
Inherited from
Account.getActiveDelegatedStakeBalance
Defined in
sendMoney
sendMoney(receiverId
, amount
): Promise
<FinalExecutionOutcome
>
Parameters
Name | Type | Description |
---|---|---|
receiverId | string | NEAR account receiving Ⓝ |
amount | BN | Amount to send in yoctoⓃ |
Returns
Promise
<FinalExecutionOutcome
>
Inherited from
Defined in
signAndSendTransaction
Protected
signAndSendTransaction(__namedParameters
): Promise
<FinalExecutionOutcome
>
Sign a transaction by redirecting to the NEAR Wallet
See
Parameters
Name | Type |
---|---|
__namedParameters | SignAndSendTransactionOptions |
Returns
Promise
<FinalExecutionOutcome
>
Overrides
Account.signAndSendTransaction
Defined in
signTransaction
Protected
signTransaction(receiverId
, actions
): Promise
<[Uint8Array
, SignedTransaction
]>
Create a signed transaction which can be broadcast to the network
See
JsonRpcProvider.sendTransaction
Parameters
Name | Type | Description |
---|---|---|
receiverId | string | NEAR account receiving the transaction |
actions | Action [] | list of actions to perform as part of the transaction |
Returns
Promise
<[Uint8Array
, SignedTransaction
]>
Inherited from
Defined in
stake
stake(publicKey
, amount
): Promise
<FinalExecutionOutcome
>
See
https://near-nodes.io/validator/staking-and-delegation
Parameters
Name | Type | Description |
---|---|---|
publicKey | string | PublicKey | The public key for the account that's staking |
amount | BN | The account to stake in yoctoⓃ |
Returns
Promise
<FinalExecutionOutcome
>
Inherited from
Defined in
state
state(): Promise
<AccountView
>
Returns basic NEAR account information via the view_account
RPC query method
See
https://docs.near.org/api/rpc/contracts#view-account
Returns
Promise
<AccountView
>
Inherited from
Defined in
viewFunction
viewFunction(...restArgs
): Promise
<any
>
Invoke a contract view function using the RPC API.
See
https://docs.near.org/api/rpc/contracts#call-a-contract-function
Parameters
Name | Type |
---|---|
...restArgs | any |
Returns
Promise
<any
>
Inherited from
Defined in
viewFunctionV1
viewFunctionV1(contractId
, methodName
, args?
, __namedParameters?
): Promise
<any
>
Parameters
Name | Type |
---|---|
contractId | string |
methodName | string |
args | any |
__namedParameters | Object |
__namedParameters.blockQuery? | BlockReference |
__namedParameters.jsContract? | boolean |
__namedParameters.parse? | (response : Uint8Array ) => any |
__namedParameters.stringify? | (input : any ) => Buffer |
Returns
Promise
<any
>
Inherited from
Defined in
viewFunctionV2
viewFunctionV2(__namedParameters
): Promise
<any
>
Parameters
Name | Type |
---|---|
__namedParameters | ViewFunctionCallOptions |
Returns
Promise
<any
>
Inherited from
Defined in
viewState
viewState(prefix
, blockQuery?
): 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/api/rpc/contracts#view-contract-state
Parameters
Name | Type | Description |
---|---|---|
prefix | string | Uint8Array | allows to filter which keys should be returned. Empty prefix means all keys. String prefix is utf-8 encoded. |
blockQuery | BlockReference | specifies which block to query state at. By default returns last "optimistic" block (i.e. not necessarily finalized). |
Returns
Promise
<{ key
: Buffer
; value
: Buffer
}[]>