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

fix: modify error message when secretKey missing and fix readme doc #33

Merged
merged 1 commit into from
Apr 10, 2024
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
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
Loading