@ledgerhq/live-common 34.48.0-nightly.1 → 34.48.0-nightly.2

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 (179) hide show
  1. package/lib/bridge/crypto-assets/index.d.ts.map +1 -1
  2. package/lib/bridge/crypto-assets/index.js +0 -4
  3. package/lib/bridge/crypto-assets/index.js.map +1 -1
  4. package/lib/bridge/crypto-assets/index.test.js +0 -36
  5. package/lib/bridge/crypto-assets/index.test.js.map +1 -1
  6. package/lib/config/sharedConfig.d.ts.map +1 -1
  7. package/lib/config/sharedConfig.js +2 -0
  8. package/lib/config/sharedConfig.js.map +1 -1
  9. package/lib/e2e/index.d.ts +3 -4
  10. package/lib/e2e/index.d.ts.map +1 -1
  11. package/lib/env.react.d.ts +1 -1
  12. package/lib/env.react.d.ts.map +1 -1
  13. package/lib/families/canton/bridge/mock-data.d.ts +6 -0
  14. package/lib/families/canton/bridge/mock-data.d.ts.map +1 -0
  15. package/lib/families/canton/bridge/mock-data.js +120 -0
  16. package/lib/families/canton/bridge/mock-data.js.map +1 -0
  17. package/lib/families/canton/bridge/mock.d.ts +12 -0
  18. package/lib/families/canton/bridge/mock.d.ts.map +1 -0
  19. package/lib/families/canton/bridge/mock.js +154 -0
  20. package/lib/families/canton/bridge/mock.js.map +1 -0
  21. package/lib/families/canton/config.d.ts.map +1 -1
  22. package/lib/families/canton/config.js +5 -2
  23. package/lib/families/canton/config.js.map +1 -1
  24. package/lib/families/canton/setup.d.ts.map +1 -1
  25. package/lib/families/canton/setup.js +8 -2
  26. package/lib/families/canton/setup.js.map +1 -1
  27. package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
  28. package/lib/featureFlags/defaultFeatures.js +0 -1
  29. package/lib/featureFlags/defaultFeatures.js.map +1 -1
  30. package/lib/featureFlags/useFeature.d.ts +1 -1
  31. package/lib/featureFlags/useFeature.d.ts.map +1 -1
  32. package/lib/generated/bridge/mock.d.ts +8 -0
  33. package/lib/generated/bridge/mock.d.ts.map +1 -1
  34. package/lib/generated/bridge/mock.js +26 -24
  35. package/lib/generated/bridge/mock.js.map +1 -1
  36. package/lib/modularDrawer/hooks/useAssetsData.d.ts +1 -0
  37. package/lib/modularDrawer/hooks/useAssetsData.d.ts.map +1 -1
  38. package/lib/modularDrawer/hooks/useAssetsData.js +3 -2
  39. package/lib/modularDrawer/hooks/useAssetsData.js.map +1 -1
  40. package/lib/modularDrawer/hooks/useSearch.d.ts +16 -0
  41. package/lib/modularDrawer/hooks/useSearch.d.ts.map +1 -0
  42. package/lib/modularDrawer/hooks/useSearch.js +24 -0
  43. package/lib/modularDrawer/hooks/useSearch.js.map +1 -0
  44. package/lib/notifications/ServiceStatusProvider/index.d.ts +16 -1
  45. package/lib/notifications/ServiceStatusProvider/index.d.ts.map +1 -1
  46. package/lib/notifications/ServiceStatusProvider/index.js +31 -7
  47. package/lib/notifications/ServiceStatusProvider/index.js.map +1 -1
  48. package/lib/notifications/ServiceStatusProvider/index.test.d.ts +2 -0
  49. package/lib/notifications/ServiceStatusProvider/index.test.d.ts.map +1 -0
  50. package/lib/notifications/ServiceStatusProvider/index.test.js +88 -0
  51. package/lib/notifications/ServiceStatusProvider/index.test.js.map +1 -0
  52. package/lib/notifications/ServiceStatusProvider/ledger-components.d.ts +2 -0
  53. package/lib/notifications/ServiceStatusProvider/ledger-components.d.ts.map +1 -0
  54. package/lib/notifications/ServiceStatusProvider/ledger-components.js +16 -0
  55. package/lib/notifications/ServiceStatusProvider/ledger-components.js.map +1 -0
  56. package/lib/wallet-api/ACRE/server.d.ts +13 -6
  57. package/lib/wallet-api/ACRE/server.d.ts.map +1 -1
  58. package/lib/wallet-api/ACRE/server.js +142 -1
  59. package/lib/wallet-api/ACRE/server.js.map +1 -1
  60. package/lib/wallet-api/ACRE/server.test.d.ts +2 -0
  61. package/lib/wallet-api/ACRE/server.test.d.ts.map +1 -0
  62. package/lib/wallet-api/ACRE/server.test.js +393 -0
  63. package/lib/wallet-api/ACRE/server.test.js.map +1 -0
  64. package/lib-es/bridge/crypto-assets/index.d.ts.map +1 -1
  65. package/lib-es/bridge/crypto-assets/index.js +0 -4
  66. package/lib-es/bridge/crypto-assets/index.js.map +1 -1
  67. package/lib-es/bridge/crypto-assets/index.test.js +0 -36
  68. package/lib-es/bridge/crypto-assets/index.test.js.map +1 -1
  69. package/lib-es/config/sharedConfig.d.ts.map +1 -1
  70. package/lib-es/config/sharedConfig.js +2 -0
  71. package/lib-es/config/sharedConfig.js.map +1 -1
  72. package/lib-es/e2e/index.d.ts +3 -4
  73. package/lib-es/e2e/index.d.ts.map +1 -1
  74. package/lib-es/env.react.d.ts +1 -1
  75. package/lib-es/env.react.d.ts.map +1 -1
  76. package/lib-es/families/canton/bridge/mock-data.d.ts +6 -0
  77. package/lib-es/families/canton/bridge/mock-data.d.ts.map +1 -0
  78. package/lib-es/families/canton/bridge/mock-data.js +116 -0
  79. package/lib-es/families/canton/bridge/mock-data.js.map +1 -0
  80. package/lib-es/families/canton/bridge/mock.d.ts +12 -0
  81. package/lib-es/families/canton/bridge/mock.d.ts.map +1 -0
  82. package/lib-es/families/canton/bridge/mock.js +152 -0
  83. package/lib-es/families/canton/bridge/mock.js.map +1 -0
  84. package/lib-es/families/canton/config.d.ts.map +1 -1
  85. package/lib-es/families/canton/config.js +5 -2
  86. package/lib-es/families/canton/config.js.map +1 -1
  87. package/lib-es/families/canton/setup.d.ts.map +1 -1
  88. package/lib-es/families/canton/setup.js +8 -2
  89. package/lib-es/families/canton/setup.js.map +1 -1
  90. package/lib-es/featureFlags/defaultFeatures.d.ts.map +1 -1
  91. package/lib-es/featureFlags/defaultFeatures.js +0 -1
  92. package/lib-es/featureFlags/defaultFeatures.js.map +1 -1
  93. package/lib-es/featureFlags/useFeature.d.ts +1 -1
  94. package/lib-es/featureFlags/useFeature.d.ts.map +1 -1
  95. package/lib-es/generated/bridge/mock.d.ts +8 -0
  96. package/lib-es/generated/bridge/mock.d.ts.map +1 -1
  97. package/lib-es/generated/bridge/mock.js +2 -0
  98. package/lib-es/generated/bridge/mock.js.map +1 -1
  99. package/lib-es/modularDrawer/hooks/useAssetsData.d.ts +1 -0
  100. package/lib-es/modularDrawer/hooks/useAssetsData.d.ts.map +1 -1
  101. package/lib-es/modularDrawer/hooks/useAssetsData.js +3 -2
  102. package/lib-es/modularDrawer/hooks/useAssetsData.js.map +1 -1
  103. package/lib-es/modularDrawer/hooks/useSearch.d.ts +16 -0
  104. package/lib-es/modularDrawer/hooks/useSearch.d.ts.map +1 -0
  105. package/lib-es/modularDrawer/hooks/useSearch.js +20 -0
  106. package/lib-es/modularDrawer/hooks/useSearch.js.map +1 -0
  107. package/lib-es/notifications/ServiceStatusProvider/index.d.ts +16 -1
  108. package/lib-es/notifications/ServiceStatusProvider/index.d.ts.map +1 -1
  109. package/lib-es/notifications/ServiceStatusProvider/index.js +31 -7
  110. package/lib-es/notifications/ServiceStatusProvider/index.js.map +1 -1
  111. package/lib-es/notifications/ServiceStatusProvider/index.test.d.ts +2 -0
  112. package/lib-es/notifications/ServiceStatusProvider/index.test.d.ts.map +1 -0
  113. package/lib-es/notifications/ServiceStatusProvider/index.test.js +86 -0
  114. package/lib-es/notifications/ServiceStatusProvider/index.test.js.map +1 -0
  115. package/lib-es/notifications/ServiceStatusProvider/ledger-components.d.ts +2 -0
  116. package/lib-es/notifications/ServiceStatusProvider/ledger-components.d.ts.map +1 -0
  117. package/lib-es/notifications/ServiceStatusProvider/ledger-components.js +13 -0
  118. package/lib-es/notifications/ServiceStatusProvider/ledger-components.js.map +1 -0
  119. package/lib-es/wallet-api/ACRE/server.d.ts +13 -6
  120. package/lib-es/wallet-api/ACRE/server.d.ts.map +1 -1
  121. package/lib-es/wallet-api/ACRE/server.js +140 -2
  122. package/lib-es/wallet-api/ACRE/server.js.map +1 -1
  123. package/lib-es/wallet-api/ACRE/server.test.d.ts +2 -0
  124. package/lib-es/wallet-api/ACRE/server.test.d.ts.map +1 -0
  125. package/lib-es/wallet-api/ACRE/server.test.js +388 -0
  126. package/lib-es/wallet-api/ACRE/server.test.js.map +1 -0
  127. package/package.json +48 -48
  128. package/src/bridge/crypto-assets/index.test.ts +0 -47
  129. package/src/bridge/crypto-assets/index.ts +0 -5
  130. package/src/config/sharedConfig.ts +2 -0
  131. package/src/families/canton/bridge/mock-data.ts +175 -0
  132. package/src/families/canton/bridge/mock.ts +180 -0
  133. package/src/families/canton/config.ts +5 -3
  134. package/src/families/canton/setup.ts +8 -5
  135. package/src/featureFlags/defaultFeatures.ts +0 -1
  136. package/src/generated/bridge/mock.ts +2 -0
  137. package/src/modularDrawer/hooks/useAssetsData.ts +3 -2
  138. package/src/modularDrawer/hooks/useSearch.ts +52 -0
  139. package/src/notifications/ServiceStatusProvider/index.test.ts +102 -0
  140. package/src/notifications/ServiceStatusProvider/index.tsx +37 -12
  141. package/src/notifications/ServiceStatusProvider/ledger-components.ts +12 -0
  142. package/src/wallet-api/ACRE/server.test.ts +470 -0
  143. package/src/wallet-api/ACRE/server.ts +202 -14
  144. package/lib/bridge/crypto-assets/cal-integration.d.ts +0 -4
  145. package/lib/bridge/crypto-assets/cal-integration.d.ts.map +0 -1
  146. package/lib/bridge/crypto-assets/cal-integration.js +0 -26
  147. package/lib/bridge/crypto-assets/cal-integration.js.map +0 -1
  148. package/lib/bridge/crypto-assets/cal-integration.test.d.ts +0 -2
  149. package/lib/bridge/crypto-assets/cal-integration.test.d.ts.map +0 -1
  150. package/lib/bridge/crypto-assets/cal-integration.test.js +0 -45
  151. package/lib/bridge/crypto-assets/cal-integration.test.js.map +0 -1
  152. package/lib/bridge/crypto-assets/cal-store.d.ts +0 -14
  153. package/lib/bridge/crypto-assets/cal-store.d.ts.map +0 -1
  154. package/lib/bridge/crypto-assets/cal-store.js +0 -58
  155. package/lib/bridge/crypto-assets/cal-store.js.map +0 -1
  156. package/lib/bridge/crypto-assets/cal-store.test.d.ts +0 -2
  157. package/lib/bridge/crypto-assets/cal-store.test.d.ts.map +0 -1
  158. package/lib/bridge/crypto-assets/cal-store.test.js +0 -70
  159. package/lib/bridge/crypto-assets/cal-store.test.js.map +0 -1
  160. package/lib-es/bridge/crypto-assets/cal-integration.d.ts +0 -4
  161. package/lib-es/bridge/crypto-assets/cal-integration.d.ts.map +0 -1
  162. package/lib-es/bridge/crypto-assets/cal-integration.js +0 -21
  163. package/lib-es/bridge/crypto-assets/cal-integration.js.map +0 -1
  164. package/lib-es/bridge/crypto-assets/cal-integration.test.d.ts +0 -2
  165. package/lib-es/bridge/crypto-assets/cal-integration.test.d.ts.map +0 -1
  166. package/lib-es/bridge/crypto-assets/cal-integration.test.js +0 -43
  167. package/lib-es/bridge/crypto-assets/cal-integration.test.js.map +0 -1
  168. package/lib-es/bridge/crypto-assets/cal-store.d.ts +0 -14
  169. package/lib-es/bridge/crypto-assets/cal-store.d.ts.map +0 -1
  170. package/lib-es/bridge/crypto-assets/cal-store.js +0 -54
  171. package/lib-es/bridge/crypto-assets/cal-store.js.map +0 -1
  172. package/lib-es/bridge/crypto-assets/cal-store.test.d.ts +0 -2
  173. package/lib-es/bridge/crypto-assets/cal-store.test.d.ts.map +0 -1
  174. package/lib-es/bridge/crypto-assets/cal-store.test.js +0 -68
  175. package/lib-es/bridge/crypto-assets/cal-store.test.js.map +0 -1
  176. package/src/bridge/crypto-assets/cal-integration.test.ts +0 -53
  177. package/src/bridge/crypto-assets/cal-integration.ts +0 -23
  178. package/src/bridge/crypto-assets/cal-store.test.ts +0 -93
  179. package/src/bridge/crypto-assets/cal-store.ts +0 -63
