tx · 2LmFCPKDWAxPQVWtiko78HQLF3RFmvWbzCSLYKGdTWK9

3N8y4wxX3JC4TdrCJBXX16SjWf6X256hrep:  -0.01000000 Waves

2022.11.19 14:54 [2323967] smart account 3N8y4wxX3JC4TdrCJBXX16SjWf6X256hrep > SELF 0.00000000 Waves

{ "type": 13, "id": "2LmFCPKDWAxPQVWtiko78HQLF3RFmvWbzCSLYKGdTWK9", "fee": 1000000, "feeAssetId": null, "timestamp": 1668858874614, "version": 2, "chainId": 84, "sender": "3N8y4wxX3JC4TdrCJBXX16SjWf6X256hrep", "senderPublicKey": "7v5L7QkXxfkirALdyqmox38QCsa9jtfAtgUfHTh34eWq", "proofs": [ "2mSrJ1j4Er5c8XMeSq2xWAUj2tFcjd61Ms6Uiy56qvsKKhhhzMHPvbd3NG6BK1mdWJLvzYjfUh2pKZEag29ax7Ay" ], "script": "base64:BgIJCAISBQoDCAgYCQAFTVVMVDgAgMLXLwALdXNkbkFzc2V0SWQBIPd26vf3g8pl224T7gI7z1gplanB0Y3yS9ps2B1igMjeAAtiYWNrRW5kQWRkcgkBEUBleHRyTmF0aXZlKDEwNjIpAQIjM041U3BYMjFSM1I3NVFvNGViM013RkZ2VzdUVXp5aHZhdnYAEGFsbG93ZWRSZXNvdXJjZXMJAMwIAgIDT2lsCQDMCAICA09yZQkAzAgCAgRXb29kCQDMCAICBFNhbmQJAMwIAgIEQ2xheQkAzAgCAgdPcmdhbmljBQNuaWwACmNvbnRpbmVudHMJAMwIAgIIQW1lcmljYXMJAMwIAgIGRXVyb3BlCQDMCAICBEFzaWEJAMwIAgIGQWZyaWNhCQDMCAICB09jZWFuaWEFA25pbAEda2V5U3RvcmVSZXNCeUNvbnRpbmVudEFuZFR5cGUCCWNvbnRpbmVudAdyZXNUeXBlCQCsAgIJAKwCAgkArAICAiBzdG9yZVJlc291cmNlQnlDb250aW5lbnRBbmRUeXBlXwUJY29udGluZW50AgFfBQdyZXNUeXBlAAdpZHhUeXBlAAAAC2lkeFF1YW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aWwAAAoBBSRmMF8xAgIkYQIkaQMJAGcCBQIkaQUCJHMFAiRhCQEFYWRkZXICBQIkYQkAkQMCBQIkbAUCJGkKAQUkZjBfMgICJGECJGkDCQBnAgUCJGkFAiRzBQIkYQkAAgECFExpc3Qgc2l6ZSBleGNlZWRzIDEwCQEFJGYwXzICCQEFJGYwXzECCQEFJGYwXzECCQEFJGYwXzECCQEFJGYwXzECCQEFJGYwXzECCQEFJGYwXzECCQEFJGYwXzECCQEFJGYwXzECCQEFJGYwXzECCQEFJGYwXzECBQUkYWNjMAAAAAEAAgADAAQABQAGAAcACAAJAAoJAM0IAggFBnJlc3VsdAJfMQkBDlNjcmlwdFRyYW5zZmVyAwULdXNlckFkZHJlc3MIBQZyZXN1bHQCXzIFC3VzZG5Bc3NldElkADmw7Ug=", "height": 2323967, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: H5ME1UH6gzgR9osALhakoc5TRBWvyLcoHBEcVwgQvfQt Next: DL78pGCqVfxGpLR21WQkRs7KhhDFtPVS9oq6a5TtudL Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let MULT6 = 1000000
4+let MULT8 = 100000000
55
66 let usdnAssetId = base58'HezsdQuRDtzksAYUy97gfhKy7Z1NW2uXYSHA3bgqenNZ'
77
3636 then throw(("Unknown resource: " + resType))
3737 else {
3838 let resKey = keyStoreResByContinentAndType(continent, resType)
39- let storedAmount = valueOrElse(getInteger(resKey), 0)
4039 let q = parseIntValue(parts[idxQuantity])
41- $Tuple2((acc._1 :+ IntegerEntry(resKey, q)), (acc._2 + fraction(q, parseIntValue(parts[idxPrice]), MULT6)))
40+ $Tuple2((acc._1 :+ IntegerEntry(resKey, (valueOrElse(getInteger(resKey), 0) + q))), (acc._2 + fraction(q, parseIntValue(parts[idxPrice]), MULT8)))
4241 }
4342 }
4443
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let MULT6 = 1000000
4+let MULT8 = 100000000
55
66 let usdnAssetId = base58'HezsdQuRDtzksAYUy97gfhKy7Z1NW2uXYSHA3bgqenNZ'
77
88 let backEndAddr = addressFromStringValue("3N5SpX21R3R75Qo4eb3MwFFvW7TUzyhvavv")
99
1010 let allowedResources = ["Oil", "Ore", "Wood", "Sand", "Clay", "Organic"]
1111
1212 let continents = ["Americas", "Europe", "Asia", "Africa", "Oceania"]
1313
1414 func keyStoreResByContinentAndType (continent,resType) = ((("storeResourceByContinentAndType_" + continent) + "_") + resType)
1515
1616
1717 let idxType = 0
1818
1919 let idxQuantity = 1
2020
2121 let idxPrice = 2
2222
2323 @Callable(i)
2424 func sellResources (userAddressStr,continent,resources) = if ((i.caller != backEndAddr))
2525 then throw("permission denied")
2626 else if ((size(i.payments) != 0))
2727 then throw("sellResources doesn't require any payments")
2828 else if (!(containsElement(continents, continent)))
2929 then throw(("Unknown continent: " + continent))
3030 else {
3131 let userAddress = addressFromStringValue(userAddressStr)
3232 func adder (acc,elem) = {
3333 let parts = split(elem, "_")
3434 let resType = parts[idxType]
3535 if (!(containsElement(allowedResources, resType)))
3636 then throw(("Unknown resource: " + resType))
3737 else {
3838 let resKey = keyStoreResByContinentAndType(continent, resType)
39- let storedAmount = valueOrElse(getInteger(resKey), 0)
4039 let q = parseIntValue(parts[idxQuantity])
41- $Tuple2((acc._1 :+ IntegerEntry(resKey, q)), (acc._2 + fraction(q, parseIntValue(parts[idxPrice]), MULT6)))
40+ $Tuple2((acc._1 :+ IntegerEntry(resKey, (valueOrElse(getInteger(resKey), 0) + q))), (acc._2 + fraction(q, parseIntValue(parts[idxPrice]), MULT8)))
4241 }
4342 }
4443
4544 let result = {
4645 let $l = resources
4746 let $s = size($l)
4847 let $acc0 = $Tuple2(nil, 0)
4948 func $f0_1 ($a,$i) = if (($i >= $s))
5049 then $a
5150 else adder($a, $l[$i])
5251
5352 func $f0_2 ($a,$i) = if (($i >= $s))
5453 then $a
5554 else throw("List size exceeds 10")
5655
5756 $f0_2($f0_1($f0_1($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), 9), 10)
5857 }
5958 (result._1 :+ ScriptTransfer(userAddress, result._2, usdnAssetId))
6059 }
6160
6261

github/deemru/w8io/026f985 
29.59 ms