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