@ledgerhq/live-wallet 0.16.1-nightly.20251205111238 → 0.16.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.
Files changed (46) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +20 -8
  3. package/lib/store.d.ts +2 -15
  4. package/lib/store.d.ts.map +1 -1
  5. package/lib/store.js +2 -14
  6. package/lib/store.js.map +1 -1
  7. package/lib/walletsync/__mocks__/index.d.ts +1 -1
  8. package/lib/walletsync/__mocks__/index.d.ts.map +1 -1
  9. package/lib/walletsync/root.d.ts +0 -24
  10. package/lib/walletsync/root.d.ts.map +1 -1
  11. package/lib/walletsync/root.js +0 -2
  12. package/lib/walletsync/root.js.map +1 -1
  13. package/lib-es/store.d.ts +2 -15
  14. package/lib-es/store.d.ts.map +1 -1
  15. package/lib-es/store.js +1 -12
  16. package/lib-es/store.js.map +1 -1
  17. package/lib-es/walletsync/__mocks__/index.d.ts +1 -1
  18. package/lib-es/walletsync/__mocks__/index.d.ts.map +1 -1
  19. package/lib-es/walletsync/root.d.ts +0 -24
  20. package/lib-es/walletsync/root.d.ts.map +1 -1
  21. package/lib-es/walletsync/root.js +0 -2
  22. package/lib-es/walletsync/root.js.map +1 -1
  23. package/package.json +7 -7
  24. package/src/ordering.test.ts +0 -1
  25. package/src/store.test.ts +0 -2
  26. package/src/store.ts +2 -23
  27. package/src/walletsync/root.ts +0 -2
  28. package/lib/walletsync/__mocks__/modules/recentAddresses.d.ts +0 -8
  29. package/lib/walletsync/__mocks__/modules/recentAddresses.d.ts.map +0 -1
  30. package/lib/walletsync/__mocks__/modules/recentAddresses.js +0 -32
  31. package/lib/walletsync/__mocks__/modules/recentAddresses.js.map +0 -1
  32. package/lib/walletsync/modules/recentAddresses.d.ts +0 -47
  33. package/lib/walletsync/modules/recentAddresses.d.ts.map +0 -1
  34. package/lib/walletsync/modules/recentAddresses.js +0 -92
  35. package/lib/walletsync/modules/recentAddresses.js.map +0 -1
  36. package/lib-es/walletsync/__mocks__/modules/recentAddresses.d.ts +0 -8
  37. package/lib-es/walletsync/__mocks__/modules/recentAddresses.d.ts.map +0 -1
  38. package/lib-es/walletsync/__mocks__/modules/recentAddresses.js +0 -25
  39. package/lib-es/walletsync/__mocks__/modules/recentAddresses.js.map +0 -1
  40. package/lib-es/walletsync/modules/recentAddresses.d.ts +0 -47
  41. package/lib-es/walletsync/modules/recentAddresses.d.ts.map +0 -1
  42. package/lib-es/walletsync/modules/recentAddresses.js +0 -87
  43. package/lib-es/walletsync/modules/recentAddresses.js.map +0 -1
  44. package/src/walletsync/__mocks__/modules/recentAddresses.ts +0 -45
  45. package/src/walletsync/__tests__/modules/recentAddresses.test.ts +0 -487
  46. package/src/walletsync/modules/recentAddresses.ts +0 -125
@@ -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;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"}
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;AAElD,MAAM,OAAO,GAAG;IACd,QAAQ;IACR,YAAY;CACb,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.20251205111238",
3
+ "version": "0.16.1",
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.20251205111238",
32
- "@ledgerhq/live-env": "2.22.0-nightly.20251205111238",
33
- "@ledgerhq/cryptoassets": "13.34.0-nightly.20251205111238",
34
- "@ledgerhq/live-network": "2.1.2-nightly.20251205111238",
31
+ "@ledgerhq/coin-framework": "6.10.0",
32
+ "@ledgerhq/cryptoassets": "13.34.0",
33
+ "@ledgerhq/live-env": "2.22.0",
34
+ "@ledgerhq/live-network": "2.1.2",
35
35
  "@ledgerhq/live-promise": "0.1.1",
