-
Notifications
You must be signed in to change notification settings - Fork 55
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
Conversation
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)
There was a problem hiding this 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.
src/core/utils/TransactionMapping.ts
Outdated
public static createFromPayload(payload: string, | ||
isEmbedded = false): Transaction | InnerTransaction { | ||
return CreateTransactionFromPayload(payload, isEmbedded); | ||
public static createFromPayload(payload: string): Transaction { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @evias ,
-
would you confirm I can remove InnerTransaction?
-
Is the simplier TransactionMapping method ok?
public static createFromPayload(payload: string): Transaction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
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.
-
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 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
- I'll add the createFromInnerPayload in TransactionMapping
There was a problem hiding this comment.
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' ?
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
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. |
There was a problem hiding this 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 👍
src/core/utils/TransactionMapping.ts
Outdated
public static createFromPayload(payload: string, | ||
isEmbedded = false): Transaction | InnerTransaction { | ||
return CreateTransactionFromPayload(payload, isEmbedded); | ||
public static createFromPayload(payload: string): Transaction { |
There was a problem hiding this comment.
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().
# 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.
# 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
…pescript-javascript into catbuffer-library
…ion handling and easier to understand) Improved how catapult-service-bootstrap folder is found
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