Skip to content

TransactionHelper deserialization #406

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

Merged
merged 10 commits into from Jan 30, 2020
Merged

TransactionHelper deserialization #406

merged 10 commits into from Jan 30, 2020

Conversation

fboucquez
Copy link
Contributor

@fboucquez fboucquez commented Dec 27, 2019

This PR is the SDK improvement from creating a catbuffer library via the generator. PR https://github.com/nemtech/catbuffer-generators/pull/67

If you are happy with the solution, we can release a proper catbuffer version (like 2.0.0) and update the current catbuffer lib version which is 0.0.4-SNAPSHOT

  1. Removed catbuffer code
  2. Added catbuffer dependency
  3. Improved serialization to use TransactionHelper and builders when they are already parsed.
  4. Added tslint task to npm (codestyle fixes still need fixing. Then we can enable Travis to do the checking)

Added catbuffer dependency
Improved serialization to use TransactionHelper and builders when they are already parsed.
Added tslint task to npm (issue needs to be fixed)
@fboucquez fboucquez requested a review from rg911 December 27, 2019 17:17
Copy link
Contributor

@rg911 rg911 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the PR review comments left on buffer generator. The NPM Package staffs are really nice. Great work. But the TransactionHelper will introduce breaking changes to the SDK. The InnerTransaction is already an exported class / type. We should evaluate the impact to the usage. Can the TransactionHelper be put into a separate PR so we can get this catbuffer package PR merged first? We should keep a PR to solve a single issue.

