Skip to content

Commit

Permalink
Merge pull request #33 from fireblocks/fireblocks-api-spec/generated/…
Browse files Browse the repository at this point in the history
…9825

fix: modify error message when secretKey missing and fix readme doc
  • Loading branch information
asafs932 authored Apr 10, 2024
2 parents eab8b6f + 2e033ad commit 6f4e365
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 12 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Fireblocks Typescript SDK
# Official Fireblocks TypeScript SDK
[![npm version](https://badge.fury.io/js/@fireblocks%2Fts-sdk.svg)](https://badge.fury.io/js/@fireblocks%2Fts-sdk)

The Fireblocks SDK allows developers to seamlessly integrate with the Fireblocks platform and perform a variety of operations, including managing vault accounts and executing transactions securely.
Expand Down Expand Up @@ -98,19 +98,18 @@ async function getVaultPagedAccounts(limit) {
To make a transaction between vault accounts, you can use the following function:</p>

```typescript
import { Fireblocks, TransferPeerPathTypeEnum } from "@fireblocks/ts-sdk";
import { TransferPeerPathType } from "@fireblocks/ts-sdk";

async function createTransaction(assetId, amount, srcId, destId) {
const fireblocks = new Fireblocks();
let payload = {
assetId,
amount,
source: {
type: TransferPeerPathTypeEnum.VaultAccount,
type: TransferPeerPathType.VaultAccount,
id: String(srcId)
},
destination: {
type: TransferPeerPathTypeEnum.VaultAccount,
type: TransferPeerPathType.VaultAccount,
id: String(destId)
},
note: "Your first transaction!"
Expand Down
2 changes: 1 addition & 1 deletion client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class Fireblocks {

let secretKey = conf.secretKey || process.env.FIREBLOCKS_SECRET_KEY;
if (!secretKey ) {
throw new Error("apiKey is required either in the configuration or as environment variable FIREBLOCKS_API_KEY");
throw new Error("secretKey is required either in the configuration or as environment variable FIREBLOCKS_SECRET_KEY");
}

let basePath = conf.basePath || process.env.FIREBLOCKS_BASE_PATH;
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions tests/client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,39 @@ describe("Fireblocks Client Tests", () => {
jest.clearAllMocks();
});

describe('Fireblocks client construction tests', () => {
it('Should construct Fireblocks client', () => {
expect(fireblocks).toBeInstanceOf(Fireblocks);
});

it('Should throw an error when apiKey is not provided', () => {
expect(() => {
new Fireblocks({
basePath: "http://mock-server",
secretKey: "secretKey"
});
}).toThrowError("apiKey is required either in the configuration or as environment variable FIREBLOCKS_API_KEY");
});

it('Should throw an error when secretKey is not provided', () => {
expect(() => {
new Fireblocks({
apiKey: "my-api-key",
basePath: "http://mock-server"
});
}).toThrowError("secretKey is required either in the configuration or as environment variable FIREBLOCKS_SECRET_KEY");
});

it('Should throw an error when basePath is not provided', () => {
expect(() => {
new Fireblocks({
apiKey: "my-api-key",
secretKey: "secretKey"
});
}).toThrowError("basePath is required either in the configuration or as environment variable FIREBLOCKS_BASE_PATH");
});
});

describe('Api getters tests', () => {
const expectedConfig = new Configuration({ basePath: "http://mock-server" });

Expand Down

0 comments on commit 6f4e365

Please sign in to comment.