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

cryptomarket

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cryptomarket - npm Package Compare versions

Comparing version 3.1.0 to 3.2.0

test/rest/changeCredentials.test.ts

83

lib/client.ts

@@ -5,2 +5,3 @@ import {

IDENTIFY_BY,
ORDER_BY,
ORDER_TYPE,

@@ -56,2 +57,22 @@ PERIOD,

/**
* Changes the window used in authenticated calls
*
* @param {number} window acceptable time between request and server execution in millis
*/
changeWindow(window: number) {
this.httpClient.changeWindow(window)
}
/**
* Changes the user credentials used for authentication in calls
*
* @param {string} apiKey the user public key used in new calls
* @param {string} apiSecret the user secret key used in new calls
*/
changeCredentials(apiKey: string, apiSecret: string) {
this.httpClient.changeCredentials(apiKey, apiSecret)
}
async publicGet(endpoint: string, params: any) {

@@ -1165,3 +1186,19 @@ const parsedParams = fromCamelCaseToSnakeCase(params)

/**
* Get estimates of withdrawal fees
*
* Requires the "Payment information" API key Access Right.
*
* https://api.exchange.cryptomkt.com/#bulk-estimate-withdrawal-fee
*
* @param {FeeRequest[]} feeRequests A list of fee requests
*
* @return The list of requested fees
*/
async getBulkEstimateWithdrawalFees(feeRequests: FeeRequest[]): Promise<Fee[]> {
return this.post("wallet/crypto/fee/estimate/bulk", feeRequests);
}
/**
* Get an estimate of a withdrawal fee

@@ -1189,2 +1226,40 @@ *

// /**
// * Get estimates of deposit fees
// *
// * Requires the "Payment information" API key Access Right.
// *
// * https://api.exchange.cryptomkt.com/#bulk-estimate-deposit-fee
// *
// * @param {FeeRequest[]} feeRequests A list of fee requests
// *
// * @return The list of requested fees
// */
// async getBulkEstimateDepositFees(feeRequests: FeeRequest[]): Promise<Fee[]> {
// return this.post("wallet/crypto/fee/deposit/estimate/bulk", feeRequests);
// }
// /**
// * Get an estimate of a deposit fee
// *
// * Requires the "Payment information" API key Access Right.
// *
// * https://api.exchange.cryptomkt.com/#estimate-deposit-fee
// *
// * @param {object} params
// * @param {string} params.currency the currency code for deposit
// * @param {string} params.amount the expected deposit amount
// * @param {string} [params.netwrokCode] Optional. Network code
// *
// * @return The expected fee
// */
// async getEstimateDepositFee(params: {
// currency: string;
// amount: string;
// networkCode?: string;
// }): Promise<string> {
// const response = await this.get("wallet/crypto/fee/deposit/estimate", params);
// return response["fee"];
// }
/**

@@ -1308,5 +1383,5 @@ * Converts between currencies

* @param {string[]} [params.networks] Optional. List of network codes
* @param {SORT_BY} [params.orderBy] Optional. Defines the sorting type.'createdAt' or 'id'. Default is 'createdAt'
* @param {string} [params.from] Optional. Interval initial value when ordering by 'createdAt'. As Datetime
* @param {string} [params.till] Optional. Interval end value when ordering by 'createdAt'. As Datetime
* @param {ORDER_BY} [params.orderBy] Optional. Defines the sorting type.'CREATED_AT', 'UPDATED_AT', 'LAST_ACTIVITY_AT' or 'ID'. Default is 'CREATED_AT'
* @param {string} [params.from] Optional. Interval initial value (inclusive). The value type depends on orderBy.
* @param {string} [params.till] Optional. Interval end value (inclusive). The value type depends on orderBy.
* @param {string} [params.idFrom] Optional. Interval initial value when ordering by id. Min is 0

@@ -1328,3 +1403,3 @@ * @param {string} [params.idTill] Optional. Interval end value when ordering by id. Min is 0

networks?: string[],
orderBy?: SORT_BY;
orderBy?: ORDER_BY;
from?: string;

@@ -1331,0 +1406,0 @@ till?: string;

@@ -30,3 +30,10 @@ export enum SIDE {

TIMESTAMP = "timestamp",
ID = "id",
}
export enum ORDER_BY {
CREATED_AT = "created_at",
UPDATED_AT = "updated_at",
LAST_ACTIVITY_AT = "last_activity_at",
ID = "id",

@@ -33,0 +40,0 @@ }

@@ -19,2 +19,11 @@ import CryptoJS from "crypto-js";

changeWindow(window: number) {
this.window = window;
}
changeCredentials(apiKey: string, apiSecret: string) {
this.apiKey = apiKey;
this.apiSecret = apiSecret;
}
/**+

@@ -21,0 +30,0 @@ *

@@ -20,2 +20,11 @@ import fetch from "node-fetch";

changeWindow(window: number) {
this.hmac.changeWindow(window)
}
changeCredentials(apiKey: string, apiSecret: string) {
this.hmac.changeCredentials(apiKey, apiSecret)
}
async makeRequest(

@@ -22,0 +31,0 @@ method: HTTP_METHOD,

2

lib/models/Fee.ts

@@ -5,3 +5,3 @@ export interface Fee {

amount: string;
networkFee: string;
networkFee?: string;
}

@@ -17,2 +17,10 @@ export interface Network {

avgProcessingTime: string;
code: string;
networkName: string;
isEnsAvailable: boolean;
crypto_paymentIdName: string;
cryptoExplorer: string;
contractAddress: string;
isMultichain: boolean;
assetId: Map<string, string>;
}

@@ -9,2 +9,3 @@ export interface Transaction {

updatedAt: string;
lastActivityAt: string;
native: NativeTransaction;

@@ -11,0 +12,0 @@ commitRisk: CommitRisk;

@@ -5,2 +5,3 @@ import { AuthClient } from "./authClient";

NOTIFICATION_TYPE,
ORDER_BY,
SORT,

@@ -98,7 +99,7 @@ SORT_BY,

* @param {TRANSACTION_STATUS[]} [params.transactionStatuses] Optional. List of statuses to query. valid subtypes are: 'CREATED', 'PENDING', 'FAILED', 'SUCCESS' and 'ROLLED_BACK'
* @param {string} [params.from] Optional. Interval initial value when ordering by 'createdAt'. As Datetime
* @param {string} [params.till] Optional. Interval end value when ordering by 'createdAt'. As Datetime
* @param {string} [params.from] Optional. Interval initial value (inclusive). The value type depends on order_by.
* @param {string} [params.till] Optional. Interval end value (inclusive). The value type depends on order_by.
* @param {string} [params.idFrom] Optional. Interval initial value when ordering by id. Min is 0
* @param {string} [params.idTill] Optional. Interval end value when ordering by id. Min is 0
* @param {SORT_BY} [params.orderBy] Optional. sorting parameter.'createdAt' or 'id'. Default is 'createdAt'
* @param {ORDER_BY} [params.orderBy] Optional. Defines the sorting type.'CREATED_AT', 'updatedAt', 'last or 'id'. Default is 'createdAt'
* @param {SORT} [params.sort] Optional. Sort direction. 'ASC' or 'DESC'. Default is 'DESC'

@@ -120,3 +121,3 @@ * @param {number} [params.limit] Optional. Transactions per query. Defaul is 100. Max is 1000

idTill?: number;
orderBy?: SORT_BY;
orderBy?: ORDER_BY;
sort?: SORT;

@@ -123,0 +124,0 @@ limit?: number;

{
"name": "cryptomarket",
"version": "3.1.0",
"version": "3.2.0",
"description": "The CryptoMarket for Node.js",

@@ -5,0 +5,0 @@ "homepage": "https://www.cryptomkt.com",

@@ -12,3 +12,3 @@ # CryptoMarket-javascript

```
npm install cryptomarket
npm install cryptomarket@3.2.0
```

@@ -15,0 +15,0 @@

@@ -5,3 +5,3 @@ import assert from "assert";

import { Client } from "../../lib/client";
import { ACCOUNT } from "../../lib/constants";
import { ACCOUNT, ORDER_BY, SORT } from "../../lib/constants";
import {

@@ -151,9 +151,39 @@ goodAddress,

]);
fees.forEach(fee => assert(goodFee(fee), "not good address"))
fees.forEach(fee => assert(goodFee(fee), "not good fee"))
});
});
describe("get bulk estimates withdrawal fees", () => {
it("", async function () {
this.timeout(0);
let fees = await client.getBulkEstimateWithdrawalFees([
{ currency: "CRO", amount: "100" },
{ currency: "EOS", amount: "12" }
]);
fees.forEach(fee => assert(goodFee(fee), "not good fee"))
});
});
// describe("get estimate deposit fee", () => {
// it("", async function () {
// this.timeout(0);
// let fee = await client.getEstimateDepositFee({
// currency: "CRO",
// amount: "100",
// });
// assert(fee !== "", "not a good fee");
// });
// });
// describe("get bulk estimates deposit fees", () => {
// it("", async function () {
// this.timeout(0);
// let fees = await client.getBulkEstimateDepositFees([
// { currency: "CRO", amount: "100" },
// { currency: "EOS", amount: "12" }
// ]);
// fees.forEach(fee => assert(goodFee(fee), "not good fee"))
// });
// });
describe("check if crypto address belongs to current account", () => {
it("cro belongs", async function () {
it("eth belongs", async function () {
this.timeout(0);
let croAddress = await client.getDepositCryptoAddress("CRO");
let croAddress = await client.getDepositCryptoAddress("ETH");
let result = await client.checkIfCryptoAddressBelongsToCurrentAccount(

@@ -164,5 +194,5 @@ croAddress.address

});
it.skip("eos belongs", async function () {
it("btc belongs", async function () {
this.timeout(0);
let eosAddress = await client.getDepositCryptoAddress("EOS");
let eosAddress = await client.getDepositCryptoAddress("BTC");
let result = await client.checkIfCryptoAddressBelongsToCurrentAccount(

@@ -219,2 +249,16 @@ eosAddress.address

});
describe("get transaction history with params", () => {
it("", async function () {
this.timeout(0);
let transactions = await client.getTransactionHistory({
currencies: ["CRO", "ETH"],
orderBy: ORDER_BY.CREATED_AT,
sort: SORT.ASC,
limit: 100,
offset: 1,
from: "1614815872000"
});
assert(goodList(goodTransaction, transactions), "not good transaction");
});
});
describe("get transaction by identifier", () => {

@@ -221,0 +265,0 @@ it("", async function () {

@@ -72,2 +72,3 @@ import { Fee, Report } from "../lib/models";

"precisionTransfer",
// "accountTopOrder", // Optional
"networks",

@@ -330,3 +331,3 @@ ]);

"fee",
"networkFee",
// "networkFee", // Optional
"amount",

@@ -346,2 +347,4 @@ "currency"

"updatedAt",
"lastActivityAt",
"commitRisk",
// "native", // optional

@@ -352,8 +355,11 @@ // "primetrust", // optional

if (!good) return false;
if ("native" in transaction && !goodNativeTransaction(transaction.native)) {
if ("native" in transaction && !goodNativeTransaction(transaction.native)) {
return false;
}
if ("meta" in transaction && !goodMetaTransaction(transaction.native)) {
if ("commitRisk" in transaction && !goodCommitRisk(transaction.commitRisk)) {
return false;
}
// if ("meta" in transaction && !goodMetaTransaction(transaction.meta)) {
// return false;
// }
return true;

@@ -401,2 +407,7 @@ }

export function goodCommitRisk(commitRisk: any) {
return goodObject(commitRisk, []);
}
export function goodReport(report: Report) {

@@ -403,0 +414,0 @@ return goodObject(report, [

@@ -7,2 +7,3 @@

import { goodBalance, goodTransaction } from "../testHelpers";
import { ORDER_BY, SORT } from "../../lib/constants";

@@ -46,2 +47,21 @@ describe("WalletClient", function () {

});
describe("get transactions with params", function () {
it("gets a list of transactions", async function () {
this.timeout(0);
await wsclient.connect();
const transactions = await wsclient.getTransactions({
currencies: ["CRO", "ETH"],
orderBy: ORDER_BY.CREATED_AT,
sort: SORT.ASC,
limit: 100,
offset: 2,
from: "1614815872000"
});
const allGood = transactions.map(goodTransaction).every(Boolean)
expect(allGood).to.be.true
await wsclient.close();
});
});
});
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