@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.
- package/.oxlintrc.json +6 -0
- package/CHANGELOG.md +38 -0
- package/LICENSE +194 -0
- package/jest-global-setup.js +3 -0
- package/jest.config.js +3 -0
- package/knip.json +15 -0
- package/lib/api/errors.d.ts.map +1 -1
- package/lib/api/errors.js +2 -0
- package/lib/api/errors.js.map +1 -1
- package/lib/api/getBalance/rejectBalanceOptions.d.ts.map +1 -1
- package/lib/api/getBalance/rejectBalanceOptions.js +2 -0
- package/lib/api/getBalance/rejectBalanceOptions.js.map +1 -1
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +6 -4
- package/lib/api/index.js.map +1 -1
- package/lib/api/types.d.ts +10 -6
- package/lib/api/types.d.ts.map +1 -1
- package/lib/api/types.js +2 -0
- package/lib/api/types.js.map +1 -1
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +2 -0
- package/lib/config.js.map +1 -1
- package/lib/currencies/BigNumberToLocaleString.d.ts.map +1 -1
- package/lib/currencies/BigNumberToLocaleString.js +2 -0
- package/lib/currencies/BigNumberToLocaleString.js.map +1 -1
- package/lib/currencies/formatCurrencyUnit.d.ts.map +1 -1
- package/lib/currencies/formatCurrencyUnit.js +3 -1
- package/lib/currencies/formatCurrencyUnit.js.map +1 -1
- package/lib/currencies/index.d.ts.map +1 -1
- package/lib/currencies/index.js +2 -0
- package/lib/currencies/index.js.map +1 -1
- package/lib/currencies/localeUtility.d.ts.map +1 -1
- package/lib/currencies/localeUtility.js +2 -0
- package/lib/currencies/localeUtility.js.map +1 -1
- package/lib/currencies/parseCurrencyUnit.d.ts.map +1 -1
- package/lib/currencies/parseCurrencyUnit.js +2 -0
- package/lib/currencies/parseCurrencyUnit.js.map +1 -1
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +2 -0
- package/lib/errors.js.map +1 -1
- package/lib/features/types.d.ts.map +1 -1
- package/lib/features/types.js +2 -0
- package/lib/features/types.js.map +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/logic/craftTransactionData.d.ts.map +1 -1
- package/lib/logic/craftTransactionData.js +2 -0
- package/lib/logic/craftTransactionData.js.map +1 -1
- package/lib/test/utils.d.ts.map +1 -1
- package/lib/test/utils.js +2 -0
- package/lib/test/utils.js.map +1 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +7 -1
- package/lib/utils.js.map +1 -1
- package/lib-es/api/errors.d.ts.map +1 -1
- package/lib-es/api/errors.js +2 -0
- package/lib-es/api/errors.js.map +1 -1
- package/lib-es/api/getBalance/rejectBalanceOptions.d.ts.map +1 -1
- package/lib-es/api/getBalance/rejectBalanceOptions.js +2 -0
- package/lib-es/api/getBalance/rejectBalanceOptions.js.map +1 -1
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.js +2 -0
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/api/types.d.ts +10 -6
- package/lib-es/api/types.d.ts.map +1 -1
- package/lib-es/api/types.js +2 -0
- package/lib-es/api/types.js.map +1 -1
- package/lib-es/config.d.ts.map +1 -1
- package/lib-es/config.js +2 -0
- package/lib-es/config.js.map +1 -1
- package/lib-es/currencies/BigNumberToLocaleString.d.ts.map +1 -1
- package/lib-es/currencies/BigNumberToLocaleString.js +2 -0
- package/lib-es/currencies/BigNumberToLocaleString.js.map +1 -1
- package/lib-es/currencies/formatCurrencyUnit.d.ts.map +1 -1
- package/lib-es/currencies/formatCurrencyUnit.js +3 -1
- package/lib-es/currencies/formatCurrencyUnit.js.map +1 -1
- package/lib-es/currencies/index.d.ts.map +1 -1
- package/lib-es/currencies/index.js +2 -0
- package/lib-es/currencies/index.js.map +1 -1
- package/lib-es/currencies/localeUtility.d.ts.map +1 -1
- package/lib-es/currencies/localeUtility.js +2 -0
- package/lib-es/currencies/localeUtility.js.map +1 -1
- package/lib-es/currencies/parseCurrencyUnit.d.ts.map +1 -1
- package/lib-es/currencies/parseCurrencyUnit.js +2 -0
- package/lib-es/currencies/parseCurrencyUnit.js.map +1 -1
- package/lib-es/errors.d.ts.map +1 -1
- package/lib-es/errors.js +2 -0
- package/lib-es/errors.js.map +1 -1
- package/lib-es/features/types.d.ts.map +1 -1
- package/lib-es/features/types.js +2 -0
- package/lib-es/features/types.js.map +1 -1
- package/lib-es/index.d.ts.map +1 -1
- package/lib-es/index.js +2 -0
- package/lib-es/index.js.map +1 -1
- package/lib-es/logic/craftTransactionData.d.ts.map +1 -1
- package/lib-es/logic/craftTransactionData.js +2 -0
- package/lib-es/logic/craftTransactionData.js.map +1 -1
- package/lib-es/test/utils.d.ts.map +1 -1
- package/lib-es/test/utils.js +2 -0
- package/lib-es/test/utils.js.map +1 -1
- package/lib-es/utils.d.ts.map +1 -1
- package/lib-es/utils.js +4 -1
- package/lib-es/utils.js.map +1 -1
- package/package.json +9 -4
- package/src/api/errors.ts +3 -0
- package/src/api/getBalance/rejectBalanceOptions.test.ts +3 -0
- package/src/api/getBalance/rejectBalanceOptions.ts +3 -0
- package/src/api/index.ts +3 -0
- package/src/api/types.ts +15 -6
- package/src/config.ts +4 -1
- package/src/currencies/BigNumberToLocaleString.test.ts +4 -1
- package/src/currencies/BigNumberToLocaleString.ts +3 -0
- package/src/currencies/formatCurrencyUnit.test.ts +5 -2
- package/src/currencies/formatCurrencyUnit.ts +5 -2
- package/src/currencies/index.ts +3 -0
- package/src/currencies/localeUtility.test.ts +7 -4
- package/src/currencies/localeUtility.ts +3 -0
- package/src/currencies/parseCurrencyUnit.test.ts +4 -1
- package/src/currencies/parseCurrencyUnit.ts +3 -0
- package/src/errors.ts +3 -0
- package/src/features/types.ts +3 -0
- package/src/index.ts +3 -0
- package/src/logic/craftTransactionData.test.ts +3 -0
- package/src/logic/craftTransactionData.ts +3 -0
- package/src/test/utils.ts +3 -0
- package/src/utils.test.ts +3 -0
- package/src/utils.ts +4 -1
- package/.eslintrc.js +0 -20
- package/.unimportedrc.json +0 -32
package/lib-es/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"
|
|
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
|
|
5
|
+
if (BigNumber.isBigNumber(bigNumber)) {
|
|
3
6
|
return BigInt(bigNumber.toFixed());
|
|
4
7
|
}
|
|
5
8
|
return defaultValue;
|
package/lib-es/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"
|
|
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": "
|
|
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": "
|
|
75
|
-
"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": "
|
|
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
package/src/api/index.ts
CHANGED
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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).
|
|
161
|
+
expect(resultFr).toBe('1 234,56')
|
|
159
162
|
})
|
|
160
163
|
|
|
161
164
|
test('toLocaleString handles separator types', () => {
|
|
@@ -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
|
|
8
|
+
import { getSeparators } from './localeUtility'
|
|
6
9
|
|
|
7
10
|
const nonBreakableSpace = '\u00A0'
|
|
8
11
|
const defaultFormatOptions = {
|
package/src/currencies/index.ts
CHANGED
|
@@ -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).
|
|
14
|
-
expect(result.thousands).
|
|
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).
|
|
20
|
-
expect(result.thousands).
|
|
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 = {
|
package/src/errors.ts
CHANGED
package/src/features/types.ts
CHANGED
|
@@ -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
package/src/test/utils.ts
CHANGED
package/src/utils.test.ts
CHANGED
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
|
|
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
|
-
};
|
package/.unimportedrc.json
DELETED
|
@@ -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
|
-
}
|