@ledgerhq/coin-module-framework 2.2.0 → 3.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 (130) hide show
  1. package/.oxlintrc.json +6 -0
  2. package/CHANGELOG.md +38 -0
  3. package/LICENSE +194 -0
  4. package/jest-global-setup.js +3 -0
  5. package/jest.config.js +3 -0
  6. package/knip.json +15 -0
  7. package/lib/api/errors.d.ts.map +1 -1
  8. package/lib/api/errors.js +2 -0
  9. package/lib/api/errors.js.map +1 -1
  10. package/lib/api/getBalance/rejectBalanceOptions.d.ts.map +1 -1
  11. package/lib/api/getBalance/rejectBalanceOptions.js +2 -0
  12. package/lib/api/getBalance/rejectBalanceOptions.js.map +1 -1
  13. package/lib/api/index.d.ts.map +1 -1
  14. package/lib/api/index.js +6 -4
  15. package/lib/api/index.js.map +1 -1
  16. package/lib/api/types.d.ts +10 -6
  17. package/lib/api/types.d.ts.map +1 -1
  18. package/lib/api/types.js +2 -0
  19. package/lib/api/types.js.map +1 -1
  20. package/lib/config.d.ts.map +1 -1
  21. package/lib/config.js +2 -0
  22. package/lib/config.js.map +1 -1
  23. package/lib/currencies/BigNumberToLocaleString.d.ts.map +1 -1
  24. package/lib/currencies/BigNumberToLocaleString.js +2 -0
  25. package/lib/currencies/BigNumberToLocaleString.js.map +1 -1
  26. package/lib/currencies/formatCurrencyUnit.d.ts.map +1 -1
  27. package/lib/currencies/formatCurrencyUnit.js +3 -1
  28. package/lib/currencies/formatCurrencyUnit.js.map +1 -1
  29. package/lib/currencies/index.d.ts.map +1 -1
  30. package/lib/currencies/index.js +2 -0
  31. package/lib/currencies/index.js.map +1 -1
  32. package/lib/currencies/localeUtility.d.ts.map +1 -1
  33. package/lib/currencies/localeUtility.js +2 -0
  34. package/lib/currencies/localeUtility.js.map +1 -1
  35. package/lib/currencies/parseCurrencyUnit.d.ts.map +1 -1
  36. package/lib/currencies/parseCurrencyUnit.js +2 -0
  37. package/lib/currencies/parseCurrencyUnit.js.map +1 -1
  38. package/lib/errors.d.ts.map +1 -1
  39. package/lib/errors.js +2 -0
  40. package/lib/errors.js.map +1 -1
  41. package/lib/features/types.d.ts.map +1 -1
  42. package/lib/features/types.js +2 -0
  43. package/lib/features/types.js.map +1 -1
  44. package/lib/index.d.ts.map +1 -1
  45. package/lib/index.js +2 -0
  46. package/lib/index.js.map +1 -1
  47. package/lib/logic/craftTransactionData.d.ts.map +1 -1
  48. package/lib/logic/craftTransactionData.js +2 -0
  49. package/lib/logic/craftTransactionData.js.map +1 -1
  50. package/lib/test/utils.d.ts.map +1 -1
  51. package/lib/test/utils.js +2 -0
  52. package/lib/test/utils.js.map +1 -1
  53. package/lib/utils.d.ts.map +1 -1
  54. package/lib/utils.js +7 -1
  55. package/lib/utils.js.map +1 -1
  56. package/lib-es/api/errors.d.ts.map +1 -1
  57. package/lib-es/api/errors.js +2 -0
  58. package/lib-es/api/errors.js.map +1 -1
  59. package/lib-es/api/getBalance/rejectBalanceOptions.d.ts.map +1 -1
  60. package/lib-es/api/getBalance/rejectBalanceOptions.js +2 -0
  61. package/lib-es/api/getBalance/rejectBalanceOptions.js.map +1 -1
  62. package/lib-es/api/index.d.ts.map +1 -1
  63. package/lib-es/api/index.js +2 -0
  64. package/lib-es/api/index.js.map +1 -1
  65. package/lib-es/api/types.d.ts +10 -6
  66. package/lib-es/api/types.d.ts.map +1 -1
  67. package/lib-es/api/types.js +2 -0
  68. package/lib-es/api/types.js.map +1 -1
  69. package/lib-es/config.d.ts.map +1 -1
  70. package/lib-es/config.js +2 -0
  71. package/lib-es/config.js.map +1 -1
  72. package/lib-es/currencies/BigNumberToLocaleString.d.ts.map +1 -1
  73. package/lib-es/currencies/BigNumberToLocaleString.js +2 -0
  74. package/lib-es/currencies/BigNumberToLocaleString.js.map +1 -1
  75. package/lib-es/currencies/formatCurrencyUnit.d.ts.map +1 -1
  76. package/lib-es/currencies/formatCurrencyUnit.js +3 -1
  77. package/lib-es/currencies/formatCurrencyUnit.js.map +1 -1
  78. package/lib-es/currencies/index.d.ts.map +1 -1
  79. package/lib-es/currencies/index.js +2 -0
  80. package/lib-es/currencies/index.js.map +1 -1
  81. package/lib-es/currencies/localeUtility.d.ts.map +1 -1
  82. package/lib-es/currencies/localeUtility.js +2 -0
  83. package/lib-es/currencies/localeUtility.js.map +1 -1
  84. package/lib-es/currencies/parseCurrencyUnit.d.ts.map +1 -1
  85. package/lib-es/currencies/parseCurrencyUnit.js +2 -0
  86. package/lib-es/currencies/parseCurrencyUnit.js.map +1 -1
  87. package/lib-es/errors.d.ts.map +1 -1
  88. package/lib-es/errors.js +2 -0
  89. package/lib-es/errors.js.map +1 -1
  90. package/lib-es/features/types.d.ts.map +1 -1
  91. package/lib-es/features/types.js +2 -0
  92. package/lib-es/features/types.js.map +1 -1
  93. package/lib-es/index.d.ts.map +1 -1
  94. package/lib-es/index.js +2 -0
  95. package/lib-es/index.js.map +1 -1
  96. package/lib-es/logic/craftTransactionData.d.ts.map +1 -1
  97. package/lib-es/logic/craftTransactionData.js +2 -0
  98. package/lib-es/logic/craftTransactionData.js.map +1 -1
  99. package/lib-es/test/utils.d.ts.map +1 -1
  100. package/lib-es/test/utils.js +2 -0
  101. package/lib-es/test/utils.js.map +1 -1
  102. package/lib-es/utils.d.ts.map +1 -1
  103. package/lib-es/utils.js +4 -1
  104. package/lib-es/utils.js.map +1 -1
  105. package/package.json +9 -4
  106. package/src/api/errors.ts +3 -0
  107. package/src/api/getBalance/rejectBalanceOptions.test.ts +3 -0
  108. package/src/api/getBalance/rejectBalanceOptions.ts +3 -0
  109. package/src/api/index.ts +3 -0
  110. package/src/api/types.ts +15 -6
  111. package/src/config.ts +4 -1
  112. package/src/currencies/BigNumberToLocaleString.test.ts +4 -1
  113. package/src/currencies/BigNumberToLocaleString.ts +3 -0
  114. package/src/currencies/formatCurrencyUnit.test.ts +5 -2
  115. package/src/currencies/formatCurrencyUnit.ts +5 -2
  116. package/src/currencies/index.ts +3 -0
  117. package/src/currencies/localeUtility.test.ts +7 -4
  118. package/src/currencies/localeUtility.ts +3 -0
  119. package/src/currencies/parseCurrencyUnit.test.ts +4 -1
  120. package/src/currencies/parseCurrencyUnit.ts +3 -0
  121. package/src/errors.ts +3 -0
  122. package/src/features/types.ts +3 -0
  123. package/src/index.ts +3 -0
  124. package/src/logic/craftTransactionData.test.ts +3 -0
  125. package/src/logic/craftTransactionData.ts +3 -0
  126. package/src/test/utils.ts +3 -0
  127. package/src/utils.test.ts +3 -0
  128. package/src/utils.ts +4 -1
  129. package/.eslintrc.js +0 -20
  130. package/.unimportedrc.json +0 -32
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAA;AACpC,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAE1F,wBAAgB,qBAAqB,CAAC,CAAC,EACrC,SAAS,EAAE,SAAS,GAAG,SAAS,EAChC,YAAY,CAAC,EAAE,CAAC,GACf,MAAM,GAAG,CAAC,CAKZ;AAED,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,iBAAiB,GAAG,EAAE,IAAI,qBAAqB,CAE1F;AAED,wBAAgB,0BAA0B,CAAC,EAAE,EAAE,iBAAiB,GAAG,EAAE,IAAI,wBAAwB,CAEhG"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAGA,OAAO,SAAS,MAAM,cAAc,CAAA;AACpC,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAE1F,wBAAgB,qBAAqB,CAAC,CAAC,EACrC,SAAS,EAAE,SAAS,GAAG,SAAS,EAChC,YAAY,CAAC,EAAE,CAAC,GACf,MAAM,GAAG,CAAC,CAKZ;AAED,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,iBAAiB,GAAG,EAAE,IAAI,qBAAqB,CAE1F;AAED,wBAAgB,0BAA0B,CAAC,EAAE,EAAE,iBAAiB,GAAG,EAAE,IAAI,wBAAwB,CAEhG"}
package/lib-es/utils.js CHANGED
@@ -1,5 +1,8 @@
1
+ // SPDX-FileCopyrightText: © 2024 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import BigNumber from 'bignumber.js';
1
4
  export function fromBigNumberToBigInt(bigNumber, defaultValue) {
2
- if (bigNumber != null) {
5
+ if (BigNumber.isBigNumber(bigNumber)) {
3
6
  return BigInt(bigNumber.toFixed());
4
7
  }
5
8
  return defaultValue;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,qBAAqB,CACnC,SAAgC,EAChC,YAAgB;IAEhB,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;QACtB,OAAO,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,CAAA;IACpC,CAAC;IACD,OAAO,YAAiB,CAAA;AAC1B,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,EAAqB;IAC3D,OAAO,EAAE,CAAC,UAAU,KAAK,aAAa,CAAA;AACxC,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,EAAqB;IAC9D,OAAO,EAAE,CAAC,UAAU,KAAK,SAAS,CAAA;AACpC,CAAC"}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,sCAAsC;AAEtC,OAAO,SAAS,MAAM,cAAc,CAAA;AAGpC,MAAM,UAAU,qBAAqB,CACnC,SAAgC,EAChC,YAAgB;IAEhB,IAAI,SAAS,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC;QACrC,OAAO,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,CAAA;IACpC,CAAC;IACD,OAAO,YAAiB,CAAA;AAC1B,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,EAAqB;IAC3D,OAAO,EAAE,CAAC,UAAU,KAAK,aAAa,CAAA;AACxC,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,EAAqB;IAC9D,OAAO,EAAE,CAAC,UAAU,KAAK,SAAS,CAAA;AACpC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/coin-module-framework",
3
- "version": "2.2.0",
3
+ "version": "3.1.0",
4
4
  "description": "Ledger framework for Coin integration",
5
5
  "keywords": [
6
6
  "Ledger",
@@ -49,6 +49,7 @@
49
49
  },
50
50
  "./package.json": "./package.json"
51
51
  },
52
+ "author": "LEDGER SAS",
52
53
  "license": "Apache-2.0",
53
54
  "dependencies": {
54
55
  "bignumber.js": "^9.1.2"
@@ -61,6 +62,8 @@
61
62
  "@types/jest": "^30.0.0",
62
63
  "cross-env": "^7.0.3",
63
64
  "jest": "30.2.0",
65
+ "oxfmt": "0.36.0",
66
+ "oxlint": "1.51.0",
64
67
  "@swc/jest": "0.2.39",
65
68
  "@swc/core": "1.15.11"
66
69
  },
@@ -71,11 +74,13 @@
71
74
  "prewatch": "pnpm build",
72
75
  "watch": "tsc --watch --project tsconfig.build.json",
73
76
  "watch:es": "tsc --watch --project tsconfig.build.json -m esnext --moduleResolution bundler --outDir lib-es",
74
- "lint": "eslint ./src --no-error-on-unmatched-pattern --ext .ts,.tsx --cache",
75
- "lint:fix": "pnpm lint --fix",
77
+ "lint": "oxlint src",
78
+ "lint:fix": "oxfmt src && oxlint src --fix --quiet",
79
+ "format": "oxfmt src",
80
+ "format:check": "oxfmt src --check",
76
81
  "test": "cross-env TZ=America/Paris jest",
77
82
  "test:debug": "cross-env TZ=America/Paris node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand",
78
- "unimported": "unimported",
83
+ "unimported": "knip --include=files,dependencies",
79
84
  "update:deps": "../../bin/update-coin-module-deps.sh"
80
85
  }
