tx · H5ME1UH6gzgR9osALhakoc5TRBWvyLcoHBEcVwgQvfQt 3N8y4wxX3JC4TdrCJBXX16SjWf6X256hrep: -0.01000000 Waves 2022.11.18 14:27 [2322493] smart account 3N8y4wxX3JC4TdrCJBXX16SjWf6X256hrep > SELF 0.00000000 Waves
{ "type": 13, "id": "H5ME1UH6gzgR9osALhakoc5TRBWvyLcoHBEcVwgQvfQt", "fee": 1000000, "feeAssetId": null, "timestamp": 1668770910514, "version": 2, "chainId": 84, "sender": "3N8y4wxX3JC4TdrCJBXX16SjWf6X256hrep", "senderPublicKey": "7v5L7QkXxfkirALdyqmox38QCsa9jtfAtgUfHTh34eWq", "proofs": [ "4P1x1gZnQcfinWHXXuTEDXtaozCQuEWVxyJmBZoS9ts3H5XstrQvEjefxpHFHdpRGBmMbVan4XAd2szBGDxgizHt" ], "script": "base64:BgIJCAISBQoDCAgYCQAFTVVMVDYAwIQ9AAt1c2RuQXNzZXRJZAEg93bq9/eDymXbbhPuAjvPWCmVqcHRjfJL2mzYHWKAyN4AC2JhY2tFbmRBZGRyCQERQGV4dHJOYXRpdmUoMTA2MikBAiMzTjVTcFgyMVIzUjc1UW80ZWIzTXdGRnZXN1RVenlodmF2dgAQYWxsb3dlZFJlc291cmNlcwkAzAgCAgNPaWwJAMwIAgIDT3JlCQDMCAICBFdvb2QJAMwIAgIEU2FuZAkAzAgCAgRDbGF5CQDMCAICB09yZ2FuaWMFA25pbAAKY29udGluZW50cwkAzAgCAghBbWVyaWNhcwkAzAgCAgZFdXJvcGUJAMwIAgIEQXNpYQkAzAgCAgZBZnJpY2EJAMwIAgIHT2NlYW5pYQUDbmlsAR1rZXlTdG9yZVJlc0J5Q29udGluZW50QW5kVHlwZQIJY29udGluZW50B3Jlc1R5cGUJAKwCAgkArAICCQCsAgICIHN0b3JlUmVzb3VyY2VCeUNvbnRpbmVudEFuZFR5cGVfBQljb250aW5lbnQCAV8FB3Jlc1R5cGUAB2lkeFR5cGUAAAALaWR4UXVhbnRpd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CBQNuaWwAAAoBBSRmMF8xAgIkYQIkaQMJAGcCBQIkaQUCJHMFAiRhCQEFYWRkZXICBQIkYQkAkQMCBQIkbAUCJGkKAQUkZjBfMgICJGECJGkDCQBnAgUCJGkFAiRzBQIkYQkAAgECFExpc3Qgc2l6ZSBleGNlZWRzIDEwCQEFJGYwXzICCQEFJGYwXzECCQEFJGYwXzECCQEFJGYwXzECCQEFJGYwXzECCQEFJGYwXzECCQEFJGYwXzECCQEFJGYwXzECCQEFJGYwXzECCQEFJGYwXzECCQEFJGYwXzECBQUkYWNjMAAAAAEAAgADAAQABQAGAAcACAAJAAoJAM0IAggFBnJlc3VsdAJfMQkBDlNjcmlwdFRyYW5zZmVyAwULdXNlckFkZHJlc3MIBQZyZXN1bHQCXzIFC3VzZG5Bc3NldElkAI1PREM=", "height": 2322493, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: 2LmFCPKDWAxPQVWtiko78HQLF3RFmvWbzCSLYKGdTWK9 Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 6 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let MULT6 = 1000000 | |
5 | + | ||
6 | + | let usdnAssetId = base58'HezsdQuRDtzksAYUy97gfhKy7Z1NW2uXYSHA3bgqenNZ' | |
7 | + | ||
8 | + | let backEndAddr = addressFromStringValue("3N5SpX21R3R75Qo4eb3MwFFvW7TUzyhvavv") | |
9 | + | ||
10 | + | let allowedResources = ["Oil", "Ore", "Wood", "Sand", "Clay", "Organic"] | |
11 | + | ||
12 | + | let continents = ["Americas", "Europe", "Asia", "Africa", "Oceania"] | |
13 | + | ||
14 | + | func keyStoreResByContinentAndType (continent,resType) = ((("storeResourceByContinentAndType_" + continent) + "_") + resType) | |
15 | + | ||
16 | + | ||
17 | + | let idxType = 0 | |
18 | + | ||
19 | + | let idxQuantity = 1 | |
20 | + | ||
21 | + | let idxPrice = 2 | |
22 | + | ||
23 | + | @Callable(i) | |
24 | + | func sellResources (userAddressStr,continent,resources) = if ((i.caller != backEndAddr)) | |
25 | + | then throw("permission denied") | |
26 | + | else if ((size(i.payments) != 0)) | |
27 | + | then throw("sellResources doesn't require any payments") | |
28 | + | else if (!(containsElement(continents, continent))) | |
29 | + | then throw(("Unknown continent: " + continent)) | |
30 | + | else { | |
31 | + | let userAddress = addressFromStringValue(userAddressStr) | |
32 | + | func adder (acc,elem) = { | |
33 | + | let parts = split(elem, "_") | |
34 | + | let resType = parts[idxType] | |
35 | + | if (!(containsElement(allowedResources, resType))) | |
36 | + | then throw(("Unknown resource: " + resType)) | |
37 | + | else { | |
38 | + | let resKey = keyStoreResByContinentAndType(continent, resType) | |
39 | + | let storedAmount = valueOrElse(getInteger(resKey), 0) | |
40 | + | let q = parseIntValue(parts[idxQuantity]) | |
41 | + | $Tuple2((acc._1 :+ IntegerEntry(resKey, q)), (acc._2 + fraction(q, parseIntValue(parts[idxPrice]), MULT6))) | |
42 | + | } | |
43 | + | } | |
44 | + | ||
45 | + | let result = { | |
46 | + | let $l = resources | |
47 | + | let $s = size($l) | |
48 | + | let $acc0 = $Tuple2(nil, 0) | |
49 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
50 | + | then $a | |
51 | + | else adder($a, $l[$i]) | |
52 | + | ||
53 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
54 | + | then $a | |
55 | + | else throw("List size exceeds 10") | |
56 | + | ||
57 | + | $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) | |
58 | + | } | |
59 | + | (result._1 :+ ScriptTransfer(userAddress, result._2, usdnAssetId)) | |
60 | + | } | |
61 | + | ||
62 | + |
github/deemru/w8io/026f985 22.03 ms ◑