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

@ledgerhq/currencies

Package Overview
Dependencies
Maintainers
7
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ledgerhq/currencies - npm Package Compare versions

Comparing version 4.3.0-beta.d226ed3b to 4.3.0-beta.f8165b69

flow-typed/npm/lodash_v4.x.x.js

191

lib/data/cryptocurrencies.js

@@ -40,3 +40,18 @@ "use strict";

scheme: "bitcoin",
apiName: "btc",
color: "#ffae35",
xpub: 0x0488b21e,
isSegwitSupported: true,
handleFeePerByte: true,
bitcoinjs: {
bech32: "bc",
bip32: {
private: 76066276,
public: 76067358
},
messagePrefix: "Bitcoin Signed Message:",
pubKeyHash: 0,
scriptHash: 5,
wif: 128
},
units: bitcoinUnits

@@ -47,5 +62,104 @@ }, {

scheme: "bitcoin",
apiName: "btc_testnet",
color: "#ffae35",
xpub: 0x043587cf,
isSegwitSupported: true,
handleFeePerByte: true,
bitcoinjs: {
bech32: "bc",
bip32: {
private: 70615956,
public: 70617039
},
messagePrefix: "Bitcoin Signed Message:",
pubKeyHash: 111,
scriptHash: 196,
wif: 239
},
units: bitcoinUnits
}, {
coinType: 145,
name: "Bitcoin Cash",
scheme: "bitcoin",
apiName: "abc",
color: "#85bb65",
xpub: 0x0488b21e,
sigHashType: 0x41,
isSegwitSupported: true,
handleFeePerByte: true,
bitcoinjs: {
bech32: "bc",
bip32: {
private: 76066276,
public: 76067358
},
messagePrefix: "Bitcoin Signed Message:",
pubKeyHash: 0,
scriptHash: 5,
wif: 128
},
units: [{
name: "bitcoin cash",
code: "BCH",
symbol: "Ƀ",
magnitude: 8
}, {
name: "mBCH",
code: "mBCH",
symbol: "Ƀ",
magnitude: 5
}, {
name: "bit",
code: "bit",
symbol: "Ƀ",
magnitude: 2
}, {
name: "satoshi",
code: "satoshi",
symbol: "Ƀ",
magnitude: 0
}]
}, {
coinType: 156,
name: "Bitcoin Gold",
scheme: "bitcoin",
apiName: "btg",
color: "#132c47",
xpub: 76067358,
sigHashType: 0x41,
isSegwitSupported: true,
handleFeePerByte: true,
areTransactionTimestamped: false,
bitcoinjs: {
messagePrefix: "Bitcoin gold Signed Message:",
bip32: {
public: 76067358,
private: 76066276
},
pubKeyHash: 38,
scriptHash: 23,
wif: 128
},
units: [{
name: "bitcoin gold",
code: "BTG",
symbol: "Ƀ",
magnitude: 8
}, {
name: "mBTG",
code: "mBTG",
symbol: "Ƀ",
magnitude: 5
}, {
name: "bit",
code: "bit",
symbol: "Ƀ",
magnitude: 2
}, {
name: "satoshi",
code: "satoshi",
symbol: "Ƀ",
magnitude: 0
}]
}, {
coinType: 2,

@@ -76,3 +190,18 @@ name: "Litecoin",

scheme: "dash",
apiName: "dash",
color: "#0e76aa",
xpub: 50221816,
isSegwitSupported: false,
handleFeePerByte: false,
areTransactionTimestamped: false,
bitcoinjs: {
messagePrefix: "DarkCoin Signed Message:",
bip32: {
public: 50221816,
private: 87393172
},
pubKeyHash: 76,
scriptHash: 16,
wif: 128
},
units: [{

@@ -87,7 +216,22 @@ name: "dash",

scheme: "peercoin",
apiName: "ppc",
color: "#3cb054",
xpub: 3874023909,
isSegwitSupported: false,
handleFeePerByte: false,
areTransactionTimestamped: true,
bitcoinjs: {
messagePrefix: "PPCoin Signed Message:",
bip32: {
public: 3874023909,
private: 87393172
},
pubKeyHash: 55,
scriptHash: 117,
wif: 128
},
units: [{
name: "peercoin",
code: "PPC",
magnitude: 8
magnitude: 6
}]

@@ -98,3 +242,18 @@ }, {

scheme: "stratis",
apiName: "strat",
color: "#1382c6",
xpub: 76071454,
isSegwitSupported: false,
handleFeePerByte: false,
areTransactionTimestamped: true,
bitcoinjs: {
messagePrefix: "Stratis Signed Message:",
bip32: {
public: 76071454,
private: 87393172
},
pubKeyHash: 63,
scriptHash: 125,
wif: 128
},
units: [{

@@ -109,3 +268,18 @@ name: "stratis",

scheme: "zcash",
apiName: "zec",
color: "#3790ca",
xpub: 76067358,
isSegwitSupported: false,
handleFeePerByte: false,
areTransactionTimestamped: false,
bitcoinjs: {
messagePrefix: "Zcash Signed Message:",
bip32: {
public: 76067358,
private: 87393172
},
pubKeyHash: new Uint8Array([0x1c, 0xb8]) /*7352*/
, scriptHash: new Uint8Array([0x1c, 0xbd]) /*7357*/
, wif: 128
},
units: [{

@@ -120,3 +294,18 @@ name: "zcash",

scheme: "komodo",
apiName: "kmd",
color: "#326464",
xpub: 4193182861,
isSegwitSupported: false,
handleFeePerByte: false,
areTransactionTimestamped: false,
bitcoinjs: {
messagePrefix: "Komodo Signed Message:",
bip32: {
public: 4193182861,
private: 87393172
},
pubKeyHash: 60,
scriptHash: 85,
wif: 128
},
units: [{

@@ -123,0 +312,0 @@ name: "komodo",

4

lib/data/icons/btc.js

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

"svg",
{ width: size, height: size, viewBox: "0 0 273.6 360" },
{ width: size, height: size, viewBox: "0 0 16 16" },
_react2.default.createElement("path", {
fill: "currentColor",
d: "M217.021,167.042c18.631-9.483,30.288-26.184,27.565-54.007c-3.667-38.023-36.526-50.773-78.006-54.404l-0.008-52.741 h-32.139l-0.009,51.354c-8.456,0-17.076,0.166-25.657,0.338L108.76,5.897l-32.11-0.003l-0.006,52.728 c-6.959,0.142-13.793,0.277-20.466,0.277v-0.156l-44.33-0.018l0.006,34.282c0,0,23.734-0.446,23.343-0.013 c13.013,0.009,17.262,7.559,18.484,14.076l0.01,60.083v84.397c-0.573,4.09-2.984,10.625-12.083,10.637 c0.414,0.364-23.379-0.004-23.379-0.004l-6.375,38.335h41.817c7.792,0.009,15.448,0.13,22.959,0.19l0.028,53.338l32.102,0.009 l-0.009-52.779c8.832,0.18,17.357,0.258,25.684,0.247l-0.009,52.532h32.138l0.018-53.249c54.022-3.1,91.842-16.697,96.544-67.385 C266.916,192.612,247.692,174.396,217.021,167.042z M109.535,95.321c18.126,0,75.132-5.767,75.14,32.064 c-0.008,36.269-56.996,32.032-75.14,32.032V95.321z M109.521,262.447l0.014-70.672c21.778-0.006,90.085-6.261,90.094,35.32 C199.638,266.971,131.313,262.431,109.521,262.447z"
d: "M7.62 0h1.7v3.058h-1.7V0zm1.7 0v3.058h-1.7V0h1.7zM7.813 12.942h1.7V16h-1.7v-3.058zm1.7 0V16h-1.7v-3.058h1.7zM4.406 0h1.7v3.058h-1.7V0zm1.7 0v3.058h-1.7V0h1.7zM4.6 12.942h1.7V16H4.6v-3.058zm1.7 0V16H4.6v-3.058h1.7zM2.666 8.813V1.95h.85l6.139.002c1.807.11 3.212 1.566 3.118 3.254l-.002.279c.111 1.744-1.298 3.217-3.168 3.328H2.666zm.85 0l.85-.85v4.32h5.608c.95-.025 1.676-.727 1.659-1.557v-.37c.019-.814-.707-1.518-1.637-1.543h-6.48zm7.557-3.275l.001-.378c.042-.77-.62-1.457-1.471-1.51H4.366v3.463h5.205c.899-.063 1.552-.753 1.502-1.575zM4.366 7.113l5.186.002.467-.002c1.86.05 3.355 1.5 3.314 3.262v.334c.036 1.779-1.458 3.224-3.337 3.273h-7.33V7.113h1.7zm0 0v.85l-.85-.85h.85z"
})

@@ -25,0 +25,0 @@ );

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

"svg",
{ width: size, height: size, viewBox: "0 0 226.777 226.777" },
{ width: size, height: size, viewBox: "0 0 16 16" },
_react2.default.createElement("path", {
fill: "currentColor",
d: "M113.388 0C50.766 0 0 50.766 0 113.388c0 62.623 50.766 113.389 113.389 113.389s113.389-50.766 113.389-113.389C226.777 50.766 176.011 0 113.388 0zM56.562 104.802h45.266l-5.238 17.024H51.326l5.236-17.024zm117.268-8.029c-1.801 6.506-7.656 26.023-10.059 32.945-2.4 6.922-6.829 12.734-12.506 16.057-5.676 3.323-7.797 4.712-15.731 4.712H54.303l5.721-18.542h76.395l11.414-37.109h-75.79l5.722-18.541h84.577c3.875 0 8.996 1.792 11.488 6.639 2.491 4.841 1.799 7.333 0 13.839z"
d: "M4.89 3.667l-.509 1.744-1.6-.467L3.64 2h5.782c4.255 0 7.307 2.297 6.426 5.312l-.64 2.103c-.803 2.75-4.804 4.836-8.917 4.836H.051l1.109-3.812 1.6.466-.488 1.679H6.29c3.452 0 6.759-1.725 7.32-3.645l.64-2.103c.484-1.658-1.523-3.169-4.829-3.169H4.89zM0 8.77V7.102h6.176v1.667H0z"
})

@@ -25,0 +25,0 @@ );

@@ -19,17 +19,9 @@ "use strict";

"svg",
{ viewBox: "0 0 2000 2000", width: size, height: size },
_react2.default.createElement(
"g",
{ fill: "currentColor" },
_react2.default.createElement("path", {
fill: "currentColor",
d: "M1024 659H881.12v281.69h224.79v117.94H881.12v281.67H1031c38.51 0 316.16 4.35 315.73-327.72S1077.44 659 1024 659z"
}),
_react2.default.createElement("path", {
fill: "currentColor",
d: "M1000 0C447.71 0 0 447.71 0 1000s447.71 1000 1000 1000 1000-447.71 1000-1000S1552.29 0 1000 0zm39.29 1540.1H677.14v-481.46H549.48V940.7h127.65V459.21h310.82c73.53 0 560.56-15.27 560.56 549.48 0 574.09-509.21 531.41-509.21 531.41z"
})
)
{ width: size, height: size, viewBox: "0 0 16 16" },
_react2.default.createElement("path", {
fill: "currentColor",
d: "M5.293 13.442H8.67c2.656 0 4.786-1.928 4.77-4.246V6.707c0-2.316-2.133-4.246-4.77-4.246H5.293v10.981zm3.376 1.661H3.632V.8h5.037c3.531 0 6.43 2.646 6.43 5.907V9.19c.024 3.266-2.877 5.914-6.43 5.914zM.6 8.883V7.02h8.397v1.861H.6z"
})
);
}
//# sourceMappingURL=dogecoin.js.map

@@ -19,14 +19,6 @@ "use strict";

"svg",
{ width: size, height: size, viewBox: "0.847 0.876 329.254 329.256" },
{ width: size, height: size, viewBox: "0 0 16 16" },
_react2.default.createElement("path", {
d: "M330.102 165.503c0 90.922-73.705 164.629-164.626 164.629C74.554 330.132.848 256.425.848 165.503.848 74.582 74.554.876 165.476.876c90.92 0 164.626 73.706 164.626 164.627",
fill: "currentColor"
}),
_react2.default.createElement("path", {
d: "M295.15 165.505c0 71.613-58.057 129.675-129.674 129.675-71.616 0-129.677-58.062-129.677-129.675 0-71.619 58.061-129.677 129.677-129.677 71.618 0 129.674 58.057 129.674 129.677",
fill: "currentColor"
}),
_react2.default.createElement("path", {
d: "M155.854 209.482l10.693-40.264 25.316-9.249 6.297-23.663-.215-.587-24.92 9.104 17.955-67.608h-50.921l-23.481 88.23-19.605 7.162-6.478 24.395 19.59-7.156-13.839 51.998h135.521l8.688-32.362h-84.601",
fill: "#fff"
fill: "currentColor",
d: "M4.535 14.348h9.198V16H2L9.064 0l1.511.667-6.04 13.681zM2.738 9.156l-.15-1.645 9.05-.827.15 1.645-9.05.827z"
})

@@ -33,0 +25,0 @@ );

@@ -18,7 +18,11 @@ "use strict";

var _memoize = require("lodash/memoize");
var _memoize2 = _interopRequireDefault(_memoize);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var nonBreakableSpace = " ";
var defaultFormatOptions = {
locale: "en-EN",
showCode: false,

@@ -30,2 +34,31 @@ alwaysShowSign: false,

var getFragPositions = (0, _memoize2.default)(function (locale) {
var res = (-1).toLocaleString(locale, {
currency: "USD",
style: "currency"
});
var frags = [];
var mandatoryFrags = 0;
for (var i = 0; i < res.length; i++) {
var c = res[i];
if (c === "$") {
// force code to be surround by separators. we'll dedup later
frags.push("separator");
frags.push("code");
frags.push("separator");
mandatoryFrags++;
} else if (c === "-") {
frags.push("sign");
mandatoryFrags++;
} else if (c === "1") {
frags.push("value");
mandatoryFrags++;
} else if (/\s/.test(c)) {
frags.push("separator");
}
if (mandatoryFrags === 3) return frags;
}
return frags;
});
function formatCurrencyUnitFragment(unit, value, options) {

@@ -35,3 +68,4 @@ var _defaultFormatOptions = (0, _extends3.default)({}, defaultFormatOptions, unit, options),

alwaysShowSign = _defaultFormatOptions.alwaysShowSign,
showAllDigits = _defaultFormatOptions.showAllDigits;
showAllDigits = _defaultFormatOptions.showAllDigits,
locale = _defaultFormatOptions.locale;

@@ -42,22 +76,32 @@ var magnitude = unit.magnitude,

var floatValue = value / Math.pow(10, magnitude);
var floatValueAbs = Math.abs(floatValue);
var minimumFractionDigits = showAllDigits ? magnitude : 0;
var maximumFractionDigits = Math.max(minimumFractionDigits, Math.max(0,
// dynamic max number of digits based on the value itself. to only show significant part
Math.min(4 - Math.round((0, _log2.default)(Math.abs(floatValue))), magnitude)));
Math.min(4 - Math.round((0, _log2.default)(floatValueAbs)), magnitude)));
var frags = [];
if (alwaysShowSign && floatValue > 0) {
frags.push({ kind: "sign", value: "+" });
}
if (showCode) {
frags.push({ kind: "code", value: code });
}
// TODO in case of negative value, we don't have it fragmented in a "sign"
frags.push({
kind: "value",
value: floatValue.toLocaleString("en-EN", {
var fragValueByKind = {
sign: alwaysShowSign || floatValue < 0 ? floatValue < 0 ? "-" : "+" : null,
code: showCode ? code : null,
value: floatValueAbs.toLocaleString(locale, {
maximumFractionDigits: maximumFractionDigits,
minimumFractionDigits: minimumFractionDigits
})
}),
separator: nonBreakableSpace
};
var frags = [];
var nonSepIndex = -1,
sepConsumed = true;
getFragPositions(locale).forEach(function (kind) {
var value = fragValueByKind[kind];
if (!value) return;
var isSep = kind === "separator";
if (sepConsumed && isSep) return;
sepConsumed = isSep;
if (!isSep) nonSepIndex = frags.length;
// $FlowFixMe
frags.push({ kind: kind, value: value });
});
frags.splice(nonSepIndex + 1); // remove extra space at the end
return frags;

@@ -70,4 +114,4 @@ }

return f.value;
}).join(nonBreakableSpace);
}).join("");
}
//# sourceMappingURL=formatCurrencyUnit.js.map

