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.3.0 to 0.4.0

8

CHANGELOG.md
# Change Log
## v0.4.0 / 2018-10-30
### Fixed
- Gas fee has changed issue.
- reconnect issue.
### Improved
- upgrade access token api.
## v0.3.0 / 2018-10-16

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

2

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

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

@@ -18,2 +18,3 @@ const rp = require('request-promise');

const ACCESS_TOKEN_TIME = 600000;
const ETH_MAX_FEE_PRICE = new BigNumber('100000000');

@@ -43,2 +44,3 @@ const NON_ETH_MAX_FEE_PRICE = new BigNumber('1000000000000000000000000000');

}
await this.updateAccessToken();
this.cable = ActionCable.createConsumer(this.wsUrl, this.origin);

@@ -55,3 +57,2 @@ this.system = new System(this);

await this.balances.subscribe();
await this.updateAccessToken();
this.orders = new Orders({

@@ -79,7 +80,6 @@ client: this,

async updateAccessToken() {
async updateAccessToken(catchError = false) {
const nonce = Math.floor(Date.now() / 1000);
const raw = `joyso${nonce}`;
const hash = ethUtil.keccak256(raw);
const vrs = this.sign(hash);
const raw = `Signing this message proves to JOYSO you are in control of your account without giving JOYSO access to any sensitive information. Message ID: ${nonce}`;
const vrs = this.sign(new Buffer(raw, 'utf8'));
try {

@@ -90,8 +90,16 @@ const r = await this.request('accounts', {

user: this.address.substr(2),
nonce: nonce
nonce: nonce,
version: 2,
locale: 'en'
}, vrs)
});
this.accessToken = r.access_token;
} catch (e) {
if (!catchError) {
throw e;
} else if (e.statusCode === 400) {
throw new Error('Failed to update access token.');
}
} finally {
this.timer = setTimeout(() => this.updateAccessToken(), 6000 * 60);
this.timer = setTimeout(() => this.updateAccessToken(true), ACCESS_TOKEN_TIME);
}

@@ -105,3 +113,4 @@ }

method: 'POST',
data: withdraw
data: withdraw,
auth: true
});

@@ -191,3 +200,4 @@ } catch (e) {

method: 'POST',
data: order
data: order,
auth: true
});

@@ -202,6 +212,4 @@ this.updateHashTable(order.nonce, hash);

await this.tokenManager.refresh();
if (e.error.length === 1) {
options.retry = true;
return this.trade(options);
}
options.retry = true;
return this.trade(options);
}

@@ -534,5 +542,5 @@ throw e;

sign(hash) {
const message = ethUtil.hashPersonalMessage(hash);
const vrs = ethUtil.ecsign(message, ethUtil.toBuffer(keys[this.keyIndex]));
sign(message) {
const result = ethUtil.hashPersonalMessage(message);
const vrs = ethUtil.ecsign(result, ethUtil.toBuffer(keys[this.keyIndex]));
return {

@@ -539,0 +547,0 @@ v: vrs.v,

@@ -6,2 +6,3 @@ const BigNumber = require('bignumber.js');

this.client = client;
this.pairs = {};
this.reload(options);

@@ -67,7 +68,10 @@ }

});
this.hiddenPairs = {};
Object.keys(json.hidden_pairs).forEach(quote => {
json.hidden_pairs[quote].forEach(base => {
this.hiddenPairs[`${base}_${quote}`] = true;
});
this.pairs = {};
this.pairs['ETH'] = new Set(this.tokens.map(t => t.symbol));
Object.keys(json.pairs).forEach(k => this.pairs[k] = new Set(json.pairs[k]));
Object.keys(json.hidden_pairs).forEach(k => {
const set = this.pairs[k];
if (set) {
json.hidden_pairs[k].forEach(t => set.delete(t));
}
});

@@ -77,7 +81,4 @@ }

getPair(pair) {
if (this.hiddenPairs[pair]) {
return [];
}
let [base, quote] = pair.split('_');
return [this.symbolMap[base], this.symbolMap[quote]];
return this.pairs[quote] && this.pairs[quote].has(base) ? [this.symbolMap[base], this.symbolMap[quote]] : [];
}

@@ -84,0 +85,0 @@

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