@ledgerhq/live-common 22.0.3 → 22.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/lib/__tests__/families/bitcoin/wallet-btc/xpub.txs.dogecoin.test.d.ts +2 -0
  2. package/lib/__tests__/families/bitcoin/wallet-btc/xpub.txs.dogecoin.test.d.ts.map +1 -0
  3. package/lib/__tests__/families/bitcoin/wallet-btc/xpub.txs.dogecoin.test.js +147 -0
  4. package/lib/__tests__/families/bitcoin/wallet-btc/xpub.txs.dogecoin.test.js.map +1 -0
  5. package/lib/api/Ripple.d.ts +17 -21
  6. package/lib/api/Ripple.d.ts.map +1 -1
  7. package/lib/api/Ripple.js +117 -176
  8. package/lib/api/Ripple.js.map +1 -1
  9. package/lib/api/index.d.ts.map +1 -1
  10. package/lib/api/index.js +1 -5
  11. package/lib/api/index.js.map +1 -1
  12. package/lib/env.d.ts +6 -6
  13. package/lib/env.d.ts.map +1 -1
  14. package/lib/env.js +3 -3
  15. package/lib/env.js.map +1 -1
  16. package/lib/env.react.d.ts +1 -1
  17. package/lib/env.react.d.ts.map +1 -1
  18. package/lib/errors.d.ts +3 -0
  19. package/lib/errors.d.ts.map +1 -1
  20. package/lib/errors.js +2 -1
  21. package/lib/errors.js.map +1 -1
  22. package/lib/families/bitcoin/getAccountNetworkInfo.d.ts.map +1 -1
  23. package/lib/families/bitcoin/getAccountNetworkInfo.js +4 -2
  24. package/lib/families/bitcoin/getAccountNetworkInfo.js.map +1 -1
  25. package/lib/families/bitcoin/specs.d.ts.map +1 -1
  26. package/lib/families/bitcoin/specs.js +5 -2
  27. package/lib/families/bitcoin/specs.js.map +1 -1
  28. package/lib/families/bitcoin/wallet-btc/utils.d.ts +2 -0
  29. package/lib/families/bitcoin/wallet-btc/utils.d.ts.map +1 -1
  30. package/lib/families/bitcoin/wallet-btc/utils.js +9 -1
  31. package/lib/families/bitcoin/wallet-btc/utils.js.map +1 -1
  32. package/lib/families/bitcoin/wallet-btc/wallet.d.ts.map +1 -1
  33. package/lib/families/bitcoin/wallet-btc/wallet.js +11 -11
  34. package/lib/families/bitcoin/wallet-btc/wallet.js.map +1 -1
  35. package/lib/families/cosmos/js-prepareTransaction.d.ts.map +1 -1
  36. package/lib/families/cosmos/js-prepareTransaction.js +29 -5
  37. package/lib/families/cosmos/js-prepareTransaction.js.map +1 -1
  38. package/lib/families/cosmos/js-signOperation.d.ts.map +1 -1
  39. package/lib/families/cosmos/js-signOperation.js +76 -39
  40. package/lib/families/cosmos/js-signOperation.js.map +1 -1
  41. package/lib/families/cosmos/validators.js +1 -1
  42. package/lib/families/ripple/bridge/js.d.ts +2 -1
  43. package/lib/families/ripple/bridge/js.d.ts.map +1 -1
  44. package/lib/families/ripple/bridge/js.js +96 -466
  45. package/lib/families/ripple/bridge/js.js.map +1 -1
  46. package/lib/families/ripple/bridge.test.js +0 -48
  47. package/lib/families/ripple/bridge.test.js.map +1 -1
  48. package/lib/families/ripple/js-synchronization.d.ts +10 -0
  49. package/lib/families/ripple/js-synchronization.d.ts.map +1 -0
  50. package/lib/families/ripple/js-synchronization.js +156 -0
  51. package/lib/families/ripple/js-synchronization.js.map +1 -0
  52. package/lib/families/ripple/test-dataset.d.ts.map +1 -1
  53. package/lib/families/ripple/test-dataset.js +1 -1
  54. package/lib/families/ripple/test-dataset.js.map +1 -1
  55. package/lib/families/ripple/types.api.d.ts +24 -0
  56. package/lib/families/ripple/types.api.d.ts.map +1 -0
  57. package/lib/families/ripple/types.api.js +3 -0
  58. package/lib/families/ripple/types.api.js.map +1 -0
  59. package/lib/families/solana/api/chain/instruction/token/types.d.ts +3 -3
  60. package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
  61. package/lib/featureFlags/defaultFeatures.js +46 -0
  62. package/lib/featureFlags/defaultFeatures.js.map +1 -1
  63. package/lib/featureFlags/types.d.ts +2 -1
  64. package/lib/featureFlags/types.d.ts.map +1 -1
  65. package/lib/platform/providers/GlobalCatalogProvider/api/mock.json +0 -26
  66. package/lib/platform/providers/RemoteLiveAppProvider/api/mock.json +0 -63
  67. package/lib/types/nft.d.ts +1 -1
  68. package/lib/types/nft.d.ts.map +1 -1
  69. package/package.json +7 -7
  70. package/src/__tests__/families/bitcoin/wallet-btc/xpub.txs.dogecoin.test.ts +96 -0
  71. package/src/api/Ripple.ts +95 -160
  72. package/src/api/index.ts +0 -2
  73. package/src/currencies/__snapshots__/sortByMarketcap.test.ts.snap +47 -3
  74. package/src/env.ts +3 -3
  75. package/src/errors.ts +4 -0
  76. package/src/families/bitcoin/getAccountNetworkInfo.ts +4 -2
  77. package/src/families/bitcoin/specs.ts +4 -5
  78. package/src/families/bitcoin/wallet-btc/utils.ts +8 -0
  79. package/src/families/bitcoin/wallet-btc/wallet.ts +24 -12
  80. package/src/families/cosmos/__snapshots__/bridge.test.ts.snap +128 -7
  81. package/src/families/cosmos/js-prepareTransaction.ts +7 -5
  82. package/src/families/cosmos/js-signOperation.ts +54 -36
  83. package/src/families/cosmos/validators.ts +1 -1
  84. package/src/families/ripple/bridge/js.ts +89 -494
  85. package/src/families/ripple/bridge.test.ts +0 -6
  86. package/src/families/ripple/js-synchronization.ts +153 -0
  87. package/src/families/ripple/test-dataset.ts +2 -0
  88. package/src/families/ripple/types.api.ts +23 -0
  89. package/src/featureFlags/defaultFeatures.ts +47 -0
  90. package/src/featureFlags/types.ts +7 -1
  91. package/src/platform/providers/GlobalCatalogProvider/api/mock.json +0 -26
  92. package/src/platform/providers/RemoteLiveAppProvider/api/mock.json +0 -63
  93. package/src/types/nft.ts +1 -1
  94. package/src/.DS_Store +0 -0
  95. package/src/__tests__/.DS_Store +0 -0
