Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nomics-platform

Package Overview
Dependencies
Maintainers
3
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nomics-platform - npm Package Compare versions

Comparing version 0.13.8 to 1.0.0

8

lib/audit/au.js

@@ -137,4 +137,8 @@ const axios = require('axios')

o[p].every(val => s.includes(val)),
`Expected ${o[p]} to only contain values from ${s}: ${JSON.stringify(o)}`
)
`Expected ${JSON.stringify(
o[p]
)} to only contain values from ${JSON.stringify(s)}: ${JSON.stringify(
o
)}`
);
} else {

@@ -141,0 +145,0 @@ au.assert(s.indexOf(o[p]) > -1, `Expected '${p}' to be one of '${JSON.stringify(s)}': ${JSON.stringify(o)}`)

@@ -41,2 +41,3 @@ const au = require('../au')

au.assertStringProperty(this.info, 'twitter', { required: false })
au.assertStringProperty(this.info, 'version');
if (au.assertProperty(this.info, 'capability', { required: false })) {

@@ -78,14 +79,27 @@ au.assertPropertyType(this.info, 'capability', 'object')

try {
const data = await au.get('/markets')
const data = await au.get('/markets');
au.assert(data.length > 0, 'Expected at least one market')
au.assert(data.length > 0, 'Expected at least one market');
data.forEach(m => au.assertStringProperty(m, 'id'))
data.forEach(m => au.assertStringProperty(m, 'base'))
data.forEach(m => au.assertStringProperty(m, 'quote'))
// required
//
data.forEach((m) => au.assertStringProperty(m, 'id'));
data.forEach((t) => au.assertPropertyInSet(t, 'type', ['spot', 'derivative', 'index']));
data.forEach((m) => au.assertStringProperty(m, 'base'));
data.forEach((m) => au.assertStringProperty(m, 'quote'));
if (process.env.NOMICS_PLATFORM_INTERNAL_STRICT_MARKETS === '1') {
data.forEach(t => au.assertPropertyInSet(t, 'type', ['spot', 'future', 'option', 'derivative', 'index']))
data.forEach(m => au.assertBooleanProperty(m, 'active'))
}
// optional
//
data.forEach((m) => au.assertBooleanProperty(m, 'active', { required: false }));
data.forEach((m) => au.assertStringProperty(m, 'settlement', { required: false }));
data.forEach((m) => au.assertStringProperty(m, 'underlying', { required: false }));
data.forEach((m) => {
if (m.type === 'derivative') {
au.assertPropertyInSet(m, 'subtypes', ['future', 'option', 'perpetual'], { required: false });
} else {
au.assertPropertyInSet(m, 'subtypes', [], { required: false });
}
});
data.forEach((m) => au.assertURLProperty(m, 'market_url', { required: false }));
data.forEach((m) => au.assertStringProperty(m, 'description', { required: false }));

@@ -127,4 +141,4 @@ const idCounts = data.reduce((memo, m) => {

try {
const market = markets[i]
uri = `/trades?market=${encodeURIComponent(market.id)}`
const market = markets[i];
uri = `/trades?market=${encodeURIComponent(market.id)}`;

@@ -143,3 +157,3 @@ let trades

au.assert(trades.length > 2, 'Expected more than two trades')
au.assert(trades.length > 2, 'Expected more than two trades');
au.assert(

@@ -150,13 +164,24 @@ !trades.find(t => new Date(t.timestamp).getTime() < new Date('2006-01-01').getTime()),

trades.forEach(t => au.assertStringProperty(t, 'id'))
trades.forEach(t => au.assertTimestampProperty(t, 'timestamp'))
trades.forEach(t => au.assertNumericStringProperty(t, 'price'))
trades.forEach(t => au.assertNumericStringProperty(t, 'amount'))
trades.forEach(t => au.assertStringProperty(t, 'order', { required: false }))
trades.forEach((t) => au.assertStringProperty(t, 'id'));
trades.forEach((t) => au.assertTimestampProperty(t, 'timestamp'));
trades.forEach((t) => au.assertNumericStringProperty(t, 'price'));
trades.forEach((t) => {
if (t.amount) {
au.assertNumericStringProperty(t, 'amount');
au.assertNumericStringProperty(t, 'amount_quote', { required: false });
} else {
au.assertNumericStringProperty(t, 'amount_quote');
au.assertNumericStringProperty(t, 'amount', { required: false });
}
});
trades.forEach(t => au.assertPropertyInSet(t, 'type', TRADE_TYPES, { required: false }))
trades.forEach(t => au.assertPropertyInSet(t, 'side', ['buy', 'sell'], { required: false }))
trades.forEach((t) => au.assertPropertyInSet(t, 'side', ['buy', 'sell'], { required: false }));
trades.forEach((t) => au.assertStringProperty(t, 'order', { required: false }));
const since = trades[0].id
const second = await au.get(`/trades?market=${encodeURIComponent(market.id)}&since=${since}`)
au.assert(second.length > 0, `Trades with since=${since} didn't return any trades`)
const since = trades[0].id;
const second = await au.get(`/trades?market=${encodeURIComponent(market.id)}&since=${since}`);
au.assert(second.length > 0, `Trades with since=${since} didn't return any trades`);
au.assert(

@@ -203,3 +228,4 @@ !second.find(t => t.id === since),

au.assert(trades.length > 2, 'Expected more than two trades')
au.assert(trades.length > 2, 'Expected more than two trades');
au.assert(

@@ -210,9 +236,19 @@ !trades.find(t => new Date(t.timestamp).getTime() < new Date('2006-01-01').getTime()),

trades.forEach(t => au.assertStringProperty(t, 'id'))
trades.forEach(t => au.assertTimestampProperty(t, 'timestamp'))
trades.forEach(t => au.assertNumericStringProperty(t, 'price'))
trades.forEach(t => au.assertNumericStringProperty(t, 'amount'))
trades.forEach(t => au.assertStringProperty(t, 'order', { required: false }))
trades.forEach((t) => au.assertStringProperty(t, 'id'));
trades.forEach((t) => au.assertTimestampProperty(t, 'timestamp'));
trades.forEach((t) => au.assertNumericStringProperty(t, 'price'));
trades.forEach((t) => {
if (t.amount) {
au.assertNumericStringProperty(t, 'amount');
au.assertNumericStringProperty(t, 'amount_quote', { required: false });
} else {
au.assertNumericStringProperty(t, 'amount_quote');
au.assertNumericStringProperty(t, 'amount', { required: false });
}
});
trades.forEach((t) => au.assertStringProperty(t, 'order', { required: false }));
trades.forEach(t => au.assertPropertyInSet(t, 'type', TRADE_TYPES, { required: false }))
trades.forEach(t => au.assertPropertyInSet(t, 'side', ['buy', 'sell'], { required: false }))
trades.forEach((t) => au.assertPropertyInSet(t, 'side', ['buy', 'sell'], { required: false }));

@@ -270,8 +306,18 @@ const since = trades[0].timestamp

trades.forEach(t => au.assertTimestampProperty(t, 'timestamp'))
trades.forEach(t => au.assertNumericStringProperty(t, 'price'))
trades.forEach(t => au.assertNumericStringProperty(t, 'amount'))
trades.forEach(t => au.assertStringProperty(t, 'order', { required: false }))
trades.forEach(t => au.assertPropertyInSet(t, 'type', TRADE_TYPES, { required: false }))
trades.forEach(t => au.assertPropertyInSet(t, 'side', ['buy', 'sell'], { required: false }))
trades.forEach((t) => au.assertNumericStringProperty(t, 'price'));
trades.forEach((t) => {
if (t.amount) {
au.assertNumericStringProperty(t, 'amount');
au.assertNumericStringProperty(t, 'amount_quote', { required: false });
} else {
au.assertNumericStringProperty(t, 'amount_quote');
au.assertNumericStringProperty(t, 'amount', { required: false });
}
});
trades.forEach((t) => au.assertStringProperty(t, 'order', { required: false }));
success = true

@@ -459,7 +505,14 @@ } catch (err) {

au.assertNumericStringProperty(c, 'close')
au.assertNumericStringProperty(c, 'close');
au.assertNumericStringProperty(c, 'volume')
au.assert(parseFloat(c.volume) >= 0, 'Expected volume to be greater than or equal to 0')
})
if (c.volume) {
au.assertNumericStringProperty(c, 'volume');
au.assertNumericStringProperty(c, 'volume_quote', { required: false });
au.assert(parseFloat(c.volume) >= 0, 'Expected volume to be greater than or equal to 0');
} else {
au.assertNumericStringProperty(c, 'volume_quote');
au.assertNumericStringProperty(c, 'volume', { required: false });
au.assert(parseFloat(c.volume_quote) >= 0, 'Expected volume to be greater than or equal to 0');
}
});
}

@@ -508,2 +561,12 @@ } catch (err) {

if (ticker.volume) {
au.assertNumericStringProperty(ticker, 'volume');
au.assertNumericStringProperty(ticker, 'volume_quote', { required: false });
au.assert(parseFloat(ticker.volume) >= 0, 'Expected volume to be greater than or equal to 0');
} else {
au.assertNumericStringProperty(ticker, 'volume_quote');
au.assertNumericStringProperty(ticker, 'volume', { required: false });
au.assert(parseFloat(ticker.volume_quote) >= 0, 'Expected volume to be greater than or equal to 0');
}
if (ticker.ask && ticker.bid) {

@@ -510,0 +573,0 @@ au.assert(

{
"name": "nomics-platform",
"version": "0.13.8",
"version": "1.0.0",
"description": "Nomics Platform Toolkit",

@@ -5,0 +5,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc