tx · 5uLGfSw1hpNrPzcAmFhwN9DgJEwxqmQr5kCLRGHMrtsB

3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H:  -0.01000000 Waves

2023.01.10 16:26 [2398899] smart account 3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H > SELF 0.00000000 Waves

{ "type": 13, "id": "5uLGfSw1hpNrPzcAmFhwN9DgJEwxqmQr5kCLRGHMrtsB", "fee": 1000000, "feeAssetId": null, "timestamp": 1673357267666, "version": 2, "chainId": 84, "sender": "3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H", "senderPublicKey": "BDeCphaaC4MZvfmbJqQZ78EvuEBZTJ1VEW7fbxue8BUu", "proofs": [ "2zPJjkfh8jrVZW59pUEeE3kVexZFdsHVHB4tr22kSAxDPebj3mcCB1L7u45wN4B143Y1gH75GpYoVY2PFeeBztNu" ], "script": "base64:BgIVCAISCQoHCAgBCAgIARIECgIBARIAGgAJc2VwYXJhdG9yAgFfAAdrR29hbFAxAgZnb2FsUDEAB2tHb2FsUDICBmdvYWxQMgALa0RlZmxlY3Rpb24CCmRlZmxlY3Rpb24ACGtWZXJ0ZXgxAgd2ZXJ0ZXgxAAhrVmVydGV4MgIHdmVydGV4MgAIa1ZlcnRleDMCB3ZlcnRleDMAB2tNYXhCZXQCBm1heEJldAEJcmFuZG9taXplAgVieXRlcwVyYW5nZQQEaGFzaAkA9wMBBQVieXRlcwQFaW5kZXgJALEJAQUEaGFzaAkAagIFBWluZGV4BQVyYW5nZQEIZ2V0UG9pbnQBBWJ5dGVzBAF4CQEJcmFuZG9taXplAgkAyQECBQVieXRlcwkAaQIJAMgBAQUFYnl0ZXMAAgBkBAF5CQEJcmFuZG9taXplAgkAzAECBQVieXRlcwkAaQIJAMgBAQUFYnl0ZXMAAgBkCQCUCgIFAXgFAXkBEWdldEdvYWxMaW5lUG9pbnRzAAQCcDEJALUJAgkBEUBleHRyTmF0aXZlKDEwNTMpAgUEdGhpcwUHa0dvYWxQMQUJc2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zAgCCAUCcDECXzIFA25pbAkAzAgCCQCRAwIIBQFpCHBheW1lbnRzAAAFA25pbAMJAAACBQNyZXMFA3JlcwUDbmlsCQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAHyEf6w=", "height": 2398899, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: BaKhAD5RipGUyouCee65jYzkxiULD75dML129Q86xZzk Next: DYFuVVcPjdoGKxuJm7q9scAnevLJVBChBQhqdgF9NwAT Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let separator = "_"
55
66 let kGoalP1 = "goalP1"
77
88 let kGoalP2 = "goalP2"
99
1010 let kDeflection = "deflection"
1111
1212 let kVertex1 = "vertex1"
1313
1414 let kVertex2 = "vertex2"
1515
1616 let kVertex3 = "vertex3"
1717
1818 let kMaxBet = "maxBet"
1919
2020 func randomize (bytes,range) = {
2121 let hash = sha256(bytes)
2222 let index = toInt(hash)
2323 (index % range)
2424 }
2525
2626
2727 func getPoint (bytes) = {
2828 let x = randomize(take(bytes, (size(bytes) / 2)), 100)
2929 let y = randomize(takeRight(bytes, (size(bytes) / 2)), 100)
3030 $Tuple2(x, y)
3131 }
3232
3333
3434 func getGoalLinePoints () = {
3535 let p1 = split(getStringValue(this, kGoalP1), separator)
3636 let p2 = split(getStringValue(this, kGoalP2), separator)
3737 $Tuple2($Tuple2(parseIntValue(p1[0]), parseIntValue(p1[1])), $Tuple2(parseIntValue(p2[0]), parseIntValue(p2[1])))
3838 }
3939
4040
4141 func getDeflection () = getIntegerValue(this, kDeflection)
4242
4343
4444 func getMaxBet () = getIntegerValue(this, kMaxBet)
4545
4646
4747 func getPolygonPoints () = {
4848 let p1 = split(getStringValue(this, kVertex1), separator)
4949 let p2 = split(getStringValue(this, kVertex2), separator)
5050 let p3 = split(getStringValue(this, kVertex3), separator)
5151 $Tuple3($Tuple2(parseIntValue(p1[0]), parseIntValue(p1[1])), $Tuple2(parseIntValue(p2[0]), parseIntValue(p2[1])), $Tuple2(parseIntValue(p3[0]), parseIntValue(p3[1])))
5252 }
5353
5454
5555 func getLine (p1,p2) = {
5656 let a = (p2._2 - p1._2)
5757 let b = (p1._1 - p2._1)
5858 let c = ((p1._2 * (p2._1 + p1._1)) - (p1._1 * (p1._2 + p2._2)))
5959 $Tuple3(a, b, c)
6060 }
6161
6262
6363 func getOrthoLine (p1,nVec) = {
6464 let a = nVec._2
6565 let b = -(nVec._1)
6666 let c = ((nVec._1 * p1._2) - (nVec._2 * p1._1))
6767 $Tuple3(a, b, c)
6868 }
6969
7070
7171 func getVec (start,end) = {
7272 let x = (end._1 - start._1)
7373 let y = (end._2 - start._2)
7474 $Tuple2(x, y)
7575 }
7676
7777
7878 func mulVectors (vA,vB) = ((vA._1 * vB._2) - (vA._2 * vB._1))
7979
8080
8181 func getLineLength (p1,p2) = {
8282 let a = pow((p2._1 - p1._1), 0, 2, 0, 0, DOWN)
8383 let b = pow((p2._2 - p1._2), 0, 2, 0, 0, DOWN)
8484 sqrt((a + b), 0, 0, DOWN)
8585 }
8686
8787
8888 func calcCrosses (accum,nextValue) = {
8989 let vp1p2 = getVec(nextValue[0]._1, nextValue[0]._2)
9090 let vp1p3 = getVec(nextValue[0]._1, nextValue[1]._1)
9191 let vp1p4 = getVec(nextValue[0]._1, nextValue[1]._2)
9292 let vp3p4 = getVec(nextValue[1]._1, nextValue[1]._2)
9393 let vp3p1 = getVec(nextValue[1]._1, nextValue[0]._1)
9494 let vp3p2 = getVec(nextValue[1]._1, nextValue[0]._2)
9595 let v1 = mulVectors(vp3p4, vp3p1)
9696 let v2 = mulVectors(vp3p4, vp3p2)
9797 let v3 = mulVectors(vp1p2, vp1p3)
9898 let v4 = mulVectors(vp1p2, vp1p4)
9999 if (if ((0 > (v1 * v2)))
100100 then (0 > (v3 * v4))
101101 else false)
102102 then (accum + 1)
103103 else accum
104104 }
105105
106106
107107 func isInside (p1,segment1,segment2,segment3) = {
108108 let segmentRay = $Tuple2(p1, $Tuple2(p1._1, 0))
109109 let arr = [[segmentRay, segment1], [segmentRay, segment2], [segmentRay, segment3]]
110110 let count = {
111111 let $l = arr
112112 let $s = size($l)
113113 let $acc0 = 0
114114 func $f0_1 ($a,$i) = if (($i >= $s))
115115 then $a
116116 else calcCrosses($a, $l[$i])
117117
118118 func $f0_2 ($a,$i) = if (($i >= $s))
119119 then $a
120120 else throw("List size exceeds 3")
121121
122122 $f0_2($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3)
123123 }
124124 ((count % 2) == 1)
125125 }
126126
127127
128128 func isPointInLine (p1,line) = ((((p1._1 * line._1) + (p1._2 * line._2)) + line._3) == 0)
129129
130130
131131 func isPointInDeflection (p1,line) = {
132132 let $t059546056 = line
133133 let a1 = $t059546056._1
134134 let b1 = $t059546056._2
135135 let c1 = $t059546056._3
136136 let $t060596194 = getOrthoLine(p1, $Tuple2(a1, b1))
137137 let aNorm = $t060596194._1
138138 let bNorm = $t060596194._2
139139 let cNorm = $t060596194._3
140140 let d = mulVectors($Tuple2(a1, b1), $Tuple2(aNorm, bNorm))
141141 let dx = mulVectors($Tuple2(-(c1), b1), $Tuple2(-(cNorm), bNorm))
142142 let dy = mulVectors($Tuple2(a1, -(c1)), $Tuple2(aNorm, -(cNorm)))
143143 let xRes = fraction(1, dx, d)
144144 let yRes = fraction(1, dy, d)
145145 let lineLen = getLineLength(p1, $Tuple2(xRes, yRes))
146146 (getDeflection() >= lineLen)
147147 }
148148
149149
150150 func isPointInPolygon (p1,vertex1,vertex2,vertex3) = {
151151 let segment1 = $Tuple2(vertex1, vertex2)
152152 let segment2 = $Tuple2(vertex2, vertex3)
153153 let segment3 = $Tuple2(vertex3, vertex1)
154154 if (if (if ((p1 == vertex1))
155155 then true
156156 else (p1 == vertex2))
157157 then true
158158 else (p1 == vertex3))
159159 then true
160160 else isInside(p1, segment1, segment2, segment3)
161161 }
162162
163163
164164 func calcRewardMultiplier (inLine,inPolygon,inDeflection) = if (if (inLine)
165165 then inPolygon
166166 else false)
167167 then 10
168168 else if (if (inDeflection)
169169 then inPolygon
170170 else false)
171171 then 8
172172 else if (inLine)
173173 then 6
174174 else if (inPolygon)
175175 then 4
176176 else if (inDeflection)
177177 then 2
178178 else 1
179179
180180
181181 func validatePayment (paymentAsset,paymentAmount) = if (if ((paymentAsset == unit))
182182 then (getMaxBet() >= paymentAmount)
183183 else false)
184184 then unit
185185 else throw("Incorrect payment")
186186
187187
188188 @Callable(i)
189189 func setLotteryParams (goalP1,goalP2,deflection,vertex1,vertex2,vertex3,maxBet) = [StringEntry(kGoalP1, goalP1), StringEntry(kGoalP2, goalP2), IntegerEntry(kDeflection, deflection), StringEntry(kVertex1, vertex1), StringEntry(kVertex2, vertex2), StringEntry(kVertex3, vertex3), IntegerEntry(kMaxBet, maxBet)]
190190
191191
192192
193193 @Callable(i)
194194 func tryToWin (p1x,p1y) = {
195195 let $t089109028 = $Tuple2(i.payments[0].assetId, value(i.payments[0].amount))
196196 let paymentAsset = $t089109028._1
197197 let paymentAmount = $t089109028._2
198198 valueOrElse(validatePayment(paymentAsset, paymentAmount), {
199199 let p1 = $Tuple2(p1x, p1y)
200200 let $t092589379 = getGoalLinePoints()
201201 let p2 = $t092589379._1
202202 let p3 = $t092589379._2
203203 let $t093849483 = getPolygonPoints()
204204 let p4 = $t093849483._1
205205 let p5 = $t093849483._2
206206 let p6 = $t093849483._3
207207 let $t094889580 = getLine(p2, p3)
208208 let a1 = $t094889580._1
209209 let b1 = $t094889580._2
210210 let c1 = $t094889580._3
211211 let inLine = isPointInLine(p1, $Tuple3(a1, b1, c1))
212212 let inPolygon = isPointInPolygon(p1, p4, p5, p6)
213213 let inDeflection = isPointInDeflection(p1, $Tuple3(a1, b1, c1))
214214 if (if (if (inLine)
215215 then true
216216 else inDeflection)
217217 then true
218218 else inPolygon)
219219 then {
220220 let multiplier = calcRewardMultiplier(inLine, inPolygon, inDeflection)
221221 let reward = (paymentAmount * multiplier)
222222 [IntegerEntry("multiplier", multiplier), ScriptTransfer(i.originCaller, reward, unit)]
223223 }
224224 else nil
225225 })
226226 }
227227
228228
229229
230230 @Callable(i)
231231 func startGame () = {
232232 let p1 = getPoint(i.transactionId)
233233 let res = invoke(this, "tryToWin", [p1._1, p1._2], [i.payments[0]])
234234 if ((res == res))
235235 then nil
236236 else throw("Strict value is not equal to itself.")
237237 }
238238
239239

github/deemru/w8io/169f3d6 
75.85 ms