Socket
Socket
Sign inDemoInstall

joyso

Package Overview
Dependencies
98
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.3 to 0.1.4

5

CHANGELOG.md
# Change Log
## v0.1.4 / 2018-10-01
### Fixed
- gas fee changed issue.
- withdraw bug.
## v0.1.3 / 2018-09-28

@@ -4,0 +9,0 @@ ### Added

2

package.json
{
"name": "joyso",
"version": "0.1.3",
"version": "0.1.4",
"description": "JOYSO API client library for trading.",

@@ -5,0 +5,0 @@ "main": "src/joyso.js",

@@ -43,4 +43,5 @@ const rp = require('request-promise');

const json = await this.system.update();
this.tokenManager = new TokenManager(json.tokens);
this.system.subscribe();
this.tokenManager = new TokenManager(this, json.tokens);
this.tokenManager.subscribe();
await this.updateAccessToken();

@@ -91,3 +92,3 @@ this.orders = new Orders({

options.retry = true;
await this.system.update();
await this.tokenManager.refresh();
return this.withdraw(options);

@@ -100,3 +101,3 @@ }

createWithdraw({ token, amount, fee }) {
this.validateWithdraw(price, amount, fee, side);
this.validateWithdraw(amount, fee);
let tokenFee, paymentMethod;

@@ -117,3 +118,3 @@ if (fee === 'token') {

}
const withdrawFee = new BigNumber(tokenFee.withdraw_fee);
const withdrawFee = tokenFee.withdrawFee;
let rawAmount = this.tokenManager.toRawAmount(token, amount);

@@ -176,3 +177,3 @@ if (token === tokenFee) {

options.retry = true;
await this.system.update();
await this.tokenManager.refresh();
return this.trade(options);

@@ -256,3 +257,3 @@ }

}
feePrice = new BigNumber(tokenFee.price).mul(10000000).truncated();
feePrice = tokenFee.price.mul(10000000).truncated();
if (feePrice.gt(100000000)) {

@@ -267,3 +268,3 @@ feePrice = new BigNumber(100000000);

}
const gasFee = new BigNumber(tokenFee.gas_fee);
const gasFee = tokenFee.gasFee;

@@ -270,0 +271,0 @@ let amountSell, amountBuy, tokenSell, tokenBuy;

const BigNumber = require('bignumber.js');
class TokenManager {
constructor(tokens) {
constructor(client, tokens) {
this.client = client;
this.reload(tokens);
}
subscribe() {
this.cable = this.client.cable.subscriptions.create({
channel: 'TokensChannel'
}, {
received: data => {
return;
switch (data.e) {
case 'update':
console.log(data.e);
const token = this.addressMap[`0x${data.data.address}`];
if (token) {
if (data.data.price) {
token.price = new BigNumber(data.data.price);
token.gasFee = new BigNumber(data.data.gas_fee);
token.withdrawFee = new BigNumber(data.data.withdraw_fee);
} else {
token.price = null;
token.gasFee = null;
token.withdrawFee = null;
}
token.depositable = data.data.depositable;
token.withdrawable = data.data.withdrawable;
token.tradable = data.data.tradable;
}
break;
}
}
});
}
async refresh() {
const json = await this.client.system.update();
this.reload(json.tokens);
}
reload(tokens) {
this.tokens = tokens;

@@ -10,2 +50,7 @@ this.symbolMap = {};

t.address = `0x${t.address}`;
if (t.price) {
t.price = new BigNumber(t.price);
t.gasFee = new BigNumber(t.gas_fee);
t.withdrawFee = new BigNumber(t.withdraw_fee);
}
this.symbolMap[t.symbol] = t;

@@ -12,0 +57,0 @@ this.addressMap[t.address] = t;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc