diff --git a/bindings/nodejs/CHANGELOG.md b/bindings/nodejs/CHANGELOG.md index ab6bc7e6fd..fa85242583 100644 --- a/bindings/nodejs/CHANGELOG.md +++ b/bindings/nodejs/CHANGELOG.md @@ -19,7 +19,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Security --> -## 1.0.4 - 2023-MM-DD +## 1.0.5 - YYYY-MM-DD + + +## 1.0.4 - 2023-08-03 + +### Changed + +- Prevent loading of bindings when importing UTXOInput type (changed UTXOInput.fromOutputId implementation) ### Fixed diff --git a/bindings/nodejs/lib/index.ts b/bindings/nodejs/lib/index.ts index b4820072c3..59d996af3c 100644 --- a/bindings/nodejs/lib/index.ts +++ b/bindings/nodejs/lib/index.ts @@ -3,6 +3,8 @@ // Needed for class-transformer json deserialisation import 'reflect-metadata'; +import { callUtilsMethod } from './bindings'; +import { OutputId, UTXOInput } from './types'; import { bigIntToHex } from './utils'; // Allow bigint to be serialized as hex string. @@ -14,6 +16,23 @@ import { bigIntToHex } from './utils'; return bigIntToHex(this); }; +// Assign the util method on UTXOInput here, +// to prevent loading bindings (callUtilsMethod) when importing UTXOInput just for typing. +Object.assign(UTXOInput, { + /** + * Creates a `UTXOInput` from an output id. + */ + fromOutputId(outputId: OutputId): UTXOInput { + const input = callUtilsMethod({ + name: 'outputIdToUtxoInput', + data: { + outputId, + }, + }); + return new UTXOInput(input.transactionId, input.transactionOutputIndex); + }, +}); + export * from './client'; export * from './secret_manager'; export * from './types'; diff --git a/bindings/nodejs/lib/types/block/input/input.ts b/bindings/nodejs/lib/types/block/input/input.ts index 661d737be8..59cd37077a 100644 --- a/bindings/nodejs/lib/types/block/input/input.ts +++ b/bindings/nodejs/lib/types/block/input/input.ts @@ -1,7 +1,6 @@ // Copyright 2023 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -import { callUtilsMethod } from '../../../bindings'; import { HexEncodedString } from '../../utils'; import { OutputId } from '../output'; @@ -68,14 +67,10 @@ class UTXOInput extends Input { /** * Creates a `UTXOInput` from an output id. */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars static fromOutputId(outputId: OutputId): UTXOInput { - const input = callUtilsMethod({ - name: 'outputIdToUtxoInput', - data: { - outputId, - }, - }); - return new UTXOInput(input.transactionId, input.transactionOutputIndex); + // Implementation injected in lib/index.ts, as it uses bindings. + return null as unknown as UTXOInput; } } diff --git a/bindings/nodejs/package.json b/bindings/nodejs/package.json index a307cc7c5d..b8fd9dbcb2 100644 --- a/bindings/nodejs/package.json +++ b/bindings/nodejs/package.json @@ -1,6 +1,6 @@ { "name": "@iota/sdk", - "version": "1.0.3", + "version": "1.0.4", "description": "Node.js binding to the IOTA SDK library", "main": "out/index.js", "types": "out/index.d.ts",