-
Notifications
You must be signed in to change notification settings - Fork 68
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
refactor: Implement generics in Transaction.go
#1089
Conversation
Signed-off-by: Ivan Ivanov <ivanivanov.ii726@gmail.com>
Signed-off-by: Ivan Ivanov <ivanivanov.ii726@gmail.com>
Signed-off-by: Ivan Ivanov <ivanivanov.ii726@gmail.com>
Signed-off-by: Ivan Ivanov <ivanivanov.ii726@gmail.com>
Signed-off-by: Ivan Ivanov <ivanivanov.ii726@gmail.com>
Signed-off-by: Ivan Ivanov <ivanivanov.ii726@gmail.com>
Signed-off-by: Ivan Ivanov <ivanivanov.ii726@gmail.com>
Signed-off-by: Ivan Ivanov <ivanivanov.ii726@gmail.com>
Signed-off-by: Ivan Ivanov <ivanivanov.ii726@gmail.com>
Signed-off-by: Ivan Ivanov <ivanivanov.ii726@gmail.com>
Signed-off-by: Ivan Ivanov <ivanivanov.ii726@gmail.com>
Signed-off-by: Ivan Ivanov <ivanivanov.ii726@gmail.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1089 +/- ##
==========================================
+ Coverage 72.16% 74.25% +2.09%
==========================================
Files 175 174 -1
Lines 28770 21624 -7146
==========================================
- Hits 20762 16057 -4705
+ Misses 7263 4899 -2364
+ Partials 745 668 -77 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Ivan Ivanov <ivanivanov.ii726@gmail.com>
Signed-off-by: Ivan Ivanov <ivanivanov.ii726@gmail.com>
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.
Do not merge until we've release v2.49
Transaction.go
Transaction.go
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.
LGTM.
Signed-off-by: Ivan Ivanov <ivanivanov.ii726@gmail.com>
|
Description:
Introduction
The current design of the
Transaction
struct in Go has 3 major inefficiencies:AccountCreateTransaction
,TokenCreateTransaction
, etc.) needs to implement boilerplate functions that simply shadow methods from the baseTransaction
struct. This results in thousands of lines of redundant code and poor maintainability as the number of methods increases.TransactionExecute
andTransactionSign
rely on large switch statements to handle various transaction types. As more transaction types are added, the code becomes increasingly complex, leading to maintainability issues and a higher likelihood of errors. For reference, the current lines of code for these static methods is around 4000.One such function is this:
Airdrop/Transfer
,TokenClaim/TokenCancel
) is costly in terms of code duplication and complexity. Every transaction type needs its own implementation, which makes code reuse difficult.In order to fix all above mentioned problems is by implementing Generics into
Transacation.go
and transactions.Overview
Old Architecture
Pros:
Example:
NewTokenCreateTransaction.SetTokenID().SetNodeAccountIDs().Execute()
Cons:
New Architecture
Pros:
Example :
NewTokenCreateTransaction.SetTokenID().SetNodeAccountIDs().Execute()
Cons:
SignTransaction
’s api needs a minor change. It would need to accept concrete transaction instead of parent transaction.Example before:
newKey.SignTransaction(&transaction.Transaction)
Example after:
newKey.SignTransaction(transaction)
.Transaction
at the end).https://www.notion.so/limechain/Go-SDK-refactor-v2-10610baa8dcd80d7a787d086a3ef3181
Related issue(s):
Fixes #
Notes for reviewer:
Checklist