@ledgerhq/coin-module-framework 11.0.0 → 11.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.
Files changed (81) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/lib/api/getBlock/assertBlockHeight.d.ts +2 -0
  3. package/lib/api/getBlock/assertBlockHeight.d.ts.map +1 -0
  4. package/lib/api/getBlock/assertBlockHeight.js +12 -0
  5. package/lib/api/getBlock/assertBlockHeight.js.map +1 -0
  6. package/lib/api/impl.d.ts +19 -1
  7. package/lib/api/impl.d.ts.map +1 -1
  8. package/lib/api/types.d.ts +79 -2
  9. package/lib/api/types.d.ts.map +1 -1
  10. package/lib/api/withDefaults.d.ts +13 -2
  11. package/lib/api/withDefaults.d.ts.map +1 -1
  12. package/lib/api/withDefaults.js +35 -1
  13. package/lib/api/withDefaults.js.map +1 -1
  14. package/lib/currencies/formatCurrencyUnit.js +1 -1
  15. package/lib/currencies/formatCurrencyUnit.js.map +1 -1
  16. package/lib/currencies/parseCurrencyUnit.js +1 -1
  17. package/lib/currencies/parseCurrencyUnit.js.map +1 -1
  18. package/lib/errors.d.ts +37 -1
  19. package/lib/errors.d.ts.map +1 -1
  20. package/lib/errors.js +71 -2
  21. package/lib/errors.js.map +1 -1
  22. package/lib/promises/promises.d.ts +1 -1
  23. package/lib/promises/promises.d.ts.map +1 -1
  24. package/lib/promises/promises.js +1 -1
  25. package/lib/promises/promises.js.map +1 -1
  26. package/lib/utils.d.ts +1 -0
  27. package/lib/utils.d.ts.map +1 -1
  28. package/lib/utils.js +9 -0
  29. package/lib/utils.js.map +1 -1
  30. package/lib-es/api/getBlock/assertBlockHeight.d.ts +2 -0
  31. package/lib-es/api/getBlock/assertBlockHeight.d.ts.map +1 -0
  32. package/lib-es/api/getBlock/assertBlockHeight.js +9 -0
  33. package/lib-es/api/getBlock/assertBlockHeight.js.map +1 -0
  34. package/lib-es/api/impl.d.ts +19 -1
  35. package/lib-es/api/impl.d.ts.map +1 -1
  36. package/lib-es/api/types.d.ts +79 -2
  37. package/lib-es/api/types.d.ts.map +1 -1
  38. package/lib-es/api/withDefaults.d.ts +13 -2
  39. package/lib-es/api/withDefaults.d.ts.map +1 -1
  40. package/lib-es/api/withDefaults.js +35 -1
  41. package/lib-es/api/withDefaults.js.map +1 -1
  42. package/lib-es/currencies/formatCurrencyUnit.js +1 -1
  43. package/lib-es/currencies/formatCurrencyUnit.js.map +1 -1
  44. package/lib-es/currencies/parseCurrencyUnit.js +1 -1
  45. package/lib-es/currencies/parseCurrencyUnit.js.map +1 -1
  46. package/lib-es/errors.d.ts +37 -1
  47. package/lib-es/errors.d.ts.map +1 -1
  48. package/lib-es/errors.js +64 -1
  49. package/lib-es/errors.js.map +1 -1
  50. package/lib-es/promises/promises.d.ts +1 -1
  51. package/lib-es/promises/promises.d.ts.map +1 -1
  52. package/lib-es/promises/promises.js +1 -1
  53. package/lib-es/promises/promises.js.map +1 -1
  54. package/lib-es/utils.d.ts +1 -0
  55. package/lib-es/utils.d.ts.map +1 -1
  56. package/lib-es/utils.js +8 -0
  57. package/lib-es/utils.js.map +1 -1
  58. package/package.json +12 -6
  59. package/src/api/getBalance/rejectBalanceOptions.test.ts +8 -0
  60. package/src/api/getBlock/assertBlockHeight.test.ts +28 -0
  61. package/src/api/getBlock/assertBlockHeight.ts +10 -0
  62. package/src/api/impl.ts +22 -1
  63. package/src/api/types.ts +97 -3
  64. package/src/api/withDefaults.test.ts +124 -1
  65. package/src/api/withDefaults.ts +65 -3
  66. package/src/currencies/formatCurrencyUnit.test.ts +14 -0
  67. package/src/currencies/formatCurrencyUnit.ts +1 -1
  68. package/src/currencies/parseCurrencyUnit.test.ts +5 -0
  69. package/src/currencies/parseCurrencyUnit.ts +1 -1
  70. package/src/errors.test.ts +89 -0
  71. package/src/errors.ts +59 -1
  72. package/src/promises/promises.test.ts +1 -1
  73. package/src/promises/promises.ts +1 -1
  74. package/src/utils.test.ts +24 -1
  75. package/src/utils.ts +11 -0
  76. package/.oxlintrc.json +0 -17
  77. package/jest-global-setup.js +0 -12
  78. package/jest.config.js +0 -32
  79. package/knip.json +0 -15
  80. package/tsconfig.build.json +0 -21
  81. package/tsconfig.json +0 -26
