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: Nested payload in TransactionDataPayload is not properly typed #1249

Closed
1 task done
kwek20 opened this issue Sep 18, 2023 · 1 comment · Fixed by #1304
Closed
1 task done

Node: Nested payload in TransactionDataPayload is not properly typed #1249

kwek20 opened this issue Sep 18, 2023 · 1 comment · Fixed by #1304
Assignees
Labels
b-nodejs Bindings - Nodejs bug Bug m-types Module - Types t-impl Task - Implementation
Milestone

Comments

@kwek20
Copy link
Contributor

kwek20 commented Sep 18, 2023

Issue description

parsing nested TransactionDataPayload causes class-transformer to stop due to cyclic parsing.

resulting in

Block data: Block {
  protocolVersion: 2,
  parents: [
    '0x3689742bb257ffec5b9789022bb0af90c23574b605d208b84d2abd083d54085d'
  ],
  payload: {
    essence: {
      type: 1,
      networkId: '1856588631910923207',
      inputs: [Array],
      inputsCommitment: '0xff6bd7f6aeb9c6926da84267d859cf08ce44c228c13fb67b8893d642030a2f51',
      outputs: [Array],
      payload: [Object]
    },
    unlocks: [ [Object] ]
  },
  nonce: '233605'
} 

instead of

Block data: Block {
payload: TransactionPayload {
    type: 6,
    essence: RegularTransactionEssence {
      type: 1,
      networkId: '1856588631910923207',
      inputsCommitment: '0xff6bd7f6aeb9c6926da84267d859cf08ce44c228c13fb67b8893d642030a2f51',
      inputs: [Array],
      outputs: [Array],
      payload: [Object]
    },
    unlocks: [ [SignatureUnlock] ]
  },
  nonce: '233605'
} 

possible fix: Custom @Transform with a new plainToInstance call like here:
typestack/class-transformer#212 (comment)

Version

1.1

Expected behaviour

nested payload has a type

Actual behaviour

no type

Can the issue reliably be reproduced?

Yes

Steps to reproduce the issue

  1. Change client 07 example to look up a transaction with payload type 6
  2. yarn run-example ./client/07-get-block-data.ts
  3. see that block data isnt typed

Errors

No response

Duplicate declaration

  • I have searched the issues tracker this issue and there is none
@kwek20 kwek20 added this to the v1.1.0 milestone Sep 18, 2023
@thibault-martinez thibault-martinez modified the milestones: v1.1.0, v1.0.0 Sep 18, 2023
@thibault-martinez thibault-martinez added b-nodejs Bindings - Nodejs bug Bug m-types Module - Types t-impl Task - Implementation labels Sep 19, 2023
@kwek20
Copy link
Contributor Author

kwek20 commented Sep 19, 2023

not fixed yet in #1253, just solved.
Needs a better solution for future different Payloads inside Transaction

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
b-nodejs Bindings - Nodejs bug Bug m-types Module - Types t-impl Task - Implementation
Projects
Status: Done
2 participants