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

[chore] Update Coinbase Constructor Args Default #55

Merged
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
6 changes: 3 additions & 3 deletions src/coinbase/coinbase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ export class Coinbase {
* @throws {InvalidAPIKeyFormat} If not able to create JWT token.
*/
constructor({
apiKeyName = "",
privateKey = "",
apiKeyName,
privateKey,
useServerSigner = false,
debugging = false,
basePath = BASE_PATH,
Expand Down Expand Up @@ -121,7 +121,7 @@ export class Coinbase {
useServerSigner = false,
debugging = false,
basePath = BASE_PATH,
}: CoinbaseConfigureFromJsonOptions): Coinbase {
}: CoinbaseConfigureFromJsonOptions = {}): Coinbase {
Copy link
Contributor

@erdimaden erdimaden Jun 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we already changed typing, we don't need to have {}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is for the configure from json options where passing undefined is valid

filePath = filePath.startsWith("~") ? filePath.replace("~", os.homedir()) : filePath;

if (!fs.existsSync(filePath)) {
Expand Down
4 changes: 2 additions & 2 deletions src/coinbase/tests/coinbase_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ const PATH_PREFIX = "./src/coinbase/tests/config";

describe("Coinbase tests", () => {
it("should throw an error if the API key name or private key is empty", () => {
expect(() => new Coinbase({ privateKey: "test" })).toThrow(
expect(() => new Coinbase({ apiKeyName: "", privateKey: "test" })).toThrow(
"Invalid configuration: apiKeyName is empty",
);
expect(() => new Coinbase({ apiKeyName: "test" })).toThrow(
expect(() => new Coinbase({ apiKeyName: "test", privateKey: "" })).toThrow(
"Invalid configuration: privateKey is empty",
);
});
Expand Down
4 changes: 2 additions & 2 deletions src/coinbase/tests/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ describe("Coinbase SDK E2E Test", () => {

beforeEach(() => {
coinbase = new Coinbase({
apiKeyName: process.env.NAME,
privateKey: process.env.PRIVATE_KEY,
apiKeyName: process.env.NAME as string,
privateKey: process.env.PRIVATE_KEY as string,
});
});

Expand Down
6 changes: 3 additions & 3 deletions src/coinbase/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,12 +353,12 @@ export type CoinbaseOptions = {
/**
* The API key name.
*/
apiKeyName?: string;
apiKeyName: string;

/**
* The private key associated with the API key.
*/
privateKey?: string;
privateKey: string;

/**
* Whether to use a Server-Signer or not.
Expand All @@ -383,7 +383,7 @@ export type CoinbaseConfigureFromJsonOptions = {
/**
* The path to the JSON file containing the API key and private key.
*/
filePath: string;
filePath?: string;

/**
* Whether to use a Server-Signer or not.
Expand Down
Loading