@@ -2,13 +2,21 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import type { CurrencyConfig } from '../config'
5
- import type { CoinModuleImpl, OptionalApiKey } from './impl'
5
+ import type {
6
+ CoinModuleImpl,
7
+ OptionalApiKey,
8
+ ReadOption,
9
+ ReadOptionMethod,
10
+ ReadOptionsDeclaration,
11
+ } from './impl'
6
12
  import type { CoinModuleApi, Memo, MemoNotSupported, TxData, TxDataNotSupported } from './types'
13
+ import { InvalidParameterError } from '../errors'
7
14
  import { optionalApiKeys } from './impl'
8
15
  import { isNotSupportedStub, notSupported } from './notSupported'
9
16
 
10
17
  /**
11
- * What {@link withDefaults} returns: the full consumer contract, plus `supports()`.
18
+ * What {@link withDefaults} returns: the full consumer contract, plus `supports()` and
19
+ * `supportsReadOption()`.
12
20
  *
13
21
  * `getAccountInfo` is narrowed to required. It is the one managed capability that
14
22
  * {@link CoinModuleApi} itself declares optional, and `withDefaults` always supplies it — so
@@ -22,6 +30,13 @@ export type WithDefaultsResult<
22
30
  > = CoinModuleApi<ConfigType, MemoType, TxDataType> &
23
31
  Required<Pick<CoinModuleApi<ConfigType, MemoType, TxDataType>, 'getAccountInfo'>> & {
24
32
  supports: (method: OptionalApiKey) => boolean
33
+ /**
34
+ * Whether `method` honours the read `option`: the module implements the method and declares
35
+ * the option in `readOptions`. When the method is implemented but does not declare the option,
36
+ * an opted-in call rejects with an {@link InvalidParameterError}. When the method is not
37
+ * implemented, every call throws `"<method> is not supported"`, as without the option.
38
+ */
39
+ supportsReadOption: (method: ReadOptionMethod, option: ReadOption) => boolean
25
40
  }
26
41
 
27
42
  /**
@@ -35,6 +50,33 @@ function implemented<T>(value: T | undefined): T | undefined {
35
50
  return value === undefined || isNotSupportedStub(value) ? undefined : value
36
51
  }
37
52
 
53
+ function declares(
54
+ readOptions: ReadOptionsDeclaration | undefined,
55
+ method: ReadOptionMethod,
56
+ option: ReadOption
57
+ ): boolean {
58
+ return readOptions?.[method]?.includes(option) ?? false
59
+ }
60
+
61
+ /**
62
+ * Rejects an opted-in call to a method that does not declare the `feesAsset` read option.
63
+ *
64
+ * Both guarded methods take their options as the third argument. A call without the option goes
65
+ * through with its arguments and its receiver unchanged: an implementation may read `this`.
66
+ */
67
+ function guardFeesAsset<Args extends [unknown, unknown, ({ feesAsset?: boolean } | undefined)?], R>(
68
+ method: ReadOptionMethod,
69
+ fn: (...args: Args) => Promise<R>,
70
+ declared: boolean
71
+ ): (...args: Args) => Promise<R> {
72
+ if (declared) return fn
73
+ return function (this: unknown, ...args: Args): Promise<R> {
74
+ return args[2]?.feesAsset
75
+ ? Promise.reject(new InvalidParameterError(`${method} does not support the feesAsset option`))
76
+ : fn.apply(this, args)
77
+ }
78
+ }
79
+
38
80
  /**
39
81
  * Widens a {@link CoinModuleImpl} authoring value to the full {@link CoinModuleApi}
40
82
  * consumer contract by backfilling the capability methods the author omitted, and attaches
@@ -49,6 +91,9 @@ function implemented<T>(value: T | undefined): T | undefined {
49
91
  *
50
92
  * A capability method is considered implemented only when the author supplied a real
51
93
  * function — a `notSupported()` stub is treated as if the method had been omitted.
94
+ *
95
+ * `listOperations` and `getBlock` reject a call that sets a read option the module does not
96
+ * declare in `readOptions` (see `ReadOptionsDeclaration`). Calls without it are unchanged.
52
97
  */
