@hiveio/wax-signers-beekeeper
Version:
Wax signer library extending transaction signing possibilities by a 3rd party Web-only extension - Beekeeper
80 lines (79 loc) • 3.85 kB
TypeScript
import type { IHiveChainInterface, IWaxBaseInterface, ISignatureTransaction, TAccountName, TRole, TSignature } from "@hiveio/wax";
import { AEncryptionProvider } from "@hiveio/wax";
import type { IBeekeeperUnlockedWallet, TPublicKey } from "@hiveio/beekeeper";
export declare class WaxBeekeeperProviderError extends Error {
}
/**
* Wax transaction signature provider using the Beekeeper.
*
* @example
* ```
* const provider = BeekeeperProvider.for(myWallet, "myaccount", "active", chain);
*
* // Create a transaction using the Wax Hive chain instance
* const tx = await chain.createTransaction();
*
* // Perform some operations, e.g. pushing operations...
*
* // Sign the transaction
* await provider.signTransaction(tx);
*
* // broadcast
* await chain.broadcast(tx);
* ```
*/
export declare class BeekeeperProvider extends AEncryptionProvider {
private readonly base;
private readonly wallet;
private readonly publicKey;
private constructor();
static for(chainOrBase: IHiveChainInterface | IWaxBaseInterface, wallet: IBeekeeperUnlockedWallet, publicKeyOrAccount: TPublicKey | TAccountName, role?: TRole): BeekeeperProvider | Promise<BeekeeperProvider>;
/**
* Encrypts data using the Beekeeper.
*
* @param content The string to encrypt.
* @param recipient The public key of the recipient to encrypt the data for. The recipient should be a valid public key, starting with "STM".
* @returns A string containing the encrypted data. The string starts with the `#` prefix.
* @throws on any error from the Beekeeper invocation.
*/
encryptData(content: string, recipient: TPublicKey): Promise<string>;
/**
* Decrypts data using the Beekeeper.
*
* @param content The string to decrypt. The string should start with the `#` prefix.
* @returns The decrypted data as a string.
* @throws on any error from the Beekeeper invocation.
*/
decryptData(content: string): Promise<string>;
/**
* Generates signatures for given transaction using the Beekeeper.
*
* @param transaction The transaction to sign. The transaction should be created using the Wax Hive chain instance.
* @throws on any error from the Beekeeper invocation.
*/
protected generateSignatures(transaction: ISignatureTransaction): Promise<TSignature[]>;
}
export interface WaxBeekeeperProviderCreator {
/**
* Creates a new instance of the BeekeeperProvider for signing transactions.
*
* @param base The Hive base interface to use for encryption.
* @param wallet The unlocked Beekeeper wallet instance.
* @param publicKey The public key to use for signing transactions. This should be a valid public key, starting with "STM".
* @throws on any error from the Beekeeper invocation.
*/
for(base: IWaxBaseInterface, wallet: IBeekeeperUnlockedWallet, publicKey: TPublicKey): BeekeeperProvider;
/**
* Creates a new instance of the BeekeeperProvider for signing transactions using an account name and role.
*
* @param chain The Hive chain interface to use for fetching the account details.
* @param wallet The unlocked Beekeeper wallet instance.
* @param account The account name to use for signing transactions. This should be a valid Wax account name.
* @param role The role to use for signing transactions. Should be one of the valid roles: "owner", "active", "posting", or "memo".
* @returns A promise that resolves to an instance of the BeekeeperProvider that can be used to sign transactions.
* @throws on any error from the Wax invocation.
*/
for(chain: IHiveChainInterface, wallet: IBeekeeperUnlockedWallet, account: TAccountName, role: TRole): Promise<BeekeeperProvider>;
}
declare const _default: WaxBeekeeperProviderCreator;
export default _default;