tx · H7A13VBTxh1HLVwbf4FDsDwuj2qfQA2LzrBEZNTtxkfb 3Msughfkwji8uccY4RAxuKWvNpnEscWyhHK: -0.01400000 Waves 2019.07.01 13:39 [566206] smart account 3Msughfkwji8uccY4RAxuKWvNpnEscWyhHK > SELF 0.00000000 Waves
{ "type": 13, "id": "H7A13VBTxh1HLVwbf4FDsDwuj2qfQA2LzrBEZNTtxkfb", "fee": 1400000, "feeAssetId": null, "timestamp": 1561977599862, "version": 1, "sender": "3Msughfkwji8uccY4RAxuKWvNpnEscWyhHK", "senderPublicKey": "AzyC6W7iD5HYehj2xef6xWKogmxDC6RaX9N1ST8P39bn", "proofs": [ "2GyUSuk36vNgbqX19SJpbNepcvjLLfUrzCQZ6yFxLTuSRmvctFyRYUHvZYyXfr63YLTQ6YJLhuusKnoaMbMiJone" ], "script": "base64:AAIDAAAAAAAAAAAAAAAKAAAAAAZsZXZlbDEAAAAAAAAAAPoAAAAABmxldmVsMgAAAAAAAAAA+gAAAAAGbGV2ZWwzAAAAAAAAAAD6AAAAAAhjYXNoQmFjawAAAAAAAAAA+gAAAAAGbWF4RmVlAAAAAAAATEtAAAAAAA5jaGFuZ2VPd25lcktleQIAAAAsQUQydmJ6cFIzWk1YaVkxWmhCZHE0aUgxd3o1dzZ0VUNIUHoxdnZOZnlDcUUBAAAAEGJhbGFuY2VJbmNyZW1lbnQAAAACAAAAB2FkZHJlc3MAAAADaW5jBAAAAApiYWxhbmNlS2V5CQABLAAAAAIFAAAAB2FkZHJlc3MCAAAACF9iYWxhbmNlCQEAAAAJRGF0YUVudHJ5AAAAAgUAAAAKYmFsYW5jZUtleQkAAGQAAAACBQAAAANpbmMEAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAAKYmFsYW5jZUtleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFiBQAAAAckbWF0Y2gwBQAAAAFiAAAAAAAAAAAAAQAAABVpbmRleEJhbGFuY2VJbmNyZW1lb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AQUAAAAHcmVmZXJlcgMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAhyZWZlcmVyMgUAAAAHJG1hdGNoMAkAASwAAAACCQABLAAAAAICAAAAASwFAAAACHJlZmVyZXIyBAAAAAckbWF0Y2gxCQEAAAAKZ2V0UmVmZXJlcgAAAAEFAAAACHJlZmVyZXIyAwkAAAEAAAACBQAAAAckbWF0Y2gxAgAAAAZTdHJpbmcEAAAACHJlZmVyZXIzBQAAAAckbWF0Y2gxCQABLAAAAAICAAAAASwFAAAACHJlZmVyZXIzAgAAAAACAAAAAAkBAAAADFNjcmlwdFJlc3VsdAAAAAIJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAAEsAAAAAgUAAAAFb3duZXICAAAACF9yZWZlcmVyBQAAAAdyZWZlcmVyCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACBQAAAAtyZWZlcmFsc0tleQUAAAAIcmVmZXJhbHMJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAAEsAAAAAgUAAAAFb3duZXICAAAADV9yZWZzdHJ1Y3R1cmUFAAAADHJlZlN0cnVjdHVyZQUAAAADbmlsCQEAAAALVHJhbnNmZXJTZXQAAAABCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAAFpAAAABmNhbGxlcggFAAAAAWkAAAADZmVlBQAAAAR1bml0BQAAAANuaWwAAAAACdpXUQ==", "chainId": 84, "height": 566206, "spentComplexity": 0 } View: original | compacted Prev: 77Gfu262aBddrNvaajnePPJ4CTzUcZ83oo7czhUmPVo9 Next: EgAnnPy2NnSQf9Wgs9pn2oKQdqmCiEhQ2Jy1Srny66TA Diff:
Old | New | Differences | |
---|---|---|---|
97 | 97 | ||
98 | 98 | @Callable(i) | |
99 | 99 | func register (referer) = { | |
100 | - | let | |
101 | - | if (( | |
102 | - | then throw(" | |
100 | + | let owner = toBase58String(i.callerPublicKey) | |
101 | + | if (isDefined(getReferer(owner))) | |
102 | + | then throw("Already registered") | |
103 | 103 | else { | |
104 | - | let owner = toBase58String(i.callerPublicKey) | |
105 | - | if (isDefined(getReferer(owner))) | |
106 | - | then throw("Already registered") | |
107 | - | else { | |
108 | - | let referalsKey = (referer + "_referrals") | |
109 | - | let referals = match getString(this, referalsKey) { | |
110 | - | case oldRefs: String => | |
111 | - | ((oldRefs + ",") + owner) | |
112 | - | case _ => | |
113 | - | owner | |
114 | - | } | |
115 | - | let refStructure = (referer + match getReferer(referer) { | |
116 | - | case referer2: String => | |
117 | - | (("," + referer2) + match getReferer(referer2) { | |
118 | - | case referer3: String => | |
119 | - | ("," + referer3) | |
120 | - | case _ => | |
121 | - | "" | |
122 | - | }) | |
104 | + | let referalsKey = (referer + "_referrals") | |
105 | + | let referals = match getString(this, referalsKey) { | |
106 | + | case oldRefs: String => | |
107 | + | ((oldRefs + ",") + owner) | |
108 | + | case _ => | |
109 | + | owner | |
110 | + | } | |
111 | + | let refStructure = (referer + match getReferer(referer) { | |
112 | + | case referer2: String => | |
113 | + | (("," + referer2) + match getReferer(referer2) { | |
114 | + | case referer3: String => | |
115 | + | ("," + referer3) | |
123 | 116 | case _ => | |
124 | 117 | "" | |
125 | 118 | }) | |
126 | - | ScriptResult(WriteSet([DataEntry((owner + "_referer"), referer), DataEntry(referalsKey, referals), DataEntry((owner + "_refstructure"), refStructure)]), TransferSet([ScriptTransfer(i.caller, i.fee, unit)])) | |
127 | - | } | |
119 | + | case _ => | |
120 | + | "" | |
121 | + | }) | |
122 | + | ScriptResult(WriteSet([DataEntry((owner + "_referer"), referer), DataEntry(referalsKey, referals), DataEntry((owner + "_refstructure"), refStructure)]), TransferSet([ScriptTransfer(i.caller, i.fee, unit)])) | |
128 | 123 | } | |
129 | 124 | } | |
130 | 125 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let level1 = 250 | |
5 | 5 | ||
6 | 6 | let level2 = 250 | |
7 | 7 | ||
8 | 8 | let level3 = 250 | |
9 | 9 | ||
10 | 10 | let cashBack = 250 | |
11 | 11 | ||
12 | 12 | let maxFee = 5000000 | |
13 | 13 | ||
14 | 14 | let changeOwnerKey = "AD2vbzpR3ZMXiY1ZhBdq4iH1wz5w6tUCHPz1vvNfyCqE" | |
15 | 15 | ||
16 | 16 | func balanceIncrement (address,inc) = { | |
17 | 17 | let balanceKey = (address + "_balance") | |
18 | 18 | DataEntry(balanceKey, (inc + match getInteger(this, balanceKey) { | |
19 | 19 | case b: Int => | |
20 | 20 | b | |
21 | 21 | case _ => | |
22 | 22 | 0 | |
23 | 23 | })) | |
24 | 24 | } | |
25 | 25 | ||
26 | 26 | ||
27 | 27 | func indexBalanceIncrement (address,owner,inc,level) = { | |
28 | 28 | let logKey = (address + level) | |
29 | 29 | let recordData = (owner + toString(inc)) | |
30 | 30 | match getString(this, logKey) { | |
31 | 31 | case prev: String => | |
32 | 32 | DataEntry(logKey, ((prev + ",") + recordData)) | |
33 | 33 | case _ => | |
34 | 34 | DataEntry(logKey, recordData) | |
35 | 35 | } | |
36 | 36 | } | |
37 | 37 | ||
38 | 38 | ||
39 | 39 | func getReferer (user) = getString(this, (user + "_referer")) | |
40 | 40 | ||
41 | 41 | ||
42 | 42 | func checkFee (i) = if ((i.fee > maxFee)) | |
43 | 43 | then throw("unreasonable large fee") | |
44 | 44 | else true | |
45 | 45 | ||
46 | 46 | ||
47 | 47 | @Callable(i) | |
48 | 48 | func fund () = { | |
49 | 49 | let owner = toBase58String(i.callerPublicKey) | |
50 | 50 | let block = extract(blockInfoByHeight(height)) | |
51 | 51 | let ownerColon = (((owner + ":") + toString(block.timestamp)) + ":") | |
52 | 52 | let amount = extract(i.payment).amount | |
53 | 53 | let cf = checkFee(i) | |
54 | 54 | ScriptResult(WriteSet( match getString(this, (owner + "_refstructure")) { | |
55 | 55 | case refListS: String => | |
56 | 56 | let refList = split(refListS, ",") | |
57 | 57 | let refListSize = size(refList) | |
58 | 58 | let incLevel1 = ((amount * level1) / 1000) | |
59 | 59 | let incCashBack = ((amount * cashBack) / 1000) | |
60 | 60 | [balanceIncrement(owner, incCashBack), indexBalanceIncrement(owner, ownerColon, incCashBack, "_txs_cashback"), balanceIncrement(refList[0], incLevel1), indexBalanceIncrement(refList[0], ownerColon, incLevel1, "_txs_l1"), if ((refListSize >= 2)) | |
61 | 61 | then { | |
62 | 62 | let incLevel2 = ((amount * level2) / 1000) | |
63 | 63 | [balanceIncrement(refList[1], incLevel2), indexBalanceIncrement(refList[1], ownerColon, incLevel2, "_txs_l2"), if ((refListSize >= 3)) | |
64 | 64 | then { | |
65 | 65 | let incLevel3 = ((amount * level3) / 1000) | |
66 | 66 | [balanceIncrement(refList[2], incLevel3), indexBalanceIncrement(refList[2], ownerColon, incLevel3, "_txs_l3"), balanceIncrement(changeOwnerKey, (((amount - incLevel1) - incLevel2) - incLevel3)), indexBalanceIncrement(changeOwnerKey, ownerColon, (((amount - incLevel1) - incLevel2) - incLevel3), "_txs_change")] | |
67 | 67 | } | |
68 | 68 | else [balanceIncrement(changeOwnerKey, ((amount - incLevel1) - incLevel2)), indexBalanceIncrement(changeOwnerKey, ownerColon, ((amount - incLevel1) - incLevel2), "_txs_change")]] | |
69 | 69 | } | |
70 | 70 | else [balanceIncrement(changeOwnerKey, (amount - incLevel1)), indexBalanceIncrement(changeOwnerKey, ownerColon, (amount - incLevel1), "_txs_change")]] | |
71 | 71 | case _ => | |
72 | 72 | [balanceIncrement(changeOwnerKey, amount), indexBalanceIncrement(changeOwnerKey, ownerColon, amount, "_txs_change")] | |
73 | 73 | }), TransferSet([ScriptTransfer(i.caller, i.fee, unit)])) | |
74 | 74 | } | |
75 | 75 | ||
76 | 76 | ||
77 | 77 | ||
78 | 78 | @Callable(i) | |
79 | 79 | func withdraw () = { | |
80 | 80 | let cf = checkFee(i) | |
81 | 81 | let owner = toBase58String(i.callerPublicKey) | |
82 | 82 | let amount = match getInteger(this, (owner + "_balance")) { | |
83 | 83 | case b: Int => | |
84 | 84 | b | |
85 | 85 | case _ => | |
86 | 86 | 0 | |
87 | 87 | } | |
88 | 88 | ScriptResult(WriteSet([DataEntry((owner + "_balance"), 0)]), TransferSet([ScriptTransfer(i.caller, amount, unit)])) | |
89 | 89 | } | |
90 | 90 | ||
91 | 91 | ||
92 | 92 | ||
93 | 93 | @Callable(i) | |
94 | 94 | func test () = WriteSet(nil) | |
95 | 95 | ||
96 | 96 | ||
97 | 97 | ||
98 | 98 | @Callable(i) | |
99 | 99 | func register (referer) = { | |
100 | - | let | |
101 | - | if (( | |
102 | - | then throw(" | |
100 | + | let owner = toBase58String(i.callerPublicKey) | |
101 | + | if (isDefined(getReferer(owner))) | |
102 | + | then throw("Already registered") | |
103 | 103 | else { | |
104 | - | let owner = toBase58String(i.callerPublicKey) | |
105 | - | if (isDefined(getReferer(owner))) | |
106 | - | then throw("Already registered") | |
107 | - | else { | |
108 | - | let referalsKey = (referer + "_referrals") | |
109 | - | let referals = match getString(this, referalsKey) { | |
110 | - | case oldRefs: String => | |
111 | - | ((oldRefs + ",") + owner) | |
112 | - | case _ => | |
113 | - | owner | |
114 | - | } | |
115 | - | let refStructure = (referer + match getReferer(referer) { | |
116 | - | case referer2: String => | |
117 | - | (("," + referer2) + match getReferer(referer2) { | |
118 | - | case referer3: String => | |
119 | - | ("," + referer3) | |
120 | - | case _ => | |
121 | - | "" | |
122 | - | }) | |
104 | + | let referalsKey = (referer + "_referrals") | |
105 | + | let referals = match getString(this, referalsKey) { | |
106 | + | case oldRefs: String => | |
107 | + | ((oldRefs + ",") + owner) | |
108 | + | case _ => | |
109 | + | owner | |
110 | + | } | |
111 | + | let refStructure = (referer + match getReferer(referer) { | |
112 | + | case referer2: String => | |
113 | + | (("," + referer2) + match getReferer(referer2) { | |
114 | + | case referer3: String => | |
115 | + | ("," + referer3) | |
123 | 116 | case _ => | |
124 | 117 | "" | |
125 | 118 | }) | |
126 | - | ScriptResult(WriteSet([DataEntry((owner + "_referer"), referer), DataEntry(referalsKey, referals), DataEntry((owner + "_refstructure"), refStructure)]), TransferSet([ScriptTransfer(i.caller, i.fee, unit)])) | |
127 | - | } | |
119 | + | case _ => | |
120 | + | "" | |
121 | + | }) | |
122 | + | ScriptResult(WriteSet([DataEntry((owner + "_referer"), referer), DataEntry(referalsKey, referals), DataEntry((owner + "_refstructure"), refStructure)]), TransferSet([ScriptTransfer(i.caller, i.fee, unit)])) | |
128 | 123 | } | |
129 | 124 | } | |
130 | 125 | ||
131 | 126 |
github/deemru/w8io/169f3d6 41.20 ms ◑