tx · 8NgdJwRuBChSvtSB5KtuktQUr9ktezaxgYWYmkUFKQam

3MsEYrugWRGMvdKBKChVCjg2qoKea8Ko9vY:  -0.01300000 Waves

2022.07.06 21:35 [2128193] smart account 3MsEYrugWRGMvdKBKChVCjg2qoKea8Ko9vY > SELF 0.00000000 Waves

{ "type": 13, "id": "8NgdJwRuBChSvtSB5KtuktQUr9ktezaxgYWYmkUFKQam", "fee": 1300000, "feeAssetId": null, "timestamp": 1657132547881, "version": 2, "chainId": 84, "sender": "3MsEYrugWRGMvdKBKChVCjg2qoKea8Ko9vY", "senderPublicKey": "A8DvbFTEjyHFvpK57CmHu6QKczzymTB5sgqq8xxjNsXG", "proofs": [ "5XPWQA9bxBpuyfYWCrTW3wECJzhUiw7jAQGS1MZpnuneYiTTvefpkHxz1jvxtr1jGWADbSZVUTtwxnBwU4eKptEQ" ], "script": null, "height": 2128193, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 64P8Ctk9QtYDPcQc4hCiVLv29KjqEUXkkGTkBGcpbnr2 Next: CSBoRczciNow8QSq5YFuNwKweECUXb7joYJX41uGJvky Full:
OldNewDifferences
1-{-# STDLIB_VERSION 5 #-}
2-{-# SCRIPT_TYPE ACCOUNT #-}
3-{-# CONTENT_TYPE DAPP #-}
4-let SEP = "__"
5-
6-let MULT6 = 1000000
7-
8-let MULT8 = 100000000
9-
10-let WAVESIDSTR = "WAVES"
11-
12-let WAVESID = fromBase58String(WAVESIDSTR)
13-
14-func getIntOrFail (key) = valueOrErrorMessage(getInteger(this, key), (("Mandatory this." + key) + " is not defined"))
15-
16-
17-func getStrOrElse (key,defaultVal) = valueOrElse(getString(this, key), defaultVal)
18-
19-
20-func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), (("Mandatory this." + key) + " is not defined"))
21-
22-
23-func getAddressOrFail (key) = valueOrErrorMessage(addressFromString(getStringOrFail(this, key)), (("Fail to convert this." + key) + " value into Address"))
24-
25-
26-func validateAddressOrFail (addressStr) = {
27- let address = valueOrErrorMessage(addressFromString(addressStr), ("fail to convert into address " + addressStr))
28- if ((0 > wavesBalance(address).available))
29- then throw()
30- else addressStr
31- }
32-
33-
34-func keyNodeRegistry (address) = ("%s__" + address)
35-
36-
37-func keyNodeRewardsTotals (address) = ("%s%s__totals__" + address)
38-
39-
40-func keyDepositAmount () = "%s%s__cfg__depositAmount"
41-
42-
43-func keyNeutrinoAddressStr () = "%s%s__cfg__neutrinoAddress"
44-
45-
46-func keyMasterNodeAddressStr () = "%s%s__cfg__mainNeutrinoNodeAddress"
47-
48-
49-func keyProtocolPartX6 () = "%s%s__cfg__protocolPartX6"
50-
51-
52-func keyBenificaryPartX6 () = "%s%s__cfg__benificaryPartX6"
53-
54-
55-func keyBeneficiaryAddress () = "%s%s__cfg__beneficiaryAddress"
56-
57-
58-func keyLastUpdateHeight () = "%s__lastUpdatedHeight"
59-
60-
61-func keyScriptUpdateHash () = "%s__scriptUpdateHash"
62-
63-
64-func formatDepositAdd (txIdStr,depositAmount,remainingDepositAmount,status) = makeString(["%s%d%d%d%d%s%d%d", txIdStr, toString(lastBlock.height), toString(lastBlock.timestamp), toString(depositAmount), toString(remainingDepositAmount), status, "0", "0"], SEP)
65-
66-
67-func formatDepositChangeStatus (origS,newStatus) = {
68- let orig = split(origS, SEP)
69- makeString(["%s%d%d%d%d%s%d%d", orig[1], orig[2], orig[3], orig[4], orig[5], newStatus, toString(lastBlock.height), toString(lastBlock.timestamp)], SEP)
70- }
71-
72-
73-func keyRewardHistory (nodeAddress,txId) = makeString(["%s%s%s", "history", toString(nodeAddress), toBase58String(txId)], SEP)
74-
75-
76-func dataRewardHistory (wavesAmountTotal,beneficiaryAmt,protocolAmt,protocolAmtPart1,protocolAmtPart2) = makeString(["%d%d%d%d%d%d%d", toString(lastBlock.height), toString(lastBlock.timestamp), toString(wavesAmountTotal), toString(beneficiaryAmt), toString(protocolAmt), toString(protocolAmtPart1), toString(protocolAmtPart2)], SEP)
77-
78-
79-func RewardHistoryEntry (nodeAddress,txId,minedAmt,beneficiaryAmt,protocolAmt,protocolAmt1,protocolAmt2) = StringEntry(keyRewardHistory(nodeAddress, txId), dataRewardHistory(minedAmt, beneficiaryAmt, protocolAmt, protocolAmt1, protocolAmt2))
80-
81-
82-func dataRewardTotals (minedAmt,beneficiaryAmt,protocolAmt,protocolAmtPart1,protocolAmtPart2) = makeString(["%d%d%d%d%d", toString(minedAmt), toString(beneficiaryAmt), toString(protocolAmt), toString(protocolAmtPart1), toString(protocolAmtPart2)], SEP)
83-
84-
85-func RewardTotalsEntry (miner,minedAmt,beneficiaryAmt,protocolAmt,protocolAmtPart1,protocolAmtPart2) = {
86- let nodeRewardsTotalsKEY = keyNodeRewardsTotals(toString(miner))
87- let nodeRewardsArray = split(getStrOrElse(nodeRewardsTotalsKEY, dataRewardTotals(0, 0, 0, 0, 0)), SEP)
88- let newMinedAmt = (parseIntValue(nodeRewardsArray[1]) + minedAmt)
89- let newBeneficiaryAmt = (parseIntValue(nodeRewardsArray[2]) + beneficiaryAmt)
90- let newProtocolAmt = (parseIntValue(nodeRewardsArray[3]) + protocolAmt)
91- let newProtocolAmtPart1 = (parseIntValue(nodeRewardsArray[4]) + protocolAmtPart1)
92- let newProtocolAmtPart2 = (parseIntValue(nodeRewardsArray[5]) + protocolAmtPart2)
93- StringEntry(nodeRewardsTotalsKEY, dataRewardTotals(newMinedAmt, newBeneficiaryAmt, newProtocolAmt, newProtocolAmtPart1, newProtocolAmtPart2))
94- }
95-
96-
97-@Callable(i)
98-func constructor (depositAmount,neutrinoAddressStr,masterNodeAddressStr,protocolPartX6,benificaryPartX6) = if ((i.caller != this))
99- then throw("permissions denied")
100- else if ((0 > depositAmount))
101- then throw("depositAmount less then zero")
102- else if ((0 > protocolPartX6))
103- then throw("protocolPartX6 less then zero")
104- else if ((0 > benificaryPartX6))
105- then throw("benificaryPartX6 less then zero")
106- else if (((protocolPartX6 + benificaryPartX6) != MULT6))
107- then throw("parts sum must be 1")
108- else [IntegerEntry(keyDepositAmount(), depositAmount), StringEntry(keyNeutrinoAddressStr(), validateAddressOrFail(neutrinoAddressStr)), StringEntry(keyMasterNodeAddressStr(), validateAddressOrFail(masterNodeAddressStr)), IntegerEntry(keyProtocolPartX6(), protocolPartX6), IntegerEntry(keyBenificaryPartX6(), benificaryPartX6)]
109-
110-
111-
112-@Callable(i)
113-func sumbitApplication () = if ((size(i.payments) != 1))
114- then throw("exact 1 payment must be attached")
115- else if ((i.caller != i.originCaller))
116- then throw("dapp to dapp calls are not allowed")
117- else {
118- let pmt = i.payments[0]
119- let deposit = pmt.amount
120- let pmtAssetId = valueOrElse(pmt.assetId, WAVESID)
121- let expectedDepositAmount = getIntOrFail(keyDepositAmount())
122- let txId = toBase58String(i.transactionId)
123- let nodeAddress = toString(i.caller)
124- let nodeRegistryKEY = keyNodeRegistry(nodeAddress)
125- if ((pmtAssetId != WAVESID))
126- then throw("only Waves can be used for deposit")
127- else if ((deposit != expectedDepositAmount))
128- then throw((("exactly " + toString(expectedDepositAmount)) + " Wavelets are expected"))
129- else if ((getStrOrElse(nodeRegistryKEY, "") != ""))
130- then throw("your node already registered")
131- else [StringEntry(nodeRegistryKEY, formatDepositAdd(txId, deposit, deposit, "PENDING"))]
132- }
133-
134-
135-
136-@Callable(i)
137-func distibuteMinerReward (benificaryAddressStr) = if ((size(i.payments) != 1))
138- then throw("exact 1 payment must be attached")
139- else if ((i.caller != i.originCaller))
140- then throw("dapp to dapp calls are not allowed")
141- else {
142- let pmt = i.payments[0]
143- let pmtAssetId = valueOrElse(pmt.assetId, WAVESID)
144- let feeAmt = i.fee
145- let feeAssetId = valueOrElse(i.feeAssetId, WAVESID)
146- let callReward = (feeAmt * 2)
147- let minedAmt = (pmt.amount - callReward)
148- if ((pmtAssetId != WAVESID))
149- then throw("only Waves can be used in payment")
150- else if ((feeAssetId != WAVESID))
151- then throw("only Waves can be used in fees")
152- else if ((feeAmt != ((5 * MULT8) / 1000)))
153- then throw("fee amount couldn't exceed 0.005")
154- else {
155- let neutrinoAddress = getAddressOrFail(keyNeutrinoAddressStr())
156- let masterNodeAddress = getAddressOrFail(keyMasterNodeAddressStr())
157- let minerAddress = i.caller
158- let minerScriptHash = scriptHash(minerAddress)
159- let beneficaryFromParam = addressFromStringValue(benificaryAddressStr)
160- let beneficcaryFromMinerState = addressFromStringValue(getStringOrFail(minerAddress, keyBeneficiaryAddress()))
161- let $t075137705 = if ((minerScriptHash == unit))
162- then $Tuple2(beneficaryFromParam, beneficaryFromParam)
163- else $Tuple2(beneficcaryFromMinerState, beneficaryFromParam)
164- let benificaryAddress = $t075137705._1
165- let callRewardReceiver = $t075137705._2
166- let protocolPart = getIntOrFail(keyProtocolPartX6())
167- let benificaryPart = getIntOrFail(keyBenificaryPartX6())
168- let availableBalance = (wavesBalance(minerAddress).available - feeAmt)
169- if ((availableBalance != 0))
170- then throw((("all " + toString(availableBalance)) + " Wavelets from the Node balance must be attached into the payment"))
171- else {
172- let benificaryAmt = fraction(minedAmt, benificaryPart, MULT6)
173- let protocolAmt = (minedAmt - benificaryAmt)
174- let protocolAmt1 = (protocolAmt / 2)
175- let protocolAmt2 = (protocolAmt - protocolAmt1)
176-[ScriptTransfer(benificaryAddress, benificaryAmt, unit), ScriptTransfer(neutrinoAddress, protocolAmt1, unit), ScriptTransfer(masterNodeAddress, protocolAmt2, unit), ScriptTransfer(callRewardReceiver, callReward, unit), RewardHistoryEntry(minerAddress, i.transactionId, minedAmt, benificaryAmt, protocolAmt, protocolAmt1, protocolAmt2), RewardTotalsEntry(minerAddress, minedAmt, benificaryAmt, protocolAmt, protocolAmt1, protocolAmt2)]
177- }
178- }
179- }
180-
181-
182-
183-@Callable(i)
184-func validateAndApproveLeasings (nListS) = {
185- let nIdxs = [0, 1, 2, 3, 4, 5, 6, 7]
186- let nList = split(nListS, SEP)
187- let expectedCount = size(nIdxs)
188- let neutrinoAddress = getAddressOrFail(keyNeutrinoAddressStr())
189- if ((i.caller != neutrinoAddress))
190- then throw("validateAndApproveLeasings not authorized")
191- else if (((size(nList) % 2) != 0))
192- then throw("Only even number of nodes is allowed")
193- else if ((size(nList) != expectedCount))
194- then throw((("Only " + toString(expectedCount)) + " node's address cab be passed"))
195- else {
196- func forEachNodeChangeStatus (acc,i) = {
197- let nodeAddr = nList[i]
198- let nodeRegistryKEY = keyNodeRegistry(nodeAddr)
199- let nodeDataOpt = getString(this, nodeRegistryKEY)
200- if (!(isDefined(nodeDataOpt)))
201- then throw(("invalid Node in list " + nodeAddr))
202- else {
203- let nodeData = split(value(nodeDataOpt), SEP)
204- let nodeStatus = nodeData[6]
205- if (if ((size(nodeData) >= 9))
206- then (nodeStatus != "PENDING")
207- else false)
208- then throw(((("node " + nodeAddr) + " already has a final status ") + nodeStatus))
209- else (acc :+ StringEntry(nodeRegistryKEY, formatDepositChangeStatus(value(nodeDataOpt), "APPROVED")))
210- }
211- }
212-
213- let approvedNodesData = {
214- let $l = nIdxs
215- let $s = size($l)
216- let $acc0 = nil
217- func $f0_1 ($a,$i) = if (($i >= $s))
218- then $a
219- else forEachNodeChangeStatus($a, $l[$i])
220-
221- func $f0_2 ($a,$i) = if (($i >= $s))
222- then $a
223- else throw("List size exceeds 8")
224-
225- $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8)
226- }
227- $Tuple2(approvedNodesData, nil)
228- }
229- }
230-
231-
232-
233-@Callable(i)
234-func returnDeposit (nodeAddress) = if ((size(i.payments) != 0))
235- then throw("No payments allowed")
236- else {
237- let callerAddress = i.caller
238- if (if ((callerAddress != this))
239- then (nodeAddress != toString(callerAddress))
240- else false)
241- then throw("returnDeposit permissions denied")
242- else {
243- let nodeRegistryKEY = keyNodeRegistry(nodeAddress)
244- let nodeDataOpt = getString(this, nodeRegistryKEY)
245- if (!(isDefined(nodeDataOpt)))
246- then throw(("Address is not applied as neutrino node: " + nodeAddress))
247- else {
248- let nodeData = split(value(nodeDataOpt), SEP)
249- let status = if ((size(nodeData) >= 9))
250- then nodeData[6]
251- else "PENDING"
252- if ((status != "PENDING"))
253- then throw("Application status is not PENDING!")
254- else {
255- let depoAmount = parseIntValue(nodeData[4])
256-[DeleteEntry(nodeRegistryKEY), ScriptTransfer(addressFromStringValue(nodeAddress), depoAmount, unit)]
257- }
258- }
259- }
260- }
261-
262-
1+# no script

github/deemru/w8io/169f3d6 
44.25 ms