@@ -6,3 +6,3 @@ "use strict";

});
exports.decodeURIScheme = exports.encodeURIScheme = exports.countervalueForRate = exports.hasCurrencyByCoinType = exports.getDefaultUnitByCoinType = exports.getCurrencyByCoinType = exports.formatCurrencyUnitFragment = exports.formatCurrencyUnit = exports.hasFiatUnit = exports.getFiatUnit = exports.listCurrencies = undefined;
exports.decodeURIScheme = exports.encodeURIScheme = exports.countervalueForRate = exports.hasCurrencyByCoinType = exports.getDefaultUnitByCoinType = exports.getCurrencyByCoinType = exports.formatShort = exports.formatCurrencyUnitFragment = exports.formatCurrencyUnit = exports.hasFiatUnit = exports.getFiatUnit = exports.listCurrencies = undefined;

@@ -17,2 +17,4 @@ var _CurrencyURIScheme = require("./CurrencyURIScheme");

var _formatShort = require("./formatShort");
var _countervalueForRate = require("./countervalueForRate");

@@ -29,2 +31,3 @@

exports.formatCurrencyUnitFragment = _formatCurrencyUnit.formatCurrencyUnitFragment;
exports.formatShort = _formatShort.formatShort;
exports.getCurrencyByCoinType = _cryptocurrencies.getCurrencyByCoinType;

