tx · 28foWu6uX7FoP1gvq6VwYKAJ78d4YrAk86Hxg5aHDbqU

3N9D8brsPwA8d2SWKxCKoG15TfAqjtp749H:  -0.01400000 Waves

2020.09.16 13:44 [1179724] smart account 3N9D8brsPwA8d2SWKxCKoG15TfAqjtp749H > SELF 0.00000000 Waves

{ "type": 13, "id": "28foWu6uX7FoP1gvq6VwYKAJ78d4YrAk86Hxg5aHDbqU", "fee": 1400000, "feeAssetId": null, "timestamp": 1600253077054, "version": 2, "chainId": 84, "sender": "3N9D8brsPwA8d2SWKxCKoG15TfAqjtp749H", "senderPublicKey": "FpA31WAx86gMxdfoFSRBf8HbjDPaHre9SnjfE1rcjTSA", "proofs": [ "4ZENv2D8gSxrQdf24EFXPs79FKA1dGV6ESaGDSSwJmYiHDjnbjDcfPr75GaWNEZLhEAbnk9KrtUSUxxkRjDURGup" ], "script": "base64:AAIEAAAAAAAAAAkIAhIDCgEIEgAAAAADAAAAAAZOU0JUaWQJAAJZAAAAAQkBAAAAE3ZhbHVlT3JFcnJvck1lc3NhZ2UAAAACCQAEHQAAAAIFAAAABHRoaXMCAAAABk5TQlRpZAIAAAAgTlNCVGlkIGlzIG5vdCBzcGVjaWZpZWQgaW4gc3RhdGUAAAAACWhlaWdodEVuZAkBAAAAE3ZhbHVlT3JFcnJvck1lc3NhZ2UAAAACCQAEGgAAAAIFAAAABHRoaXMCAAAACmhlaWdodF9lbmQCAAAAJGhlaWdodF9lbmQgaXMgbm90IHNwZWNpZmllZCBpbiBzdGF0ZQEAAAAOa2V5VXNlckJhbGFuY2UAAAABAAAACHVzZXJBZGRyCQAEuQAAAAIJAARMAAAAAgIAAAAHYmFsYW5jZQkABEwAAAACCQAEJQAAAAEFAAAACHVzZXJBZGRyBQAAAANuaWwCAAAAAV8AAAACAAAACmNvbnRleHRPYmoBAAAACGNhc3RWb3RlAAAAAQAAAAR2b3RlBAAAAAh2b2l0ZUtleQkABLkAAAACCQAETAAAAAICAAAABXZvaXRlCQAETAAAAAIFAAAAB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AOa2V5VXNlckJhbGFuY2UAAAABCAUAAAAKY29udGV4dE9iagAAAAZjYWxsZXIDCQAAZgAAAAIFAAAACWhlaWdodEVuZAUAAAAGaGVpZ2h0CQAAAgAAAAECAAAAD3ZvdGUgaW4gcHJvY2VzcwQAAAANY2FsbGVyQmFsYW5jZQkBAAAAC3ZhbHVlT3JFbHNlAAAAAgkABBoAAAACBQAAAAR0aGlzBQAAAA51c2VyQmFsYW5jZUtleQAAAAAAAAAAAAMJAABnAAAAAgAAAAAAAAAAAAUAAAANY2FsbGVyQmFsYW5jZQkAAAIAAAABAgAAABBiYWxhbmNlIGlzIGVtcHR5CQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAApjb250ZXh0T2JqAAAABmNhbGxlcgUAAAANY2FsbGVyQmFsYW5jZQUAAAAGTlNCVGlkCQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACBQAAAA51c2VyQmFsYW5jZUtleQAAAAAAAAAAAAUAAAADbmlsAAAAAFzqsMs=", "height": 1179724, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 7XkBHyiRnVhtGybv7sTvBbdykMC4njL1ZBaYUta5KHQB Next: 2eCkQw2TszTB2JHCvoNW4Ewc4q5kbeZw6kykvMKMSwWE Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 4 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let NSBTid = fromBase58String(getStringValue(this, "NSBTid"))
4+let NSBTid = fromBase58String(valueOrErrorMessage(getString(this, "NSBTid"), "NSBTid is not specified in state"))
55
6-let heightEnd = getIntegerValue(this, "height_end")
6+let heightEnd = valueOrErrorMessage(getInteger(this, "height_end"), "height_end is not specified in state")
7+
8+func keyUserBalance (userAddr) = makeString(["balance", toString(userAddr)], "_")
9+
710
811 @Callable(contextObj)
912 func castVote (vote) = {
1013 let voiteKey = makeString(["voite", vote], "_")
11- let userBalanceKey = makeString(["balance", toString(contextObj.caller)], "_")
14+ let userBalanceKey = keyUserBalance(contextObj.caller)
1215 let payment = value(contextObj.payments[0])
1316 let assetIdReceived = payment.assetId
1417 let tokenReceiveAmount = payment.amount
15- let voteNumberThis = match getInteger(this, voiteKey) {
16- case voteValue: Int =>
17- voteValue
18- case voteValue: Unit =>
19- 0
20- case _ =>
21- throw("Match error")
22- }
23- let contractUserBalance = match getInteger(this, userBalanceKey) {
24- case balance: Int =>
25- balance
26- case balance: Unit =>
27- 0
28- case _ =>
29- throw("Match error")
30- }
18+ let voteNumberThis = valueOrElse(getInteger(this, voiteKey), 0)
19+ let contractUserBalance = valueOrElse(getInteger(this, userBalanceKey), 0)
3120 if ((assetIdReceived != NSBTid))
3221 then throw("incorrect assets")
3322 else if ((height >= heightEnd))
3423 then throw("vote finished")
35- else [IntegerEntry(voiteKey, (voteNumberThis + tokenReceiveAmount)), IntegerEntry(userBalanceKey, tokenReceiveAmount)]
24+ else [IntegerEntry(voiteKey, (voteNumberThis + tokenReceiveAmount)), IntegerEntry(userBalanceKey, (contractUserBalance + tokenReceiveAmount))]
3625 }
3726
3827
3928
4029 @Callable(contextObj)
4130 func withdraw () = {
42- let userBalanceKey = makeString(["balance", toString(contextObj.caller)], "_")
31+ let userBalanceKey = keyUserBalance(contextObj.caller)
4332 if ((heightEnd > height))
4433 then throw("vote in process")
4534 else {
46- let callerBalance = getIntegerValue(this, userBalanceKey)
47-[ScriptTransfer(contextObj.caller, callerBalance, NSBTid), IntegerEntry(userBalanceKey, 0)]
35+ let callerBalance = valueOrElse(getInteger(this, userBalanceKey), 0)
36+ if ((0 >= callerBalance))
37+ then throw("balance is empty")
38+ else [ScriptTransfer(contextObj.caller, callerBalance, NSBTid), IntegerEntry(userBalanceKey, 0)]
4839 }
4940 }
5041
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 4 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let NSBTid = fromBase58String(getStringValue(this, "NSBTid"))
4+let NSBTid = fromBase58String(valueOrErrorMessage(getString(this, "NSBTid"), "NSBTid is not specified in state"))
55
6-let heightEnd = getIntegerValue(this, "height_end")
6+let heightEnd = valueOrErrorMessage(getInteger(this, "height_end"), "height_end is not specified in state")
7+
8+func keyUserBalance (userAddr) = makeString(["balance", toString(userAddr)], "_")
9+
710
811 @Callable(contextObj)
912 func castVote (vote) = {
1013 let voiteKey = makeString(["voite", vote], "_")
11- let userBalanceKey = makeString(["balance", toString(contextObj.caller)], "_")
14+ let userBalanceKey = keyUserBalance(contextObj.caller)
1215 let payment = value(contextObj.payments[0])
1316 let assetIdReceived = payment.assetId
1417 let tokenReceiveAmount = payment.amount
15- let voteNumberThis = match getInteger(this, voiteKey) {
16- case voteValue: Int =>
17- voteValue
18- case voteValue: Unit =>
19- 0
20- case _ =>
21- throw("Match error")
22- }
23- let contractUserBalance = match getInteger(this, userBalanceKey) {
24- case balance: Int =>
25- balance
26- case balance: Unit =>
27- 0
28- case _ =>
29- throw("Match error")
30- }
18+ let voteNumberThis = valueOrElse(getInteger(this, voiteKey), 0)
19+ let contractUserBalance = valueOrElse(getInteger(this, userBalanceKey), 0)
3120 if ((assetIdReceived != NSBTid))
3221 then throw("incorrect assets")
3322 else if ((height >= heightEnd))
3423 then throw("vote finished")
35- else [IntegerEntry(voiteKey, (voteNumberThis + tokenReceiveAmount)), IntegerEntry(userBalanceKey, tokenReceiveAmount)]
24+ else [IntegerEntry(voiteKey, (voteNumberThis + tokenReceiveAmount)), IntegerEntry(userBalanceKey, (contractUserBalance + tokenReceiveAmount))]
3625 }
3726
3827
3928
4029 @Callable(contextObj)
4130 func withdraw () = {
42- let userBalanceKey = makeString(["balance", toString(contextObj.caller)], "_")
31+ let userBalanceKey = keyUserBalance(contextObj.caller)
4332 if ((heightEnd > height))
4433 then throw("vote in process")
4534 else {
46- let callerBalance = getIntegerValue(this, userBalanceKey)
47-[ScriptTransfer(contextObj.caller, callerBalance, NSBTid), IntegerEntry(userBalanceKey, 0)]
35+ let callerBalance = valueOrElse(getInteger(this, userBalanceKey), 0)
36+ if ((0 >= callerBalance))
37+ then throw("balance is empty")
38+ else [ScriptTransfer(contextObj.caller, callerBalance, NSBTid), IntegerEntry(userBalanceKey, 0)]
4839 }
4940 }
5041
5142

github/deemru/w8io/169f3d6 
49.65 ms