diff --git a/src/fireblocks-sdk.ts b/src/fireblocks-sdk.ts index 1ad2fdf1..ee7ad4ba 100644 --- a/src/fireblocks-sdk.ts +++ b/src/fireblocks-sdk.ts @@ -23,7 +23,7 @@ import { ExecuteTermArgs, CreateTransferTicketResponse, EstimateTransactionFeeResponse, - EstimateFeeResponse + EstimateFeeResponse, PublicKeyInfoArgs, PublicKeyInfoForVaultAccountArgs } from "./types"; export * from "./types"; @@ -594,11 +594,41 @@ export class FireblocksSDK { } /** - * Set the required number of confirmtations for transactions by tx hash + * Set the required number of confirmations for transactions by tx hash * @param txHash * @param requiredConfirmationsNumber */ public async setConfirmationThresholdForTxHash(txHash: string, requiredConfirmationsNumber: number) { return await this.apiClient.issuePostRequest(`/v1/txHash/${txHash}/set_confirmation_threshold`, {numOfConfirmations: requiredConfirmationsNumber}); } + + /** + * Get the public key information + * @param args + */ + public async getPublicKeyInfo(args: PublicKeyInfoArgs) { + let url = `/v1/vault/public_key_info`; + if (args.algorithm) { + url += `?algorithm=${args.algorithm}`; + } + if (args.derivationPath) { + url += `&derivationPath=${args.derivationPath}`; + } + if (args.compressed) { + url += `&compressed=${args.compressed}`; + } + return await this.apiClient.issueGetRequest(url); + } + + /** + * Get the public key information for a vault account + * @param args + */ + public async getPublicKeyInfoForVaultAccount(args: PublicKeyInfoForVaultAccountArgs) { + let url = `/v1/vault/accounts/${args.vaultAccountId}/${args.assetId}/${args.change}/${args.addressIndex}/public_key_info`; + if (args.compressed) { + url += `?compressed=${args.compressed}`; + } + return await this.apiClient.issueGetRequest(url); + } } diff --git a/src/types.ts b/src/types.ts index 26da5285..027e422b 100644 --- a/src/types.ts +++ b/src/types.ts @@ -73,8 +73,8 @@ export interface EstimatedTransactionFee { } export interface TransferPeerPath { - type: PeerType; - id: string; + type?: PeerType; + id?: string; } interface DestinationTransferPeerPath { @@ -104,11 +104,29 @@ export interface GenerateAddressResponse { legacyAddress?: string; } +export enum SigningAlgorithm { + MPC_ECDSA_SECP256K1 = "MPC_ECDSA_SECP256K1", + MPC_ECDSA_SECP256R1 = "MPC_ECDSA_SECP256R1", + MPC_EDDSA_ED25519 = "MPC_EDDSA_ED25519" +} + +export interface RawMessageData { + messages: RawMessage[]; + algorithm?: SigningAlgorithm; +} + +export interface RawMessage { + content: string; + bip44addressIndex?: number; + bip44change?: number; + derivationPath?: number[]; +} + export interface TransactionArguments { - assetId: string; - source: TransferPeerPath; + assetId?: string; + source?: TransferPeerPath; destination?: DestinationTransferPeerPath; - amount: number | string; + amount?: number | string; operation?: TransactionOperation; fee?: number; gasPrice?: number; @@ -117,6 +135,9 @@ export interface TransactionArguments { networkStaking?: number; autoStaking?: boolean; customerRefId?: string; + extraParameters?: { + rawMessageData: RawMessageData; + }; } export interface ExchangeResponse { @@ -181,6 +202,20 @@ export interface TransactionResponse { provider: string; payload: any; }; + signedMessages?: SignedMessageResponse[]; +} + +export interface SignedMessageResponse { + content: string; + algorithm: string; + derivationPath: string; + signature: { + fullSig: string; + r?: string; + s?: string; + v?: number; + }; + publicKey: string; } export interface CancelTransactionResponse { @@ -266,7 +301,8 @@ export enum TransactionOperation { MINT = "MINT", BURN = "BURN", SUPPLY_TO_COMPOUND = "SUPPLY_TO_COMPOUND", - REDEEM_FROM_COMPOUND = "REDEEM_FROM_COMPOUND" + REDEEM_FROM_COMPOUND = "REDEEM_FROM_COMPOUND", + RAW = "RAW" } export interface CreateTransferTicketArgs { @@ -325,3 +361,17 @@ export interface ExecuteTermArgs { export interface CreateTransferTicketResponse { ticketId: string; } + +export interface PublicKeyInfoArgs { + algorithm?: string; + derivationPath?: string; + compressed?: boolean; +} + +export interface PublicKeyInfoForVaultAccountArgs { + assetId: string; + vaultAccountId: number; + change: number; + addressIndex: number; + compressed?: boolean; +} \ No newline at end of file