@ledgerhq/live-wallet 0.16.1-nightly.20251128145758 → 0.16.1-nightly.20251202023925
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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +8 -8
- package/lib/store.d.ts +15 -2
- package/lib/store.d.ts.map +1 -1
- package/lib/store.js +14 -2
- package/lib/store.js.map +1 -1
- package/lib/walletsync/__mocks__/index.d.ts +1 -1
- package/lib/walletsync/__mocks__/index.d.ts.map +1 -1
- package/lib/walletsync/__mocks__/modules/recentAddresses.d.ts +8 -0
- package/lib/walletsync/__mocks__/modules/recentAddresses.d.ts.map +1 -0
- package/lib/walletsync/__mocks__/modules/recentAddresses.js +32 -0
- package/lib/walletsync/__mocks__/modules/recentAddresses.js.map +1 -0
- package/lib/walletsync/modules/recentAddresses.d.ts +47 -0
- package/lib/walletsync/modules/recentAddresses.d.ts.map +1 -0
- package/lib/walletsync/modules/recentAddresses.js +92 -0
- package/lib/walletsync/modules/recentAddresses.js.map +1 -0
- package/lib/walletsync/root.d.ts +24 -0
- package/lib/walletsync/root.d.ts.map +1 -1
- package/lib/walletsync/root.js +2 -0
- package/lib/walletsync/root.js.map +1 -1
- package/lib-es/store.d.ts +15 -2
- package/lib-es/store.d.ts.map +1 -1
- package/lib-es/store.js +12 -1
- package/lib-es/store.js.map +1 -1
- package/lib-es/walletsync/__mocks__/index.d.ts +1 -1
- package/lib-es/walletsync/__mocks__/index.d.ts.map +1 -1
- package/lib-es/walletsync/__mocks__/modules/recentAddresses.d.ts +8 -0
- package/lib-es/walletsync/__mocks__/modules/recentAddresses.d.ts.map +1 -0
- package/lib-es/walletsync/__mocks__/modules/recentAddresses.js +25 -0
- package/lib-es/walletsync/__mocks__/modules/recentAddresses.js.map +1 -0
- package/lib-es/walletsync/modules/recentAddresses.d.ts +47 -0
- package/lib-es/walletsync/modules/recentAddresses.d.ts.map +1 -0
- package/lib-es/walletsync/modules/recentAddresses.js +87 -0
- package/lib-es/walletsync/modules/recentAddresses.js.map +1 -0
- package/lib-es/walletsync/root.d.ts +24 -0
- package/lib-es/walletsync/root.d.ts.map +1 -1
- package/lib-es/walletsync/root.js +2 -0
- package/lib-es/walletsync/root.js.map +1 -1
- package/package.json +7 -7
- package/src/ordering.test.ts +1 -0
- package/src/store.test.ts +2 -0
- package/src/store.ts +23 -2
- package/src/walletsync/__mocks__/modules/recentAddresses.ts +45 -0
- package/src/walletsync/__tests__/modules/recentAddresses.test.ts +487 -0
- package/src/walletsync/modules/recentAddresses.ts +125 -0
- package/src/walletsync/root.ts +2 -0
package/lib-es/store.js
CHANGED
|
@@ -5,6 +5,7 @@ export const initialState = {
|
|
|
5
5
|
starredAccountIds: new Set(),
|
|
6
6
|
nonImportedAccountInfos: [],
|
|
7
7
|
walletSyncState: { data: null, version: 0 },
|
|
8
|
+
recentAddresses: {},
|
|
8
9
|
};
|
|
9
10
|
export var WalletHandlerType;
|
|
10
11
|
(function (WalletHandlerType) {
|
|
@@ -16,6 +17,7 @@ export var WalletHandlerType;
|
|
|
16
17
|
WalletHandlerType["WALLET_SYNC_UPDATE"] = "WALLET_SYNC_UPDATE";
|
|
17
18
|
WalletHandlerType["IMPORT_WALLET_SYNC"] = "IMPORT_WALLET_SYNC";
|
|
18
19
|
WalletHandlerType["SET_NON_IMPORTED_ACCOUNTS"] = "SET_NON_IMPORTED_ACCOUNTS";
|
|
20
|
+
WalletHandlerType["UPDATE_RECENT_ADDRESSES"] = "UPDATE_RECENT_ADDRESSES";
|
|
19
21
|
})(WalletHandlerType || (WalletHandlerType = {}));
|
|
20
22
|
export const handlers = {
|
|
21
23
|
INIT_ACCOUNTS: (state, { payload: { accountsUserData } }) => {
|
|
@@ -85,6 +87,9 @@ export const handlers = {
|
|
|
85
87
|
SET_NON_IMPORTED_ACCOUNTS: (state, { payload }) => {
|
|
86
88
|
return { ...state, nonImportedAccountInfos: payload };
|
|
87
89
|
},
|
|
90
|
+
UPDATE_RECENT_ADDRESSES: (state, { payload }) => {
|
|
91
|
+
return { ...state, recentAddresses: { ...payload } };
|
|
92
|
+
},
|
|
88
93
|
};
|
|
89
94
|
// actions
|
|
90
95
|
export const setAccountName = (accountId, name) => ({
|
|
@@ -126,6 +131,10 @@ export const setNonImportedAccounts = (payload) => ({
|
|
|
126
131
|
type: "SET_NON_IMPORTED_ACCOUNTS",
|
|
127
132
|
payload,
|
|
128
133
|
});
|
|
134
|
+
export const updateRecentAddresses = (payload) => ({
|
|
135
|
+
type: "UPDATE_RECENT_ADDRESSES",
|
|
136
|
+
payload,
|
|
137
|
+
});
|
|
129
138
|
// Local Selectors
|
|
130
139
|
export const accountNameSelector = (state, { accountId }) => state.accountNames.get(accountId);
|
|
131
140
|
export const accountNameWithDefaultSelector = (state, account) => state?.accountNames?.get(account.id) || getDefaultAccountName(account);
|
|
@@ -177,12 +186,14 @@ export const exportWalletState = (state) => ({
|
|
|
177
186
|
accountNames: Array.from(state.accountNames),
|
|
178
187
|
starredAccountIds: Array.from(state.starredAccountIds),
|
|
179
188
|
},
|
|
189
|
+
recentAddresses: state.recentAddresses,
|
|
180
190
|
});
|
|
181
191
|
export const walletStateExportShouldDiffer = (a, b) => {
|
|
182
192
|
return (a.walletSyncState !== b.walletSyncState ||
|
|
183
193
|
a.nonImportedAccountInfos !== b.nonImportedAccountInfos ||
|
|
184
194
|
a.accountNames !== b.accountNames ||
|
|
185
|
-
a.starredAccountIds !== b.starredAccountIds
|
|
195
|
+
a.starredAccountIds !== b.starredAccountIds ||
|
|
196
|
+
a.recentAddresses !== b.recentAddresses);
|
|
186
197
|
};
|
|
187
198
|
export const walletSyncStateSelector = (state) => state.walletSyncState;
|
|
188
199
|
//# sourceMappingURL=store.js.map
|
package/lib-es/store.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.js","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"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,EAAE,UAAU,EAAE,CAAC;AAClC,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAkB,EAAuB,EAAE,CAAC,CAAC;IAC7E,eAAe,EAAE,KAAK,CAAC,eAAe;IACtC,uBAAuB,EAAE,KAAK,CAAC,uBAAuB;IACtD,YAAY,EAAE;QACZ,YAAY,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC;QAC5C,iBAAiB,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC;KACvD;IACD,eAAe,EAAE,KAAK,CAAC,eAAe;CACvC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAc,EAAE,CAAc,EAAW,EAAE;IACvF,OAAO,CACL,CAAC,CAAC,eAAe,KAAK,CAAC,CAAC,eAAe;QACvC,CAAC,CAAC,uBAAuB,KAAK,CAAC,CAAC,uBAAuB;QACvD,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,YAAY;QACjC,CAAC,CAAC,iBAAiB,KAAK,CAAC,CAAC,iBAAiB;QAC3C,CAAC,CAAC,eAAe,KAAK,CAAC,CAAC,eAAe,CACxC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,KAAkB,EAAW,EAAE,CAAC,KAAK,CAAC,eAAe,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DistantState, LocalState } from "..";
|
|
2
2
|
export declare const emptyState: LocalState;
|
|
3
3
|
export declare const genState: (index: number) => LocalState;
|
|
4
|
-
export declare const genModuleState: <K extends "accounts" | "accountNames">(name: K, index: number) => LocalState[K];
|
|
4
|
+
export declare const genModuleState: <K extends "accounts" | "accountNames" | "recentAddresses">(name: K, index: number) => LocalState[K];
|
|
5
5
|
export declare const convertLocalToDistantState: (localState: LocalState) => DistantState;
|
|
6
6
|
export declare const convertDistantToLocalState: (distantState: DistantState) => LocalState;
|
|
7
7
|
export declare const similarLocalState: (a: LocalState, b: LocalState) => boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/walletsync/__mocks__/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAuBnD,eAAO,MAAM,UAAU,EAAE,UAEV,CAAC;AAEhB,eAAO,MAAM,QAAQ,UAAW,MAAM,KAAG,UAGxB,CAAC;AAElB,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/walletsync/__mocks__/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAuBnD,eAAO,MAAM,UAAU,EAAE,UAEV,CAAC;AAEhB,eAAO,MAAM,QAAQ,UAAW,MAAM,KAAG,UAGxB,CAAC;AAElB,eAAO,MAAM,cAAc,oEAA+B,CAAC,SAAS,MAAM,KAAG,UAAU,CAAC,CAAC,CAIxF,CAAC;AAEF,eAAO,MAAM,0BAA0B,eAAgB,UAAU,KAAG,YASjD,CAAC;AAEpB,eAAO,MAAM,0BAA0B,iBAAkB,YAAY,KAAG,UASvD,CAAC;AAElB,eAAO,MAAM,iBAAiB,MAAO,UAAU,KAAK,UAAU,KAAG,OAI9D,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RecentAddressesState } from "@ledgerhq/types-live";
|
|
2
|
+
import { DistantRecentAddressesState } from "../../modules/recentAddresses";
|
|
3
|
+
export declare const emptyState: {};
|
|
4
|
+
export declare const genState: (index: number) => RecentAddressesState;
|
|
5
|
+
export declare const convertLocalToDistantState: (localState: RecentAddressesState) => DistantRecentAddressesState;
|
|
6
|
+
export declare const convertDistantToLocalState: (distantState: DistantRecentAddressesState) => RecentAddressesState;
|
|
7
|
+
export declare const similarLocalState: (state: RecentAddressesState, otherState: RecentAddressesState) => boolean;
|
|
8
|
+
//# sourceMappingURL=recentAddresses.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recentAddresses.d.ts","sourceRoot":"","sources":["../../../../src/walletsync/__mocks__/modules/recentAddresses.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EACL,2BAA2B,EAG5B,MAAM,+BAA+B,CAAC;AAEvC,eAAO,MAAM,UAAU,IAAK,CAAC;AAE7B,eAAO,MAAM,QAAQ,UAAW,MAAM,yBAWrC,CAAC;AAEF,eAAO,MAAM,0BAA0B,eAAgB,oBAAoB,gCAC/C,CAAC;AAE7B,eAAO,MAAM,0BAA0B,iBAAkB,2BAA2B,yBAC7D,CAAC;AAExB,eAAO,MAAM,iBAAiB,UACrB,oBAAoB,cACf,oBAAoB,YAcjC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { toDistantState, toState, } from "../../modules/recentAddresses";
|
|
2
|
+
export const emptyState = {};
|
|
3
|
+
export const genState = (index) => {
|
|
4
|
+
const recentAddressesState = {};
|
|
5
|
+
for (let i = 0; i < index + 1; i++) {
|
|
6
|
+
recentAddressesState["currency-" + i.toString()] = [];
|
|
7
|
+
for (let j = 0; j < 12; j++) {
|
|
8
|
+
recentAddressesState["currency-" + i.toString()].push(`some random address at index ${j}`);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return recentAddressesState;
|
|
12
|
+
};
|
|
13
|
+
export const convertLocalToDistantState = (localState) => toDistantState(localState);
|
|
14
|
+
export const convertDistantToLocalState = (distantState) => toState(distantState);
|
|
15
|
+
export const similarLocalState = (state, otherState) => {
|
|
16
|
+
const stateKeys = Object.keys(state);
|
|
17
|
+
const otherStateKeys = Object.keys(otherState);
|
|
18
|
+
return (stateKeys.length === otherStateKeys.length &&
|
|
19
|
+
otherStateKeys.every(key => {
|
|
20
|
+
return (state[key] &&
|
|
21
|
+
state[key].length === otherState[key].length &&
|
|
22
|
+
otherState[key].every(address => state[key].includes(address)));
|
|
23
|
+
}));
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=recentAddresses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recentAddresses.js","sourceRoot":"","sources":["../../../../src/walletsync/__mocks__/modules/recentAddresses.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,cAAc,EACd,OAAO,GACR,MAAM,+BAA+B,CAAC;AAEvC,MAAM,CAAC,MAAM,UAAU,GAAG,EAAE,CAAC;AAE7B,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAE,EAAE;IACxC,MAAM,oBAAoB,GAAyB,EAAE,CAAC;IAEtD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACnC,oBAAoB,CAAC,WAAW,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,CAAC;QACtD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;YAC5B,oBAAoB,CAAC,WAAW,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,gCAAgC,CAAC,EAAE,CAAC,CAAC;QAC7F,CAAC;IACH,CAAC;IAED,OAAO,oBAAoB,CAAC;AAC9B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,UAAgC,EAAE,EAAE,CAC7E,cAAc,CAAC,UAAU,CAAC,CAAC;AAE7B,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,YAAyC,EAAE,EAAE,CACtF,OAAO,CAAC,YAAY,CAAC,CAAC;AAExB,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,KAA2B,EAC3B,UAAgC,EAChC,EAAE;IACF,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACrC,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC/C,OAAO,CACL,SAAS,CAAC,MAAM,KAAK,cAAc,CAAC,MAAM;QAC1C,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;YACzB,OAAO,CACL,KAAK,CAAC,GAAG,CAAC;gBACV,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,UAAU,CAAC,GAAG,CAAC,CAAC,MAAM;gBAC5C,UAAU,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAC/D,CAAC;QACJ,CAAC,CAAC,CACH,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module recentAddresses
|
|
3
|
+
*
|
|
4
|
+
* This module is responsible for synchronizing recent addresses across Wallet instances
|
|
5
|
+
* in the WalletSync system. It manages an ordered list of recently used addresses,
|
|
6
|
+
* ensuring that when a user accesses an address on one Live instance, that address
|
|
7
|
+
* (and its position in the recent list) is propagated to all other synchronized Live instances.
|
|
8
|
+
*
|
|
9
|
+
* Recent addresses are off-chain data (not stored on the blockchain), and therefore need to
|
|
10
|
+
* be synchronized through the WalletSync system to ensure consistency across all Live instances.
|
|
11
|
+
*
|
|
12
|
+
* Key responsibilities:
|
|
13
|
+
* - Tracks local recent address changes and prepares them for synchronization
|
|
14
|
+
* - Resolves incoming recent address updates from other Live instances
|
|
15
|
+
* - Maintains the order/index of addresses in the recent list
|
|
16
|
+
* - Handles conflict resolution by accepting incoming state changes (last-write-wins strategy)
|
|
17
|
+
* - Maintains consistency between local state (string[]) and distant state (RecentAddressesState[])
|
|
18
|
+
*
|
|
19
|
+
* The module preserves the index/position of each address, allowing the UI to maintain
|
|
20
|
+
* a consistent ordering of recently used addresses across all synchronized Live instances.
|
|
21
|
+
*/
|
|
22
|
+
import { z } from "zod";
|
|
23
|
+
import { WalletSyncDataManager } from "../types";
|
|
24
|
+
import { RecentAddressesState } from "@ledgerhq/types-live";
|
|
25
|
+
/**
|
|
26
|
+
* We dont use the same data structure for remote state
|
|
27
|
+
* An index attribute has been added to keep the order (recomputed locally)
|
|
28
|
+
*/
|
|
29
|
+
export type DistantRecentAddressesState = Record<string, {
|
|
30
|
+
address: string;
|
|
31
|
+
index: number;
|
|
32
|
+
}[]>;
|
|
33
|
+
export declare function toDistantState(addressesByCurrency: RecentAddressesState): DistantRecentAddressesState;
|
|
34
|
+
export declare function toState(addressesByCurrency: DistantRecentAddressesState): RecentAddressesState;
|
|
35
|
+
declare const schema: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodObject<{
|
|
36
|
+
address: z.ZodString;
|
|
37
|
+
index: z.ZodNumber;
|
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
|
39
|
+
index: number;
|
|
40
|
+
address: string;
|
|
41
|
+
}, {
|
|
42
|
+
index: number;
|
|
43
|
+
address: string;
|
|
44
|
+
}>, "many">>;
|
|
45
|
+
declare const manager: WalletSyncDataManager<RecentAddressesState, RecentAddressesState, typeof schema>;
|
|
46
|
+
export default manager;
|
|
47
|
+
//# sourceMappingURL=recentAddresses.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recentAddresses.d.ts","sourceRoot":"","sources":["../../../src/walletsync/modules/recentAddresses.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D;;;GAGG;AACH,MAAM,MAAM,2BAA2B,GAAG,MAAM,CAC9C,MAAM,EACN;IACE,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf,EAAE,CACJ,CAAC;AAEF,wBAAgB,cAAc,CAC5B,mBAAmB,EAAE,oBAAoB,GACxC,2BAA2B,CAO7B;AAED,wBAAgB,OAAO,CAAC,mBAAmB,EAAE,2BAA2B,GAAG,oBAAoB,CAS9F;AA8BD,QAAA,MAAM,MAAM;;;;;;;;;YAAuD,CAAC;AAEpE,QAAA,MAAM,OAAO,EAAE,qBAAqB,CAAC,oBAAoB,EAAE,oBAAoB,EAAE,OAAO,MAAM,CAgC7F,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module recentAddresses
|
|
3
|
+
*
|
|
4
|
+
* This module is responsible for synchronizing recent addresses across Wallet instances
|
|
5
|
+
* in the WalletSync system. It manages an ordered list of recently used addresses,
|
|
6
|
+
* ensuring that when a user accesses an address on one Live instance, that address
|
|
7
|
+
* (and its position in the recent list) is propagated to all other synchronized Live instances.
|
|
8
|
+
*
|
|
9
|
+
* Recent addresses are off-chain data (not stored on the blockchain), and therefore need to
|
|
10
|
+
* be synchronized through the WalletSync system to ensure consistency across all Live instances.
|
|
11
|
+
*
|
|
12
|
+
* Key responsibilities:
|
|
13
|
+
* - Tracks local recent address changes and prepares them for synchronization
|
|
14
|
+
* - Resolves incoming recent address updates from other Live instances
|
|
15
|
+
* - Maintains the order/index of addresses in the recent list
|
|
16
|
+
* - Handles conflict resolution by accepting incoming state changes (last-write-wins strategy)
|
|
17
|
+
* - Maintains consistency between local state (string[]) and distant state (RecentAddressesState[])
|
|
18
|
+
*
|
|
19
|
+
* The module preserves the index/position of each address, allowing the UI to maintain
|
|
20
|
+
* a consistent ordering of recently used addresses across all synchronized Live instances.
|
|
21
|
+
*/
|
|
22
|
+
import { z } from "zod";
|
|
23
|
+
export function toDistantState(addressesByCurrency) {
|
|
24
|
+
const state = {};
|
|
25
|
+
Object.keys(addressesByCurrency).forEach(key => {
|
|
26
|
+
state[key] = addressesByCurrency[key].map((address, index) => ({ address, index }));
|
|
27
|
+
});
|
|
28
|
+
return state;
|
|
29
|
+
}
|
|
30
|
+
export function toState(addressesByCurrency) {
|
|
31
|
+
const state = {};
|
|
32
|
+
Object.keys(addressesByCurrency).forEach(key => {
|
|
33
|
+
state[key] = addressesByCurrency[key]
|
|
34
|
+
.sort((current, other) => current.index - other.index)
|
|
35
|
+
.map(data => data.address);
|
|
36
|
+
});
|
|
37
|
+
return state;
|
|
38
|
+
}
|
|
39
|
+
function sameDistantState(localData, distantState) {
|
|
40
|
+
const localDataKeys = Object.keys(localData);
|
|
41
|
+
const distantStateKeys = Object.keys(distantState);
|
|
42
|
+
return (localDataKeys.length === distantStateKeys.length &&
|
|
43
|
+
distantStateKeys.every(key => {
|
|
44
|
+
return (localData[key] &&
|
|
45
|
+
localData[key].length === distantState[key].length &&
|
|
46
|
+
!distantState[key].some(data => data.index < 0 ||
|
|
47
|
+
data.index >= localData[key].length ||
|
|
48
|
+
localData[key][data.index] !== data.address));
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
const recentAddressesSchema = z.object({
|
|
52
|
+
address: z.string(),
|
|
53
|
+
index: z.number(),
|
|
54
|
+
});
|
|
55
|
+
const schema = z.record(z.string(), z.array(recentAddressesSchema));
|
|
56
|
+
const manager = {
|
|
57
|
+
schema,
|
|
58
|
+
diffLocalToDistant(localData, latestState) {
|
|
59
|
+
if (!sameDistantState(localData, latestState ?? {})) {
|
|
60
|
+
return {
|
|
61
|
+
hasChanges: true,
|
|
62
|
+
nextState: toDistantState(localData),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
hasChanges: false,
|
|
67
|
+
nextState: latestState ?? {},
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
async resolveIncrementalUpdate(_ctx, localData, latestState, incomingState) {
|
|
71
|
+
if (!incomingState) {
|
|
72
|
+
return { hasChanges: false };
|
|
73
|
+
}
|
|
74
|
+
if (latestState === incomingState || sameDistantState(localData, incomingState)) {
|
|
75
|
+
return { hasChanges: false };
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
hasChanges: true,
|
|
79
|
+
update: toState(incomingState),
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
applyUpdate(_localData, update) {
|
|
83
|
+
return update;
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
export default manager;
|
|
87
|
+
//# sourceMappingURL=recentAddresses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recentAddresses.js","sourceRoot":"","sources":["../../../src/walletsync/modules/recentAddresses.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAgBxB,MAAM,UAAU,cAAc,CAC5B,mBAAyC;IAEzC,MAAM,KAAK,GAAgC,EAAE,CAAC;IAC9C,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QAC7C,KAAK,CAAC,GAAG,CAAC,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IACtF,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,mBAAgD;IACtE,MAAM,KAAK,GAAyB,EAAE,CAAC;IACvC,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QAC7C,KAAK,CAAC,GAAG,CAAC,GAAG,mBAAmB,CAAC,GAAG,CAAC;aAClC,IAAI,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EA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AAqF;IAChG,MAAM;IACN,kBAAkB,CAAC,SAAS,EAAE,WAAW;QACvC,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,WAAW,IAAI,EAAE,CAAC,EAAE,CAAC;YACpD,OAAO;gBACL,UAAU,EAAE,IAAI;gBAChB,SAAS,EAAE,cAAc,CAAC,SAAS,CAAC;aACrC,CAAC;QACJ,CAAC;QAED,OAAO;YACL,UAAU,EAAE,KAAK;YACjB,SAAS,EAAE,WAAW,IAAI,EAAE;SAC7B,CAAC;IACJ,CAAC;IACD,KAAK,CAAC,wBAAwB,CAAC,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa;QACxE,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;QAC/B,CAAC;QAED,IAAI,WAAW,KAAK,aAAa,IAAI,gBAAgB,CAAC,SAAS,EAAE,aAAa,CAAC,EAAE,CAAC;YAChF,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;QAC/B,CAAC;QAED,OAAO;YACL,UAAU,EAAE,IAAI;YAChB,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC;SAC/B,CAAC;IACJ,CAAC;IACD,WAAW,CAAC,UAAU,EAAE,MAAM;QAC5B,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -11,6 +11,7 @@ declare const root: import("./types").WalletSyncDataManager<{
|
|
|
11
11
|
nonImportedAccountInfos: import("./modules/accounts").NonImportedAccountInfo[];
|
|
12
12
|
};
|
|
13
13
|
accountNames: Map<string, string>;
|
|
14
|
+
recentAddresses: import("@ledgerhq/types-live").RecentAddressesState;
|
|
14
15
|
}, {
|
|
15
16
|
accounts: import("./types").UpdateDiff<{
|
|
16
17
|
removed: string[];
|
|
@@ -20,6 +21,7 @@ declare const root: import("./types").WalletSyncDataManager<{
|
|
|
20
21
|
accountNames: import("./types").UpdateDiff<{
|
|
21
22
|
replaceAllNames: Record<string, string>;
|
|
22
23
|
}>;
|
|
24
|
+
recentAddresses: import("./types").UpdateDiff<import("@ledgerhq/types-live").RecentAddressesState>;
|
|
23
25
|
}, z.ZodObject<{
|
|
24
26
|
accounts: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
25
27
|
id: z.ZodString;
|
|
@@ -44,6 +46,16 @@ declare const root: import("./types").WalletSyncDataManager<{
|
|
|
44
46
|
currencyId: string;
|
|
45
47
|
}>, "many">>;
|
|
46
48
|
accountNames: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
49
|
+
recentAddresses: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodObject<{
|
|
50
|
+
address: z.ZodString;
|
|
51
|
+
index: z.ZodNumber;
|
|
52
|
+
}, "strip", z.ZodTypeAny, {
|
|
53
|
+
index: number;
|
|
54
|
+
address: string;
|
|
55
|
+
}, {
|
|
56
|
+
index: number;
|
|
57
|
+
address: string;
|
|
58
|
+
}>, "many">>>;
|
|
47
59
|
}, "strip", z.ZodTypeAny, {
|
|
48
60
|
accounts?: {
|
|
49
61
|
index: number;
|
|
@@ -54,6 +66,10 @@ declare const root: import("./types").WalletSyncDataManager<{
|
|
|
54
66
|
currencyId: string;
|
|
55
67
|
}[] | undefined;
|
|
56
68
|
accountNames?: Record<string, string> | undefined;
|
|
69
|
+
recentAddresses?: Record<string, {
|
|
70
|
+
index: number;
|
|
71
|
+
address: string;
|
|
72
|
+
}[]> | undefined;
|
|
57
73
|
}, {
|
|
58
74
|
accounts?: {
|
|
59
75
|
index: number;
|
|
@@ -64,6 +80,10 @@ declare const root: import("./types").WalletSyncDataManager<{
|
|
|
64
80
|
currencyId: string;
|
|
65
81
|
}[] | undefined;
|
|
66
82
|
accountNames?: Record<string, string> | undefined;
|
|
83
|
+
recentAddresses?: Record<string, {
|
|
84
|
+
index: number;
|
|
85
|
+
address: string;
|
|
86
|
+
}[]> | undefined;
|
|
67
87
|
}>, {
|
|
68
88
|
accounts?: {
|
|
69
89
|
index: number;
|
|
@@ -74,6 +94,10 @@ declare const root: import("./types").WalletSyncDataManager<{
|
|
|
74
94
|
currencyId: string;
|
|
75
95
|
}[] | undefined;
|
|
76
96
|
accountNames?: Record<string, string> | undefined;
|
|
97
|
+
recentAddresses?: Record<string, {
|
|
98
|
+
index: number;
|
|
99
|
+
address: string;
|
|
100
|
+
}[]> | undefined;
|
|
77
101
|
}>;
|
|
78
102
|
type Root = typeof root;
|
|
79
103
|
export type LocalState = ExtractLocalState<Root>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../../src/walletsync/root.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../../src/walletsync/root.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAgB/E;;;;GAIG;AACH,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAA4B,CAAC;AAEvC,KAAK,IAAI,GAAG,OAAO,IAAI,CAAC;AACxB,MAAM,MAAM,UAAU,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;AACjD,MAAM,MAAM,WAAW,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;AACnD,MAAM,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;AACzC,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAE3C,eAAe,IAAI,CAAC"}
|
|
@@ -3,9 +3,11 @@ import { createAggregator } from "./aggregator";
|
|
|
3
3
|
// New modules can be added over time, it's also possible to remove modules but don't replace modules because the schema of a field must not change.
|
|
4
4
|
import accounts from "./modules/accounts";
|
|
5
5
|
import accountNames from "./modules/accountNames";
|
|
6
|
+
import recentAddresses from "./modules/recentAddresses";
|
|
6
7
|
const modules = {
|
|
7
8
|
accounts,
|
|
8
9
|
accountNames,
|
|
10
|
+
recentAddresses,
|
|
9
11
|
};
|
|
10
12
|
/**
|
|
11
13
|
* This is the root WalletSyncDataManager that manage the data as a whole
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"root.js","sourceRoot":"","sources":["../../src/walletsync/root.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,qEAAqE;AACrE,oJAAoJ;AAEpJ,OAAO,QAAQ,MAAM,oBAAoB,CAAC;AAC1C,OAAO,YAAY,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"root.js","sourceRoot":"","sources":["../../src/walletsync/root.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,qEAAqE;AACrE,oJAAoJ;AAEpJ,OAAO,QAAQ,MAAM,oBAAoB,CAAC;AAC1C,OAAO,YAAY,MAAM,wBAAwB,CAAC;AAClD,OAAO,eAAe,MAAM,2BAA2B,CAAC;AAExD,MAAM,OAAO,GAAG;IACd,QAAQ;IACR,YAAY;IACZ,eAAe;CAChB,CAAC;AAEF;;;;GAIG;AACH,MAAM,IAAI,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;AAQvC,eAAe,IAAI,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/live-wallet",
|
|
3
|
-
"version": "0.16.1-nightly.
|
|
3
|
+
"version": "0.16.1-nightly.20251202023925",
|
|
4
4
|
"description": "Ledger Live wallet",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ledger"
|
|
@@ -28,15 +28,15 @@
|
|
|
28
28
|
"pako": "^2.0.4",
|
|
29
29
|
"rxjs": "7",
|
|
30
30
|
"zod": "^3.22.4",
|
|
31
|
-
"@ledgerhq/coin-framework": "6.10.0-nightly.
|
|
32
|
-
"@ledgerhq/
|
|
33
|
-
"@ledgerhq/live-
|
|
31
|
+
"@ledgerhq/coin-framework": "6.10.0-nightly.20251202023925",
|
|
32
|
+
"@ledgerhq/cryptoassets": "13.34.0-nightly.20251202023925",
|
|
33
|
+
"@ledgerhq/live-env": "2.22.0-nightly.20251202023925",
|
|
34
|
+
"@ledgerhq/live-network": "2.1.2-nightly.20251202023925",
|
|
34
35
|
"@ledgerhq/live-promise": "0.1.1",
|
|
35
|
-
"@ledgerhq/cryptoassets": "13.34.0-nightly.20251128145758",
|
|
36
36
|
"@ledgerhq/logs": "6.13.0",
|
|
37
|
+
"@ledgerhq/ledger-key-ring-protocol": "0.8.0-nightly.20251202023925",
|
|
37
38
|
"@ledgerhq/types-cryptoassets": "7.30.0",
|
|
38
|
-
"@ledgerhq/
|
|
39
|
-
"@ledgerhq/types-live": "6.90.0-nightly.20251128145758"
|
|
39
|
+
"@ledgerhq/types-live": "6.90.0-nightly.20251202023925"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/jest": "^29.5.10",
|
package/src/ordering.test.ts
CHANGED
package/src/store.test.ts
CHANGED
|
@@ -246,6 +246,7 @@ describe("Wallet store", () => {
|
|
|
246
246
|
accountNames: [],
|
|
247
247
|
starredAccountIds: [],
|
|
248
248
|
},
|
|
249
|
+
recentAddresses: {},
|
|
249
250
|
};
|
|
250
251
|
|
|
251
252
|
it("allows partial wallet state", () => {
|
|
@@ -395,6 +396,7 @@ describe("Wallet store", () => {
|
|
|
395
396
|
? ["mock:1:ethereum:eth:", "mock:1:ethereum:eth:|0", "mock:1:ethereum:eth:|1"]
|
|
396
397
|
: ["mock:1:ethereum:eth:"],
|
|
397
398
|
},
|
|
399
|
+
recentAddresses: {},
|
|
398
400
|
});
|
|
399
401
|
const stateImport2 = handlers.IMPORT_WALLET_SYNC(
|
|
400
402
|
stateImport1,
|
package/src/store.ts
CHANGED
|
@@ -3,7 +3,13 @@
|
|
|
3
3
|
* The Wallet store is a store that contains the user data related to accounts.
|
|
4
4
|
* It essentially is the whole user's wallet.
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
Account,
|
|
8
|
+
AccountLike,
|
|
9
|
+
AccountRaw,
|
|
10
|
+
AccountUserData,
|
|
11
|
+
RecentAddressesState,
|
|
12
|
+
} from "@ledgerhq/types-live";
|
|
7
13
|
import { getDefaultAccountName, getDefaultAccountNameForCurrencyIndex } from "./accountName";
|
|
8
14
|
import { AddAccountsAction } from "./addAccounts";
|
|
9
15
|
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies";
|
|
@@ -26,6 +32,7 @@ export type WalletState = {
|
|
|
26
32
|
|
|
27
33
|
// local copy of the wallet sync data last synchronized with the backend of wallet sync, in order to be able to diff what we need to do when we apply an incremental update
|
|
28
34
|
walletSyncState: WSState;
|
|
35
|
+
recentAddresses: RecentAddressesState;
|
|
29
36
|
};
|
|
30
37
|
|
|
31
38
|
export type ExportedWalletState = {
|
|
@@ -35,6 +42,7 @@ export type ExportedWalletState = {
|
|
|
35
42
|
accountNames: Array<[string, string]>;
|
|
36
43
|
starredAccountIds: string[];
|
|
37
44
|
};
|
|
45
|
+
recentAddresses: RecentAddressesState;
|
|
38
46
|
};
|
|
39
47
|
|
|
40
48
|
export const initialState: WalletState = {
|
|
@@ -42,6 +50,7 @@ export const initialState: WalletState = {
|
|
|
42
50
|
starredAccountIds: new Set(),
|
|
43
51
|
nonImportedAccountInfos: [],
|
|
44
52
|
walletSyncState: { data: null, version: 0 },
|
|
53
|
+
recentAddresses: {},
|
|
45
54
|
};
|
|
46
55
|
|
|
47
56
|
export enum WalletHandlerType {
|
|
@@ -53,6 +62,7 @@ export enum WalletHandlerType {
|
|
|
53
62
|
WALLET_SYNC_UPDATE = "WALLET_SYNC_UPDATE",
|
|
54
63
|
IMPORT_WALLET_SYNC = "IMPORT_WALLET_SYNC",
|
|
55
64
|
SET_NON_IMPORTED_ACCOUNTS = "SET_NON_IMPORTED_ACCOUNTS",
|
|
65
|
+
UPDATE_RECENT_ADDRESSES = "UPDATE_RECENT_ADDRESSES",
|
|
56
66
|
}
|
|
57
67
|
|
|
58
68
|
export type HandlersPayloads = {
|
|
@@ -67,6 +77,7 @@ export type HandlersPayloads = {
|
|
|
67
77
|
};
|
|
68
78
|
IMPORT_WALLET_SYNC: Partial<ExportedWalletState>;
|
|
69
79
|
SET_NON_IMPORTED_ACCOUNTS: NonImportedAccountInfo[];
|
|
80
|
+
UPDATE_RECENT_ADDRESSES: RecentAddressesState;
|
|
70
81
|
};
|
|
71
82
|
|
|
72
83
|
type Handlers<State, Types, PreciseKey = true> = {
|
|
@@ -144,6 +155,9 @@ export const handlers: WalletHandlers = {
|
|
|
144
155
|
SET_NON_IMPORTED_ACCOUNTS: (state, { payload }) => {
|
|
145
156
|
return { ...state, nonImportedAccountInfos: payload };
|
|
146
157
|
},
|
|
158
|
+
UPDATE_RECENT_ADDRESSES: (state, { payload }) => {
|
|
159
|
+
return { ...state, recentAddresses: { ...payload } };
|
|
160
|
+
},
|
|
147
161
|
};
|
|
148
162
|
|
|
149
163
|
// actions
|
|
@@ -194,6 +208,11 @@ export const setNonImportedAccounts = (payload: NonImportedAccountInfo[]) => ({
|
|
|
194
208
|
payload,
|
|
195
209
|
});
|
|
196
210
|
|
|
211
|
+
export const updateRecentAddresses = (payload: RecentAddressesState) => ({
|
|
212
|
+
type: "UPDATE_RECENT_ADDRESSES",
|
|
213
|
+
payload,
|
|
214
|
+
});
|
|
215
|
+
|
|
197
216
|
// Local Selectors
|
|
198
217
|
|
|
199
218
|
export const accountNameSelector = (
|
|
@@ -262,6 +281,7 @@ export const exportWalletState = (state: WalletState): ExportedWalletState => ({
|
|
|
262
281
|
accountNames: Array.from(state.accountNames),
|
|
263
282
|
starredAccountIds: Array.from(state.starredAccountIds),
|
|
264
283
|
},
|
|
284
|
+
recentAddresses: state.recentAddresses,
|
|
265
285
|
});
|
|
266
286
|
|
|
267
287
|
export const walletStateExportShouldDiffer = (a: WalletState, b: WalletState): boolean => {
|
|
@@ -269,7 +289,8 @@ export const walletStateExportShouldDiffer = (a: WalletState, b: WalletState): b
|
|
|
269
289
|
a.walletSyncState !== b.walletSyncState ||
|
|
270
290
|
a.nonImportedAccountInfos !== b.nonImportedAccountInfos ||
|
|
271
291
|
a.accountNames !== b.accountNames ||
|
|
272
|
-
a.starredAccountIds !== b.starredAccountIds
|
|
292
|
+
a.starredAccountIds !== b.starredAccountIds ||
|
|
293
|
+
a.recentAddresses !== b.recentAddresses
|
|
273
294
|
);
|
|
274
295
|
};
|
|
275
296
|
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { RecentAddressesState } from "@ledgerhq/types-live";
|
|
2
|
+
import {
|
|
3
|
+
DistantRecentAddressesState,
|
|
4
|
+
toDistantState,
|
|
5
|
+
toState,
|
|
6
|
+
} from "../../modules/recentAddresses";
|
|
7
|
+
|
|
8
|
+
export const emptyState = {};
|
|
9
|
+
|
|
10
|
+
export const genState = (index: number) => {
|
|
11
|
+
const recentAddressesState: RecentAddressesState = {};
|
|
12
|
+
|
|
13
|
+
for (let i = 0; i < index + 1; i++) {
|
|
14
|
+
recentAddressesState["currency-" + i.toString()] = [];
|
|
15
|
+
for (let j = 0; j < 12; j++) {
|
|
16
|
+
recentAddressesState["currency-" + i.toString()].push(`some random address at index ${j}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return recentAddressesState;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const convertLocalToDistantState = (localState: RecentAddressesState) =>
|
|
24
|
+
toDistantState(localState);
|
|
25
|
+
|
|
26
|
+
export const convertDistantToLocalState = (distantState: DistantRecentAddressesState) =>
|
|
27
|
+
toState(distantState);
|
|
28
|
+
|
|
29
|
+
export const similarLocalState = (
|
|
30
|
+
state: RecentAddressesState,
|
|
31
|
+
otherState: RecentAddressesState,
|
|
32
|
+
) => {
|
|
33
|
+
const stateKeys = Object.keys(state);
|
|
34
|
+
const otherStateKeys = Object.keys(otherState);
|
|
35
|
+
return (
|
|
36
|
+
stateKeys.length === otherStateKeys.length &&
|
|
37
|
+
otherStateKeys.every(key => {
|
|
38
|
+
return (
|
|
39
|
+
state[key] &&
|
|
40
|
+
state[key].length === otherState[key].length &&
|
|
41
|
+
otherState[key].every(address => state[key].includes(address))
|
|
42
|
+
);
|
|
43
|
+
})
|
|
44
|
+
);
|
|
45
|
+
};
|