@@ -1,12 +1,6 @@
1
1
  import { setup } from "../../__tests__/test-helpers/libcore-setup";
2
2
  import { testBridge } from "../../__tests__/test-helpers/bridge";
3
3
  import dataset from "./test-dataset";
4
- import { disconnect } from "../../api/Ripple";
5
-
6
- // Disconnect all api clients that could be open.
7
- afterAll(async () => {
8
- await disconnect();
9
- });
10
4
 
11
5
  setup("ripple");
12
6
  testBridge("ripple", dataset);
@@ -0,0 +1,153 @@
1
+ import BigNumber from "bignumber.js";
2
+ import {
3
+ getAccountInfo,
4
+ getServerInfo,
5
+ getTransactions,
6
+ } from "../../api/Ripple";
7
+ import {
8
+ GetAccountShape,
9
+ makeScanAccounts,
10
+ makeSync,
11
+ mergeOps,
12
+ } from "../../bridge/jsHelpers";
13
+ import { encodeOperationId } from "../../operation";
14
+ import { Account, Operation } from "../../types";
15
+ import { encodeAccountId } from "../../account";
16
+ import { NEW_ACCOUNT_ERROR_MESSAGE } from "./bridge/js";
17
+ import { TxXRPL } from "./types.api";
18
+
19
+ const txToOperation =
20
+ (accountId: string, address: string) =>
21
+ ({
22
+ meta: { delivered_amount },
23
+ tx: {
24
+ DestinationTag,
25
+ Fee,
26
+ hash,
27
+ inLedger,
28
+ date,
29
+ Account,
30
+ Destination,
31
+ Sequence,
32
+ },
33
+ }: TxXRPL): Operation | null | undefined => {
34
+ const type = Account === address ? "OUT" : "IN";
35
+ let value =
36
+ delivered_amount && typeof delivered_amount === "string"
37
+ ? new BigNumber(delivered_amount)
38
+ : new BigNumber(0);
39
+ const feeValue = new BigNumber(Fee);
40
+
41
+ if (type === "OUT") {
42
+ if (!Number.isNaN(feeValue)) {
43
+ value = value.plus(feeValue);
44
+ }
45
+ }
46
+
47
+ // https://xrpl.org/basic-data-types.html#specifying-time
48
+ const toEpochDate = (946684800 + date) * 1000;
49
+
50
+ const op: Operation = {
51
+ id: encodeOperationId(accountId, hash, type),
52
+ hash: hash,
53
+ accountId: accountId,
54
+ type,
55
+ value,
56
+ fee: feeValue,
57
+ blockHash: null,
58
+ blockHeight: inLedger,
59
+ senders: [Account],
60
+ recipients: [Destination],
61
+ date: new Date(toEpochDate),
62
+ transactionSequenceNumber: Sequence,
63
+ extra: {},
64
+ };
65
+
66
+ if (DestinationTag) {
67
+ op.extra.tag = DestinationTag;
68
+ }
69
+
70
+ return op;
71
+ };
72
+
73
+ const filterOperations: any = (
74
+ transactions: TxXRPL[],
75
+ accountId: string,
76
+ address: string
77
+ ) => {
78
+ return transactions
79
+ .filter(
80
+ (tx: TxXRPL) =>
81
+ tx.tx.TransactionType === "Payment" &&
82
+ typeof tx.meta.delivered_amount === "string"
83
+ )
84
+ .map(txToOperation(accountId, address))
85
+ .filter(Boolean);
86
+ };
87
+
88
+ const getAccountShape: GetAccountShape = async (
89
+ info
90
+ ): Promise<Partial<Account>> => {
91
+ const { address, initialAccount, currency, derivationMode } = info;
92
+ const accountId = encodeAccountId({
93
+ type: "js",
94
+ version: "2",
95
+ currencyId: currency.id,
96
+ xpubOrAddress: address,
97
+ derivationMode,
98
+ });
99
+ const accountInfo = await getAccountInfo(address);
100
+
101
+ if (!accountInfo || accountInfo.error === NEW_ACCOUNT_ERROR_MESSAGE) {
102
+ return {
103
+ id: accountId,
104
+ xpub: address,
105
+ blockHeight: 0,
106
+ balance: new BigNumber(0),
107
+ spendableBalance: new BigNumber(0),
108
+ operations: [],
109
+ operationsCount: 0,
110
+ };
111
+ }
112
+
113
+ const serverInfo = await getServerInfo();
114
+
115
+ const oldOperations = initialAccount?.operations || [];
116
+ const startAt = oldOperations.length
117
+ ? (oldOperations[0].blockHeight || 0) + 1
118
+ : 0;
119
+
120
+ const ledgers = serverInfo.info.complete_ledgers.split("-");
121
+ const minLedgerVersion = Number(ledgers[0]);
122
+ const maxLedgerVersion = Number(ledgers[1]);
123
+
124
+ const balance = new BigNumber(accountInfo.account_data.Balance);
125
+
126
+ const newTransactions =
127
+ (await getTransactions(address, {
128
+ ledger_index_min: Math.max(
129
+ startAt, // if there is no ops, it might be after a clear and we prefer to pull from the oldest possible history
130
+ minLedgerVersion
131
+ ),
132
+ ledger_index_max: maxLedgerVersion,
133
+ })) || [];
134
+
135
+ const newOperations = filterOperations(newTransactions, accountId, address);
136
+
137
+ const operations = mergeOps(oldOperations, newOperations as Operation[]);
138
+
139
+ const shape = {
140
+ id: accountId,
141
+ xpub: address,
142
+ blockHeight: maxLedgerVersion,
143
+ balance,
144
+ spendableBalance: balance,
145
+ operations,
146
+ operationsCount: operations.length,
147
+ };
148
+
149
+ return shape;
150
+ };
151
+
152
+ export const scanAccounts = makeScanAccounts({ getAccountShape });
153
+ export const sync = makeSync({ getAccountShape });
@@ -23,6 +23,8 @@ const dataset: DatasetTest<Transaction> = {
23
23
  unstableAccounts: true,
24
24
  // our account is getting spammed...
25
25
  apdus: `
26
+ => e00200400d038000002c8000009080000000
27
+ <= 2103c73f64083463fa923e1530af6f558204853873c6a45cbfb1f2f1e2ac2a5d989c2272734a4675764165634c333153513750594864504b6b3335625a456f78446d5231789000
26
28
  => e002004015058000002c80000090800000000000000000000000
27
29
  <= 2103d1adcff3e0cf1232b1416a75cd6f23b49dd6a25c69bc291a1f6783ec6825ec062272616765584842365134566276765764547a4b414e776a65435434485846434b58379000
28
30
  => e002004015058000002c80000090800000010000000000000000
@@ -0,0 +1,23 @@
1
+ interface Currency {
2
+ currency: string;
3
+ amount: string;
4
+ }
5
+
6
+ export interface TxXRPL {
7
+ meta: {
8
+ TransactionResult: string;
9
+ delivered_amount: Currency | string;
10
+ };
11
+ tx: {
12
+ TransactionType: string;
13
+ Fee: string;
14
+ Account: string;
15
+ Destination: string;
16
+ DestinationTag?: number;
17
+ Amount: string;
18
+ Sequence: number;
19
+ date: number;
20
+ inLedger: number;
21
+ hash: string;
22
+ };
23
+ }
@@ -7,4 +7,51 @@ export const defaultFeatures: DefaultFeatures = {
7
7
  pushNotifications: {
8
8
  enabled: false,
9
9
  },
10
+ ratings: {
11
+ enabled: false,
12
+ params: {
13
+ happy_moments: [
14
+ {
15
+ route_name: "ReceiveConfirmation",
16
+ timer: 2000,
17
+ type: "on_enter",
18
+ },
19
+ {
20
+ route_name: "ClaimRewardsValidationSuccess",
21
+ timer: 2000,
22
+ type: "on_enter",
23
+ },
24
+ {
25
+ route_name: "SendValidationSuccess",
26
+ timer: 2000,
27
+ type: "on_enter",
28
+ },
29
+ {
30
+ route_name: "MarketDetail",
31
+ timer: 3000,
32
+ type: "on_enter",
33
+ },
34
+ ],
35
+ conditions: {
36
+ not_now_delay: {
37
+ days: 15,
38
+ },
39
+ disappointed_delay: {
40
+ days: 90,
41
+ },
42
+ satisfied_then_not_now_delay: {
43
+ days: 3,
44
+ },
45
+ minimum_accounts_number: 3,
46
+ minimum_app_starts_number: 3,
47
+ minimum_duration_since_app_first_start: {
48
+ days: 3,
49
+ },
50
+ minimum_number_of_app_starts_since_last_crash: 2,
51
+ },
52
+ typeform_url:
53
+ "https://form.typeform.com/to/Jo7gqcB4?typeform-medium=embed-sdk&typeform-medium-version=next&typeform-embed=popup-blank",
54
+ support_email: "support@ledger.com",
55
+ },
56
+ },
10
57
  };
@@ -1,10 +1,16 @@
1
1
  // Add others with union (e.g. "learn" | "market" | "foo")
2
- export type FeatureId = "learn" | "pushNotifications";
2
+ export type FeatureId =
3
+ | "learn"
4
+ | "pushNotifications"
5
+ | "llmUsbFirmwareUpdate"
6
+ | "ratings"
7
+ | string;
3
8
 
4
9
  // We use objects instead of direct booleans for potential future improvements
5
10
  // like feature versioning etc
6
11
  export type Feature = {
7
12
  enabled: boolean;
13
+ params?: any;
8
14
  };
9
15
 
10
16
  export type DefaultFeatures = { [key in FeatureId]: Feature };
@@ -83,32 +83,6 @@
83
83
  "tags": [],
84
84
  "categories": []
85
85
  },
86
- {
87
- "appId": "Card",
88
- "type": "LIVE_APP",
89
- "tags": [
90
- "card"
91
- ],
92
- "categories": [
93
- "spend"
94
- ],
95
- "platform": "all",
96
- "branch": "stable",
97
- "currencies": "*"
98
- },
99
- {
100
- "appId": "cl-card",
101
- "type": "LIVE_APP",
102
- "tags": [
103
- "card"
104
- ],
105
- "categories": [
106
- "spend"
107
- ],
108
- "platform": "all",
109
- "branch": "stable",
110
- "currencies": "*"
111
- },
112
86
  {
113
87
  "appId": "moonpay",
114
88
  "type": "LIVE_APP",
@@ -1,67 +1,4 @@
1
1
  [
2
- {
3
- "id": "Card",
4
- "name": "Card",
5
- "url": "https://cl-cards.com/waiting-list/",
6
- "homepageUrl": "https://baanx.com/",
7
- "icon": "https://cdn.live.ledger.com/icons/platform/card2.png",
8
- "platform": "all",
9
- "apiVersion": "0.0.1",
10
- "manifestVersion": "1",
11
- "branch": "stable",
12
- "categories": [
13
- "card"
14
- ],
15
- "currencies": "*",
16
- "content": {
17
- "shortDescription": {
18
- "en": "Coming soon: spend your crypto globally with the crypto debit CL Card, powered by Ledger. Built to be compatible with your Ledger wallet. Join the waitlist"
19
- },
20
- "description": {
21
- "en": "Coming soon: spend your crypto globally with the crypto debit CL Card, powered by Ledger. Built to be compatible with your Ledger wallet. Join the waitlist"
22
- }
23
- },
24
- "permissions": [
25
- {
26
- "method": "*"
27
- }
28
- ],
29
- "domains": [
30
- "https://*"
31
- ]
32
- },
33
- {
34
- "id": "cl-card",
35
- "name": "Card",
36
- "url": "https://cl-cards.com/waiting-list/",
37
- "homepageUrl": "https://baanx.com/",
38
- "icon": "https://cdn.live.ledger.com/icons/platform/card2.png",
39
- "platform": "all",
40
- "apiVersion": "0.0.1",
41
- "manifestVersion": "1",
42
- "private": true,
43
- "branch": "stable",
44
- "categories": [
45
- "card"
46
- ],
47
- "currencies": "*",
48
- "content": {
49
- "shortDescription": {
50
- "en": "Coming soon: spend your crypto globally with the crypto debit CL Card, powered by Ledger. Built to be compatible with your Ledger wallet. Join the waitlist"
51
- },
52
- "description": {
53
- "en": "Coming soon: spend your crypto globally with the crypto debit CL Card, powered by Ledger. Built to be compatible with your Ledger wallet. Join the waitlist"
54
- }
55
- },
56
- "permissions": [
57
- {
58
- "method": "*"
59
- }
60
- ],
61
- "domains": [
62
- "https://*"
63
- ]
64
- },
65
2
  {
66
3
  "id": "moonpay",
67
4
  "name": "MoonPay",
package/src/types/nft.ts CHANGED
@@ -36,7 +36,7 @@ export type NFT = Omit<ProtoNFT, "metadata"> & {
36
36
  metadata: NFTMetadata;
37
37
  };
38
38
 
39
- export type NFTMetadataLinksProviders = "opensea" | "rarible" | "etherscan";
39
+ export type NFTMetadataLinksProviders = "opensea" | "rarible" | "explorer";
40
40
 
41
41
  export type NFTMetadataResponse = {
42
42
  status: 200 | 404 | 500;
package/src/.DS_Store DELETED
Binary file
Binary file