81
86
  }
package/src/api/errors.ts CHANGED
@@ -1,3 +1,6 @@
1
+ // SPDX-FileCopyrightText: © 2024 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
1
4
  export class IncorrectTypeError extends Error {
2
5
  constructor(message?: string) {
3
6
  super(`IncorrectType: ${message}`)
@@ -1,3 +1,6 @@
1
+ // SPDX-FileCopyrightText: © 2024 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
1
4
  import { InvalidParameterError } from '@ledgerhq/errors'
2
5
  import { BalanceOptions } from '../types'
3
6
  import { rejectBalanceOptions } from './rejectBalanceOptions'
@@ -1,3 +1,6 @@
1
+ // SPDX-FileCopyrightText: © 2024 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
1
4
  import { InvalidParameterError } from '@ledgerhq/errors'
2
5
  import { Balance, BalanceOptions } from '../types'
3
6
 
package/src/api/index.ts CHANGED
@@ -1,3 +1,6 @@
1
+ // SPDX-FileCopyrightText: © 2024 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
1
4
  /**
2
5
  * Module related to all API exposition constraints and helper.
3
6
  * One consumer of this API is Alpaca.
package/src/api/types.ts CHANGED
@@ -1,3 +1,6 @@
1
+ // SPDX-FileCopyrightText: © 2024 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
1
4
  // NOTE: from types-live
2
5
  export type BroadcastConfig = {
3
6
  mevProtected: boolean
@@ -187,7 +190,7 @@ export type Account = {
187
190
  /**
188
191
  * A component of an account/address balance, for a single asset.
189
192
  *
190
- * @see AlpacaApi#getBalance
193
+ * @see CoinModuleApi#getBalance
191
194
  */
192
195
  export type Balance = {
193
196
  /** The balance value, in base unit of {@link asset} (always positive). */
@@ -203,6 +206,9 @@ export type Balance = {
203
206
  stake?: Stake
204
207
  }
205
208
 
209
+ /** The actions that are possible to do from a {@link Stake}. */
210
+ export type StakeAction = 'delegate' | 'redelegate' | 'undelegate' | 'claim_reward'
211
+
206
212
  /** The state of a {@link Stake}. */
207
213
  export type StakeState =
208
214
  | 'inactive' // stake has been created/funded, but not collecting any rewards for any reason
@@ -217,7 +223,7 @@ export type StakeState =
217
223
  * as several {@link Stake}.
218
224
  *
219
225
  * @see Reward
220
- * @see AlpacaApi#getStakes
226
+ * @see CoinModuleApi#getStakes
221
227
  */
222
228
  export type Stake = {
223
229
  /** An immutable, globally unique id of the stake. Depending on the blockchain, it could simply be the account address,
@@ -234,6 +240,9 @@ export type Stake = {
234
240
  /** The stake status, see {@link StakeState}. */
235
241
  state: StakeState
236
242
 
243
+ /** The possible actions for that stake, see {@link StakeAction}. If no actions are possible, use empty array. */
244
+ actions: Array<StakeAction>
245
+
237
246
  /** UTC date of last state change. */
238
247
  stateUpdatedAt?: Date
239
248
 
@@ -260,7 +269,7 @@ export type Stake = {
260
269
  * A staking reward distribution event.
261
270
  *
262
271
  * @see Stake
263
- * @see AlpacaApi#getRewards
272
+ * @see CoinModuleApi#getRewards
264
273
  */
265
274
  export type Reward = {
266
275
  /** {@link Stake#uid} via which this reward was obtained. */
@@ -396,7 +405,7 @@ export type FeeEstimation = {
396
405
  parameters?: Record<string, unknown>
397
406
  }
398
407
 
399
- /** Response of {@link AlpacaApi#craftTransaction}. */
408
+ /** Response of {@link CoinModuleApi#craftTransaction}. */
400
409
  export type CraftedTransaction = {
401
410
  /** The serialized transaction (encoding is blockchain dependent). */
402
411
  transaction: string
@@ -413,7 +422,7 @@ export type Page<T> = {
413
422
  next?: Cursor | undefined
414
423
  }
415
424
 
416
- /** Options for {@link AlpacaApi#listOperations}. */
425
+ /** Options for {@link CoinModuleApi#listOperations}. */
417
426
  export type ListOperationsOptions = {
418
427
  /**
419
428
  * The minimum block height for which to fetch operations (inclusive).
@@ -491,7 +500,7 @@ export type BalanceOptions = {
491
500
  includeAssets?: (asset: AssetInfo) => Promise<boolean>
492
501
  }
493
502
 
494
- export type AlpacaApi<
503
+ export type CoinModuleApi<
495
504
  MemoType extends Memo = MemoNotSupported,
496
505
  TxDataType extends TxData = TxDataNotSupported,
497
506
  > = {
package/src/config.ts CHANGED
@@ -1,5 +1,8 @@
1
- import { MissingCoinConfig } from './errors'
1
+ // SPDX-FileCopyrightText: © 2024 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
2
4
  import type { FeatureConfig } from './features/types'
5
+ import { MissingCoinConfig } from './errors'
3
6
 
4
7
  type ConfigStatus =
5
8
  | {
@@ -1,3 +1,6 @@
1
+ // SPDX-FileCopyrightText: © 2024 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
1
4
  // Forked from @ledgerhq/live-currency-format/src/BigNumberToLocaleString.test.ts
2
5
  import { BigNumber } from 'bignumber.js'
3
6
  import { toLocaleString } from './BigNumberToLocaleString'
@@ -155,7 +158,7 @@ test('toLocaleString with different locales', () => {
155
158
  const resultEn = toLocaleString(new BigNumber('1234.56'), 'en')
156
159
  expect(resultEn).toBe('1,234.56')
157
160
  const resultFr = toLocaleString(new BigNumber('1234.56'), 'fr')
158
- expect(resultFr).toBeDefined()
161
+ expect(resultFr).toBe('1 234,56')
159
162
  })
160
163
 
161
164
  test('toLocaleString handles separator types', () => {
@@ -1,3 +1,6 @@
1
+ // SPDX-FileCopyrightText: © 2024 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
1
4
  // Forked from @ledgerhq/live-currency-format/src/BigNumberToLocaleString.ts
2
5
  import { BigNumber } from 'bignumber.js'
3
6
  import { getSeparators } from './localeUtility'
@@ -1,8 +1,11 @@
1
+ // SPDX-FileCopyrightText: © 2024 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { Unit } from '../api/types'
5
+ import { BigNumber } from 'bignumber.js'
1
6
  // Forked from @ledgerhq/live-currency-format/src/formatCurrencyUnit.test.ts
2
7
  // Snapshot tests using @ledgerhq/cryptoassets removed (not available in this repo)
3
8
  import { formatCurrencyUnit, formatCurrencyUnitFragment } from './formatCurrencyUnit'
4
- import { BigNumber } from 'bignumber.js'
5
- import type { Unit } from '../api/types'
6
9
 
7
10
  describe('formatCurrencyUnit', () => {
8
11
  describe('error handling', () => {
@@ -1,8 +1,11 @@
1
+ // SPDX-FileCopyrightText: © 2024 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { Unit } from '../api/types'
1
5
  // Forked from @ledgerhq/live-currency-format/src/formatCurrencyUnit.ts
2
6
  import { BigNumber } from 'bignumber.js'
3
- import { getSeparators } from './localeUtility'
4
7
  import { toLocaleString } from './BigNumberToLocaleString'
5
- import type { Unit } from '../api/types'
8
+ import { getSeparators } from './localeUtility'
6
9
 
7
10
  const nonBreakableSpace = '\u00A0'
8
11
  const defaultFormatOptions = {
@@ -1,3 +1,6 @@
1
+ // SPDX-FileCopyrightText: © 2024 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
1
4
  export { parseCurrencyUnit } from './parseCurrencyUnit'
2
5
  export {
3
6
  formatCurrencyUnit,
@@ -1,3 +1,6 @@
1
+ // SPDX-FileCopyrightText: © 2024 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
1
4
  // Forked from @ledgerhq/live-currency-format/src/localeUtility.test.ts
2
5
  import { getSeparators } from './localeUtility'
3
6
 
@@ -10,13 +13,13 @@ describe('localeUtility', () => {
10
13
 
11
14
  test('getSeparators with locale not in staticFallback', () => {
12
15
  const result = getSeparators('it')
13
- expect(result.decimal).toBeDefined()
14
- expect(result.thousands).toBeDefined()
16
+ expect(result.decimal).toBe(',')
17
+ expect(result.thousands).toBe('.')
15
18
  })
16
19
 
17
20
  test('getFallback uses en when locale not in staticFallback', () => {
18
21
  const result = getSeparators('de')
19
- expect(result.decimal).toBeDefined()
20
- expect(result.thousands).toBeDefined()
22
+ expect(result.decimal).toBe(',')
23
+ expect(result.thousands).toBe('.')
21
24
  })
22
25
  })
@@ -1,3 +1,6 @@
1
+ // SPDX-FileCopyrightText: © 2024 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
1
4
  // Forked from @ledgerhq/live-currency-format/src/localeUtility.ts
2
5
  const memoize = <T extends (arg: string) => ReturnType<T>>(fn: T): T => {
3
6
  const cache: Record<string, ReturnType<T>> = {}
@@ -1,6 +1,9 @@
1
+ // SPDX-FileCopyrightText: © 2024 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { Unit } from '../api/types'
1
5
  // Forked from @ledgerhq/live-currency-format/src/parseCurrencyUnit.test.ts
2
6
  import { BigNumber } from 'bignumber.js'
3
- import type { Unit } from '../api/types'
4
7
  import { parseCurrencyUnit } from './parseCurrencyUnit'
5
8
 
6
9
  const unit: Unit = {
@@ -1,3 +1,6 @@
1
+ // SPDX-FileCopyrightText: © 2024 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
1
4
  // Forked from @ledgerhq/live-currency-format/src/parseCurrencyUnit.ts
2
5
  import type { Unit } from '../api/types'
3
6
  import { BigNumber } from 'bignumber.js'
package/src/errors.ts CHANGED
@@ -1,3 +1,6 @@
1
+ // SPDX-FileCopyrightText: © 2024 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
1
4
  import { createCustomErrorClass } from '@ledgerhq/errors'
2
5
 
3
6
  /** When a coin-module has no CoinConfig setted */
@@ -1,3 +1,6 @@
1
+ // SPDX-FileCopyrightText: © 2024 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
1
4
  /**
2
5
  * Feature IDs as defined in https://ledgerhq.atlassian.net/wiki/spaces/CF/pages/6125551933/Coin+modules+-+ADR-003+-+Features+support
3
6
  * These represent the capabilities/features a coin module can support
package/src/index.ts CHANGED
@@ -1,3 +1,6 @@
1
+ // SPDX-FileCopyrightText: © 2024 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
1
4
  import * as api from './api'
2
5
 
3
6
  export default {
@@ -1,3 +1,6 @@
1
+ // SPDX-FileCopyrightText: © 2024 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
1
4
  import { TransactionIntent } from '../api'
2
5
  import { craftTransactionData } from './craftTransactionData'
3
6
 
@@ -1,3 +1,6 @@
1
+ // SPDX-FileCopyrightText: © 2024 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
1
4
  import { TransactionIntent, TxDataNotSupported } from '../api/types'
2
5
 
3
6
  export function craftTransactionData(intent: TransactionIntent): TxDataNotSupported {
package/src/test/utils.ts CHANGED
@@ -1,3 +1,6 @@
1
+ // SPDX-FileCopyrightText: © 2024 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
1
4
  /**
2
5
  * Recursively makes all properties optional.
3
6
  * Arrays keep their element type (but each element is deeply partial).
package/src/utils.test.ts CHANGED
@@ -1,3 +1,6 @@
1
+ // SPDX-FileCopyrightText: © 2024 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
1
4
  import BigNumber from 'bignumber.js'
2
5
  import { fromBigNumberToBigInt } from './utils'
3
6
 
package/src/utils.ts CHANGED
@@ -1,3 +1,6 @@
1
+ // SPDX-FileCopyrightText: © 2024 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
1
4
  import BigNumber from 'bignumber.js'
2
5
  import { SendTransactionIntent, StakingTransactionIntent, TransactionIntent } from './api'
3
6
 
@@ -5,7 +8,7 @@ export function fromBigNumberToBigInt<T>(
5
8
  bigNumber: BigNumber | undefined,
6
9
  defaultValue?: T
7
10
  ): bigint | T {
8
- if (bigNumber != null) {
11
+ if (BigNumber.isBigNumber(bigNumber)) {
9
12
  return BigInt(bigNumber.toFixed())
10
13
  }
11
14
  return defaultValue as T
package/.eslintrc.js DELETED
@@ -1,20 +0,0 @@
1
- module.exports = {
2
- env: {
3
- browser: true,
4
- es6: true,
5
- },
6
- overrides: [
7
- {
8
- files: ["src/**/*.test.{ts,tsx}"],
9
- env: {
10
- "jest/globals": true,
11
- },
12
- plugins: ["jest"],
13
- },
14
- ],
15
- rules: {
16
- "no-console": ["error", { allow: ["warn", "error"] }],
17
- "@typescript-eslint/no-empty-function": "off",
18
- "@typescript-eslint/no-explicit-any": "warn",
19
- },
20
- };
@@ -1,32 +0,0 @@
1
- {
2
- "entry": [
3
- "src/api/index.ts",
4
- "src/currencies/index.ts",
5
- "src/index.ts",
6
- "src/utils.ts"
7
- ],
8
- "ignoreUnimported": [
9
- "src/api/errors.ts",
10
- "src/api/index.ts",
11
- "src/api/types.ts",
12
- "src/config.ts",
13
- "src/currencies/formatCurrencyUnit.ts",
14
- "src/currencies/index.ts",
15
- "src/currencies/parseCurrencyUnit.ts",
16
- "src/errors.ts",
17
- "src/features/types.ts",
18
- "src/setup.ts",
19
- "src/test/utils.ts",
20
- "src/utils.ts",
21
- "src/api/getBalance/rejectBalanceOptions.ts",
22
- "src/logic/craftTransactionData.ts"
23
- ],
24
- "ignoreUnresolved": [
25
- "src/features/types.ts",
26
- "src/utils.ts"
27
- ],
28
- "ignoreUnused": [
29
- "@ledgerhq/errors",
30
- "expect"
31
- ]
32
- }