35 | | - | |
---|
36 | | - | @Callable(w) |
---|
37 | | - | func registerData (x,y,z,A,B) = { |
---|
38 | | - | let C = { |
---|
39 | | - | let D = getString(z) |
---|
40 | | - | if ($isInstanceOf(D, "String")) |
---|
41 | | - | then { |
---|
42 | | - | let E = D |
---|
43 | | - | E |
---|
44 | | - | } |
---|
45 | | - | else "no Data exists" |
---|
46 | | - | } |
---|
47 | | - | if ((C != "no Data exists")) |
---|
48 | | - | then throw("There is already existing Data for this case!") |
---|
49 | | - | else { |
---|
50 | | - | let F = [z, b, "evaluatedDataCallback"] |
---|
51 | | - | let G = toString(w.caller) |
---|
52 | | - | let H = toBase58String(w.transactionId) |
---|
53 | | - | let I = invoke(Address(fromBase58String(a)), "registerTaskCallback", F, [AttachedPayment(d, c)]) |
---|
54 | | - | [StringEntry(z, H), IntegerEntry((((z + "_") + G) + "_age"), x[0]), IntegerEntry((((z + "_") + G) + "_sex"), x[1]), IntegerEntry((((z + "_") + G) + "_damage"), x[2]), IntegerEntry((((z + "_") + G) + "_fac1"), x[3]), IntegerEntry((((z + "_") + G) + "_fac2"), x[4]), IntegerEntry((((z + "_") + G) + "_fac3"), x[5]), IntegerEntry((((z + "_") + G) + "_fac4"), x[6]), IntegerEntry((((z + "_") + G) + "_vio1"), x[7]), IntegerEntry((((z + "_") + G) + "_vio2"), x[8]), IntegerEntry((((z + "_") + G) + "_vio3"), x[9]), IntegerEntry((((z + "_") + G) + "_vio4"), x[10]), IntegerEntry((((z + "_") + G) + "_cost"), x[11]), IntegerEntry((((z + "_") + A) + "_age"), y[0]), IntegerEntry((((z + "_") + A) + "_sex"), y[1]), IntegerEntry((((z + "_") + A) + "_damage"), y[2]), IntegerEntry((((z + "_") + A) + "_fac1"), y[3]), IntegerEntry((((z + "_") + A) + "_fac2"), y[4]), IntegerEntry((((z + "_") + A) + "_fac3"), y[5]), IntegerEntry((((z + "_") + A) + "_fac4"), y[6]), IntegerEntry((((z + "_") + A) + "_vio1"), y[7]), IntegerEntry((((z + "_") + A) + "_vio2"), y[8]), IntegerEntry((((z + "_") + A) + "_vio3"), y[9]), IntegerEntry((((z + "_") + A) + "_vio4"), y[10]), IntegerEntry((((z + "_") + A) + "_cost"), y[11]), IntegerEntry((z + "_lgt"), B), StringEntry((z + "_status"), "open"), StringEntry((z + "_sender"), G)] |
---|
55 | | - | } |
---|
56 | | - | } |
---|
57 | | - | |
---|
58 | | - | |
---|
59 | | - | |
---|
60 | | - | @Callable(w) |
---|
61 | | - | func evaluatedDataCallback (J) = { |
---|
62 | | - | let H = toBase58String(w.transactionId) |
---|
63 | | - | let K = i(J) |
---|
64 | | - | let L = K._1[1] |
---|
65 | | - | let M = K._2[1] |
---|
66 | | - | let N = K._3[1] |
---|
67 | | - | let O = { |
---|
68 | | - | let D = getString(L) |
---|
69 | | - | if ($isInstanceOf(D, "String")) |
---|
70 | | - | then { |
---|
71 | | - | let E = D |
---|
72 | | - | E |
---|
73 | | - | } |
---|
74 | | - | else "no Data exists" |
---|
75 | | - | } |
---|
76 | | - | if ((O == "no Data exists")) |
---|
77 | | - | then throw("There is no Data for this crashId!") |
---|
78 | | - | else { |
---|
79 | | - | let P = { |
---|
80 | | - | let D = getString((L + "_status")) |
---|
81 | | - | if ($isInstanceOf(D, "String")) |
---|
82 | | - | then { |
---|
83 | | - | let E = D |
---|
84 | | - | E |
---|
85 | | - | } |
---|
86 | | - | else "no Data exists" |
---|
87 | | - | } |
---|
88 | | - | if ((P == "no Data exists")) |
---|
89 | | - | then throw("There is no status for this case!") |
---|
90 | | - | else if ((P == "closed")) |
---|
91 | | - | then throw("A case should not be evaluated twice!") |
---|
92 | | - | else { |
---|
93 | | - | let Q = { |
---|
94 | | - | let D = getInteger((((O + "_") + M) + "_cost")) |
---|
95 | | - | if ($isInstanceOf(D, "Int")) |
---|
96 | | - | then { |
---|
97 | | - | let E = D |
---|
98 | | - | E |
---|
99 | | - | } |
---|
100 | | - | else "No data Found" |
---|
101 | | - | } |
---|
102 | | - | if ((Q == "No data Found")) |
---|
103 | | - | then throw("There is no data for this address!") |
---|
104 | | - | else if ((Q == -1)) |
---|
105 | | - | then [StringEntry((L + "_eval"), H), StringEntry((L + "_innocent_address"), M), StringEntry((L + "_guilty_address"), N), StringEntry((L + "_status"), "evaluated")] |
---|
106 | | - | else [StringEntry((L + "_eval"), H), StringEntry((L + "_innocent_address"), M), StringEntry((L + "_guilty_address"), N), StringEntry((L + "_status"), "closed"), ScriptTransfer(Address(fromBase58String(M)), 100000000, unit)] |
---|
107 | | - | } |
---|
108 | | - | } |
---|
109 | | - | } |
---|
110 | | - | |
---|
111 | | - | |
---|
112 | | - | |
---|
113 | | - | @Callable(w) |
---|
114 | | - | func evaluatedData (R,S,T,U) = { |
---|
115 | | - | let H = toBase58String(w.transactionId) |
---|
116 | | - | [StringEntry(R, H), StringEntry((H + "_guilty"), U)] |
---|
117 | | - | } |
---|
118 | | - | |
---|
119 | | - | |
---|
120 | | - | |
---|
121 | | - | @Callable(w) |
---|
122 | | - | func requestPayout (V,W,z) = { |
---|
123 | | - | let G = toString(w.caller) |
---|
124 | | - | let H = toBase58String(w.transactionId) |
---|
125 | | - | [StringEntry((z + "_request_payout"), H), IntegerEntry((H + "_amount"), W), StringEntry((H + "_prediction_id"), V)] |
---|
126 | | - | } |
---|
127 | | - | |
---|
128 | | - | |
---|
129 | | - | @Verifier(X) |
---|
130 | | - | func Y () = sigVerify(X.bodyBytes, X.proofs[0], X.senderPublicKey) |
---|