Socket
Socket
Sign inDemoInstall

@ledgerhq/coin-check

Package Overview
Dependencies
Maintainers
20
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ledgerhq/coin-check - npm Package Compare versions

Comparing version 0.3.12 to 0.3.13

6

CHANGELOG.md
# @ledgerhq/coin-check
## 0.3.13
### Patch Changes
- 832fa50: [coin-check] Fix getBalance()
## 0.3.12

@@ -4,0 +10,0 @@

1

lib/coinGateway.d.ts

@@ -5,2 +5,3 @@ import type { Logger } from "@ledgerhq/vault-utils";

baseURL: string;
redirectURLs?: Record<string, string>;
logger?: Logger;

@@ -7,0 +8,0 @@ };

@@ -20,8 +20,11 @@ "use strict";

function createCoinGatewayClient(opts) {
const { baseURL, logger = vault_utils_1.SILENT_LOGGER } = opts;
const { baseURL, redirectURLs, logger = vault_utils_1.SILENT_LOGGER } = opts;
const httpClient = axios_1.default.create({ baseURL });
if (process.env.DEBUG === "1") {
httpClient.interceptors.response.use((res) => {
logger.info(`['${res.config.url}', ${JSON.stringify(res.data)}]`);
logger.info(`[${res.status}, '${res.config.url}', ${JSON.stringify(res.data)}]`);
return res;
}, (err) => {
logger.info(`[${err.response.status}, '${err.config.url}', []]`);
throw err;
});

@@ -76,4 +79,34 @@ }

const _getBalance = (pool, wallet, index) => __awaiter(this, void 0, void 0, function* () {
const { data } = yield httpClient.get(`/pools/${pool}/wallets/${wallet}/accounts/${index}/balance`, { headers: { pubkey: pool }, transformResponse: (r) => r });
return data;
var _c, _d;
const url = `/pools/${pool}/wallets/${wallet}/accounts/${index}/balance`;
try {
const { data } = yield httpClient.get(url, {
headers: { pubkey: pool },
transformResponse: (r) => r,
maxRedirects: 0,
});
return data;
}
catch (err) {
if (axios_1.default.isAxiosError(err)) {
if (((_c = err.response) === null || _c === void 0 ? void 0 : _c.status) === 307) {
if (!redirectURLs)
throw new Error("redirecting: redirectURLs must be defined");
const [protocol, hostname] = err.response.headers.location.split(":");
const host = `${protocol}:${hostname}`;
const redirectURL = `${redirectURLs[host]}${url}`;
logger.info(`Redirect - GET ${redirectURL}`);
const { data } = yield httpClient.get(redirectURL, {
headers: { pubkey: pool },
transformResponse: (r) => r,
});
return data;
}
logger.error(`GET ${url} - status ${(_d = err.response) === null || _d === void 0 ? void 0 : _d.status} - ${err.message}`);
}
else {
logger.error(`GET ${url} - Unknown error: ${err}`);
}
throw err;
}
});

@@ -80,0 +113,0 @@ const _getTransactions = (pool, wallet, index, next) => __awaiter(this, void 0, void 0, function* () {

3

lib/index.d.ts

@@ -7,6 +7,7 @@ import { Logger } from "@ledgerhq/vault-utils";

wallet?: string;
redirectURLs?: Record<string, string>;
logger: Logger;
};
declare function check({ coinGatewayURL, pool, wallet, logger, }: GetAccountsOptions): Promise<Report>;
declare function check({ coinGatewayURL, pool, wallet, redirectURLs, logger, }: GetAccountsOptions): Promise<Report>;
export default check;
//# sourceMappingURL=index.d.ts.map

@@ -19,5 +19,5 @@ "use strict";

const helpers_1 = require("./helpers");
function check({ coinGatewayURL, pool, wallet, logger = vault_utils_1.SILENT_LOGGER, }) {
function check({ coinGatewayURL, pool, wallet, redirectURLs, logger = vault_utils_1.SILENT_LOGGER, }) {
return __awaiter(this, void 0, void 0, function* () {
const coinGateway = (0, coinGateway_1.default)({ baseURL: coinGatewayURL, logger });
const coinGateway = (0, coinGateway_1.default)({ baseURL: coinGatewayURL, redirectURLs, logger });
const cryptoAPIs = (0, cryptoAPIs_1.default)({ logger });

@@ -24,0 +24,0 @@ const coinGatewayAccounts = yield coinGateway.getAccounts({ poolName: pool, walletName: wallet });

{
"name": "@ledgerhq/coin-check",
"version": "0.3.12",
"version": "0.3.13",
"main": "./lib/index.js",

@@ -26,3 +26,3 @@ "description": "> TODO: description",

"@vitest/coverage-c8": "^0.25.1",
"axios-mock-adapter": "^1.18.2",
"axios-mock-adapter": "^1.21.2",
"eslint-config-custom": "0.0.2",

@@ -29,0 +29,0 @@ "tsconfig": "0.0.2",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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