Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Prevent webpack loading bindings when importing UTXOInput type #990

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion bindings/nodejs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
22 changes: 14 additions & 8 deletions bindings/nodejs/lib/types/block/input/input.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -69,13 +68,20 @@ class UTXOInput extends Input {
* Creates a `UTXOInput` from an output id.
*/
static fromOutputId(outputId: OutputId): UTXOInput {
const input = callUtilsMethod({
name: 'outputIdToUtxoInput',
data: {
outputId,
},
});
return new UTXOInput(input.transactionId, input.transactionOutputIndex);
const source = outputId.startsWith('0x')
? outputId.substring(2)
: outputId;
const indexHexLe = source.slice(64);
const chunks = [indexHexLe.substring(0, 2), indexHexLe.substring(2)];
const buffer = Uint8Array.from(
chunks.map((n) => parseInt(n, 16)),
).buffer;
const indexData = new DataView(buffer);

const transactionId = source.substring(0, source.length - 4);
const transactionOutputIndex = indexData.getUint16(0, true);

return new UTXOInput(`0x${transactionId}`, transactionOutputIndex);
}
}

Expand Down
2 changes: 1 addition & 1 deletion bindings/nodejs/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Loading