tx · CwKnpEMwVKg5B4gCdryW29Ju92F6eCPErhdKaWEKoYN5 3N5YzdqDE6FDdsLNGXU4G4yrmirb2oiifEc: -0.01000000 Waves 2022.10.21 11:08 [2281910] smart account 3N5YzdqDE6FDdsLNGXU4G4yrmirb2oiifEc > SELF 0.00000000 Waves
{ "type": 13, "id": "CwKnpEMwVKg5B4gCdryW29Ju92F6eCPErhdKaWEKoYN5", "fee": 1000000, "feeAssetId": null, "timestamp": 1666339751106, "version": 2, "chainId": 84, "sender": "3N5YzdqDE6FDdsLNGXU4G4yrmirb2oiifEc", "senderPublicKey": "E3rsNDJ7CyVzRYUkm1k4GYLuZYYxzQioRgWedzPYXTSL", "proofs": [ "2CqEPTSfyAgciFjzGgujmaA2jCYo5DPHqair3Nb4jVQjSVdzyWFgfnV8u2o2AYnJjcTuPFQvnfGPnVhiSU1gj9Rr" ], "script": "base64:AAIFAAAAAAAAABIIAhIDCgEIEgQKAgEBEgMKAQEAAAAIAAAAAAl2b3RlQXNzZXQBAAAAIC03E4HTJDddn+FvdtPRD5PvLCz03YmtXEpW6HzJAXIbAAAAAAx2b3RlQXNzZXRTdHICAAAALDQzVzRGY3FBMXJFcFNtVUdIb0dpWHZwU0xmaGFkd3M5TFM1ajNTSnNLeHhTAAAAAA9uZXdQdXJwb3NlUHJpY2UAAAAAAlQL5AAAAAAADHZvdGVEdXJhdGlvbgkAAGgAAAACAAAAAAAAAAAHAAAAAAAAAAWgAAAAAA1uZXdQdXJwb3NlS2V5AgAAAAdwdXJwb3NlAAAAAAxwdXJwb3NlSWRLZXkCAAAACXB1cnBvc2VJZAAAAAAKbXVsdGlwbGllcgAAAAAAAAAAAgEAAAALaXNQYXltZW50T2sAAAABAAAAAWkEAAAAEWFjY2VwdGFibGVBc3NldElkBQAAAAl2b3RlQXNzZXQDCQAAAAAAAAIJAAGQAAAAAQgFAAAAAWkAAAAIcGF5bWVudHMAAAAAAAAAAAAJAAACAAAAAQIAAAAUcGF5bWVudCBub3QgYXR0YW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9yRXJyb3JNZXNzYWdlAAAAAgkABBoAAAACBQAAAAR0aGlzCQABLAAAAAIJAAEsAAAAAgkAASwAAAACCQABLAAAAAIJAAEsAAAAAgUAAAANbmV3UHVycG9zZUtleQIAAAABXwkAAaQAAAABBQAAAAlwdXJwb3NlSWQCAAAAAV8FAAAACmN1cnJlbnRLZXkCAAAAD19maXJzdFZvdGVCbG9jawIAAAA5c29tZXRoaW5nIHdlbnQgd3JvbmcuIHByb2JhYmx5IHlvdSBkaWQgbm90IHZvdGUgZm9yIHRoaXMhBAAAAAlsb2NrQmxvY2sJAABkAAAAAgUAAAAMZ2V0TG9ja0Jsb2NrBQAAAAx2b3RlRHVyYXRpb24EAAAABXRvdGFsCQAAZAAAAAIFAAAACmdldFllc1VzZXIFAAAACWdldE5vVXNlcgMJAABmAAAAAgUAAAAGaGVpZ2h0BQAAAAlsb2NrQmxvY2sDCQAAZgAAAAIFAAAABXRvdGFsAAAAAAAAAAAACQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAAFpAAAABmNhbGxlcgUAAAAFdG90YWwFAAAACXZvdGVBc3NldAUAAAADbmlsCQAAAgAAAAECAAAAEW5vdGhpbmcgdG8gY2xhaW0hCQAAAgAAAAEJAAEsAAAAAgIAAAAkc3RpbGwgbG9ja2VkISB3aWxsIGJlIGF2YWlsYWJsZSBhdDogCQABpAAAAAEFAAAADGdldExvY2tCbG9jawAAAADA5A2q", "height": 2281910, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 2A8tU5AXsf5vVhQnwHJ5X4FJTZfsb4ND73Gknkurqnaj Next: none Diff:
Old | New | Differences | |
---|---|---|---|
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let voteAsset = base58'43W4FcqA1rEpSmUGHoGiXvpSLfhadws9LS5j3SJsKxxS' | |
5 | 5 | ||
6 | - | let gAsset = base58'AkU3DaDKndbWSVaw4LmxuduVQBXkwkKZ7mV5dxrAqLvT' | |
7 | - | ||
8 | 6 | let voteAssetStr = "43W4FcqA1rEpSmUGHoGiXvpSLfhadws9LS5j3SJsKxxS" | |
9 | - | ||
10 | - | let gAssetStr = "AkU3DaDKndbWSVaw4LmxuduVQBXkwkKZ7mV5dxrAqLvT" | |
11 | 7 | ||
12 | 8 | let newPurposePrice = 10000000000 | |
13 | 9 | ||
77 | 73 | else { | |
78 | 74 | let amount = i.payments[0].amount | |
79 | 75 | let lockTill = (height + voteDuration) | |
80 | - | if (if ( | |
76 | + | if (if ((0 >= amount)) | |
81 | 77 | then true | |
82 | 78 | else (i.payments[0].assetId != voteAsset)) | |
83 | - | then true | |
84 | - | else (i.payments[0].assetId != gAsset)) | |
85 | 79 | then throw("invalid token attached") | |
86 | 80 | else { | |
87 | 81 | let totalVote = valueOrElse(getInteger(this, (((newPurposeKey + "_") + toString(purposeId)) + "_totalVote")), 0) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let voteAsset = base58'43W4FcqA1rEpSmUGHoGiXvpSLfhadws9LS5j3SJsKxxS' | |
5 | 5 | ||
6 | - | let gAsset = base58'AkU3DaDKndbWSVaw4LmxuduVQBXkwkKZ7mV5dxrAqLvT' | |
7 | - | ||
8 | 6 | let voteAssetStr = "43W4FcqA1rEpSmUGHoGiXvpSLfhadws9LS5j3SJsKxxS" | |
9 | - | ||
10 | - | let gAssetStr = "AkU3DaDKndbWSVaw4LmxuduVQBXkwkKZ7mV5dxrAqLvT" | |
11 | 7 | ||
12 | 8 | let newPurposePrice = 10000000000 | |
13 | 9 | ||
14 | 10 | let voteDuration = (7 * 1440) | |
15 | 11 | ||
16 | 12 | let newPurposeKey = "purpose" | |
17 | 13 | ||
18 | 14 | let purposeIdKey = "purposeId" | |
19 | 15 | ||
20 | 16 | let multiplier = 2 | |
21 | 17 | ||
22 | 18 | func isPaymentOk (i) = { | |
23 | 19 | let acceptableAssetId = voteAsset | |
24 | 20 | if ((size(i.payments) == 0)) | |
25 | 21 | then throw("payment not attached") | |
26 | 22 | else { | |
27 | 23 | let p = i.payments[0] | |
28 | 24 | match p.assetId { | |
29 | 25 | case assetId: ByteVector => | |
30 | 26 | if ((assetId == acceptableAssetId)) | |
31 | 27 | then (p.amount == newPurposePrice) | |
32 | 28 | else false | |
33 | 29 | case _ => | |
34 | 30 | throw("wrong payment asset") | |
35 | 31 | } | |
36 | 32 | } | |
37 | 33 | } | |
38 | 34 | ||
39 | 35 | ||
40 | 36 | @Callable(i) | |
41 | 37 | func newPurpose (purpose) = { | |
42 | 38 | let stringSize = size(toBytes(purpose)) | |
43 | 39 | let currentKey = toBase58String(i.caller.bytes) | |
44 | 40 | let purposeId = valueOrElse(getInteger(this, purposeIdKey), 0) | |
45 | 41 | if (if ((stringSize > 200)) | |
46 | 42 | then true | |
47 | 43 | else (10 > stringSize)) | |
48 | 44 | then throw("purpose text cannot be more than 200") | |
49 | 45 | else if (!(isPaymentOk(i))) | |
50 | 46 | then throw(("you have to pay " + toString(newPurposePrice))) | |
51 | 47 | else { | |
52 | 48 | let startHeight = height | |
53 | 49 | let endHeight = (height + voteDuration) | |
54 | 50 | let text = toBase64String(toBytes(purpose)) | |
55 | 51 | let id = (purposeId + 1) | |
56 | 52 | [StringEntry((((newPurposeKey + "_") + toString(id)) + "_text"), text), IntegerEntry(purposeIdKey, id), StringEntry((((newPurposeKey + "_") + toString(id)) + "_duration"), ((toString(startHeight) + "_") + toString(endHeight))), StringEntry((((newPurposeKey + "_") + toString(id)) + "_owner"), currentKey)] | |
57 | 53 | } | |
58 | 54 | } | |
59 | 55 | ||
60 | 56 | ||
61 | 57 | ||
62 | 58 | @Callable(i) | |
63 | 59 | func vote4EnnoDAO (purposeId,vote) = { | |
64 | 60 | let getDuration = valueOrErrorMessage(getString(this, (((newPurposeKey + "_") + toString(purposeId)) + "_duration")), "purpose not found") | |
65 | 61 | let duration = split(getDuration, "_") | |
66 | 62 | let startHeight = valueOrElse(parseInt(duration[0]), 0) | |
67 | 63 | let endHeight = valueOrElse(parseInt(duration[1]), 0) | |
68 | 64 | let currentKey = toBase58String(i.caller.bytes) | |
69 | 65 | if (if ((startHeight > height)) | |
70 | 66 | then true | |
71 | 67 | else (height > endHeight)) | |
72 | 68 | then throw(("voting period is over for purposal: " + toString(purposeId))) | |
73 | 69 | else if (if ((0 >= vote)) | |
74 | 70 | then true | |
75 | 71 | else (vote > 2)) | |
76 | 72 | then throw("vote must be yes or no") | |
77 | 73 | else { | |
78 | 74 | let amount = i.payments[0].amount | |
79 | 75 | let lockTill = (height + voteDuration) | |
80 | - | if (if ( | |
76 | + | if (if ((0 >= amount)) | |
81 | 77 | then true | |
82 | 78 | else (i.payments[0].assetId != voteAsset)) | |
83 | - | then true | |
84 | - | else (i.payments[0].assetId != gAsset)) | |
85 | 79 | then throw("invalid token attached") | |
86 | 80 | else { | |
87 | 81 | let totalVote = valueOrElse(getInteger(this, (((newPurposeKey + "_") + toString(purposeId)) + "_totalVote")), 0) | |
88 | 82 | let walletTotalVote = valueOrElse(getInteger(this, ((((newPurposeKey + "_") + toString(purposeId)) + currentKey) + "_walletTotalVote")), 0) | |
89 | 83 | let firstVoteCast = valueOrElse(getInteger(this, (((((newPurposeKey + "_") + toString(purposeId)) + "_") + currentKey) + "_firstVoteBlock")), height) | |
90 | 84 | if ((vote == 1)) | |
91 | 85 | then { | |
92 | 86 | let getYes = valueOrElse(getInteger(this, (((newPurposeKey + "_") + toString(purposeId)) + "_yes")), 0) | |
93 | 87 | let getYesUser = valueOrElse(getInteger(this, (((((newPurposeKey + "_") + toString(purposeId)) + "_") + currentKey) + "_yes")), 0) | |
94 | 88 | let total = (getYes + amount) | |
95 | 89 | [IntegerEntry((((((newPurposeKey + "_") + toString(purposeId)) + "_") + currentKey) + "_yes"), (getYesUser + amount)), IntegerEntry((((newPurposeKey + "_") + toString(purposeId)) + "_yes"), total), IntegerEntry((((newPurposeKey + "_") + toString(purposeId)) + "_totalVote"), (amount + totalVote)), IntegerEntry((((((newPurposeKey + "_") + toString(purposeId)) + "_") + currentKey) + "_firstVoteBlock"), firstVoteCast), IntegerEntry((((((newPurposeKey + "_") + toString(purposeId)) + "_") + currentKey) + "_walletTotalVote"), (amount + walletTotalVote))] | |
96 | 90 | } | |
97 | 91 | else if ((vote == 2)) | |
98 | 92 | then { | |
99 | 93 | let getNo = valueOrElse(getInteger(this, (((newPurposeKey + "_") + toString(purposeId)) + "_no")), 0) | |
100 | 94 | let getNoUser = valueOrElse(getInteger(this, (((((newPurposeKey + "_") + toString(purposeId)) + "_") + currentKey) + "_no")), 0) | |
101 | 95 | let total = (getNo + amount) | |
102 | 96 | [IntegerEntry((((((newPurposeKey + "_") + toString(purposeId)) + "_") + currentKey) + "_no"), (getNoUser + amount)), IntegerEntry((((newPurposeKey + "_") + toString(purposeId)) + "_no"), total), IntegerEntry((((newPurposeKey + "_") + toString(purposeId)) + "_totalVote"), (amount + totalVote)), IntegerEntry((((((newPurposeKey + "_") + toString(purposeId)) + "_") + currentKey) + "_firstVoteBlock"), firstVoteCast), IntegerEntry((((((newPurposeKey + "_") + toString(purposeId)) + "_") + currentKey) + "_walletTotalVote"), (amount + walletTotalVote))] | |
103 | 97 | } | |
104 | 98 | else throw("nothing to do my friend") | |
105 | 99 | } | |
106 | 100 | } | |
107 | 101 | } | |
108 | 102 | ||
109 | 103 | ||
110 | 104 | ||
111 | 105 | @Callable(i) | |
112 | 106 | func claimBack (purposeId) = { | |
113 | 107 | let currentKey = toBase58String(i.caller.bytes) | |
114 | 108 | let getYesUser = valueOrElse(getInteger(this, (((((newPurposeKey + "_") + toString(purposeId)) + "_") + currentKey) + "_yes")), 0) | |
115 | 109 | let getNoUser = valueOrElse(getInteger(this, (((((newPurposeKey + "_") + toString(purposeId)) + "_") + currentKey) + "_no")), 0) | |
116 | 110 | let getLockBlock = valueOrErrorMessage(getInteger(this, (((((newPurposeKey + "_") + toString(purposeId)) + "_") + currentKey) + "_firstVoteBlock")), "something went wrong. probably you did not vote for this!") | |
117 | 111 | let lockBlock = (getLockBlock + voteDuration) | |
118 | 112 | let total = (getYesUser + getNoUser) | |
119 | 113 | if ((height > lockBlock)) | |
120 | 114 | then if ((total > 0)) | |
121 | 115 | then [ScriptTransfer(i.caller, total, voteAsset)] | |
122 | 116 | else throw("nothing to claim!") | |
123 | 117 | else throw(("still locked! will be available at: " + toString(getLockBlock))) | |
124 | 118 | } | |
125 | 119 | ||
126 | 120 |
github/deemru/w8io/026f985 32.72 ms ◑