Skip to content

Instantly share code, notes, and snippets.

@ayende
Created March 4, 2020 07:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayende/2d7f0c3bf743db663cf974aa726b4ccf to your computer and use it in GitHub Desktop.
Save ayende/2d7f0c3bf743db663cf974aa726b4ccf to your computer and use it in GitHub Desktop.
declare function SourceAccountIsValid(src, dst, req){
}
declare function SourceAccountHasFunds(src, dst, req){
}
declare function validate_transfer(src, dst, req){
var rules = [SourceAccountIsValid, SourceAccountHasFunds,
SourceAccountDailyLimitNotExceed, DestinationAccountHasNoLiens,
DestinationAccountMaxAmountNotExceeded, MoneyTransferIsNotFromDirtyBitcoins
];
var errors = rules.map(rule=> rule(src, dst, req).filter(x=>x!= null);
return { Errors: errors, Valid: errores.length == 0 };
}
from Accounts as src
where id(src) == $source
load $destination as dst
select {
Source: src,
Destination: dst,
Valid: validate_transfer(src, dst, $req)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment