Skip to content

Instantly share code, notes, and snippets.

@azamsharp
Created January 4, 2018 21:17
Show Gist options
  • Save azamsharp/8c928f5c494c87640a26e01d6d096412 to your computer and use it in GitHub Desktop.
Save azamsharp/8c928f5c494c87640a26e01d6d096412 to your computer and use it in GitHub Desktop.
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