@ledgerhq/live-common 26.1.0-next.1 → 27.0.0
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/lib/account/importAccounts.d.ts +35 -2
- package/lib/account/importAccounts.d.ts.map +1 -1
- package/lib/account/importAccounts.integration.test.d.ts +2 -0
- package/lib/account/importAccounts.integration.test.d.ts.map +1 -0
- package/lib/account/importAccounts.integration.test.js +219 -0
- package/lib/account/importAccounts.integration.test.js.map +1 -0
- package/lib/account/importAccounts.js +130 -12
- package/lib/account/importAccounts.js.map +1 -1
- package/lib/account/importAccounts.test.d.ts +2 -0
- package/lib/account/importAccounts.test.d.ts.map +1 -0
- package/lib/{__tests__/accounts/importAccounts.js → account/importAccounts.test.js} +44 -64
- package/lib/account/importAccounts.test.js.map +1 -0
- package/package.json +17 -17
- package/src/account/importAccounts.integration.test.ts +193 -0
- package/src/{__tests__/accounts/importAccounts.ts → account/importAccounts.test.ts} +39 -59
- package/src/account/importAccounts.ts +103 -12
- package/lib/__tests__/accounts/importAccounts.d.ts +0 -2
- package/lib/__tests__/accounts/importAccounts.d.ts.map +0 -1
- package/lib/__tests__/accounts/importAccounts.js.map +0 -1
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
exports.__esModule = true;
|
|
3
|
-
var
|
|
4
|
-
var currencies_1 = require("
|
|
5
|
-
var version_1 = require("
|
|
3
|
+
var _1 = require(".");
|
|
4
|
+
var currencies_1 = require("../currencies");
|
|
5
|
+
var version_1 = require("../platform/version");
|
|
6
6
|
(0, version_1.setPlatformVersion)("1.1.0");
|
|
7
7
|
(0, currencies_1.setSupportedCurrencies)(["ethereum"]);
|
|
8
8
|
describe("importAccountsMakeItems", function () {
|
|
9
|
-
|
|
10
|
-
test.skip("should migrate ethereum accounts", function () {
|
|
9
|
+
test("importing ethereum accounts", function () {
|
|
11
10
|
var result = {
|
|
12
11
|
meta: {
|
|
13
12
|
exporterName: "desktop",
|
|
@@ -15,7 +14,7 @@ describe("importAccountsMakeItems", function () {
|
|
|
15
14
|
},
|
|
16
15
|
accounts: [
|
|
17
16
|
{
|
|
18
|
-
id: "
|
|
17
|
+
id: "js:1:ethereum:0x01:",
|
|
19
18
|
name: "Ethereum 1",
|
|
20
19
|
seedIdentifier: "seed",
|
|
21
20
|
derivationMode: "",
|
|
@@ -26,7 +25,7 @@ describe("importAccountsMakeItems", function () {
|
|
|
26
25
|
swapHistory: []
|
|
27
26
|
},
|
|
28
27
|
{
|
|
29
|
-
id: "
|
|
28
|
+
id: "js:1:ethereum:0x02:",
|
|
30
29
|
name: "Ethereum 2",
|
|
31
30
|
seedIdentifier: "seed",
|
|
32
31
|
derivationMode: "",
|
|
@@ -37,7 +36,7 @@ describe("importAccountsMakeItems", function () {
|
|
|
37
36
|
swapHistory: []
|
|
38
37
|
},
|
|
39
38
|
{
|
|
40
|
-
id: "
|
|
39
|
+
id: "js:1:ethereum:0x04:",
|
|
41
40
|
name: "Ethereum 4",
|
|
42
41
|
seedIdentifier: "seed",
|
|
43
42
|
derivationMode: "",
|
|
@@ -48,7 +47,7 @@ describe("importAccountsMakeItems", function () {
|
|
|
48
47
|
swapHistory: []
|
|
49
48
|
},
|
|
50
49
|
{
|
|
51
|
-
id: "
|
|
50
|
+
id: "js:1:ethereum:0x03:",
|
|
52
51
|
name: "ETH3 name edited",
|
|
53
52
|
seedIdentifier: "seed",
|
|
54
53
|
derivationMode: "",
|
|
@@ -59,7 +58,7 @@ describe("importAccountsMakeItems", function () {
|
|
|
59
58
|
swapHistory: []
|
|
60
59
|
},
|
|
61
60
|
{
|
|
62
|
-
id: "
|
|
61
|
+
id: "js:1:ethereum:0x05:",
|
|
63
62
|
name: "Ethereum 5",
|
|
64
63
|
seedIdentifier: "seed",
|
|
65
64
|
derivationMode: "",
|
|
@@ -79,7 +78,7 @@ describe("importAccountsMakeItems", function () {
|
|
|
79
78
|
};
|
|
80
79
|
var accounts = [
|
|
81
80
|
{
|
|
82
|
-
id: "
|
|
81
|
+
id: "js:1:ethereum:0x01:",
|
|
83
82
|
seedIdentifier: "0x01",
|
|
84
83
|
name: "Ethereum 1",
|
|
85
84
|
derivationMode: "",
|
|
@@ -96,7 +95,7 @@ describe("importAccountsMakeItems", function () {
|
|
|
96
95
|
balance: "51281813126095910"
|
|
97
96
|
},
|
|
98
97
|
{
|
|
99
|
-
id: "
|
|
98
|
+
id: "js:1:ethereum:0x02:",
|
|
100
99
|
seedIdentifier: "0x02",
|
|
101
100
|
name: "Ethereum 2",
|
|
102
101
|
derivationMode: "",
|
|
@@ -113,7 +112,7 @@ describe("importAccountsMakeItems", function () {
|
|
|
113
112
|
balance: "1081392000000000"
|
|
114
113
|
},
|
|
115
114
|
{
|
|
116
|
-
id: "
|
|
115
|
+
id: "js:1:ethereum:0x03:",
|
|
117
116
|
seedIdentifier: "seed",
|
|
118
117
|
name: "Ethereum 3",
|
|
119
118
|
derivationMode: "",
|
|
@@ -129,79 +128,60 @@ describe("importAccountsMakeItems", function () {
|
|
|
129
128
|
lastSyncDate: "2019-07-17T15:13:29.306Z",
|
|
130
129
|
balance: "1081392000000000"
|
|
131
130
|
},
|
|
132
|
-
].map(
|
|
133
|
-
var items = (0,
|
|
131
|
+
].map(_1.fromAccountRaw);
|
|
132
|
+
var items = (0, _1.importAccountsMakeItems)({
|
|
134
133
|
result: result,
|
|
135
134
|
accounts: accounts
|
|
136
135
|
});
|
|
137
136
|
expect(items).toMatchObject([
|
|
138
137
|
{
|
|
139
|
-
initialAccountId: "
|
|
140
|
-
account: {
|
|
141
|
-
id: "libcore:1:ethereum:xpub4:",
|
|
142
|
-
name: "Ethereum 4"
|
|
143
|
-
},
|
|
138
|
+
initialAccountId: "js:1:ethereum:0x04:",
|
|
139
|
+
account: { id: "js:1:ethereum:0x04:", name: "Ethereum 4" },
|
|
144
140
|
mode: "create"
|
|
145
141
|
},
|
|
146
142
|
{
|
|
147
|
-
initialAccountId: "
|
|
148
|
-
account: {
|
|
149
|
-
id: "libcore:1:ethereum:xpub5:",
|
|
150
|
-
name: "Ethereum 5"
|
|
151
|
-
},
|
|
143
|
+
initialAccountId: "js:1:ethereum:0x05:",
|
|
144
|
+
account: { id: "js:1:ethereum:0x05:", name: "Ethereum 5" },
|
|
152
145
|
mode: "create"
|
|
153
146
|
},
|
|
154
147
|
{
|
|
155
|
-
initialAccountId: "
|
|
156
|
-
account: {
|
|
157
|
-
id: "libcore:1:ethereum:xpub1:",
|
|
158
|
-
name: "Ethereum 1"
|
|
159
|
-
},
|
|
148
|
+
initialAccountId: "js:1:ethereum:0x03:",
|
|
149
|
+
account: { id: "js:1:ethereum:0x03:", name: "ETH3 name edited" },
|
|
160
150
|
mode: "update"
|
|
161
151
|
},
|
|
162
152
|
{
|
|
163
|
-
initialAccountId: "
|
|
164
|
-
account: {
|
|
165
|
-
|
|
166
|
-
name: "Ethereum 2"
|
|
167
|
-
},
|
|
168
|
-
mode: "update"
|
|
153
|
+
initialAccountId: "js:1:ethereum:0x01:",
|
|
154
|
+
account: { id: "js:1:ethereum:0x01:", name: "Ethereum 1" },
|
|
155
|
+
mode: "id"
|
|
169
156
|
},
|
|
170
157
|
{
|
|
171
|
-
initialAccountId: "
|
|
172
|
-
account: {
|
|
173
|
-
|
|
174
|
-
name: "ETH3 name edited"
|
|
175
|
-
},
|
|
176
|
-
mode: "update"
|
|
158
|
+
initialAccountId: "js:1:ethereum:0x02:",
|
|
159
|
+
account: { id: "js:1:ethereum:0x02:", name: "Ethereum 2" },
|
|
160
|
+
mode: "id"
|
|
177
161
|
},
|
|
178
162
|
]);
|
|
179
|
-
var
|
|
163
|
+
var syncResult = {
|
|
164
|
+
failed: {},
|
|
165
|
+
synchronized: {}
|
|
166
|
+
};
|
|
167
|
+
result.accounts.forEach(function (a) {
|
|
168
|
+
syncResult.synchronized[a.id] = a;
|
|
169
|
+
});
|
|
170
|
+
var reduced = (0, _1.importAccountsReduce)(accounts, {
|
|
180
171
|
items: items,
|
|
181
172
|
selectedAccounts: [
|
|
182
|
-
"
|
|
183
|
-
"
|
|
184
|
-
"
|
|
185
|
-
]
|
|
173
|
+
"js:1:ethereum:0x03:",
|
|
174
|
+
"js:1:ethereum:0x02:",
|
|
175
|
+
"js:1:ethereum:0x05:",
|
|
176
|
+
],
|
|
177
|
+
syncResult: syncResult
|
|
186
178
|
});
|
|
187
179
|
expect(reduced).toMatchObject([
|
|
188
|
-
{
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
},
|
|
192
|
-
{
|
|
193
|
-
id: "libcore:1:ethereum:xpub2:",
|
|
194
|
-
name: "Ethereum 2"
|
|
195
|
-
},
|
|
196
|
-
{
|
|
197
|
-
id: "libcore:1:ethereum:xpub3:",
|
|
198
|
-
name: "ETH3 name edited"
|
|
199
|
-
},
|
|
200
|
-
{
|
|
201
|
-
id: "libcore:1:ethereum:xpub5:",
|
|
202
|
-
name: "Ethereum 5"
|
|
203
|
-
},
|
|
180
|
+
{ id: "js:1:ethereum:0x01:", name: "Ethereum 1" },
|
|
181
|
+
{ id: "js:1:ethereum:0x02:", name: "Ethereum 2" },
|
|
182
|
+
{ id: "js:1:ethereum:0x03:", name: "ETH3 name edited" },
|
|
183
|
+
{ id: "js:1:ethereum:0x05:", name: "Ethereum 5" },
|
|
204
184
|
]);
|
|
205
185
|
});
|
|
206
186
|
});
|
|
207
|
-
//# sourceMappingURL=importAccounts.js.map
|
|
187
|
+
//# sourceMappingURL=importAccounts.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"importAccounts.test.js","sourceRoot":"","sources":["../../src/account/importAccounts.test.ts"],"names":[],"mappings":";;AACA,sBAIW;AACX,4CAAuD;AACvD,+CAAyD;AAEzD,IAAA,4BAAkB,EAAC,OAAO,CAAC,CAAC;AAE5B,IAAA,mCAAsB,EAAC,CAAC,UAAU,CAAC,CAAC,CAAC;AACrC,QAAQ,CAAC,yBAAyB,EAAE;IAClC,IAAI,CAAC,6BAA6B,EAAE;QAClC,IAAM,MA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MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAC,CAAC;YACxB,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;QACH,IAAM,OAAO,GAAG,IAAA,uBAAoB,EAAC,QAAQ,EAAE;YAC7C,KAAK,OAAA;YACL,gBAAgB,EAAE;gBAChB,qBAAqB;gBACrB,qBAAqB;gBACrB,qBAAqB;aACtB;YACD,UAAU,YAAA;SACX,CAAC,CAAC;QACH,MAAM,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC;YAC5B,EAAE,EAAE,EAAE,qBAAqB,EAAE,IAAI,EAAE,YAAY,EAAE;YACjD,EAAE,EAAE,EAAE,qBAAqB,EAAE,IAAI,EAAE,YAAY,EAAE;YACjD,EAAE,EAAE,EAAE,qBAAqB,EAAE,IAAI,EAAE,kBAAkB,EAAE;YACvD,EAAE,EAAE,EAAE,qBAAqB,EAAE,IAAI,EAAE,YAAY,EAAE;SAClD,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
},
|
|
5
5
|
"name": "@ledgerhq/live-common",
|
|
6
6
|
"description": "Common ground for the Ledger Live apps",
|
|
7
|
-
"version": "
|
|
7
|
+
"version": "27.0.0",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "https://github.com/LedgerHQ/ledger-live.git"
|
|
@@ -111,22 +111,22 @@
|
|
|
111
111
|
"@hashgraph/sdk": "^2.10.1",
|
|
112
112
|
"@keplr-wallet/cosmos": "^0.9.16",
|
|
113
113
|
"@ledgerhq/compressjs": "github:LedgerHQ/compressjs#d9e8e4d994923e0ea76a32b97289bcccfe71b82e",
|
|
114
|
-
"@ledgerhq/cryptoassets": "^6.
|
|
114
|
+
"@ledgerhq/cryptoassets": "^6.33.0",
|
|
115
115
|
"@ledgerhq/devices": "^7.0.0",
|
|
116
116
|
"@ledgerhq/errors": "^6.10.1",
|
|
117
|
-
"@ledgerhq/hw-app-algorand": "^6.27.3
|
|
118
|
-
"@ledgerhq/hw-app-btc": "^8.0.1
|
|
119
|
-
"@ledgerhq/hw-app-cosmos": "^6.27.3
|
|
120
|
-
"@ledgerhq/hw-app-eth": "^6.29.5
|
|
121
|
-
"@ledgerhq/hw-app-polkadot": "^6.27.3
|
|
122
|
-
"@ledgerhq/hw-app-solana": "^6.27.3
|
|
123
|
-
"@ledgerhq/hw-app-str": "^6.27.3
|
|
124
|
-
"@ledgerhq/hw-app-tezos": "^6.27.3
|
|
125
|
-
"@ledgerhq/hw-app-trx": "^6.27.3
|
|
126
|
-
"@ledgerhq/hw-app-xrp": "^6.27.3
|
|
127
|
-
"@ledgerhq/hw-transport": "^6.27.3
|
|
128
|
-
"@ledgerhq/hw-transport-mocker": "^6.27.3
|
|
129
|
-
"@ledgerhq/hw-transport-node-speculos": "^6.27.3
|
|
117
|
+
"@ledgerhq/hw-app-algorand": "^6.27.3",
|
|
118
|
+
"@ledgerhq/hw-app-btc": "^8.0.1",
|
|
119
|
+
"@ledgerhq/hw-app-cosmos": "^6.27.3",
|
|
120
|
+
"@ledgerhq/hw-app-eth": "^6.29.5",
|
|
121
|
+
"@ledgerhq/hw-app-polkadot": "^6.27.3",
|
|
122
|
+
"@ledgerhq/hw-app-solana": "^6.27.3",
|
|
123
|
+
"@ledgerhq/hw-app-str": "^6.27.3",
|
|
124
|
+
"@ledgerhq/hw-app-tezos": "^6.27.3",
|
|
125
|
+
"@ledgerhq/hw-app-trx": "^6.27.3",
|
|
126
|
+
"@ledgerhq/hw-app-xrp": "^6.27.3",
|
|
127
|
+
"@ledgerhq/hw-transport": "^6.27.3",
|
|
128
|
+
"@ledgerhq/hw-transport-mocker": "^6.27.3",
|
|
129
|
+
"@ledgerhq/hw-transport-node-speculos": "^6.27.3",
|
|
130
130
|
"@ledgerhq/json-bignumber": "^1.1.0",
|
|
131
131
|
"@ledgerhq/live-app-sdk": "^0.7.0",
|
|
132
132
|
"@ledgerhq/logs": "^6.10.0",
|
|
@@ -218,8 +218,8 @@
|
|
|
218
218
|
"devDependencies": {
|
|
219
219
|
"@keplr-wallet/proto-types": "^0.10.4",
|
|
220
220
|
"@ledgerhq/types-cryptoassets": "^6.23.0",
|
|
221
|
-
"@ledgerhq/types-devices": "^6.22.1
|
|
222
|
-
"@ledgerhq/types-live": "^6.24.0
|
|
221
|
+
"@ledgerhq/types-devices": "^6.22.1",
|
|
222
|
+
"@ledgerhq/types-live": "^6.24.0",
|
|
223
223
|
"@svgr/core": "^5.5.0",
|
|
224
224
|
"@testing-library/react": "12",
|
|
225
225
|
"@testing-library/react-hooks": "^4.0.1",
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import "../__tests__/test-helpers/setup";
|
|
2
|
+
import { makeBridgeCacheSystem } from "../bridge/cache";
|
|
3
|
+
import { accountToAccountData } from "../cross";
|
|
4
|
+
import {
|
|
5
|
+
importAccountsMakeItems,
|
|
6
|
+
importAccountsReduce,
|
|
7
|
+
fromAccountRaw,
|
|
8
|
+
syncNewAccountsToImport,
|
|
9
|
+
} from ".";
|
|
10
|
+
import { Account } from "@ledgerhq/types-live";
|
|
11
|
+
|
|
12
|
+
jest.setTimeout(200000);
|
|
13
|
+
|
|
14
|
+
test("importAccounts with a set of real data", async () => {
|
|
15
|
+
const accounts = [
|
|
16
|
+
{
|
|
17
|
+
id: "js:2:algorand:32PI2C5HLHMVUF5KMNURLGCTYVIOVJJ2NLHLZ2PIMK567MKMS4RXBSVWQI:",
|
|
18
|
+
seedIdentifier:
|
|
19
|
+
"32PI2C5HLHMVUF5KMNURLGCTYVIOVJJ2NLHLZ2PIMK567MKMS4RXBSVWQI",
|
|
20
|
+
name: "Algorand legacy 32PI2C5H...RXBSVWQI",
|
|
21
|
+
starred: true,
|
|
22
|
+
used: true,
|
|
23
|
+
derivationMode: "",
|
|
24
|
+
index: 0,
|
|
25
|
+
freshAddress:
|
|
26
|
+
"32PI2C5HLHMVUF5KMNURLGCTYVIOVJJ2NLHLZ2PIMK567MKMS4RXBSVWQI",
|
|
27
|
+
freshAddressPath: "44'/283'/0'/0/0",
|
|
28
|
+
freshAddresses: [],
|
|
29
|
+
blockHeight: 23066613,
|
|
30
|
+
creationDate: "2022-02-04T13:12:58.000Z",
|
|
31
|
+
operationsCount: 184,
|
|
32
|
+
operations: [],
|
|
33
|
+
pendingOperations: [],
|
|
34
|
+
currencyId: "algorand",
|
|
35
|
+
unitMagnitude: 6,
|
|
36
|
+
lastSyncDate: "2022-08-26T09:24:27.076Z",
|
|
37
|
+
balance: "2100190",
|
|
38
|
+
spendableBalance: "190",
|
|
39
|
+
xpub: "32PI2C5HLHMVUF5KMNURLGCTYVIOVJJ2NLHLZ2PIMK567MKMS4RXBSVWQI",
|
|
40
|
+
subAccounts: [],
|
|
41
|
+
algorandResources: { rewards: "190", nbAssets: 20 },
|
|
42
|
+
swapHistory: [],
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: "js:2:tron:TRbtdwHowocq8ThZbRnTHgK4JG5sx3fFCK:",
|
|
46
|
+
seedIdentifier: "TRbtdwHowocq8ThZbRnTHgK4JG5sx3fFCK",
|
|
47
|
+
name: "Tron legacy TRbtdwHo...5sx3fFCK",
|
|
48
|
+
starred: true,
|
|
49
|
+
used: true,
|
|
50
|
+
derivationMode: "",
|
|
51
|
+
index: 0,
|
|
52
|
+
freshAddress: "TRbtdwHowocq8ThZbRnTHgK4JG5sx3fFCK",
|
|
53
|
+
freshAddressPath: "44'/195'/0'/0/0",
|
|
54
|
+
freshAddresses: [],
|
|
55
|
+
blockHeight: 43642499,
|
|
56
|
+
creationDate: "2022-07-19T15:32:12.000Z",
|
|
57
|
+
operationsCount: 41,
|
|
58
|
+
operations: [],
|
|
59
|
+
pendingOperations: [],
|
|
60
|
+
currencyId: "tron",
|
|
61
|
+
unitMagnitude: 6,
|
|
62
|
+
lastSyncDate: "2022-08-26T09:24:59.492Z",
|
|
63
|
+
balance: "0",
|
|
64
|
+
spendableBalance: "0",
|
|
65
|
+
xpub: "TRbtdwHowocq8ThZbRnTHgK4JG5sx3fFCK",
|
|
66
|
+
subAccounts: [],
|
|
67
|
+
tronResources: {
|
|
68
|
+
frozen: {},
|
|
69
|
+
delegatedFrozen: {},
|
|
70
|
+
votes: [],
|
|
71
|
+
tronPower: 0,
|
|
72
|
+
energy: "0",
|
|
73
|
+
bandwidth: {
|
|
74
|
+
freeUsed: "0",
|
|
75
|
+
freeLimit: "1500",
|
|
76
|
+
gainedUsed: "0",
|
|
77
|
+
gainedLimit: "0",
|
|
78
|
+
},
|
|
79
|
+
unwithdrawnReward: "2730",
|
|
80
|
+
lastVotedDate: "2022-07-22T14:39:51.000Z",
|
|
81
|
+
cacheTransactionInfoById: {},
|
|
82
|
+
},
|
|
83
|
+
swapHistory: [],
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
id: "js:2:polkadot:15jLBbe9LD6VSUYFkV5Fmo5LhZU5cns9E6g8qcDv5KrKM1eP:polkadotbip44",
|
|
87
|
+
seedIdentifier: "15jLBbe9LD6VSUYFkV5Fmo5LhZU5cns9E6g8qcDv5KrKM1eP",
|
|
88
|
+
name: "Polkadot polkadotbip44 15jLBbe9...5KrKM1eP",
|
|
89
|
+
starred: true,
|
|
90
|
+
used: true,
|
|
91
|
+
derivationMode: "polkadotbip44",
|
|
92
|
+
index: 0,
|
|
93
|
+
freshAddress: "15jLBbe9LD6VSUYFkV5Fmo5LhZU5cns9E6g8qcDv5KrKM1eP",
|
|
94
|
+
freshAddressPath: "44'/354'/0'/0'/0'",
|
|
95
|
+
freshAddresses: [],
|
|
96
|
+
blockHeight: 11771108,
|
|
97
|
+
creationDate: "2022-02-24T14:39:00.007Z",
|
|
98
|
+
operationsCount: 65,
|
|
99
|
+
operations: [],
|
|
100
|
+
pendingOperations: [],
|
|
101
|
+
currencyId: "polkadot",
|
|
102
|
+
unitMagnitude: 10,
|
|
103
|
+
lastSyncDate: "2022-08-26T09:25:00.713Z",
|
|
104
|
+
balance: "15512511464",
|
|
105
|
+
spendableBalance: "15512511464",
|
|
106
|
+
xpub: "15jLBbe9LD6VSUYFkV5Fmo5LhZU5cns9E6g8qcDv5KrKM1eP",
|
|
107
|
+
polkadotResources: {
|
|
108
|
+
controller: null,
|
|
109
|
+
stash: null,
|
|
110
|
+
nonce: 63,
|
|
111
|
+
lockedBalance: "0",
|
|
112
|
+
unlockedBalance: "0",
|
|
113
|
+
unlockingBalance: "0",
|
|
114
|
+
unlockings: [],
|
|
115
|
+
nominations: [],
|
|
116
|
+
},
|
|
117
|
+
swapHistory: [],
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
id: "js:2:bsc:0xa22CA840265d3C5CB1846e419B14c6a6CdD06FAB:",
|
|
121
|
+
seedIdentifier: "0xa22CA840265d3C5CB1846e419B14c6a6CdD06FAB",
|
|
122
|
+
name: "Binance Smart Chain legacy 0xa22CA8...CdD06FAB",
|
|
123
|
+
starred: true,
|
|
124
|
+
used: true,
|
|
125
|
+
derivationMode: "",
|
|
126
|
+
index: 0,
|
|
127
|
+
freshAddress: "0xa22CA840265d3C5CB1846e419B14c6a6CdD06FAB",
|
|
128
|
+
freshAddressPath: "44'/60'/0'/0/0",
|
|
129
|
+
freshAddresses: [],
|
|
130
|
+
blockHeight: 20775454,
|
|
131
|
+
syncHash: "[]_655",
|
|
132
|
+
creationDate: "2022-02-04T13:11:32.001Z",
|
|
133
|
+
operationsCount: 21,
|
|
134
|
+
operations: [],
|
|
135
|
+
pendingOperations: [],
|
|
136
|
+
currencyId: "bsc",
|
|
137
|
+
unitMagnitude: 18,
|
|
138
|
+
lastSyncDate: "2022-08-26T09:25:01.109Z",
|
|
139
|
+
balance: "3128019430408477",
|
|
140
|
+
spendableBalance: "3128019430408477",
|
|
141
|
+
xpub: "0xa22CA840265d3C5CB1846e419B14c6a6CdD06FAB",
|
|
142
|
+
subAccounts: [],
|
|
143
|
+
swapHistory: [],
|
|
144
|
+
},
|
|
145
|
+
].map(fromAccountRaw);
|
|
146
|
+
|
|
147
|
+
const localCache = {};
|
|
148
|
+
const bridgeCache = makeBridgeCacheSystem({
|
|
149
|
+
saveData(c, d) {
|
|
150
|
+
localCache[c.id] = d;
|
|
151
|
+
return Promise.resolve();
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
getData(c) {
|
|
155
|
+
return Promise.resolve(localCache[c.id]);
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
const result = {
|
|
160
|
+
accounts: accounts.map(accountToAccountData),
|
|
161
|
+
settings: { currenciesSettings: {}, pairExchanges: {} },
|
|
162
|
+
meta: { exporterName: "Test", exporterVersion: "0" },
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const accountsState = [];
|
|
166
|
+
|
|
167
|
+
const items = importAccountsMakeItems({
|
|
168
|
+
result,
|
|
169
|
+
accounts: accountsState,
|
|
170
|
+
});
|
|
171
|
+
const selectedAccounts = accounts.map((a) => a.id);
|
|
172
|
+
const syncResult = await syncNewAccountsToImport(
|
|
173
|
+
{ items, selectedAccounts },
|
|
174
|
+
bridgeCache
|
|
175
|
+
);
|
|
176
|
+
const reduced = importAccountsReduce(accountsState, {
|
|
177
|
+
items,
|
|
178
|
+
selectedAccounts,
|
|
179
|
+
syncResult,
|
|
180
|
+
});
|
|
181
|
+
expect(reduced.length).toEqual(4);
|
|
182
|
+
expect((reduced[0] as AlgorandAccount).algorandResources).toBeDefined();
|
|
183
|
+
expect((reduced[1] as TronAccount).tronResources).toBeDefined();
|
|
184
|
+
expect((reduced[2] as PolkadotAccount).polkadotResources).toBeDefined();
|
|
185
|
+
expect(reduced[0].operations.length).toBeGreaterThan(1);
|
|
186
|
+
expect(reduced[1].operations.length).toBeGreaterThan(1);
|
|
187
|
+
expect(reduced[2].operations.length).toBeGreaterThan(1);
|
|
188
|
+
expect(reduced[3].operations.length).toBeGreaterThan(1);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
type AlgorandAccount = Account & { algorandResources: any };
|
|
192
|
+
type TronAccount = Account & { tronResources: any };
|
|
193
|
+
type PolkadotAccount = Account & { polkadotResources: any };
|
|
@@ -3,16 +3,15 @@ import {
|
|
|
3
3
|
importAccountsMakeItems,
|
|
4
4
|
importAccountsReduce,
|
|
5
5
|
fromAccountRaw,
|
|
6
|
-
} from "
|
|
7
|
-
import { setSupportedCurrencies } from "
|
|
8
|
-
import { setPlatformVersion } from "
|
|
6
|
+
} from ".";
|
|
7
|
+
import { setSupportedCurrencies } from "../currencies";
|
|
8
|
+
import { setPlatformVersion } from "../platform/version";
|
|
9
9
|
|
|
10
10
|
setPlatformVersion("1.1.0");
|
|
11
11
|
|
|
12
12
|
setSupportedCurrencies(["ethereum"]);
|
|
13
13
|
describe("importAccountsMakeItems", () => {
|
|
14
|
-
|
|
15
|
-
test.skip("should migrate ethereum accounts", () => {
|
|
14
|
+
test("importing ethereum accounts", () => {
|
|
16
15
|
const result = {
|
|
17
16
|
meta: {
|
|
18
17
|
exporterName: "desktop",
|
|
@@ -20,7 +19,7 @@ describe("importAccountsMakeItems", () => {
|
|
|
20
19
|
},
|
|
21
20
|
accounts: [
|
|
22
21
|
{
|
|
23
|
-
id: "
|
|
22
|
+
id: "js:1:ethereum:0x01:",
|
|
24
23
|
name: "Ethereum 1",
|
|
25
24
|
seedIdentifier: "seed",
|
|
26
25
|
derivationMode: "",
|
|
@@ -31,7 +30,7 @@ describe("importAccountsMakeItems", () => {
|
|
|
31
30
|
swapHistory: [],
|
|
32
31
|
},
|
|
33
32
|
{
|
|
34
|
-
id: "
|
|
33
|
+
id: "js:1:ethereum:0x02:",
|
|
35
34
|
name: "Ethereum 2",
|
|
36
35
|
seedIdentifier: "seed",
|
|
37
36
|
derivationMode: "",
|
|
@@ -42,7 +41,7 @@ describe("importAccountsMakeItems", () => {
|
|
|
42
41
|
swapHistory: [],
|
|
43
42
|
},
|
|
44
43
|
{
|
|
45
|
-
id: "
|
|
44
|
+
id: "js:1:ethereum:0x04:",
|
|
46
45
|
name: "Ethereum 4",
|
|
47
46
|
seedIdentifier: "seed",
|
|
48
47
|
derivationMode: "",
|
|
@@ -53,7 +52,7 @@ describe("importAccountsMakeItems", () => {
|
|
|
53
52
|
swapHistory: [],
|
|
54
53
|
},
|
|
55
54
|
{
|
|
56
|
-
id: "
|
|
55
|
+
id: "js:1:ethereum:0x03:",
|
|
57
56
|
name: "ETH3 name edited",
|
|
58
57
|
seedIdentifier: "seed",
|
|
59
58
|
derivationMode: "",
|
|
@@ -64,7 +63,7 @@ describe("importAccountsMakeItems", () => {
|
|
|
64
63
|
swapHistory: [],
|
|
65
64
|
},
|
|
66
65
|
{
|
|
67
|
-
id: "
|
|
66
|
+
id: "js:1:ethereum:0x05:",
|
|
68
67
|
name: "Ethereum 5",
|
|
69
68
|
seedIdentifier: "seed",
|
|
70
69
|
derivationMode: "",
|
|
@@ -84,7 +83,7 @@ describe("importAccountsMakeItems", () => {
|
|
|
84
83
|
};
|
|
85
84
|
const accounts = [
|
|
86
85
|
<AccountRaw>{
|
|
87
|
-
id: "
|
|
86
|
+
id: "js:1:ethereum:0x01:",
|
|
88
87
|
seedIdentifier: "0x01",
|
|
89
88
|
name: "Ethereum 1",
|
|
90
89
|
derivationMode: "",
|
|
@@ -101,7 +100,7 @@ describe("importAccountsMakeItems", () => {
|
|
|
101
100
|
balance: "51281813126095910",
|
|
102
101
|
},
|
|
103
102
|
<AccountRaw>{
|
|
104
|
-
id: "
|
|
103
|
+
id: "js:1:ethereum:0x02:",
|
|
105
104
|
seedIdentifier: "0x02",
|
|
106
105
|
name: "Ethereum 2",
|
|
107
106
|
derivationMode: "",
|
|
@@ -118,7 +117,7 @@ describe("importAccountsMakeItems", () => {
|
|
|
118
117
|
balance: "1081392000000000",
|
|
119
118
|
},
|
|
120
119
|
<AccountRaw>{
|
|
121
|
-
id: "
|
|
120
|
+
id: "js:1:ethereum:0x03:",
|
|
122
121
|
seedIdentifier: "seed",
|
|
123
122
|
name: "Ethereum 3",
|
|
124
123
|
derivationMode: "",
|
|
@@ -141,71 +140,52 @@ describe("importAccountsMakeItems", () => {
|
|
|
141
140
|
});
|
|
142
141
|
expect(items).toMatchObject([
|
|
143
142
|
{
|
|
144
|
-
initialAccountId: "
|
|
145
|
-
account: {
|
|
146
|
-
id: "libcore:1:ethereum:xpub4:",
|
|
147
|
-
name: "Ethereum 4",
|
|
148
|
-
},
|
|
143
|
+
initialAccountId: "js:1:ethereum:0x04:",
|
|
144
|
+
account: { id: "js:1:ethereum:0x04:", name: "Ethereum 4" },
|
|
149
145
|
mode: "create",
|
|
150
146
|
},
|
|
151
147
|
{
|
|
152
|
-
initialAccountId: "
|
|
153
|
-
account: {
|
|
154
|
-
id: "libcore:1:ethereum:xpub5:",
|
|
155
|
-
name: "Ethereum 5",
|
|
156
|
-
},
|
|
148
|
+
initialAccountId: "js:1:ethereum:0x05:",
|
|
149
|
+
account: { id: "js:1:ethereum:0x05:", name: "Ethereum 5" },
|
|
157
150
|
mode: "create",
|
|
158
151
|
},
|
|
159
152
|
{
|
|
160
|
-
initialAccountId: "
|
|
161
|
-
account: {
|
|
162
|
-
id: "libcore:1:ethereum:xpub1:",
|
|
163
|
-
name: "Ethereum 1",
|
|
164
|
-
},
|
|
153
|
+
initialAccountId: "js:1:ethereum:0x03:",
|
|
154
|
+
account: { id: "js:1:ethereum:0x03:", name: "ETH3 name edited" },
|
|
165
155
|
mode: "update",
|
|
166
156
|
},
|
|
167
157
|
{
|
|
168
|
-
initialAccountId: "
|
|
169
|
-
account: {
|
|
170
|
-
|
|
171
|
-
name: "Ethereum 2",
|
|
172
|
-
},
|
|
173
|
-
mode: "update",
|
|
158
|
+
initialAccountId: "js:1:ethereum:0x01:",
|
|
159
|
+
account: { id: "js:1:ethereum:0x01:", name: "Ethereum 1" },
|
|
160
|
+
mode: "id",
|
|
174
161
|
},
|
|
175
162
|
{
|
|
176
|
-
initialAccountId: "
|
|
177
|
-
account: {
|
|
178
|
-
|
|
179
|
-
name: "ETH3 name edited",
|
|
180
|
-
},
|
|
181
|
-
mode: "update",
|
|
163
|
+
initialAccountId: "js:1:ethereum:0x02:",
|
|
164
|
+
account: { id: "js:1:ethereum:0x02:", name: "Ethereum 2" },
|
|
165
|
+
mode: "id",
|
|
182
166
|
},
|
|
183
167
|
]);
|
|
168
|
+
const syncResult = {
|
|
169
|
+
failed: {},
|
|
170
|
+
synchronized: {},
|
|
171
|
+
};
|
|
172
|
+
result.accounts.forEach((a) => {
|
|
173
|
+
syncResult.synchronized[a.id] = a;
|
|
174
|
+
});
|
|
184
175
|
const reduced = importAccountsReduce(accounts, {
|
|
185
176
|
items,
|
|
186
177
|
selectedAccounts: [
|
|
187
|
-
"
|
|
188
|
-
"
|
|
189
|
-
"
|
|
178
|
+
"js:1:ethereum:0x03:",
|
|
179
|
+
"js:1:ethereum:0x02:",
|
|
180
|
+
"js:1:ethereum:0x05:",
|
|
190
181
|
],
|
|
182
|
+
syncResult,
|
|
191
183
|
});
|
|
192
184
|
expect(reduced).toMatchObject([
|
|
193
|
-
{
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
},
|
|
197
|
-
{
|
|
198
|
-
id: "libcore:1:ethereum:xpub2:",
|
|
199
|
-
name: "Ethereum 2",
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
id: "libcore:1:ethereum:xpub3:",
|
|
203
|
-
name: "ETH3 name edited",
|
|
204
|
-
},
|
|
205
|
-
{
|
|
206
|
-
id: "libcore:1:ethereum:xpub5:",
|
|
207
|
-
name: "Ethereum 5",
|
|
208
|
-
},
|
|
185
|
+
{ id: "js:1:ethereum:0x01:", name: "Ethereum 1" },
|
|
186
|
+
{ id: "js:1:ethereum:0x02:", name: "Ethereum 2" },
|
|
187
|
+
{ id: "js:1:ethereum:0x03:", name: "ETH3 name edited" },
|
|
188
|
+
{ id: "js:1:ethereum:0x05:", name: "Ethereum 5" },
|
|
209
189
|
]);
|
|
210
190
|
});
|
|
211
191
|
});
|