@@ -8,7 +8,8 @@ import {
8
8
  isTokenAccount,
9
9
  } from "@ledgerhq/coin-framework/account/index";
10
10
  import { Account, AccountLike, AnyMessage, Operation, SignedOperation } from "@ledgerhq/types-live";
11
- import { findTokenById } from "@ledgerhq/cryptoassets";
11
+ import { findTokenById, findTokenByAddressInCurrency } from "@ledgerhq/cryptoassets";
12
+ import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies";
12
13
  import {
13
14
  MessageSignParams,
14
15
  MessageSignResult,
@@ -18,17 +19,21 @@ import {
18
19
  TransactionSignAndBroadcastResult,
19
20
  TransactionSignParams,
20
21
  TransactionSignResult,
22
+ RegisterYieldBearingEthereumAddressParams,
23
+ RegisterYieldBearingEthereumAddressResult,
21
24
  } from "@ledgerhq/wallet-api-acre-module";
22
- import { TrackingAPI } from "./tracking";
25
+ import { Transaction } from "../../generated/types";
23
26
  import { AppManifest } from "../types";
27
+ import { TrackingAPI } from "./tracking";
24
28
  import {
25
29
  getAccountIdFromWalletAccountId,
26
30
  getWalletAPITransactionSignFlowInfos,
27
31
  } from "../converters";
28
32
  import { getAccountBridge } from "../../bridge";
29
- import { Transaction } from "../../generated/types";
30
33
  import { UserRefusedOnDevice } from "@ledgerhq/errors";
31
34
  import { getEnv } from "@ledgerhq/live-env";
35
+ import BigNumber from "bignumber.js";
36
+ import { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";
32
37
 
33
38
  type Handlers = {
34
39
  "custom.acre.messageSign": RPCHandler<MessageSignResult, MessageSignParams>;
@@ -37,9 +42,13 @@ type Handlers = {
37
42
  TransactionSignAndBroadcastResult,
38
43
  TransactionSignAndBroadcastParams
39
44
  >;
45
+ "custom.acre.registerYieldBearingEthereumAddress": RPCHandler<
46
+ RegisterYieldBearingEthereumAddressResult,
47
+ RegisterYieldBearingEthereumAddressParams
48
+ >;
40
49
  };
41
50
 
42
- type ACREUiHooks = {
51
+ export type ACREUiHooks = {
43
52
  "custom.acre.messageSign": (params: {
44
53
  account: AccountLike;
45
54
  message: AnyMessage;
@@ -66,8 +75,117 @@ type ACREUiHooks = {
66
75
  mainAccount: Account,
67
76
  optimisticOperation: Operation,
68
77
  ) => void;
78
+ "custom.acre.registerAccount": (params: {
79
+ parentAccount: Account;
80
+ accountName: string;
81
+ existingAccounts: Account[];
82
+ onSuccess: () => void;
83
+ onError: (error: Error) => void;
84
+ }) => void;
69
85
  };
70
86
 
87
+ // Helper function to validate Ethereum address format
88
+ function isValidEthereumAddress(address: string): boolean {
89
+ return /^0x[a-fA-F0-9]{40}$/.test(address);
90
+ }
91
+
92
+ // Helper function to validate all inputs before account creation
93
+ function validateInputs(params: RegisterYieldBearingEthereumAddressParams): {
94
+ ethereumAddress: string;
95
+ tokenContractAddress?: string;
96
+ tokenTicker?: string;
97
+ meta?: Record<string, unknown>;
98
+ } {
99
+ const { ethereumAddress, tokenContractAddress, tokenTicker, meta } = params;
100
+
101
+ // Validate Ethereum address format
102
+ if (!ethereumAddress) {
103
+ throw new Error("Ethereum address is required");
104
+ }
105
+ if (!isValidEthereumAddress(ethereumAddress)) {
106
+ throw new Error("Invalid Ethereum address format");
107
+ }
108
+
109
+ // Validate that at least one token identifier is provided
110
+ if (!tokenContractAddress && !tokenTicker) {
111
+ throw new Error("Either tokenContractAddress or tokenTicker must be provided");
112
+ }
113
+
114
+ return { ethereumAddress, tokenContractAddress, tokenTicker, meta };
115
+ }
116
+
117
+ // Helper function to find acreToken by address or token id
118
+ function findAcreToken(
119
+ tokenContractAddress?: string,
120
+ tokenTicker?: string,
121
+ ): { token: TokenCurrency; contractAddress: string } {
122
+ let foundToken: TokenCurrency | undefined;
123
+ // Try to find token by contract address first (if provided)
124
+ if (tokenContractAddress) {
125
+ foundToken = findTokenByAddressInCurrency(tokenContractAddress, "ethereum");
126
+ } else if (tokenTicker) {
127
+ foundToken = findTokenById(tokenTicker.toLowerCase());
128
+ }
129
+ if (!foundToken) {
130
+ throw new Error(
131
+ `Token not found. Tried contract address: ${tokenContractAddress || "not provided"}, ticker: ${tokenTicker || "not provided"}`,
132
+ );
133
+ }
134
+ return { token: foundToken, contractAddress: foundToken.contractAddress };
135
+ }
136
+
137
+ // Helper function to generate unique account names with suffixes
138
+ // This is clearly a hack as we do not have account name on Account type, we leverage on how many accounts have acreBTC as token sub account to define the name
139
+ // This is made to help user to identify different ACRE account but not resilient to token account being wiped, emptied
140
+ // (empty subAccount would not been included in the list therefore parent account not considered as an acre account anymore).
141
+ function generateUniqueAccountName(
142
+ existingAccounts: Account[],
143
+ baseName: string,
144
+ tokenAddress: string,
145
+ ): string {
146
+ const existingAccountWithAcreToken = existingAccounts.flatMap(
147
+ account =>
148
+ account.subAccounts?.filter(
149
+ subAccount => subAccount.token.contractAddress.toLowerCase() === tokenAddress.toLowerCase(),
150
+ ) || [],
151
+ );
152
+ return existingAccountWithAcreToken.length > 0
153
+ ? `${baseName} ${existingAccountWithAcreToken.length}`
154
+ : baseName;
155
+ }
156
+
157
+ // Helper function to create parent Ethereum account
158
+ function createParentAccount(ethereumAddress: string, ethereumCurrency: CryptoCurrency): Account {
159
+ return {
160
+ type: "Account" as const,
161
+ id: `js:2:ethereum:${ethereumAddress}:`,
162
+ seedIdentifier: `04${ethereumAddress.slice(2)}`,
163
+ derivationMode: "" as any,
164
+ index: 0,
165
+ freshAddress: ethereumAddress,
166
+ freshAddressPath: "44'/60'/0'/0/0",
167
+ used: false,
168
+ blockHeight: 0,
169
+ creationDate: new Date(),
170
+ balance: new BigNumber(0),
171
+ spendableBalance: new BigNumber(0),
172
+ operationsCount: 0,
173
+ operations: [],
174
+ pendingOperations: [],
175
+ currency: ethereumCurrency,
176
+ lastSyncDate: new Date(),
177
+ swapHistory: [],
178
+ balanceHistoryCache: {
179
+ HOUR: { latestDate: Date.now(), balances: [] },
180
+ DAY: { latestDate: Date.now(), balances: [] },
181
+ WEEK: { latestDate: Date.now(), balances: [] },
182
+ },
183
+ syncHash: "0x00000000", // Use proper hash format
184
+ subAccounts: [], // Add empty subAccounts array
185
+ nfts: [],
186
+ };
187
+ }
188
+
71
189
  export const handlers = ({
72
190
  accounts,
73
191
  tracking,
@@ -76,6 +194,7 @@ export const handlers = ({
76
194
  "custom.acre.messageSign": uiMessageSign,
77
195
  "custom.acre.transactionSign": uiTransactionSign,
78
196
  "custom.acre.transactionBroadcast": uiTransactionBroadcast,
197
+ "custom.acre.registerAccount": uiRegisterAccount,
79
198
  },
80
199
  }: {
81
200
  accounts: AccountLike[];
@@ -92,20 +211,16 @@ export const handlers = ({
92
211
  const transaction = deserializeTransaction(rawTransaction);
93
212
 
94
213
  tracking.signTransactionRequested(manifest);
95
-
96
214
  if (!transaction) {
97
215
  tracking.signTransactionFail(manifest);
98
216
  return Promise.reject(new Error("Transaction required"));
99
217
  }
100
-
101
218
  const accountId = getAccountIdFromWalletAccountId(walletAccountId);
102
219
  if (!accountId) {
103
220
  tracking.signTransactionFail(manifest);
104
221
  return Promise.reject(new Error(`accountId ${walletAccountId} unknown`));
105
222
  }
106
-
107
223
  const account = accounts.find(account => account.id === accountId);
108
-
109
224
  if (!account) {
110
225
  tracking.signTransactionFail(manifest);
111
226
  return Promise.reject(new Error("Account required"));
@@ -120,7 +235,6 @@ export const handlers = ({
120
235
  const mainAccount = getMainAccount(account, parentAccount);
121
236
  const currency = tokenCurrency ? findTokenById(tokenCurrency) : null;
122
237
  const signerAccount = currency ? makeEmptyTokenAccount(mainAccount, currency) : account;
123
-
124
238
  const { canEditFees, liveTx, hasFeesProvided } = getWalletAPITransactionSignFlowInfos({
125
239
  walletApiTransaction: transaction,
126
240
  account,
@@ -162,7 +276,6 @@ export const handlers = ({
162
276
  });
163
277
  });
164
278
  }
165
-
166
279
  return {
167
280
  "custom.acre.messageSign": customWrapper<MessageSignParams, MessageSignResult>(async params => {
168
281
  if (!params) {
@@ -275,7 +388,6 @@ export const handlers = ({
275
388
  const broadcastAccount = getMainAccount(signerAccount, parentAccount);
276
389
 
277
390
  let optimisticOperation: Operation = signedOperation.operation;
278
-
279
391
  if (!getEnv("DISABLE_TRANSACTION_BROADCAST")) {
280
392
  try {
281
393
  optimisticOperation = await bridge.broadcast({
@@ -288,17 +400,93 @@ export const handlers = ({
288
400
  throw error;
289
401
  }
290
402
  }
291
-
292
403
  uiTransactionBroadcast &&
293
404
  uiTransactionBroadcast(account, parentAccount, mainAccount, optimisticOperation);
294
-
295
405
  return {
296
406
  transactionHash: optimisticOperation.hash,
297
407
  };
298
408
  }),
409
+ "custom.acre.registerYieldBearingEthereumAddress": customWrapper<
410
+ RegisterYieldBearingEthereumAddressParams,
411
+ RegisterYieldBearingEthereumAddressResult
412
+ >(async params => {
413
+ if (!params) {
414
+ return Promise.reject(new Error("Parameters required"));
415
+ }
416
+ const validatedInputs = validateInputs(params);
417
+ const ethereumCurrency = getCryptoCurrencyById("ethereum");
418
+ const { token: existingToken, contractAddress: finalTokenContractAddress } = findAcreToken(
419
+ validatedInputs.tokenContractAddress,
420
+ validatedInputs.tokenTicker,
421
+ );
422
+ const existingBearingAccount = accounts.find(
423
+ account =>
424
+ "freshAddress" in account &&
425
+ (account as any).freshAddress === validatedInputs.ethereumAddress,
426
+ );
427
+ const baseName = "Yield-bearing BTC on ACRE";
428
+ // Account already added, skip registration.
429
+ if (existingBearingAccount) {
430
+ return {
431
+ success: true,
432
+ accountName: baseName,
433
+ parentAccountId: existingBearingAccount.id,
434
+ tokenAccountId: existingBearingAccount.id,
435
+ ethereumAddress: validatedInputs.ethereumAddress,
436
+ tokenContractAddress: finalTokenContractAddress,
437
+ meta: validatedInputs.meta,
438
+ };
439
+ }
440
+
441
+ if (uiRegisterAccount) {
442
+ // Create account & manage the case where an ACRE account has been already registered on another Ethereum address
443
+ // Filter to have only root accounts
444
+ const existingParentAccounts = accounts.filter(
445
+ (acc): acc is Account => acc.type === "Account",
446
+ );
447
+ const accountName = generateUniqueAccountName(
448
+ existingParentAccounts,
449
+ baseName,
450
+ finalTokenContractAddress,
451
+ );
452
+ const parentAccount = createParentAccount(
453
+ validatedInputs.ethereumAddress,
454
+ ethereumCurrency,
455
+ );
456
+ const tokenAccount = makeEmptyTokenAccount(parentAccount, existingToken);
457
+ // Add token account as sub-account of parent account
458
+ const parentAccountWithSubAccount = {
459
+ ...parentAccount,
460
+ subAccounts: [tokenAccount],
461
+ };
462
+
463
+ return new Promise((resolve, reject) => {
464
+ uiRegisterAccount({
465
+ parentAccount: parentAccountWithSubAccount,
466
+ accountName,
467
+ existingAccounts: existingParentAccounts,
468
+ onSuccess: () => {
469
+ resolve({
470
+ success: true,
471
+ accountName,
472
+ parentAccountId: parentAccountWithSubAccount.id,
473
+ tokenAccountId: tokenAccount.id,
474
+ ethereumAddress: validatedInputs.ethereumAddress,
475
+ tokenContractAddress: finalTokenContractAddress,
476
+ meta: validatedInputs.meta,
477
+ });
478
+ },
479
+ onError: error => {
480
+ reject(error);
481
+ },
482
+ });
483
+ });
484
+ } else {
485
+ throw new Error("No account registration UI hook available");
486
+ }
487
+ }),
299
488
  } as const satisfies Handlers;
300
489
  };
301
-
302
490
  function fromRelativePath(basePath: string, derivationPath?: string) {
303
491
  if (!derivationPath) {
304
492
  return basePath;
@@ -1,4 +0,0 @@
1
- import type { CryptoAssetsStore } from "@ledgerhq/types-live";
2
- export declare function isCALIntegrationEnabled(): boolean;
3
- export declare function getCALStore(): CryptoAssetsStore;
4
- //# sourceMappingURL=cal-integration.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cal-integration.d.ts","sourceRoot":"","sources":["../../../src/bridge/crypto-assets/cal-integration.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAM9D,wBAAgB,uBAAuB,IAAI,OAAO,CAOjD;AAED,wBAAgB,WAAW,IAAI,iBAAiB,CAK/C"}
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCALStore = exports.isCALIntegrationEnabled = void 0;
4
- const live_env_1 = require("@ledgerhq/live-env");
5
- const logs_1 = require("@ledgerhq/logs");
6
- const cal_store_1 = require("./cal-store");
7
- const firebaseFeatureFlags_1 = require("../../featureFlags/firebaseFeatureFlags");
8
- let calStoreInstance;
9
- function isCALIntegrationEnabled() {
10
- try {
11
- return !(0, live_env_1.getEnv)("MOCK") && (0, firebaseFeatureFlags_1.isFeature)("calLedgerService");
12
- }
13
- catch (error) {
14
- (0, logs_1.log)("cal", "Error checking CAL integration:", error);
15
- return false;
16
- }
17
- }
18
- exports.isCALIntegrationEnabled = isCALIntegrationEnabled;
19
- function getCALStore() {
20
- if (!calStoreInstance) {
21
- calStoreInstance = new cal_store_1.CALStore();
22
- }
23
- return calStoreInstance;
24
- }
25
- exports.getCALStore = getCALStore;
26
- //# sourceMappingURL=cal-integration.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cal-integration.js","sourceRoot":"","sources":["../../../src/bridge/crypto-assets/cal-integration.ts"],"names":[],"mappings":";;;AAAA,iDAA4C;AAC5C,yCAAqC;AAErC,2CAAuC;AACvC,kFAAoE;AAEpE,IAAI,gBAAsC,CAAC;AAE3C,SAAgB,uBAAuB;IACrC,IAAI;QACF,OAAO,CAAC,IAAA,iBAAM,EAAC,MAAM,CAAC,IAAI,IAAA,gCAAS,EAAC,kBAAkB,CAAC,CAAC;KACzD;IAAC,OAAO,KAAK,EAAE;QACd,IAAA,UAAG,EAAC,KAAK,EAAE,iCAAiC,EAAE,KAAK,CAAC,CAAC;QACrD,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AAPD,0DAOC;AAED,SAAgB,WAAW;IACzB,IAAI,CAAC,gBAAgB,EAAE;QACrB,gBAAgB,GAAG,IAAI,oBAAQ,EAAE,CAAC;KACnC;IACD,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AALD,kCAKC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=cal-integration.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cal-integration.test.d.ts","sourceRoot":"","sources":["../../../src/bridge/crypto-assets/cal-integration.test.ts"],"names":[],"mappings":""}
@@ -1,45 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const cal_integration_1 = require("./cal-integration");
4
- const cal_store_1 = require("./cal-store");
5
- const firebaseFeatureFlags_1 = require("../../featureFlags/firebaseFeatureFlags");
6
- jest.mock("../../featureFlags/firebaseFeatureFlags", () => ({
7
- isFeature: jest.fn(),
8
- }));
9
- const mockIsFeature = jest.mocked(firebaseFeatureFlags_1.isFeature);
10
- describe("CAL Integration", () => {
11
- beforeEach(() => {
12
- mockIsFeature.mockClear();
13
- });
14
- describe("isCALIntegrationEnabled", () => {
15
- it("should return false when feature flag is disabled", () => {
16
- mockIsFeature.mockReturnValue(false);
17
- expect((0, cal_integration_1.isCALIntegrationEnabled)()).toBe(false);
18
- expect(mockIsFeature).toHaveBeenCalledWith("calLedgerService");
19
- });
20
- it("should return true when feature flag is enabled (assuming MOCK is false)", () => {
21
- mockIsFeature.mockReturnValue(true);
22
- const result = (0, cal_integration_1.isCALIntegrationEnabled)();
23
- expect(mockIsFeature).toHaveBeenCalledWith("calLedgerService");
24
- expect(result).toEqual(true);
25
- });
26
- it("should return false when feature check throws", () => {
27
- mockIsFeature.mockImplementation(() => {
28
- throw new Error("Feature check error");
29
- });
30
- expect((0, cal_integration_1.isCALIntegrationEnabled)()).toBe(false);
31
- });
32
- });
33
- describe("getCALStore", () => {
34
- it("should return a CALStore instance", () => {
35
- const store = (0, cal_integration_1.getCALStore)();
36
- expect(store).toBeInstanceOf(cal_store_1.CALStore);
37
- });
38
- it("should return the same instance on multiple calls", () => {
39
- const store1 = (0, cal_integration_1.getCALStore)();
40
- const store2 = (0, cal_integration_1.getCALStore)();
41
- expect(store1).toBe(store2);
42
- });
43
- });
44
- });
45
- //# sourceMappingURL=cal-integration.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cal-integration.test.js","sourceRoot":"","sources":["../../../src/bridge/crypto-assets/cal-integration.test.ts"],"names":[],"mappings":";;AAAA,uDAAyE;AACzE,2CAAuC;AACvC,kFAAoE;AAEpE,IAAI,CAAC,IAAI,CAAC,yCAAyC,EAAE,GAAG,EAAE,CAAC,CAAC;IAC1D,SAAS,EAAE,IAAI,CAAC,EAAE,EAAE;CACrB,CAAC,CAAC,CAAC;AAEJ,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,gCAAS,CAAC,CAAC;AAE7C,QAAQ,CAAC,iBAA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,CAAC;QACzC,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,mDAAmD,EAAE,GAAG,EAAE;YAC3D,MAAM,MAAM,GAAG,IAAA,6BAAW,GAAE,CAAC;YAC7B,MAAM,MAAM,GAAG,IAAA,6BAAW,GAAE,CAAC;YAC7B,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC9B,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,14 +0,0 @@
1
- import type { CryptoAssetsStore } from "@ledgerhq/types-live";
2
- import { TokenCurrency } from "@ledgerhq/types-cryptoassets";
3
- export declare class CALStore implements CryptoAssetsStore {
4
- private tokenCache;
5
- private addressCache;
6
- private tickerCache;
7
- addTokens(tokens: TokenCurrency[]): void;
8
- findTokenByAddress(address: string): TokenCurrency | undefined;
9
- getTokenById(id: string): TokenCurrency;
10
- findTokenById(id: string): TokenCurrency | undefined;
11
- findTokenByAddressInCurrency(address: string, currencyId: string): TokenCurrency | undefined;
12
- findTokenByTicker(ticker: string): TokenCurrency | undefined;
13
- }
14
- //# sourceMappingURL=cal-store.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cal-store.d.ts","sourceRoot":"","sources":["../../../src/bridge/crypto-assets/cal-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAK7D,qBAAa,QAAS,YAAW,iBAAiB;IAChD,OAAO,CAAC,UAAU,CAAoC;IACtD,OAAO,CAAC,YAAY,CAAoC;IACxD,OAAO,CAAC,WAAW,CAAoC;IAEvD,SAAS,CAAC,MAAM,EAAE,aAAa,EAAE;IAcjC,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAQ9D,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,aAAa;IAQvC,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAIpD,4BAA4B,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAc5F,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;CAG7D"}
@@ -1,58 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CALStore = void 0;
4
- // Coins with case-sensitive addresses (b58, ...)
5
- const CASE_SENSITIVE_COINS = ["solana"];
6
- class CALStore {
7
- tokenCache = new Map();
8
- addressCache = new Map();
9
- tickerCache = new Map();
10
- addTokens(tokens) {
11
- tokens.forEach(token => {
12
- this.tokenCache.set(token.id, token);
13
- if (token.contractAddress) {
14
- const isCaseSensitive = CASE_SENSITIVE_COINS.includes(token.parentCurrency.id);
15
- const normalizedAddress = isCaseSensitive
16
- ? token.contractAddress
17
- : token.contractAddress.toLowerCase();
18
- this.addressCache.set(normalizedAddress, token);
19
- }
20
- this.tickerCache.set(token.ticker, token);
21
- });
22
- }
23
- findTokenByAddress(address) {
24
- const exactMatch = this.addressCache.get(address);
25
- if (exactMatch)
26
- return exactMatch;
27
- const lowercaseMatch = this.addressCache.get(address.toLowerCase());
28
- return lowercaseMatch;
29
- }
30
- getTokenById(id) {
31
- const token = this.tokenCache.get(id);
32
- if (!token) {
33
- throw new Error(`Token not found: ${id}`);
34
- }
35
- return token;
36
- }
37
- findTokenById(id) {
38
- return this.tokenCache.get(id);
39
- }
40
- findTokenByAddressInCurrency(address, currencyId) {
41
- const isCaseSensitive = CASE_SENSITIVE_COINS.includes(currencyId);
42
- if (isCaseSensitive) {
43
- const token = this.addressCache.get(address);
44
- if (token && token.parentCurrency.id === currencyId)
45
- return token;
46
- return undefined;
47
- }
48
- const token = this.addressCache.get(address.toLowerCase());
49
- if (token && token.parentCurrency.id === currencyId)
50
- return token;
51
- return undefined;
52
- }
53
- findTokenByTicker(ticker) {
54
- return this.tickerCache.get(ticker);
55
- }
56
- }
57
- exports.CALStore = CALStore;
58
- //# sourceMappingURL=cal-store.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cal-store.js","sourceRoot":"","sources":["../../../src/bridge/crypto-assets/cal-store.ts"],"names":[],"mappings":";;;AAGA,iDAAiD;AACjD,MAAM,oBAAoB,GAAG,CAAC,QAAQ,CAAC,CAAC;AAExC,MAAa,QAAQ;IACX,UAAU,GAAG,IAAI,GAAG,EAAyB,CAAC;IAC9C,YAAY,GAAG,IAAI,GAAG,EAAyB,CAAC;IAChD,WAAW,GAAG,IAAI,GAAG,EAAyB,CAAC;IAEvD,SAAS,CAAC,MAAuB;QAC/B,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YACrB,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;YACrC,IAAI,KAAK,CAAC,eAAe,EAAE;gBACzB,MAAM,eAAe,GAAG,oBAAoB,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;gBAC/E,MAAM,iBAAiB,GAAG,eAAe;oBACvC,CAAC,CAAC,KAAK,CAAC,eAAe;oBACvB,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC,WAAW,EAAE,CAAC;gBACxC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC;aACjD;YACD,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;IACL,CAAC;IAED,kBAAkB,CAAC,OAAe;QAChC,MAAM,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAClD,IAAI,UAAU;YAAE,OAAO,UAAU,CAAC;QAElC,MAAM,cAAc,GAAG,IAAI,CAAC,YAAY,CAA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../src/bridge/crypto-assets/cal-store.test.ts"],"names":[],"mappings":""}
@@ -1,70 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const cal_store_1 = require("./cal-store");
4
- describe("CALStore", () => {
5
- let store;
6
- beforeEach(() => {
7
- store = new cal_store_1.CALStore();
8
- });
9
- describe("Token cache operations", () => {
10
- const token = {
11
- id: "ethereum/erc20/usdt",
12
- name: "Tether USD",
13
- ticker: "USDT",
14
- contractAddress: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
15
- parentCurrency: { id: "ethereum" },
16
- type: "TokenCurrency",
17
- units: [
18
- {
19
- name: "USDT",
20
- code: "USDT",
21
- magnitude: 6,
22
- },
23
- ],
24
- };
25
- it("should store and retrieve tokens by ID", () => {
26
- store.addTokens([token]);
27
- const foundToken = store.findTokenById("ethereum/erc20/usdt");
28
- expect(foundToken).toEqual(token);
29
- });
30
- it("should store and retrieve tokens by address", () => {
31
- store.addTokens([token]);
32
- const foundToken = store.findTokenByAddress("0xdAC17F958D2ee523a2206206994597C13D831ec7");
33
- expect(foundToken).toEqual(token);
34
- });
35
- it("should store and retrieve tokens by ticker", () => {
36
- store.addTokens([token]);
37
- const foundToken = store.findTokenByTicker("USDT");
38
- expect(foundToken).toEqual(token);
39
- });
40
- it("should find token by address in specific currency", () => {
41
- store.addTokens([token]);
42
- const foundToken = store.findTokenByAddressInCurrency("0xdAC17F958D2ee523a2206206994597C13D831ec7", "ethereum");
43
- expect(foundToken).toEqual(token);
44
- });
45
- it("should not find token by address in different currency", () => {
46
- store.addTokens([token]);
47
- const foundToken = store.findTokenByAddressInCurrency("0xdAC17F958D2ee523a2206206994597C13D831ec7", "polygon");
48
- expect(foundToken).toBeUndefined();
49
- });
50
- it("should return undefined for non-existent address in findTokenByAddressInCurrency", () => {
51
- store.addTokens([token]);
52
- const foundToken = store.findTokenByAddressInCurrency("0xNONEXISTENT", "ethereum");
53
- expect(foundToken).toBeUndefined();
54
- });
55
- it("should return undefined for non-existent tokens", () => {
56
- expect(store.findTokenById("non-existent")).toBeUndefined();
57
- expect(store.findTokenByAddress("0x0000")).toBeUndefined();
58
- expect(store.findTokenByTicker("FAKE")).toBeUndefined();
59
- });
60
- it("should throw error when getting non-existent token by ID", () => {
61
- expect(() => store.getTokenById("non-existent")).toThrow("Token not found: non-existent");
62
- });
63
- it("should get existing token by ID", () => {
64
- store.addTokens([token]);
65
- const foundToken = store.getTokenById("ethereum/erc20/usdt");
66
- expect(foundToken).toEqual(token);
67
- });
68
- });
69
- });
70
- //# sourceMappingURL=cal-store.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cal-store.test.js","sourceRoot":"","sources":["../../../src/bridge/crypto-assets/cal-store.test.ts"],"names":[],"mappings":";;AAAA,2CAAuC;AAGvC,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;IACxB,IAAI,KAAe,CAAC;IAEpB,UAAU,CAAC,GAAG,EAAE;QACd,KAAK,GAAG,IAAI,oBAAQ,EAAE,CAAC;IACzB,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;QACtC,MAAM,KAAK,GAAG;YACZ,EAAE,EAAE,qBAAqB;YACzB,IAAI,EAAE,YAAY;YAClB,MAAM,EAAE,MAAM;YACd,eAAe,EAAE,4CAA4C;YAC7D,cAAc,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE;YAClC,IAAI,EAAE,eAAe;YACrB,KAAK,EAAE;gBACL;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,MAAM;oBACZ,SAAS,EAAE,CAAC;iBACb;aACF;SACe,CAAC;QAEnB,EAAE,CAAC,wCAAwC,EAAE,GAAG,EAAE;YAChD,KAAK,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;YAEzB,MAAM,UAAU,GAAG,KAAK,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC;YAC9D,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO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;YAEzB,MAAM,UAAU,GAAG,KAAK,CAAC,4BAA4B,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;YACnF,MAAM,CAAC,UAAU,CAAC,CAAC,aAAa,EAAE,CAAC;QACrC,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;YACzD,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;YAC5D,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;YAC3D,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;QAC1D,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,0DAA0D,EAAE,GAAG,EAAE;YAClE,MAAM,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,+BAA+B,CAAC,CAAC;QAC5F,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;YACzC,KAAK,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;YAEzB,MAAM,UAAU,GAAG,KAAK,CAAC,YAAY,CAAC,qBAAqB,CAAC,CAAC;YAC7D,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,4 +0,0 @@
1
- import type { CryptoAssetsStore } from "@ledgerhq/types-live";
2
- export declare function isCALIntegrationEnabled(): boolean;
3
- export declare function getCALStore(): CryptoAssetsStore;
4
- //# sourceMappingURL=cal-integration.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cal-integration.d.ts","sourceRoot":"","sources":["../../../src/bridge/crypto-assets/cal-integration.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAM9D,wBAAgB,uBAAuB,IAAI,OAAO,CAOjD;AAED,wBAAgB,WAAW,IAAI,iBAAiB,CAK/C"}
@@ -1,21 +0,0 @@
1
- import { getEnv } from "@ledgerhq/live-env";
2
- import { log } from "@ledgerhq/logs";
3
- import { CALStore } from "./cal-store";
4
- import { isFeature } from "../../featureFlags/firebaseFeatureFlags";
5
- let calStoreInstance;
6
- export function isCALIntegrationEnabled() {
7
- try {
8
- return !getEnv("MOCK") && isFeature("calLedgerService");
9
- }
10
- catch (error) {
11
- log("cal", "Error checking CAL integration:", error);
12
- return false;
13
- }
14
- }
15
- export function getCALStore() {
16
- if (!calStoreInstance) {
17
- calStoreInstance = new CALStore();
18
- }
19
- return calStoreInstance;
20
- }
21
- //# sourceMappingURL=cal-integration.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cal-integration.js","sourceRoot":"","sources":["../../../src/bridge/crypto-assets/cal-integration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAErC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,IAAI,gBAAsC,CAAC;AAE3C,MAAM,UAAU,uBAAuB;IACrC,IAAI;QACF,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,SAAS,CAAC,kBAAkB,CAAC,CAAC;KACzD;IAAC,OAAO,KAAK,EAAE;QACd,GAAG,CAAC,KAAK,EAAE,iCAAiC,EAAE,KAAK,CAAC,CAAC;QACrD,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,IAAI,CAAC,gBAAgB,EAAE;QACrB,gBAAgB,GAAG,IAAI,QAAQ,EAAE,CAAC;KACnC;IACD,OAAO,gBAAgB,CAAC;AAC1B,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=cal-integration.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cal-integration.test.d.ts","sourceRoot":"","sources":["../../../src/bridge/crypto-assets/cal-integration.test.ts"],"names":[],"mappings":""}