1 | | - | {-# STDLIB_VERSION 1 #-} |
---|
2 | | - | {-# CONTENT_TYPE EXPRESSION #-} |
---|
3 | | - | let voteBank = tx.sender |
---|
4 | | - | let minimalVotingHeight = 100 |
---|
5 | | - | match tx { |
---|
6 | | - | case d: DataTransaction => |
---|
7 | | - | if ((size(d.data) == 2)) |
---|
8 | | - | then { |
---|
9 | | - | let feeTransferId = transactionById(d.proofs[0]) |
---|
10 | | - | match feeTransferId { |
---|
11 | | - | case fT: TransferTransaction => |
---|
12 | | - | let votingHeight = extract(getInteger(d.data, 0)) |
---|
13 | | - | if (if (if (if (if (!(isDefined(getString(voteBank, d.data[0].key)))) |
---|
14 | | - | then (fT.recipient == voteBank) |
---|
15 | | - | else false) |
---|
16 | | - | then !(isDefined(fT.assetId)) |
---|
17 | | - | else false) |
---|
18 | | - | then (votingHeight > height) |
---|
19 | | - | else false) |
---|
20 | | - | then ((votingHeight - height) >= minimalVotingHeight) |
---|
21 | | - | else false) |
---|
22 | | - | then match transactionById(fromBase58String(d.data[0].key)) { |
---|
23 | | - | case i: IssueTransaction => |
---|
24 | | - | let accountScriptedProof = extract(getBinary(d.data, 1)) |
---|
25 | | - | let accountScriptHash = extract(getBinary(voteBank, "IssuerAccountScriptHash")) |
---|
26 | | - | let scriptTx = transactionById(accountScriptedProof) |
---|
27 | | - | if ((fT.amount >= (i.quantity * 900000))) |
---|
28 | | - | then if (if (if (if ( match scriptTx { |
---|
29 | | - | case s: SetScriptTransaction => |
---|
30 | | - | if ((sha256(extract(s.script)) == accountScriptHash)) |
---|
31 | | - | then true |
---|
32 | | - | else throw(("hash should be equal to " + toBase58String(sha256(extract(s.script))))) |
---|
33 | | - | case _ => |
---|
34 | | - | throw("voting initiator not scripted, or script is wrong") |
---|
35 | | - | }) |
---|
36 | | - | then (i.decimals == 0) |
---|
37 | | - | else false) |
---|
38 | | - | then (fT.senderPublicKey == i.senderPublicKey) |
---|
39 | | - | else false) |
---|
40 | | - | then (d.data[1].key == toBase58String(i.sender.bytes)) |
---|
41 | | - | else false) |
---|
42 | | - | then sigVerify(d.bodyBytes, d.proofs[1], fT.senderPublicKey) |
---|
43 | | - | else false |
---|
44 | | - | else throw(("minimum trasfer transaction amount is" + toString((i.quantity * 900000)))) |
---|
45 | | - | case _ => |
---|
46 | | - | throw("data key at 0 index should contain voting asset id") |
---|
47 | | - | } |
---|
48 | | - | else false |
---|
49 | | - | case _ => |
---|
50 | | - | throw("proof at index 0 doesn't contain fee transfer transaction") |
---|
51 | | - | } |
---|
52 | | - | } |
---|
53 | | - | else throw("data tx should contain two key-value pairs: 0 - assetId-maxVotingHeight, 1 - ") |
---|
54 | | - | case t: TransferTransaction => |
---|
55 | | - | if (isDefined(getInteger(voteBank, toBase58String(extract(t.assetId))))) |
---|
56 | | - | then { |
---|
57 | | - | let h = getInteger(voteBank, toBase58String(extract(t.assetId))) |
---|
58 | | - | if (if (if ((height >= extract(h))) |
---|
59 | | - | then if ((addressFromRecipient(t.recipient) == addressFromString(extract(getString(voteBank, "pros"))))) |
---|
60 | | - | then true |
---|
61 | | - | else (addressFromRecipient(t.recipient) == addressFromString(extract(getString(voteBank, "cons")))) |
---|
62 | | - | else false) |
---|
63 | | - | then isDefined(getString(voteBank, "pros")) |
---|
64 | | - | else false) |
---|
65 | | - | then isDefined(getString(voteBank, "cons")) |
---|
66 | | - | else false |
---|
67 | | - | } |
---|
68 | | - | else throw("you cannot vote with this token. It's not registred") |
---|
69 | | - | case s: SetScriptTransaction => |
---|
70 | | - | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) |
---|
71 | | - | case _ => |
---|
72 | | - | false |
---|
73 | | - | } |
---|
| 1 | + | # no script |
---|