Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support raw messages #7

Merged
merged 3 commits into from
Oct 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions src/fireblocks-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
ExecuteTermArgs,
CreateTransferTicketResponse,
EstimateTransactionFeeResponse,
EstimateFeeResponse
EstimateFeeResponse, PublicKeyInfoArgs, PublicKeyInfoForVaultAccountArgs
} from "./types";

export * from "./types";
Expand Down Expand Up @@ -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);
}
}
62 changes: 56 additions & 6 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ export interface EstimatedTransactionFee {
}

export interface TransferPeerPath {
type: PeerType;
id: string;
type?: PeerType;
id?: string;
}

interface DestinationTransferPeerPath {
Expand Down Expand Up @@ -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;
Expand All @@ -117,6 +135,9 @@ export interface TransactionArguments {
networkStaking?: number;
autoStaking?: boolean;
customerRefId?: string;
extraParameters?: {
rawMessageData: RawMessageData;
};
}

export interface ExchangeResponse {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}