@chorus-one/signer-fireblocks
Version:
Fireblocks signer for Chorus One SDK
110 lines (109 loc) • 4.72 kB
TypeScript
import type { TransactionResponse } from 'fireblocks-sdk';
import { FireblocksSDK } from 'fireblocks-sdk';
import type { Signature, SignerData, AddressDerivationFn } from '@chorus-one/signer';
import type { Logger } from '@chorus-one/utils';
import type { FireblocksSignerConfig } from './types';
import type { Hex } from 'viem';
/**
* The FireblocksSigner in the Chorus One SDK is a specialized implementation of the Signer interface that integrates
* with the Fireblocks platform.
*
* Fireblocks is known for its advanced security features, including multi-party computation (MPC) and secure wallet
* infrastructure, making it an ideal choice for enterprises requiring robust security and compliance.
*/
interface FireblocksTxStatus {
status: 'success' | 'failure' | 'pending' | 'unknown';
reason?: string;
receipt: TransactionResponse | null;
}
export declare class FireblocksSigner {
private readonly config;
private fireblocksClient?;
private vault?;
private addressDerivationFn;
private accounts;
private logger;
/**
* Constructs a new FireblocksSigner.
*
* @param params - The parameters required to initialize the FireblocksSigner
* @param params.apiSecretKey - Fireblocks API Secret key
* @param params.apiKey - Fireblocks API Key
* @param params.vaultName - The name of the Fireblocks vault where the assets are stored
* @param params.assetId - The identifier for the asset you intend to manage
* @param params.addressDerivationFn - A function that derives the address from the public key
* @param params.timeout - (Optional) The maximum time (in ms) to wait for the Fireblocks API sign request to complete
* @param params.pollInterval - (Optional) The interval (in ms) at which the signer polls the Fireblocks API to check if the sign request has completed
* @param params.apiUrl - (Optional) The URL of the Fireblocks API, defaults to `https://api.fireblocks.io`
* @param params.logger - (Optional) A logger to use for logging messages, i.e `console`
*
* @returns A new instance of FireblocksSigner.
*/
constructor(params: {
apiSecretKey: string;
apiKey: string;
vaultName: string;
assetId: string;
addressDerivationFn: AddressDerivationFn;
timeout?: number;
pollInterval?: number;
apiUrl?: string;
logger?: Logger;
});
/**
* Initializes the signer, performing any necessary setup or configuration.
* @returns A promise that resolves once the initialization is complete.
*/
init(): Promise<void>;
/**
* Signs the provided data using the private key associated with the signer's address.
*
* @param signerAddress - The address of the signer
* @param signerData - The data to be signed, which can be a raw message or custom data
* @param options - Additional options
* @param options.note - An optional note to include with the transaction
*
* @returns A promise that resolves to an object containing the signature and public key.
*/
sign(signerAddress: string, signerData: SignerData, options?: {
note?: string;
}): Promise<{
sig: Signature;
pk: Uint8Array;
}>;
/**
* Signs an Ethereum contract call transaction using Fireblocks.
*
* @param params - Parameters for the contract call
* @param params.to - The destination contract address
* @param params.value - The amount to send in wei (optional)
* @param params.data - The contract call data
* @param params.gasLimit - Gas limit for the transaction (optional)
* @param params.maxFeePerGas - Maximum fee per gas in wei (optional)
* @param params.maxPriorityFeePerGas - Maximum priority fee per gas in wei (optional)
* @param params.note - Optional note for the transaction
*
* @returns A promise that resolves to the transaction response from Fireblocks.
*/
contractCall(params: {
to: Hex;
value?: bigint;
data: Hex;
gas: bigint;
maxFeePerGas: bigint;
maxPriorityFeePerGas: bigint;
gasPrice: bigint;
note?: string;
}): Promise<FireblocksTxStatus>;
/**
* Retrieves the public key associated with the signer's address.
*
* @param address - The address of the signer
*
* @returns A promise that resolves to a Uint8Array representing the public key.
*/
getPublicKey(address: string): Promise<Uint8Array>;
private getPublicKeyInfoForVaultAccount;
}
export declare function newFireblocksSignerBackend(config: FireblocksSignerConfig): Promise<FireblocksSDK>;
export {};