@ledgerhq/coin-module-framework 2.1.0 → 3.0.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/.eslintrc.js +3 -0
- package/.unimportedrc.json +17 -5
- package/CHANGELOG.md +16 -0
- package/LICENSE +194 -0
- package/jest-global-setup.js +3 -0
- package/jest.config.js +3 -1
- 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 +14 -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 +2 -0
- 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 +3 -0
- package/lib/logic/craftTransactionData.d.ts.map +1 -0
- package/lib/logic/craftTransactionData.js +10 -0
- package/lib/logic/craftTransactionData.js.map +1 -0
- 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 +2 -0
- 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 +14 -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 +2 -0
- 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 +3 -0
- package/lib-es/logic/craftTransactionData.d.ts.map +1 -0
- package/lib-es/logic/craftTransactionData.js +7 -0
- package/lib-es/logic/craftTransactionData.js.map +1 -0
- 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 +2 -0
- package/lib-es/utils.js.map +1 -1
- package/package.json +4 -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 +18 -6
- package/src/config.ts +3 -0
- package/src/currencies/BigNumberToLocaleString.test.ts +3 -0
- package/src/currencies/BigNumberToLocaleString.ts +3 -0
- package/src/currencies/formatCurrencyUnit.test.ts +3 -0
- package/src/currencies/formatCurrencyUnit.ts +3 -0
- package/src/currencies/index.ts +3 -0
- package/src/currencies/localeUtility.test.ts +3 -0
- package/src/currencies/localeUtility.ts +3 -0
- package/src/currencies/parseCurrencyUnit.test.ts +3 -0
- 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 +11 -0
- package/src/logic/craftTransactionData.ts +9 -0
- package/src/test/utils.ts +3 -0
- package/src/utils.test.ts +3 -0
- package/src/utils.ts +3 -0
- package/lib/setup.d.ts +0 -2
- package/lib/setup.d.ts.map +0 -1
- package/lib/setup.js +0 -6
- package/lib/setup.js.map +0 -1
- package/lib-es/setup.d.ts +0 -2
- package/lib-es/setup.d.ts.map +0 -1
- package/lib-es/setup.js +0 -4
- package/lib-es/setup.js.map +0 -1
- package/src/setup.ts +0 -4
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;AAKtC,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/coin-module-framework",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Ledger framework for Coin integration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ledger",
|
|
@@ -49,19 +49,19 @@
|
|
|
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"
|
|
55
56
|
},
|
|
56
57
|
"peerDependencies": {
|
|
57
|
-
"@ledgerhq/errors": "^6.33.0"
|
|
58
|
-
"@ledgerhq/live-env": "^2.31.0"
|
|
58
|
+
"@ledgerhq/errors": "^6.33.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/node": "^24.0.0",
|
|
62
62
|
"@types/jest": "^30.0.0",
|
|
63
63
|
"cross-env": "^7.0.3",
|
|
64
|
-
"jest": "
|
|
64
|
+
"jest": "30.2.0",
|
|
65
65
|
"@swc/jest": "0.2.39",
|
|
66
66
|
"@swc/core": "1.15.11"
|
|
67
67
|
},
|
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). */
|
|
@@ -217,7 +220,7 @@ export type StakeState =
|
|
|
217
220
|
* as several {@link Stake}.
|
|
218
221
|
*
|
|
219
222
|
* @see Reward
|
|
220
|
-
* @see
|
|
223
|
+
* @see CoinModuleApi#getStakes
|
|
221
224
|
*/
|
|
222
225
|
export type Stake = {
|
|
223
226
|
/** An immutable, globally unique id of the stake. Depending on the blockchain, it could simply be the account address,
|
|
@@ -260,7 +263,7 @@ export type Stake = {
|
|
|
260
263
|
* A staking reward distribution event.
|
|
261
264
|
*
|
|
262
265
|
* @see Stake
|
|
263
|
-
* @see
|
|
266
|
+
* @see CoinModuleApi#getRewards
|
|
264
267
|
*/
|
|
265
268
|
export type Reward = {
|
|
266
269
|
/** {@link Stake#uid} via which this reward was obtained. */
|
|
@@ -396,7 +399,7 @@ export type FeeEstimation = {
|
|
|
396
399
|
parameters?: Record<string, unknown>
|
|
397
400
|
}
|
|
398
401
|
|
|
399
|
-
/** Response of {@link
|
|
402
|
+
/** Response of {@link CoinModuleApi#craftTransaction}. */
|
|
400
403
|
export type CraftedTransaction = {
|
|
401
404
|
/** The serialized transaction (encoding is blockchain dependent). */
|
|
402
405
|
transaction: string
|
|
@@ -413,7 +416,7 @@ export type Page<T> = {
|
|
|
413
416
|
next?: Cursor | undefined
|
|
414
417
|
}
|
|
415
418
|
|
|
416
|
-
/** Options for {@link
|
|
419
|
+
/** Options for {@link CoinModuleApi#listOperations}. */
|
|
417
420
|
export type ListOperationsOptions = {
|
|
418
421
|
/**
|
|
419
422
|
* The minimum block height for which to fetch operations (inclusive).
|
|
@@ -491,7 +494,7 @@ export type BalanceOptions = {
|
|
|
491
494
|
includeAssets?: (asset: AssetInfo) => Promise<boolean>
|
|
492
495
|
}
|
|
493
496
|
|
|
494
|
-
export type
|
|
497
|
+
export type CoinModuleApi<
|
|
495
498
|
MemoType extends Memo = MemoNotSupported,
|
|
496
499
|
TxDataType extends TxData = TxDataNotSupported,
|
|
497
500
|
> = {
|
|
@@ -730,4 +733,13 @@ export type AlpacaApi<
|
|
|
730
733
|
address: string,
|
|
731
734
|
parameters: Partial<AddressValidationCurrencyParameters>
|
|
732
735
|
) => Promise<boolean>
|
|
736
|
+
|
|
737
|
+
/**
|
|
738
|
+
* Get a blockchain specific payload. For Ethereum, it would be a calldata,
|
|
739
|
+
* for Solana, it would be instructions, and so on
|
|
740
|
+
*
|
|
741
|
+
* @param intent transaction intent
|
|
742
|
+
* @returns blockchain-specific {@link TxData} for this module
|
|
743
|
+
*/
|
|
744
|
+
craftTransactionData: (intent: TransactionIntent<MemoType, TxDataType>) => TxDataType
|
|
733
745
|
}
|
package/src/config.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/BigNumberToLocaleString.test.ts
|
|
2
5
|
import { BigNumber } from 'bignumber.js'
|
|
3
6
|
import { toLocaleString } from './BigNumberToLocaleString'
|
|
@@ -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/formatCurrencyUnit.test.ts
|
|
2
5
|
// Snapshot tests using @ledgerhq/cryptoassets removed (not available in this repo)
|
|
3
6
|
import { formatCurrencyUnit, formatCurrencyUnitFragment } from './formatCurrencyUnit'
|
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.ts
|
|
2
5
|
const memoize = <T extends (arg: string) => ReturnType<T>>(fn: T): T => {
|
|
3
6
|
const cache: Record<string, ReturnType<T>> = {}
|
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
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: © 2024 LEDGER SAS
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { TransactionIntent } from '../api'
|
|
5
|
+
import { craftTransactionData } from './craftTransactionData'
|
|
6
|
+
|
|
7
|
+
describe('craftTransactionData', () => {
|
|
8
|
+
it('should return not supported tx data', () => {
|
|
9
|
+
expect(craftTransactionData({} as unknown as TransactionIntent)).toEqual({ type: 'none' })
|
|
10
|
+
})
|
|
11
|
+
})
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: © 2024 LEDGER SAS
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { TransactionIntent, TxDataNotSupported } from '../api/types'
|
|
5
|
+
|
|
6
|
+
export function craftTransactionData(intent: TransactionIntent): TxDataNotSupported {
|
|
7
|
+
void intent
|
|
8
|
+
return { type: 'none' }
|
|
9
|
+
}
|
package/src/test/utils.ts
CHANGED
package/src/utils.test.ts
CHANGED
package/src/utils.ts
CHANGED
package/lib/setup.d.ts
DELETED
package/lib/setup.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":""}
|
package/lib/setup.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const bignumber_js_1 = require("bignumber.js");
|
|
4
|
-
const live_env_1 = require("@ledgerhq/live-env");
|
|
5
|
-
bignumber_js_1.BigNumber.set({ DECIMAL_PLACES: (0, live_env_1.getEnv)('BIG_NUMBER_DECIMAL_PLACES') });
|
|
6
|
-
//# sourceMappingURL=setup.js.map
|
package/lib/setup.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":";;AAAA,+CAAwC;AACxC,iDAA2C;AAE3C,wBAAS,CAAC,GAAG,CAAC,EAAE,cAAc,EAAE,IAAA,iBAAM,EAAC,2BAA2B,CAAC,EAAE,CAAC,CAAA"}
|
package/lib-es/setup.d.ts
DELETED
package/lib-es/setup.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":""}
|
package/lib-es/setup.js
DELETED
package/lib-es/setup.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAE3C,SAAS,CAAC,GAAG,CAAC,EAAE,cAAc,EAAE,MAAM,CAAC,2BAA2B,CAAC,EAAE,CAAC,CAAA"}
|
package/src/setup.ts
DELETED