@ledgerhq/coin-framework 0.3.0-nightly.2 → 0.3.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.
@@ -1,4 +1,4 @@
1
1
 
2
- > @ledgerhq/coin-framework@0.3.0-nightly.1 build /home/runner/work/ledger-live/ledger-live/libs/coin-framework
2
+ > @ledgerhq/coin-framework@0.3.0 build /home/runner/work/ledger-live/ledger-live/libs/coin-framework
3
3
  > tsc && tsc -m ES6 --outDir lib-es
4
4
 
package/CHANGELOG.md CHANGED
@@ -1,23 +1,21 @@
1
1
  # @ledgerhq/coin-framework
2
2
 
3
- ## 0.3.0-nightly.2
3
+ ## 0.3.0
4
4
 
5
- ### Patch Changes
6
-
7
- - Updated dependencies [[`3242a0a794`](https://github.com/LedgerHQ/ledger-live/commit/3242a0a7948c20fb0100ce3cc73e55e338534d32)]:
8
- - @ledgerhq/cryptoassets@9.3.0-nightly.1
5
+ ### Minor Changes
9
6
 
10
- ## 0.3.0-nightly.1
7
+ - [#3079](https://github.com/LedgerHQ/ledger-live/pull/3079) [`d9732f38ed`](https://github.com/LedgerHQ/ledger-live/commit/d9732f38ed891ce090c98645de55103208015a60) Thanks [@gre](https://github.com/gre)! - Sunset Compound Lending from Ledger Live 'native' codebase
11
8
 
12
9
  ### Patch Changes
13
10
 
14
- - [#2817](https://github.com/LedgerHQ/ledger-live/pull/2817) [`d5cf1abc6e`](https://github.com/LedgerHQ/ledger-live/commit/d5cf1abc6eb30d399c83b827452dc4bc61fd2253) Thanks [@thomasrogerlux](https://github.com/thomasrogerlux)! - Add Stax-enabled NFTs in the mock fixtures
15
-
16
- - Updated dependencies [[`d5cf1abc6e`](https://github.com/LedgerHQ/ledger-live/commit/d5cf1abc6eb30d399c83b827452dc4bc61fd2253)]:
17
- - @ledgerhq/types-live@6.32.0-nightly.1
18
- - @ledgerhq/live-portfolio@0.0.2-nightly.1
11
+ - Updated dependencies [[`d9732f38ed`](https://github.com/LedgerHQ/ledger-live/commit/d9732f38ed891ce090c98645de55103208015a60), [`5785155282`](https://github.com/LedgerHQ/ledger-live/commit/5785155282d61d0dbdc30f7a66d3243a74fce117), [`197d28697b`](https://github.com/LedgerHQ/ledger-live/commit/197d28697b173c3f6b2badfe4d1deddeadc912d4), [`d4834aad3f`](https://github.com/LedgerHQ/ledger-live/commit/d4834aad3f58d904850be9a3ab40b46260d9f7d4)]:
12
+ - @ledgerhq/types-cryptoassets@7.1.0
13
+ - @ledgerhq/cryptoassets@9.3.0
14
+ - @ledgerhq/types-live@6.32.0
15
+ - @ledgerhq/live-env@0.1.0
16
+ - @ledgerhq/live-portfolio@0.0.2
19
17
 
20
- ## 0.3.0-nightly.0
18
+ ## 0.3.0-next.0
21
19
 
22
20
  ### Minor Changes
23
21
 
@@ -25,14 +23,12 @@
25
23
 
26
24
  ### Patch Changes
27
25
 
28
- - [#3164](https://github.com/LedgerHQ/ledger-live/pull/3164) [`be5589dac6`](https://github.com/LedgerHQ/ledger-live/commit/be5589dac675e2c8c1771b135bd0f330a868ed2d) Thanks [@haammar-ledger](https://github.com/haammar-ledger)! - Add a 'feesCurrency' field to 'Account' type, and use it
29
-
30
- - Updated dependencies [[`d9732f38ed`](https://github.com/LedgerHQ/ledger-live/commit/d9732f38ed891ce090c98645de55103208015a60), [`197d28697b`](https://github.com/LedgerHQ/ledger-live/commit/197d28697b173c3f6b2badfe4d1deddeadc912d4), [`be5589dac6`](https://github.com/LedgerHQ/ledger-live/commit/be5589dac675e2c8c1771b135bd0f330a868ed2d), [`d4834aad3f`](https://github.com/LedgerHQ/ledger-live/commit/d4834aad3f58d904850be9a3ab40b46260d9f7d4)]:
31
- - @ledgerhq/types-cryptoassets@7.1.0-nightly.0
32
- - @ledgerhq/cryptoassets@9.3.0-nightly.0
33
- - @ledgerhq/types-live@6.32.0-nightly.0
34
- - @ledgerhq/live-env@0.1.0-nightly.0
35
- - @ledgerhq/live-portfolio@0.0.2-nightly.0
26
+ - Updated dependencies [[`d9732f38ed`](https://github.com/LedgerHQ/ledger-live/commit/d9732f38ed891ce090c98645de55103208015a60), [`5785155282`](https://github.com/LedgerHQ/ledger-live/commit/5785155282d61d0dbdc30f7a66d3243a74fce117), [`197d28697b`](https://github.com/LedgerHQ/ledger-live/commit/197d28697b173c3f6b2badfe4d1deddeadc912d4), [`d4834aad3f`](https://github.com/LedgerHQ/ledger-live/commit/d4834aad3f58d904850be9a3ab40b46260d9f7d4)]:
27
+ - @ledgerhq/types-cryptoassets@7.1.0-next.0
28
+ - @ledgerhq/cryptoassets@9.3.0-next.0
29
+ - @ledgerhq/types-live@6.32.0-next.0
30
+ - @ledgerhq/live-env@0.1.0-next.0
31
+ - @ledgerhq/live-portfolio@0.0.2-next.0
36
32
 
37
33
  ## 0.2.1
38
34
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/coin-framework",
3
- "version": "0.3.0-nightly.2",
3
+ "version": "0.3.0",
4
4
  "description": "Ledger framework for Coin integration",
5
5
  "keywords": [
6
6
  "Ledger",
@@ -61,16 +61,16 @@
61
61
  "prando": "^6.0.1",
62
62
  "rxjs": "^6.6.7",
63
63
  "rxjs-compat": "^6.6.7",
64
- "@ledgerhq/cryptoassets": "^9.3.0-nightly.1",
64
+ "@ledgerhq/cryptoassets": "^9.3.0",
65
65
  "@ledgerhq/devices": "^8.0.1",
66
66
  "@ledgerhq/errors": "^6.12.4",
67
67
  "@ledgerhq/hw-transport": "^6.28.2",
68
- "@ledgerhq/live-env": "^0.1.0-nightly.0",
69
- "@ledgerhq/live-portfolio": "^0.0.2-nightly.1",
68
+ "@ledgerhq/live-env": "^0.1.0",
69
+ "@ledgerhq/live-portfolio": "^0.0.2",
70
70
  "@ledgerhq/live-promise": "^0.0.1",
71
71
  "@ledgerhq/logs": "^6.10.1",
72
- "@ledgerhq/types-cryptoassets": "^7.1.0-nightly.0",
73
- "@ledgerhq/types-live": "^6.32.0-nightly.1"
72
+ "@ledgerhq/types-cryptoassets": "^7.1.0",
73
+ "@ledgerhq/types-live": "^6.32.0"
74
74
  },
75
75
  "devDependencies": {
76
76
  "@types/invariant": "^2.2.2",
@@ -90,7 +90,7 @@
90
90
  "prettier": "^2.8.1",
91
91
  "timemachine": "^0.3.2",
92
92
  "ts-jest": "^28.0.5",
93
- "typescript": "^4.9.5"
93
+ "typescript": "^4.9.4"
94
94
  },
95
95
  "scripts": {
96
96
  "clean": "rm -rf lib lib-es",
@@ -18,7 +18,6 @@ import {
18
18
  getAccountName,
19
19
  getAccountSpendableBalance,
20
20
  getAccountUnit,
21
- getFeesCurrency,
22
21
  } from ".";
23
22
  import {
24
23
  isAccountEmpty,
@@ -136,65 +135,6 @@ describe(getAccountUnit.name, () => {
136
135
  });
137
136
  });
138
137
 
139
- describe(getFeesCurrency.name, () => {
140
- describe("given an Account", () => {
141
- beforeEach(() => {
142
- mockAccount.type = "Account";
143
- });
144
- describe("without feesCurrency", () => {
145
- it("should return the account's currency", () => {
146
- const sampleCurrency = { family: "bitcoin" } as CryptoCurrency;
147
- mockAccount.currency = sampleCurrency;
148
- expect(getFeesCurrency(mockAccount)).toEqual(sampleCurrency);
149
- });
150
- });
151
- describe("with feesCurrency", () => {
152
- it("should return the fees currency", () => {
153
- const sampleCurrency = { family: "vechain" } as CryptoCurrency;
154
- const sampleFeesCurrency = { id: "VTHO" } as TokenCurrency;
155
- mockAccount.currency = sampleCurrency;
156
- mockAccount.feesCurrency = sampleFeesCurrency;
157
- expect(getFeesCurrency(mockAccount)).toEqual(sampleFeesCurrency);
158
- });
159
- });
160
- });
161
-
162
- describe("given a ChildAccount", () => {
163
- it("should return the currency", () => {
164
- const sampleCurrency = { family: "bitcoin" } as CryptoCurrency;
165
- childAccount.currency = sampleCurrency;
166
- expect(getFeesCurrency(childAccount)).toEqual(sampleCurrency);
167
- });
168
- });
169
-
170
- describe("given a TokenAccount", () => {
171
- it("should return the token currency", () => {
172
- const sampleToken = { id: "tokenId" } as TokenCurrency;
173
- tokenAccount.token = sampleToken;
174
- expect(getFeesCurrency(tokenAccount)).toEqual(sampleToken);
175
- });
176
- });
177
-
178
- describe("given an unknown type Account", () => {
179
- beforeEach(() => {
180
- (mockAccount as any).type = "DefinitelyNotAStandardAccount";
181
- });
182
-
183
- it("should throw an error", () => {
184
- expect(() => getFeesCurrency(mockAccount)).toThrow(Error);
185
- });
186
-
187
- it("should display the account type in the error message", () => {
188
- expect.assertions(1);
189
- try {
190
- getFeesCurrency(mockAccount);
191
- } catch (e: unknown) {
192
- expect((e as Error).message.includes(mockAccount.type)).toEqual(true);
193
- }
194
- });
195
- });
196
- });
197
-
198
138
  describe(getAccountName.name, () => {
199
139
  describe("given an Account", () => {
200
140
  beforeEach(() => {
@@ -17,9 +17,9 @@ import {
17
17
  Unit,
18
18
  } from "@ledgerhq/types-cryptoassets";
19
19
 
20
- // By convention, a main account is the top level account
21
- // - in case of an Account is the account itself
22
- // - in case of a SubAccount it's the parentAccount
20
+ // by convention, a main account is the top level account
21
+ // in case of an Account is the account itself
22
+ // in case of a TokenAccount it's the parentAccount
23
23
  export const getMainAccount = (
24
24
  account: AccountLike,
25
25
  parentAccount?: Account | null | undefined
@@ -29,32 +29,6 @@ export const getMainAccount = (
29
29
  return mainAccount as Account;
30
30
  };
31
31
 
32
- // Return the currency in which fees are paid for this account
33
- export const getFeesCurrency = (
34
- account?: AccountLike
35
- ): TokenCurrency | CryptoCurrency => {
36
- switch (account?.type) {
37
- case "Account":
38
- return account.feesCurrency || account.currency;
39
-
40
- case "ChildAccount":
41
- return account.currency;
42
-
43
- case "TokenAccount":
44
- return account.token;
45
-
46
- default:
47
- throw new Error(
48
- "invalid account.type=" + (account as unknown as { type: string })?.type
49
- );
50
- }
51
- };
52
-
53
- // Return the unit to use with the fees currency
54
- export const getFeesUnit = (currency: TokenCurrency | CryptoCurrency): Unit => {
55
- return currency.units[0];
56
- };
57
-
58
32
  export const getAccountCurrency = (
59
33
  account?: AccountLike
60
34
  ): TokenCurrency | CryptoCurrency => {
@@ -65,6 +65,7 @@ const hardcodedMarketcap = [
65
65
  "tezos",
66
66
  "iota",
67
67
  "ethereum/erc20/link_chainlink",
68
+ "neo",
68
69
  "ethereum/erc20/makerdao",
69
70
  "ethereum/erc20/usd__coin",
70
71
  "ontology",
@@ -390,8 +391,7 @@ export function genAccount(
390
391
  ...(withNft && {
391
392
  nfts: Array(10)
392
393
  .fill(null)
393
- // The index === 0 ensure at least one NFT is a Stax NFT if the currency is Ethereum
394
- .map((_, index) => createFixtureNFT(accountId, currency, index === 0)),
394
+ .map(() => createFixtureNFT(accountId, currency)),
395
395
  }),
396
396
  };
397
397
 
@@ -307,19 +307,6 @@ export const NFTs = [
307
307
  },
308
308
  ];
309
309
 
310
- // Ethereum NFTs with the special "staxImage" metadata designed to fit the Ledger Stax screen
311
- export const NFTs_ETHEREUM_STAX_METADATA = [
312
- {
313
- id: "js:2:ethereum:0xB98d10d9f6d07bA283bFD21B2dFEc050f9Ae282A:+0xf4ac11a8967bc88c9ce5acf886bce605c9db9d6e+8482",
314
- tokenId: "8482",
315
- amount: "1",
316
- collection: {
317
- contract: "0xf4ac11a8967bc88c9ce5acf886bce605c9db9d6e",
318
- standard: "ERC721",
319
- },
320
- },
321
- ];
322
-
323
310
  export const NFTs_POLYGON = [
324
311
  {
325
312
  id: "js:2:ethereum:0xB98d10d9f6d07bA283bFD21B2dFEc050f9Ae282A:+0x68a0B29526f342de944BBd6bF61D9c644B96b771+7",
@@ -353,15 +340,9 @@ export const NFTs_POLYGON = [
353
340
  ];
354
341
  export function createFixtureNFT(
355
342
  accountId: string,
356
- currency: CryptoCurrency = defaultEthCryptoFamily,
357
- useStaxNFTs?: boolean
343
+ currency: CryptoCurrency = defaultEthCryptoFamily
358
344
  ): ProtoNFT {
359
- const nfts =
360
- currency.id === "ethereum"
361
- ? useStaxNFTs
362
- ? NFTs_ETHEREUM_STAX_METADATA
363
- : NFTs
364
- : NFTs_POLYGON;
345
+ const nfts = currency.id === "ethereum" ? NFTs : NFTs_POLYGON;
365
346
  const index = Math.floor(Math.random() * nfts.length);
366
347
 
367
348
  const nft = nfts[index];