@@ -31,0 +34,0 @@ exports.getDefaultUnitByCoinType = _cryptocurrencies.getDefaultUnitByCoinType;

{
"name": "@ledgerhq/currencies",
"version": "4.3.0-beta.d226ed3b",
"version": "4.3.0-beta.f8165b69",
"description": "Ledger Hardware Wallet currencies dataset",

@@ -20,2 +20,4 @@ "keywords": [],

"dependencies": {
"lodash": "^4.17.5",
"numeral": "^2.0.6",
"querystring": "^0.2.0"

@@ -22,0 +24,0 @@ },

@@ -36,3 +36,18 @@ //@flow

scheme: "bitcoin",
apiName: "btc",
color: "#ffae35",
xpub: 0x0488b21e,
isSegwitSupported: true,
handleFeePerByte: true,
bitcoinjs: {
bech32: "bc",
bip32: {
private: 76066276,
public: 76067358
},
messagePrefix: "Bitcoin Signed Message:",
pubKeyHash: 0,
scriptHash: 5,
wif: 128
},
units: bitcoinUnits

@@ -44,6 +59,117 @@ },

scheme: "bitcoin",
apiName: "btc_testnet",
color: "#ffae35",
xpub: 0x043587cf,
isSegwitSupported: true,
handleFeePerByte: true,
bitcoinjs: {
bech32: "bc",
bip32: {
private: 70615956,
public: 70617039
},
messagePrefix: "Bitcoin Signed Message:",
pubKeyHash: 111,
scriptHash: 196,
wif: 239
},
units: bitcoinUnits
},
{
coinType: 145,
name: "Bitcoin Cash",
scheme: "bitcoin",
apiName: "abc",
color: "#85bb65",
xpub: 0x0488b21e,
sigHashType: 0x41,
isSegwitSupported: true,
handleFeePerByte: true,
bitcoinjs: {
bech32: "bc",
bip32: {
private: 76066276,
public: 76067358
},
messagePrefix: "Bitcoin Signed Message:",
pubKeyHash: 0,
scriptHash: 5,
wif: 128
},
units: [
{
name: "bitcoin cash",
code: "BCH",
symbol: "Ƀ",
magnitude: 8
},
{
name: "mBCH",
code: "mBCH",
symbol: "Ƀ",
magnitude: 5
},
{
name: "bit",
code: "bit",
symbol: "Ƀ",
magnitude: 2
},
{
name: "satoshi",
code: "satoshi",
symbol: "Ƀ",
magnitude: 0
}
]
},
{
coinType: 156,
name: "Bitcoin Gold",
scheme: "bitcoin",
apiName: "btg",
color: "#132c47",
xpub: 76067358,
sigHashType: 0x41,
isSegwitSupported: true,
handleFeePerByte: true,
areTransactionTimestamped: false,
bitcoinjs: {
messagePrefix: "Bitcoin gold Signed Message:",
bip32: {
public: 76067358,
private: 76066276
},
pubKeyHash: 38,
scriptHash: 23,
wif: 128
},
units: [
{
name: "bitcoin gold",
code: "BTG",
symbol: "Ƀ",
magnitude: 8
},
{
name: "mBTG",
code: "mBTG",
symbol: "Ƀ",
magnitude: 5
},
{
name: "bit",
code: "bit",
symbol: "Ƀ",
magnitude: 2
},
{
name: "satoshi",
code: "satoshi",
symbol: "Ƀ",
magnitude: 0
}
]
},
{
coinType: 2,

@@ -80,3 +206,18 @@ name: "Litecoin",

scheme: "dash",
apiName: "dash",
color: "#0e76aa",
xpub: 50221816,
isSegwitSupported: false,
handleFeePerByte: false,
areTransactionTimestamped: false,
bitcoinjs: {
messagePrefix: "DarkCoin Signed Message:",
bip32: {
public: 50221816,
private: 87393172
},
pubKeyHash: 76,
scriptHash: 16,
wif: 128
},
units: [

@@ -94,3 +235,18 @@ {

scheme: "peercoin",
apiName: "ppc",
color: "#3cb054",
xpub: 3874023909,
isSegwitSupported: false,
handleFeePerByte: false,
areTransactionTimestamped: true,
bitcoinjs: {
messagePrefix: "PPCoin Signed Message:",
bip32: {
public: 3874023909,
private: 87393172
},
pubKeyHash: 55,
scriptHash: 117,
wif: 128
},
units: [

@@ -100,3 +256,3 @@ {

code: "PPC",
magnitude: 8
magnitude: 6
}

@@ -109,3 +265,18 @@ ]

scheme: "stratis",
apiName: "strat",
color: "#1382c6",
xpub: 76071454,
isSegwitSupported: false,
handleFeePerByte: false,
areTransactionTimestamped: true,
bitcoinjs: {
messagePrefix: "Stratis Signed Message:",
bip32: {
public: 76071454,
private: 87393172
},
pubKeyHash: 63,
scriptHash: 125,
wif: 128
},
units: [

@@ -123,3 +294,18 @@ {

scheme: "zcash",
apiName: "zec",
color: "#3790ca",
xpub: 76067358,
isSegwitSupported: false,
handleFeePerByte: false,
areTransactionTimestamped: false,
bitcoinjs: {
messagePrefix: "Zcash Signed Message:",
bip32: {
public: 76067358,
private: 87393172
},
pubKeyHash: new Uint8Array([0x1c, 0xb8]) /*7352*/,
scriptHash: new Uint8Array([0x1c, 0xbd]) /*7357*/,
wif: 128
},
units: [

@@ -137,3 +323,18 @@ {

scheme: "komodo",
apiName: "kmd",
color: "#326464",
xpub: 4193182861,
isSegwitSupported: false,
handleFeePerByte: false,
areTransactionTimestamped: false,
bitcoinjs: {
messagePrefix: "Komodo Signed Message:",
bip32: {
public: 4193182861,
private: 87393172
},
pubKeyHash: 60,
scriptHash: 85,
wif: 128
},
units: [

@@ -140,0 +341,0 @@ {

@@ -11,6 +11,6 @@ //@flow

return (
<svg width={size} height={size} viewBox="0 0 273.6 360">
<svg width={size} height={size} viewBox="0 0 16 16">
<path
fill="currentColor"
d="M217.021,167.042c18.631-9.483,30.288-26.184,27.565-54.007c-3.667-38.023-36.526-50.773-78.006-54.404l-0.008-52.741 h-32.139l-0.009,51.354c-8.456,0-17.076,0.166-25.657,0.338L108.76,5.897l-32.11-0.003l-0.006,52.728 c-6.959,0.142-13.793,0.277-20.466,0.277v-0.156l-44.33-0.018l0.006,34.282c0,0,23.734-0.446,23.343-0.013 c13.013,0.009,17.262,7.559,18.484,14.076l0.01,60.083v84.397c-0.573,4.09-2.984,10.625-12.083,10.637 c0.414,0.364-23.379-0.004-23.379-0.004l-6.375,38.335h41.817c7.792,0.009,15.448,0.13,22.959,0.19l0.028,53.338l32.102,0.009 l-0.009-52.779c8.832,0.18,17.357,0.258,25.684,0.247l-0.009,52.532h32.138l0.018-53.249c54.022-3.1,91.842-16.697,96.544-67.385 C266.916,192.612,247.692,174.396,217.021,167.042z M109.535,95.321c18.126,0,75.132-5.767,75.14,32.064 c-0.008,36.269-56.996,32.032-75.14,32.032V95.321z M109.521,262.447l0.014-70.672c21.778-0.006,90.085-6.261,90.094,35.32 C199.638,266.971,131.313,262.431,109.521,262.447z"
d="M7.62 0h1.7v3.058h-1.7V0zm1.7 0v3.058h-1.7V0h1.7zM7.813 12.942h1.7V16h-1.7v-3.058zm1.7 0V16h-1.7v-3.058h1.7zM4.406 0h1.7v3.058h-1.7V0zm1.7 0v3.058h-1.7V0h1.7zM4.6 12.942h1.7V16H4.6v-3.058zm1.7 0V16H4.6v-3.058h1.7zM2.666 8.813V1.95h.85l6.139.002c1.807.11 3.212 1.566 3.118 3.254l-.002.279c.111 1.744-1.298 3.217-3.168 3.328H2.666zm.85 0l.85-.85v4.32h5.608c.95-.025 1.676-.727 1.659-1.557v-.37c.019-.814-.707-1.518-1.637-1.543h-6.48zm7.557-3.275l.001-.378c.042-.77-.62-1.457-1.471-1.51H4.366v3.463h5.205c.899-.063 1.552-.753 1.502-1.575zM4.366 7.113l5.186.002.467-.002c1.86.05 3.355 1.5 3.314 3.262v.334c.036 1.779-1.458 3.224-3.337 3.273h-7.33V7.113h1.7zm0 0v.85l-.85-.85h.85z"
/>

@@ -17,0 +17,0 @@ </svg>

@@ -11,6 +11,6 @@ //@flow

return (
<svg width={size} height={size} viewBox="0 0 226.777 226.777">
<svg width={size} height={size} viewBox="0 0 16 16">
<path
fill="currentColor"
d="M113.388 0C50.766 0 0 50.766 0 113.388c0 62.623 50.766 113.389 113.389 113.389s113.389-50.766 113.389-113.389C226.777 50.766 176.011 0 113.388 0zM56.562 104.802h45.266l-5.238 17.024H51.326l5.236-17.024zm117.268-8.029c-1.801 6.506-7.656 26.023-10.059 32.945-2.4 6.922-6.829 12.734-12.506 16.057-5.676 3.323-7.797 4.712-15.731 4.712H54.303l5.721-18.542h76.395l11.414-37.109h-75.79l5.722-18.541h84.577c3.875 0 8.996 1.792 11.488 6.639 2.491 4.841 1.799 7.333 0 13.839z"
d="M4.89 3.667l-.509 1.744-1.6-.467L3.64 2h5.782c4.255 0 7.307 2.297 6.426 5.312l-.64 2.103c-.803 2.75-4.804 4.836-8.917 4.836H.051l1.109-3.812 1.6.466-.488 1.679H6.29c3.452 0 6.759-1.725 7.32-3.645l.64-2.103c.484-1.658-1.523-3.169-4.829-3.169H4.89zM0 8.77V7.102h6.176v1.667H0z"
/>

@@ -17,0 +17,0 @@ </svg>

@@ -11,15 +11,9 @@ //@flow

return (
<svg viewBox="0 0 2000 2000" width={size} height={size}>
<g fill="currentColor">
<path
fill="currentColor"
d="M1024 659H881.12v281.69h224.79v117.94H881.12v281.67H1031c38.51 0 316.16 4.35 315.73-327.72S1077.44 659 1024 659z"
/>
<path
fill="currentColor"
d="M1000 0C447.71 0 0 447.71 0 1000s447.71 1000 1000 1000 1000-447.71 1000-1000S1552.29 0 1000 0zm39.29 1540.1H677.14v-481.46H549.48V940.7h127.65V459.21h310.82c73.53 0 560.56-15.27 560.56 549.48 0 574.09-509.21 531.41-509.21 531.41z"
/>
</g>
<svg width={size} height={size} viewBox="0 0 16 16">
<path
fill="currentColor"
d="M5.293 13.442H8.67c2.656 0 4.786-1.928 4.77-4.246V6.707c0-2.316-2.133-4.246-4.77-4.246H5.293v10.981zm3.376 1.661H3.632V.8h5.037c3.531 0 6.43 2.646 6.43 5.907V9.19c.024 3.266-2.877 5.914-6.43 5.914zM.6 8.883V7.02h8.397v1.861H.6z"
/>
</svg>
);
}

@@ -11,17 +11,9 @@ //@flow

return (
<svg width={size} height={size} viewBox="0.847 0.876 329.254 329.256">
<svg width={size} height={size} viewBox="0 0 16 16">
<path
d="M330.102 165.503c0 90.922-73.705 164.629-164.626 164.629C74.554 330.132.848 256.425.848 165.503.848 74.582 74.554.876 165.476.876c90.92 0 164.626 73.706 164.626 164.627"
fill="currentColor"
d="M4.535 14.348h9.198V16H2L9.064 0l1.511.667-6.04 13.681zM2.738 9.156l-.15-1.645 9.05-.827.15 1.645-9.05.827z"
/>
<path
d="M295.15 165.505c0 71.613-58.057 129.675-129.674 129.675-71.616 0-129.677-58.062-129.677-129.675 0-71.619 58.061-129.677 129.677-129.677 71.618 0 129.674 58.057 129.674 129.677"
fill="currentColor"
/>
<path
d="M155.854 209.482l10.693-40.264 25.316-9.249 6.297-23.663-.215-.587-24.92 9.104 17.955-67.608h-50.921l-23.481 88.23-19.605 7.162-6.478 24.395 19.59-7.156-13.839 51.998h135.521l8.688-32.362h-84.601"
fill="#fff"
/>
</svg>
);
}
//@flow
import type { Unit } from "./types";
import memoize from "lodash/memoize";
const nonBreakableSpace = " ";
const defaultFormatOptions = {
locale: "en-EN",
showCode: false,

@@ -15,4 +17,34 @@ alwaysShowSign: false,

| { kind: "sign", value: string }
| { kind: "code", value: string };
| { kind: "code", value: string }
| { kind: "separator", value: string };
const getFragPositions = memoize((locale: string): Array<*> => {
const res = (-1).toLocaleString(locale, {
currency: "USD",
style: "currency"
});
const frags = [];
let mandatoryFrags = 0;
for (let i = 0; i < res.length; i++) {
const c = res[i];
if (c === "$") {
// force code to be surround by separators. we'll dedup later
frags.push("separator");
frags.push("code");
frags.push("separator");
mandatoryFrags++;
} else if (c === "-") {
frags.push("sign");
mandatoryFrags++;
} else if (c === "1") {
frags.push("value");
mandatoryFrags++;
} else if (/\s/.test(c)) {
frags.push("separator");
}
if (mandatoryFrags === 3) return frags;
}
return frags;
});
export function formatCurrencyUnitFragment(

@@ -23,3 +55,3 @@ unit: Unit,

): FormatFragment[] {
const { showCode, alwaysShowSign, showAllDigits } = {
const { showCode, alwaysShowSign, showAllDigits, locale } = {
...defaultFormatOptions,

@@ -31,2 +63,3 @@ ...unit,

const floatValue = value / 10 ** magnitude;
const floatValueAbs = Math.abs(floatValue);
const minimumFractionDigits = showAllDigits ? magnitude : 0;

@@ -38,21 +71,31 @@ const maximumFractionDigits = Math.max(

// dynamic max number of digits based on the value itself. to only show significant part
Math.min(4 - Math.round(Math.log10(Math.abs(floatValue))), magnitude)
Math.min(4 - Math.round(Math.log10(floatValueAbs)), magnitude)
)
);
const frags = [];
if (alwaysShowSign && floatValue > 0) {
frags.push({ kind: "sign", value: "+" });
}
if (showCode) {
frags.push({ kind: "code", value: code });
}
// TODO in case of negative value, we don't have it fragmented in a "sign"
frags.push({
kind: "value",
value: floatValue.toLocaleString("en-EN", {
const fragValueByKind = {
sign:
alwaysShowSign || floatValue < 0 ? (floatValue < 0 ? "-" : "+") : null,
code: showCode ? code : null,
value: floatValueAbs.toLocaleString(locale, {
maximumFractionDigits,
minimumFractionDigits
})
}),
separator: nonBreakableSpace
};
const frags = [];
let nonSepIndex = -1,
sepConsumed = true;
getFragPositions(locale).forEach(kind => {
const value = fragValueByKind[kind];
if (!value) return;
const isSep = kind === "separator";
if (sepConsumed && isSep) return;
sepConsumed = isSep;
if (!isSep) nonSepIndex = frags.length;
// $FlowFixMe
frags.push({ kind, value });
});
frags.splice(nonSepIndex + 1); // remove extra space at the end
return frags;

@@ -69,3 +112,3 @@ }

.map(f => f.value)
.join(nonBreakableSpace);
.join("");
}

@@ -19,2 +19,4 @@ //@flow

import { formatShort } from "./formatShort";
import countervalueForRate from "./countervalueForRate";

@@ -28,2 +30,3 @@

formatCurrencyUnitFragment,
formatShort,
getCurrencyByCoinType,

@@ -30,0 +33,0 @@ getDefaultUnitByCoinType,

@@ -9,3 +9,3 @@ //@flow

export type Unit = {
export type Unit = {|
// display name of a given unit (exemple: satoshi)

@@ -21,7 +21,19 @@ name: string,

showAllDigits?: boolean
};
|};
export type UnitValue = { value: number, unit: Unit };
export type UnitValue = {| value: number, unit: Unit |};
export type Currency = {
export type BitcoinJS = {|
bech32?: string,
bip32: {
private: number,
public: number
},
messagePrefix: string,
pubKeyHash: number | Uint8Array,
scriptHash: number | Uint8Array,
wif: number
|};
export type Currency = {|
// coinType is an identifier specified by https://github.com/satoshilabs/slips/blob/master/slip-0044.md

@@ -37,6 +49,19 @@ coinType: number,

// IMPORTANT: by convention, [0] is the default and have "highest" magnitude
units: Unit[]
// NB more field will come as we need them. basically see https://github.com/LedgerHQ/ledger-wallet-chrome/blob/487a8c86726f92dd49eb284fe12c49f4d3410d69/app/src/bitcoin/networks.coffee
};
units: Unit[],
// TODO: document apiName
apiName?: string,
// TODO: document xpub
xpub?: number,
// TODO: document isSegwitSupported
isSegwitSupported?: boolean,
// TODO: document handleFeePerByte
handleFeePerByte?: boolean,
// TODO: document areTransactionTimestamped
areTransactionTimestamped?: boolean,
// TODO: document sigHashType
sigHashType?: number,
// TODO: document bitcoinjs
bitcoinjs?: BitcoinJS
|};
export type CurrencyEntity = Currency;

@@ -12,2 +12,3 @@ //@flow

formatCurrencyUnit,
formatShort,
decodeURIScheme,

@@ -117,2 +118,22 @@ encodeURIScheme

test("formatter can change locale", () => {
expect(
formatCurrencyUnit(getFiatUnit("USD"), -1234567, { showCode: true })
).toBe("- USD 12,345.67");
// FIXME we can't test this unless we configure node.js properly to have the locales. we'll come back to this later...
/*
expect(
formatCurrencyUnit(getFiatUnit("EUR"), -1234567, {
showCode: true,
locale: "fr-FR"
})
).toBe("-12 345.67 EUR");
*/
});
test("formatShort", () => {
expect(formatShort(getFiatUnit("EUR"), 123456789)).toBe("1.2m");
expect(formatShort(getFiatUnit("EUR"), 123456)).toBe("1.2k");
});
test("encodeURIScheme", () => {

@@ -119,0 +140,0 @@ expect(

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

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

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