2 | | - | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | | - | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let EMTPYSTRING = "" |
---|
5 | | - | |
---|
6 | | - | func getStringFromKey (key) = match getString(this, key) { |
---|
7 | | - | case str: String => |
---|
8 | | - | str |
---|
9 | | - | case _ => |
---|
10 | | - | EMTPYSTRING |
---|
11 | | - | } |
---|
12 | | - | |
---|
13 | | - | |
---|
14 | | - | func isValidSender (sender) = { |
---|
15 | | - | let entryForSenderAddress = getStringFromKey(sender) |
---|
16 | | - | if ((entryForSenderAddress == EMTPYSTRING)) |
---|
17 | | - | then false |
---|
18 | | - | else true |
---|
19 | | - | } |
---|
20 | | - | |
---|
21 | | - | |
---|
22 | | - | @Callable(i) |
---|
23 | | - | func addRisk (name,description) = { |
---|
24 | | - | let sender = toBase58String(i.caller.bytes) |
---|
25 | | - | if (isValidSender(sender)) |
---|
26 | | - | then WriteSet([DataEntry((toBase58String(i.transactionId) + "_name"), name), DataEntry((toBase58String(i.transactionId) + "_description"), description)]) |
---|
27 | | - | else throw("Sender not allowed to store risks!") |
---|
28 | | - | } |
---|
29 | | - | |
---|
30 | | - | |
---|
31 | | - | |
---|
32 | | - | @Callable(i) |
---|
33 | | - | func addConsolidatedRisk (name,description) = { |
---|
34 | | - | let sender = toBase58String(i.caller.bytes) |
---|
35 | | - | if (isValidSender(sender)) |
---|
36 | | - | then WriteSet([DataEntry((toBase58String(i.transactionId) + "_consolidated_name"), name), DataEntry((toBase58String(i.transactionId) + "_consolidated_description"), description)]) |
---|
37 | | - | else throw("Sender not allowed to consolidate risks!") |
---|
38 | | - | } |
---|
39 | | - | |
---|
40 | | - | |
---|
41 | | - | |
---|
42 | | - | @Callable(i) |
---|
43 | | - | func evaluateRisk (id,probability,impact) = { |
---|
44 | | - | let sender = toBase58String(i.caller.bytes) |
---|
45 | | - | if (isValidSender(sender)) |
---|
46 | | - | then WriteSet([DataEntry((((id + "_") + toBase58String(i.transactionId)) + "_prob"), probability), DataEntry((((id + "_") + toBase58String(i.transactionId)) + "_imp"), impact)]) |
---|
47 | | - | else throw("Sender not allowed to evaluate or evaluated already!") |
---|
48 | | - | } |
---|
49 | | - | |
---|
50 | | - | |
---|
51 | | - | @Verifier(tx) |
---|
52 | | - | func verify () = match tx { |
---|
53 | | - | case _ => |
---|
54 | | - | true |
---|
55 | | - | } |
---|
56 | | - | |
---|
| 2 | + | {-# CONTENT_TYPE EXPRESSION #-} |
---|
| 3 | + | let PubKey1 = base58'854p8BYzrj6yBPRPmfQur3oF1Rjc1AJ548qRp5FT5kDa' |
---|
| 4 | + | let PubKey2 = base58'DKGFPozLrsiR8NM4NJzqQaBYC8NyGYjuw2hDYicQVjco' |
---|
| 5 | + | let sig1 = if (sigVerify(tx.bodyBytes, tx.proofs[0], PubKey1)) |
---|
| 6 | + | then 1 |
---|
| 7 | + | else 0 |
---|
| 8 | + | let sig2 = if (sigVerify(tx.bodyBytes, tx.proofs[1], PubKey2)) |
---|
| 9 | + | then 1 |
---|
| 10 | + | else 0 |
---|
| 11 | + | ((sig1 + sig2) > 0) |
---|