coinbase-pro-node
Advanced tools
Comparing version 2.12.0 to 2.13.0
@@ -0,1 +1,12 @@ | ||
### 2.13.0 (2020-10-22) | ||
##### Chores | ||
- Rename branch 'master' to 'main' ([#285](https://github.com/bennyn/coinbase-pro-node/pull/285)) ([81d9bb41](https://github.com/bennyn/coinbase-pro-node/commit/81d9bb413f40b7d9bf711b859b33d19472b239de)) | ||
- yarn upgrade --latest ([c4908e26](https://github.com/bennyn/coinbase-pro-node/commit/c4908e26f2a9add26cb8a0f65bde9118eb1138ac)) | ||
##### New Features | ||
- Ability to get withdrawal fee estimate ([#284](https://github.com/bennyn/coinbase-pro-node/pull/284)) ([4e940978](https://github.com/bennyn/coinbase-pro-node/commit/4e9409780abf7618ae6e00ea52f055c00da9c4d0)) | ||
### 2.12.0 (2020-10-18) | ||
@@ -2,0 +13,0 @@ |
@@ -7,2 +7,5 @@ import { AxiosInstance } from 'axios'; | ||
} | ||
export interface WithdrawalFeeEstimate { | ||
fee: string; | ||
} | ||
export declare class WithdrawAPI { | ||
@@ -13,2 +16,3 @@ private readonly apiClient; | ||
CRYPTO: string; | ||
FEE_ESTIMATE: string; | ||
}; | ||
@@ -29,2 +33,10 @@ }; | ||
postCryptoWithdrawal(amount: number, currency: string, cryptoAddress: string, destinationTag?: string, addNetworkFeeToTotal?: boolean): Promise<CryptoWithdrawal>; | ||
/** | ||
* Gets the network fee estimate when sending to the given address. | ||
* | ||
* @param currency - The type of currency | ||
* @param cryptoAddress - A crypto address of the recipient | ||
* @see https://docs.pro.coinbase.com/#fee-estimate | ||
*/ | ||
getFeeEstimate(currency: string, cryptoAddress: string): Promise<WithdrawalFeeEstimate>; | ||
} |
@@ -47,2 +47,18 @@ "use strict"; | ||
} | ||
/** | ||
* Gets the network fee estimate when sending to the given address. | ||
* | ||
* @param currency - The type of currency | ||
* @param cryptoAddress - A crypto address of the recipient | ||
* @see https://docs.pro.coinbase.com/#fee-estimate | ||
*/ | ||
getFeeEstimate(currency, cryptoAddress) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const resource = WithdrawAPI.URL.WITHDRAWALS.FEE_ESTIMATE; | ||
const response = yield this.apiClient.get(resource, { | ||
params: { crypto_address: cryptoAddress, currency }, | ||
}); | ||
return response.data; | ||
}); | ||
} | ||
} | ||
@@ -53,4 +69,5 @@ exports.WithdrawAPI = WithdrawAPI; | ||
CRYPTO: '/withdrawals/crypto', | ||
FEE_ESTIMATE: '/withdrawals/fee-estimate', | ||
}, | ||
}; | ||
//# sourceMappingURL=WithdrawAPI.js.map |
@@ -18,2 +18,5 @@ "use strict"; | ||
describe('WithdrawAPI', () => { | ||
const currency = 'BTC'; | ||
const cryptoAddress = '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa'; | ||
const expectedFeeEstimate = { fee: '.01' }; | ||
const withdrawalId = 'fake-withdrawal-id-abcd-01234'; | ||
@@ -33,8 +36,9 @@ afterAll(() => nock_1.default.cleanAll()); | ||
return [200, JSON.stringify(response)]; | ||
}); | ||
}) | ||
.get(WithdrawAPI_1.WithdrawAPI.URL.WITHDRAWALS.FEE_ESTIMATE) | ||
.query({ crypto_address: cryptoAddress, currency }) | ||
.reply(200, JSON.stringify(expectedFeeEstimate)); | ||
}); | ||
describe('postCryptoWithdrawal', () => { | ||
const amount = 1.23; | ||
const currency = 'BTC'; | ||
const cryptoAddress = '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa'; | ||
const destinationTag = 'satoshi-nakamoto'; | ||
@@ -50,3 +54,9 @@ it('creates a new withdrawal to crypto address', () => __awaiter(void 0, void 0, void 0, function* () { | ||
}); | ||
describe('getFeeEstimate', () => { | ||
it('gets a fee estimate', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const estimate = yield global.client.rest.withdraw.getFeeEstimate(currency, cryptoAddress); | ||
expect(estimate).toEqual(expectedFeeEstimate); | ||
})); | ||
}); | ||
}); | ||
//# sourceMappingURL=WithdrawAPI.test.js.map |
@@ -19,8 +19,8 @@ { | ||
"@types/jasmine": "3.5.14", | ||
"@typescript-eslint/eslint-plugin": "4.4.1", | ||
"@typescript-eslint/parser": "4.4.1", | ||
"@typescript-eslint/eslint-plugin": "4.5.0", | ||
"@typescript-eslint/parser": "4.5.0", | ||
"cross-env": "7.0.2", | ||
"dotenv-defaults": "2.0.1", | ||
"eslint": "7.11.0", | ||
"eslint-config-prettier": "6.13.0", | ||
"eslint-config-prettier": "6.14.0", | ||
"eslint-plugin-prettier": "3.1.4", | ||
@@ -39,3 +39,3 @@ "eslint-plugin-typescript-sort-keys": "1.5.0", | ||
"typedoc": "0.19.2", | ||
"typedoc-plugin-markdown": "3.0.10", | ||
"typedoc-plugin-markdown": "3.0.11", | ||
"typescript": "4.0.3" | ||
@@ -100,3 +100,3 @@ }, | ||
"prettier": "prettier --ignore-path .gitignore --loglevel silent \"**/*.{html,json,scss,yml}\"", | ||
"preversion": "git checkout master && git pull && yarn install && yarn lint && yarn test && yarn dist", | ||
"preversion": "git checkout main && git pull && yarn install && yarn lint && yarn test && yarn dist", | ||
"release:major": "generate-changelog -M && yarn changelog:commit && yarn docs:release && npm version major", | ||
@@ -108,3 +108,3 @@ "release:minor": "generate-changelog -m && yarn changelog:commit && yarn docs:release && npm version minor", | ||
}, | ||
"version": "2.12.0" | ||
"version": "2.13.0" | ||
} |
# Coinbase Pro API | ||
![Language Details](https://img.shields.io/github/languages/top/bennyn/coinbase-pro-node) ![Code Coverage](https://img.shields.io/codecov/c/github/bennyn/coinbase-pro-node/master) ![License](https://img.shields.io/npm/l/coinbase-pro-node.svg) ![Package Version](https://img.shields.io/npm/v/coinbase-pro-node.svg) ![Dependency Updates](https://img.shields.io/david/bennyn/coinbase-pro-node.svg) | ||
![Language Details](https://img.shields.io/github/languages/top/bennyn/coinbase-pro-node) ![Code Coverage](https://img.shields.io/codecov/c/github/bennyn/coinbase-pro-node/main) ![License](https://img.shields.io/npm/l/coinbase-pro-node.svg) ![Package Version](https://img.shields.io/npm/v/coinbase-pro-node.svg) ![Dependency Updates](https://img.shields.io/david/bennyn/coinbase-pro-node.svg) | ||
@@ -16,3 +16,3 @@ [Coinbase Pro][1] API for Node.js, written in TypeScript and covered by tests. | ||
- **Convenient.** Request throttling is built-in. Don't worry about rate limiting. | ||
- **Comfortable.** More than an API client. You will get extras like [candle watching](https://github.com/bennyn/coinbase-pro-node/blob/master/src/demo/rest-watch-candles.ts). | ||
- **Comfortable.** More than an API client. You will get extras like [candle watching](https://github.com/bennyn/coinbase-pro-node/blob/main/src/demo/rest-watch-candles.ts). | ||
- **Maintained.** Automated security updates. No threats from outdated dependencies. | ||
@@ -86,8 +86,8 @@ - **Documented.** Get started with [demo scripts][3] and [generated documentation][4]. | ||
- [Subscribe to "ticker" channel (real-time price updates)](https://github.com/bennyn/coinbase-pro-node/blob/master/src/demo/websocket-ticker.ts) | ||
- [Subscribe to authenticated "user" channel](https://github.com/bennyn/coinbase-pro-node/blob/master/src/demo/websocket-user.ts) | ||
- [Subscribe to "ticker" channel (real-time price updates)](https://github.com/bennyn/coinbase-pro-node/blob/main/src/demo/websocket-ticker.ts) | ||
- [Subscribe to authenticated "user" channel](https://github.com/bennyn/coinbase-pro-node/blob/main/src/demo/websocket-user.ts) | ||
### Demos | ||
All [demo scripts][3] are executable from the root directory. If you want to use specific credentials with a demo script, simply add a `.env` file to the root of this package to [modify environment variables](https://github.com/motdotla/dotenv/tree/v8.2.0#usage) used in [init-client.ts](https://github.com/bennyn/coinbase-pro-node/blob/master/src/demo/init-client.ts). | ||
All [demo scripts][3] are executable from the root directory. If you want to use specific credentials with a demo script, simply add a `.env` file to the root of this package to [modify environment variables](https://github.com/motdotla/dotenv/tree/v8.2.0#usage) used in [init-client.ts](https://github.com/bennyn/coinbase-pro-node/blob/main/src/demo/init-client.ts). | ||
@@ -98,3 +98,3 @@ ```bash | ||
**Tip:** There is a [.env.defaults](https://github.com/bennyn/coinbase-pro-node/blob/master/.env.defaults) file which serves as a template. Just remove its `.defaults` extension and enter your credentials to get started. Do not commit this file (or your credentials) to any repository! | ||
**Tip:** There is a [.env.defaults](https://github.com/bennyn/coinbase-pro-node/blob/main/.env.defaults) file which serves as a template. Just remove its `.defaults` extension and enter your credentials to get started. Do not commit this file (or your credentials) to any repository! | ||
@@ -137,3 +137,3 @@ ### Real-world examples | ||
[2]: https://docs.pro.coinbase.com/ | ||
[3]: https://github.com/bennyn/coinbase-pro-node/tree/master/src/demo | ||
[3]: https://github.com/bennyn/coinbase-pro-node/tree/main/src/demo | ||
[4]: https://benny.work/coinbase-pro-node | ||
@@ -140,0 +140,0 @@ [5]: https://www.npmjs.com/package/coinbase-pro-node |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
400225
4869