tx · Cn4jbpdfoMf4rZ8MCxmeN4ym3gbS74XA2CTzkuFiuRWK 3N7UuYar6264P58FBhVWKPQAh4Yua2hgngv: -0.00400000 Waves 2024.09.12 19:20 [3280653] smart account 3N7UuYar6264P58FBhVWKPQAh4Yua2hgngv > SELF 0.00000000 Waves
{ "type": 13, "id": "Cn4jbpdfoMf4rZ8MCxmeN4ym3gbS74XA2CTzkuFiuRWK", "fee": 400000, "feeAssetId": null, "timestamp": 1726158029547, "version": 2, "chainId": 84, "sender": "3N7UuYar6264P58FBhVWKPQAh4Yua2hgngv", "senderPublicKey": "2fNSk5gmWbXBDTkSYSKd66xSgVvAYzrJnP9YSAFNvTwC", "proofs": [ "3J55ca9jmEAXc7rHQzg6ndadvQUzAuAxubVhkzijFcPf6pUrwJBQVGLvBqBuRrwjnxoS9KhwVzAhssttzEFAHMtX" ], "script": "base64:BgIMCAISAwoBGBIDCgEIGwADU0VQAgJfXwAFY2hhaW4JAMkBAgkAygECCAUEdGhpcwVieXRlcwABAAEAFmRlZmF1bHRSZXN0MkFkZHJlc3NTdHIEByRtYXRjaDAFBWNoYWluAwkAAAIBAVcFByRtYXRjaDACIzNQRndZdGE4YmlFejMxenBlRmU1REpLOHdFNXRyU3BRVkY4AwkAAAIBAVQFByRtYXRjaDACIzNON1V1WWFyNjI2NFA1OEZCaFZXS1BRQWg0WXVhMmhnbmd2CQACAQINVW5rbm93biBjaGFpbgEPZ2V0U3RyaW5nT3JGYWlsAgdhZGRyZXNzA2tleQkBE3ZhbHVlT3JFcnJvck1lc3NhZ2UCCQCdCAIFB2FkZHJlc3MFA2tleQkAuQkCCQDMCAICCm1hbmRhdG9yeSAJAMwIAgkApQgBBQdhZGRyZXNzCQDMCAICAS4JAMwIAgUDa2V5CQDMCAICDyBpcyBub3QgZGVmaW5lZAUDbmlsAgAAEElkeENmZ0FjcmVzMkRhcHAAAQANSWR4Q2ZnV2xnRGFwcAACAQprZXlSZXN0Q2ZnAAIOJXNfX3Jlc3RDb25maW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IAAwAEAAUABgAHAAgACQAKCQDMCAIJAQtTdHJpbmdFbnRyeQIJAQprZXlSZXN0Q2ZnAAkAuQkCCQDMCAIFBWRlc2NyBQljb250cmFjdHMFA1NFUAkAzAgCCQELU3RyaW5nRW50cnkCCQEPa2V5UmVzdDJBZGRyZXNzAAkApQgBBQR0aGlzBQNuaWwBaQESd2FsbGV0SW5mb1JFQURPTkxZAQ51c2VyQWRkcmVzc09wdAkAlAoCBQNuaWwJAQ53YWxsZXRJbnRlcm5hbAEFDnVzZXJBZGRyZXNzT3B0ABVQaEY=", "height": 3280653, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 81FfyMfwhifgSh933ZGAbRCsjJ3QEXURjpddssyUtyM4 Next: 8oNhYXVoHCW257sF3FavVcLbTVipu7JgHMGp8fh5SX1F Diff:
Old | New | Differences | |
---|---|---|---|
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SEP = "__" | |
5 | 5 | ||
6 | - | let MULT8 = 100000000 | |
7 | - | ||
8 | 6 | let chain = take(drop(this.bytes, 1), 1) | |
9 | 7 | ||
10 | - | let | |
8 | + | let defaultRest2AddressStr = match chain { | |
11 | 9 | case _ => | |
12 | 10 | if ((base58'2W' == $match0)) | |
13 | - | then " | |
11 | + | then "3PFwYta8biEz31zpeFe5DJK8wE5trSpQVF8" | |
14 | 12 | else if ((base58'2T' == $match0)) | |
15 | - | then " | |
13 | + | then "3N7UuYar6264P58FBhVWKPQAh4Yua2hgngv" | |
16 | 14 | else throw("Unknown chain") | |
17 | 15 | } | |
18 | 16 | ||
19 | 17 | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
20 | 18 | ||
21 | 19 | ||
22 | - | let | |
20 | + | let IdxCfgAcres2Dapp = 1 | |
23 | 21 | ||
24 | 22 | let IdxCfgWlgDapp = 2 | |
25 | 23 | ||
26 | 24 | func keyRestCfg () = "%s__restConfig" | |
27 | 25 | ||
28 | 26 | ||
29 | - | func | |
27 | + | func keyRest2Address () = "%s__rest2Addr" | |
30 | 28 | ||
31 | 29 | ||
32 | 30 | func readRestCfgOrFail (rest) = split_4C(getStringOrFail(rest, keyRestCfg()), SEP) | |
33 | 31 | ||
34 | 32 | ||
35 | - | func getContractAddressOrFail ( | |
33 | + | func getContractAddressOrFail (rest2Cfg,idx) = valueOrErrorMessage(addressFromString(rest2Cfg[idx]), ("Rest cfg doesn't contain address at index " + toString(idx))) | |
36 | 34 | ||
37 | 35 | ||
38 | - | let | |
36 | + | let rest2Contract = addressFromStringValue(valueOrElse(getString(this, keyRest2Address()), defaultRest2AddressStr)) | |
39 | 37 | ||
40 | - | let | |
38 | + | let rest2Cfg = readRestCfgOrFail(rest2Contract) | |
41 | 39 | ||
42 | - | let | |
40 | + | let acres2Contract = getContractAddressOrFail(rest2Cfg, IdxCfgAcres2Dapp) | |
43 | 41 | ||
44 | - | let wlgContract = getContractAddressOrFail( | |
42 | + | let wlgContract = getContractAddressOrFail(rest2Cfg, IdxCfgWlgDapp) | |
45 | 43 | ||
46 | 44 | func keyLastTxIdByUser (addr) = ("lastTxIdByUser_" + addr) | |
47 | 45 | ||
52 | 50 | ||
53 | 51 | let acresAssetIdKey = "acresAssetId" | |
54 | 52 | ||
55 | - | let acresAssetId = valueOrErrorMessage(getBinary(stakingContract, acresAssetIdKey), "ACRES is not issued yet") | |
53 | + | let acresAssetId = valueOrErrorMessage(getBinary(acres2Contract, acresAssetIdKey), "ACRES is not issued yet") | |
54 | + | ||
55 | + | func keyAddressToCustomName (addr) = ("accountCustomNameByAddr_" + addr) | |
56 | + | ||
57 | + | ||
58 | + | func keyAddressRefBy (addr) = ("accRefBy_" + addr) | |
59 | + | ||
60 | + | ||
61 | + | func keyAddressReferrals (addr) = ("accReferrals_" + addr) | |
62 | + | ||
63 | + | ||
64 | + | let M8_ = 100000000 | |
65 | + | ||
66 | + | func keyAcresStakedAmtByUser (addr) = ("acresStakedAmountByUser_" + addr) | |
67 | + | ||
56 | 68 | ||
57 | 69 | let levels = [10, 20, 40, 80, 150, 250, 400, 700, 1000] | |
58 | 70 | ||
59 | 71 | func getLevelByAcres (acres) = { | |
60 | - | let acr = (acres / | |
72 | + | let acr = (acres / M8_) | |
61 | 73 | func checker (acc,item) = if ((item > acr)) | |
62 | 74 | then acc | |
63 | 75 | else (acc + 1) | |
80 | 92 | } | |
81 | 93 | ||
82 | 94 | ||
83 | - | func keyAddressToCustomName (addr) = ("accountCustomNameByAddr_" + addr) | |
84 | - | ||
85 | - | ||
86 | - | func keyAddressRefBy (addr) = ("accRefBy_" + addr) | |
87 | - | ||
88 | - | ||
89 | - | func keyAddressReferrals (addr) = ("accReferrals_" + addr) | |
90 | - | ||
91 | - | ||
92 | - | func keyAcresStakedAmountByUser (addr) = ("acresStakedAmountByUser_" + addr) | |
93 | - | ||
94 | - | ||
95 | 95 | func walletInternal (userAddressOpt) = { | |
96 | 96 | let addr = addressFromString(userAddressOpt) | |
97 | 97 | let balance = if (isDefined(addr)) | |
100 | 100 | let wlgoldBalance = if (isDefined(addr)) | |
101 | 101 | then assetBalance(value(addr), wlgAssetId) | |
102 | 102 | else 0 | |
103 | - | let customName = valueOrElse(getString( | |
103 | + | let customName = valueOrElse(getString(acres2Contract, keyAddressToCustomName(userAddressOpt)), userAddressOpt) | |
104 | 104 | let refByKey = keyAddressRefBy(userAddressOpt) | |
105 | - | let refBy = getString( | |
106 | - | let refs = valueOrElse(getString( | |
107 | - | let lastTxId = valueOrElse(getString( | |
105 | + | let refBy = getString(acres2Contract, refByKey) | |
106 | + | let refs = valueOrElse(getString(acres2Contract, keyAddressReferrals(userAddressOpt)), "") | |
107 | + | let lastTxId = valueOrElse(getString(acres2Contract, keyLastTxIdByUser(userAddressOpt)), "") | |
108 | 108 | let acresBalance = if (isDefined(addr)) | |
109 | 109 | then assetBalance(value(addr), acresAssetId) | |
110 | 110 | else 0 | |
111 | - | let stakedAcres = valueOrElse(getInteger( | |
111 | + | let stakedAcres = valueOrElse(getInteger(acres2Contract, keyAcresStakedAmtByUser(userAddressOpt)), 0) | |
112 | 112 | let lvl = getLevelByAcres(acresBalance) | |
113 | 113 | [("%s%s__customName__" + customName), ("%s%s__referredBy__" + valueOrElse(refBy, "")), ("%s%s__referrals__" + refs), ("%s%s__lastTxId__" + lastTxId), ("%s%d__wavesBalance__" + toString(balance.available)), ("%s%d__wlgoldBalance__" + toString(wlgoldBalance)), ("%s%d__acresBalance__" + toString(acresBalance)), ("%s%d__stakedAcres__" + toString(stakedAcres)), ("%s%d__currentLvl__" + toString(lvl))] | |
114 | 114 | } | |
134 | 134 | ||
135 | 135 | $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) | |
136 | 136 | } | |
137 | - | [StringEntry(keyRestCfg(), makeString(descr :: contracts, SEP)), StringEntry( | |
137 | + | [StringEntry(keyRestCfg(), makeString(descr :: contracts, SEP)), StringEntry(keyRest2Address(), toString(this))] | |
138 | 138 | } | |
139 | 139 | ||
140 | 140 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SEP = "__" | |
5 | 5 | ||
6 | - | let MULT8 = 100000000 | |
7 | - | ||
8 | 6 | let chain = take(drop(this.bytes, 1), 1) | |
9 | 7 | ||
10 | - | let | |
8 | + | let defaultRest2AddressStr = match chain { | |
11 | 9 | case _ => | |
12 | 10 | if ((base58'2W' == $match0)) | |
13 | - | then " | |
11 | + | then "3PFwYta8biEz31zpeFe5DJK8wE5trSpQVF8" | |
14 | 12 | else if ((base58'2T' == $match0)) | |
15 | - | then " | |
13 | + | then "3N7UuYar6264P58FBhVWKPQAh4Yua2hgngv" | |
16 | 14 | else throw("Unknown chain") | |
17 | 15 | } | |
18 | 16 | ||
19 | 17 | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
20 | 18 | ||
21 | 19 | ||
22 | - | let | |
20 | + | let IdxCfgAcres2Dapp = 1 | |
23 | 21 | ||
24 | 22 | let IdxCfgWlgDapp = 2 | |
25 | 23 | ||
26 | 24 | func keyRestCfg () = "%s__restConfig" | |
27 | 25 | ||
28 | 26 | ||
29 | - | func | |
27 | + | func keyRest2Address () = "%s__rest2Addr" | |
30 | 28 | ||
31 | 29 | ||
32 | 30 | func readRestCfgOrFail (rest) = split_4C(getStringOrFail(rest, keyRestCfg()), SEP) | |
33 | 31 | ||
34 | 32 | ||
35 | - | func getContractAddressOrFail ( | |
33 | + | func getContractAddressOrFail (rest2Cfg,idx) = valueOrErrorMessage(addressFromString(rest2Cfg[idx]), ("Rest cfg doesn't contain address at index " + toString(idx))) | |
36 | 34 | ||
37 | 35 | ||
38 | - | let | |
36 | + | let rest2Contract = addressFromStringValue(valueOrElse(getString(this, keyRest2Address()), defaultRest2AddressStr)) | |
39 | 37 | ||
40 | - | let | |
38 | + | let rest2Cfg = readRestCfgOrFail(rest2Contract) | |
41 | 39 | ||
42 | - | let | |
40 | + | let acres2Contract = getContractAddressOrFail(rest2Cfg, IdxCfgAcres2Dapp) | |
43 | 41 | ||
44 | - | let wlgContract = getContractAddressOrFail( | |
42 | + | let wlgContract = getContractAddressOrFail(rest2Cfg, IdxCfgWlgDapp) | |
45 | 43 | ||
46 | 44 | func keyLastTxIdByUser (addr) = ("lastTxIdByUser_" + addr) | |
47 | 45 | ||
48 | 46 | ||
49 | 47 | let wlgAssetIdKey = "wlg_assetId" | |
50 | 48 | ||
51 | 49 | let wlgAssetId = valueOrErrorMessage(getBinary(wlgContract, wlgAssetIdKey), "WLGOLD is not issued yet") | |
52 | 50 | ||
53 | 51 | let acresAssetIdKey = "acresAssetId" | |
54 | 52 | ||
55 | - | let acresAssetId = valueOrErrorMessage(getBinary(stakingContract, acresAssetIdKey), "ACRES is not issued yet") | |
53 | + | let acresAssetId = valueOrErrorMessage(getBinary(acres2Contract, acresAssetIdKey), "ACRES is not issued yet") | |
54 | + | ||
55 | + | func keyAddressToCustomName (addr) = ("accountCustomNameByAddr_" + addr) | |
56 | + | ||
57 | + | ||
58 | + | func keyAddressRefBy (addr) = ("accRefBy_" + addr) | |
59 | + | ||
60 | + | ||
61 | + | func keyAddressReferrals (addr) = ("accReferrals_" + addr) | |
62 | + | ||
63 | + | ||
64 | + | let M8_ = 100000000 | |
65 | + | ||
66 | + | func keyAcresStakedAmtByUser (addr) = ("acresStakedAmountByUser_" + addr) | |
67 | + | ||
56 | 68 | ||
57 | 69 | let levels = [10, 20, 40, 80, 150, 250, 400, 700, 1000] | |
58 | 70 | ||
59 | 71 | func getLevelByAcres (acres) = { | |
60 | - | let acr = (acres / | |
72 | + | let acr = (acres / M8_) | |
61 | 73 | func checker (acc,item) = if ((item > acr)) | |
62 | 74 | then acc | |
63 | 75 | else (acc + 1) | |
64 | 76 | ||
65 | 77 | let idx = { | |
66 | 78 | let $l = levels | |
67 | 79 | let $s = size($l) | |
68 | 80 | let $acc0 = 0 | |
69 | 81 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
70 | 82 | then $a | |
71 | 83 | else checker($a, $l[$i]) | |
72 | 84 | ||
73 | 85 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
74 | 86 | then $a | |
75 | 87 | else throw("List size exceeds 10") | |
76 | 88 | ||
77 | 89 | $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) | |
78 | 90 | } | |
79 | 91 | (idx + 1) | |
80 | 92 | } | |
81 | 93 | ||
82 | 94 | ||
83 | - | func keyAddressToCustomName (addr) = ("accountCustomNameByAddr_" + addr) | |
84 | - | ||
85 | - | ||
86 | - | func keyAddressRefBy (addr) = ("accRefBy_" + addr) | |
87 | - | ||
88 | - | ||
89 | - | func keyAddressReferrals (addr) = ("accReferrals_" + addr) | |
90 | - | ||
91 | - | ||
92 | - | func keyAcresStakedAmountByUser (addr) = ("acresStakedAmountByUser_" + addr) | |
93 | - | ||
94 | - | ||
95 | 95 | func walletInternal (userAddressOpt) = { | |
96 | 96 | let addr = addressFromString(userAddressOpt) | |
97 | 97 | let balance = if (isDefined(addr)) | |
98 | 98 | then wavesBalance(value(addr)) | |
99 | 99 | else BalanceDetails(0, 0, 0, 0) | |
100 | 100 | let wlgoldBalance = if (isDefined(addr)) | |
101 | 101 | then assetBalance(value(addr), wlgAssetId) | |
102 | 102 | else 0 | |
103 | - | let customName = valueOrElse(getString( | |
103 | + | let customName = valueOrElse(getString(acres2Contract, keyAddressToCustomName(userAddressOpt)), userAddressOpt) | |
104 | 104 | let refByKey = keyAddressRefBy(userAddressOpt) | |
105 | - | let refBy = getString( | |
106 | - | let refs = valueOrElse(getString( | |
107 | - | let lastTxId = valueOrElse(getString( | |
105 | + | let refBy = getString(acres2Contract, refByKey) | |
106 | + | let refs = valueOrElse(getString(acres2Contract, keyAddressReferrals(userAddressOpt)), "") | |
107 | + | let lastTxId = valueOrElse(getString(acres2Contract, keyLastTxIdByUser(userAddressOpt)), "") | |
108 | 108 | let acresBalance = if (isDefined(addr)) | |
109 | 109 | then assetBalance(value(addr), acresAssetId) | |
110 | 110 | else 0 | |
111 | - | let stakedAcres = valueOrElse(getInteger( | |
111 | + | let stakedAcres = valueOrElse(getInteger(acres2Contract, keyAcresStakedAmtByUser(userAddressOpt)), 0) | |
112 | 112 | let lvl = getLevelByAcres(acresBalance) | |
113 | 113 | [("%s%s__customName__" + customName), ("%s%s__referredBy__" + valueOrElse(refBy, "")), ("%s%s__referrals__" + refs), ("%s%s__lastTxId__" + lastTxId), ("%s%d__wavesBalance__" + toString(balance.available)), ("%s%d__wlgoldBalance__" + toString(wlgoldBalance)), ("%s%d__acresBalance__" + toString(acresBalance)), ("%s%d__stakedAcres__" + toString(stakedAcres)), ("%s%d__currentLvl__" + toString(lvl))] | |
114 | 114 | } | |
115 | 115 | ||
116 | 116 | ||
117 | 117 | @Callable(i) | |
118 | 118 | func constructorV1 (contracts) = if ((i.caller != this)) | |
119 | 119 | then throw("permissions denied") | |
120 | 120 | else { | |
121 | 121 | func descriptor (acc,ignoredItem) = (acc + "%s") | |
122 | 122 | ||
123 | 123 | let descr = { | |
124 | 124 | let $l = contracts | |
125 | 125 | let $s = size($l) | |
126 | 126 | let $acc0 = "" | |
127 | 127 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
128 | 128 | then $a | |
129 | 129 | else descriptor($a, $l[$i]) | |
130 | 130 | ||
131 | 131 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
132 | 132 | then $a | |
133 | 133 | else throw("List size exceeds 10") | |
134 | 134 | ||
135 | 135 | $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) | |
136 | 136 | } | |
137 | - | [StringEntry(keyRestCfg(), makeString(descr :: contracts, SEP)), StringEntry( | |
137 | + | [StringEntry(keyRestCfg(), makeString(descr :: contracts, SEP)), StringEntry(keyRest2Address(), toString(this))] | |
138 | 138 | } | |
139 | 139 | ||
140 | 140 | ||
141 | 141 | ||
142 | 142 | @Callable(i) | |
143 | 143 | func walletInfoREADONLY (userAddressOpt) = $Tuple2(nil, walletInternal(userAddressOpt)) | |
144 | 144 | ||
145 | 145 |
github/deemru/w8io/169f3d6 65.01 ms ◑