tx · DSgTqxw9vomsU4KfLjjYLMDUdJW3rkYPafHn4q1sR39k 3N8YkRZsgDVNAxtmwU1F65EpcYMb8f7QPos: -0.01100000 Waves 2024.05.14 15:34 [3105693] smart account 3N8YkRZsgDVNAxtmwU1F65EpcYMb8f7QPos > SELF 0.00000000 Waves
{ "type": 13, "id": "DSgTqxw9vomsU4KfLjjYLMDUdJW3rkYPafHn4q1sR39k", "fee": 1100000, "feeAssetId": null, "timestamp": 1715690012471, "version": 2, "chainId": 84, "sender": "3N8YkRZsgDVNAxtmwU1F65EpcYMb8f7QPos", "senderPublicKey": "F7SLwr7RYVQpyocmVScFC6ooaAwewaGq6wNRDYvyiPj1", "proofs": [ "S9S1jQY2n7VQqorZbqPVPSBAXFgSKuX3bRuUUjUnMdgwtY7GYsE9Madi8AZDZAB6UDqysEABxoCXb3PjSTb7UPh" ], "script": "base64:AAIFAAAAAAAAAAoIAhIECgIICBIAAAAABAAAAAAKbWF4Q291bnRlcgAAAAAAAAAAAwAAAAANZGVmYXVsdFJhdGluZwAAAAAAAAAAZAEAAAAUc2VhcmNoRm9yUHJlZGljdGlvbnMAAAACAAAABml0ZW1JZAAAAAdjb3VudGVyBAAAABBzZWFyY2hGb3JDb3VudGVyBAAAAAckbWF0Y2gwCQAEIgAAAAEJAAEsAAAAAgkAASwAAAACBQAAAAZpdGVtSWQCAAAAAV8JAAGkAAAAAQUAAAAHY291bnRlcgMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFzBQAAAAckbWF0Y2gwBQAAAAFzAgAAAAdObyBVc2VyBQAAABBzZWFyY2hGb3JDb3VudGVyAQAAABZmaW5kUHJlZGljdGlvbkFkcmVzc2VzAAAAAgAAAAZpdGVtSWQAAAAHY291bnRlcgQAAAAKYWRyZXNzTGlzdAUAAAADbmlsAwkAAGcAAAACBQAAAAdjb3VudGVyAAAAAAAAAAABBAAAAAdhZHJlc3MxCQEAAAAUc2VhcmNoRm9yUHJlZGljdGlvbnM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eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXl13gjJ", "height": 3105693, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: CfPFMxDkvxFr4BNcWpW6bPkg8vErv18DZzvLyPdKLwaA Next: 3LznDyEZnroS5VU5YsA1EM8VP4seozQ42jUfKGmdFDu5 Diff:
Old | New | Differences | |
---|---|---|---|
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let maxCounter = 3 | |
5 | 5 | ||
6 | + | let defaultRating = 100 | |
7 | + | ||
6 | 8 | func searchForPredictions (itemId,counter) = { | |
7 | - | let | |
9 | + | let searchForCounter = match getString(((itemId + "_") + toString(counter))) { | |
8 | 10 | case s: String => | |
9 | 11 | s | |
10 | 12 | case _ => | |
11 | 13 | "No User" | |
12 | 14 | } | |
13 | - | | |
15 | + | searchForCounter | |
14 | 16 | } | |
15 | 17 | ||
16 | 18 | ||
65 | 67 | if ((searchForItem == "no Data exists")) | |
66 | 68 | then throw("This ItemID does not exist!") | |
67 | 69 | else { | |
68 | - | let searchForUser = match | |
69 | - | case s: | |
70 | + | let searchForUser = match getInteger(clientAdress) { | |
71 | + | case s: Int => | |
70 | 72 | s | |
71 | 73 | case _ => | |
72 | 74 | "no User exists" | |
113 | 115 | } | |
114 | 116 | ||
115 | 117 | ||
118 | + | ||
119 | + | @Callable(i) | |
120 | + | func registerUser () = { | |
121 | + | let clientAdress = toString(i.caller) | |
122 | + | let searchForUser = match getInteger(clientAdress) { | |
123 | + | case s: Int => | |
124 | + | s | |
125 | + | case _ => | |
126 | + | "No user found" | |
127 | + | } | |
128 | + | if ((searchForUser != "No user Found")) | |
129 | + | then throw("User already exists") | |
130 | + | else [IntegerEntry(clientAdress, defaultRating)] | |
131 | + | } | |
132 | + | ||
133 | + | ||
116 | 134 | @Verifier(tx) | |
117 | 135 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
118 | 136 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let maxCounter = 3 | |
5 | 5 | ||
6 | + | let defaultRating = 100 | |
7 | + | ||
6 | 8 | func searchForPredictions (itemId,counter) = { | |
7 | - | let | |
9 | + | let searchForCounter = match getString(((itemId + "_") + toString(counter))) { | |
8 | 10 | case s: String => | |
9 | 11 | s | |
10 | 12 | case _ => | |
11 | 13 | "No User" | |
12 | 14 | } | |
13 | - | | |
15 | + | searchForCounter | |
14 | 16 | } | |
15 | 17 | ||
16 | 18 | ||
17 | 19 | func findPredictionAdresses (itemId,counter) = { | |
18 | 20 | let adressList = nil | |
19 | 21 | if ((counter >= 1)) | |
20 | 22 | then { | |
21 | 23 | let adress1 = searchForPredictions(itemId, 1) | |
22 | 24 | (adressList :+ adress1) | |
23 | 25 | } | |
24 | 26 | else if ((counter >= 2)) | |
25 | 27 | then { | |
26 | 28 | let adress1 = searchForPredictions(itemId, 1) | |
27 | 29 | let adress2 = searchForPredictions(itemId, 2) | |
28 | 30 | ((adressList :+ adress1) :+ adress2) | |
29 | 31 | } | |
30 | 32 | else if ((counter >= 3)) | |
31 | 33 | then { | |
32 | 34 | let adress1 = searchForPredictions(itemId, 1) | |
33 | 35 | let adress2 = searchForPredictions(itemId, 2) | |
34 | 36 | let adress3 = searchForPredictions(itemId, 3) | |
35 | 37 | (((adressList :+ adress1) :+ adress2) :+ adress3) | |
36 | 38 | } | |
37 | 39 | else if ((counter >= 4)) | |
38 | 40 | then { | |
39 | 41 | let adress1 = searchForPredictions(itemId, 1) | |
40 | 42 | let adress2 = searchForPredictions(itemId, 2) | |
41 | 43 | let adress3 = searchForPredictions(itemId, 3) | |
42 | 44 | let adress4 = searchForPredictions(itemId, 4) | |
43 | 45 | ((((adressList :+ adress1) :+ adress2) :+ adress3) :+ adress4) | |
44 | 46 | } | |
45 | 47 | else { | |
46 | 48 | let adress1 = searchForPredictions(itemId, 1) | |
47 | 49 | let adress2 = searchForPredictions(itemId, 2) | |
48 | 50 | let adress3 = searchForPredictions(itemId, 3) | |
49 | 51 | let adress4 = searchForPredictions(itemId, 4) | |
50 | 52 | let adress5 = searchForPredictions(itemId, 5) | |
51 | 53 | (((((adressList :+ adress1) :+ adress2) :+ adress3) :+ adress4) :+ adress5) | |
52 | 54 | } | |
53 | 55 | } | |
54 | 56 | ||
55 | 57 | ||
56 | 58 | @Callable(i) | |
57 | 59 | func savePrediction (itemId,prediction) = { | |
58 | 60 | let clientAdress = toString(i.caller) | |
59 | 61 | let searchForItem = match getString(itemId) { | |
60 | 62 | case s: String => | |
61 | 63 | s | |
62 | 64 | case _ => | |
63 | 65 | "no Data exists" | |
64 | 66 | } | |
65 | 67 | if ((searchForItem == "no Data exists")) | |
66 | 68 | then throw("This ItemID does not exist!") | |
67 | 69 | else { | |
68 | - | let searchForUser = match | |
69 | - | case s: | |
70 | + | let searchForUser = match getInteger(clientAdress) { | |
71 | + | case s: Int => | |
70 | 72 | s | |
71 | 73 | case _ => | |
72 | 74 | "no User exists" | |
73 | 75 | } | |
74 | 76 | if ((searchForUser == "no User exists")) | |
75 | 77 | then throw("User does not exist") | |
76 | 78 | else { | |
77 | 79 | let searchForCounter = match getInteger((itemId + "_counter")) { | |
78 | 80 | case s: Int => | |
79 | 81 | s | |
80 | 82 | case _ => | |
81 | 83 | -1 | |
82 | 84 | } | |
83 | 85 | let adressList = findPredictionAdresses(itemId, searchForCounter) | |
84 | 86 | if (containsElement(adressList, clientAdress)) | |
85 | 87 | then throw("This User already gave a Prediction") | |
86 | 88 | else if ((searchForCounter >= 1)) | |
87 | 89 | then { | |
88 | 90 | let predictionCounter = match getInteger((itemId + "_predictionCounter")) { | |
89 | 91 | case s: Int => | |
90 | 92 | s | |
91 | 93 | case _ => | |
92 | 94 | -1 | |
93 | 95 | } | |
94 | 96 | let lastPredictionAdress = adressList[(size(adressList) - 1)] | |
95 | 97 | let lastPrediction = match getString(((itemId + "_") + lastPredictionAdress)) { | |
96 | 98 | case s: String => | |
97 | 99 | s | |
98 | 100 | case _ => | |
99 | 101 | "no Prediction Found" | |
100 | 102 | } | |
101 | 103 | let newCounter = (searchForCounter + 1) | |
102 | 104 | if ((lastPrediction == prediction)) | |
103 | 105 | then if (((predictionCounter + 1) == maxCounter)) | |
104 | 106 | then [StringEntry(((itemId + "_") + toString(newCounter)), clientAdress), StringEntry(((itemId + "_") + clientAdress), prediction), IntegerEntry((itemId + "_counter"), newCounter), IntegerEntry((itemId + "_predictionCounter"), (predictionCounter + 1)), BooleanEntry((itemId + "_final"), true), BooleanEntry((itemId + "_cancelled"), false)] | |
105 | 107 | else [StringEntry(((itemId + "_") + toString(newCounter)), clientAdress), StringEntry(((itemId + "_") + clientAdress), prediction), IntegerEntry((itemId + "_counter"), newCounter), IntegerEntry((itemId + "_predictionCounter"), (predictionCounter + 1)), BooleanEntry((itemId + "_final"), false), BooleanEntry((itemId + "_cancelled"), false)] | |
106 | 108 | else if ((newCounter >= 6)) | |
107 | 109 | then [StringEntry(((itemId + "_") + toString(newCounter)), clientAdress), StringEntry(((itemId + "_") + clientAdress), prediction), IntegerEntry((itemId + "_counter"), newCounter), IntegerEntry((itemId + "_predictionCounter"), (predictionCounter - 1)), BooleanEntry((itemId + "_cancelled"), true), BooleanEntry((itemId + "_final"), false)] | |
108 | 110 | else [StringEntry(((itemId + "_") + toString(newCounter)), clientAdress), StringEntry(((itemId + "_") + clientAdress), prediction), IntegerEntry((itemId + "_counter"), newCounter), IntegerEntry((itemId + "_predictionCounter"), (predictionCounter - 1)), BooleanEntry((itemId + "_cancelled"), false), BooleanEntry((itemId + "_final"), false)] | |
109 | 111 | } | |
110 | 112 | else [StringEntry(((itemId + "_") + toString(1)), clientAdress), StringEntry(((itemId + "_") + clientAdress), prediction), IntegerEntry((itemId + "_counter"), 1), IntegerEntry((itemId + "_predictionCounter"), 1)] | |
111 | 113 | } | |
112 | 114 | } | |
113 | 115 | } | |
114 | 116 | ||
115 | 117 | ||
118 | + | ||
119 | + | @Callable(i) | |
120 | + | func registerUser () = { | |
121 | + | let clientAdress = toString(i.caller) | |
122 | + | let searchForUser = match getInteger(clientAdress) { | |
123 | + | case s: Int => | |
124 | + | s | |
125 | + | case _ => | |
126 | + | "No user found" | |
127 | + | } | |
128 | + | if ((searchForUser != "No user Found")) | |
129 | + | then throw("User already exists") | |
130 | + | else [IntegerEntry(clientAdress, defaultRating)] | |
131 | + | } | |
132 | + | ||
133 | + | ||
116 | 134 | @Verifier(tx) | |
117 | 135 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
118 | 136 |
github/deemru/w8io/026f985 29.02 ms ◑