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

Node: Cyclic dep. in transaction payload #1253

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions bindings/nodejs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Security -->

## 1.0.12 - 2023-09-14

### Changed

- `RegularTransactionEssence.payload` field type to an optional `TaggedDataPayload`;

## 1.0.11 - 2023-09-14

### Fixed
Expand Down
15 changes: 10 additions & 5 deletions bindings/nodejs/examples/client/07-get-block-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ require('dotenv').config({ path: '.env' });
// Run with command:
// yarn run-example ./client/07-get-block-data.ts

// Set a specific block id or leave undefined for getting a tip.
const ID: string | undefined = '0x1234';

// In this example we will send a block and get the data and metadata for it.
async function run() {
initLogger();
Expand All @@ -22,15 +25,17 @@ async function run() {
try {
// Fetch a block ID from the node.
const blockIds = await client.getTips();
console.log('Block IDs:', blockIds, '\n');

const blockId = ID || blockIds[0];
console.log('Block ID:', blockId, '\n');

// Get the metadata for the block.
const blockMetadata = await client.getBlockMetadata(blockIds[0]);
console.log('Block metadata: ', blockMetadata, '\n');
const blockMetadata = await client.getBlockMetadata(blockId);
console.log('Block metadata:', blockMetadata, '\n');

// Request the block by its id.
const blockData = await client.getBlock(blockIds[0]);
console.log('Block data: ', blockData, '\n');
const blockData = await client.getBlock(blockId);
console.log('Block data:', blockData, '\n');
} catch (error) {
console.error('Error: ', error);
}
Expand Down
11 changes: 4 additions & 7 deletions bindings/nodejs/lib/types/block/payload/transaction/essence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
// SPDX-License-Identifier: Apache-2.0

import { Type } from 'class-transformer';
import { PayloadDiscriminator } from '..';
import { HexEncodedString } from '../../../utils';
import { Input, InputDiscriminator } from '../../input';
import { Output, OutputDiscriminator } from '../../output';
import { Payload } from '../payload';
import { TaggedDataPayload } from '../tagged';

/**
* All of the essence types.
Expand Down Expand Up @@ -57,10 +56,8 @@ class RegularTransactionEssence extends TransactionEssence {
})
outputs: Output[];

@Type(() => Payload, {
discriminator: PayloadDiscriminator,
})
payload: Payload | undefined;
@Type(() => TaggedDataPayload)
payload?: TaggedDataPayload;

/**
* @param networkId The ID of the network the transaction was issued to.
Expand All @@ -75,7 +72,7 @@ class RegularTransactionEssence extends TransactionEssence {
inputsCommitment: HexEncodedString,
inputs: Input[],
outputs: Output[],
payload: Payload | undefined,
payload: TaggedDataPayload | undefined,
kwek20 marked this conversation as resolved.
Show resolved Hide resolved
) {
super(TransactionEssenceType.Regular);
this.networkId = networkId;
Expand Down