36
36
  "@ledgerhq/logs": "6.13.0",
37
- "@ledgerhq/ledger-key-ring-protocol": "0.8.0-nightly.20251205111238",
37
+ "@ledgerhq/ledger-key-ring-protocol": "0.8.0",
38
38
  "@ledgerhq/types-cryptoassets": "7.30.0",
39
- "@ledgerhq/types-live": "6.90.0-nightly.20251205111238"
39
+ "@ledgerhq/types-live": "6.90.0"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/jest": "^29.5.10",
@@ -100,7 +100,6 @@ const walletState: WalletState = {
100
100
  version: 0,
101
101
  },
102
102
  nonImportedAccountInfos: [],
103
- recentAddresses: {},
104
103
  };
105
104
 
106
105
  beforeAll(async () => {
package/src/store.test.ts CHANGED
@@ -246,7 +246,6 @@ describe("Wallet store", () => {
246
246
  accountNames: [],
247
247
  starredAccountIds: [],
248
248
  },
249
- recentAddresses: {},
250
249
  };
251
250
 
252
251
  it("allows partial wallet state", () => {
@@ -396,7 +395,6 @@ describe("Wallet store", () => {
396
395
  ? ["mock:1:ethereum:eth:", "mock:1:ethereum:eth:|0", "mock:1:ethereum:eth:|1"]
397
396
  : ["mock:1:ethereum:eth:"],
398
397
  },
399
- recentAddresses: {},
400
398
  });
401
399
  const stateImport2 = handlers.IMPORT_WALLET_SYNC(
402
400
  stateImport1,
package/src/store.ts CHANGED
@@ -3,13 +3,7 @@
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 {
7
- Account,
8
- AccountLike,
9
- AccountRaw,
10
- AccountUserData,
11
- RecentAddressesState,
12
- } from "@ledgerhq/types-live";
6
+ import { Account, AccountLike, AccountRaw, AccountUserData } from "@ledgerhq/types-live";
13
7
  import { getDefaultAccountName, getDefaultAccountNameForCurrencyIndex } from "./accountName";
14
8
  import { AddAccountsAction } from "./addAccounts";
15
9
  import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies";
@@ -32,7 +26,6 @@ export type WalletState = {
32
26
 
33
27
  // 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
34
28
  walletSyncState: WSState;
35
- recentAddresses: RecentAddressesState;
36
29
  };
37
30
 
38
31
  export type ExportedWalletState = {
@@ -42,7 +35,6 @@ export type ExportedWalletState = {
42
35
  accountNames: Array<[string, string]>;
43
36
  starredAccountIds: string[];
44
37
  };
45
- recentAddresses: RecentAddressesState;
46
38
  };
47
39
 
48
40
  export const initialState: WalletState = {
@@ -50,7 +42,6 @@ export const initialState: WalletState = {
50
42
  starredAccountIds: new Set(),
51
43
  nonImportedAccountInfos: [],
52
44
  walletSyncState: { data: null, version: 0 },
53
- recentAddresses: {},
54
45
  };
55
46
 
56
47
  export enum WalletHandlerType {
@@ -62,7 +53,6 @@ export enum WalletHandlerType {
62
53
  WALLET_SYNC_UPDATE = "WALLET_SYNC_UPDATE",
63
54
  IMPORT_WALLET_SYNC = "IMPORT_WALLET_SYNC",
64
55
  SET_NON_IMPORTED_ACCOUNTS = "SET_NON_IMPORTED_ACCOUNTS",
65
- UPDATE_RECENT_ADDRESSES = "UPDATE_RECENT_ADDRESSES",
66
56
  }
67
57
 
68
58
  export type HandlersPayloads = {
@@ -77,7 +67,6 @@ export type HandlersPayloads = {
77
67
  };
78
68
  IMPORT_WALLET_SYNC: Partial<ExportedWalletState>;
79
69
  SET_NON_IMPORTED_ACCOUNTS: NonImportedAccountInfo[];
80
- UPDATE_RECENT_ADDRESSES: RecentAddressesState;
81
70
  };
82
71
 
83
72
  type Handlers<State, Types, PreciseKey = true> = {
@@ -155,9 +144,6 @@ export const handlers: WalletHandlers = {
155
144
  SET_NON_IMPORTED_ACCOUNTS: (state, { payload }) => {
156
145
  return { ...state, nonImportedAccountInfos: payload };
157
146
  },
158
- UPDATE_RECENT_ADDRESSES: (state, { payload }) => {
159
- return { ...state, recentAddresses: { ...payload } };
160
- },
161
147
  };
162
148
 
163
149
  // actions
@@ -208,11 +194,6 @@ export const setNonImportedAccounts = (payload: NonImportedAccountInfo[]) => ({
208
194
  payload,
209
195
  });
210
196
 
211
- export const updateRecentAddresses = (payload: RecentAddressesState) => ({
212
- type: "UPDATE_RECENT_ADDRESSES",
213
- payload,
214
- });
215
-
216
197
  // Local Selectors
217
198
 
218
199
  export const accountNameSelector = (
@@ -281,7 +262,6 @@ export const exportWalletState = (state: WalletState): ExportedWalletState => ({
281
262
  accountNames: Array.from(state.accountNames),
282
263
  starredAccountIds: Array.from(state.starredAccountIds),
283
264
  },
284
- recentAddresses: state.recentAddresses,
285
265
  });
286
266
 
287
267
  export const walletStateExportShouldDiffer = (a: WalletState, b: WalletState): boolean => {
@@ -289,8 +269,7 @@ export const walletStateExportShouldDiffer = (a: WalletState, b: WalletState): b
289
269
  a.walletSyncState !== b.walletSyncState ||
290
270
  a.nonImportedAccountInfos !== b.nonImportedAccountInfos ||
291
271
  a.accountNames !== b.accountNames ||
292
- a.starredAccountIds !== b.starredAccountIds ||
293
- a.recentAddresses !== b.recentAddresses
272
+ a.starredAccountIds !== b.starredAccountIds
294
273
  );
295
274
  };
296
275
 
@@ -7,12 +7,10 @@ import { createAggregator } from "./aggregator";
7
7
 
8
8
  import accounts from "./modules/accounts";
9
9
  import accountNames from "./modules/accountNames";
10
- import recentAddresses from "./modules/recentAddresses";
11
10
 
12
11
  const modules = {
13
12
  accounts,
14
13
  accountNames,
15
- recentAddresses,
16
14
  };
17
15
 
18
16
  /**
@@ -1,8 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.similarLocalState = exports.convertDistantToLocalState = exports.convertLocalToDistantState = exports.genState = exports.emptyState = void 0;
4
- const recentAddresses_1 = require("../../modules/recentAddresses");
5
- exports.emptyState = {};
6
- const genState = (index) => {
7
- const recentAddressesState = {};
8
- for (let i = 0; i < index + 1; i++) {
9
- recentAddressesState["currency-" + i.toString()] = [];
10
- for (let j = 0; j < 12; j++) {
11
- recentAddressesState["currency-" + i.toString()].push(`some random address at index ${j}`);
12
- }
13
- }
14
- return recentAddressesState;
15
- };
16
- exports.genState = genState;
17
- const convertLocalToDistantState = (localState) => (0, recentAddresses_1.toDistantState)(localState);
18
- exports.convertLocalToDistantState = convertLocalToDistantState;
19
- const convertDistantToLocalState = (distantState) => (0, recentAddresses_1.toState)(distantState);
20
- exports.convertDistantToLocalState = convertDistantToLocalState;
21
- const similarLocalState = (state, otherState) => {
22
- const stateKeys = Object.keys(state);
23
- const otherStateKeys = Object.keys(otherState);
24
- return (stateKeys.length === otherStateKeys.length &&
25
- otherStateKeys.every(key => {
26
- return (state[key] &&
27
- state[key].length === otherState[key].length &&
28
- otherState[key].every(address => state[key].includes(address)));
29
- }));
30
- };
31
- exports.similarLocalState = similarLocalState;
32
- //# sourceMappingURL=recentAddresses.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"recentAddresses.js","sourceRoot":"","sources":["../../../../src/walletsync/__mocks__/modules/recentAddresses.ts"],"names":[],"mappings":";;;AACA,mEAIuC;AAE1B,QAAA,UAAU,GAAG,EAAE,CAAC;AAEtB,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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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
@@ -1 +0,0 @@
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"}
@@ -1,92 +0,0 @@
1
- "use strict";
2
- /**
3
- * @module recentAddresses
4
- *
5
- * This module is responsible for synchronizing recent addresses across Wallet instances
6
- * in the WalletSync system. It manages an ordered list of recently used addresses,
7
- * ensuring that when a user accesses an address on one Live instance, that address
8
- * (and its position in the recent list) is propagated to all other synchronized Live instances.
9
- *
10
- * Recent addresses are off-chain data (not stored on the blockchain), and therefore need to
11
- * be synchronized through the WalletSync system to ensure consistency across all Live instances.
12
- *
13
- * Key responsibilities:
14
- * - Tracks local recent address changes and prepares them for synchronization
15
- * - Resolves incoming recent address updates from other Live instances
16
- * - Maintains the order/index of addresses in the recent list
17
- * - Handles conflict resolution by accepting incoming state changes (last-write-wins strategy)
18
- * - Maintains consistency between local state (string[]) and distant state (RecentAddressesState[])
19
- *
20
- * The module preserves the index/position of each address, allowing the UI to maintain
21
- * a consistent ordering of recently used addresses across all synchronized Live instances.
22
- */
23
- Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.toState = exports.toDistantState = void 0;
25
- const zod_1 = require("zod");
26
- function toDistantState(addressesByCurrency) {
27
- const state = {};
28
- Object.keys(addressesByCurrency).forEach(key => {
29
- state[key] = addressesByCurrency[key].map((address, index) => ({ address, index }));
30
- });
31
- return state;
32
- }
33
- exports.toDistantState = toDistantState;
34
- function toState(addressesByCurrency) {
35
- const state = {};
36
- Object.keys(addressesByCurrency).forEach(key => {
37
- state[key] = addressesByCurrency[key]
38
- .sort((current, other) => current.index - other.index)
39
- .map(data => data.address);
40
- });
41
- return state;
42
- }
43
- exports.toState = toState;
44
- function sameDistantState(localData, distantState) {
45
- const localDataKeys = Object.keys(localData);
46
- const distantStateKeys = Object.keys(distantState);
47
- return (localDataKeys.length === distantStateKeys.length &&
48
- distantStateKeys.every(key => {
49
- return (localData[key] &&
50
- localData[key].length === distantState[key].length &&
51
- !distantState[key].some(data => data.index < 0 ||
52
- data.index >= localData[key].length ||
53
- localData[key][data.index] !== data.address));
54
- }));
55
- }
56
- const recentAddressesSchema = zod_1.z.object({
57
- address: zod_1.z.string(),
58
- index: zod_1.z.number(),
59
- });
60
- const schema = zod_1.z.record(zod_1.z.string(), zod_1.z.array(recentAddressesSchema));
61
- const manager = {
62
- schema,
63
- diffLocalToDistant(localData, latestState) {
64
- if (!sameDistantState(localData, latestState ?? {})) {
65
- return {
66
- hasChanges: true,
67
- nextState: toDistantState(localData),
68
- };
69
- }
70
- return {
71
- hasChanges: false,
72
- nextState: latestState ?? {},
73
- };
74
- },
75
- async resolveIncrementalUpdate(_ctx, localData, latestState, incomingState) {
76
- if (!incomingState) {
77
- return { hasChanges: false };
78
- }
79
- if (latestState === incomingState || sameDistantState(localData, incomingState)) {
80
- return { hasChanges: false };
81
- }
82
- return {
83
- hasChanges: true,
84
- update: toState(incomingState),
85
- };
86
- },
87
- applyUpdate(_localData, update) {
88
- return update;
89
- },
90
- };
91
- exports.default = manager;
92
- //# sourceMappingURL=recentAddresses.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"recentAddresses.js","sourceRoot":"","sources":["../../../src/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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,kBAAe,OAAO,CAAC"}
@@ -1,8 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,25 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,47 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,87 +0,0 @@
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
@@ -1 +0,0 @@
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,G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AE,MAAM;QAC5B,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1,45 +0,0 @@
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
- };