tx · 7Y2YBguTGHyXmEUHTZgbTFtoRukTvNPfUiwjesLCxf2s 3NAg879tKUJh949h21umkwiaRQhwZftz1BE: -0.05000000 Waves 2019.09.03 16:53 [659894] smart account 3NAg879tKUJh949h21umkwiaRQhwZftz1BE > SELF 0.00000000 Waves
{ "type": 13, "id": "7Y2YBguTGHyXmEUHTZgbTFtoRukTvNPfUiwjesLCxf2s", "fee": 5000000, "feeAssetId": null, "timestamp": 1567518915458, "version": 1, "sender": "3NAg879tKUJh949h21umkwiaRQhwZftz1BE", "senderPublicKey": "BqY2jhkQCcbidtQdQZu6f9RV3AkFAS8VPToHxwYu1KdJ", "proofs": [ "4uKuxPtq5m8JnFMhCDsRJMuVneQefre5xFNwAR2e1NLDDTFdfNGFqb2riMJA5hUGZzk2oRgvPCtLtfwSPUPDzavw" ], "script": "base64:AAIDAAAAAAAAAAAAAAAUAAAAAAN3dnMAAAAAAAX14QAAAAAAFHRpY2tlckFsbG93ZWRMZXR0ZXJzAgAAABpBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWgAAAAANdGlja2VyRXhhbXBsZQIAAAADQlRDAAAAAA90aWNrZXJNaW5MZW5ndGgAAAAAAAAAAAEAAAAAD3RpY2tlck1heExlbmd0aAAAAAAAAAAABgAAAAAWZGVzY3JpcHRpb25VcGRhdGVQcmljZQkAAGgAAAACAAAAAAAAAAABBQAAAAN3dnMAAAAAD2xpbmtVcGRhdGVQcmljZQkAAGgAAAACAAAAAAAAAAABBQAAAAN3dnMAAAAAEXRpY2tlclVwZGF0ZVByaWNlCQAAaAAAAAIAAAAAAAAAAAIFAAAAA3d2cwAAAAAcdGlja2VyQ2F0YWxvZ3VlT3JhY2xlQWRkcmVzcwkBAAAAHEBleHRyVXNlcihhZGRyZXNzRnJvbVN0cmluZykAAAABAgAAACMzTXhIeFc1VldxNEtyV2NiaEZmeEtyYWZYbTRtTDZyWkhmagAAAAAYdG9rZW5SYXRpbmdPcmFjbGVBZGRyZXNzCQEAAAAcQGV4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2aWNlIGNhbiBvbmx5IGJlIHBhaWQgaW4gd2F2ZXMAAAAAHdsF2Q==", "chainId": 84, "height": 659894, "spentComplexity": 0 } View: original | compacted Prev: 6PhuUpNa9j7NF6xGXe35tR3Pxh4ScukzJ6u1Y2rY9Kts Next: DVu3TitB8GhonEtmF4yZ91Xh9z5dqcFbKBVNxybsuymJ Diff:
Old | New | Differences | |
---|---|---|---|
45 | 45 | case _ => | |
46 | 46 | throw() | |
47 | 47 | } | |
48 | + | ||
49 | + | ||
50 | + | func assetIdFromString (assetId) = if (if ((assetId == "WAVES")) | |
51 | + | then true | |
52 | + | else (assetId == "")) | |
53 | + | then unit | |
54 | + | else fromBase58String(assetId) | |
48 | 55 | ||
49 | 56 | ||
50 | 57 | func isValidTicker (ticker) = { | |
139 | 146 | else false | |
140 | 147 | ||
141 | 148 | ||
149 | + | func getAssetIssuerFromAssetId (assetId) = match assetInfo(fromBase58String(assetId)) { | |
150 | + | case a: Asset => | |
151 | + | a | |
152 | + | case _ => | |
153 | + | unit | |
154 | + | } | |
155 | + | ||
156 | + | ||
142 | 157 | @Callable(i) | |
143 | - | func updateTicker (assetId, | |
158 | + | func updateTicker (assetId,ticker) = { | |
144 | 159 | let payment = extract(i.payment) | |
145 | 160 | let callerAddress = toBase58String(i.caller.bytes) | |
146 | 161 | let issuerTickerKey = ((("issuerTicker_" + "<") + assetId) + ">") | |
147 | 162 | let tickerFromOracle = getStringFromAccount(tickerCatalogueOracleAddress, ticker) | |
163 | + | let assetIssuerAdress = toString(valueOrErrorMessage(assetInfo(fromBase58String(assetId)), "there is no asset with such id").issuer) | |
148 | 164 | if (!(isDefined(payment.assetId))) | |
149 | 165 | then if ((payment.amount >= tickerUpdatePrice)) | |
150 | - | then if ((callerAddress == | |
166 | + | then if ((callerAddress == assetIssuerAdress)) | |
151 | 167 | then if (isUpdateAllowedByRating(assetId)) | |
152 | 168 | then if ((tickerFromOracle == unit)) | |
153 | 169 | then if (isValidTicker(ticker)) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let wvs = 100000000 | |
5 | 5 | ||
6 | 6 | let tickerAllowedLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
7 | 7 | ||
8 | 8 | let tickerExample = "BTC" | |
9 | 9 | ||
10 | 10 | let tickerMinLength = 1 | |
11 | 11 | ||
12 | 12 | let tickerMaxLength = 6 | |
13 | 13 | ||
14 | 14 | let descriptionUpdatePrice = (1 * wvs) | |
15 | 15 | ||
16 | 16 | let linkUpdatePrice = (1 * wvs) | |
17 | 17 | ||
18 | 18 | let tickerUpdatePrice = (2 * wvs) | |
19 | 19 | ||
20 | 20 | let tickerCatalogueOracleAddress = addressFromStringValue("3MxHxW5VWq4KrWcbhFfxKrafXm4mL6rZHfj") | |
21 | 21 | ||
22 | 22 | let tokenRatingOracleAddress = addressFromStringValue("3NADqHoLMbMTfXdP2TeBBSx5mQXePVj3KZm") | |
23 | 23 | ||
24 | 24 | func getStringFromAccount (accountAddress,key) = match getString(accountAddress, key) { | |
25 | 25 | case s: String => | |
26 | 26 | s | |
27 | 27 | case _ => | |
28 | 28 | unit | |
29 | 29 | } | |
30 | 30 | ||
31 | 31 | ||
32 | 32 | func getIntegerFromAccount (accountAddress,key) = match getInteger(accountAddress, key) { | |
33 | 33 | case i: Int => | |
34 | 34 | i | |
35 | 35 | case _ => | |
36 | 36 | 0 | |
37 | 37 | } | |
38 | 38 | ||
39 | 39 | ||
40 | 40 | func isSubstrExist (str,substr) = match indexOf(str, substr) { | |
41 | 41 | case index: Int => | |
42 | 42 | true | |
43 | 43 | case index: Unit => | |
44 | 44 | false | |
45 | 45 | case _ => | |
46 | 46 | throw() | |
47 | 47 | } | |
48 | + | ||
49 | + | ||
50 | + | func assetIdFromString (assetId) = if (if ((assetId == "WAVES")) | |
51 | + | then true | |
52 | + | else (assetId == "")) | |
53 | + | then unit | |
54 | + | else fromBase58String(assetId) | |
48 | 55 | ||
49 | 56 | ||
50 | 57 | func isValidTicker (ticker) = { | |
51 | 58 | let tickerLetters = split(ticker, "") | |
52 | 59 | let tickerLength = size(tickerLetters) | |
53 | 60 | let isLetter1Valid = isSubstrExist(tickerAllowedLetters, tickerLetters[0]) | |
54 | 61 | let isLetter2Valid = isSubstrExist(tickerAllowedLetters, tickerLetters[1]) | |
55 | 62 | let isLetter3Valid = isSubstrExist(tickerAllowedLetters, tickerLetters[2]) | |
56 | 63 | let isLetter4Valid = isSubstrExist(tickerAllowedLetters, tickerLetters[3]) | |
57 | 64 | let isLetter5Valid = isSubstrExist(tickerAllowedLetters, tickerLetters[4]) | |
58 | 65 | let isLetter6Valid = isSubstrExist(tickerAllowedLetters, tickerLetters[5]) | |
59 | 66 | if ((ticker != "")) | |
60 | 67 | then if (if ((tickerLength >= tickerMinLength)) | |
61 | 68 | then (tickerMaxLength >= tickerLength) | |
62 | 69 | else false) | |
63 | 70 | then if ((1 == tickerLength)) | |
64 | 71 | then isLetter1Valid | |
65 | 72 | else if ((2 == tickerLength)) | |
66 | 73 | then if (isLetter1Valid) | |
67 | 74 | then isLetter2Valid | |
68 | 75 | else false | |
69 | 76 | else if ((3 == tickerLength)) | |
70 | 77 | then if (if (isLetter1Valid) | |
71 | 78 | then isLetter2Valid | |
72 | 79 | else false) | |
73 | 80 | then isLetter3Valid | |
74 | 81 | else false | |
75 | 82 | else if ((4 == tickerLength)) | |
76 | 83 | then if (if (if (isLetter1Valid) | |
77 | 84 | then isLetter2Valid | |
78 | 85 | else false) | |
79 | 86 | then isLetter3Valid | |
80 | 87 | else false) | |
81 | 88 | then isLetter4Valid | |
82 | 89 | else false | |
83 | 90 | else if ((5 == tickerLength)) | |
84 | 91 | then if (if (if (if (isLetter1Valid) | |
85 | 92 | then isLetter2Valid | |
86 | 93 | else false) | |
87 | 94 | then isLetter3Valid | |
88 | 95 | else false) | |
89 | 96 | then isLetter4Valid | |
90 | 97 | else false) | |
91 | 98 | then isLetter5Valid | |
92 | 99 | else false | |
93 | 100 | else if ((6 == tickerLength)) | |
94 | 101 | then if (if (if (if (if (isLetter1Valid) | |
95 | 102 | then isLetter2Valid | |
96 | 103 | else false) | |
97 | 104 | then isLetter3Valid | |
98 | 105 | else false) | |
99 | 106 | then isLetter4Valid | |
100 | 107 | else false) | |
101 | 108 | then isLetter5Valid | |
102 | 109 | else false) | |
103 | 110 | then isLetter6Valid | |
104 | 111 | else false | |
105 | 112 | else false | |
106 | 113 | else false | |
107 | 114 | else false | |
108 | 115 | } | |
109 | 116 | ||
110 | 117 | ||
111 | 118 | func isAssetUpdateAllowedByRating (assetId) = { | |
112 | 119 | let assetRatingKey = (("assetRating_" + assetId) + "_1") | |
113 | 120 | let assetRatingValue = getIntegerFromAccount(tokenRatingOracleAddress, assetRatingKey) | |
114 | 121 | let assetRatingTreshold = getIntegerFromAccount(tokenRatingOracleAddress, "assetRating_1") | |
115 | 122 | (assetRatingValue >= assetRatingTreshold) | |
116 | 123 | } | |
117 | 124 | ||
118 | 125 | ||
119 | 126 | func isAssetUpdateAllowedByWeight (assetId) = { | |
120 | 127 | let assetWeightKey = "assetWeight" | |
121 | 128 | let assetWeightValue = getIntegerFromAccount(tokenRatingOracleAddress, assetWeightKey) | |
122 | 129 | let assetWeightTreshold = getIntegerFromAccount(tokenRatingOracleAddress, "assetWeight") | |
123 | 130 | (assetWeightValue >= assetWeightTreshold) | |
124 | 131 | } | |
125 | 132 | ||
126 | 133 | ||
127 | 134 | func isAssetUpdateAllowedByVotes (assetId) = { | |
128 | 135 | let assetVotesKey = "assetVotes" | |
129 | 136 | let assetVotesValue = getIntegerFromAccount(tokenRatingOracleAddress, assetVotesKey) | |
130 | 137 | let assetVotesTreshold = getIntegerFromAccount(tokenRatingOracleAddress, "assetVotes") | |
131 | 138 | (assetVotesValue >= assetVotesTreshold) | |
132 | 139 | } | |
133 | 140 | ||
134 | 141 | ||
135 | 142 | func isUpdateAllowedByRating (assetId) = if (if (isAssetUpdateAllowedByRating(assetId)) | |
136 | 143 | then isAssetUpdateAllowedByWeight(assetId) | |
137 | 144 | else false) | |
138 | 145 | then isAssetUpdateAllowedByVotes(assetId) | |
139 | 146 | else false | |
140 | 147 | ||
141 | 148 | ||
149 | + | func getAssetIssuerFromAssetId (assetId) = match assetInfo(fromBase58String(assetId)) { | |
150 | + | case a: Asset => | |
151 | + | a | |
152 | + | case _ => | |
153 | + | unit | |
154 | + | } | |
155 | + | ||
156 | + | ||
142 | 157 | @Callable(i) | |
143 | - | func updateTicker (assetId, | |
158 | + | func updateTicker (assetId,ticker) = { | |
144 | 159 | let payment = extract(i.payment) | |
145 | 160 | let callerAddress = toBase58String(i.caller.bytes) | |
146 | 161 | let issuerTickerKey = ((("issuerTicker_" + "<") + assetId) + ">") | |
147 | 162 | let tickerFromOracle = getStringFromAccount(tickerCatalogueOracleAddress, ticker) | |
163 | + | let assetIssuerAdress = toString(valueOrErrorMessage(assetInfo(fromBase58String(assetId)), "there is no asset with such id").issuer) | |
148 | 164 | if (!(isDefined(payment.assetId))) | |
149 | 165 | then if ((payment.amount >= tickerUpdatePrice)) | |
150 | - | then if ((callerAddress == | |
166 | + | then if ((callerAddress == assetIssuerAdress)) | |
151 | 167 | then if (isUpdateAllowedByRating(assetId)) | |
152 | 168 | then if ((tickerFromOracle == unit)) | |
153 | 169 | then if (isValidTicker(ticker)) | |
154 | 170 | then WriteSet([DataEntry(issuerTickerKey, ticker)]) | |
155 | 171 | else throw("error#5. Ticker should consist of 1-6 capital Latin characters.") | |
156 | 172 | else throw("error#4. Asset with such ticker is already exist") | |
157 | 173 | else throw("error#3. Too little rating") | |
158 | 174 | else throw("error#2. Only asset issuer can update asset ticker") | |
159 | 175 | else throw("error#2. Insufficient payment for asset ticker update service.") | |
160 | 176 | else throw("error#1. The service can only be paid in waves") | |
161 | 177 | } | |
162 | 178 | ||
163 | 179 |
github/deemru/w8io/169f3d6 36.50 ms ◑