53
98
  export function withDefaults<
54
99
  ConfigType extends CurrencyConfig,
@@ -61,12 +106,28 @@ export function withDefaults<
61
106
  const implementedMethods = new Set<OptionalApiKey>(
62
107
  optionalApiKeys.filter((k) => implemented(impl[k]) !== undefined)
63
108
  )
109
+ // A stub stays the tagged stub, not a guarded wrapper: callers detect it as "not supported".
110
+ // listOperations is required, but a read-only module built on notSupportedApi() may stub it.
111
+ const listOperations = implemented(impl.listOperations)
112
+ const getBlock = implemented(impl.getBlock)
113
+ const supportsReadOption = (method: ReadOptionMethod, option: ReadOption): boolean =>
114
+ (method === 'listOperations' ? listOperations !== undefined : getBlock !== undefined) &&
115
+ declares(impl.readOptions, method, option)
64
116
 
65
117
  // Spread first so anything the module exposes beyond the API surface survives, then
66
118
  // override every capability method with either the real implementation or the default.
67
119
  return {
68
120
  ...impl,
69
- getBlock: implemented(impl.getBlock) ?? notSupported('getBlock'),
121
+ listOperations: listOperations
122
+ ? guardFeesAsset(
123
+ 'listOperations',
124
+ listOperations,
125
+ supportsReadOption('listOperations', 'feesAsset')
126
+ )
127
+ : impl.listOperations,
128
+ getBlock: getBlock
129
+ ? guardFeesAsset('getBlock', getBlock, supportsReadOption('getBlock', 'feesAsset'))
130
+ : notSupported('getBlock'),
70
131
  getBlockInfo: implemented(impl.getBlockInfo) ?? notSupported('getBlockInfo'),
71
132
  getStakes: implemented(impl.getStakes) ?? notSupported('getStakes'),
72
133
  getRewards: implemented(impl.getRewards) ?? notSupported('getRewards'),
@@ -83,5 +144,6 @@ export function withDefaults<
83
144
  // of a throwing stub. Callers read `type` and branch on it.
84
145
  getAccountInfo: implemented(impl.getAccountInfo) ?? (() => Promise.resolve({ type: 'none' })),
85
146
  supports: (method: OptionalApiKey): boolean => implementedMethods.has(method),
147
+ supportsReadOption,
86
148
  }
87
149
  }
@@ -105,6 +105,20 @@ describe('formatCurrencyUnit', () => {
105
105
  )
106
106
  })
107
107
 
