@ledgerhq/coin-hypercore 0.4.1 → 0.4.3

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,17 @@
1
1
  # @ledgerhq/coin-hypercore
2
2
 
3
+ ## 0.4.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#758](https://github.com/LedgerHQ/coin-modules/pull/758) [`aa464dd`](https://github.com/LedgerHQ/coin-modules/commit/aa464dd83fe9fcaf730ab9857a9b5853b23544bf) Thanks [@YazhuEth](https://github.com/YazhuEth)! - Implement `validateAddress` so the generic coin framework can validate HyperCore recipients/addresses. It previously threw `notSupported`, which broke address validation now that the framework consumes it from the `CoinModuleApi` instance. HyperCore addresses are Ethereum-format, so this checks the `0x`-prefixed 40-hex-character shape.
8
+
9
+ ## 0.4.2
10
+
11
+ ### Patch Changes
12
+
13
+ - [#754](https://github.com/LedgerHQ/coin-modules/pull/754) [`207701b`](https://github.com/LedgerHQ/coin-modules/commit/207701baed385e19350dd49d407ad51877940745) Thanks [@YazhuEth](https://github.com/YazhuEth)! - Implement `lastBlock` so the generic coin framework can synchronize HyperCore accounts. It previously threw `notSupported`, which broke account discovery/import. The perps proxy exposes no block height for actions, so both `lastBlock` and `listOperations` now use a unix-second timestamp as a monotonic pseudo-height (settlement time for operations, current time for `lastBlock`). This keeps settled deposits/withdrawals showing as confirmed instead of stuck "pending".
14
+
3
15
  ## 0.4.1
4
16
 
5
17
  ### Patch Changes
@@ -1 +1 @@
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;AAI5D,wBAAgB,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,aAAa,CAuBhE"}
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;AAM5D,wBAAgB,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,aAAa,CAuBhE"}
package/lib/api/index.js CHANGED
@@ -9,11 +9,13 @@ exports.createApi = createApi;
9
9
  const index_1 = require("@ledgerhq/coin-module-framework/api/index");
10
10
  const config_1 = __importDefault(require("../config"));
11
11
  const getBalance_1 = require("./getBalance");
12
+ const lastBlock_1 = require("./lastBlock");
12
13
  const listOperations_1 = require("./listOperations");
14
+ const validateAddress_1 = require("./validateAddress");
13
15
  function createApi(config) {
14
16
  config_1.default.setCoinConfig(() => ({ ...config, status: { type: 'active' } }));
15
17
  return {
16
- lastBlock: (0, index_1.notSupported)('lastBlock'),
18
+ lastBlock: lastBlock_1.lastBlock,
17
19
  getBlockInfo: (0, index_1.notSupported)('getBlockInfo'),
18
20
  getBlock: (0, index_1.notSupported)('getBlock'),
19
21
  call: (0, index_1.notSupported)('call'),
@@ -29,7 +31,7 @@ function createApi(config) {
29
31
  broadcast: (0, index_1.notSupported)('broadcast'),
30
32
  validateIntent: (0, index_1.notSupported)('validateIntent'),
31
33
  getNextSequence: (0, index_1.notSupported)('getNextSequence'),
32
- validateAddress: (0, index_1.notSupported)('validateAddress'),
34
+ validateAddress: validateAddress_1.validateAddress,
33
35
  craftTransactionData: (0, index_1.notSupported)('craftTransactionData'),
34
36
  };
35
37
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":";AAAA,4CAA4C;AAC5C,sCAAsC;;;;;AAOtC,8BAuBC;AA5BD,qEAA4F;AAC5F,uDAA4D;AAC5D,6CAAyC;AACzC,qDAAiD;AAEjD,SAAgB,SAAS,CAAC,MAAuB;IAC/C,gBAAU,CAAC,a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mD;AAEnD,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,EAAT,qBAAS;QACT,YAAY,EAAE,IAAA,oBAAY,EAAC,cAAc,CAAC;QAC1C,QAAQ,EAAE,IAAA,oBAAY,EAAC,UAAU,CAAC;QAClC,IAAI,EAAE,IAAA,oBAAY,EAAC,MAAM,CAAC;QAC1B,aAAa,EAAE,IAAA,oBAAY,EAAC,eAAe,CAAC;QAC5C,UAAU,EAAV,uBAAU;QACV,cAAc,EAAd,+BAAc;QACd,SAAS,EAAE,IAAA,oBAAY,EAAC,WAAW,CAAC;QACpC,UAAU,EAAE,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,EAAf,iCAAe;QACf,oBAAoB,EAAE,IAAA,oBAAY,EAAC,sBAAsB,CAAC;KAC3D,CAAA;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { BlockInfo } from '@ledgerhq/coin-module-framework/api/types';
2
+ export declare function lastBlock(): Promise<BlockInfo>;
3
+ //# sourceMappingURL=lastBlock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lastBlock.d.ts","sourceRoot":"","sources":["../../src/api/lastBlock.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2CAA2C,CAAA;AAI1E,wBAAsB,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC,CAOpD"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ // SPDX-FileCopyrightText: © 2024 LEDGER SAS
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.lastBlock = lastBlock;
6
+ // The proxy exposes no block height; use a unix-second timestamp as a monotonic height (matching
7
+ // listOperations) so operations resolve as confirmed.
8
+ async function lastBlock() {
9
+ const time = new Date();
10
+ return {
11
+ height: Math.floor(time.getTime() / 1000),
12
+ hash: '',
13
+ time,
14
+ };
15
+ }
16
+ //# sourceMappingURL=lastBlock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lastBlock.js","sourceRoot":"","sources":["../../src/api/lastBlock.ts"],"names":[],"mappings":";AAAA,4CAA4C;AAC5C,sCAAsC;;AAMtC,8BAOC;AATD,iGAAiG;AACjG,sDAAsD;AAC/C,KAAK,UAAU,SAAS;IAC7B,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAA;IACvB,OAAO;QACL,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;QACzC,IAAI,EAAE,EAAE;QACR,IAAI;KACL,CAAA;AACH,CAAC"}
@@ -24,8 +24,8 @@ function toOperation(address, dto) {
24
24
  asset: { type: 'native' },
25
25
  tx: {
26
26
  hash: dto.id,
27
- // HyperCore actions have no block height on this API.
28
- block: { height: 0, hash: '', time: date },
27
+ // No block height from the proxy; use the settlement time (unix seconds) as a monotonic height.
28
+ block: { height: Math.floor(date.getTime() / 1000), hash: '', time: date },
29
29
  fees: 0n,
30
30
  date,
31
31
  failed: dto.status.toUpperCase() === 'FAILED',
@@ -1 +1 @@
1
- {"version":3,"file":"listOperations.js","sourceRo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function validateAddress(address: string, _parameters: Partial<AddressValidationCurrencyParameters>): Promise<boolean>;
3
+ //# sourceMappingURL=validateAddress.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateAddress.d.ts","sourceRoot":"","sources":["../../src/api/validateAddress.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,2CAA2C,CAAA;AAKpG,wBAAsB,eAAe,CACnC,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,OAAO,CAAC,mCAAmC,CAAC,GACxD,OAAO,CAAC,OAAO,CAAC,CAElB"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ // SPDX-FileCopyrightText: © 2024 LEDGER SAS
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.validateAddress = validateAddress;
6
+ // Ethereum-format address; validate hex shape only (no EIP-55 checksum — no keccak dep).
7
+ const ETH_ADDRESS_REGEX = /^0x[0-9a-fA-F]{40}$/;
8
+ async function validateAddress(address, _parameters) {
9
+ return ETH_ADDRESS_REGEX.test(address);
10
+ }
11
+ //# sourceMappingURL=validateAddress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateAddress.js","sourceRoot":"","sources":["../../src/api/validateAddress.ts"],"names":[],"mappings":";AAAA,4CAA4C;AAC5C,sCAAsC;;AAOtC,0CAKC;AARD,yFAAyF;AACzF,MAAM,iBAAiB,GAAG,qBAAqB,CAAA;AAExC,KAAK,UAAU,eAAe,CACnC,OAAe,EACf,WAAyD;IAEzD,OAAO,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;AACxC,CAAC"}
@@ -1 +1 @@
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;AAI5D,wBAAgB,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,aAAa,CAuBhE"}
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;AAM5D,wBAAgB,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,aAAa,CAuBhE"}
@@ -3,11 +3,13 @@
3
3
  import { notSupported } from '@ledgerhq/coin-module-framework/api/index';
4
4
  import coinConfig from '../config';
5
5
  import { getBalance } from './getBalance';
6
+ import { lastBlock } from './lastBlock';
6
7
  import { listOperations } from './listOperations';
8
+ import { validateAddress } from './validateAddress';
7
9
  export function createApi(config) {
8
10
  coinConfig.setCoinConfig(() => ({ ...config, status: { type: 'active' } }));
9
11
  return {
10
- lastBlock: notSupported('lastBlock'),
12
+ lastBlock,
11
13
  getBlockInfo: notSupported('getBlockInfo'),
12
14
  getBlock: notSupported('getBlock'),
13
15
  call: notSupported('call'),
@@ -23,7 +25,7 @@ export function createApi(config) {
23
25
  broadcast: notSupported('broadcast'),
24
26
  validateIntent: notSupported('validateIntent'),
25
27
  getNextSequence: notSupported('getNextSequence'),
26
- validateAddress: notSupported('validateAddress'),
28
+ validateAddress,
27
29
  craftTransactionData: notSupported('craftTransactionData'),
28
30
  };
29
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,sCAAsC;AAEtC,OAAO,EAAsB,YAAY,EAAE,MAAM,2CAA2C,CAAA;AAC5F,OAAO,UAAoC,MAAM,WAAW,CAAA;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEjD,MAAM,UAAU,SAAS,CA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E,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD,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;QACT,YAAY,EAAE,YAAY,CAAC,cAAc,CAAC;QAC1C,QAAQ,EAAE,YAAY,CAAC,UAAU,CAAC;QAClC,IAAI,EAAE,YAAY,CAAC,MAAM,CAAC;QAC1B,aAAa,EAAE,YAAY,CAAC,eAAe,CAAC;QAC5C,UAAU;QACV,cAAc;QACd,SAAS,EAAE,YAAY,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;QACf,oBAAoB,EAAE,YAAY,CAAC,sBAAsB,CAAC;KAC3D,CAAA;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { BlockInfo } from '@ledgerhq/coin-module-framework/api/types';
2
+ export declare function lastBlock(): Promise<BlockInfo>;
3
+ //# sourceMappingURL=lastBlock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lastBlock.d.ts","sourceRoot":"","sources":["../../src/api/lastBlock.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2CAA2C,CAAA;AAI1E,wBAAsB,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC,CAOpD"}
@@ -0,0 +1,13 @@
1
+ // SPDX-FileCopyrightText: © 2024 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ // The proxy exposes no block height; use a unix-second timestamp as a monotonic height (matching
4
+ // listOperations) so operations resolve as confirmed.
5
+ export async function lastBlock() {
6
+ const time = new Date();
7
+ return {
8
+ height: Math.floor(time.getTime() / 1000),
9
+ hash: '',
10
+ time,
11
+ };
12
+ }
13
+ //# sourceMappingURL=lastBlock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lastBlock.js","sourceRoot":"","sources":["../../src/api/lastBlock.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,sCAAsC;AAItC,iGAAiG;AACjG,sDAAsD;AACtD,MAAM,CAAC,KAAK,UAAU,SAAS;IAC7B,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAA;IACvB,OAAO;QACL,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;QACzC,IAAI,EAAE,EAAE;QACR,IAAI;KACL,CAAA;AACH,CAAC"}
@@ -21,8 +21,8 @@ function toOperation(address, dto) {
21
21
  asset: { type: 'native' },
22
22
  tx: {
23
23
  hash: dto.id,
24
- // HyperCore actions have no block height on this API.
25
- block: { height: 0, hash: '', time: date },
24
+ // No block height from the proxy; use the settlement time (unix seconds) as a monotonic height.
25
+ block: { height: Math.floor(date.getTime() / 1000), hash: '', time: date },
26
26
  fees: 0n,
27
27
  date,
28
28
  failed: dto.status.toUpperCase() === 'FAILED',
@@ -1 +1 @@
1
- {"version":3,"file":"listOperations.js","sourceRoot":"","sources":["../../src/api/listOperations.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,sCAAsC;AAOtC,OAAO,EAEL,WAAW,EACX,aAAa,EACb,eAAe,EACf,YAAY,GACb,MAAM,kBAAkB,CAAA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validateAddress(address: string, _parameters: Partial<AddressValidationCurrencyParameters>): Promise<boolean>;
3
+ //# sourceMappingURL=validateAddress.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateAddress.d.ts","sourceRoot":"","sources":["../../src/api/validateAddress.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,2CAA2C,CAAA;AAKpG,wBAAsB,eAAe,CACnC,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,OAAO,CAAC,mCAAmC,CAAC,GACxD,OAAO,CAAC,OAAO,CAAC,CAElB"}
@@ -0,0 +1,8 @@
1
+ // SPDX-FileCopyrightText: © 2024 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ // Ethereum-format address; validate hex shape only (no EIP-55 checksum — no keccak dep).
4
+ const ETH_ADDRESS_REGEX = /^0x[0-9a-fA-F]{40}$/;
5
+ export async function validateAddress(address, _parameters) {
6
+ return ETH_ADDRESS_REGEX.test(address);
7
+ }
8
+ //# sourceMappingURL=validateAddress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateAddress.js","sourceRoot":"","sources":["../../src/api/validateAddress.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,sCAAsC;AAItC,yFAAyF;AACzF,MAAM,iBAAiB,GAAG,qBAAqB,CAAA;AAE/C,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,OAAe,EACf,WAAyD;IAEzD,OAAO,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;AACxC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/coin-hypercore",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
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": "^4.0.1"
68
+ "@ledgerhq/coin-module-framework": "^4.0.2"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@swc/core": "1.15.11",
@@ -11,7 +11,6 @@ describe('Hypercore Api (Alpaca stub)', () => {
11
11
  const api = createApi({ node: 'https://api.hyperliquid.xyz' })
12
12
 
13
13
  it.each<keyof typeof api>([
14
- 'lastBlock',
15
14
  'getBlockInfo',
16
15
  'getBlock',
17
16
  'getValidators',
@@ -24,7 +23,6 @@ describe('Hypercore Api (Alpaca stub)', () => {
24
23
  'broadcast',
25
24
  'validateIntent',
26
25
  'getNextSequence',
27
- 'validateAddress',
28
26
  'craftTransactionData',
29
27
  ])('%s throws "not supported"', (name) => {
30
28
  expect(api[name]).toThrow('not supported')
package/src/api/index.ts CHANGED
@@ -4,13 +4,15 @@
4
4
  import { type CoinModuleApi, notSupported } from '@ledgerhq/coin-module-framework/api/index'
5
5
  import coinConfig, { type HypercoreConfig } from '../config'
6
6
  import { getBalance } from './getBalance'
7
+ import { lastBlock } from './lastBlock'
7
8
  import { listOperations } from './listOperations'
9
+ import { validateAddress } from './validateAddress'
8
10
 
9
11
  export function createApi(config: HypercoreConfig): CoinModuleApi {
10
12
  coinConfig.setCoinConfig(() => ({ ...config, status: { type: 'active' } }))
11
13
 
12
14
  return {
13
- lastBlock: notSupported('lastBlock'),
15
+ lastBlock,
14
16
  getBlockInfo: notSupported('getBlockInfo'),
15
17
  getBlock: notSupported('getBlock'),
16
18
  call: notSupported('call'),
@@ -26,7 +28,7 @@ export function createApi(config: HypercoreConfig): CoinModuleApi {
26
28
  broadcast: notSupported('broadcast'),
27
29
  validateIntent: notSupported('validateIntent'),
28
30
  getNextSequence: notSupported('getNextSequence'),
29
- validateAddress: notSupported('validateAddress'),
31
+ validateAddress,
30
32
  craftTransactionData: notSupported('craftTransactionData'),
31
33
  }
32
34
  }
@@ -0,0 +1,17 @@
1
+ // SPDX-FileCopyrightText: © 2024 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { lastBlock } from './lastBlock'
5
+
6
+ describe('lastBlock', () => {
7
+ it('returns a unix-second timestamp as a monotonic height (proxy exposes no block)', async () => {
8
+ const before = Math.floor(Date.now() / 1000)
9
+ const block = await lastBlock()
10
+ const after = Math.floor(Date.now() / 1000)
11
+
12
+ expect(block.height).toBeGreaterThanOrEqual(before)
13
+ expect(block.height).toBeLessThanOrEqual(after)
14
+ expect(block.hash).toBe('')
15
+ expect(block.time).toBeInstanceOf(Date)
16
+ })
17
+ })
@@ -0,0 +1,15 @@
1
+ // SPDX-FileCopyrightText: © 2024 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { BlockInfo } from '@ledgerhq/coin-module-framework/api/types'
5
+
6
+ // The proxy exposes no block height; use a unix-second timestamp as a monotonic height (matching
7
+ // listOperations) so operations resolve as confirmed.
8
+ export async function lastBlock(): Promise<BlockInfo> {
9
+ const time = new Date()
10
+ return {
11
+ height: Math.floor(time.getTime() / 1000),
12
+ hash: '',
13
+ time,
14
+ }
15
+ }
@@ -37,8 +37,8 @@ function toOperation(address: string, dto: ActionDto): Operation {
37
37
  asset: { type: 'native' },
38
38
  tx: {
39
39
  hash: dto.id,
40
- // HyperCore actions have no block height on this API.
41
- block: { height: 0, hash: '', time: date },
40
+ // No block height from the proxy; use the settlement time (unix seconds) as a monotonic height.
41
+ block: { height: Math.floor(date.getTime() / 1000), hash: '', time: date },
42
42
  fees: 0n,
43
43
  date,
44
44
  failed: dto.status.toUpperCase() === 'FAILED',
@@ -0,0 +1,23 @@
1
+ // SPDX-FileCopyrightText: © 2024 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { validateAddress } from './validateAddress'
5
+
6
+ describe('validateAddress', () => {
7
+ it.each([
8
+ '0x90D5b3f3FaA3cd61fBd78bF1CE3DdB2100F4BFb2', // checksummed
9
+ '0x90d5b3f3faa3cd61fbd78bf1ce3ddb2100f4bfb2', // lowercase
10
+ ])('accepts a well-formed Ethereum address (%s)', async (address) => {
11
+ expect(await validateAddress(address, {})).toBe(true)
12
+ })
13
+
14
+ it.each([
15
+ '', // empty
16
+ '90D5b3f3FaA3cd61fBd78bF1CE3DdB2100F4BFb2', // missing 0x prefix
17
+ '0x90D5b3f3FaA3cd61fBd78bF1CE3DdB2100F4BF', // too short
18
+ '0x90D5b3f3FaA3cd61fBd78bF1CE3DdB2100F4BFb2ab', // too long
19
+ '0xZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ', // non-hex
20
+ ])('rejects a malformed address (%s)', async (address) => {
21
+ expect(await validateAddress(address, {})).toBe(false)
22
+ })
23
+ })
@@ -0,0 +1,14 @@
1
+ // SPDX-FileCopyrightText: © 2024 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { AddressValidationCurrencyParameters } from '@ledgerhq/coin-module-framework/api/types'
5
+
6
+ // Ethereum-format address; validate hex shape only (no EIP-55 checksum — no keccak dep).
7
+ const ETH_ADDRESS_REGEX = /^0x[0-9a-fA-F]{40}$/
8
+
9
+ export async function validateAddress(
10
+ address: string,
11
+ _parameters: Partial<AddressValidationCurrencyParameters>
12
+ ): Promise<boolean> {
13
+ return ETH_ADDRESS_REGEX.test(address)
14
+ }