@ledgerhq/live-common 22.2.1-nightly.0 → 22.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -12
- package/lib/bridge/mockHelpers.d.ts.map +1 -1
- package/lib/bridge/mockHelpers.js +0 -2
- package/lib/bridge/mockHelpers.js.map +1 -1
- package/lib/bridge/useBridgeTransaction.d.ts +0 -3
- package/lib/bridge/useBridgeTransaction.d.ts.map +1 -1
- package/lib/bridge/useBridgeTransaction.js +1 -18
- package/lib/bridge/useBridgeTransaction.js.map +1 -1
- package/lib/data/icons/react/index.d.ts +0 -3
- package/lib/data/icons/react/index.d.ts.map +1 -1
- package/lib/data/icons/react/index.js +10 -16
- package/lib/data/icons/react/index.js.map +1 -1
- package/lib/data/icons/reactNative/index.d.ts +0 -3
- package/lib/data/icons/reactNative/index.d.ts.map +1 -1
- package/lib/data/icons/reactNative/index.js +10 -16
- package/lib/data/icons/reactNative/index.js.map +1 -1
- package/lib/exchange/swap/getExchangeRates.d.ts.map +1 -1
- package/lib/exchange/swap/getExchangeRates.js +14 -15
- package/lib/exchange/swap/getExchangeRates.js.map +1 -1
- package/lib/families/bitcoin/bridge/js.d.ts.map +1 -1
- package/lib/families/bitcoin/bridge/js.js +0 -2
- package/lib/families/bitcoin/bridge/js.js.map +1 -1
- package/lib/families/cosmos/specs.d.ts.map +1 -1
- package/lib/families/cosmos/specs.js +1 -0
- package/lib/families/cosmos/specs.js.map +1 -1
- package/lib/families/ethereum/specs.js +2 -2
- package/lib/families/ethereum/specs.js.map +1 -1
- package/lib/families/polkadot/bridge/js.d.ts.map +1 -1
- package/lib/families/polkadot/bridge/js.js +1 -5
- package/lib/families/polkadot/bridge/js.js.map +1 -1
- package/lib/families/polkadot/js-buildTransaction.d.ts.map +1 -1
- package/lib/families/polkadot/js-buildTransaction.js +8 -12
- package/lib/families/polkadot/js-buildTransaction.js.map +1 -1
- package/lib/families/polkadot/js-estimateMaxSpendable.d.ts.map +1 -1
- package/lib/families/polkadot/js-estimateMaxSpendable.js +2 -5
- package/lib/families/polkadot/js-estimateMaxSpendable.js.map +1 -1
- package/lib/families/polkadot/js-getTransactionStatus.d.ts.map +1 -1
- package/lib/families/polkadot/js-getTransactionStatus.js +55 -58
- package/lib/families/polkadot/js-getTransactionStatus.js.map +1 -1
- package/lib/families/polkadot/js-prepareTransaction.d.ts.map +1 -1
- package/lib/families/polkadot/js-prepareTransaction.js +2 -5
- package/lib/families/polkadot/js-prepareTransaction.js.map +1 -1
- package/lib/families/polkadot/js-synchronisation.d.ts.map +1 -1
- package/lib/families/polkadot/js-synchronisation.js +3 -6
- package/lib/families/polkadot/js-synchronisation.js.map +1 -1
- package/lib/families/polkadot/preload.d.ts.map +1 -1
- package/lib/families/polkadot/preload.js +12 -16
- package/lib/families/polkadot/preload.js.map +1 -1
- package/lib/hw/actions/startExchange.d.ts.map +1 -1
- package/lib/hw/actions/startExchange.js +3 -2
- package/lib/hw/actions/startExchange.js.map +1 -1
- package/lib/market/api/api.d.ts +1 -1
- package/lib/market/api/api.d.ts.map +1 -1
- package/lib/market/api/api.js +24 -43
- package/lib/market/api/api.js.map +1 -1
- package/lib/market/types.d.ts +0 -1
- package/lib/market/types.d.ts.map +1 -1
- package/lib/reactNative.d.ts +0 -1
- package/lib/reactNative.d.ts.map +1 -1
- package/lib/reactNative.js +0 -3
- package/lib/reactNative.js.map +1 -1
- package/package.json +19 -19
- package/src/bridge/mockHelpers.ts +2 -5
- package/src/bridge/useBridgeTransaction.ts +1 -22
- package/src/currencies/__snapshots__/sortByMarketcap.test.ts.snap +45 -1
- package/src/data/icons/react/index.tsx +0 -3
- package/src/data/icons/reactNative/index.tsx +0 -3
- package/src/exchange/swap/getExchangeRates.ts +22 -30
- package/src/families/bitcoin/bridge/js.ts +0 -2
- package/src/families/cosmos/specs.ts +1 -0
- package/src/families/ethereum/specs.ts +2 -2
- package/src/families/polkadot/bridge/js.ts +0 -2
- package/src/families/polkadot/js-buildTransaction.ts +0 -3
- package/src/families/polkadot/js-estimateMaxSpendable.ts +0 -2
- package/src/families/polkadot/js-getTransactionStatus.ts +0 -3
- package/src/families/polkadot/js-prepareTransaction.ts +0 -2
- package/src/families/polkadot/js-synchronisation.ts +0 -2
- package/src/families/polkadot/preload.ts +0 -2
- package/src/hw/actions/startExchange.ts +3 -2
- package/src/market/api/api.ts +17 -39
- package/src/market/types.ts +0 -1
- package/src/reactNative.ts +0 -5
- package/lib/bridge/useBridgeTransaction.test.d.ts +0 -2
- package/lib/bridge/useBridgeTransaction.test.d.ts.map +0 -1
- package/lib/bridge/useBridgeTransaction.test.js +0 -145
- package/lib/bridge/useBridgeTransaction.test.js.map +0 -1
- package/lib/data/icons/react/abi.d.ts +0 -8
- package/lib/data/icons/react/abi.d.ts.map +0 -1
- package/lib/data/icons/react/abi.js +0 -35
- package/lib/data/icons/react/abi.js.map +0 -1
- package/lib/data/icons/react/gAbi.d.ts +0 -8
- package/lib/data/icons/react/gAbi.d.ts.map +0 -1
- package/lib/data/icons/react/gAbi.js +0 -36
- package/lib/data/icons/react/gAbi.js.map +0 -1
- package/lib/data/icons/react/sAbi.d.ts +0 -8
- package/lib/data/icons/react/sAbi.d.ts.map +0 -1
- package/lib/data/icons/react/sAbi.js +0 -35
- package/lib/data/icons/react/sAbi.js.map +0 -1
- package/lib/data/icons/reactNative/abi.d.ts +0 -8
- package/lib/data/icons/reactNative/abi.d.ts.map +0 -1
- package/lib/data/icons/reactNative/abi.js +0 -36
- package/lib/data/icons/reactNative/abi.js.map +0 -1
- package/lib/data/icons/reactNative/gAbi.d.ts +0 -8
- package/lib/data/icons/reactNative/gAbi.d.ts.map +0 -1
- package/lib/data/icons/reactNative/gAbi.js +0 -37
- package/lib/data/icons/reactNative/gAbi.js.map +0 -1
- package/lib/data/icons/reactNative/sAbi.d.ts +0 -8
- package/lib/data/icons/reactNative/sAbi.d.ts.map +0 -1
- package/lib/data/icons/reactNative/sAbi.js +0 -36
- package/lib/data/icons/reactNative/sAbi.js.map +0 -1
- package/lib/exchange/swap/getExchangeRates.test.d.ts +0 -2
- package/lib/exchange/swap/getExchangeRates.test.d.ts.map +0 -1
- package/lib/exchange/swap/getExchangeRates.test.js +0 -200
- package/lib/exchange/swap/getExchangeRates.test.js.map +0 -1
- package/lib/families/polkadot/polkadot-crypto.d.ts +0 -2
- package/lib/families/polkadot/polkadot-crypto.d.ts.map +0 -1
- package/lib/families/polkadot/polkadot-crypto.js +0 -14
- package/lib/families/polkadot/polkadot-crypto.js.map +0 -1
- package/src/bridge/useBridgeTransaction.test.ts +0 -70
- package/src/data/icons/react/abi.tsx +0 -14
- package/src/data/icons/react/gAbi.tsx +0 -14
- package/src/data/icons/react/sAbi.tsx +0 -14
- package/src/data/icons/reactNative/abi.tsx +0 -15
- package/src/data/icons/reactNative/gAbi.tsx +0 -15
- package/src/data/icons/reactNative/sAbi.tsx +0 -15
- package/src/data/icons/svg/ABI.svg +0 -3
- package/src/data/icons/svg/gABI.svg +0 -4
- package/src/data/icons/svg/sABI.svg +0 -3
- package/src/exchange/swap/getExchangeRates.test.ts +0 -151
- package/src/families/polkadot/polkadot-crypto.ts +0 -10
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets";
|
|
2
|
-
import axios from "axios";
|
|
3
|
-
import BigNumber from "bignumber.js";
|
|
4
|
-
import { mocked } from "ts-jest/utils";
|
|
5
|
-
import { Account, Transaction } from "../../types";
|
|
6
|
-
import getExchangeRates from "./getExchangeRates";
|
|
7
|
-
import { Exchange, ExchangeRate } from "./types";
|
|
8
|
-
|
|
9
|
-
jest.mock("axios");
|
|
10
|
-
const mockedAxios = mocked(axios);
|
|
11
|
-
|
|
12
|
-
const bitcoinCurrency = getCryptoCurrencyById("bitcoin");
|
|
13
|
-
const ethereumCurrency = getCryptoCurrencyById("ethereum");
|
|
14
|
-
|
|
15
|
-
const fromAccount: Account = {
|
|
16
|
-
type: "Account",
|
|
17
|
-
id: "TEST_ID",
|
|
18
|
-
seedIdentifier: "SEED_IDENTIFIER",
|
|
19
|
-
derivationMode: "",
|
|
20
|
-
index: 0,
|
|
21
|
-
freshAddress: "freshAddress",
|
|
22
|
-
freshAddressPath: "freshAddressPath",
|
|
23
|
-
freshAddresses: [],
|
|
24
|
-
name: "TEST_ACCOUNT",
|
|
25
|
-
starred: false,
|
|
26
|
-
used: false,
|
|
27
|
-
balance: new BigNumber(1000000),
|
|
28
|
-
spendableBalance: new BigNumber(1000000),
|
|
29
|
-
creationDate: new Date(),
|
|
30
|
-
blockHeight: 0,
|
|
31
|
-
currency: bitcoinCurrency,
|
|
32
|
-
unit: bitcoinCurrency.units[0],
|
|
33
|
-
operationsCount: 0,
|
|
34
|
-
operations: [],
|
|
35
|
-
pendingOperations: [],
|
|
36
|
-
lastSyncDate: new Date(),
|
|
37
|
-
balanceHistoryCache: {
|
|
38
|
-
HOUR: { latestDate: null, balances: [] },
|
|
39
|
-
DAY: { latestDate: null, balances: [] },
|
|
40
|
-
WEEK: { latestDate: null, balances: [] },
|
|
41
|
-
},
|
|
42
|
-
swapHistory: [],
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const toAccount = {
|
|
46
|
-
...fromAccount,
|
|
47
|
-
currency: ethereumCurrency,
|
|
48
|
-
unit: ethereumCurrency.units[0],
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const exchange: Exchange = {
|
|
52
|
-
fromAccount,
|
|
53
|
-
toAccount,
|
|
54
|
-
fromParentAccount: undefined,
|
|
55
|
-
toParentAccount: undefined,
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const transaction: Transaction = {
|
|
59
|
-
amount: new BigNumber(10000),
|
|
60
|
-
recipient: "recipient",
|
|
61
|
-
family: "bitcoin",
|
|
62
|
-
utxoStrategy: {
|
|
63
|
-
strategy: 0,
|
|
64
|
-
pickUnconfirmedRBF: false,
|
|
65
|
-
excludeUTXOs: [],
|
|
66
|
-
},
|
|
67
|
-
rbf: true,
|
|
68
|
-
feePerByte: undefined,
|
|
69
|
-
networkInfo: undefined,
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
describe("swap/getExchangeRates", () => {
|
|
73
|
-
test("rate should be valid for 'fixed' trade method", async () => {
|
|
74
|
-
const tradeMethod: "fixed" | "float" = "fixed";
|
|
75
|
-
|
|
76
|
-
const data = [
|
|
77
|
-
{
|
|
78
|
-
provider: "changelly",
|
|
79
|
-
rateId: "RATE_ID",
|
|
80
|
-
from: "bitcoin",
|
|
81
|
-
to: "ethereum",
|
|
82
|
-
amountFrom: "0.005",
|
|
83
|
-
amountTo: "0.07",
|
|
84
|
-
rate: "14",
|
|
85
|
-
tradeMethod,
|
|
86
|
-
status: "success",
|
|
87
|
-
},
|
|
88
|
-
];
|
|
89
|
-
const resp = {
|
|
90
|
-
data,
|
|
91
|
-
status: 200,
|
|
92
|
-
statusText: "",
|
|
93
|
-
headers: {},
|
|
94
|
-
config: {},
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
mockedAxios.mockResolvedValue(Promise.resolve(resp));
|
|
98
|
-
const res = await getExchangeRates(exchange, transaction);
|
|
99
|
-
|
|
100
|
-
const expectedExchangeRate: ExchangeRate = {
|
|
101
|
-
magnitudeAwareRate: new BigNumber("140000000000"),
|
|
102
|
-
provider: data[0].provider,
|
|
103
|
-
rate: new BigNumber(data[0].rate),
|
|
104
|
-
rateId: data[0].rateId,
|
|
105
|
-
toAmount: new BigNumber("70000000000000000"),
|
|
106
|
-
tradeMethod: data[0].tradeMethod,
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
expect(res).toEqual([expectedExchangeRate]);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
test("rate should be valid for 'float' trade method", async () => {
|
|
113
|
-
const tradeMethod: "fixed" | "float" = "float";
|
|
114
|
-
|
|
115
|
-
const data = [
|
|
116
|
-
{
|
|
117
|
-
provider: "changelly",
|
|
118
|
-
from: "bitcoin",
|
|
119
|
-
to: "ethereum",
|
|
120
|
-
amountFrom: "0.005",
|
|
121
|
-
amountTo: "0.07",
|
|
122
|
-
minAmountFrom: "0.0015",
|
|
123
|
-
maxAmountFrom: "1445",
|
|
124
|
-
payoutNetworkFees: "0.0030432000000000000000",
|
|
125
|
-
tradeMethod,
|
|
126
|
-
status: "success",
|
|
127
|
-
},
|
|
128
|
-
];
|
|
129
|
-
const resp = {
|
|
130
|
-
data,
|
|
131
|
-
status: 200,
|
|
132
|
-
statusText: "",
|
|
133
|
-
headers: {},
|
|
134
|
-
config: {},
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
mockedAxios.mockResolvedValue(Promise.resolve(resp));
|
|
138
|
-
const res = await getExchangeRates(exchange, transaction);
|
|
139
|
-
|
|
140
|
-
const expectedExchangeRate: ExchangeRate = {
|
|
141
|
-
magnitudeAwareRate: new BigNumber("133913600000"),
|
|
142
|
-
provider: data[0].provider,
|
|
143
|
-
rate: new BigNumber(13.39136),
|
|
144
|
-
toAmount: new BigNumber("66956800000000000"),
|
|
145
|
-
tradeMethod: data[0].tradeMethod,
|
|
146
|
-
payoutNetworkFees: new BigNumber("3043200000000000"),
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
expect(res).toEqual([expectedExchangeRate]);
|
|
150
|
-
});
|
|
151
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { cryptoWaitReady } from "@polkadot/util-crypto";
|
|
2
|
-
|
|
3
|
-
let loadingPromise: null | Promise<boolean>;
|
|
4
|
-
|
|
5
|
-
export function loadPolkadotCrypto(): Promise<boolean> {
|
|
6
|
-
if (loadingPromise) return loadingPromise;
|
|
7
|
-
const p = cryptoWaitReady();
|
|
8
|
-
loadingPromise = p;
|
|
9
|
-
return p;
|
|
10
|
-
}
|