nearlib
Index
Enumerations
Classes
- AccessKey
- AccessKeyPermission
- Account
- AccountCreator
- Action
- AddKey
- Assignable
- BinaryReader
- BinaryWriter
- BrowserLocalStorageKeyStore
- Connection
- Contract
- CreateAccount
- DeleteAccount
- DeleteKey
- DeployContract
- Enum
- FullAccessPermission
- FunctionCall
- FunctionCallPermission
- IAction
- InMemoryKeyStore
- InMemorySigner
- JsonRpcProvider
- KeyPair
- KeyPairEd25519
- KeyStore
- LocalAccountCreator
- MergeKeyStore
- Near
- Provider
- PublicKey
- Signature
- SignedTransaction
- Signer
- Stake
- Transaction
- Transfer
- UnencryptedFileSystemKeyStore
- UrlAccountCreator
- WalletAccount
Interfaces
- AccountInfo
- AccountState
- BlockHeader
- BlockResult
- ConnectionInfo
- FinalTransactionResult
- Network
- NodeStatusResult
- SyncInfo
- TotalWeight
- TransactionLog
- TransactionResult
Type aliases
Variables
- DEFAULT_FUNC_CALL_AMOUNT
- INITIAL_LENGTH
- LOCAL_STORAGE_KEY_PREFIX
- LOCAL_STORAGE_KEY_SUFFIX
- LOGIN_WALLET_URL_SUFFIX
- PENDING_ACCESS_KEY_PREFIX
- SCHEMA
- TX_STATUS_RETRY_NUMBER
- TX_STATUS_RETRY_WAIT
- TX_STATUS_RETRY_WAIT_BACKOFF
- _nextId
- exists
- fetch
- mkdir
- readFile
- readdir
- unlink
- writeFile
Functions
- addKey
- base_decode
- base_encode
- connect
- createAccount
- deleteAccount
- deleteKey
- deployContract
- deserialize
- deserializeField
- deserializeStruct
- ensureDir
- fetchJson
- fullAccessKey
- functionCall
- functionCallAccessKey
- getProvider
- getSigner
- getTransactionLastResult
- key_type_to_str
- loadJsonFile
- promisify
- readKeyFile
- serialize
- serializeField
- serializeStruct
- signTransaction
- sleep
- stake
- str_to_key_type
- transfer
Type aliases
Arrayish
Ƭ Arrayish: string | ArrayLike‹number›
Defined in utils/key_pair.ts:6
Schema
Ƭ Schema: Map‹Function, any›
Defined in utils/serialize.ts:19
Variables
Const
DEFAULT_FUNC_CALL_AMOUNT
• DEFAULT_FUNC_CALL_AMOUNT: 2000000 = 2000000
Defined in account.ts:14
Const
INITIAL_LENGTH
• INITIAL_LENGTH: 1024 = 1024
Defined in utils/serialize.ts:17
Const
LOCAL_STORAGE_KEY_PREFIX
• LOCAL_STORAGE_KEY_PREFIX: "nearlib:keystore:" = "nearlib:keystore:"
Defined in key_stores/browser_local_storage_key_store.ts:6
Const
LOCAL_STORAGE_KEY_SUFFIX
• LOCAL_STORAGE_KEY_SUFFIX: "_wallet_auth_key" = "_wallet_auth_key"
Defined in wallet-account.ts:10
Const
LOGIN_WALLET_URL_SUFFIX
• LOGIN_WALLET_URL_SUFFIX: "/login/" = "/login/"
Defined in wallet-account.ts:8
Const
PENDING_ACCESS_KEY_PREFIX
• PENDING_ACCESS_KEY_PREFIX: "pending_key" = "pending_key"
Defined in wallet-account.ts:11
Const
SCHEMA
• SCHEMA: Map‹Function, any› = new Map<Function, any>([ [Signature, {kind: 'struct', fields: [ ['keyType', 'u8'], ['data', [32]] ]}], [SignedTransaction, {kind: 'struct', fields: [ ['transaction', Transaction], ['signature', Signature] ]}], [Transaction, { kind: 'struct', fields: [ ['signerId', 'string'], ['publicKey', PublicKey], ['nonce', 'u64'], ['receiverId', 'string'], ['blockHash', [32]], ['actions', [Action]] ]}], [PublicKey, { kind: 'struct', fields: [ ['keyType', 'u8'], ['data', [32]] ]}], [AccessKey, { kind: 'struct', fields: [ ['nonce', 'u64'], ['permission', AccessKeyPermission], ]}], [AccessKeyPermission, {kind: 'enum', field: 'enum', values: [ ['functionCall', FunctionCallPermission], ['fullAccess', FullAccessPermission], ]}], [FunctionCallPermission, {kind: 'struct', fields: [ ['allowance', {kind: 'option', type: 'u128'}], ['receiverId', 'string'], ['methodNames', ['string']], ]}], [FullAccessPermission, {kind: 'struct', fields: []}], [Action, {kind: 'enum', field: 'enum', values: [ ['createAccount', CreateAccount], ['deployContract', DeployContract], ['functionCall', functionCall], ['transfer', transfer], ['stake', stake], ['addKey', addKey], ['deleteKey', deleteKey], ['deleteAccount', deleteAccount], ]}], [CreateAccount, { kind: 'struct', fields: [] }], [DeployContract, { kind: 'struct', fields: [ ['code', ['u8']] ]}], [FunctionCall, { kind: 'struct', fields: [ ['methodName', 'string'], ['args', ['u8']], ['gas', 'u64'], ['deposit', 'u128'] ]}], [Transfer, { kind: 'struct', fields: [ ['deposit', 'u128'] ]}], [Stake, { kind: 'struct', fields: [ ['stake', 'u128'], ['publicKey', PublicKey] ]}], [AddKey, { kind: 'struct', fields: [ ['publicKey', PublicKey], ['accessKey', AccessKey] ]}], [DeleteKey, { kind: 'struct', fields: [ ['publicKey', PublicKey] ]}], [DeleteAccount, { kind: 'struct', fields: [ ['beneficiaryId', 'string'] ]}], ])
Defined in transaction.ts:140
Const
TX_STATUS_RETRY_NUMBER
• TX_STATUS_RETRY_NUMBER: 10 = 10
Defined in account.ts:17
Const
TX_STATUS_RETRY_WAIT
• TX_STATUS_RETRY_WAIT: 500 = 500
Defined in account.ts:20
Const
TX_STATUS_RETRY_WAIT_BACKOFF
• TX_STATUS_RETRY_WAIT_BACKOFF: 1.5 = 1.5
Defined in account.ts:23
Let
_nextId
• _nextId: number = 123
Defined in providers/json-rpc-provider.ts:10
Const
exists
• exists: Function = promisify(fs.exists)
Defined in key_stores/unencrypted_file_system_keystore.ts:18
Const
fetch
• fetch: any = (typeof window === 'undefined' || window.name === 'nodejs') ? require('node-fetch') : window.fetch
Defined in utils/web.ts:14
Const
mkdir
• mkdir: Function = promisify(fs.mkdir)
Defined in key_stores/unencrypted_file_system_keystore.ts:23
Const
readFile
• readFile: Function = promisify(fs.readFile)
Defined in key_stores/unencrypted_file_system_keystore.ts:19
Const
readdir
• readdir: Function = promisify(fs.readdir)
Defined in key_stores/unencrypted_file_system_keystore.ts:22
Const
unlink
• unlink: Function = promisify(fs.unlink)
Defined in key_stores/unencrypted_file_system_keystore.ts:21
Const
writeFile
• writeFile: Function = promisify(fs.writeFile)
Defined in key_stores/unencrypted_file_system_keystore.ts:20
Functions
addKey
▸ addKey(publicKey
: PublicKey, accessKey
: AccessKey): Action
Defined in transaction.ts:89
Parameters:
Name | Type |
---|---|
publicKey | PublicKey |
accessKey | AccessKey |
Returns: Action
base_decode
▸ base_decode(value
: string): Uint8Array
Defined in utils/serialize.ts:13
Parameters:
Name | Type |
---|---|
value | string |
Returns: Uint8Array
base_encode
▸ base_encode(value
: Uint8Array | string): string
Defined in utils/serialize.ts:6
Parameters:
Name | Type |
---|---|
value | Uint8Array | string |
Returns: string
connect
▸ connect(config
: any): Promise‹Near›
Defined in near.ts:72
Parameters:
Name | Type |
---|---|
config | any |
Returns: Promise‹Near›
createAccount
▸ createAccount(): Action
Defined in transaction.ts:69
Returns: Action
deleteAccount
▸ deleteAccount(beneficiaryId
: string): Action
Defined in transaction.ts:97
Parameters:
Name | Type |
---|---|
beneficiaryId | string |
Returns: Action
deleteKey
▸ deleteKey(publicKey
: PublicKey): Action
Defined in transaction.ts:93
Parameters:
Name | Type |
---|---|
publicKey | PublicKey |
Returns: Action
deployContract
▸ deployContract(code
: Uint8Array): Action
Defined in transaction.ts:73
Parameters:
Name | Type |
---|---|
code | Uint8Array |
Returns: Action
deserialize
▸ deserialize(schema
: Schema, classType
: any, buffer
: Buffer): any
Defined in utils/serialize.ts:228
Parameters:
Name | Type |
---|---|
schema | Schema |
classType | any |
buffer | Buffer |
Returns: any
deserializeField
▸ deserializeField(schema
: Schema, fieldType
: any, reader
: any): any
Defined in utils/serialize.ts:206
Parameters:
Name | Type |
---|---|
schema | Schema |
fieldType | any |
reader | any |
Returns: any
deserializeStruct
▸ deserializeStruct(schema
: Schema, classType
: any, reader
: any): any
Defined in utils/serialize.ts:220
Parameters:
Name | Type |
---|---|
schema | Schema |
classType | any |
reader | any |
Returns: any
ensureDir
▸ ensureDir(path
: string): Promise‹void›
Defined in key_stores/unencrypted_file_system_keystore.ts:38
Parameters:
Name | Type |
---|---|
path | string |
Returns: Promise‹void›
fetchJson
▸ fetchJson(connection
: string | ConnectionInfo, json?
: string): Promise‹any›
Defined in utils/web.ts:16
Parameters:
Name | Type |
---|---|
connection | string | ConnectionInfo |
json? | string |
Returns: Promise‹any›
fullAccessKey
▸ fullAccessKey(): AccessKey
Defined in transaction.ts:50
Returns: AccessKey
functionCall
▸ functionCall(methodName
: string, args
: Uint8Array, gas
: number, deposit
: BN): Action
Defined in transaction.ts:77
Parameters:
Name | Type |
---|---|
methodName | string |
args | Uint8Array |
gas | number |
deposit | BN |
Returns: Action
functionCallAccessKey
▸ functionCallAccessKey(receiverId
: string, methodNames
: String[], allowance?
: BN): AccessKey
Defined in transaction.ts:54
Parameters:
Name | Type |
---|---|
receiverId | string |
methodNames | String[] |
allowance? | BN |
Returns: AccessKey
getProvider
▸ getProvider(config
: any): Provider
Defined in connection.ts:6
Parameters:
Name | Type |
---|---|
config | any |
Returns: Provider
getSigner
▸ getSigner(networkId
: string, config
: any): Signer
Defined in connection.ts:13
Parameters:
Name | Type |
---|---|
networkId | string |
config | any |
Returns: Signer
getTransactionLastResult
▸ getTransactionLastResult(txResult
: FinalTransactionResult): any
Defined in providers/provider.ts:83
Parameters:
Name | Type |
---|---|
txResult | FinalTransactionResult |
Returns: any
key_type_to_str
▸ key_type_to_str(keyType
: KeyType): String
Defined in utils/key_pair.ts:18
Parameters:
Name | Type |
---|---|
keyType | KeyType |
Returns: String
loadJsonFile
▸ loadJsonFile(path
: string): Promise‹any›
Defined in key_stores/unencrypted_file_system_keystore.ts:33
Parameters:
Name | Type |
---|---|
path | string |
Returns: Promise‹any›
Const
promisify
▸ promisify(fn
: any): Function
Defined in key_stores/unencrypted_file_system_keystore.ts:9
Parameters:
Name | Type |
---|---|
fn | any |
Returns: Function
readKeyFile
▸ readKeyFile(path
: string): Promise‹[string, KeyPair]›
Defined in key_stores/unencrypted_file_system_keystore.ts:46
Parameters:
Name | Type |
---|---|
path | string |
Returns: Promise‹[string, KeyPair]›
serialize
▸ serialize(schema
: Schema, obj
: any): Uint8Array
Defined in utils/serialize.ts:200
Parameters:
Name | Type |
---|---|
schema | Schema |
obj | any |
Returns: Uint8Array
serializeField
▸ serializeField(schema
: Schema, value
: any, fieldType
: any, writer
: any): void
Defined in utils/serialize.ts:147
Parameters:
Name | Type |
---|---|
schema | Schema |
value | any |
fieldType | any |
writer | any |
Returns: void
serializeStruct
▸ serializeStruct(schema
: Schema, obj
: any, writer
: any): void
Defined in utils/serialize.ts:174
Parameters:
Name | Type |
---|---|
schema | Schema |
obj | any |
writer | any |
Returns: void
signTransaction
▸ signTransaction(receiverId
: string, nonce
: number, actions
: Action[], blockHash
: Uint8Array, signer
: Signer, accountId?
: string, networkId?
: string): Promise‹[Uint8Array, SignedTransaction]›
Defined in transaction.ts:214
Parameters:
Name | Type |
---|---|
receiverId | string |
nonce | number |
actions | Action[] |
blockHash | Uint8Array |
signer | Signer |
accountId? | string |
networkId? | string |
Returns: Promise‹[Uint8Array, SignedTransaction]›
sleep
▸ sleep(millis
: number): Promise‹any›
Defined in account.ts:26
Parameters:
Name | Type |
---|---|
millis | number |
Returns: Promise‹any›
stake
▸ stake(stake
: BN, publicKey
: PublicKey): Action
Defined in transaction.ts:85
Parameters:
Name | Type |
---|---|
stake | BN |
publicKey | PublicKey |
Returns: Action
str_to_key_type
▸ str_to_key_type(keyType
: string): KeyType
Defined in utils/key_pair.ts:25
Parameters:
Name | Type |
---|---|
keyType | string |
Returns: KeyType
transfer
▸ transfer(deposit
: BN): Action
Defined in transaction.ts:81
Parameters:
Name | Type |
---|---|
deposit | BN |
Returns: Action