Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.

ShapeShift Improvements #452

Merged
merged 2 commits into from
Oct 23, 2017
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
4 changes: 4 additions & 0 deletions src/eth/eth-account.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ class EthAccount {
return this._addr;
}

get receiveAddress () {
return this.address;
}

get privateKey () {
return this._priv;
}
Expand Down
26 changes: 8 additions & 18 deletions src/shift/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,22 @@ class ShapeShift {
return this._api.getRate(coinPair)
}

getQuote (coinPair, amount) {
getQuote (from, to, amount) {
trace('getting quote')
let [from, to] = coinPair.split('_')

let withdrawalAddress = this.nextAddressForCurrency(to)
let returnAddress = this.nextAddressForCurrency(from)
let returnAddress = from.receiveAddress;
let withdrawalAddress = to.receiveAddress;
let coinPair = from.coinCode + '_' + to.coinCode;

return this._api.getQuote(coinPair, amount, withdrawalAddress, returnAddress)
.then(Quote.fromApiResponse)
}

getApproximateQuote (coinPair, amount) {
getApproximateQuote (from, to, amount) {
trace('getting approximate quote')

let coinPair = from.coinCode + '_' + to.coinCode;

return this._api.getQuote(coinPair, amount)
.then(Quote.fromApiResponse)
}
Expand Down Expand Up @@ -121,19 +124,6 @@ class ShapeShift {
return Promise.all(requests);
}

nextAddressForCurrency (currency) {
if (currency === 'btc') {
return this._wallet.hdwallet.defaultAccount.receiveAddress
}
if (currency === 'eth') {
return this._wallet.eth.defaultAccount.address
}
if (currency === 'bch') {
return this._wallet.bch.defaultAccount.receiveAddress
}
throw new Error(`Currency '${currency}' is not supported`)
}

saveBtcWithdrawalLabel (quote) {
let label = `ShapeShift order #${quote.orderId}`
let account = this._wallet.hdwallet.defaultAccount
Expand Down