tx · 5qmPbwkaikKYMcSCMBCFeFGmFpeMWrrhnWteeD7WLz8u 3NAg879tKUJh949h21umkwiaRQhwZftz1BE: -0.05000000 Waves 2019.09.03 15:50 [659823] smart account 3NAg879tKUJh949h21umkwiaRQhwZftz1BE > SELF 0.00000000 Waves
{ "type": 13, "id": "5qmPbwkaikKYMcSCMBCFeFGmFpeMWrrhnWteeD7WLz8u", "fee": 5000000, "feeAssetId": null, "timestamp": 1567514996419, "version": 1, "sender": "3NAg879tKUJh949h21umkwiaRQhwZftz1BE", "senderPublicKey": "BqY2jhkQCcbidtQdQZu6f9RV3AkFAS8VPToHxwYu1KdJ", "proofs": [ "Nh5gYuvNM48BeyFunpTX5kKRoQnwbQbTDQbxkeiyn9UmpVbZw81z8YRJHh6zNy2QEXJNZ2kxsFESas8k2FqPQpy" ], "script": "base64:AAIDAAAAAAAAAAAAAAASAAAAAAN3dnMAAAAAAAX14QAAAAAAFHRpY2tlckFsbG93ZWRMZXR0ZXJzAgAAABpBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWgAAAAANdGlja2VyRXhhbXBsZQIAAAADQlRDAAAAAA90aWNrZXJNaW5MZW5ndGgAAAAAAAAAAAEAAAAAD3RpY2tlck1heExlbmd0aAAAAAAAAAAABgAAAAAWZGVzY3JpcHRpb25VcGRhdGVQcmljZQkAAGgAAAACAAAAAAAAAAABBQAAAAN3dnMAAAAAD2xpbmtVcGRhdGVQcmljZQkAAGgAAAACAAAAAAAAAAABBQAAAAN3dnMAAAAAEXRpY2tlclVwZGF0ZVByaWNlCQAAaAAAAAIAAAAAAAAAAAIFAAAAA3d2cwAAAAAcdGlja2VyQ2F0YWxvZ3VlT3JhY2xlQWRkcmVzcwkBAAAAHEBleHRyVXNlcihhZGRyZXNzRnJvbVN0cmluZykAAAABAgAAACMzTXhIeFc1VldxNEtyV2NiaEZmeEtyYWZYbTRtTDZyWkhmagAAAAAYdG9rZW5SYXRpbmdPcmFjbGVBZGRyZXNzCQEAAAAcQGV4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zc2V0IHdpdGggc3VjaCB0aWNrZXIgaXMgYWxyZWFkeSBleGlzdAMJAQAAAA1pc1ZhbGlkVGlja2VyAAAAAQUAAAAGdGlja2VyCQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACBQAAAA9pc3N1ZXJUaWNrZXJLZXkFAAAABnRpY2tlcgUAAAADbmlsCQAAAgAAAAECAAAAP2Vycm9yIzUuIFRpY2tlciBzaG91bGQgY29uc2lzdCBvZiAxLTYgY2FwaXRhbCBMYXRpbiBjaGFyYWN0ZXJzLgkAAAIAAAABAgAAABplcnJvciMzLiBUb28gbGl0dGxlIHJhdGluZwkAAAIAAAABAgAAADJlcnJvciMyLiBPbmx5IGFzc2V0IGlzc3VlciBjYW4gdXBkYXRlIGFzc2V0IHRpY2tlcgkAAAIAAAABAgAAAD5lcnJvciMyLiBJbnN1ZmZpY2llbnQgcGF5bWVudCBmb3IgYXNzZXQgdGlja2VyIHVwZGF0ZSBzZXJ2aWNlLgAAAACuzQzy", "chainId": 84, "height": 659823, "spentComplexity": 0 } View: original | compacted Prev: HvLtM1kddqFVgSvBYijnatrLZWuZ4f4xLWRnLaqKfdUL Next: H62QpgvHt1zZWvrDPPhVGRenYP4o4ehkCLZvmTxmkXbd Diff:
Old | New | Differences | |
---|---|---|---|
108 | 108 | } | |
109 | 109 | ||
110 | 110 | ||
111 | - | func | |
112 | - | let | |
113 | - | let | |
114 | - | let | |
115 | - | ( | |
111 | + | func isAssetUpdateAllowedByRating (assetId) = { | |
112 | + | let assetRatingKey = (("assetRating_" + assetId) + "_1") | |
113 | + | let assetRatingValue = getIntegerFromAccount(tokenRatingOracleAddress, assetRatingKey) | |
114 | + | let assetRatingTreshold = getIntegerFromAccount(tokenRatingOracleAddress, "assetRating_1") | |
115 | + | (assetRatingValue >= assetRatingTreshold) | |
116 | 116 | } | |
117 | 117 | ||
118 | 118 | ||
119 | - | func isUpdateAllowedByRating (assetId) = if (if (isAssetUpdateAllowedByIndicator(assetId, "assetRating")) | |
120 | - | then isAssetUpdateAllowedByIndicator(assetId, "assetWeight") | |
119 | + | func isAssetUpdateAllowedByWeight (assetId) = { | |
120 | + | let assetWeightKey = "assetWeight" | |
121 | + | let assetWeightValue = getIntegerFromAccount(tokenRatingOracleAddress, assetWeightKey) | |
122 | + | let assetWeightTreshold = getIntegerFromAccount(tokenRatingOracleAddress, "assetWeight") | |
123 | + | (assetWeightValue >= assetWeightTreshold) | |
124 | + | } | |
125 | + | ||
126 | + | ||
127 | + | func isAssetUpdateAllowedByVotes (assetId) = { | |
128 | + | let assetVotesKey = "assetVotes" | |
129 | + | let assetVotesValue = getIntegerFromAccount(tokenRatingOracleAddress, assetVotesKey) | |
130 | + | let assetVotesTreshold = getIntegerFromAccount(tokenRatingOracleAddress, "assetVotes") | |
131 | + | (assetVotesValue >= assetVotesTreshold) | |
132 | + | } | |
133 | + | ||
134 | + | ||
135 | + | func isUpdateAllowedByRating (assetId) = if (if (isAssetUpdateAllowedByRating(assetId)) | |
136 | + | then isAssetUpdateAllowedByWeight(assetId) | |
121 | 137 | else false) | |
122 | - | then | |
138 | + | then isAssetUpdateAllowedByVotes(assetId) | |
123 | 139 | else false | |
124 | 140 | ||
125 | 141 |
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 | 48 | ||
49 | 49 | ||
50 | 50 | func isValidTicker (ticker) = { | |
51 | 51 | let tickerLetters = split(ticker, "") | |
52 | 52 | let tickerLength = size(tickerLetters) | |
53 | 53 | let isLetter1Valid = isSubstrExist(tickerAllowedLetters, tickerLetters[0]) | |
54 | 54 | let isLetter2Valid = isSubstrExist(tickerAllowedLetters, tickerLetters[1]) | |
55 | 55 | let isLetter3Valid = isSubstrExist(tickerAllowedLetters, tickerLetters[2]) | |
56 | 56 | let isLetter4Valid = isSubstrExist(tickerAllowedLetters, tickerLetters[3]) | |
57 | 57 | let isLetter5Valid = isSubstrExist(tickerAllowedLetters, tickerLetters[4]) | |
58 | 58 | let isLetter6Valid = isSubstrExist(tickerAllowedLetters, tickerLetters[5]) | |
59 | 59 | if ((ticker != "")) | |
60 | 60 | then if (if ((tickerLength >= tickerMinLength)) | |
61 | 61 | then (tickerMaxLength >= tickerLength) | |
62 | 62 | else false) | |
63 | 63 | then if ((1 == tickerLength)) | |
64 | 64 | then isLetter1Valid | |
65 | 65 | else if ((2 == tickerLength)) | |
66 | 66 | then if (isLetter1Valid) | |
67 | 67 | then isLetter2Valid | |
68 | 68 | else false | |
69 | 69 | else if ((3 == tickerLength)) | |
70 | 70 | then if (if (isLetter1Valid) | |
71 | 71 | then isLetter2Valid | |
72 | 72 | else false) | |
73 | 73 | then isLetter3Valid | |
74 | 74 | else false | |
75 | 75 | else if ((4 == tickerLength)) | |
76 | 76 | then if (if (if (isLetter1Valid) | |
77 | 77 | then isLetter2Valid | |
78 | 78 | else false) | |
79 | 79 | then isLetter3Valid | |
80 | 80 | else false) | |
81 | 81 | then isLetter4Valid | |
82 | 82 | else false | |
83 | 83 | else if ((5 == tickerLength)) | |
84 | 84 | then if (if (if (if (isLetter1Valid) | |
85 | 85 | then isLetter2Valid | |
86 | 86 | else false) | |
87 | 87 | then isLetter3Valid | |
88 | 88 | else false) | |
89 | 89 | then isLetter4Valid | |
90 | 90 | else false) | |
91 | 91 | then isLetter5Valid | |
92 | 92 | else false | |
93 | 93 | else if ((6 == tickerLength)) | |
94 | 94 | then if (if (if (if (if (isLetter1Valid) | |
95 | 95 | then isLetter2Valid | |
96 | 96 | else false) | |
97 | 97 | then isLetter3Valid | |
98 | 98 | else false) | |
99 | 99 | then isLetter4Valid | |
100 | 100 | else false) | |
101 | 101 | then isLetter5Valid | |
102 | 102 | else false) | |
103 | 103 | then isLetter6Valid | |
104 | 104 | else false | |
105 | 105 | else false | |
106 | 106 | else false | |
107 | 107 | else false | |
108 | 108 | } | |
109 | 109 | ||
110 | 110 | ||
111 | - | func | |
112 | - | let | |
113 | - | let | |
114 | - | let | |
115 | - | ( | |
111 | + | func isAssetUpdateAllowedByRating (assetId) = { | |
112 | + | let assetRatingKey = (("assetRating_" + assetId) + "_1") | |
113 | + | let assetRatingValue = getIntegerFromAccount(tokenRatingOracleAddress, assetRatingKey) | |
114 | + | let assetRatingTreshold = getIntegerFromAccount(tokenRatingOracleAddress, "assetRating_1") | |
115 | + | (assetRatingValue >= assetRatingTreshold) | |
116 | 116 | } | |
117 | 117 | ||
118 | 118 | ||
119 | - | func isUpdateAllowedByRating (assetId) = if (if (isAssetUpdateAllowedByIndicator(assetId, "assetRating")) | |
120 | - | then isAssetUpdateAllowedByIndicator(assetId, "assetWeight") | |
119 | + | func isAssetUpdateAllowedByWeight (assetId) = { | |
120 | + | let assetWeightKey = "assetWeight" | |
121 | + | let assetWeightValue = getIntegerFromAccount(tokenRatingOracleAddress, assetWeightKey) | |
122 | + | let assetWeightTreshold = getIntegerFromAccount(tokenRatingOracleAddress, "assetWeight") | |
123 | + | (assetWeightValue >= assetWeightTreshold) | |
124 | + | } | |
125 | + | ||
126 | + | ||
127 | + | func isAssetUpdateAllowedByVotes (assetId) = { | |
128 | + | let assetVotesKey = "assetVotes" | |
129 | + | let assetVotesValue = getIntegerFromAccount(tokenRatingOracleAddress, assetVotesKey) | |
130 | + | let assetVotesTreshold = getIntegerFromAccount(tokenRatingOracleAddress, "assetVotes") | |
131 | + | (assetVotesValue >= assetVotesTreshold) | |
132 | + | } | |
133 | + | ||
134 | + | ||
135 | + | func isUpdateAllowedByRating (assetId) = if (if (isAssetUpdateAllowedByRating(assetId)) | |
136 | + | then isAssetUpdateAllowedByWeight(assetId) | |
121 | 137 | else false) | |
122 | - | then | |
138 | + | then isAssetUpdateAllowedByVotes(assetId) | |
123 | 139 | else false | |
124 | 140 | ||
125 | 141 | ||
126 | 142 | @Callable(i) | |
127 | 143 | func updateTicker (assetId,issuerAddress,ticker) = { | |
128 | 144 | let payment = extract(i.payment) | |
129 | 145 | let callerAddress = toBase58String(i.caller.bytes) | |
130 | 146 | let issuerTickerKey = ((("issuerTicker_" + "<") + assetId) + ">") | |
131 | 147 | let tickerFromOracle = getStringFromAccount(tickerCatalogueOracleAddress, ticker) | |
132 | 148 | if (isDefined(payment.assetId)) | |
133 | 149 | then throw("error#1. The service can only be paid in waves") | |
134 | 150 | else if ((payment.amount >= tickerUpdatePrice)) | |
135 | 151 | then if ((callerAddress == issuerAddress)) | |
136 | 152 | then if (isUpdateAllowedByRating(assetId)) | |
137 | 153 | then if ((tickerFromOracle != unit)) | |
138 | 154 | then throw("error#4. Asset with such ticker is already exist") | |
139 | 155 | else if (isValidTicker(ticker)) | |
140 | 156 | then WriteSet([DataEntry(issuerTickerKey, ticker)]) | |
141 | 157 | else throw("error#5. Ticker should consist of 1-6 capital Latin characters.") | |
142 | 158 | else throw("error#3. Too little rating") | |
143 | 159 | else throw("error#2. Only asset issuer can update asset ticker") | |
144 | 160 | else throw("error#2. Insufficient payment for asset ticker update service.") | |
145 | 161 | } | |
146 | 162 | ||
147 | 163 |
github/deemru/w8io/169f3d6 35.16 ms ◑