@ledgerhq/coin-module-framework 0.1.9 → 1.0.5
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/CHANGELOG.md +30 -0
- package/lib/api/errors.d.ts +4 -0
- package/lib/api/errors.d.ts.map +1 -0
- package/lib/api/errors.js +10 -0
- package/lib/api/errors.js.map +1 -0
- package/lib/api/index.d.ts +7 -0
- package/lib/api/index.d.ts.map +1 -0
- package/lib/api/index.js +23 -0
- package/lib/api/index.js.map +1 -0
- package/lib/api/types.d.ts +568 -0
- package/lib/api/types.d.ts.map +1 -0
- package/lib/api/types.js +3 -0
- package/lib/api/types.js.map +1 -0
- package/lib/config.d.ts +43 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +21 -0
- package/lib/config.js.map +1 -0
- package/lib/currencies/formatCurrencyUnit.d.ts +2 -0
- package/lib/currencies/formatCurrencyUnit.d.ts.map +1 -0
- package/lib/currencies/formatCurrencyUnit.js +7 -0
- package/lib/currencies/formatCurrencyUnit.js.map +1 -0
- package/lib/currencies/index.d.ts +3 -0
- package/lib/currencies/index.d.ts.map +1 -0
- package/lib/currencies/index.js +9 -0
- package/lib/currencies/index.js.map +1 -0
- package/lib/currencies/parseCurrencyUnit.d.ts +2 -0
- package/lib/currencies/parseCurrencyUnit.d.ts.map +1 -0
- package/lib/currencies/parseCurrencyUnit.js +6 -0
- package/lib/currencies/parseCurrencyUnit.js.map +1 -0
- package/lib/errors.d.ts +5 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +7 -0
- package/lib/errors.js.map +1 -0
- package/lib/features/types.d.ts +46 -0
- package/lib/features/types.d.ts.map +1 -0
- package/lib/features/types.js +18 -0
- package/lib/features/types.js.map +1 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +40 -0
- package/lib/index.js.map +1 -0
- package/lib/setup.d.ts +2 -0
- package/lib/setup.d.ts.map +1 -0
- package/lib/setup.js +6 -0
- package/lib/setup.js.map +1 -0
- package/lib/test/utils.d.ts +20 -0
- package/lib/test/utils.d.ts.map +1 -0
- package/lib/test/utils.js +3 -0
- package/lib/test/utils.js.map +1 -0
- package/lib/utils.d.ts +6 -0
- package/lib/utils.d.ts.map +1 -0
- package/lib/utils.js +18 -0
- package/lib/utils.js.map +1 -0
- package/lib-es/api/errors.d.ts +4 -0
- package/lib-es/api/errors.d.ts.map +1 -0
- package/lib-es/api/errors.js +6 -0
- package/lib-es/api/errors.js.map +1 -0
- package/lib-es/api/index.d.ts +7 -0
- package/lib-es/api/index.d.ts.map +1 -0
- package/lib-es/api/index.js +7 -0
- package/lib-es/api/index.js.map +1 -0
- package/lib-es/api/types.d.ts +568 -0
- package/lib-es/api/types.d.ts.map +1 -0
- package/lib-es/api/types.js +2 -0
- package/lib-es/api/types.js.map +1 -0
- package/lib-es/config.d.ts +43 -0
- package/lib-es/config.d.ts.map +1 -0
- package/lib-es/config.js +19 -0
- package/lib-es/config.js.map +1 -0
- package/lib-es/currencies/formatCurrencyUnit.d.ts +2 -0
- package/lib-es/currencies/formatCurrencyUnit.d.ts.map +1 -0
- package/lib-es/currencies/formatCurrencyUnit.js +2 -0
- package/lib-es/currencies/formatCurrencyUnit.js.map +1 -0
- package/lib-es/currencies/index.d.ts +3 -0
- package/lib-es/currencies/index.d.ts.map +1 -0
- package/lib-es/currencies/index.js +3 -0
- package/lib-es/currencies/index.js.map +1 -0
- package/lib-es/currencies/parseCurrencyUnit.d.ts +2 -0
- package/lib-es/currencies/parseCurrencyUnit.d.ts.map +1 -0
- package/lib-es/currencies/parseCurrencyUnit.js +2 -0
- package/lib-es/currencies/parseCurrencyUnit.js.map +1 -0
- package/lib-es/errors.d.ts +5 -0
- package/lib-es/errors.d.ts.map +1 -0
- package/lib-es/errors.js +4 -0
- package/lib-es/errors.js.map +1 -0
- package/lib-es/features/types.d.ts +46 -0
- package/lib-es/features/types.d.ts.map +1 -0
- package/lib-es/features/types.js +14 -0
- package/lib-es/features/types.js.map +1 -0
- package/lib-es/index.d.ts +6 -0
- package/lib-es/index.d.ts.map +1 -0
- package/lib-es/index.js +5 -0
- package/lib-es/index.js.map +1 -0
- package/lib-es/setup.d.ts +2 -0
- package/lib-es/setup.d.ts.map +1 -0
- package/lib-es/setup.js +4 -0
- package/lib-es/setup.js.map +1 -0
- package/lib-es/test/utils.d.ts +20 -0
- package/lib-es/test/utils.d.ts.map +1 -0
- package/lib-es/test/utils.js +2 -0
- package/lib-es/test/utils.js.map +1 -0
- package/lib-es/utils.d.ts +6 -0
- package/lib-es/utils.d.ts.map +1 -0
- package/lib-es/utils.js +13 -0
- package/lib-es/utils.js.map +1 -0
- package/package.json +1 -1
- package/tsconfig.build.json +5 -2
- package/tsconfig.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatCurrencyUnit.js","sourceRoot":"","sources":["../../src/currencies/formatCurrencyUnit.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,0BAA0B,GAG3B,MAAM,gCAAgC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/currencies/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,KAAK,yBAAyB,EAC9B,KAAK,cAAc,GACpB,MAAM,sBAAsB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/currencies/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EACL,kBAAkB,EAClB,0BAA0B,GAG3B,MAAM,sBAAsB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseCurrencyUnit.d.ts","sourceRoot":"","sources":["../../src/currencies/parseCurrencyUnit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseCurrencyUnit.js","sourceRoot":"","sources":["../../src/currencies/parseCurrencyUnit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA,kDAAkD;AAClD,eAAO,MAAM,iBAAiB;;EAA8C,CAAA"}
|
package/lib-es/errors.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AAEzD,kDAAkD;AAClD,MAAM,CAAC,MAAM,iBAAiB,GAAG,sBAAsB,CAAC,mBAAmB,CAAC,CAAA"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Feature IDs as defined in https://ledgerhq.atlassian.net/wiki/spaces/CF/pages/6125551933/Coin+modules+-+ADR-003+-+Features+support
|
|
3
|
+
* These represent the capabilities/features a coin module can support
|
|
4
|
+
*/
|
|
5
|
+
export type FeatureId = 'blockchain_txs' | 'staking_txs';
|
|
6
|
+
/**
|
|
7
|
+
* Intent types for blockchain_txs feature
|
|
8
|
+
*/
|
|
9
|
+
export type BlockchainTxsIntent = 'send';
|
|
10
|
+
/**
|
|
11
|
+
* Intent types for staking_txs feature
|
|
12
|
+
*/
|
|
13
|
+
export type StakingTxsIntent = 'delegate' | 'undelegate' | 'redelegate' | 'claimReward' | 'withdraw';
|
|
14
|
+
/**
|
|
15
|
+
* Mapping from feature ID to its supported intents
|
|
16
|
+
*/
|
|
17
|
+
export type FeatureIntentMap = {
|
|
18
|
+
blockchain_txs: BlockchainTxsIntent;
|
|
19
|
+
staking_txs: StakingTxsIntent;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* A supported feature declaration in a coin module
|
|
23
|
+
* Maps feature IDs to their supported intents
|
|
24
|
+
* Example: { "blockchain_txs": ["send"], "staking_txs": ["delegate", "claimReward"] }
|
|
25
|
+
*/
|
|
26
|
+
export type SupportedFeatures = Partial<Record<FeatureId, string[]>>;
|
|
27
|
+
/**
|
|
28
|
+
* Feature status in liveconfig
|
|
29
|
+
*/
|
|
30
|
+
export type FeatureStatus = 'active' | 'inactive';
|
|
31
|
+
/**
|
|
32
|
+
* Feature configuration in liveconfig
|
|
33
|
+
*/
|
|
34
|
+
export type FeatureConfig = {
|
|
35
|
+
id: FeatureId;
|
|
36
|
+
status: FeatureStatus;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Helper function to check if a feature is supported
|
|
40
|
+
*/
|
|
41
|
+
export declare function hasFeature(supportedFeatures: SupportedFeatures, featureId: FeatureId): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Helper function to check if an intent is supported for a feature
|
|
44
|
+
*/
|
|
45
|
+
export declare function hasIntent(supportedFeatures: SupportedFeatures, featureId: FeatureId, intent: string): boolean;
|
|
46
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/features/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,SAAS,GAEjB,gBAAgB,GAEhB,aAAa,CAAA;AAEjB;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAA;AAExC;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,YAAY,GAAG,YAAY,GAAG,aAAa,GAAG,UAAU,CAAA;AAEpG;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,cAAc,EAAE,mBAAmB,CAAA;IACnC,WAAW,EAAE,gBAAgB,CAAA;CAC9B,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC,CAAA;AAEpE;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,UAAU,CAAA;AAEjD;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,SAAS,CAAA;IACb,MAAM,EAAE,aAAa,CAAA;CACtB,CAAA;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,iBAAiB,EAAE,iBAAiB,EAAE,SAAS,EAAE,SAAS,GAAG,OAAO,CAE9F;AAED;;GAEG;AACH,wBAAgB,SAAS,CACvB,iBAAiB,EAAE,iBAAiB,EACpC,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,GACb,OAAO,CAGT"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper function to check if a feature is supported
|
|
3
|
+
*/
|
|
4
|
+
export function hasFeature(supportedFeatures, featureId) {
|
|
5
|
+
return featureId in supportedFeatures;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Helper function to check if an intent is supported for a feature
|
|
9
|
+
*/
|
|
10
|
+
export function hasIntent(supportedFeatures, featureId, intent) {
|
|
11
|
+
const intents = supportedFeatures[featureId];
|
|
12
|
+
return intents?.includes(intent) ?? false;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/features/types.ts"],"names":[],"mappings":"AAgDA;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,iBAAoC,EAAE,SAAoB;IACnF,OAAO,SAAS,IAAI,iBAAiB,CAAA;AACvC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CACvB,iBAAoC,EACpC,SAAoB,EACpB,MAAc;IAEd,MAAM,OAAO,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAA;IAC5C,OAAO,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK,CAAA;AAC3C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,OAAO,CAAA;;;;AAE5B,wBAEC"}
|
package/lib-es/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,OAAO,CAAA;AAE5B,eAAe;IACb,GAAG;CACJ,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":""}
|
package/lib-es/setup.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recursively makes all properties optional.
|
|
3
|
+
* Arrays keep their element type (but each element is deeply partial).
|
|
4
|
+
* Primitives and built-in value types (Date, RegExp) are preserved as-is.
|
|
5
|
+
*/
|
|
6
|
+
export type DeepPartial<T> = T extends (infer U)[] ? DeepPartial<U>[] : T extends Date | RegExp ? T : T extends object ? {
|
|
7
|
+
[K in keyof T]?: DeepPartial<T[K]>;
|
|
8
|
+
} : T;
|
|
9
|
+
/**
|
|
10
|
+
* Re-types a function so its return value is wrapped in `Promise<DeepPartial<…>>`,
|
|
11
|
+
* while keeping the original parameter types intact.
|
|
12
|
+
*
|
|
13
|
+
* Useful for typing Jest mock functions that return partial RPC/API data:
|
|
14
|
+
* ```ts
|
|
15
|
+
* const mock = jest.fn() as jest.MockedFunction<DeepPartialReturn<SomeApi["method"]>>;
|
|
16
|
+
* mock.mockResolvedValue({ onlyTheFieldsWeNeed: true });
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export type DeepPartialReturn<F extends (...args: never[]) => unknown> = (...args: Parameters<F>) => Promise<DeepPartial<Awaited<ReturnType<F>>>>;
|
|
20
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/test/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GAC9C,WAAW,CAAC,CAAC,CAAC,EAAE,GAChB,CAAC,SAAS,IAAI,GAAG,MAAM,GACrB,CAAC,GACD,CAAC,SAAS,MAAM,GACd;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GACtC,CAAC,CAAA;AAET;;;;;;;;;GASG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,IAAI,CACvE,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KACnB,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/test/utils.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import BigNumber from 'bignumber.js';
|
|
2
|
+
import { SendTransactionIntent, StakingTransactionIntent, TransactionIntent } from './api';
|
|
3
|
+
export declare function fromBigNumberToBigInt<T>(bigNumber: BigNumber | undefined, defaultValue?: T): bigint | T;
|
|
4
|
+
export declare function isSendTransactionIntent(tx: TransactionIntent): tx is SendTransactionIntent;
|
|
5
|
+
export declare function isStakingTransactionIntent(tx: TransactionIntent): tx is StakingTransactionIntent;
|
|
6
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +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"}
|
package/lib-es/utils.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function fromBigNumberToBigInt(bigNumber, defaultValue) {
|
|
2
|
+
if (bigNumber != null) {
|
|
3
|
+
return BigInt(bigNumber.toFixed());
|
|
4
|
+
}
|
|
5
|
+
return defaultValue;
|
|
6
|
+
}
|
|
7
|
+
export function isSendTransactionIntent(tx) {
|
|
8
|
+
return tx.intentType === 'transaction';
|
|
9
|
+
}
|
|
10
|
+
export function isStakingTransactionIntent(tx) {
|
|
11
|
+
return tx.intentType === 'staking';
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +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"}
|
package/package.json
CHANGED
package/tsconfig.build.json
CHANGED
package/tsconfig.json
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"declaration": true,
|
|
5
5
|
"declarationMap": true,
|
|
6
|
-
"downlevelIteration": true,
|
|
7
6
|
"lib": [
|
|
8
7
|
"es2020",
|
|
9
8
|
"dom"
|
|
@@ -13,6 +12,7 @@
|
|
|
13
12
|
"jest"
|
|
14
13
|
],
|
|
15
14
|
"outDir": "lib",
|
|
15
|
+
"rootDir": "src",
|
|
16
16
|
"exactOptionalPropertyTypes": true,
|
|
17
17
|
"typeRoots": [
|
|
18
18
|
"./types",
|