import { KeyPair } from '@near-js/crypto'; import { KeyStore } from './keystore.js'; /** * Keystore which can be used to merge multiple key stores into one virtual key store. * * @example * ```js * const { homedir } = require('os'); * import { connect, keyStores, utils } from 'near-api-js'; * * const privateKey = '.......'; * const keyPair = utils.KeyPair.fromString(privateKey); * * const inMemoryKeyStore = new keyStores.InMemoryKeyStore(); * inMemoryKeyStore.setKey('testnet', 'example-account.testnet', keyPair); * * const fileSystemKeyStore = new keyStores.UnencryptedFileSystemKeyStore(`${homedir()}/.near-credentials`); * * const keyStore = new MergeKeyStore([ * inMemoryKeyStore, * fileSystemKeyStore * ]); * const config = { * keyStore, // instance of MergeKeyStore * networkId: 'testnet', * nodeUrl: 'https://rpc.testnet.near.org', * walletUrl: 'https://wallet.testnet.near.org', * helperUrl: 'https://helper.testnet.near.org', * explorerUrl: 'https://explorer.testnet.near.org' * }; * * // inside an async function * const near = await connect(config) * ``` */ interface MergeKeyStoreOptions { writeKeyStoreIndex: number; } declare class MergeKeyStore extends KeyStore { private options; keyStores: KeyStore[]; /** * @param keyStores read calls are attempted from start to end of array * @param options KeyStore options * @param options.writeKeyStoreIndex the keystore index that will receive all write calls */ constructor(keyStores: KeyStore[], options?: MergeKeyStoreOptions); /** * Store a {@link KeyPair} to the first index of a key store array * @param networkId The targeted network. (ex. default, betanet, etc…) * @param accountId The NEAR account tied to the key pair * @param keyPair The key pair to store in local storage */ setKey(networkId: string, accountId: string, keyPair: KeyPair): Promise; /** * Gets a {@link KeyPair} from the array of key stores * @param networkId The targeted network. (ex. default, betanet, etc…) * @param accountId The NEAR account tied to the key pair * @returns {Promise} */ getKey(networkId: string, accountId: string): Promise; /** * Removes a {@link KeyPair} from the array of key stores * @param networkId The targeted network. (ex. default, betanet, etc…) * @param accountId The NEAR account tied to the key pair */ removeKey(networkId: string, accountId: string): Promise; /** * Removes all items from each key store */ clear(): Promise; /** * Get the network(s) from the array of key stores * @returns {Promise} */ getNetworks(): Promise; /** * Gets the account(s) from the array of key stores * @param networkId The targeted network. (ex. default, betanet, etc…) */ getAccounts(networkId: string): Promise; /** @hidden */ toString(): string; } export { MergeKeyStore };