This repository has been archived by the owner on Jun 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 456
Assign and verify transaction fees in Transactions domain - Closes #3860 #3893
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
c5f704f
Make fee an static property in base transaction and transfer transaction
pablitovicente ed1c2a0
Add FEE prop to transaction types 1,2,3,5
pablitovicente aa69b1d
Do not use static property for multi-signatures due to its dynamic na…
pablitovicente c6095ac
Fix test_transaction
pablitovicente 477e0f4
Add FEE property to matcher CustomTransationClass
pablitovicente 1549559
Allow zero fee transactions
pablitovicente e05cbd2
Update tests related to zero fee
pablitovicente 7273557
Merge branch 'release/2.1.0' into 3860-make-fee-transaction-property
pablitovicente 510a7ca
Add isGreaterThanOrEqualToZero based on PR feedback
pablitovicente 5c426d5
Use MultisignatureTransaction.FEE instead of constant
pablitovicente 2f165f8
Rename typeMultiSignature to MULTISIGNATURE_TYPE
pablitovicente 98c5217
Add megative test case to isGreaterThanOrEqualToZero
pablitovicente 36f5555
Refactor validation of fees out of validate() into its own method so …
pablitovicente eb4f095
Add tests related to validateFee()
pablitovicente 843de50
Apply suggestions from code review
pablitovicente 10b2eaf
Merge branch 'release/2.1.0' into 3860-make-fee-transaction-property
pablitovicente File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,6 +115,7 @@ export abstract class BaseTransaction { | |
public receivedAt?: Date; | ||
|
||
public static TYPE: number; | ||
public static FEE: string; | ||
|
||
protected _id?: string; | ||
protected _senderId?: string; | ||
|
@@ -300,9 +301,27 @@ export abstract class BaseTransaction { | |
); | ||
} | ||
|
||
const feeError = this.validateFee(); | ||
|
||
if (feeError) { | ||
errors.push(feeError); | ||
} | ||
|
||
return createResponse(this.id, errors); | ||
} | ||
|
||
public validateFee(): TransactionError | undefined { | ||
return !this.fee.eq((this.constructor as typeof BaseTransaction).FEE) | ||
? new TransactionError( | ||
`Invalid fee`, | ||
this.id, | ||
'.fee', | ||
this.fee.toString(), | ||
(this.constructor as typeof BaseTransaction).FEE.toString(), | ||
) | ||
: undefined; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is undefined needed here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @MaciejBaj because if there's no error it returns undefined and I saw this was being used for example |
||
} | ||
|
||
public verifyAgainstOtherTransactions( | ||
transactions: ReadonlyArray<TransactionJSON>, | ||
): TransactionResponse { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 don't think this function is meant to be public, used only within the class.
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.
Protected methods can not be overridden and we need to handle the special case of multi-signatures that's why public seems the only possible solution in this case but if you alternatives please share!