108
+ test('showAllDigits with magnitude above default DECIMAL_PLACES', () => {
109
+ const highMagUnit: Unit = { ...unit, magnitude: 24 }
110
+ expect(formatCurrencyUnit(highMagUnit, new BigNumber(1), { showAllDigits: true })).toBe(
111
+ '0.000000000000000000000001'
112
+ )
113
+ })
114
+
115
+ test('disableRounding with magnitude above default DECIMAL_PLACES', () => {
116
+ const highMagUnit: Unit = { ...unit, magnitude: 24 }
117
+ expect(formatCurrencyUnit(highMagUnit, new BigNumber(1), { disableRounding: true })).toBe(
118
+ '0.000000000000000000000001'
119
+ )
120
+ })
121
+
108
122
  test('filters undefined options', () => {
109
123
  expect(
110
124
  // @ts-expect-error explicit undefined, for JS callers
@@ -100,7 +100,7 @@ const buildFormatState = (
100
100
  staticSignificantDigits,
101
101
  } = resolvedOptions
102
102
  const { magnitude, code } = unit
103
- const floatValue = value.div(new BigNumber(10).pow(magnitude))
103
+ const floatValue = value.shiftedBy(-magnitude)
104
104
  const floatValueAbs = floatValue.abs()
105
105
  const minimumFractionDigits = showAllDigits ? magnitude : 0
106
106
  const maximumFractionDigits = disableRounding
@@ -26,4 +26,9 @@ describe('parseCurrencyUnit', () => {
26
26
  test('returns zero on invalid input', () => {
27
27
  expect(parseCurrencyUnit(unit, 'invalid')).toEqual(new BigNumber(0))
28
28
  })
29
+
30
+ test('parses magnitude above default DECIMAL_PLACES', () => {
31
+ const highMagUnit: Unit = { ...unit, magnitude: 24 }
32
+ expect(parseCurrencyUnit(highMagUnit, '0.000000000000000000000001')).toEqual(new BigNumber(1))
33
+ })
29
34
  })
@@ -9,5 +9,5 @@ export const parseCurrencyUnit = (unit: Unit, valueString: string): BigNumber =>
9
9
  const str = valueString.replace(/,/g, '.')
10
10
  const value = new BigNumber(str)
11
11
  if (value.isNaN()) return new BigNumber(0)
12
- return value.times(new BigNumber(10).pow(unit.magnitude)).integerValue()
12
+ return value.shiftedBy(unit.magnitude).integerValue()
13
13
  }
@@ -0,0 +1,89 @@
1
+ // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import {
5
+ BlockNotFoundError,
6
+ GetBlockError,
7
+ GetBlockInfoError,
8
+ InvalidBlockHeightError,
9
+ InvalidExplorerResponse,
10
+ RateLimitError,
11
+ statusCodeOf,
12
+ } from './errors'
13
+
14
+ type ErrorClass = new (
15
+ message?: string,
16
+ fields?: Record<string, unknown>,
17
+ options?: { cause?: unknown }
18
+ ) => Error
19
+
20
+ const ERRORS: Array<[string, ErrorClass, string | undefined]> = [
21
+ ['BlockNotFoundError', BlockNotFoundError, undefined],
22
+ ['InvalidBlockHeightError', InvalidBlockHeightError, undefined],
23
+ ['RateLimitError', RateLimitError, 'Upstream rate limit exceeded (429), please retry later'],
24
+ ['InvalidExplorerResponse', InvalidExplorerResponse, undefined],
25
+ ['GetBlockInfoError', GetBlockInfoError, undefined],
26
+ ['GetBlockError', GetBlockError, undefined],
27
+ ]
28
+
29
+ describe.each(ERRORS)('%s', (name, ErrorType, defaultMessage) => {
30
+ it('is an Error named after its class with a default message', () => {
31
+ const error = new ErrorType()
32
+
33
+ expect(error).toBeInstanceOf(Error)
34
+ expect(error.name).toBe(name)
35
+ expect(error.message).toBe(defaultMessage ?? name)
36
+ expect(error).not.toHaveProperty('cause')
37
+ })
38
+
39
+ it('keeps a custom message', () => {
40
+ expect(new ErrorType('custom').message).toBe('custom')
41
+ })
42
+
43
+ it('exposes the fields as attributes', () => {
44
+ expect(new ErrorType('custom', { height: 12 })).toHaveProperty('height', 12)
45
+ })
46
+
47
+ it('attaches the cause', () => {
48
+ const cause = new Error('root')
49
+
50
+ expect(new ErrorType('custom', { height: 12 }, { cause })).toHaveProperty('cause', cause)
51
+ })
52
+ })
53
+
54
+ describe('statusCode', () => {
55
+ it.each<[string, ErrorClass, number]>([
56
+ ['BlockNotFoundError', BlockNotFoundError, 404],
57
+ ['InvalidBlockHeightError', InvalidBlockHeightError, 400],
58
+ ['RateLimitError', RateLimitError, 429],
59
+ ])('%s carries %d', (_name, ErrorType, statusCode) => {
60
+ expect(new ErrorType()).toHaveProperty('statusCode', statusCode)
61
+ })
62
+
63
+ it('can be overridden through the fields', () => {
64
+ expect(new BlockNotFoundError(undefined, { statusCode: 500 })).toHaveProperty('statusCode', 500)
65
+ })
66
+
67
+ it.each<[string, ErrorClass]>([
68
+ ['InvalidExplorerResponse', InvalidExplorerResponse],
69
+ ['GetBlockInfoError', GetBlockInfoError],
70
+ ['GetBlockError', GetBlockError],
71
+ ])('%s carries none', (_name, ErrorType) => {
72
+ expect(new ErrorType()).not.toHaveProperty('statusCode')
73
+ })
74
+ })
75
+
76
+ describe('statusCodeOf', () => {
77
+ it('returns the numeric status code of an error', () => {
78
+ expect(statusCodeOf(new BlockNotFoundError())).toEqual(404)
79
+ })
80
+
81
+ it('returns nothing when the error has no numeric status code', () => {
82
+ expect(statusCodeOf(new Error('plain'))).toBeUndefined()
83
+ expect(statusCodeOf(Object.assign(new Error('plain'), { statusCode: '404' }))).toBeUndefined()
84
+ })
85
+
86
+ it('returns nothing when nothing was thrown', () => {
87
+ expect(statusCodeOf(undefined)).toBeUndefined()
88
+ })
89
+ })
package/src/errors.ts CHANGED
@@ -121,11 +121,69 @@ export class UnknownError extends Error {
121
121
 
122
122
  export class BlockNotFoundError extends Error {
123
123
  override name = 'BlockNotFoundError'
124
- constructor(message?: string) {
124
+ readonly statusCode = 404
125
+ constructor(message?: string, fields?: Record<string, unknown>, options?: { cause?: unknown }) {
125
126
  super(message || 'BlockNotFoundError')
127
+ if (fields) Object.assign(this, fields)
128
+ if (options?.cause !== undefined) Object.assign(this, { cause: options.cause })
129
+ }
130
+ }
131
+
132
+ export class InvalidBlockHeightError extends Error {
133
+ override name = 'InvalidBlockHeightError'
134
+ readonly statusCode = 400
135
+ constructor(message?: string, fields?: Record<string, unknown>, options?: { cause?: unknown }) {
136
+ super(message || 'InvalidBlockHeightError')
137
+ if (fields) Object.assign(this, fields)
138
+ if (options?.cause !== undefined) Object.assign(this, { cause: options.cause })
139
+ }
140
+ }
141
+
142
+ export class RateLimitError extends Error {
143
+ override name = 'RateLimitError'
144
+ readonly statusCode = 429
145
+ constructor(message?: string, fields?: Record<string, unknown>, options?: { cause?: unknown }) {
146
+ super(message || 'Upstream rate limit exceeded (429), please retry later')
147
+ if (fields) Object.assign(this, fields)
148
+ if (options?.cause !== undefined) Object.assign(this, { cause: options.cause })
149
+ }
150
+ }
151
+
152
+ export class InvalidExplorerResponse extends Error {
153
+ override name = 'InvalidExplorerResponse'
154
+ constructor(message?: string, fields?: Record<string, unknown>, options?: { cause?: unknown }) {
155
+ super(message || 'InvalidExplorerResponse')
156
+ if (fields) Object.assign(this, fields)
157
+ if (options?.cause !== undefined) Object.assign(this, { cause: options.cause })
126
158
  }
127
159
  }
128
160
 
161
+ export class GetBlockInfoError extends Error {
162
+ override name = 'GetBlockInfoError'
163
+ constructor(message?: string, fields?: Record<string, unknown>, options?: { cause?: unknown }) {
164
+ super(message || 'GetBlockInfoError')
165
+ if (fields) Object.assign(this, fields)
166
+ if (options?.cause !== undefined) Object.assign(this, { cause: options.cause })
167
+ }
168
+ }
169
+
170
+ export class GetBlockError extends Error {
171
+ override name = 'GetBlockError'
172
+ constructor(message?: string, fields?: Record<string, unknown>, options?: { cause?: unknown }) {
173
+ super(message || 'GetBlockError')
174
+ if (fields) Object.assign(this, fields)
175
+ if (options?.cause !== undefined) Object.assign(this, { cause: options.cause })
176
+ }
177
+ }
178
+
179
+ export function statusCodeOf(error: unknown): number | undefined {
180
+ if (error instanceof Error && 'statusCode' in error && typeof error.statusCode === 'number') {
181
+ return error.statusCode
182
+ }
183
+
184
+ return undefined
185
+ }
186
+
129
187
  export class UnexpectedGetBalanceError extends Error {
130
188
  override name = 'UnexpectedGetBalanceError'
131
189
  cause: unknown
@@ -44,7 +44,7 @@ describe('promise', () => {
44
44
  await retry(() => testFunction(), {
45
45
  maxRetry: 5,
46
46
  interval: 0,
47
- retryCondition: (_) => true,
47
+ retryCondition: () => true,
48
48
  })
49
49
  } catch (e) {
50
50
  expect(e).toBe(5)
@@ -9,7 +9,7 @@ const defaults = {
9
9
  interval: 300,
10
10
  intervalMultiplicator: 1.5,
11
11
  context: '',
12
- retryCondition: (_: unknown) => true,
12
+ retryCondition: (_error: unknown) => true,
13
13
  }
14
14
 
15
15
  export function retry<A>(f: () => Promise<A>, options?: Partial<typeof defaults>): Promise<A> {
package/src/utils.test.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import BigNumber from 'bignumber.js'
5
- import { fromBigNumberToBigInt } from './utils'
5
+ import { fromBigNumberToBigInt, isHttpTooManyRequests } from './utils'
6
6
 
7
7
  describe('bigNumberToBigInt', () => {
8
8
  it('should convert BigNumber to BigInt', () => {
@@ -24,3 +24,26 @@ describe('bigNumberToBigInt', () => {
24
24
  expect(valBigint).toEqual(BigInt(valueStr))
25
25
  })
26
26
  })
27
+
28
+ describe('isHttpTooManyRequests', () => {
29
+ it('detects an error whose response status is 429', () => {
30
+ expect(
31
+ isHttpTooManyRequests(Object.assign(new Error('429'), { response: { status: 429 } }))
32
+ ).toBe(true)
33
+ })
34
+
35
+ it.each<[string, unknown]>([
36
+ [
37
+ 'a response with another status',
38
+ Object.assign(new Error('500'), { response: { status: 500 } }),
39
+ ],
40
+ ['a response without status', Object.assign(new Error('x'), { response: {} })],
41
+ ['a null response', Object.assign(new Error('x'), { response: null })],
42
+ ['a non-object response', Object.assign(new Error('x'), { response: 429 })],
43
+ ['an error without response', new Error('x')],
44
+ ['a non-error with a 429 response', { response: { status: 429 } }],
45
+ ['nothing', undefined],
46
+ ])('rejects %s', (_label, error) => {
47
+ expect(isHttpTooManyRequests(error)).toBe(false)
48
+ })
49
+ })
package/src/utils.ts CHANGED
@@ -26,3 +26,14 @@ export function isSendTransactionIntent(tx: TransactionIntent): tx is SendTransa
26
26
  export function isStakingTransactionIntent(tx: TransactionIntent): tx is StakingTransactionIntent {
27
27
  return tx.intentType === 'staking'
28
28
  }
29
+
30
+ export function isHttpTooManyRequests(error: unknown): boolean {
31
+ return (
32
+ error instanceof Error &&
33
+ 'response' in error &&
34
+ typeof error.response === 'object' &&
35
+ error.response !== null &&
36
+ 'status' in error.response &&
37
+ error.response.status === 429
38
+ )
39
+ }
package/.oxlintrc.json DELETED
@@ -1,17 +0,0 @@
1
- {
2
- "$schema": "../../node_modules/oxlint/configuration_schema.json",
3
- "extends": ["../../.oxlintrc.json"],
4
- "rules": {
5
- "typescript/no-explicit-any": "error",
6
- "typescript/consistent-type-assertions": ["error", { "assertionStyle": "never" }]
7
- },
8
- "overrides": [
9
- {
10
- "files": ["**/*.test.ts"],
11
- "rules": {
12
- "typescript/no-explicit-any": "error",
13
- "typescript/consistent-type-assertions": ["error", { "assertionStyle": "never" }]
14
- }
15
- }
16
- ]
17
- }
@@ -1,12 +0,0 @@
1
- // SPDX-FileCopyrightText: © 2024 LEDGER SAS
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- module.exports = async () => {
5
- /**
6
- * Set the timezone to EST for all tests
7
- * This allow us to run tests directly through jest without having to manually
8
- * set the timezone as an env var beforehand, either manually or through a
9
- * custom script in package.json
10
- */
11
- process.env.TZ = "America/New_York";
12
- };
package/jest.config.js DELETED
@@ -1,32 +0,0 @@
1
- // SPDX-FileCopyrightText: © 2024 LEDGER SAS
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- module.exports = {
5
- testEnvironment: "node",
6
- transform: {
7
- "^.+\\.(t|j)sx?$": [
8
- "@swc/jest",
9
- {
10
- jsc: {
11
- target: "esnext",
12
- },
13
- },
14
- ],
15
- },
16
- testPathIgnorePatterns: ["lib/", "lib-es/"],
17
- globalSetup: "<rootDir>/jest-global-setup.js",
18
- collectCoverageFrom: [
19
- "src/**/*.{ts,js,tsx}",
20
- "!src/**/*.test.{ts,tsx}",
21
- "!src/**/*.spec.{ts,tsx}",
22
- "!src/**/__integration__/**",
23
- "!src/**/__integrations__/**",
24
- "!src/**/__tests__/**",
25
- ],
26
- coverageReporters: ["json", ["lcov", { file: "lcov.info", projectRoot: "../../" }], "text"],
27
- coverageProvider: "v8",
28
- reporters: [
29
- "default",
30
- ["jest-sonar", { outputName: "sonar-executionTests-report.xml", reportedFilePath: "absolute" }],
31
- ],
32
- };
package/knip.json DELETED
@@ -1,15 +0,0 @@
1
- {
2
- "$schema": "https://unpkg.com/knip@5.34.1/schema.json",
3
- "entry": [
4
- "src/api/errors.ts",
5
- "src/api/getBalance/rejectBalanceOptions.ts",
6
- "src/api/index.ts",
7
- "src/config.ts",
8
- "src/currencies/index.ts",
9
- "src/index.ts",
10
- "src/logic/craftTransactionData.ts",
11
- "src/test/utils.ts",
12
- "src/utils.ts"
13
- ],
14
- "project": ["src/**/*.ts"]
15
- }
@@ -1,21 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "customConditions": [],
5
- "types": [
6
- "node"
7
- ]
8
- },
9
- "exclude": [
10
- "**/*.test.ts",
11
- "**/*.test.tsx",
12
- "**/*.spec.ts",
13
- "**/*.spec.tsx",
14
- "**/__tests__/**/*",
15
- "**/tests/**/*",
16
- "**/*.test.js",
17
- "**/*.test.jsx",
18
- "**/*.spec.js",
19
- "**/*.spec.jsx"
20
- ]
21
- }
package/tsconfig.json DELETED
@@ -1,26 +0,0 @@
1
- {
2
- "extends": "../tsconfig.base",
3
- "compilerOptions": {
4
- "declaration": true,
5
- "declarationMap": true,
6
- "lib": [
7
- "es2020",
8
- "dom"
9
- ],
10
- "types": [
11
- "node",
12
- "jest"
13
- ],
14
- "outDir": "lib",
15
- "rootDir": "src",
16
- "exactOptionalPropertyTypes": true,
17
- "typeRoots": [
18
- "./types",
19
- "./node_modules/@types"
20
- ]
21
- },
22
- "include": [
23
- "src/**/*",
24
- "types/*.d.ts"
25
- ]
26
- }