Class: Account2FA
account_multisig.Account2FA
This class provides common account related RPC calls including signing transactions with a KeyPair.
Hint
Use WalletConnection in the browser to redirect to NEAR Wallet for Account/key management using the BrowserLocalStorageKeyStore.
See
Hierarchy
↳
Account2FA
Constructors
constructor
new Account2FA(connection
, accountId
, options
)
Parameters
Name | Type |
---|---|
connection | Connection |
accountId | string |
options | any |
Overrides
Defined in
Properties
accountId
Readonly
accountId: string
Inherited from
Defined in
connection
Readonly
connection: Connection
Inherited from
Defined in
getCode
getCode: getCodeFunction
Defined in
helperUrl
helperUrl: string
= 'https://helper.testnet.near.org'
Defined in
onAddRequestResult
onAddRequestResult: (any
: any
) => any
Type declaration
(any
): any
Parameters
Name | Type |
---|---|
any | any |
Returns
any
Inherited from
AccountMultisig.onAddRequestResult
Defined in
onConfirmResult
onConfirmResult: (any
: any
) => any
Type declaration
(any
): any
Parameters
Name | Type |
---|---|
any | any |
Returns
any
Defined in
sendCode
sendCode: sendCodeFunction
Account2FA has options object where you can provide callbacks for:
- sendCode: how to send the 2FA code in case you don't use NEAR Contract Helper
- getCode: how to get code from user (use this to provide custom UI/UX for prompt of 2FA code)
- onResult: the tx result after it's been confirmed by NEAR Contract Helper
Defined in
storage
storage: any
Inherited from
Defined in
verifyCode
verifyCode: verifyCodeFunction
Defined in
Methods
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
checkMultisigCodeAndStateStatus
checkMultisigCodeAndStateStatus(contractBytes?
): Promise
<{ codeStatus
: MultisigCodeStatus
; stateStatus
: MultisigStateStatus
}>
Parameters
Name | Type |
---|---|
contractBytes? | Uint8Array |
Returns
Promise
<{ codeStatus
: MultisigCodeStatus
; stateStatus
: MultisigStateStatus
}>
Inherited from
AccountMultisig.checkMultisigCodeAndStateStatus
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
AccountMultisig.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
deleteAllRequests
deleteAllRequests(): Promise
<void
>
Returns
Promise
<void
>
Inherited from
AccountMultisig.deleteAllRequests
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
deleteRequest
deleteRequest(request_id
): Promise
<FinalExecutionOutcome
>
Parameters
Name | Type |
---|---|
request_id | any |
Returns
Promise
<FinalExecutionOutcome
>
Inherited from
Defined in
deleteUnconfirmedRequests
deleteUnconfirmedRequests(): Promise
<void
>
Returns
Promise
<void
>
Inherited from
AccountMultisig.deleteUnconfirmedRequests
Defined in
deployContract
deployContract(data
): Promise
<FinalExecutionOutcome
>
Parameters
Name | Type | Description |
---|---|---|
data | Uint8Array | The compiled contract code |
Returns
Promise
<FinalExecutionOutcome
>
Inherited from
AccountMultisig.deployContract
Defined in
deployMultisig
deployMultisig(contractBytes
): Promise
<FinalExecutionOutcome
>
Parameters
Name | Type |
---|---|
contractBytes | Uint8Array |
Returns
Promise
<FinalExecutionOutcome
>
Defined in
disable
disable(contractBytes?
, cleanupContractBytes?
): Promise
<FinalExecutionOutcome
>
This method converts LAKs back to FAKs, clears state and deploys an 'empty' contract (contractBytes param)
Parameters
Name | Type | Description |
---|---|---|
contractBytes? | Uint8Array | https://github.com/near/near-wallet/blob/master/packages/frontend/src/wasm/main.wasm?raw=true |
cleanupContractBytes? | Uint8Array | https://github.com/near/core-contracts/blob/master/state-cleanup/res/state_cleanup.wasm?raw=true |
Returns
Promise
<FinalExecutionOutcome
>
Defined in
disableWithFAK
disableWithFAK(__namedParameters
): Promise
<FinalExecutionOutcome
>
Parameters
Name | Type |
---|---|
__namedParameters | Object |
__namedParameters.cleanupContractBytes? | Uint8Array |
__namedParameters.contractBytes | Uint8Array |
Returns
Promise
<FinalExecutionOutcome
>
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
get2faDisableCleanupActions
get2faDisableCleanupActions(cleanupContractBytes
): Promise
<Action
[]>
Parameters
Name | Type |
---|---|
cleanupContractBytes | Uint8Array |
Returns
Promise
<Action
[]>
Defined in
get2faDisableKeyConversionActions
get2faDisableKeyConversionActions(): Promise
<Action
[]>
Returns
Promise
<Action
[]>
Defined in
get2faMethod
get2faMethod(): Promise
<{ detail
: any
; kind
: any
}>
Returns
Promise
<{ detail
: any
; kind
: any
}>
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
AccountMultisig.getAccountBalance
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
AccountMultisig.getAccountDetails
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
AccountMultisig.getActiveDelegatedStakeBalance
Defined in
getCodeDefault
getCodeDefault(): Promise
<string
>
Returns
Promise
<string
>
Defined in
getRecoveryMethods
getRecoveryMethods(): Promise
<{ accountId
: string
; data
: any
}>
Returns
Promise
<{ accountId
: string
; data
: any
}>
Defined in
getRequest
getRequest(): any
Returns
any
Inherited from
Defined in
getRequestIds
getRequestIds(): Promise
<string
[]>
Returns
Promise
<string
[]>
Inherited from
Defined in
postSignedJson
postSignedJson(path
, body
): Promise
<any
>
Parameters
Name | Type |
---|---|
path | any |
body | any |
Returns
Promise
<any
>
Defined in
promptAndVerify
promptAndVerify(): any
Returns
any
Defined in
sendCodeDefault
sendCodeDefault(): Promise
<any
>
Returns
Promise
<any
>
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
setRequest
setRequest(data
): any
Parameters
Name | Type |
---|---|
data | any |
Returns
any
Inherited from
Defined in
signAndSendTransaction
Protected
signAndSendTransaction(__namedParameters
): Promise
<FinalExecutionOutcome
>
Sign a transaction to preform a list of actions and broadcast it using the RPC API.
See
JsonRpcProvider.sendTransaction
Parameters
Name | Type |
---|---|
__namedParameters | SignAndSendTransactionOptions |
Returns
Promise
<FinalExecutionOutcome
>
Overrides
AccountMultisig.signAndSendTransaction
Defined in
signAndSendTransactionWithAccount
signAndSendTransactionWithAccount(receiverId
, actions
): Promise
<FinalExecutionOutcome
>
Parameters
Name | Type |
---|---|
receiverId | string |
actions | Action [] |
Returns
Promise
<FinalExecutionOutcome
>
Inherited from
AccountMultisig.signAndSendTransactionWithAccount
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
AccountMultisig.signTransaction
Defined in
signatureFor
signatureFor(): Promise
<{ blockNumber
: string
; blockNumberSignature
: string
}>
Returns
Promise
<{ blockNumber
: string
; blockNumberSignature
: string
}>
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
verifyCodeDefault
verifyCodeDefault(securityCode
): Promise
<any
>
Parameters
Name | Type |
---|---|
securityCode | string |
Returns
Promise
<any
>
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
AccountMultisig.viewFunctionV1
Defined in
viewFunctionV2
viewFunctionV2(__namedParameters
): Promise
<any
>
Parameters
Name | Type |
---|---|
__namedParameters | ViewFunctionCallOptions |
Returns
Promise
<any
>
Inherited from
AccountMultisig.viewFunctionV2
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
}[]>