Socket
Socket
Sign inDemoInstall

near-api-js

Package Overview
Dependencies
Maintainers
6
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

near-api-js - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

LICENSE

2

lib/account_multisig.d.ts

@@ -65,3 +65,3 @@ import BN from 'bn.js';

* Sign a transaction to preform a list of actions and broadcast it using the RPC API.
* @see {@link JsonRpcProvider.sendTransaction}
* @see {@link providers/json-rpc-provider!JsonRpcProvider#sendTransaction | JsonRpcProvider.sendTransaction}
*/

@@ -68,0 +68,0 @@ protected signAndSendTransaction({ receiverId, actions }: SignAndSendTransactionOptions): Promise<FinalExecutionOutcome>;

@@ -236,3 +236,3 @@ 'use strict';

* Sign a transaction to preform a list of actions and broadcast it using the RPC API.
* @see {@link JsonRpcProvider.sendTransaction}
* @see {@link providers/json-rpc-provider!JsonRpcProvider#sendTransaction | JsonRpcProvider.sendTransaction}
*/

@@ -239,0 +239,0 @@ signAndSendTransaction({ receiverId, actions }) {

@@ -39,3 +39,3 @@ /// <reference types="node" />

* Options used to initiate a function call (especially a change function call)
* @see {@link viewFunction} to initiate a view function call
* @see {@link account!Account#viewFunction} to initiate a view function call
*/

@@ -80,8 +80,18 @@ export interface FunctionCallOptions {

}
interface StakedBalance {
validatorId: string;
amount?: string;
error?: string;
}
interface ActiveDelegatedStakeBalance {
stakedValidators: StakedBalance[];
failedValidators: StakedBalance[];
total: BN | string;
}
/**
* This class provides common account related RPC calls including signing transactions with a {@link KeyPair}.
* This class provides common account related RPC calls including signing transactions with a {@link utils/key_pair!KeyPair}.
*
* @example {@link https://docs.near.org/docs/develop/front-end/naj-quick-reference#account}
* @hint Use {@link WalletConnection} in the browser to redirect to {@link https://docs.near.org/docs/tools/near-wallet | NEAR Wallet} for Account/key management using the {@link BrowserLocalStorageKeyStore}.
* @see {@link https://nomicon.io/DataStructures/Account.html | Account Spec}
* @hint Use {@link walletAccount!WalletConnection} in the browser to redirect to [NEAR Wallet](https://wallet.near.org/) for Account/key management using the {@link key_stores/browser_local_storage_key_store!BrowserLocalStorageKeyStore}.
* @see [https://docs.near.org/docs/develop/front-end/naj-quick-reference#account](https://docs.near.org/tools/near-api-js/quick-reference#account)
* @see [Account Spec](https://nomicon.io/DataStructures/Account.html)
*/

@@ -94,3 +104,3 @@ export declare class Account {

* Returns basic NEAR account information via the `view_account` RPC query method
* @see {@link https://docs.near.org/docs/develop/front-end/rpc#view-account}
* @see [https://docs.near.org/api/rpc/contracts#view-account](https://docs.near.org/api/rpc/contracts#view-account)
*/

@@ -106,3 +116,3 @@ state(): Promise<AccountView>;

* @param actions list of actions to perform as part of the transaction
* @see {@link JsonRpcProvider.sendTransaction}
* @see {@link providers/json-rpc-provider!JsonRpcProvider#sendTransaction | JsonRpcProvider.sendTransaction}
*/

@@ -112,3 +122,3 @@ protected signTransaction(receiverId: string, actions: Action[]): Promise<[Uint8Array, SignedTransaction]>;

* Sign a transaction to preform a list of actions and broadcast it using the RPC API.
* @see {@link JsonRpcProvider.sendTransaction}
* @see {@link providers/json-rpc-provider!JsonRpcProvider#sendTransaction | JsonRpcProvider.sendTransaction}
*/

@@ -121,3 +131,3 @@ protected signAndSendTransaction({ receiverId, actions, returnError }: SignAndSendTransactionOptions): Promise<FinalExecutionOutcome>;

/**
* Finds the {@link AccessKeyView} associated with the accounts {@link PublicKey} stored in the {@link KeyStore}.
* Finds the {@link providers/provider!AccessKeyView} associated with the accounts {@link utils/key_pair!PublicKey} stored in the {@link key_stores/keystore!KeyStore}.
*

@@ -169,3 +179,3 @@ * @todo Find matching access key based on transaction (i.e. receiverId and actions)

/**
* @see {@link https://docs.near.org/docs/concepts/account#access-keys}
* @see [https://docs.near.org/concepts/basics/accounts/access-keys](https://docs.near.org/concepts/basics/accounts/access-keys)
* @todo expand this API to support more options.

@@ -184,3 +194,3 @@ * @param publicKey A public key to be associated with the contract

/**
* @see {@link https://docs.near.org/docs/validator/staking-overview}
* @see [https://near-nodes.io/validator/staking-and-delegation](https://near-nodes.io/validator/staking-and-delegation)
*

@@ -195,3 +205,3 @@ * @param publicKey The public key for the account that's staking

* Invoke a contract view function using the RPC API.
* @see {@link https://docs.near.org/docs/develop/front-end/rpc#call-a-contract-function}
* @see [https://docs.near.org/api/rpc/contracts#call-a-contract-function](https://docs.near.org/api/rpc/contracts#call-a-contract-function)
*

@@ -218,3 +228,3 @@ * @param contractId NEAR account where the contract is deployed

* Pass an empty string for prefix if you would like to return the entire state.
* @see {@link https://docs.near.org/docs/develop/front-end/rpc#view-contract-state}
* @see [https://docs.near.org/api/rpc/contracts#view-contract-state](https://docs.near.org/api/rpc/contracts#view-contract-state)
*

@@ -230,3 +240,3 @@ * @param prefix allows to filter which keys should be returned. Empty prefix means all keys. String prefix is utf-8 encoded.

* Get all access keys for the account
* @see {@link https://docs.near.org/docs/develop/front-end/rpc#view-access-key-list}
* @see [https://docs.near.org/api/rpc/access-keys#view-access-key-list](https://docs.near.org/api/rpc/access-keys#view-access-key-list)
*/

@@ -245,2 +255,10 @@ getAccessKeys(): Promise<AccessKeyInfoView[]>;

getAccountBalance(): Promise<AccountBalance>;
/**
* 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>}
*/
getActiveDelegatedStakeBalance(): Promise<ActiveDelegatedStakeBalance>;
}
export {};

@@ -39,7 +39,7 @@ "use strict";

/**
* This class provides common account related RPC calls including signing transactions with a {@link KeyPair}.
* This class provides common account related RPC calls including signing transactions with a {@link utils/key_pair!KeyPair}.
*
* @example {@link https://docs.near.org/docs/develop/front-end/naj-quick-reference#account}
* @hint Use {@link WalletConnection} in the browser to redirect to {@link https://docs.near.org/docs/tools/near-wallet | NEAR Wallet} for Account/key management using the {@link BrowserLocalStorageKeyStore}.
* @see {@link https://nomicon.io/DataStructures/Account.html | Account Spec}
* @hint Use {@link walletAccount!WalletConnection} in the browser to redirect to [NEAR Wallet](https://wallet.near.org/) for Account/key management using the {@link key_stores/browser_local_storage_key_store!BrowserLocalStorageKeyStore}.
* @see [https://docs.near.org/docs/develop/front-end/naj-quick-reference#account](https://docs.near.org/tools/near-api-js/quick-reference#account)
* @see [Account Spec](https://nomicon.io/DataStructures/Account.html)
*/

@@ -55,3 +55,3 @@ class Account {

* Returns basic NEAR account information via the `view_account` RPC query method
* @see {@link https://docs.near.org/docs/develop/front-end/rpc#view-account}
* @see [https://docs.near.org/api/rpc/contracts#view-account](https://docs.near.org/api/rpc/contracts#view-account)
*/

@@ -91,3 +91,3 @@ state() {

* @param actions list of actions to perform as part of the transaction
* @see {@link JsonRpcProvider.sendTransaction}
* @see {@link providers/json-rpc-provider!JsonRpcProvider#sendTransaction | JsonRpcProvider.sendTransaction}
*/

@@ -103,3 +103,3 @@ signTransaction(receiverId, actions) {

const blockHash = block.header.hash;
const nonce = ++accessKey.nonce;
const nonce = accessKey.nonce.add(new bn_js_1.default(1));
return yield (0, transaction_1.signTransaction)(receiverId, nonce, actions, (0, borsh_1.baseDecode)(blockHash), this.connection.signer, this.accountId, this.connection.networkId);

@@ -110,3 +110,3 @@ });

* Sign a transaction to preform a list of actions and broadcast it using the RPC API.
* @see {@link JsonRpcProvider.sendTransaction}
* @see {@link providers/json-rpc-provider!JsonRpcProvider#sendTransaction | JsonRpcProvider.sendTransaction}
*/

@@ -154,3 +154,4 @@ signAndSendTransaction({ receiverId, actions, returnError }) {

this.printLogsAndFailures(signedTx.transaction.receiverId, flatLogs);
if (!returnError && typeof result.status === 'object' && typeof result.status.Failure === 'object') {
// Should be falsy if result.status.Failure is null
if (!returnError && typeof result.status === 'object' && typeof result.status.Failure === 'object' && result.status.Failure !== null) {
// if error data has error_message and error_type properties, we consider that node returned an error in the old format

@@ -169,3 +170,3 @@ if (result.status.Failure.error_message && result.status.Failure.error_type) {

/**
* Finds the {@link AccessKeyView} associated with the accounts {@link PublicKey} stored in the {@link KeyStore}.
* Finds the {@link providers/provider!AccessKeyView} associated with the accounts {@link utils/key_pair!PublicKey} stored in the {@link key_stores/keystore!KeyStore}.
*

@@ -191,3 +192,3 @@ * @todo Find matching access key based on transaction (i.e. receiverId and actions)

try {
const accessKey = yield this.connection.provider.query({
const rawAccessKey = yield this.connection.provider.query({
request_type: 'view_access_key',

@@ -198,2 +199,4 @@ account_id: this.accountId,

});
// store nonce as BN to preserve precision on big number
const accessKey = Object.assign(Object.assign({}, rawAccessKey), { nonce: new bn_js_1.default(rawAccessKey.nonce) });
// this function can be called multiple times and retrieve the same access key

@@ -316,3 +319,3 @@ // this checks to see if the access key was already retrieved and cached while

/**
* @see {@link https://docs.near.org/docs/concepts/account#access-keys}
* @see [https://docs.near.org/concepts/basics/accounts/access-keys](https://docs.near.org/concepts/basics/accounts/access-keys)
* @todo expand this API to support more options.

@@ -358,3 +361,3 @@ * @param publicKey A public key to be associated with the contract

/**
* @see {@link https://docs.near.org/docs/validator/staking-overview}
* @see [https://near-nodes.io/validator/staking-and-delegation](https://near-nodes.io/validator/staking-and-delegation)
*

@@ -384,3 +387,3 @@ * @param publicKey The public key for the account that's staking

* Invoke a contract view function using the RPC API.
* @see {@link https://docs.near.org/docs/develop/front-end/rpc#call-a-contract-function}
* @see [https://docs.near.org/api/rpc/contracts#call-a-contract-function](https://docs.near.org/api/rpc/contracts#call-a-contract-function)
*

@@ -437,3 +440,3 @@ * @param contractId NEAR account where the contract is deployed

* Pass an empty string for prefix if you would like to return the entire state.
* @see {@link https://docs.near.org/docs/develop/front-end/rpc#view-contract-state}
* @see [https://docs.near.org/api/rpc/contracts#view-contract-state](https://docs.near.org/api/rpc/contracts#view-contract-state)
*

@@ -454,5 +457,6 @@ * @param prefix allows to filter which keys should be returned. Empty prefix means all keys. String prefix is utf-8 encoded.

* Get all access keys for the account
* @see {@link https://docs.near.org/docs/develop/front-end/rpc#view-access-key-list}
* @see [https://docs.near.org/api/rpc/access-keys#view-access-key-list](https://docs.near.org/api/rpc/access-keys#view-access-key-list)
*/
getAccessKeys() {
var _a;
return __awaiter(this, void 0, void 0, function* () {

@@ -464,9 +468,4 @@ const response = yield this.connection.provider.query({

});
// A breaking API change introduced extra information into the
// response, so it now returns an object with a `keys` field instead
// of an array: https://github.com/nearprotocol/nearcore/pull/1789
if (Array.isArray(response)) {
return response;
}
return response.keys;
// Replace raw nonce into a new BN
return (_a = response === null || response === void 0 ? void 0 : response.keys) === null || _a === void 0 ? void 0 : _a.map((key) => (Object.assign(Object.assign({}, key), { access_key: Object.assign(Object.assign({}, key.access_key), { nonce: new bn_js_1.default(key.access_key.nonce) }) })));
});

@@ -516,3 +515,53 @@ }

}
/**
* 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>}
*/
getActiveDelegatedStakeBalance() {
return __awaiter(this, void 0, void 0, function* () {
const block = yield this.connection.provider.block({ finality: 'final' });
const blockHash = block.header.hash;
const epochId = block.header.epoch_id;
const { current_validators, next_validators, current_proposals } = yield this.connection.provider.validators(epochId);
const pools = new Set();
[...current_validators, ...next_validators, ...current_proposals]
.forEach((validator) => pools.add(validator.account_id));
const uniquePools = [...pools];
const promises = uniquePools
.map((validator) => (this.viewFunction({
contractId: validator,
methodName: 'get_account_total_balance',
args: { account_id: this.accountId },
blockQuery: { blockId: blockHash }
})));
const results = yield Promise.allSettled(promises);
const hasTimeoutError = results.some((result) => {
if (result.status === 'rejected' && result.reason.type === 'TimeoutError') {
return true;
}
return false;
});
// When RPC is down and return timeout error, throw error
if (hasTimeoutError) {
throw new Error('Failed to get delegated stake balance');
}
const summary = results.reduce((result, state, index) => {
const validatorId = uniquePools[index];
if (state.status === 'fulfilled') {
const currentBN = new bn_js_1.default(state.value);
if (!currentBN.isZero()) {
return Object.assign(Object.assign({}, result), { stakedValidators: [...result.stakedValidators, { validatorId, amount: currentBN.toString() }], total: result.total.add(currentBN) });
}
}
if (state.status === 'rejected') {
return Object.assign(Object.assign({}, result), { failedValidators: [...result.failedValidators, { validatorId, error: state.reason }] });
}
return result;
}, { stakedValidators: [], failedValidators: [], total: new bn_js_1.default(0) });
return Object.assign(Object.assign({}, summary), { total: summary.total.toString() });
});
}
}
exports.Account = Account;
import { Near, NearConfig } from './near';
export interface ConnectConfig extends NearConfig {
/**
* Initialize an {@link InMemoryKeyStore} by reading the file at keyPath.
* Initialize an {@link key_stores/in_memory_key_store!InMemoryKeyStore} by reading the file at keyPath.
*/

@@ -6,0 +6,0 @@ keyPath?: string;

@@ -6,3 +6,3 @@ import { Account } from './account';

*
* @see {@link Account.functionCall}
* @see {@link account!Account.functionCall}
*/

@@ -13,3 +13,3 @@ changeMethods: string[];

*
* @@see {@link Account.viewFunction}
* @see {@link account!Account#viewFunction}
*/

@@ -21,3 +21,3 @@ viewMethods: string[];

*
* @example {@link https://docs.near.org/docs/develop/front-end/naj-quick-reference#contract}
* @see [https://docs.near.org/tools/near-api-js/quick-reference#contract](https://docs.near.org/tools/near-api-js/quick-reference#contract)
* @example

@@ -24,0 +24,0 @@ * ```js

@@ -33,3 +33,3 @@ "use strict";

*
* @example {@link https://docs.near.org/docs/develop/front-end/naj-quick-reference#contract}
* @see [https://docs.near.org/tools/near-api-js/quick-reference#contract](https://docs.near.org/tools/near-api-js/quick-reference#contract)
* @example

@@ -36,0 +36,0 @@ * ```js

@@ -6,3 +6,3 @@ import { KeyStore } from './keystore';

*
* @example {@link https://docs.near.org/docs/develop/front-end/naj-quick-reference#key-store}
* @see [https://docs.near.org/docs/develop/front-end/naj-quick-reference#key-store](https://docs.near.org/docs/develop/front-end/naj-quick-reference#key-store)
* @example

@@ -37,3 +37,3 @@ * ```js

/**
* Stores a {@link KeyPair} in local storage.
* Stores a {@link utils/key_pair!KeyPair} in local storage.
* @param networkId The targeted network. (ex. default, betanet, etc…)

@@ -45,3 +45,3 @@ * @param accountId The NEAR account tied to the key pair

/**
* Gets a {@link KeyPair} from local storage
* Gets a {@link utils/key_pair!KeyPair} from local storage
* @param networkId The targeted network. (ex. default, betanet, etc…)

@@ -53,3 +53,3 @@ * @param accountId The NEAR account tied to the key pair

/**
* Removes a {@link KeyPair} from local storage
* Removes a {@link utils/key_pair!KeyPair} from local storage
* @param networkId The targeted network. (ex. default, betanet, etc…)

@@ -71,3 +71,2 @@ * @param accountId The NEAR account tied to the key pair

* @param networkId The targeted network. (ex. default, betanet, etc…)
* @returns{Promise<string[]>}
*/

@@ -74,0 +73,0 @@ getAccounts(networkId: string): Promise<string[]>;

@@ -19,3 +19,3 @@ "use strict";

*
* @example {@link https://docs.near.org/docs/develop/front-end/naj-quick-reference#key-store}
* @see [https://docs.near.org/docs/develop/front-end/naj-quick-reference#key-store](https://docs.near.org/docs/develop/front-end/naj-quick-reference#key-store)
* @example

@@ -50,3 +50,3 @@ * ```js

/**
* Stores a {@link KeyPair} in local storage.
* Stores a {@link utils/key_pair!KeyPair} in local storage.
* @param networkId The targeted network. (ex. default, betanet, etc…)

@@ -62,3 +62,3 @@ * @param accountId The NEAR account tied to the key pair

/**
* Gets a {@link KeyPair} from local storage
* Gets a {@link utils/key_pair!KeyPair} from local storage
* @param networkId The targeted network. (ex. default, betanet, etc…)

@@ -78,3 +78,3 @@ * @param accountId The NEAR account tied to the key pair

/**
* Removes a {@link KeyPair} from local storage
* Removes a {@link utils/key_pair!KeyPair} from local storage
* @param networkId The targeted network. (ex. default, betanet, etc…)

@@ -119,3 +119,2 @@ * @param accountId The NEAR account tied to the key pair

* @param networkId The targeted network. (ex. default, betanet, etc…)
* @returns{Promise<string[]>}
*/

@@ -122,0 +121,0 @@ getAccounts(networkId) {

@@ -6,3 +6,3 @@ import { KeyStore } from './keystore';

*
* @example {@link https://docs.near.org/docs/develop/front-end/naj-quick-reference#key-store}
* @see [https://docs.near.org/docs/develop/front-end/naj-quick-reference#key-store](https://docs.near.org/docs/develop/front-end/naj-quick-reference#key-store)
* @example

@@ -36,3 +36,3 @@ * ```js

/**
* Stores a {@KeyPair} in in-memory storage item
* Stores a {@link utils/key_pair!KeyPair} in in-memory storage item
* @param networkId The targeted network. (ex. default, betanet, etc…)

@@ -44,3 +44,3 @@ * @param accountId The NEAR account tied to the key pair

/**
* Gets a {@link KeyPair} from in-memory storage
* Gets a {@link utils/key_pair!KeyPair} from in-memory storage
* @param networkId The targeted network. (ex. default, betanet, etc…)

@@ -52,3 +52,3 @@ * @param accountId The NEAR account tied to the key pair

/**
* Removes a {@link KeyPair} from in-memory storage
* Removes a {@link utils/key_pair!KeyPair} from in-memory storage
* @param networkId The targeted network. (ex. default, betanet, etc…)

@@ -59,3 +59,3 @@ * @param accountId The NEAR account tied to the key pair

/**
* Removes all {@link KeyPairs} from in-memory storage
* Removes all {@link utils/key_pair!KeyPair} from in-memory storage
*/

@@ -71,3 +71,2 @@ clear(): Promise<void>;

* @param networkId The targeted network. (ex. default, betanet, etc…)
* @returns{Promise<string[]>}
*/

@@ -74,0 +73,0 @@ getAccounts(networkId: string): Promise<string[]>;

@@ -18,3 +18,3 @@ "use strict";

*
* @example {@link https://docs.near.org/docs/develop/front-end/naj-quick-reference#key-store}
* @see [https://docs.near.org/docs/develop/front-end/naj-quick-reference#key-store](https://docs.near.org/docs/develop/front-end/naj-quick-reference#key-store)
* @example

@@ -49,3 +49,3 @@ * ```js

/**
* Stores a {@KeyPair} in in-memory storage item
* Stores a {@link utils/key_pair!KeyPair} in in-memory storage item
* @param networkId The targeted network. (ex. default, betanet, etc…)

@@ -61,3 +61,3 @@ * @param accountId The NEAR account tied to the key pair

/**
* Gets a {@link KeyPair} from in-memory storage
* Gets a {@link utils/key_pair!KeyPair} from in-memory storage
* @param networkId The targeted network. (ex. default, betanet, etc…)

@@ -77,3 +77,3 @@ * @param accountId The NEAR account tied to the key pair

/**
* Removes a {@link KeyPair} from in-memory storage
* Removes a {@link utils/key_pair!KeyPair} from in-memory storage
* @param networkId The targeted network. (ex. default, betanet, etc…)

@@ -88,3 +88,3 @@ * @param accountId The NEAR account tied to the key pair

/**
* Removes all {@link KeyPairs} from in-memory storage
* Removes all {@link utils/key_pair!KeyPair} from in-memory storage
*/

@@ -113,3 +113,2 @@ clear() {

* @param networkId The targeted network. (ex. default, betanet, etc…)
* @returns{Promise<string[]>}
*/

@@ -116,0 +115,0 @@ getAccounts(networkId) {

import { KeyPair } from '../utils/key_pair';
/**
* KeyStores are passed to {@link Near} via {@link NearConfig}
* and are used by the {@link InMemorySigner} to sign transactions.
* KeyStores are passed to {@link near!Near} via {@link near!NearConfig}
* and are used by the {@link signer!InMemorySigner} to sign transactions.
*
* @example {@link connect}
* @see {@link connect}
*/

@@ -8,0 +8,0 @@ export declare abstract class KeyStore {

@@ -5,6 +5,6 @@ "use strict";

/**
* KeyStores are passed to {@link Near} via {@link NearConfig}
* and are used by the {@link InMemorySigner} to sign transactions.
* KeyStores are passed to {@link near!Near} via {@link near!NearConfig}
* and are used by the {@link signer!InMemorySigner} to sign transactions.
*
* @example {@link connect}
* @see {@link connect}
*/

@@ -11,0 +11,0 @@ class KeyStore {

@@ -48,3 +48,3 @@ import { KeyStore } from './keystore';

/**
* Store a {@link KeyPain} to the first index of a key store array
* Store a {@link utils/key_pair!KeyPair} to the first index of a key store array
* @param networkId The targeted network. (ex. default, betanet, etc…)

@@ -56,3 +56,3 @@ * @param accountId The NEAR account tied to the key pair

/**
* Gets a {@link KeyPair} from the array of key stores
* Gets a {@link utils/key_pair!KeyPair} from the array of key stores
* @param networkId The targeted network. (ex. default, betanet, etc…)

@@ -64,3 +64,3 @@ * @param accountId The NEAR account tied to the key pair

/**
* Removes a {@link KeyPair} from the array of key stores
* Removes a {@link utils/key_pair!KeyPair} from the array of key stores
* @param networkId The targeted network. (ex. default, betanet, etc…)

@@ -82,3 +82,2 @@ * @param accountId The NEAR account tied to the key pair

* @param networkId The targeted network. (ex. default, betanet, etc…)
* @returns{Promise<string[]>}
*/

@@ -85,0 +84,0 @@ getAccounts(networkId: string): Promise<string[]>;

@@ -25,3 +25,3 @@ "use strict";

/**
* Store a {@link KeyPain} to the first index of a key store array
* Store a {@link utils/key_pair!KeyPair} to the first index of a key store array
* @param networkId The targeted network. (ex. default, betanet, etc…)

@@ -37,3 +37,3 @@ * @param accountId The NEAR account tied to the key pair

/**
* Gets a {@link KeyPair} from the array of key stores
* Gets a {@link utils/key_pair!KeyPair} from the array of key stores
* @param networkId The targeted network. (ex. default, betanet, etc…)

@@ -55,3 +55,3 @@ * @param accountId The NEAR account tied to the key pair

/**
* Removes a {@link KeyPair} from the array of key stores
* Removes a {@link utils/key_pair!KeyPair} from the array of key stores
* @param networkId The targeted network. (ex. default, betanet, etc…)

@@ -95,3 +95,2 @@ * @param accountId The NEAR account tied to the key pair

* @param networkId The targeted network. (ex. default, betanet, etc…)
* @returns{Promise<string[]>}
*/

@@ -98,0 +97,0 @@ getAccounts(networkId) {

@@ -8,5 +8,5 @@ import { KeyPair } from '../utils/key_pair';

/**
* This module contains the {@link UnencryptedFileSystemKeyStore} class which is used to store keys on the file system.
* This class is used to store keys on the file system.
*
* @example {@link https://docs.near.org/docs/develop/front-end/naj-quick-reference#key-store}
* @see [https://docs.near.org/docs/develop/front-end/naj-quick-reference#key-store](https://docs.near.org/docs/develop/front-end/naj-quick-reference#key-store)
* @example

@@ -39,3 +39,3 @@ * ```js

/**
* Store a {@link KeyPair} in an unencrypted file
* Store a {@link utils/key_pair!KeyPair} in an unencrypted file
* @param networkId The targeted network. (ex. default, betanet, etc…)

@@ -47,3 +47,3 @@ * @param accountId The NEAR account tied to the key pair

/**
* Gets a {@link KeyPair} from an unencrypted file
* Gets a {@link utils/key_pair!KeyPair} from an unencrypted file
* @param networkId The targeted network. (ex. default, betanet, etc…)

@@ -55,3 +55,3 @@ * @param accountId The NEAR account tied to the key pair

/**
* Deletes an unencrypted file holding a {@link KeyPair}
* Deletes an unencrypted file holding a {@link utils/key_pair!KeyPair}
* @param networkId The targeted network. (ex. default, betanet, etc…)

@@ -75,3 +75,2 @@ * @param accountId The NEAR account tied to the key pair

* @param networkId The targeted network. (ex. default, betanet, etc…)
* @returns{Promise<string[]>}
*/

@@ -78,0 +77,0 @@ getAccounts(networkId: string): Promise<string[]>;

@@ -69,5 +69,5 @@ "use strict";

/**
* This module contains the {@link UnencryptedFileSystemKeyStore} class which is used to store keys on the file system.
* This class is used to store keys on the file system.
*
* @example {@link https://docs.near.org/docs/develop/front-end/naj-quick-reference#key-store}
* @see [https://docs.near.org/docs/develop/front-end/naj-quick-reference#key-store](https://docs.near.org/docs/develop/front-end/naj-quick-reference#key-store)
* @example

@@ -101,3 +101,3 @@ * ```js

/**
* Store a {@link KeyPair} in an unencrypted file
* Store a {@link utils/key_pair!KeyPair} in an unencrypted file
* @param networkId The targeted network. (ex. default, betanet, etc…)

@@ -115,3 +115,3 @@ * @param accountId The NEAR account tied to the key pair

/**
* Gets a {@link KeyPair} from an unencrypted file
* Gets a {@link utils/key_pair!KeyPair} from an unencrypted file
* @param networkId The targeted network. (ex. default, betanet, etc…)

@@ -132,3 +132,3 @@ * @param accountId The NEAR account tied to the key pair

/**
* Deletes an unencrypted file holding a {@link KeyPair}
* Deletes an unencrypted file holding a {@link utils/key_pair!KeyPair}
* @param networkId The targeted network. (ex. default, betanet, etc…)

@@ -177,3 +177,2 @@ * @param accountId The NEAR account tied to the key pair

* @param networkId The targeted network. (ex. default, betanet, etc…)
* @returns{Promise<string[]>}
*/

@@ -180,0 +179,0 @@ getAccounts(networkId) {

@@ -8,3 +8,3 @@ import { Account } from './account';

export interface NearConfig {
/** Holds {@link KeyPair | KeyPairs} for signing transactions */
/** Holds {@link utils/key_pair!KeyPair | KeyPairs} for signing transactions */
keyStore?: KeyStore;

@@ -14,9 +14,9 @@ /** @hidden */

/**
* {@link https://github.com/near/near-contract-helper | NEAR Contract Helper} url used to create accounts if no master account is provided
* @see {@link UrlAccountCreator}
* [NEAR Contract Helper](https://github.com/near/near-contract-helper) url used to create accounts if no master account is provided
* @see {@link account_creator!UrlAccountCreator}
*/
helperUrl?: string;
/**
* The balance transferred from the {@link NearConfig.masterAccount | masterAccount} to a created account
* @see {@link LocalAccountCreator}
* The balance transferred from the {@link masterAccount} to a created account
* @see {@link account_creator!LocalAccountCreator}
*/

@@ -26,7 +26,7 @@ initialBalance?: string;

* The account to use when creating new accounts
* @see {@link LocalAccountCreator}
* @see {@link account_creator!LocalAccountCreator}
*/
masterAccount?: string;
/**
* {@link KeyPair | KeyPairs} are stored in a {@link KeyStore} under the `networkId` namespace.
* {@link utils/key_pair!KeyPair | KeyPairs} are stored in a {@link key_stores/keystore!KeyStore} under the `networkId` namespace.
*/

@@ -36,3 +36,3 @@ networkId: string;

* NEAR RPC API url. used to make JSON RPC calls to interact with NEAR.
* @see {@link JsonRpcProvider.JsonRpcProvider | JsonRpcProvider}
* @see {@link providers/json-rpc-provider!JsonRpcProvider}
*/

@@ -42,3 +42,3 @@ nodeUrl: string;

* NEAR RPC API headers. Can be used to pass API KEY and other parameters.
* @see {@link JsonRpcProvider.JsonRpcProvider | JsonRpcProvider}
* @see {@link providers/json-rpc-provider!JsonRpcProvider}
*/

@@ -50,3 +50,3 @@ headers?: {

* NEAR wallet url used to redirect users to their wallet in browser applications.
* @see {@link https://docs.near.org/docs/tools/near-wallet}
* @see [https://wallet.near.org/](https://wallet.near.org/)
*/

@@ -76,6 +76,6 @@ walletUrl?: string;

/**
* Create an account using the {@link AccountCreator}. Either:
* * using a masterAccount with {@link LocalAccountCreator}
* * using the helperUrl with {@link UrlAccountCreator}
* @see {@link NearConfig.masterAccount} and {@link NearConfig.helperUrl}-
* Create an account using the {@link account_creator!AccountCreator}. Either:
* * using a masterAccount with {@link account_creator!LocalAccountCreator}
* * using the helperUrl with {@link account_creator!UrlAccountCreator}
* @see {@link NearConfig.masterAccount} and {@link NearConfig.helperUrl}
*

@@ -82,0 +82,0 @@ * @param accountId

@@ -18,6 +18,6 @@ "use strict";

* This module contains the main class developers will use to interact with NEAR.
* The {@link Near} class is used to interact with {@link Account | Accounts} through the {@link JsonRpcProvider.JsonRpcProvider | JsonRpcProvider}.
* The {@link Near} class is used to interact with {@link account!Account | Accounts} through the {@link providers/json-rpc-provider!JsonRpcProvider}.
* It is configured via the {@link NearConfig}.
*
* @example {@link https://docs.near.org/docs/develop/front-end/naj-quick-reference#account}
* @see [https://docs.near.org/tools/near-api-js/quick-reference#account](https://docs.near.org/tools/near-api-js/quick-reference#account)
*

@@ -69,6 +69,6 @@ * @module near

/**
* Create an account using the {@link AccountCreator}. Either:
* * using a masterAccount with {@link LocalAccountCreator}
* * using the helperUrl with {@link UrlAccountCreator}
* @see {@link NearConfig.masterAccount} and {@link NearConfig.helperUrl}-
* Create an account using the {@link account_creator!AccountCreator}. Either:
* * using a masterAccount with {@link account_creator!LocalAccountCreator}
* * using the helperUrl with {@link account_creator!UrlAccountCreator}
* @see {@link NearConfig.masterAccount} and {@link NearConfig.helperUrl}
*

@@ -75,0 +75,0 @@ * @param accountId

/**
* @module
* @description
* This module contains the {@link JsonRpcProvider} client class
* which can be used to interact with the NEAR RPC API.
* @see {@link providers/provider} for a list of request and response types
* which can be used to interact with the [NEAR RPC API](https://docs.near.org/api/rpc/introduction).
* @see {@link providers/provider | providers} for a list of request and response types
*/

@@ -13,4 +15,4 @@ import { AccessKeyWithPublicKey, Provider, FinalExecutionOutcome, NodeStatusResult, BlockId, BlockReference, BlockResult, BlockChangeResult, ChangeResult, ChunkId, ChunkResult, EpochValidatorInfo, NearProtocolConfig, LightClientProof, LightClientProofRequest, GasPrice, QueryResponseKind } from './provider';

/**
* Client class to interact with the NEAR RPC API.
* @see {@link https://github.com/near/nearcore/tree/master/chain/jsonrpc}
* Client class to interact with the [NEAR RPC API](https://docs.near.org/api/rpc/introduction).
* @see [https://github.com/near/nearcore/tree/master/chain/jsonrpc](https://github.com/near/nearcore/tree/master/chain/jsonrpc)
*/

@@ -26,3 +28,3 @@ export declare class JsonRpcProvider extends Provider {

* Gets the RPC's status
* @see {@link https://docs.near.org/docs/develop/front-end/rpc#general-validator-status}
* @see [https://docs.near.org/docs/develop/front-end/rpc#general-validator-status](https://docs.near.org/docs/develop/front-end/rpc#general-validator-status)
*/

@@ -32,3 +34,3 @@ status(): Promise<NodeStatusResult>;

* Sends a signed transaction to the RPC and waits until transaction is fully complete
* @see {@link https://docs.near.org/docs/develop/front-end/rpc#send-transaction-await}
* @see [https://docs.near.org/docs/develop/front-end/rpc#send-transaction-await](https://docs.near.org/docs/develop/front-end/rpc#general-validator-status)
*

@@ -47,3 +49,3 @@ * @param signedTransaction The signed transaction being sent

* Gets a transaction's status from the RPC
* @see {@link https://docs.near.org/docs/develop/front-end/rpc#transaction-status}
* @see [https://docs.near.org/docs/develop/front-end/rpc#transaction-status](https://docs.near.org/docs/develop/front-end/rpc#general-validator-status)
*

@@ -65,5 +67,4 @@ * @param txHash A transaction hash as either a Uint8Array or a base58 encoded string

/**
* Query the RPC as [shown in the docs](https://docs.near.org/docs/develop/front-end/rpc#accounts--contracts)
* Query the RPC by passing an {@link RpcQueryRequest}
* @see {@link https://docs.near.org/docs/develop/front-end/rpc#accounts--contracts}
* Query the RPC by passing an {@link providers/provider!RpcQueryRequest}
* @see [https://docs.near.org/api/rpc/contracts](https://docs.near.org/api/rpc/contracts)
*

@@ -76,5 +77,5 @@ * @typeParam T the shape of the returned query response

* pass block_id OR finality as blockQuery, not both
* @see {@link https://docs.near.org/docs/interaction/rpc#block}
* @see [https://docs.near.org/api/rpc/block-chunk](https://docs.near.org/api/rpc/block-chunk)
*
* @param blockQuery {@link BlockReference} (passing a {@link BlockId} is deprecated)
* @param blockQuery {@link providers/provider!BlockReference} (passing a {@link providers/provider!BlockId} is deprecated)
*/

@@ -85,3 +86,3 @@ block(blockQuery: BlockId | BlockReference): Promise<BlockResult>;

* pass block_id OR finality as blockQuery, not both
* See [docs for more info](https://docs.near.org/docs/develop/front-end/rpc#block-details)
* @see [https://docs.near.org/api/rpc/block-chunk](https://docs.near.org/api/rpc/block-chunk)
*/

@@ -91,3 +92,3 @@ blockChanges(blockQuery: BlockReference): Promise<BlockChangeResult>;

* Queries for details about a specific chunk appending details of receipts and transactions to the same chunk data provided by a block
* @see {@link https://docs.near.org/docs/interaction/rpc#chunk}
* @see [https://docs.near.org/api/rpc/block-chunk](https://docs.near.org/api/rpc/block-chunk)
*

@@ -99,3 +100,3 @@ * @param chunkId Hash of a chunk ID or shard ID

* Query validators of the epoch defined by the given block id.
* @see {@link https://docs.near.org/docs/develop/front-end/rpc#detailed-validator-status}
* @see [https://docs.near.org/api/rpc/network#validation-status](https://docs.near.org/api/rpc/network#validation-status)
*

@@ -107,3 +108,2 @@ * @param blockId Block hash or height, or null for latest.

* Gets the protocol config at a block from RPC
* @see {@link }
*

@@ -117,3 +117,3 @@ * @param blockReference specifies the block to get the protocol config for

* Gets a light client execution proof for verifying execution outcomes
* @see {@link https://github.com/nearprotocol/NEPs/blob/master/specs/ChainSpec/LightClient.md#light-client-proof}
* @see [https://github.com/nearprotocol/NEPs/blob/master/specs/ChainSpec/LightClient.md#light-client-proof](https://github.com/nearprotocol/NEPs/blob/master/specs/ChainSpec/LightClient.md#light-client-proof)
*/

@@ -159,3 +159,3 @@ lightClientProof(request: LightClientProofRequest): Promise<LightClientProof>;

* Returns gas price for a specific block_height or block_hash.
* @see {@link https://docs.near.org/docs/develop/front-end/rpc#gas-price}
* @see [https://docs.near.org/api/rpc/gas](https://docs.near.org/api/rpc/gas)
*

@@ -162,0 +162,0 @@ * @param blockId Block hash or height, or null for latest.

@@ -28,5 +28,7 @@ "use strict";

/**
* @module
* @description
* This module contains the {@link JsonRpcProvider} client class
* which can be used to interact with the NEAR RPC API.
* @see {@link providers/provider} for a list of request and response types
* which can be used to interact with the [NEAR RPC API](https://docs.near.org/api/rpc/introduction).
* @see {@link providers/provider | providers} for a list of request and response types
*/

@@ -50,4 +52,4 @@ const provider_1 = require("./provider");

/**
* Client class to interact with the NEAR RPC API.
* @see {@link https://github.com/near/nearcore/tree/master/chain/jsonrpc}
* Client class to interact with the [NEAR RPC API](https://docs.near.org/api/rpc/introduction).
* @see [https://github.com/near/nearcore/tree/master/chain/jsonrpc](https://github.com/near/nearcore/tree/master/chain/jsonrpc)
*/

@@ -64,3 +66,3 @@ class JsonRpcProvider extends provider_1.Provider {

* Gets the RPC's status
* @see {@link https://docs.near.org/docs/develop/front-end/rpc#general-validator-status}
* @see [https://docs.near.org/docs/develop/front-end/rpc#general-validator-status](https://docs.near.org/docs/develop/front-end/rpc#general-validator-status)
*/

@@ -74,3 +76,3 @@ status() {

* Sends a signed transaction to the RPC and waits until transaction is fully complete
* @see {@link https://docs.near.org/docs/develop/front-end/rpc#send-transaction-await}
* @see [https://docs.near.org/docs/develop/front-end/rpc#send-transaction-await](https://docs.near.org/docs/develop/front-end/rpc#general-validator-status)
*

@@ -99,3 +101,3 @@ * @param signedTransaction The signed transaction being sent

* Gets a transaction's status from the RPC
* @see {@link https://docs.near.org/docs/develop/front-end/rpc#transaction-status}
* @see [https://docs.near.org/docs/develop/front-end/rpc#transaction-status](https://docs.near.org/docs/develop/front-end/rpc#general-validator-status)
*

@@ -143,5 +145,4 @@ * @param txHash A transaction hash as either a Uint8Array or a base58 encoded string

/**
* Query the RPC as [shown in the docs](https://docs.near.org/docs/develop/front-end/rpc#accounts--contracts)
* Query the RPC by passing an {@link RpcQueryRequest}
* @see {@link https://docs.near.org/docs/develop/front-end/rpc#accounts--contracts}
* Query the RPC by passing an {@link providers/provider!RpcQueryRequest}
* @see [https://docs.near.org/api/rpc/contracts](https://docs.near.org/api/rpc/contracts)
*

@@ -170,5 +171,5 @@ * @typeParam T the shape of the returned query response

* pass block_id OR finality as blockQuery, not both
* @see {@link https://docs.near.org/docs/interaction/rpc#block}
* @see [https://docs.near.org/api/rpc/block-chunk](https://docs.near.org/api/rpc/block-chunk)
*
* @param blockQuery {@link BlockReference} (passing a {@link BlockId} is deprecated)
* @param blockQuery {@link providers/provider!BlockReference} (passing a {@link providers/provider!BlockId} is deprecated)
*/

@@ -185,3 +186,3 @@ block(blockQuery) {

* pass block_id OR finality as blockQuery, not both
* See [docs for more info](https://docs.near.org/docs/develop/front-end/rpc#block-details)
* @see [https://docs.near.org/api/rpc/block-chunk](https://docs.near.org/api/rpc/block-chunk)
*/

@@ -197,3 +198,3 @@ blockChanges(blockQuery) {

* Queries for details about a specific chunk appending details of receipts and transactions to the same chunk data provided by a block
* @see {@link https://docs.near.org/docs/interaction/rpc#chunk}
* @see [https://docs.near.org/api/rpc/block-chunk](https://docs.near.org/api/rpc/block-chunk)
*

@@ -209,3 +210,3 @@ * @param chunkId Hash of a chunk ID or shard ID

* Query validators of the epoch defined by the given block id.
* @see {@link https://docs.near.org/docs/develop/front-end/rpc#detailed-validator-status}
* @see [https://docs.near.org/api/rpc/network#validation-status](https://docs.near.org/api/rpc/network#validation-status)
*

@@ -221,3 +222,2 @@ * @param blockId Block hash or height, or null for latest.

* Gets the protocol config at a block from RPC
* @see {@link }
*

@@ -228,3 +228,4 @@ * @param blockReference specifies the block to get the protocol config for

return __awaiter(this, void 0, void 0, function* () {
return yield this.sendJsonRpc('EXPERIMENTAL_protocol_config', blockReference);
const _a = blockReference, { blockId } = _a, otherParams = __rest(_a, ["blockId"]);
return yield this.sendJsonRpc('EXPERIMENTAL_protocol_config', Object.assign(Object.assign({}, otherParams), { block_id: blockId }));
});

@@ -234,3 +235,3 @@ }

* Gets a light client execution proof for verifying execution outcomes
* @see {@link https://github.com/nearprotocol/NEPs/blob/master/specs/ChainSpec/LightClient.md#light-client-proof}
* @see [https://github.com/nearprotocol/NEPs/blob/master/specs/ChainSpec/LightClient.md#light-client-proof](https://github.com/nearprotocol/NEPs/blob/master/specs/ChainSpec/LightClient.md#light-client-proof)
*/

@@ -336,3 +337,3 @@ lightClientProof(request) {

* Returns gas price for a specific block_height or block_hash.
* @see {@link https://docs.near.org/docs/develop/front-end/rpc#gas-price}
* @see [https://docs.near.org/api/rpc/gas](https://docs.near.org/api/rpc/gas)
*

@@ -339,0 +340,0 @@ * @param blockId Block hash or height, or null for latest.

@@ -6,2 +6,3 @@ /**

import { SignedTransaction } from '../transaction';
import BN from 'bn.js';
export interface SyncInfo {

@@ -168,3 +169,3 @@ latest_block_hash: string;

hash: string;
nonce: bigint;
nonce: BN;
public_key: string;

@@ -307,6 +308,10 @@ receiver_id: string;

}
export interface AccessKeyView extends QueryResponseKind {
export interface AccessKeyViewRaw extends QueryResponseKind {
nonce: number;
permission: 'FullAccess' | FunctionCallPermissionView;
}
export interface AccessKeyView extends QueryResponseKind {
nonce: BN;
permission: 'FullAccess' | FunctionCallPermissionView;
}
export interface AccessKeyInfoView {

@@ -313,0 +318,0 @@ public_key: string;

@@ -18,3 +18,2 @@ /// <reference types="node" />

export declare class AccessKey extends Assignable {
nonce: number;
permission: AccessKeyPermission;

@@ -81,3 +80,3 @@ }

publicKey: PublicKey;
nonce: number;
nonce: BN;
receiverId: string;

@@ -111,5 +110,5 @@ actions: Action[];

export declare const SCHEMA: Map<Class<any>, any>;
export declare function createTransaction(signerId: string, publicKey: PublicKey, receiverId: string, nonce: number, actions: Action[], blockHash: Uint8Array): Transaction;
export declare function createTransaction(signerId: string, publicKey: PublicKey, receiverId: string, nonce: BN | string | number, actions: Action[], blockHash: Uint8Array): Transaction;
export declare function signTransaction(transaction: Transaction, signer: Signer, accountId?: string, networkId?: string): Promise<[Uint8Array, SignedTransaction]>;
export declare function signTransaction(receiverId: string, nonce: number, actions: Action[], blockHash: Uint8Array, signer: Signer, accountId?: string, networkId?: string): Promise<[Uint8Array, SignedTransaction]>;
export declare function signTransaction(receiverId: string, nonce: BN, actions: Action[], blockHash: Uint8Array, signer: Signer, accountId?: string, networkId?: string): Promise<[Uint8Array, SignedTransaction]>;
export {};

@@ -33,7 +33,7 @@ "use strict";

function fullAccessKey() {
return new AccessKey({ nonce: 0, permission: new AccessKeyPermission({ fullAccess: new FullAccessPermission({}) }) });
return new AccessKey({ permission: new AccessKeyPermission({ fullAccess: new FullAccessPermission({}) }) });
}
exports.fullAccessKey = fullAccessKey;
function functionCallAccessKey(receiverId, methodNames, allowance) {
return new AccessKey({ nonce: 0, permission: new AccessKeyPermission({ functionCall: new FunctionCallPermission({ receiverId, allowance, methodNames }) }) });
return new AccessKey({ permission: new AccessKeyPermission({ functionCall: new FunctionCallPermission({ receiverId, allowance, methodNames }) }) });
}

@@ -40,0 +40,0 @@ exports.functionCallAccessKey = functionCallAccessKey;

/**
* The classes in this module are used in conjunction with the {@link BrowserLocalStorageKeyStore}. This module exposes two classes:
* * {@link WalletConnection} which redirects users to {@link https://docs.near.org/docs/tools/near-wallet | NEAR Wallet} for key management.
* * {@link ConnectedWalletAccount} is an {@link Account} implementation that uses {@link WalletConnection} to get keys
* The classes in this module are used in conjunction with the {@link key_stores/browser_local_storage_key_store!BrowserLocalStorageKeyStore}.
* This module exposes two classes:
* * {@link WalletConnection} which redirects users to [NEAR Wallet](https://wallet.near.org/) for key management.
* * {@link ConnectedWalletAccount} is an {@link account!Account} implementation that uses {@link WalletConnection} to get keys
*

@@ -33,7 +34,7 @@ * @module walletAccount

/**
* This class is used in conjunction with the {@link BrowserLocalStorageKeyStore}.
* It redirects users to {@link https://docs.near.org/docs/tools/near-wallet | NEAR Wallet} for key management.
* This class is used in conjunction with the {@link key_stores/browser_local_storage_key_store!BrowserLocalStorageKeyStore}.
* It redirects users to [NEAR Wallet](https://wallet.near.org) for key management.
* This class is not intended for use outside the browser. Without `window` (i.e. in server contexts), it will instantiate but will throw a clear error when used.
*
* @example {@link https://docs.near.org/docs/develop/front-end/naj-quick-reference#wallet}
* @see [https://docs.near.org/tools/near-api-js/quick-reference#wallet](https://docs.near.org/tools/near-api-js/quick-reference#wallet)
* @example

@@ -57,3 +58,6 @@ * ```js

/** @hidden */
_authData: any;
_authData: {
accountId?: string;
allKeys?: string[];
};
/** @hidden */

@@ -96,3 +100,3 @@ _networkId: string;

*/
getAccountId(): any;
getAccountId(): string;
/**

@@ -140,3 +144,3 @@ * Redirects current page to the wallet authentication page.

/**
* {@link Account} implementation which redirects to wallet using {@link WalletConnection} when no local key is available.
* {@link account!Account} implementation which redirects to wallet using {@link WalletConnection} when no local key is available.
*/

@@ -153,3 +157,3 @@ export declare class ConnectedWalletAccount extends Account {

* Check if given access key allows the function call or method attempted in transaction
* @param accessKey Array of {access_key: AccessKey, public_key: PublicKey} items
* @param accessKey Array of \{access_key: AccessKey, public_key: PublicKey\} items
* @param receiverId The NEAR account attempting to have access

@@ -164,3 +168,2 @@ * @param actions The action(s) needed to be checked for access

* @param localKey A local public key provided to check for access
* @returns Promise<any>
*/

@@ -167,0 +170,0 @@ accessKeyForTransaction(receiverId: string, actions: Action[], localKey?: PublicKey): Promise<any>;

@@ -11,8 +11,12 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConnectedWalletAccount = exports.WalletConnection = void 0;
/**
* The classes in this module are used in conjunction with the {@link BrowserLocalStorageKeyStore}. This module exposes two classes:
* * {@link WalletConnection} which redirects users to {@link https://docs.near.org/docs/tools/near-wallet | NEAR Wallet} for key management.
* * {@link ConnectedWalletAccount} is an {@link Account} implementation that uses {@link WalletConnection} to get keys
* The classes in this module are used in conjunction with the {@link key_stores/browser_local_storage_key_store!BrowserLocalStorageKeyStore}.
* This module exposes two classes:
* * {@link WalletConnection} which redirects users to [NEAR Wallet](https://wallet.near.org/) for key management.
* * {@link ConnectedWalletAccount} is an {@link account!Account} implementation that uses {@link WalletConnection} to get keys
*

@@ -26,2 +30,3 @@ * @module walletAccount

const borsh_2 = require("borsh");
const bn_js_1 = __importDefault(require("bn.js"));
const LOGIN_WALLET_URL_SUFFIX = '/login/';

@@ -32,7 +37,7 @@ const MULTISIG_HAS_METHOD = 'add_request_and_confirm';

/**
* This class is used in conjunction with the {@link BrowserLocalStorageKeyStore}.
* It redirects users to {@link https://docs.near.org/docs/tools/near-wallet | NEAR Wallet} for key management.
* This class is used in conjunction with the {@link key_stores/browser_local_storage_key_store!BrowserLocalStorageKeyStore}.
* It redirects users to [NEAR Wallet](https://wallet.near.org) for key management.
* This class is not intended for use outside the browser. Without `window` (i.e. in server contexts), it will instantiate but will throw a clear error when used.
*
* @example {@link https://docs.near.org/docs/develop/front-end/naj-quick-reference#wallet}
* @see [https://docs.near.org/tools/near-api-js/quick-reference#wallet](https://docs.near.org/tools/near-api-js/quick-reference#wallet)
* @example

@@ -239,3 +244,3 @@ * ```js

/**
* {@link Account} implementation which redirects to wallet using {@link WalletConnection} when no local key is available.
* {@link account!Account} implementation which redirects to wallet using {@link WalletConnection} when no local key is available.
*/

@@ -279,3 +284,3 @@ class ConnectedWalletAccount extends account_1.Account {

// TODO: Cache & listen for nonce updates for given access key
const nonce = accessKey.access_key.nonce + 1;
const nonce = accessKey.access_key.nonce.add(new bn_js_1.default(1));
const transaction = (0, transaction_1.createTransaction)(this.accountId, publicKey, receiverId, nonce, actions, blockHash);

@@ -298,3 +303,3 @@ yield this.walletConnection.requestSignTransactions({

* Check if given access key allows the function call or method attempted in transaction
* @param accessKey Array of {access_key: AccessKey, public_key: PublicKey} items
* @param accessKey Array of \{access_key: AccessKey, public_key: PublicKey\} items
* @param receiverId The NEAR account attempting to have access

@@ -338,3 +343,2 @@ * @param actions The action(s) needed to be checked for access

* @param localKey A local public key provided to check for access
* @returns Promise<any>
*/

@@ -341,0 +345,0 @@ accessKeyForTransaction(receiverId, actions, localKey) {

{
"name": "near-api-js",
"description": "JavaScript library to interact with NEAR Protocol via RPC API",
"version": "1.0.0",
"repository": {
"type": "git",
"url": "git+https://github.com/near/near-api-js.git"
},
"homepage": "https://github.com/near/near-api-js",
"main": "lib/index.js",
"browser": "lib/browser-index.js",
"types": "lib/index.d.ts",
"dependencies": {
"bn.js": "5.2.1",
"borsh": "^0.7.0",
"bs58": "^4.0.0",
"depd": "^2.0.0",
"error-polyfill": "^0.1.3",
"http-errors": "^1.7.2",
"js-sha256": "^0.9.0",
"mustache": "^4.0.0",
"node-fetch": "^2.6.1",
"text-encoding-utf-8": "^1.0.2",
"tweetnacl": "^1.0.1"
},
"devDependencies": {
"@types/bn.js": "^5.1.0",
"@types/http-errors": "^1.6.1",
"browserify": "^16.2.3",
"bundlewatch": "^0.3.1",
"concurrently": "^7.3.0",
"danger": "^11.1.1",
"danger-plugin-yarn": "^1.3.2",
"husky": "^7.0.4",
"in-publish": "^2.0.0",
"jest": "^26.0.1",
"localstorage-memory": "^1.0.3",
"near-hello": "^0.5.1",
"rimraf": "^3.0.0",
"semver": "^7.1.1",
"ts-jest": "^26.5.6",
"ts-morph": "^15.1.0",
"typedoc": "0.23.10",
"typedoc-neo-theme": "^1.1.1",
"typescript": "^4.7.4",
"uglifyify": "^5.0.1"
},
"keywords": [],
"license": "(MIT AND Apache-2.0)",
"scripts": {
"dist": "yarn browserify && yarn doc",
"browserify": "browserify browser-exports.js -i node-fetch -i http -i https -o dist/near-api-js.js && browserify browser-exports.js -i node-fetch -g uglifyify -o dist/near-api-js.min.js",
"prebrowserify": "yarn build",
"compile": "tsc -p ./tsconfig.json",
"dev": "yarn compile -w",
"doc": "typedoc src && touch docs/.nojekyll",
"build": "yarn compile",
"test": "jest test",
"lint": "concurrently \"yarn:lint:*(!fix)\"",
"lint:src": "eslint --ext .ts src",
"lint:test": "eslint --ext .js test",
"lint:fix": "concurrently \"yarn:lint:*:fix\"",
"lint:src:fix": "eslint --ext .ts --fix src",
"lint:test:fix": "eslint --ext .js --fix test",
"prefuzz": "yarn build",
"fuzz": "jsfuzz test/fuzz/borsh-roundtrip.js test/fuzz/corpus/",
"clean": "yarn rimraf lib",
"prepare": "yarn build && yarn browserify"
},
"bundlewatch": {
"files": [
{
"path": "dist/near-api-js.min.js",
"maxSize": "105kB"
}
]
},
"name": "near-api-js",
"description": "JavaScript library to interact with NEAR Protocol via RPC API",
"version": "1.1.0",
"repository": {
"type": "git",
"url": "git+https://github.com/near/near-api-js.git"
},
"homepage": "https://github.com/near/near-api-js",
"main": "lib/index.js",
"browser": "lib/browser-index.js",
"types": "lib/index.d.ts",
"dependencies": {
"bn.js": "5.2.1",
"borsh": "^0.7.0",
"bs58": "^4.0.0",
"depd": "^2.0.0",
"error-polyfill": "^0.1.3",
"http-errors": "^1.7.2",
"js-sha256": "^0.9.0",
"mustache": "^4.0.0",
"node-fetch": "^2.6.1",
"text-encoding-utf-8": "^1.0.2",
"tweetnacl": "^1.0.1"
},
"devDependencies": {
"@types/bn.js": "^5.1.0",
"@types/http-errors": "^1.6.1",
"@types/node": "^18.7.14",
"browserify": "^16.2.3",
"bundlewatch": "^0.3.1",
"concurrently": "^7.3.0",
"danger": "^11.1.1",
"danger-plugin-yarn": "^1.3.2",
"in-publish": "^2.0.0",
"jest": "^26.0.1",
"localstorage-memory": "^1.0.3",
"near-hello": "^0.5.1",
"rimraf": "^3.0.0",
"semver": "^7.1.1",
"ts-jest": "^26.5.6",
"uglifyify": "^5.0.1"
},
"keywords": [],
"license": "(MIT AND Apache-2.0)",
"bundlewatch": {
"files": [
"lib",
"dist",
"browser-exports.js"
],
"author": "NEAR Inc"
}
{
"path": "dist/near-api-js.min.js",
"maxSize": "105kB"
}
]
},
"files": [
"lib",
"dist",
"browser-exports.js"
],
"author": "NEAR Inc",
"scripts": {
"dist": "pnpm browserify",
"browserify": "browserify browser-exports.js -i node-fetch -i http -i https -o dist/near-api-js.js && browserify browser-exports.js -i node-fetch -g uglifyify -o dist/near-api-js.min.js",
"compile": "tsc -p ./tsconfig.json",
"dev": "pnpm compile -w",
"build": "pnpm compile && pnpm browserify",
"test": "jest test",
"lint": "concurrently \"pnpm:lint:*(!fix)\"",
"lint:src": "eslint --ext .ts src",
"lint:test": "eslint --ext .js test",
"lint:fix": "concurrently \"pnpm:lint:*:fix\"",
"lint:src:fix": "eslint --ext .ts --fix src",
"lint:test:fix": "eslint --ext .js --fix test",
"prefuzz": "pnpm build",
"fuzz": "jsfuzz test/fuzz/borsh-roundtrip.js test/fuzz/corpus/",
"clean": "pnpm rimraf lib",
"bundlewatch": "bundlewatch"
}
}

@@ -1,64 +0,18 @@

# near-api-js
# NEAR JavaScript API
[![Build Status](https://travis-ci.com/near/near-api-js.svg?branch=master)](https://travis-ci.com/near/near-api-js)
[![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/near/near-api-js)
NEAR JavaScript API is a complete library to interact with the NEAR blockchain. You can use it in the browser, or in Node.js runtime.
A JavaScript/TypeScript library for development of DApps on the NEAR platform
## Documentation
# Documentation
- [Learn how to use](https://docs.near.org/tools/near-api-js/quick-reference) the library in your project
[Read the TypeDoc API documentation](https://near.github.io/near-api-js/)
- Read the [TypeDoc API](https://near.github.io/near-api-js/) documentation
---
- [Cookbook](https://github.com/near/near-api-js/blob/master/examples/cookbook/README.md) with common use cases
# Examples
- To quickly get started with integrating NEAR in a _web browser_, read our [Web Frontend integration](https://docs.near.org/develop/integrate/frontend) article.
## [Quick Reference](https://github.com/near/near-api-js/blob/master/examples/quick-reference.md)
_(Cheat sheet / quick reference)_
## [Cookbook](https://github.com/near/near-api-js/blob/master/examples/cookbook/README.md)
_(Common use cases / more complex examples)_
---
# Contribute to this library
1. Install dependencies
yarn
2. Run continuous build with:
yarn build -- -w
# Publish
Prepare `dist` version by running:
yarn dist
When publishing to npm use [np](https://github.com/sindresorhus/np).
---
# Integration Test
Start the node by following instructions from [nearcore](https://github.com/nearprotocol/nearcore), then
yarn test
Tests use sample contract from `near-hello` npm package, see https://github.com/nearprotocol/near-hello
# Update error schema
Follow next steps:
1. [Change hash for the commit with errors in the nearcore](https://github.com/near/near-api-js/blob/master/fetch_error_schema.js#L8-L9)
2. Fetch new schema: `node fetch_error_schema.js`
3. `yarn build` to update `lib/**.js` files
# License
This repository is distributed under the terms of both the MIT license and the Apache License (Version 2.0).
See [LICENSE](LICENSE) and [LICENSE-APACHE](LICENSE-APACHE) for details.
See [LICENSE](https://github.com/near/near-api-js/blob/master/LICENSE) and [LICENSE-APACHE](https://github.com/near/near-api-js/blob/master/LICENSE-APACHE) for details.

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc