proximax-storage / java-xpx-chain-sdk

ProximaX Sirius-Chain Java SDK
Apache License 2.0
7 stars 1 forks source link

Fee calculation strategies and transaction builders #116

Closed tonowie closed 5 years ago

tonowie commented 5 years ago

Introducing FeeCalculationStrategy enum which allows for simple fee calculation based on the transaction size + refactoring to get the size outside of serialization. BlockchainApi provides DEFAULT_FEE_CALCULATION_STRATEGY constant in case someone wants to use the default provided by SDK. Also introducing TransactionFactory with TransferTransactionBuilder implemented as a demo. Similar will need to be done for every transaction type. E2ETransferTest.java shows how factory can be retrieved from the api, defaults set and then used to make transfer. Simplest "transfer" (no mosaic, empty message) is as follows TransferTransaction transaction = transact.transfer().to(target).build();

Feedback is very welcome as I am starting with implementation of builders for the rest of the transactions and would hate to throw everything out of window :)

tonowie commented 5 years ago

most of the transaction types are now moved to single-constructor + builder implementation. E2E tests showcase the use of the builder. Based on the feedback from @xgreenx fee calculation strategy was removed from transactions and is performed by the builder

tonowie commented 5 years ago

finished refactoring of transactions. E2E tests now pass. couple jUnit tests are failing on compilation issues which need to be resolved

tonowie commented 5 years ago

Work is done now. I will be writing more automated tests to increase code coverage to 90% prior to merge to master but final review and approval can already be done. E2E tests pass and there will potentially be only very minor changes to the implementation or API. @alvin-reyes please review the pull request and approve if it is OK with you.

tonowie commented 5 years ago

done, pending approval from @alvin-reyes