tx · J1nDFoPMsnY56ZbtcBHMHYWsFDRsYQQYoX2iT93iZ9SW

3Mu2Rf9Lq4qKYnDt7zKJ4fa8tXvaAQVwJVE:  -0.01000000 Waves

2023.07.26 16:50 [2682911] smart account 3Mu2Rf9Lq4qKYnDt7zKJ4fa8tXvaAQVwJVE > SELF 0.00000000 Waves

{ "type": 13, "id": "J1nDFoPMsnY56ZbtcBHMHYWsFDRsYQQYoX2iT93iZ9SW", "fee": 1000000, "feeAssetId": null, "timestamp": 1690379489297, "version": 2, "chainId": 84, "sender": "3Mu2Rf9Lq4qKYnDt7zKJ4fa8tXvaAQVwJVE", "senderPublicKey": "5ijzyZ48KXTRHdsMMmAhd26WNdWJeMvGb7uh9jZHBkqb", "proofs": [ "2zrs2kSABWoi1b87XRvZQ5mravg4ijPdnnhTBxz6ecAjgwJ9fuCukn3mTurTw8ucnmWrs1kBvYSmoNtPKBsFMvHq" ], "script": "base64:BgIGCAISABIAAQAIa2Fzc2V0SWQCB0Fzc2V0SUQCAWkBDXRva2VuSXNzdWFuY2UABARuYW1lAgpCZWJyYVRva2VuBA5sZW5kZXNjcmlwdGlvbgIPQmVicmEgYnkgS3JpbmdlBAhxdWFudGl0eQCgjQYECGRlY2ltYWxzAAMECmlzc3VlQmVicmEJAMIIBQUEbmFtZQUObGVuZGVzY3JpcHRpb24FCHF1YW50aXR5BQhkZWNpbWFscwYEB2Fzc2V0SWQJALgIAQUKaXNzdWVCZWJyYQQJa25ld1Rva2VuAgVUb2tlbgQLZ2V0TmV3VG9rZW4JARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkAnQgCBQR0aGlzBQlrbmV3VG9rZW4CGUJlYnJhVG9rZW4gaXMgbm90IGRlZmluZWQJAMwIAgUKaXNzdWVCZWJyYQkAzAgCCQELQmluYXJ5RW50cnkCBQhrYXNzZXRJZAUHYXNzZXRJZAkAzAgCCQELU3RyaW5nRW50cnkCBQlrbmV3VG9rZW4IBQppc3N1ZUJlYnJhBG5hbWUFA25pbAFpAQtzZW5kZXJUb2tlbgAEB2Fzc2V0SUQJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkBEUBleHRyTmF0aXZlKDEwNTIpAgUEdGhpcwUIa2Fzc2V0SWQCBWVycm9yCQDMCAIJAQ5TY3JpcHRUcmFuc2ZlcgMFBHRoaXMAAgUEdW5pdAkAzAgCCQEOU2NyaXB0VHJhbnNmZXIDCAUBaQZjYWxsZXIAFAUHYXNzZXRJRAUDbmlsAGSHpyA=", "height": 2682911, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 7mZrmwvKersWKeDmFSf7bYaKxS6iWvcC5JBHqyV7HKMZ Next: 3X46o7KpMuzWry1acndFRCVunT5aRx3bCxVMWM1S1FLL Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let SEP = "__"
5-
6-func blockHeightError () = throw("The block's height is too big for this proposal")
7-
8-
9-func alreadyVoteError () = throw("You have already voted")
10-
11-
12-func noVoteError () = throw("You have not already voted")
13-
14-
15-func gwxContractAddress () = makeString(["%s", "gwxContractAddress"], SEP)
16-
17-
18-func keyCurrentIndex () = makeString(["%s", "currentIndex"], SEP)
19-
20-
21-func keyProposalInfo (number) = makeString(["%s%d", "proposalInfo", toString(number)], SEP)
22-
23-
24-func keyProposalDescription (number) = makeString(["%s%d", "proposalDescription", toString(number)], SEP)
25-
26-
27-func keyUserVoteOnProposal (number,user) = makeString(["%s%d%s", "userVoteOnProposal", toString(number), user], SEP)
28-
29-
30-func keyManagerPublicKey () = "%s__managerPublicKey"
31-
32-
33-func keyManagerVaultAddress () = "%s__managerVaultAddress"
34-
35-
36-func getCurrentIndex () = getIntegerValue(this, keyCurrentIndex())
37-
38-
39-func getManagerVaultAddressOrThis () = match getString(keyManagerVaultAddress()) {
40- case s: String =>
41- addressFromStringValue(s)
42- case _ =>
43- this
44-}
45-
46-
47-func formatProposalInfo (name,end,quorumNumber,positiveVotes,negativeVotes) = makeString(["%d%d%d%d%d", name, end, quorumNumber, positiveVotes, negativeVotes], SEP)
48-
49-
50-func formatUserVoteOnProposal (vote,gwxNumber) = makeString(["%d%d", vote, gwxNumber], SEP)
51-
52-
53-func asInt (val) = match val {
54- case valInt: Int =>
55- valInt
56- case _ =>
57- throw("fail to cast into Int")
58-}
59-
60-
61-func managerPublicKeyOrUnit () = {
62- let managerVaultAddress = getManagerVaultAddressOrThis()
63- match getString(managerVaultAddress, keyManagerPublicKey()) {
64- case s: String =>
65- fromBase58String(s)
66- case _: Unit =>
67- unit
68- case _ =>
69- throw("Match error")
70- }
71- }
72-
73-
74-func isManager (i) = match managerPublicKeyOrUnit() {
75- case pk: ByteVector =>
76- (i.callerPublicKey == pk)
77- case _: Unit =>
78- (i.caller == this)
79- case _ =>
80- throw("Match error")
81-}
82-
83-
84-func mustManager (i) = if (isManager(i))
85- then true
86- else throw("permission denied")
87-
4+let kassetId = "AssetID"
885
896 @Callable(i)
90-func startNewVote (name,description,expirationHeight,quorumNumber) = {
91- let theIndex = 0
92-[IntegerEntry(keyCurrentIndex(), (theIndex + 1)), StringEntry(keyProposalInfo(theIndex), formatProposalInfo(name, toString((lastBlock.height + expirationHeight)), toString(quorumNumber), "0", "0")), StringEntry(keyProposalDescription(theIndex), description)]
7+func tokenIssuance () = {
8+ let name = "BebraToken"
9+ let lendescription = "Bebra by Kringe"
10+ let quantity = 100000
11+ let decimals = 3
12+ let issueBebra = Issue(name, lendescription, quantity, decimals, true)
13+ let assetId = calculateAssetId(issueBebra)
14+ let knewToken = "Token"
15+ let getNewToken = valueOrErrorMessage(getString(this, knewToken), "BebraToken is not defined")
16+[issueBebra, BinaryEntry(kassetId, assetId), StringEntry(knewToken, issueBebra.name)]
9317 }
9418
9519
9620
9721 @Callable(i)
98-func voteFor (proposalIndex,choice) = {
99- let EMPTY = "EMPTY"
100- let voteInfo = valueOrElse(getString(this, keyProposalInfo(proposalIndex)), EMPTY)
101- let voteInfoArray = split(voteInfo, SEP)
102- let userVoteInfo = valueOrElse(getString(this, keyUserVoteOnProposal(proposalIndex, toString(i.caller))), EMPTY)
103- let checks = [if ((voteInfo != EMPTY))
104- then true
105- else throw("No such vote"), if ((value(parseInt(voteInfoArray[2])) > lastBlock.height))
106- then true
107- else blockHeightError(), if ((userVoteInfo == EMPTY))
108- then true
109- else alreadyVoteError()]
110- if ((checks == checks))
111- then {
112- let gwxNumber = asInt(invoke(addressFromStringValue(getStringValue(gwxContractAddress())), "getUserGwxAmountAtHeightREADONLY", [toString(i.caller), value(parseInt(voteInfoArray[2]))], nil))
113- let $t035164552 = if (choice)
114- then {
115- let action1 = StringEntry(keyProposalInfo(proposalIndex), formatProposalInfo(voteInfoArray[1], voteInfoArray[2], voteInfoArray[3], toString((value(parseInt(voteInfoArray[4])) + gwxNumber)), voteInfoArray[5]))
116- let action2 = StringEntry(keyUserVoteOnProposal(proposalIndex, toString(i.caller)), formatUserVoteOnProposal("1", toString(gwxNumber)))
117- $Tuple2(action1, action2)
118- }
119- else {
120- let action1 = StringEntry(keyProposalInfo(proposalIndex), formatProposalInfo(voteInfoArray[1], voteInfoArray[2], voteInfoArray[3], voteInfoArray[4], toString((value(parseInt(voteInfoArray[5])) + gwxNumber))))
121- let action2 = StringEntry(keyUserVoteOnProposal(proposalIndex, toString(i.caller)), formatUserVoteOnProposal("0", toString(gwxNumber)))
122- $Tuple2(action1, action2)
123- }
124- let action1 = $t035164552._1
125- let action2 = $t035164552._2
126-[action1, action2]
127- }
128- else throw("Strict value is not equal to itself.")
129- }
130-
131-
132-
133-@Callable(i)
134-func deleteVote (proposalIndex) = {
135- let EMPTY = "EMPTY"
136- let voteInfo = valueOrElse(getString(this, keyProposalInfo(proposalIndex)), EMPTY)
137- let voteInfoArray = split(voteInfo, SEP)
138- let userVoteInfo = valueOrElse(getString(this, keyUserVoteOnProposal(proposalIndex, toString(i.caller))), EMPTY)
139- let userVoteInfoArray = split(userVoteInfo, SEP)
140- let checks = [if ((voteInfo != EMPTY))
141- then true
142- else throw("No such vote"), if ((value(parseInt(voteInfoArray[2])) > lastBlock.height))
143- then true
144- else blockHeightError(), if ((userVoteInfo != EMPTY))
145- then true
146- else noVoteError()]
147- if ((checks == checks))
148- then {
149- let action = if ((userVoteInfoArray[1] == "1"))
150- then StringEntry(keyProposalInfo(proposalIndex), formatProposalInfo(voteInfoArray[1], voteInfoArray[2], voteInfoArray[3], toString((value(parseInt(voteInfoArray[4])) - value(parseInt(userVoteInfoArray[2])))), voteInfoArray[5]))
151- else StringEntry(keyProposalInfo(proposalIndex), formatProposalInfo(voteInfoArray[1], voteInfoArray[2], voteInfoArray[3], voteInfoArray[4], toString((value(parseInt(voteInfoArray[5])) - value(parseInt(userVoteInfoArray[2]))))))
152-[action, DeleteEntry(keyUserVoteOnProposal(proposalIndex, toString(i.caller)))]
153- }
154- else throw("Strict value is not equal to itself.")
155- }
156-
157-
158-
159-@Callable(i)
160-func changeVote (proposalIndex,choice) = {
161- let EMPTY = "EMPTY"
162- let voteInfo = valueOrElse(getString(this, keyProposalInfo(proposalIndex)), EMPTY)
163- let voteInfoArray = split(voteInfo, SEP)
164- let userVoteInfo = valueOrElse(getString(this, keyUserVoteOnProposal(proposalIndex, toString(i.caller))), EMPTY)
165- let userVoteInfoArray = split(userVoteInfo, SEP)
166- let checks = [if ((voteInfo != EMPTY))
167- then true
168- else throw("No such vote"), if ((value(parseInt(voteInfoArray[2])) > lastBlock.height))
169- then true
170- else blockHeightError(), if ((userVoteInfo != EMPTY))
171- then true
172- else noVoteError()]
173- if ((checks == checks))
174- then {
175- let gwxNumber = asInt(invoke(addressFromStringValue(getStringValue(gwxContractAddress())), "getUserGwxAmountAtHeightREADONLY", [toString(i.caller), value(parseInt(voteInfoArray[3]))], nil))
176- let $t067207059 = if (choice)
177- then {
178- let forNumber = gwxNumber
179- let againstNumber = 0
180- let choiceInteger = 1
181- $Tuple3(forNumber, againstNumber, choiceInteger)
182- }
183- else {
184- let forNumber = 0
185- let againstNumber = gwxNumber
186- let choiceInteger = 0
187- $Tuple3(forNumber, againstNumber, choiceInteger)
188- }
189- let userPowerFor = $t067207059._1
190- let userPowerAgainst = $t067207059._2
191- let choiceInt = $t067207059._3
192- let action = if ((userVoteInfoArray[1] == "1"))
193- then StringEntry(keyProposalInfo(proposalIndex), formatProposalInfo(voteInfoArray[1], voteInfoArray[2], voteInfoArray[3], toString(((value(parseInt(voteInfoArray[4])) - value(parseInt(userVoteInfoArray[2]))) + userPowerFor)), toString((value(parseInt(voteInfoArray[5])) + userPowerAgainst))))
194- else StringEntry(keyProposalInfo(proposalIndex), formatProposalInfo(voteInfoArray[1], voteInfoArray[2], voteInfoArray[3], toString((value(parseInt(voteInfoArray[4])) + userPowerFor)), toString(((value(parseInt(voteInfoArray[5])) - value(parseInt(userVoteInfoArray[2]))) + userPowerAgainst))))
195-[action, StringEntry(keyUserVoteOnProposal(proposalIndex, toString(i.caller)), formatUserVoteOnProposal(toString(choiceInt), toString(gwxNumber)))]
196- }
197- else throw("Strict value is not equal to itself.")
198- }
199-
200-
201-
202-@Callable(i)
203-func getResultREADONLY (proposalIndex) = {
204- let EMPTY = "EMPTY"
205- let voteInfo = valueOrElse(getString(this, keyProposalInfo(proposalIndex)), EMPTY)
206- let voteInfoArray = split(voteInfo, SEP)
207- let checks = [if ((voteInfo != EMPTY))
208- then true
209- else throw("No such vote")]
210- if ((checks == checks))
211- then {
212- let quorumNumber = voteInfoArray[3]
213- let positiveVotes = voteInfoArray[4]
214- let negativeVotes = voteInfoArray[5]
215- $Tuple2(nil, [positiveVotes, negativeVotes, quorumNumber])
216- }
217- else throw("Strict value is not equal to itself.")
22+func senderToken () = {
23+ let assetID = valueOrErrorMessage(getBinaryValue(this, kassetId), "error")
24+[ScriptTransfer(this, 2, unit), ScriptTransfer(i.caller, 20, assetID)]
21825 }
21926
22027

github/deemru/w8io/fabc49c 
29.10 ms