From 05cb5cf0695a7035f1ff4f3b9587a44642e75f1b Mon Sep 17 00:00:00 2001 From: Brord van Wierst Date: Mon, 2 Oct 2023 13:17:36 +0200 Subject: [PATCH 1/5] added id() --- bindings/nodejs/lib/types/block/core/wrapper.ts | 14 +++++++++++++- bindings/nodejs/lib/types/utils/bridge/utils.ts | 5 ++++- bindings/nodejs/lib/utils/utils.ts | 12 ++++++++---- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/bindings/nodejs/lib/types/block/core/wrapper.ts b/bindings/nodejs/lib/types/block/core/wrapper.ts index 5445e30041..79b4ed3de8 100644 --- a/bindings/nodejs/lib/types/block/core/wrapper.ts +++ b/bindings/nodejs/lib/types/block/core/wrapper.ts @@ -1,7 +1,7 @@ // Copyright 2023 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -import { IssuerId } from '../id'; +import { BlockId, IssuerId } from '../id'; import { Signature, SignatureDiscriminator } from '../signature'; import { SlotCommitmentId, SlotIndex } from '../slot'; import { u64 } from '../../utils/type-aliases'; @@ -10,6 +10,8 @@ import { Block, BlockType } from './block'; import { BasicBlock } from './basic'; import { ValidationBlock } from './validation'; import { BlockDiscriminator } from './'; +import { Utils } from '../../../utils'; +import { ProtocolParameters } from '../../models'; /** * Represent the object that nodes gossip around the network. @@ -73,6 +75,16 @@ class BlockWrapper { this.block = block; } + /** + * Compute the block ID (Blake2b256 hash of the block bytes). + * + * @param params The network protocol parameters. + * @returns The corresponding block ID. + */ + id(params: ProtocolParameters): BlockId { + return Utils.blockId(this, params) + } + /** * Checks whether the block is a `BasicBlock`. * @returns true if it is, otherwise false diff --git a/bindings/nodejs/lib/types/utils/bridge/utils.ts b/bindings/nodejs/lib/types/utils/bridge/utils.ts index 451c2f93f5..cc41c58df0 100644 --- a/bindings/nodejs/lib/types/utils/bridge/utils.ts +++ b/bindings/nodejs/lib/types/utils/bridge/utils.ts @@ -8,6 +8,8 @@ import { TokenSchemeType, Output, RentStructure, + BlockWrapper, + ProtocolParameters, } from '../../'; import { AccountId } from '../../block/id'; import { SlotCommitment } from '../../block/slot'; @@ -88,7 +90,8 @@ export interface __ParseBech32AddressMethod__ { export interface __BlockIdMethod__ { name: 'blockId'; data: { - block: Block; + wrapper: BlockWrapper; + params: ProtocolParameters; }; } diff --git a/bindings/nodejs/lib/utils/utils.ts b/bindings/nodejs/lib/utils/utils.ts index 014975a1e2..740a27bb03 100644 --- a/bindings/nodejs/lib/utils/utils.ts +++ b/bindings/nodejs/lib/utils/utils.ts @@ -15,6 +15,8 @@ import { RentStructure, OutputId, u64, + BlockWrapper, + ProtocolParameters, } from '../types'; import { AccountId, @@ -193,16 +195,18 @@ export class Utils { } /** - * Compute the block ID (Blake2b256 hash of the block bytes) of a block. + * Compute the block ID (Blake2b256 hash of the block bytes) of a blockwrapper. * - * @param block A block. + * @param wrapper A blockwrapper. + * @param params The network protocol parameters. * @returns The corresponding block ID. */ - static blockId(block: Block): BlockId { + static blockId(wrapper: BlockWrapper, params: ProtocolParameters): BlockId { return callUtilsMethod({ name: 'blockId', data: { - block, + wrapper, + params, }, }); } From 083b27f3f48d60f1ca7f768e646c7c76983cfbef Mon Sep 17 00:00:00 2001 From: Brord van Wierst Date: Mon, 2 Oct 2023 13:29:47 +0200 Subject: [PATCH 2/5] fmt --- bindings/nodejs/lib/types/block/core/wrapper.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bindings/nodejs/lib/types/block/core/wrapper.ts b/bindings/nodejs/lib/types/block/core/wrapper.ts index 79b4ed3de8..23d2b144ea 100644 --- a/bindings/nodejs/lib/types/block/core/wrapper.ts +++ b/bindings/nodejs/lib/types/block/core/wrapper.ts @@ -77,12 +77,12 @@ class BlockWrapper { /** * Compute the block ID (Blake2b256 hash of the block bytes). - * + * * @param params The network protocol parameters. * @returns The corresponding block ID. */ id(params: ProtocolParameters): BlockId { - return Utils.blockId(this, params) + return Utils.blockId(this, params); } /** From 7df416f9b8edbebcafa614a00d9f74de3526a651 Mon Sep 17 00:00:00 2001 From: Brord van Wierst Date: Mon, 2 Oct 2023 15:31:03 +0200 Subject: [PATCH 3/5] removed stuff --- bindings/nodejs/lib/types/block/core/wrapper.ts | 14 +------------- bindings/nodejs/lib/types/utils/bridge/utils.ts | 1 - bindings/nodejs/lib/utils/utils.ts | 1 - 3 files changed, 1 insertion(+), 15 deletions(-) diff --git a/bindings/nodejs/lib/types/block/core/wrapper.ts b/bindings/nodejs/lib/types/block/core/wrapper.ts index 23d2b144ea..5445e30041 100644 --- a/bindings/nodejs/lib/types/block/core/wrapper.ts +++ b/bindings/nodejs/lib/types/block/core/wrapper.ts @@ -1,7 +1,7 @@ // Copyright 2023 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -import { BlockId, IssuerId } from '../id'; +import { IssuerId } from '../id'; import { Signature, SignatureDiscriminator } from '../signature'; import { SlotCommitmentId, SlotIndex } from '../slot'; import { u64 } from '../../utils/type-aliases'; @@ -10,8 +10,6 @@ import { Block, BlockType } from './block'; import { BasicBlock } from './basic'; import { ValidationBlock } from './validation'; import { BlockDiscriminator } from './'; -import { Utils } from '../../../utils'; -import { ProtocolParameters } from '../../models'; /** * Represent the object that nodes gossip around the network. @@ -75,16 +73,6 @@ class BlockWrapper { this.block = block; } - /** - * Compute the block ID (Blake2b256 hash of the block bytes). - * - * @param params The network protocol parameters. - * @returns The corresponding block ID. - */ - id(params: ProtocolParameters): BlockId { - return Utils.blockId(this, params); - } - /** * Checks whether the block is a `BasicBlock`. * @returns true if it is, otherwise false diff --git a/bindings/nodejs/lib/types/utils/bridge/utils.ts b/bindings/nodejs/lib/types/utils/bridge/utils.ts index cc41c58df0..d1eccb2876 100644 --- a/bindings/nodejs/lib/types/utils/bridge/utils.ts +++ b/bindings/nodejs/lib/types/utils/bridge/utils.ts @@ -1,7 +1,6 @@ import { Ed25519Signature, HexEncodedString, - Block, TransactionEssence, TransactionPayload, TransactionId, diff --git a/bindings/nodejs/lib/utils/utils.ts b/bindings/nodejs/lib/utils/utils.ts index 740a27bb03..24ff347656 100644 --- a/bindings/nodejs/lib/utils/utils.ts +++ b/bindings/nodejs/lib/utils/utils.ts @@ -5,7 +5,6 @@ import { callUtilsMethod } from '../bindings'; import { Address, HexEncodedString, - Block, Ed25519Signature, TransactionEssence, TransactionPayload, From 84fa1081ec59d15d0feb52711aefc82033c8565a Mon Sep 17 00:00:00 2001 From: Brord van Wierst Date: Tue, 3 Oct 2023 01:46:08 +0200 Subject: [PATCH 4/5] named to block --- bindings/nodejs/lib/types/utils/bridge/utils.ts | 2 +- bindings/nodejs/lib/utils/utils.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bindings/nodejs/lib/types/utils/bridge/utils.ts b/bindings/nodejs/lib/types/utils/bridge/utils.ts index d1eccb2876..c7e237a5f8 100644 --- a/bindings/nodejs/lib/types/utils/bridge/utils.ts +++ b/bindings/nodejs/lib/types/utils/bridge/utils.ts @@ -89,7 +89,7 @@ export interface __ParseBech32AddressMethod__ { export interface __BlockIdMethod__ { name: 'blockId'; data: { - wrapper: BlockWrapper; + block: BlockWrapper; params: ProtocolParameters; }; } diff --git a/bindings/nodejs/lib/utils/utils.ts b/bindings/nodejs/lib/utils/utils.ts index 24ff347656..88c5454129 100644 --- a/bindings/nodejs/lib/utils/utils.ts +++ b/bindings/nodejs/lib/utils/utils.ts @@ -194,17 +194,17 @@ export class Utils { } /** - * Compute the block ID (Blake2b256 hash of the block bytes) of a blockwrapper. + * Compute the block ID (Blake2b256 hash of the block bytes) of a block. * - * @param wrapper A blockwrapper. + * @param block A block. * @param params The network protocol parameters. * @returns The corresponding block ID. */ - static blockId(wrapper: BlockWrapper, params: ProtocolParameters): BlockId { + static blockId(block: BlockWrapper, params: ProtocolParameters): BlockId { return callUtilsMethod({ name: 'blockId', data: { - wrapper, + block, params, }, }); From 93afb7231803fa19315345b2b022acec2879b67e Mon Sep 17 00:00:00 2001 From: Brord van Wierst Date: Tue, 3 Oct 2023 01:47:40 +0200 Subject: [PATCH 5/5] ?? --- bindings/nodejs/lib/utils/utils.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/bindings/nodejs/lib/utils/utils.ts b/bindings/nodejs/lib/utils/utils.ts index 88c5454129..c960546fba 100644 --- a/bindings/nodejs/lib/utils/utils.ts +++ b/bindings/nodejs/lib/utils/utils.ts @@ -210,9 +210,6 @@ export class Utils { }); } - /** - - /** * Compute the transaction ID (Blake2b256 hash of the provided transaction payload) of a transaction payload. *