Created
January 4, 2018 21:17
-
-
Save azamsharp/8c928f5c494c87640a26e01d6d096412 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class InternationalDomesticTransferFeesContract : SmartContract { | |
func apply(to transaction: Transaction) { | |
switch transaction.transactionType { | |
case .international: | |
transaction.fees = 10 | |
case .domestic: | |
transaction.fees = 2 | |
} | |
if transaction.amount < transaction.fees { | |
print("broken rule") | |
transaction.addBrokenRule(BrokenRule(contractName: "InternationalDomesticTransferFeesContract", message: "Insufficient funds")) | |
} else { | |
transaction.amount -= transaction.fees | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment