Skip to content

Commit

Permalink
Merge pull request #36 from CelsiusNetwork/release/v0.10.12
Browse files Browse the repository at this point in the history
Release/v0.10.12
  • Loading branch information
g4ndr4 authored Jan 27, 2020
2 parents ff711b2 + 1c8d708 commit 81a32c2
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.10.12] - 2020-01-24
- Adding support for `Origin address of the first deposit` withdrawal scheme.
* Whitelabel partners can now be configured in a way that allows withdrawing funds only to the origin addresses of first deposits.
* Adding method ```CelsiusInstance.getWithdrawalAddresses(userSecret)``` which returns all withdrawal addresses for the given user.
* Adding method ```CelsiusInstance.getWithdrawalAddressForCoin(coin, userSecret)``` which returns withdrawal address for the given user and coin.

## [0.10.11] - 2019-12-18
- Raising axios version from 0.18.0 up to 0.18.1 to address security vulnerabilities.

Expand Down
22 changes: 22 additions & 0 deletions docs/whitelabel-partner.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,28 @@ celsius.getDeposit(coin, userToken).then((address) => {
console.log(error)
})
```
#### Get all withdrawal addresses
This endpoint returns withdrawal addresses only for partners which are using '**Origin address of the first deposit**' withdrawal scheme.
```javascript
celsius.getWithdrawalAddresses(userToken).then((addresses) => {
console.log(addresses)
})
.catch((error) => {
console.log(error)
})
```
#### Get withdrawal address for a specific currency
This endpoint returns withdrawal address only for partners which are using '**Origin address of the first deposit**' withdrawal scheme.
```javascript
const coin = 'BTC'

celsius.getWithdrawalAddressForCoin(coin, userToken).then((address) => {
console.log(address)
})
.catch((error) => {
console.log(error)
})
```
#### Withdraw funds to an address
```javascript
const coin = 'BTC'
Expand Down
12 changes: 12 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ declare module 'celsius-sdk' {
state: string;
}

/**
* Celsius Withdrawal Addresses
*/
interface CelsiusWithdrawalAddresses {
addresses: {
/** Each key,value pair represents a coin and the withdrawal address for that coin **/
[key: string]: string
};
}

interface CelsiusTransactionRecord extends CelsiusCoinBalanceResponse {
/** The amount in this coin */
amount: string;
Expand Down Expand Up @@ -272,6 +282,8 @@ declare module 'celsius-sdk' {
getCoinTransactions(coin: string, pagination: CelsiusPagination, userSecret: string): Promise<CelsiusTransactionSummary>;
getDeposit(coin: string, userSecret: string): Promise<{address: string}>;
withdraw(coin: string, formFields: CelsiusWithdrawOptions, userSecret: string): Promise<{transaction_id: string}>;
getWithdrawalAddressForCoin(coin: string, userSecret: string): Promise<{address: string}>
getWithdrawalAddresses(userSecret: string): Promise<CelsiusWithdrawalAddresses>
getTransactionStatus(transaction: string, userSecret: string): Promise<CelsiusWithdrawalTransaction>;
getUsers(pagination: PaginationOptions, userSecret: string): Promise<UsersResponse>;
changeMetadata(id: string, data: object, userSecret: string): Promise<UserMetadataResponse>;
Expand Down
4 changes: 4 additions & 0 deletions lib/consts.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ const PATHS = {
WITHDRAW: (coin) => {
return '/wallet/' + coin + '/withdraw'
},
WITHDRAWAL_ADDRESS_FOR_COIN: (coin) => {
return '/wallet/' + coin + '/withdrawal-address'
},
WITHDRAWAL_ADDRESSES: '/wallet/withdrawal-addresses',
TRANSACTION_STATUS: (transaction) => {
return '/wallet/transactions/' + transaction + '/status'
},
Expand Down
38 changes: 38 additions & 0 deletions lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ const { HttpClient } = require('./http-client')
* @description Contains balances for all supported coins.
*/

/**
* @typedef {object} WithdrawalAddressesResponse
* @description Contains withdrawal addresses for coins.
*/

/**
* @typedef {object} InterestResponse
* @description Contains interest earned so far for all supported coins and total interest earned in usd.
Expand Down Expand Up @@ -327,6 +332,39 @@ const Celsius = function (config) {
return httpClient.post(PATHS.WITHDRAW(coin), formFields, null, userSecret)
},

/**
* Returns withdrawal address for the given coin.
* This method is usable only if you are using `originating` withdrawal scheme.
* An error is return if any other scheme is being used.
*
* @param coin {string} - Coin for which to find withdrawal address
* @param userSecret {string} - Represents a secret value used to uniquely identify users.
*
* @returns { { address: string } | Error}
* Error name | Description
* :--------------- | :----------
* Invalid Action For Withdrawal Scheme | You have attempted to obtain withdrawal address but aren't using `originating` withdrawal scheme
*/
getWithdrawalAddressForCoin: function (coin, userSecret) {
return httpClient.get(PATHS.WITHDRAWAL_ADDRESS_FOR_COIN(coin), null, userSecret)
},

/**
* Returns withdrawal addresses for all coins.
* This method is usable only if you are using `originating` withdrawal scheme.
* An error is return if any other scheme is being used.
*
* @param userSecret {string} - Represents a secret value used to uniquely identify users.
*
* @returns { WithdrawalAddressesResponse | Error}
* Error name | Description
* :--------------- | :----------
* Invalid Action For Withdrawal Scheme | You have attempted to obtain withdrawal address but aren't using `originating` withdrawal scheme
*/
getWithdrawalAddresses: function (userSecret) {
return httpClient.get(PATHS.WITHDRAWAL_ADDRESSES, null, userSecret)
},

/**
* This method returns transaction status for specific transaction.
*
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "celsius-sdk",
"version": "0.10.11",
"version": "0.10.12",
"author": {
"name": "Celsius Network",
"email": "",
Expand Down

0 comments on commit 81a32c2

Please sign in to comment.