tx · 2H62WQsMcwSECDUJx4pgxTBTrsX1V1F2eGHHKEB3gZfr

3N5YzdqDE6FDdsLNGXU4G4yrmirb2oiifEc:  -0.01000000 Waves

2022.10.19 11:45 [2279045] smart account 3N5YzdqDE6FDdsLNGXU4G4yrmirb2oiifEc > SELF 0.00000000 Waves

{ "type": 13, "id": "2H62WQsMcwSECDUJx4pgxTBTrsX1V1F2eGHHKEB3gZfr", "fee": 1000000, "feeAssetId": null, "timestamp": 1666169174789, "version": 2, "chainId": 84, "sender": "3N5YzdqDE6FDdsLNGXU4G4yrmirb2oiifEc", "senderPublicKey": "E3rsNDJ7CyVzRYUkm1k4GYLuZYYxzQioRgWedzPYXTSL", "proofs": [ "sbhBUPzZsQZzr4i8WbqZW2pbbj2kyh9uxFbcjrmqpsTh1L4cdhXiZY4PMvUdgqV1JRNb7ofSTbzBZSz9z4k6GQR" ], "script": "base64:AAIFAAAAAAAAAA4IAhIDCgEIEgUKAwEBAQAAAAYAAAAACXZvdGVBc3NldAEAAAAgLTcTgdMkN12f4W9209EPk+8sLPTdia1cSlbofMkBchsAAAAAD25ld1B1cnBvc2VQcmljZQAAAAACVAvkAAAAAAAMdm90ZUR1cmF0aW9uCQAAaAAAAAIAAAAAAAAAAAcAAAAAAAAABaAAAAAADW5ld1B1cnBvc2VLZXkCAAAAB3B1cnBvc2UAAAAADHB1cnBvc2VJZEtleQIAAAAJcHVycG9zZUlkAQAAAAtpc1BheW1lbnRPawAAAAEAAAABaQQAAAARYWNjZXB0YWJsZUFzc2V0SWQFAAAACXZvdGVBc3NldAMJAAAAAAAAAgkAAZAAAAABCAUAAAABaQAAAAhwYXltZW50cwAAAAAAAAAAAAkAAAIAAAABAgAAABRQYXltZW50IG5vdCBhdHRhY2hlZAQAAAABcAkAAZEAAAACCAUAAAABaQAAAAhwYXltZW50cwAAAAAAAAAAAAQAAAAHJG1hdGNoMAgFAAAAAXAAAAAHYXNzZXRJZAMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAK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QAAAANuaWwDCQAAAAAAAAIFAAAABHZvdGUAAAAAAAAAAAIEAAAABWdldE5vCQEAAAALdmFsdWVPckVsc2UAAAACCQAEGgAAAAIFAAAABHRoaXMJAAEsAAAAAgkAASwAAAACCQABLAAAAAIFAAAADW5ld1B1cnBvc2VLZXkCAAAAAV8JAAGkAAAAAQUAAAAJcHVycG9zZUlkAgAAAANfbm8AAAAAAAAAAAAEAAAABXRvdGFsCQAAZAAAAAIFAAAABWdldE5vBQAAAAZhbW91bnQJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIJAAEsAAAAAgkAASwAAAACCQABLAAAAAIFAAAADW5ld1B1cnBvc2VLZXkCAAAAAV8JAAGkAAAAAQUAAAAJcHVycG9zZUlkAgAAAANfbm8FAAAABXRvdGFsBQAAAANuaWwJAAACAAAAAQIAAAAXbm90aGluZyB0byBkbyBteSBmcmllbmQAAAAAGh23aw==", "height": 2279045, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 2D6qNz6SxcHoQiURM9wU6ie8gPmT3GwkLoTxsh2XFpQr Next: 4wRYV1nWNXdQKoaakko3YvfhTT7tyrDRoiMhrsYatDVz Diff:
OldNewDifferences
5050 }
5151
5252
53+
54+@Callable(i)
55+func vote4EnnoDAO (purposeId,vote,votePower) = {
56+ let getDuration = valueOrErrorMessage(getString(this, (((newPurposeKey + "_") + toString(purposeId)) + "_duration")), "purpose not found")
57+ let duration = split(getDuration, "_")
58+ let startHeight = valueOrElse(parseInt(duration[0]), 0)
59+ let endHeight = valueOrElse(parseInt(duration[1]), 0)
60+ if (if ((startHeight > height))
61+ then true
62+ else (height > endHeight))
63+ then throw(("voting period is over for purpose: " + toString(purposeId)))
64+ else if (if ((0 >= vote))
65+ then true
66+ else (vote > 2))
67+ then throw("vote must be yes or no")
68+ else {
69+ let amount = i.payments[0].amount
70+ let lockTill = (height + voteDuration)
71+ if (if ((0 >= amount))
72+ then true
73+ else (i.payments[0].assetId != voteAsset))
74+ then throw("invalid token attached")
75+ else if ((vote == 1))
76+ then {
77+ let getYes = valueOrElse(getInteger(this, (((newPurposeKey + "_") + toString(purposeId)) + "_yes")), 0)
78+ let total = (getYes + amount)
79+[IntegerEntry((((newPurposeKey + "_") + toString(purposeId)) + "_yes"), total)]
80+ }
81+ else if ((vote == 2))
82+ then {
83+ let getNo = valueOrElse(getInteger(this, (((newPurposeKey + "_") + toString(purposeId)) + "_no")), 0)
84+ let total = (getNo + amount)
85+[IntegerEntry((((newPurposeKey + "_") + toString(purposeId)) + "_no"), total)]
86+ }
87+ else throw("nothing to do my friend")
88+ }
89+ }
90+
91+
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let voteAsset = base58'43W4FcqA1rEpSmUGHoGiXvpSLfhadws9LS5j3SJsKxxS'
55
66 let newPurposePrice = 10000000000
77
88 let voteDuration = (7 * 1440)
99
1010 let newPurposeKey = "purpose"
1111
1212 let purposeIdKey = "purposeId"
1313
1414 func isPaymentOk (i) = {
1515 let acceptableAssetId = voteAsset
1616 if ((size(i.payments) == 0))
1717 then throw("Payment not attached")
1818 else {
1919 let p = i.payments[0]
2020 match p.assetId {
2121 case assetId: ByteVector =>
2222 if ((assetId == acceptableAssetId))
2323 then (p.amount == newPurposePrice)
2424 else false
2525 case _ =>
2626 throw("Wrong payment asset")
2727 }
2828 }
2929 }
3030
3131
3232 @Callable(i)
3333 func newPurpose (purpose) = {
3434 let stringSize = size(toBytes(purpose))
3535 let currentKey = toBase58String(i.caller.bytes)
3636 let purposeId = valueOrElse(getInteger(this, purposeIdKey), 1)
3737 if (if ((stringSize > 200))
3838 then true
3939 else (10 > stringSize))
4040 then throw("Purpose text cannot be more than 200")
4141 else if (!(isPaymentOk(i)))
4242 then throw(("you have to pay " + toString(newPurposePrice)))
4343 else {
4444 let startHeight = height
4545 let endHeight = (height + voteDuration)
4646 let text = toBase64String(toBytes(purpose))
4747 let id = (purposeId + 1)
4848 [StringEntry(((newPurposeKey + "_") + toString(id)), text), IntegerEntry(purposeIdKey, id), StringEntry((((newPurposeKey + "_") + toString(id)) + "_duration"), ((toString(startHeight) + "_") + toString(endHeight))), StringEntry((((newPurposeKey + "_") + toString(id)) + "_owner"), currentKey)]
4949 }
5050 }
5151
5252
53+
54+@Callable(i)
55+func vote4EnnoDAO (purposeId,vote,votePower) = {
56+ let getDuration = valueOrErrorMessage(getString(this, (((newPurposeKey + "_") + toString(purposeId)) + "_duration")), "purpose not found")
57+ let duration = split(getDuration, "_")
58+ let startHeight = valueOrElse(parseInt(duration[0]), 0)
59+ let endHeight = valueOrElse(parseInt(duration[1]), 0)
60+ if (if ((startHeight > height))
61+ then true
62+ else (height > endHeight))
63+ then throw(("voting period is over for purpose: " + toString(purposeId)))
64+ else if (if ((0 >= vote))
65+ then true
66+ else (vote > 2))
67+ then throw("vote must be yes or no")
68+ else {
69+ let amount = i.payments[0].amount
70+ let lockTill = (height + voteDuration)
71+ if (if ((0 >= amount))
72+ then true
73+ else (i.payments[0].assetId != voteAsset))
74+ then throw("invalid token attached")
75+ else if ((vote == 1))
76+ then {
77+ let getYes = valueOrElse(getInteger(this, (((newPurposeKey + "_") + toString(purposeId)) + "_yes")), 0)
78+ let total = (getYes + amount)
79+[IntegerEntry((((newPurposeKey + "_") + toString(purposeId)) + "_yes"), total)]
80+ }
81+ else if ((vote == 2))
82+ then {
83+ let getNo = valueOrElse(getInteger(this, (((newPurposeKey + "_") + toString(purposeId)) + "_no")), 0)
84+ let total = (getNo + amount)
85+[IntegerEntry((((newPurposeKey + "_") + toString(purposeId)) + "_no"), total)]
86+ }
87+ else throw("nothing to do my friend")
88+ }
89+ }
90+
91+

github/deemru/w8io/169f3d6 
26.55 ms