Add require builtin
This commit is contained in:
@@ -104,10 +104,10 @@ contract AEProof =
|
||||
proofsByOwner : map(address, array(uint)) }
|
||||
|
||||
function notarize(document:string, comment:string, ipfsHash:hash) =
|
||||
let _ = require(aetoken.balanceOf(caller()) > 0)
|
||||
let _ = require(aetoken.balanceOf(caller()) > 0, "false")
|
||||
let proofHash: uint = calculateHash(document)
|
||||
let proof : proof = Map.get_(proofHash, state().proofs)
|
||||
let _ = require(proof.owner == #0)
|
||||
let _ = require(proof.owner == #0, "false")
|
||||
let proof' : proof = proof { owner = caller()
|
||||
, timestamp = block().timestamp
|
||||
, proofBlock = block().height
|
||||
@@ -124,12 +124,12 @@ contract AEProof =
|
||||
function getProof(document) : proof =
|
||||
let calcHash = calculateHash(document)
|
||||
let proof = Map.get_(calcHash, state().proofs)
|
||||
let _ = require(proof.owner != #0)
|
||||
let _ = require(proof.owner != #0, "false")
|
||||
proof
|
||||
|
||||
function getProofByHash(hash: uint) : proof =
|
||||
let proof = Map.get_(hash, state().proofs)
|
||||
let _ = require(proof.owner != #0)
|
||||
let _ = require(proof.owner != #0, "false")
|
||||
proof
|
||||
|
||||
|
||||
@@ -141,5 +141,3 @@ contract AEProof =
|
||||
function getProofsByOwner(owner: address): array(uint) =
|
||||
Map.get(owner, state())
|
||||
|
||||
function require(x : bool) : unit = if(x) () else abort("false")
|
||||
|
||||
|
||||
@@ -15,5 +15,3 @@ contract BasicAuth =
|
||||
function to_sign(h : hash, n : int) =
|
||||
Crypto.blake2b((h, n))
|
||||
|
||||
private function require(b : bool, err : string) =
|
||||
if(!b) abort(err)
|
||||
|
||||
@@ -14,5 +14,3 @@ contract BitcoinAuth =
|
||||
function to_sign(h : hash, n : int) : hash =
|
||||
Crypto.blake2b((h, n))
|
||||
|
||||
private function require(b : bool, err : string) =
|
||||
if(!b) abort(err)
|
||||
|
||||
@@ -15,9 +15,6 @@ contract DutchAuction =
|
||||
Chain.spend(to, amount)
|
||||
total - amount
|
||||
|
||||
private function require(b : bool, err : string) =
|
||||
if(!b) abort(err)
|
||||
|
||||
// TTL set by user on posting contract, typically (start - end ) div dec
|
||||
public function init(beneficiary, start, decrease) : state =
|
||||
require(start > 0 && decrease > 0, "bad args")
|
||||
|
||||
@@ -77,9 +77,6 @@ contract ERC20Token =
|
||||
put( state{approval_log = e :: state.approval_log })
|
||||
e
|
||||
|
||||
private function require(b : bool, err : string) =
|
||||
if(!b) abort(err)
|
||||
|
||||
private function sub(_a : int, _b : int) : int =
|
||||
require(_b =< _a, "Error")
|
||||
_a - _b
|
||||
|
||||
@@ -12,9 +12,6 @@ contract FundMe =
|
||||
deadline : int,
|
||||
goal : int }
|
||||
|
||||
private function require(b : bool, err : string) =
|
||||
if(!b) abort(err)
|
||||
|
||||
private stateful function spend(args : spend_args) =
|
||||
Chain.spend(args.recipient, args.amount)
|
||||
|
||||
|
||||
@@ -108,5 +108,3 @@ contract Oracles =
|
||||
Oracle.respond(o, q, Answer(question, "magic", 1337), signature = sig)
|
||||
Oracle.get_answer(o, q)
|
||||
|
||||
private function require(b : bool, err : string) =
|
||||
if(!b) abort(err)
|
||||
|
||||
@@ -20,5 +20,3 @@ contract OraclesGas =
|
||||
Oracle.respond(o, q, answer)
|
||||
()
|
||||
|
||||
private function require(b : bool, err : string) =
|
||||
if(!b) abort(err)
|
||||
|
||||
@@ -33,5 +33,3 @@ contract Oracles =
|
||||
q : query_id) : option(answer_t) =
|
||||
Oracle.get_answer(o, q)
|
||||
|
||||
private function require(b : bool, err : string) =
|
||||
if(!b) abort(err)
|
||||
|
||||
@@ -9,8 +9,6 @@ contract VariantTypes =
|
||||
|
||||
function init() = Stopped
|
||||
|
||||
function require(b) = if(!b) abort("required")
|
||||
|
||||
stateful function start(bal : int) =
|
||||
switch(state)
|
||||
Stopped => put(Started({owner = Call.caller, balance = bal, color = Grey(0)}))
|
||||
@@ -18,7 +16,7 @@ contract VariantTypes =
|
||||
stateful function stop() =
|
||||
switch(state)
|
||||
Started(st) =>
|
||||
require(Call.caller == st.owner)
|
||||
require(Call.caller == st.owner, "required")
|
||||
put(Stopped)
|
||||
st.balance
|
||||
|
||||
|
||||
Reference in New Issue
Block a user