public static createFromPayload(payload: string,
isEmbedded = false): Transaction | InnerTransaction {
return CreateTransactionFromPayload(payload, isEmbedded);
public static createFromPayload(payload: string): Transaction {
Copy link
Contributor Author

@fboucquez fboucquez Dec 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @rg911

I believe this is the only public API method that breaks. The removal of the optional isEmbedded. Alhotugh I don't think clients would be calling this method with isEmbedded = true, I can add the isEmbedded flag back and return InnerTransaction like the old signature. What do you think? Happy to split the PR if you still find it necessary.
This PR doesn't remove the InnerTransaction. That would be a different one once we get confirmation from the clients.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tend to agree but am not 100% convinced using Transaction as EmbeddedTransaction. Code will work but the concept of EmbeddedTransaction becomes a confusing. @evias @dgarcia360

But simply from PR point of view, it should be split

Copy link
Contributor Author

@fboucquez fboucquez Dec 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough, I'll create a PR with just the catbuffer library and the current master code (I'll remove catbuffer code, include the package and just update the imports)

I'll keep this PR for the TransactonHelper usage. Should we remove the InnerTransaction here?

@evias @dgarcia360 , we are noticing that InnertTransaciton type doesn't add anything special to Transaction. The only added attribute signer is already in Transaction superclass. We want to remove it simplifying the models. It's a small breaking change. You would need to change any reference from InnerTransaction to Transaction.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure that many people would be using InnerTransaction much vs specialized TransferTransaction with call to toAggregate().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @evias ,

  1. would you confirm I can remove InnerTransaction?

  2. Is the simplier TransactionMapping method ok?

public static createFromPayload(payload: string): Transaction

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I couldnt confirm the removal of InnerTransaction completely because this class may also be used when trying to read things from chain inside aggregates and I cant speak for all clients that this is required/not required.

  2. Take following two payloads:

2.1: Simple transfer transaction (extends Transaction)

CD00000000000000A775C5ACE3D7167447629EB7BB535D87E6252D46B550E4E98EBF16B3815F60BC47080010FD3C3817620C49B2E50AB3562A88968A0244BF17DDDB268A2CFF220130664BF316E6CC84B668D283F15F783724640FD4CFD1229D7D9C7604EDF46805000000000198544140420F00000000004A941B050100000098DAD0DFE1E7049C9606A7EE037B528493075B1C7F540161E3011D000000000029CF5FD941AD25D501000000000000000053696D706C65207472616E73666572206F662031206E656D2E78656D

2.2: Aggregate transaction with one transfer transaction (extends Transaction)

1001000000000000D29C33F6983DA4DF650E3C5E638494C8620DF7A28C73E375917C92958B0A139FA4EE95F7175B7590811E0440CEF418D85D440C323D70571DC514DFC4A3CD260830664BF316E6CC84B668D283F15F783724640FD4CFD1229D7D9C7604EDF46805000000000198414140420F00000000005A831C05010000003E04C29404A49C65964BE1FFBB7E7EB7918D6211430EE8F8531BF5995175682F6800000000000000610000000000000030664BF316E6CC84B668D283F15F783724640FD4CFD1229D7D9C7604EDF46805000000000198544198DAD0DFE1E7049C9606A7EE037B528493075B1C7F540161E30101000000000029CF5FD941AD25D501000000000000000000000000000000

2.3: Embedded transaction content of one transfer transaction (extends InnerTransaction)

98DAD0DFE1E7049C9606A7EE037B528493075B1C7F540161E30101000000000029CF5FD941AD25D501000000000000000000000000000000

One thing I can think about is that removing the isEmbedded flag in the case of aggregate transactions, a client could share only the embedded payload (like in 2.3) so that other clients have correct content (but its not defined which key should sign). As a compromise, you could also provide with a createFromInnerPayload method.

Copy link
Contributor Author

@fboucquez fboucquez Dec 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I would remove it, it won't be a big change for the customers as it just changing the class name. Currently, the downcasting is pretty odd at least
  2. I'll add the createFromInnerPayload in TransactionMapping

Copy link
Contributor

@rg911 rg911 Dec 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

regarding all these changes mentioned, why can't it just keep as it is now? Doesn't seem to me a 'must' ?

Copy link
Contributor Author

@fboucquez fboucquez Dec 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine either way. 2 methods or 1 method with an if. I guess keeping the same signature won't break existing customers. (If the code would have been new, I would prefer 2 methods though)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed InnerTransaction. Code is simpler.
Added isEmbedded back to the createFromPayload
Added unit test

@fboucquez fboucquez changed the title Catbuffer library TransactionHelper deserialization Dec 29, 2019
@fboucquez fboucquez mentioned this pull request Dec 29, 2019
@fboucquez
Copy link
Contributor Author

Created #408 that only includes the catbuffer library.

This PR will just include the TransactionHelper improvement and probably the removal of InnerTransaction once users are happy.

Copy link
Contributor

@evias evias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would recommend a minor version upgrade for these changes. anyways great work 👍

One thing I notice where I will review tomorrow again is the breaking change with embedded transactions 👍

public static createFromPayload(payload: string,
isEmbedded = false): Transaction | InnerTransaction {
return CreateTransactionFromPayload(payload, isEmbedded);
public static createFromPayload(payload: string): Transaction {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure that many people would be using InnerTransaction much vs specialized TransferTransaction with call to toAggregate().

fboucquez and others added 3 commits December 30, 2019 18:31
# Conflicts:
#	package-lock.json
#	package.json
#	src/infrastructure/transaction/CreateTransactionFromPayload.ts
#	src/model/transaction/AggregateTransaction.ts
#	src/model/transaction/TransferTransaction.ts
Added isEmbedded argument back to TransactionMapping
Fixed catbuffer lib version using the one that includes the src and dist folders for easy debugging.
@fboucquez fboucquez requested review from evias and rg911 December 31, 2019 17:46
# Conflicts:
#	package.json
#	src/model/transaction/TransactionStatus.ts
# Conflicts:
#	src/infrastructure/transaction/CreateTransactionFromPayload.ts
#	src/model/transaction/AccountAddressRestrictionTransaction.ts
#	src/model/transaction/AccountMosaicRestrictionTransaction.ts
#	src/model/transaction/AccountOperationRestrictionTransaction.ts
#	src/service/AggregateTransactionService.ts
…ion handling and easier to understand)

Improved how catapult-service-bootstrap folder is found
@rg911 rg911 merged commit c92f39d into symbol:master Jan 30, 2020
@fboucquez fboucquez deleted the catbuffer-library branch April 13, 2020 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants