@ledgerhq/coin-hypercore 0.2.0 → 0.2.1

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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # @ledgerhq/coin-hypercore
2
2
 
3
+ ## 0.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#734](https://github.com/LedgerHQ/coin-modules/pull/734) [`fe0b58e`](https://github.com/LedgerHQ/coin-modules/commit/fe0b58ebc0e1ecc2134b4b6fc73d516662de66b9) Thanks [@adussarps](https://github.com/adussarps)! - Add the read-only smart-contract `call` API to `CoinModuleApi`, along with the `CallParams`/`CallResult` types and a shared `notSupported` helper for modules that do not implement optional API methods. Modules without a contract-read primitive (`coin-hypercore`, `coin-stellar`, `coin-xrp`) now stub `call` as unsupported.
8
+
9
+ - Updated dependencies [[`fe0b58e`](https://github.com/LedgerHQ/coin-modules/commit/fe0b58ebc0e1ecc2134b4b6fc73d516662de66b9)]:
10
+ - @ledgerhq/coin-module-framework@4.0.0
11
+
3
12
  ## 0.2.0
4
13
 
5
14
  ### Minor Changes
@@ -1,4 +1,4 @@
1
- import type { CoinModuleApi } from '@ledgerhq/coin-module-framework/api/index';
1
+ import { type CoinModuleApi } from '@ledgerhq/coin-module-framework/api/index';
2
2
  import { type HypercoreConfig } from '../config';
3
3
  export declare function createApi(config: HypercoreConfig): CoinModuleApi;
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAA;AAC9E,OAAmB,EAAE,KAAK,eAAe,EAAE,MAAM,WAAW,CAAA;AAM5D,wBAAgB,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,aAAa,CAsBhE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,aAAa,EAAgB,MAAM,2CAA2C,CAAA;AAC5F,OAAmB,EAAE,KAAK,eAAe,EAAE,MAAM,WAAW,CAAA;AAE5D,wBAAgB,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,aAAa,CAuBhE"}
package/lib/api/index.js CHANGED
@@ -6,30 +6,29 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
6
6
  };
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.createApi = createApi;
9
+ const index_1 = require("@ledgerhq/coin-module-framework/api/index");
9
10
  const config_1 = __importDefault(require("../config"));
10
- const notSupported = (name) => () => {
11
- throw new Error(`${name} is not supported`);
12
- };
13
11
  function createApi(config) {
14
12
  config_1.default.setCoinConfig(() => ({ ...config, status: { type: 'active' } }));
15
13
  return {
16
- lastBlock: notSupported('lastBlock'),
17
- getBlockInfo: notSupported('getBlockInfo'),
18
- getBlock: notSupported('getBlock'),
19
- getValidators: notSupported('getValidators'),
20
- getBalance: notSupported('getBalance'),
21
- listOperations: notSupported('listOperations'),
22
- getStakes: notSupported('getStakes'),
23
- getRewards: notSupported('getRewards'),
24
- craftTransaction: notSupported('craftTransaction'),
25
- craftRawTransaction: notSupported('craftRawTransaction'),
26
- estimateFees: notSupported('estimateFees'),
27
- combine: notSupported('combine'),
28
- broadcast: notSupported('broadcast'),
29
- validateIntent: notSupported('validateIntent'),
30
- getNextSequence: notSupported('getNextSequence'),
31
- validateAddress: notSupported('validateAddress'),
32
- craftTransactionData: notSupported('craftTransactionData'),
14
+ lastBlock: (0, index_1.notSupported)('lastBlock'),
15
+ getBlockInfo: (0, index_1.notSupported)('getBlockInfo'),
16
+ getBlock: (0, index_1.notSupported)('getBlock'),
17
+ call: (0, index_1.notSupported)('call'),
18
+ getValidators: (0, index_1.notSupported)('getValidators'),
19
+ getBalance: (0, index_1.notSupported)('getBalance'),
20
+ listOperations: (0, index_1.notSupported)('listOperations'),
21
+ getStakes: (0, index_1.notSupported)('getStakes'),
22
+ getRewards: (0, index_1.notSupported)('getRewards'),
23
+ craftTransaction: (0, index_1.notSupported)('craftTransaction'),
24
+ craftRawTransaction: (0, index_1.notSupported)('craftRawTransaction'),
25
+ estimateFees: (0, index_1.notSupported)('estimateFees'),
26
+ combine: (0, index_1.notSupported)('combine'),
27
+ broadcast: (0, index_1.notSupported)('broadcast'),
28
+ validateIntent: (0, index_1.notSupported)('validateIntent'),
29
+ getNextSequence: (0, index_1.notSupported)('getNextSequence'),
30
+ validateAddress: (0, index_1.notSupported)('validateAddress'),
31
+ craftTransactionData: (0, index_1.notSupported)('craftTransactionData'),
33
32
  };
34
33
  }
35
34
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":";AAAA,4CAA4C;AAC5C,sCAAsC;;;;;AAStC,8BAsBC;AA5BD,uDAA4D;AAE5D,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,GAAU,EAAE;IACjD,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,mBAAmB,CAAC,CAAA;AAC7C,CAAC,CAAA;AAED,SAAgB,SAAS,CAAC,MAAuB;IAC/C,gBAAU,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAA;IAE3E,OAAO;QACL,SAAS,EAAE,YAAY,CAAC,WAAW,CAAC;QACpC,YAAY,EAAE,YAAY,CAAC,cAAc,CAAC;QAC1C,QAAQ,EAAE,YAAY,CAAC,UAAU,CAAC;QAClC,aAAa,EAAE,YAAY,CAAC,eAAe,CAAC;QAC5C,UAAU,EAAE,YAAY,CAAC,YAAY,CAAC;QACtC,cAAc,EAAE,YAAY,CAAC,gBAAgB,CAAC;QAC9C,SAAS,EAAE,YAAY,CAAC,WAAW,CAA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AE,IAAA,oBAAY,EAAC,YAAY,CAAC;QACtC,gBAAgB,EAAE,IAAA,oBAAY,EAAC,kBAAkB,CAAC;QAClD,mBAAmB,EAAE,IAAA,oBAAY,EAAC,qBAAqB,CAAC;QACxD,YAAY,EAAE,IAAA,oBAAY,EAAC,cAAc,CAAC;QAC1C,OAAO,EAAE,IAAA,oBAAY,EAAC,SAAS,CAAC;QAChC,SAAS,EAAE,IAAA,oBAAY,EAAC,WAAW,CAAC;QACpC,cAAc,EAAE,IAAA,oBAAY,EAAC,gBAAgB,CAAC;QAC9C,eAAe,EAAE,IAAA,oBAAY,EAAC,iBAAiB,CAAC;QAChD,eAAe,EAAE,IAAA,oBAAY,EAAC,iBAAiB,CAAC;QAChD,oBAAoB,EAAE,IAAA,oBAAY,EAAC,sBAAsB,CAAC;KAC3D,CAAA;AACH,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { CoinModuleApi } from '@ledgerhq/coin-module-framework/api/index';
1
+ import { type CoinModuleApi } from '@ledgerhq/coin-module-framework/api/index';
2
2
  import { type HypercoreConfig } from '../config';
3
3
  export declare function createApi(config: HypercoreConfig): CoinModuleApi;
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAA;AAC9E,OAAmB,EAAE,KAAK,eAAe,EAAE,MAAM,WAAW,CAAA;AAM5D,wBAAgB,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,aAAa,CAsBhE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,aAAa,EAAgB,MAAM,2CAA2C,CAAA;AAC5F,OAAmB,EAAE,KAAK,eAAe,EAAE,MAAM,WAAW,CAAA;AAE5D,wBAAgB,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,aAAa,CAuBhE"}
@@ -1,15 +1,14 @@
1
1
  // SPDX-FileCopyrightText: © 2024 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
+ import { notSupported } from '@ledgerhq/coin-module-framework/api/index';
3
4
  import coinConfig from '../config';
4
- const notSupported = (name) => () => {
5
- throw new Error(`${name} is not supported`);
6
- };
7
5
  export function createApi(config) {
8
6
  coinConfig.setCoinConfig(() => ({ ...config, status: { type: 'active' } }));
9
7
  return {
10
8
  lastBlock: notSupported('lastBlock'),
11
9
  getBlockInfo: notSupported('getBlockInfo'),
12
10
  getBlock: notSupported('getBlock'),
11
+ call: notSupported('call'),
13
12
  getValidators: notSupported('getValidators'),
14
13
  getBalance: notSupported('getBalance'),
15
14
  listOperations: notSupported('listOperations'),
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,sCAAsC;AAGtC,OAAO,UAAoC,MAAM,WAAW,CAAA;AAE5D,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,GAAU,EAAE;IACjD,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,mBAAmB,CAAC,CAAA;AAC7C,CAAC,CAAA;AAED,MAAM,UAAU,SAAS,CAAC,MAAuB;IAC/C,UAAU,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAA;IAE3E,OAAO;QACL,SAAS,EAAE,YAAY,CAAC,WAAW,CAAC;QACpC,YAAY,EAAE,YAAY,CAAC,cAAc,CAAC;QAC1C,QAAQ,EAAE,YAAY,CAAC,UAAU,CAAC;QAClC,aAAa,EAAE,YAAY,CAAC,eAAe,CAAC;QAC5C,UAAU,EAAE,YAAY,CAAC,YAAY,CAAC;QACtC,cAAc,EAAE,YAAY,CAAC,gBAAgB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,CAAC,WAAW,CAAC;QACpC,UAAU,EAAE,YAAY,CAAC,YAAY,CAAC;QACtC,gBAAgB,EAAE,YAAY,CAAC,kBAAkB,CAAC;QAClD,mBAAmB,EAAE,YAAY,CAAC,qBAAqB,CAAC;QACxD,YAAY,EAAE,YAAY,CAAC,cAAc,CAAC;QAC1C,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC;QAChC,SAAS,EAAE,YAAY,CAAC,WAAW,CAAC;QACpC,cAAc,EAAE,YAAY,CAAC,gBAAgB,CAAC;QAC9C,eAAe,EAAE,YAAY,CAAC,iBAAiB,CAAC;QAChD,eAAe,EAAE,YAAY,CAAC,iBAAiB,CAAC;QAChD,oBAAoB,EAAE,YAAY,CAAC,sBAAsB,CAAC;KAC3D,CAAA;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/coin-hypercore",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Ledger Hypercore Coin integration",
5
5
  "keywords": [
6
6
  "Ledger",
@@ -65,7 +65,7 @@
65
65
  "author": "LEDGER SAS",
66
66
  "license": "Apache-2.0",
67
67
  "dependencies": {
68
- "@ledgerhq/coin-module-framework": "^3.6.0"
68
+ "@ledgerhq/coin-module-framework": "^4.0.0"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@swc/core": "1.15.11",
@@ -94,7 +94,7 @@
94
94
  "test": "jest",
95
95
  "test:debug": "node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand",
96
96
  "test-watch": "jest --watch",
97
- "test-integ": "jest --config=jest.integ.config.js --passWithNoTests",
97
+ "test-integ": "jest --config=jest.integ.config.js",
98
98
  "test-integ:debug": "node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand --config=jest.integ.config.js",
99
99
  "typecheck": "tsc --noEmit --customConditions node",
100
100
  "unimported": "knip --include=files,dependencies",
@@ -25,6 +25,6 @@ describe('Hypercore Api (Alpaca stub)', () => {
25
25
  'validateAddress',
26
26
  'craftTransactionData',
27
27
  ])('%s throws "not supported"', (name) => {
28
- expect(() => (api[name] as (...args: unknown[]) => unknown)()).toThrow('not supported')
28
+ expect(api[name]).toThrow('not supported')
29
29
  })
30
30
  })
@@ -0,0 +1,29 @@
1
+ // SPDX-FileCopyrightText: © 2024 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { createApi } from '.'
5
+
6
+ describe('createApi', () => {
7
+ it('returns all API methods', () => {
8
+ expect(createApi({ node: 'http://localhost' })).toEqual({
9
+ broadcast: expect.any(Function),
10
+ call: expect.any(Function),
11
+ combine: expect.any(Function),
12
+ craftRawTransaction: expect.any(Function),
13
+ craftTransaction: expect.any(Function),
14
+ craftTransactionData: expect.any(Function),
15
+ estimateFees: expect.any(Function),
16
+ getBalance: expect.any(Function),
17
+ getBlock: expect.any(Function),
18
+ getBlockInfo: expect.any(Function),
19
+ getNextSequence: expect.any(Function),
20
+ getRewards: expect.any(Function),
21
+ getStakes: expect.any(Function),
22
+ getValidators: expect.any(Function),
23
+ lastBlock: expect.any(Function),
24
+ listOperations: expect.any(Function),
25
+ validateAddress: expect.any(Function),
26
+ validateIntent: expect.any(Function),
27
+ })
28
+ })
29
+ })
package/src/api/index.ts CHANGED
@@ -1,13 +1,9 @@
1
1
  // SPDX-FileCopyrightText: © 2024 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import type { CoinModuleApi } from '@ledgerhq/coin-module-framework/api/index'
4
+ import { type CoinModuleApi, notSupported } from '@ledgerhq/coin-module-framework/api/index'
5
5
  import coinConfig, { type HypercoreConfig } from '../config'
6
6
 
7
- const notSupported = (name: string) => (): never => {
8
- throw new Error(`${name} is not supported`)
9
- }
10
-
11
7
  export function createApi(config: HypercoreConfig): CoinModuleApi {
12
8
  coinConfig.setCoinConfig(() => ({ ...config, status: { type: 'active' } }))
13
9
 
@@ -15,6 +11,7 @@ export function createApi(config: HypercoreConfig): CoinModuleApi {
15
11
  lastBlock: notSupported('lastBlock'),
16
12
  getBlockInfo: notSupported('getBlockInfo'),
17
13
  getBlock: notSupported('getBlock'),
14
+ call: notSupported('call'),
18
15
  getValidators: notSupported('getValidators'),
19
16
  getBalance: notSupported('getBalance'),
20
17
  listOperations: notSupported('listOperations'),