@ledgerhq/coin-module-framework 0.1.9 → 1.0.4
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 +24 -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/lib/api/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":""}
|
package/lib/config.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { CryptoCurrency, CryptoCurrencyId } from '@ledgerhq/types-cryptoassets';
|
|
2
|
+
import type { FeatureConfig } from './features/types';
|
|
3
|
+
type ConfigStatus = {
|
|
4
|
+
type: 'active';
|
|
5
|
+
features?: FeatureConfig[];
|
|
6
|
+
} | {
|
|
7
|
+
type: 'under_maintenance';
|
|
8
|
+
message?: string;
|
|
9
|
+
} | {
|
|
10
|
+
type: 'migration';
|
|
11
|
+
chain: CryptoCurrencyId;
|
|
12
|
+
from: string;
|
|
13
|
+
to: string;
|
|
14
|
+
link: string;
|
|
15
|
+
} | {
|
|
16
|
+
type: 'feature_unavailable';
|
|
17
|
+
link: string;
|
|
18
|
+
feature: 'history' | 'swap' | 'token_history' | 'send_and_receive' | 'send' | 'receive' | 'sending_tokens' | 'receiving_tokens' | 'staking' | 'claiming_staking_rewards';
|
|
19
|
+
} | {
|
|
20
|
+
type: 'will_be_deprecated';
|
|
21
|
+
deprecated_date: string;
|
|
22
|
+
link: string;
|
|
23
|
+
} | {
|
|
24
|
+
type: 'deprecated';
|
|
25
|
+
};
|
|
26
|
+
type Banner = {
|
|
27
|
+
isDisplay: boolean;
|
|
28
|
+
bannerText: string;
|
|
29
|
+
bannerLink?: string;
|
|
30
|
+
bannerLinkText?: string;
|
|
31
|
+
};
|
|
32
|
+
export type CurrencyConfig = {
|
|
33
|
+
status: ConfigStatus;
|
|
34
|
+
customBanner?: Banner;
|
|
35
|
+
[key: string]: unknown;
|
|
36
|
+
};
|
|
37
|
+
export type CoinConfig<T extends CurrencyConfig> = (currency?: CryptoCurrency) => T;
|
|
38
|
+
declare function buildCoinConfig<T extends CurrencyConfig>(): {
|
|
39
|
+
setCoinConfig: (config: CoinConfig<T>) => void;
|
|
40
|
+
getCoinConfig: (currency?: CryptoCurrency) => T;
|
|
41
|
+
};
|
|
42
|
+
export default buildCoinConfig;
|
|
43
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAE/E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAErD,KAAK,YAAY,GACb;IACE,IAAI,EAAE,QAAQ,CAAA;IACd,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAA;CAC3B,GACD;IACE,IAAI,EAAE,mBAAmB,CAAA;IACzB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,GACD;IACE,IAAI,EAAE,WAAW,CAAA;IACjB,KAAK,EAAE,gBAAgB,CAAA;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;CACb,GACD;IACE,IAAI,EAAE,qBAAqB,CAAA;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EACH,SAAS,GACT,MAAM,GACN,eAAe,GACf,kBAAkB,GAClB,MAAM,GACN,SAAS,GACT,gBAAgB,GAChB,kBAAkB,GAClB,SAAS,GACT,0BAA0B,CAAA;CAC/B,GACD;IACE,IAAI,EAAE,oBAAoB,CAAA;IAC1B,eAAe,EAAE,MAAM,CAAA;IACvB,IAAI,EAAE,MAAM,CAAA;CACb,GACD;IACE,IAAI,EAAE,YAAY,CAAA;CACnB,CAAA;AAEL,KAAK,MAAM,GAAG;IACZ,SAAS,EAAE,OAAO,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,YAAY,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,cAAc,IAAI,CAAC,QAAQ,CAAC,EAAE,cAAc,KAAK,CAAC,CAAA;AAEnF,iBAAS,eAAe,CAAC,CAAC,SAAS,cAAc;4BAGhB,UAAU,CAAC,CAAC,CAAC,KAAG,IAAI;+BAIjB,cAAc,KAAG,CAAC;EAYrD;AAED,eAAe,eAAe,CAAA"}
|
package/lib/config.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const errors_1 = require("./errors");
|
|
4
|
+
function buildCoinConfig() {
|
|
5
|
+
let coinConfig;
|
|
6
|
+
const setCoinConfig = (config) => {
|
|
7
|
+
coinConfig = config;
|
|
8
|
+
};
|
|
9
|
+
const getCoinConfig = (currency) => {
|
|
10
|
+
if (!coinConfig) {
|
|
11
|
+
throw new errors_1.MissingCoinConfig();
|
|
12
|
+
}
|
|
13
|
+
return coinConfig(currency);
|
|
14
|
+
};
|
|
15
|
+
return {
|
|
16
|
+
setCoinConfig,
|
|
17
|
+
getCoinConfig,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
exports.default = buildCoinConfig;
|
|
21
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;AACA,qCAA4C;AA0D5C,SAAS,eAAe;IACtB,IAAI,UAAqC,CAAA;IAEzC,MAAM,aAAa,GAAG,CAAC,MAAqB,EAAQ,EAAE;QACpD,UAAU,GAAG,MAAM,CAAA;IACrB,CAAC,CAAA;IAED,MAAM,aAAa,GAAG,CAAC,QAAyB,EAAK,EAAE;QACrD,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,IAAI,0BAAiB,EAAE,CAAA;QAC/B,CAAC;QAED,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAA;IAC7B,CAAC,CAAA;IAED,OAAO;QACL,aAAa;QACb,aAAa;KACd,CAAA;AACH,CAAC;AAED,kBAAe,eAAe,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatCurrencyUnit.d.ts","sourceRoot":"","sources":["../../src/currencies/formatCurrencyUnit.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,KAAK,yBAAyB,EAC9B,KAAK,cAAc,GACpB,MAAM,gCAAgC,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatCurrencyUnitFragment = exports.formatCurrencyUnit = void 0;
|
|
4
|
+
var live_currency_format_1 = require("@ledgerhq/live-currency-format");
|
|
5
|
+
Object.defineProperty(exports, "formatCurrencyUnit", { enumerable: true, get: function () { return live_currency_format_1.formatCurrencyUnit; } });
|
|
6
|
+
Object.defineProperty(exports, "formatCurrencyUnitFragment", { enumerable: true, get: function () { return live_currency_format_1.formatCurrencyUnitFragment; } });
|
|
7
|
+
//# sourceMappingURL=formatCurrencyUnit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatCurrencyUnit.js","sourceRoot":"","sources":["../../src/currencies/formatCurrencyUnit.ts"],"names":[],"mappings":";;;AAAA,uEAKuC;AAJrC,0HAAA,kBAAkB,OAAA;AAClB,kIAAA,0BAA0B,OAAA"}
|
|
@@ -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,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatCurrencyUnitFragment = exports.formatCurrencyUnit = exports.parseCurrencyUnit = void 0;
|
|
4
|
+
var parseCurrencyUnit_1 = require("./parseCurrencyUnit");
|
|
5
|
+
Object.defineProperty(exports, "parseCurrencyUnit", { enumerable: true, get: function () { return parseCurrencyUnit_1.parseCurrencyUnit; } });
|
|
6
|
+
var formatCurrencyUnit_1 = require("./formatCurrencyUnit");
|
|
7
|
+
Object.defineProperty(exports, "formatCurrencyUnit", { enumerable: true, get: function () { return formatCurrencyUnit_1.formatCurrencyUnit; } });
|
|
8
|
+
Object.defineProperty(exports, "formatCurrencyUnitFragment", { enumerable: true, get: function () { return formatCurrencyUnit_1.formatCurrencyUnitFragment; } });
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/currencies/index.ts"],"names":[],"mappings":";;;AAAA,yDAAuD;AAA9C,sHAAA,iBAAiB,OAAA;AAC1B,2DAK6B;AAJ3B,wHAAA,kBAAkB,OAAA;AAClB,gIAAA,0BAA0B,OAAA"}
|
|
@@ -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,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseCurrencyUnit = void 0;
|
|
4
|
+
var live_currency_format_1 = require("@ledgerhq/live-currency-format");
|
|
5
|
+
Object.defineProperty(exports, "parseCurrencyUnit", { enumerable: true, get: function () { return live_currency_format_1.parseCurrencyUnit; } });
|
|
6
|
+
//# sourceMappingURL=parseCurrencyUnit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseCurrencyUnit.js","sourceRoot":"","sources":["../../src/currencies/parseCurrencyUnit.ts"],"names":[],"mappings":";;;AAAA,uEAAkE;AAAzD,yHAAA,iBAAiB,OAAA"}
|
package/lib/errors.d.ts
ADDED
|
@@ -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/errors.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MissingCoinConfig = void 0;
|
|
4
|
+
const errors_1 = require("@ledgerhq/errors");
|
|
5
|
+
/** When a coin-module has no CoinConfig setted */
|
|
6
|
+
exports.MissingCoinConfig = (0, errors_1.createCustomErrorClass)('MissingCoinConfig');
|
|
7
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAAA,6CAAyD;AAEzD,kDAAkD;AACrC,QAAA,iBAAiB,GAAG,IAAA,+BAAsB,EAAC,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,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hasFeature = hasFeature;
|
|
4
|
+
exports.hasIntent = hasIntent;
|
|
5
|
+
/**
|
|
6
|
+
* Helper function to check if a feature is supported
|
|
7
|
+
*/
|
|
8
|
+
function hasFeature(supportedFeatures, featureId) {
|
|
9
|
+
return featureId in supportedFeatures;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Helper function to check if an intent is supported for a feature
|
|
13
|
+
*/
|
|
14
|
+
function hasIntent(supportedFeatures, featureId, intent) {
|
|
15
|
+
const intents = supportedFeatures[featureId];
|
|
16
|
+
return intents?.includes(intent) ?? false;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/features/types.ts"],"names":[],"mappings":";;AAmDA,gCAEC;AAKD,8BAOC;AAjBD;;GAEG;AACH,SAAgB,UAAU,CAAC,iBAAoC,EAAE,SAAoB;IACnF,OAAO,SAAS,IAAI,iBAAiB,CAAA;AACvC,CAAC;AAED;;GAEG;AACH,SAAgB,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"}
|
package/lib/index.d.ts
ADDED
|
@@ -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/index.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const api = __importStar(require("./api"));
|
|
37
|
+
exports.default = {
|
|
38
|
+
api,
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4B;AAE5B,kBAAe;IACb,GAAG;CACJ,CAAA"}
|
package/lib/setup.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":""}
|
package/lib/setup.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
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
ADDED
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -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":""}
|
package/lib/utils.d.ts
ADDED
|
@@ -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/utils.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fromBigNumberToBigInt = fromBigNumberToBigInt;
|
|
4
|
+
exports.isSendTransactionIntent = isSendTransactionIntent;
|
|
5
|
+
exports.isStakingTransactionIntent = isStakingTransactionIntent;
|
|
6
|
+
function fromBigNumberToBigInt(bigNumber, defaultValue) {
|
|
7
|
+
if (bigNumber != null) {
|
|
8
|
+
return BigInt(bigNumber.toFixed());
|
|
9
|
+
}
|
|
10
|
+
return defaultValue;
|
|
11
|
+
}
|
|
12
|
+
function isSendTransactionIntent(tx) {
|
|
13
|
+
return tx.intentType === 'transaction';
|
|
14
|
+
}
|
|
15
|
+
function isStakingTransactionIntent(tx) {
|
|
16
|
+
return tx.intentType === 'staking';
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=utils.js.map
|
package/lib/utils.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;AAGA,sDAQC;AAED,0DAEC;AAED,gEAEC;AAhBD,SAAgB,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,SAAgB,uBAAuB,CAAC,EAAqB;IAC3D,OAAO,EAAE,CAAC,UAAU,KAAK,aAAa,CAAA;AACxC,CAAC;AAED,SAAgB,0BAA0B,CAAC,EAAqB;IAC9D,OAAO,EAAE,CAAC,UAAU,KAAK,SAAS,CAAA;AACpC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/api/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,CAAC,EAAE,MAAM;CAG7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/api/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAgB;QAC1B,KAAK,CAAC,kBAAkB,OAAO,EAAE,CAAC,CAAA;IACpC,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA"}
|