tx · HEoua9dKVzD4nMG5ByCNUW6Ject6jVUzKK17XKMsGVVZ

3NCBtz3MDVBU6G54EAvHRRQ6k2YE6TCuPUv:  -0.01500000 Waves

2019.10.12 12:48 [716510] smart account 3NCBtz3MDVBU6G54EAvHRRQ6k2YE6TCuPUv > SELF 0.00000000 Waves

{ "type": 13, "id": "HEoua9dKVzD4nMG5ByCNUW6Ject6jVUzKK17XKMsGVVZ", "fee": 1500000, "feeAssetId": null, "timestamp": 1570873725222, "version": 1, "sender": "3NCBtz3MDVBU6G54EAvHRRQ6k2YE6TCuPUv", "senderPublicKey": "9ft3D8mA7Qj2tvLPBg2resprWt2Gj2yvuanKNshrY6xb", "proofs": [ "45FmnpS7LJRfvbV3ZMknz64Rxn5G75zrVvk5uW4RqYUu2p8g9UMC3zSKdF6KLKJR3QvZE94ZKPyYPz1XioWrW9UE" ], "script": "base64:AAIDAAAAAAAAAAkIARIAEgMKAQgAAAAAAAAAAgAAAAFpAQAAAAFhAAAAAAQAAAANb3JhY2xlQWRkcmVzcwIAAAAjM040VzcxZjhCaURFSDk2RlNteEhINkdCb0FtUmh3OUFFcnEEAAAACWV1cm9QcmljZQQAAAAHJG1hdGNoMAkABB0AAAACCQEAAAAcQGV4dHJVc2VyKGFkZHJlc3NGcm9tU3RyaW5nKQAAAAEFAAAADW9yYWNsZUFkZHJlc3MCAAAAA0VVUgMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhCQAAAgAAAAECAAAAGENvdWxkbid0IGZpbmQgRXVybyBQcmljZQQAAAANZXVyb1ByaWNlTGlzdAkABLUAAAACBQAAAAlldXJvUHJpY2UCAAAAAS4EAAAACmV1cm9QcmljZTIJAAEsAAAAAgkAAZEAAAACBQAAAA1ldXJvUHJpY2VMaXN0AAAAAAAAAAAACQABkQAAAAIFAAAADWV1cm9QcmljZUxpc3QAAAAAAAAAAAEEAAAACmV1cm9QcmljZTMJAQAAAA1wYXJzZUludFZhbHVlAAAAAQkAAS8AAAACBQAAAApldXJvUHJpY2UyAAAAAAAAAAAEBAAAAAdhbW91bnQxCQAAaAAAAAIAAAAAAAX14QAAAAAAAAX14QAEAAAAB3dhdmVzSWQJAAPrAAAAAgkBAAAAHEBleHRyVXNlcihhZGRyZXNzRnJvbVN0cmluZykAAAABBQAAAA1vcmFjbGVBZGRyZXNzAQAAAAQTq9kzBAAAAAthbWJhc3NhZG9yMQEAAAAg27TPUj36Wh4UzoIbdIokDoBJ0cVnPSfudcacjaZH5x4JAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAICAAAACWV1cm9QcmljZQUAAAAJZXVyb1ByaWNlCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACAgAAAApldXJvUHJpY2UyBQAAAApldXJvUHJpY2UyCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACAgAAAApldXJvUHJpY2UzBQAAAApldXJvUHJpY2UzCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACAgAAAAdBbW91bnQxBQAAAAd3YXZlc0lkCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACAgAAAAt0b0Jhc2U1OFB1YgkAAlgAAAABBQAAAAthbWJhc3NhZG9yMQUAAAADbmlsAAAAAWkBAAAAAWIAAAABAAAABmNvdXNyZQkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgIAAAADRVVSBQAAAAZjb3VzcmUFAAAAA25pbAAAAABzxfB5", "chainId": 84, "height": 716510, "spentComplexity": 0 } View: original | compacted Prev: Bmx2sW7boaYrPAWkXw2pRc7ukuZ2jjpqhtBk4iERqoRC Next: none Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let day = 1440
5-
6-let WAVES = unit
7-
8-let wBTC = base58'8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS'
9-
10-let wEUR = base58'Gtb1WRznfchDnTh37ezoDTJ4wcoKaRsKqKjJjy7nm2zU'
11-
12-let wUSD = base58'Ft8X1v1LTa1ABafufpaCWyVj8KkaxUWE6xBhW6sNFJck'
13-
14-let stateOpen = "Opened"
15-
16-let stateSuggested = "Suggested"
17-
18-let stateCancel = "Canceled"
19-
20-let stateInProgress = "InProgress"
21-
22-let stateWait4Confirm = "WaitForConfirmation"
23-
24-let stateComplete = "Completed"
25-
26-let stateDispute = "Dispute"
27-
28-let stateDisputeResolved = "DisputeResolved"
29-
30-let client = "CMR"
31-
32-let freelancer = "FL"
33-
34-let ambassador1 = base58'1'
35-
36-let ambassador2 = base58'1'
37-
38-let ambassador3 = base58'1'
39-
40-let ambassador4 = base58'1'
41-
42-let ambassador5 = base58'1'
43-
44-func AuctionIdDataKey (auctionId) = (auctionId + "_AuctionData")
454
465
47-func AssetNameToBase58 (auctionAssetName) = if ((auctionAssetName == "WAVES"))
48- then WAVES
49- else if ((auctionAssetName == "BTC"))
50- then wBTC
51- else if ((auctionAssetName == "EUR"))
52- then wEUR
53- else if ((auctionAssetName == "USD"))
54- then wUSD
55- else throw("Incorrect Asset Id")
56-
57-
58-func timeCheck (currentTime,startTime,expirationTime) = ((currentTime - startTime) > expirationTime)
59-
60-
61-func increaseFreezedBalance (pmtAssetName,auctionPrice) = {
62- let keyFreezedFunds = getInteger(this, (pmtAssetName + "_Freezed"))
63- let currentFreezedBalance = match keyFreezedFunds {
64- case a: Int =>
65- a
66- case _ =>
67- 0
68- }
69- (currentFreezedBalance + auctionPrice)
70- }
71-
72-
73-func decreaseFreezedBalance (pmtAssetName,auctionPrice) = {
74- let keyFreezedFunds = getInteger(this, (pmtAssetName + "_Freezed"))
75- let currentFreezedBalance = match keyFreezedFunds {
76- case a: Int =>
77- a
78- case _ =>
79- 0
80- }
81- let a = (currentFreezedBalance - auctionPrice)
82- if ((a > 0))
83- then a
84- else throw("Freezed amount couldn't be less than 0")
85- }
86-
87-
88-func freelancerIsRegistered (callerPub) = {
89- let freelancerIsRegistered = getString(this, (callerPub + "_Freelancer"))
90- match freelancerIsRegistered {
91- case a: String =>
92- callerPub
93- case _ =>
94- throw("Only registered users can make bets")
95- }
96- }
97-
98-
99-func createAuctionPriceCheck (pmtAmount) = if ((pmtAmount > 0))
100- then pmtAmount
101- else throw("Amount must be higher then 0")
102-
103-
104-func getAuctionState (auctionId) = {
105- let valueState = getString(this, (auctionId + "_State"))
106- match valueState {
6+@Callable(i)
7+func a () = {
8+ let oracleAddress = "3N4W71f8BiDEH96FSmxHH6GBoAmRhw9AErq"
9+ let euroPrice = match getString(addressFromStringValue(oracleAddress), "EUR") {
10710 case a: String =>
10811 a
10912 case _ =>
110- throw("Auction State was not found")
13+ throw("Couldn't find Euro Price")
11114 }
112- }
113-
114-
115-func getAuctionClientPub (auctionId) = {
116- let valueClient = getString(this, (auctionId + "_AuctionClient"))
117- let a = match valueClient {
118- case a: String =>
119- a
120- case _ =>
121- throw("Auction Client was not found")
122- }
123- fromBase58String(a)
124- }
125-
126-
127-func getAuctionStartTime (auctionId) = {
128- let valueAuctionStart = getInteger(this, (auctionId + "_AuctionStart"))
129- match valueAuctionStart {
130- case a: Int =>
131- a
132- case _ =>
133- throw("Auction Start time was not found")
134- }
135- }
136-
137-
138-func getAuctionDurationTime (auctionId) = {
139- let valueauctionDuration = getInteger(this, (auctionId + "_AuctionDuration"))
140- match valueauctionDuration {
141- case a: Int =>
142- a
143- case _ =>
144- throw("Auction duration time was not found")
145- }
146- }
147-
148-
149-func getAuctionJobPerformanceTime (auctionId) = {
150- let valueBlocksForExecution = getInteger(this, (auctionId + "_JobPerformance"))
151- match valueBlocksForExecution {
152- case a: Int =>
153- a
154- case _ =>
155- throw("Auction job performance time was not found")
156- }
157- }
158-
159-
160-func getAuctionAssetName (auctionId) = {
161- let valueAssetName = getString(this, (auctionId + "_AssetName"))
162- match valueAssetName {
163- case a: String =>
164- a
165- case _ =>
166- throw("Auction asset name was not found")
167- }
168- }
169-
170-
171-func getAuctionPrice (auctionId) = {
172- let valuePrice = getInteger(this, (auctionId + "_Price"))
173- match valuePrice {
174- case a: Int =>
175- a
176- case _ =>
177- throw("Auction price was not found")
178- }
179- }
180-
181-
182-func getAuctionFreelancerPub (auctionId) = {
183- let valueClient = getString(this, (auctionId + "_HiredFreelancer"))
184- let a = match valueClient {
185- case a: String =>
186- a
187- case _ =>
188- throw("Auction Client was not found")
189- }
190- fromBase58String(a)
191- }
192-
193-
194-@Callable(i)
195-func freelancerSignUp (info) = {
196- let userPublicKey = toBase58String(i.callerPublicKey)
197- let alreadyRegistered = getString(this, (userPublicKey + "_Freelancer"))
198- if (isDefined(alreadyRegistered))
199- then throw("User already registered")
200- else WriteSet([DataEntry((userPublicKey + "_Freelancer"), info)])
15+ let euroPriceList = split(euroPrice, ".")
16+ let euroPrice2 = (euroPriceList[0] + euroPriceList[1])
17+ let euroPrice3 = parseIntValue(take(euroPrice2, 4))
18+ let amount1 = (100000000 * 100000000)
19+ let wavesId = assetBalance(addressFromStringValue(oracleAddress), base58'WAVES')
20+ let ambassador1 = base58'FneCJqM5BP2eAuyteMiuEEHYALrE4axhEfcpHVGbdr5s'
21+ WriteSet([DataEntry("euroPrice", euroPrice), DataEntry("euroPrice2", euroPrice2), DataEntry("euroPrice3", euroPrice3), DataEntry("Amount1", wavesId), DataEntry("toBase58Pub", toBase58String(ambassador1))])
20122 }
20223
20324
20425
20526 @Callable(i)
206-func clientSignUp (info) = {
207- let userPublicKey = toBase58String(i.callerPublicKey)
208- let alreadyRegistered = getString(this, (userPublicKey + "_Client"))
209- if (isDefined(alreadyRegistered))
210- then throw("User already registered")
211- else WriteSet([DataEntry((userPublicKey + "_Client"), info)])
212- }
27+func b (cousre) = WriteSet([DataEntry("EUR", cousre)])
21328
214-
215-
216-@Callable(i)
217-func createAuction (jobExecutionDays,auctionDurationDays,auctionInfo) = {
218- let auctionId = toBase58String(i.transactionId)
219- let auctionClient = toBase58String(i.callerPublicKey)
220- let pmt = extract(i.payment)
221- let pmtAmount = pmt.amount
222- let auctionPrice = createAuctionPriceCheck(pmtAmount)
223- let auctionStart = height
224- let auctionDurationBlocks = (auctionDurationDays * day)
225- let blocksForExecution = (jobExecutionDays * day)
226- let pmtAssetName = if (!(isDefined(pmt.assetId)))
227- then "WAVES"
228- else if ((pmt.assetId == wBTC))
229- then "BTC"
230- else if ((pmt.assetId == wEUR))
231- then "EUR"
232- else if ((pmt.assetId == wUSD))
233- then "USD"
234- else throw("AssetId is incorrect")
235- let newFreezedBalance = increaseFreezedBalance(pmtAssetName, auctionPrice)
236- WriteSet([DataEntry((auctionId + "_State"), stateOpen), DataEntry((auctionId + "_Info"), auctionInfo), DataEntry((auctionId + "_AuctionClient"), auctionClient), DataEntry((auctionId + "_AuctionStart"), auctionStart), DataEntry((auctionId + "_AuctionDuration"), auctionDurationBlocks), DataEntry((auctionId + "_JobPerformance"), blocksForExecution), DataEntry((auctionId + "_AssetName"), pmtAssetName), DataEntry((auctionId + "_Price"), auctionPrice), DataEntry((pmtAssetName + "_Freezed"), newFreezedBalance)])
237- }
238-
239-
240-
241-@Callable(i)
242-func makeBid (auctionId,betPrice) = {
243- let callerPub = toBase58String(i.callerPublicKey)
244- let betTime = height
245- let auctionState = getAuctionState(auctionId)
246- let auctionClient = getAuctionClientPub(auctionId)
247- let auctionStart = getAuctionStartTime(auctionId)
248- let auctionDuration = getAuctionDurationTime(auctionId)
249- let auctionBlocksForExecution = getAuctionJobPerformanceTime(auctionId)
250- let auctionAssetName = getAuctionAssetName(auctionId)
251- let auctionPrice = getAuctionPrice(auctionId)
252- let auctionAssetId58 = AssetNameToBase58(auctionAssetName)
253- let newFreelancer = freelancerIsRegistered(callerPub)
254- let dAppCommission = ((auctionPrice * 3) / 100)
255- let newFreezedBalance = decreaseFreezedBalance(auctionAssetName, auctionPrice)
256- let auctionTimeisOver = timeCheck(betTime, auctionStart, auctionDuration)
257- if (auctionTimeisOver)
258- then if ((auctionState == stateOpen))
259- then ScriptResult(WriteSet([DataEntry((auctionId + "_State"), stateCancel), DataEntry((auctionAssetName + "_Freezed"), newFreezedBalance)]), TransferSet([ScriptTransfer(addressFromPublicKey(auctionClient), (auctionPrice - dAppCommission), auctionAssetId58)]))
260- else if ((auctionState == stateSuggested))
261- then {
262- let auctionLowestBidder = {
263- let valueLowestBidder = getString(this, (auctionId + "_LowestBidderPub"))
264- match valueLowestBidder {
265- case a: String =>
266- a
267- case _ =>
268- throw("Auction lowest bidder was not found")
269- }
270- }
271- let newAuctionPrice = {
272- let valueNewAuctionPrice = getInteger(this, ((auctionId + "_Bid_") + auctionLowestBidder))
273- match valueNewAuctionPrice {
274- case a: Int =>
275- a
276- case _ =>
277- throw("Auction lowest bid was not found")
278- }
279- }
280- let amountDifference = ((auctionPrice - newAuctionPrice) - dAppCommission)
281- ScriptResult(WriteSet([DataEntry((auctionId + "_State"), stateInProgress), DataEntry((auctionId + "_HiredFreelancer"), auctionLowestBidder), DataEntry((auctionId + "_Price"), newAuctionPrice)]), TransferSet([ScriptTransfer(addressFromPublicKey(auctionClient), amountDifference, auctionAssetId58)]))
282- }
283- else throw("Incorrect auction state")
284- else if ((auctionState == stateOpen))
285- then WriteSet([DataEntry(((auctionId + "_Bid_") + newFreelancer), betPrice), DataEntry((auctionId + "_State"), stateSuggested), DataEntry((auctionId + "_LowestBidderPub"), callerPub)])
286- else if ((auctionState == stateSuggested))
287- then {
288- let currentLowestBidderPub = {
289- let lowestBidder = getString(this, (auctionId + "_LowestBidderPub"))
290- match lowestBidder {
291- case a: String =>
292- a
293- case _ =>
294- throw("Auction lowest bidder was not found")
295- }
296- }
297- let newLowestBidderPub = {
298- let valueCurrentLowestBid = getInteger(this, ((auctionId + "_Bid_") + currentLowestBidderPub))
299- let currentLowestBid = match valueCurrentLowestBid {
300- case a: Int =>
301- a
302- case _ =>
303- throw("Auction lowest bid was not found")
304- }
305- if ((currentLowestBid > betPrice))
306- then newFreelancer
307- else currentLowestBidderPub
308- }
309- WriteSet([DataEntry((auctionId + "_LowestBidderPub"), newLowestBidderPub), DataEntry(((auctionId + "_Bid_") + newFreelancer), betPrice)])
310- }
311- else throw(((((("Incorrect jobId state. Now: " + auctionState) + ", must be: ") + stateOpen) + " or ") + stateSuggested))
312- }
313-
314-
315-
316-@Callable(i)
317-func chooseFreelancer (auctionId,freelancerPub) = {
318- let callerPub = extract(i.callerPublicKey)
319- let betTime = height
320- let auctionState = getAuctionState(auctionId)
321- let auctionClient = getAuctionClientPub(auctionId)
322- let auctionStart = getAuctionStartTime(auctionId)
323- let auctionDuration = getAuctionDurationTime(auctionId)
324- let auctionAssetName = getAuctionAssetName(auctionId)
325- let auctionPrice = getAuctionPrice(auctionId)
326- let auctionAssetId58 = AssetNameToBase58(auctionAssetName)
327- let freelancerBidAmount = {
328- let keyFreelancerBid = ((auctionId + "_Bid_") + freelancerPub)
329- let valueFreelacerBid = getInteger(this, keyFreelancerBid)
330- match valueFreelacerBid {
331- case a: Int =>
332- a
333- case _ =>
334- throw("Freelancer's bet was not found")
335- }
336- }
337- let dAppCommission = ((freelancerBidAmount * 3) / 100)
338- let auctionTimeisOver = timeCheck(betTime, auctionStart, auctionDuration)
339- if ((callerPub == auctionClient))
340- then if (auctionTimeisOver)
341- then if ((auctionState == stateOpen))
342- then {
343- let newFreezedBalance = decreaseFreezedBalance(auctionAssetName, auctionPrice)
344- ScriptResult(WriteSet([DataEntry((auctionId + "_State"), stateCancel), DataEntry((auctionAssetName + "_Freezed"), newFreezedBalance)]), TransferSet([ScriptTransfer(addressFromPublicKey(auctionClient), (auctionPrice - dAppCommission), auctionAssetId58)]))
345- }
346- else if ((auctionState == stateSuggested))
347- then {
348- let auctionLowestBidder = {
349- let valueLowestBidder = getString(this, (auctionId + "_LowestBidderPub"))
350- match valueLowestBidder {
351- case a: String =>
352- a
353- case _ =>
354- throw("Auction lowest bidder was not found")
355- }
356- }
357- let newAuctionPrice = {
358- let valueNewAuctionPrice = getInteger(this, ((auctionId + "_Bid_") + auctionLowestBidder))
359- match valueNewAuctionPrice {
360- case a: Int =>
361- a
362- case _ =>
363- throw("Auction lowest bid was not found")
364- }
365- }
366- let amountDifference = (auctionPrice - newAuctionPrice)
367- let newFreezedBalance = decreaseFreezedBalance(auctionAssetName, amountDifference)
368- ScriptResult(WriteSet([DataEntry((auctionId + "_State"), stateInProgress), DataEntry((auctionId + "_HiredFreelancer"), auctionLowestBidder), DataEntry((auctionId + "_Price"), newAuctionPrice), DataEntry((auctionAssetName + "_Freezed"), newFreezedBalance)]), TransferSet([ScriptTransfer(addressFromPublicKey(auctionClient), amountDifference, auctionAssetId58)]))
369- }
370- else throw("Incorrect auction state")
371- else {
372- let setNewFreelancer = {
373- let newFreelancer = getInteger(this, ((auctionId + "_Bid_") + freelancerPub))
374- match newFreelancer {
375- case a: Int =>
376- freelancerPub
377- case _ =>
378- throw("Error: Incorrect freelancerPub")
379- }
380- }
381- let newAuctionPrice = {
382- let freelancerBid = getInteger(this, ((auctionId + "_Bid_") + freelancerPub))
383- match freelancerBid {
384- case a: Int =>
385- a
386- case _ =>
387- throw("Auction lowest bidder was not found")
388- }
389- }
390- let amountDifference = (auctionPrice - freelancerBidAmount)
391- let newFreezedBalance = decreaseFreezedBalance(auctionAssetName, amountDifference)
392- ScriptResult(WriteSet([DataEntry((auctionId + "_State"), stateInProgress), DataEntry((auctionId + "_HiredFreelancer"), setNewFreelancer), DataEntry((auctionId + "_Price"), newAuctionPrice), DataEntry((auctionAssetName + "_Freezed"), newFreezedBalance)]), TransferSet([ScriptTransfer(addressFromPublicKey(auctionClient), (amountDifference - dAppCommission), auctionAssetId58)]))
393- }
394- else throw("Only auction customer can choose a freelancer")
395- }
396-
397-
398-
399-@Callable(i)
400-func increaseExecutionTime (auctionId,executionDays) = {
401- let caller = extract(i.callerPublicKey)
402- let auctionState = getAuctionState(auctionId)
403- let auctionClient = getAuctionClientPub(auctionId)
404- let auctionBlocksForExecution = getAuctionJobPerformanceTime(auctionId)
405- let newAuctionExecutionTime = {
406- let newAuctionBlocksForExecution = (executionDays * day)
407- if ((newAuctionBlocksForExecution > auctionBlocksForExecution))
408- then newAuctionBlocksForExecution
409- else throw("New execution time must more than current execution time")
410- }
411- if ((caller == auctionClient))
412- then if (if (if ((auctionState == stateOpen))
413- then true
414- else (auctionState == stateSuggested))
415- then true
416- else (auctionState == stateInProgress))
417- then WriteSet([DataEntry((auctionId + "_JobPerformance"), newAuctionExecutionTime)])
418- else throw("Incorrect state")
419- else throw("Only Client can increase execution time")
420- }
421-
422-
423-
424-@Callable(i)
425-func cancelAuction (auctionId) = {
426- let callerPub = extract(i.callerPublicKey)
427- let auctionState = getAuctionState(auctionId)
428- let auctionClient = getAuctionClientPub(auctionId)
429- let auctionAssetName = getAuctionAssetName(auctionId)
430- let auctionPrice = getAuctionPrice(auctionId)
431- let auctionAssetId58 = AssetNameToBase58(auctionAssetName)
432- let dAppCommission = ((auctionPrice * 3) / 100)
433- let amountWithoutComm = (auctionPrice - dAppCommission)
434- let newFreezedBalance = decreaseFreezedBalance(auctionAssetName, auctionPrice)
435- let callerIsClient = if ((callerPub == auctionClient))
436- then true
437- else throw("Auction can be canceled only by auction owner.")
438- if (callerIsClient)
439- then if ((auctionState == stateOpen))
440- then ScriptResult(WriteSet([DataEntry((auctionId + "_State"), stateCancel), DataEntry((auctionAssetName + "_Freezed"), newFreezedBalance)]), TransferSet([ScriptTransfer(addressFromPublicKey(auctionClient), amountWithoutComm, auctionAssetId58)]))
441- else throw("Incorrect auction state.")
442- else throw("Only Client can cancel auction")
443- }
444-
445-
446-
447-@Callable(i)
448-func openDispute (auctionId) = {
449- let caller = extract(i.callerPublicKey)
450- let auctionState = getAuctionState(auctionId)
451- let auctionClient = getAuctionClientPub(auctionId)
452- let auctionFreelancer = getAuctionFreelancerPub(auctionId)
453- if (if ((auctionState == stateOpen))
454- then true
455- else (auctionState == stateSuggested))
456- then throw("Incorrect auction state for dispute opening")
457- else if (if ((caller == auctionClient))
458- then true
459- else (caller == auctionFreelancer))
460- then WriteSet([DataEntry((auctionId + "_State"), stateDispute), DataEntry((auctionId + "_DisputeVotes"), 0)])
461- else throw("Only customer and freelancer can open dispute")
462- }
463-
464-
465-
466-@Callable(i)
467-func voteDispute (auctionId,vote) = {
468- let callerPub = extract(i.callerPublicKey)
469- let auctionState = getAuctionState(auctionId)
470- let auctionClient = getAuctionClientPub(auctionId)
471- let auctionAssetName = getAuctionAssetName(auctionId)
472- let auctionPrice = getAuctionPrice(auctionId)
473- let auctionFreelancer = getAuctionFreelancerPub(auctionId)
474- let comission = ((auctionPrice * 3) / 100)
475- let auctionAssetId58 = AssetNameToBase58(auctionAssetName)
476- let callerIsAmbassador = if (if (if (if (if ((callerPub == ambassador1))
477- then true
478- else (callerPub == ambassador2))
479- then true
480- else (callerPub == ambassador3))
481- then true
482- else (callerPub == ambassador4))
483- then true
484- else (callerPub == ambassador5))
485- then toBase58String(callerPub)
486- else throw("Only defined ambassadors can vote in disputes")
487- let newVote = if (if ((vote == client))
488- then true
489- else (vote == freelancer))
490- then vote
491- else throw(((("Vote is incorrect. Must be: " + client) + " or ") + freelancer))
492- let newVoter = {
493- let keyVoter = ((auctionId + "_DiputeVote_") + callerIsAmbassador)
494- let valueVoter = getString(this, keyVoter)
495- match valueVoter {
496- case a: String =>
497- throw("User already voted")
498- case _ =>
499- callerIsAmbassador
500- }
501- }
502- let votesNumber = {
503- let valueVotesNumber = getInteger(this, (auctionId + "_DisputeVotes"))
504- match valueVotesNumber {
505- case a: Int =>
506- a
507- case _ =>
508- throw("VotesNumber was not found")
509- }
510- }
511- if ((auctionState == stateDispute))
512- then if ((votesNumber == 4))
513- then {
514- let disputeWinner = {
515- let ambassador1Vote = getString(this, ((auctionId + "_DiputeVote_") + toBase58String(ambassador1)))
516- let ambassador2Vote = getString(this, ((auctionId + "_DiputeVote_") + toBase58String(ambassador2)))
517- let ambassador3Vote = getString(this, ((auctionId + "_DiputeVote_") + toBase58String(ambassador3)))
518- let ambassador4Vote = getString(this, ((auctionId + "_DiputeVote_") + toBase58String(ambassador4)))
519- let ambassador5Vote = getString(this, ((auctionId + "_DiputeVote_") + toBase58String(ambassador5)))
520- let v1 = if ((ambassador1Vote == client))
521- then 1
522- else 0
523- let v2 = if ((ambassador2Vote == client))
524- then 1
525- else 0
526- let v3 = if ((ambassador3Vote == client))
527- then 1
528- else 0
529- let v4 = if ((ambassador4Vote == client))
530- then 1
531- else 0
532- let v5 = if ((ambassador5Vote == client))
533- then 1
534- else 0
535- let currentVote = if ((newVote == client))
536- then 1
537- else 0
538- let votesForClient = (((((v1 + v2) + v3) + v4) + v5) + currentVote)
539- if ((votesForClient > 2))
540- then auctionClient
541- else auctionFreelancer
542- }
543- let paymentWithoutComm = if ((disputeWinner == auctionClient))
544- then auctionPrice
545- else (auctionPrice - comission)
546- let newFreezedBalance = decreaseFreezedBalance(auctionAssetName, auctionPrice)
547- ScriptResult(WriteSet([DataEntry((auctionId + "_DisputeVotes"), (votesNumber + 1)), DataEntry((auctionId + "_State"), stateDisputeResolved), DataEntry(((auctionId + "_DiputeVote_") + callerIsAmbassador), newVote), DataEntry((auctionAssetName + "_Freezed"), newFreezedBalance)]), TransferSet([ScriptTransfer(addressFromPublicKey(disputeWinner), paymentWithoutComm, auctionAssetId58)]))
548- }
549- else WriteSet([DataEntry((auctionId + "_DisputeVotes"), (votesNumber + 1)), DataEntry(((auctionId + "_DiputeVote_") + callerIsAmbassador), newVote)])
550- else throw(("Incorrect state. Must be: " + stateDispute))
551- }
552-
553-
554-
555-@Callable(i)
556-func workHandOver (auctionId) = {
557- let callerPub = extract(i.callerPublicKey)
558- let auctionState = getAuctionState(auctionId)
559- let auctionStart = getAuctionStartTime(auctionId)
560- let auctionDuration = getAuctionDurationTime(auctionId)
561- let auctionBlocksForExecution = getAuctionJobPerformanceTime(auctionId)
562- let auctionFreelancer = getAuctionFreelancerPub(auctionId)
563- let currentTime = height
564- let freelancerPubCheck = if ((callerPub == auctionFreelancer))
565- then callerPub
566- else throw("Only a freelancer can indicate that the work is done")
567- let timeIsOver = ((currentTime - auctionStart) > auctionBlocksForExecution)
568- if ((auctionState == stateInProgress))
569- then if (timeIsOver)
570- then WriteSet([DataEntry((auctionId + "_State"), stateDispute), DataEntry((auctionId + "_DisputeVotes"), "0")])
571- else WriteSet([DataEntry((auctionId + "_State"), stateWait4Confirm)])
572- else throw("Auction state is incorrect")
573- }
574-
575-
576-
577-@Callable(i)
578-func acceptWork (auctionId) = {
579- let callerPub = extract(i.callerPublicKey)
580- let auctionState = getAuctionState(auctionId)
581- let auctionClient = getAuctionClientPub(auctionId)
582- let auctionStart = getAuctionStartTime(auctionId)
583- let auctionDuration = getAuctionDurationTime(auctionId)
584- let auctionAssetName = getAuctionAssetName(auctionId)
585- let auctionPrice = getAuctionPrice(auctionId)
586- let auctionFreelancer = getAuctionFreelancerPub(auctionId)
587- let dAppCommission = ((auctionPrice * 3) / 100)
588- let amountWithoutComm = (auctionPrice - dAppCommission)
589- let auctionAssetId58 = AssetNameToBase58(auctionAssetName)
590- let newFreezedBalance = decreaseFreezedBalance(auctionAssetName, auctionPrice)
591- let newRating = {
592- let valueRating = getInteger(this, (toBase58String(auctionFreelancer) + "_Rating"))
593- let currentRating = match valueRating {
594- case a: Int =>
595- a
596- case _ =>
597- 0
598- }
599- (currentRating + 1)
600- }
601- if ((callerPub == auctionClient))
602- then if ((auctionState == stateWait4Confirm))
603- then ScriptResult(WriteSet([DataEntry((auctionId + "_State"), stateComplete), DataEntry((toBase58String(auctionFreelancer) + "_Rating"), newRating), DataEntry((auctionAssetName + "_Freezed"), newFreezedBalance)]), TransferSet([ScriptTransfer(addressFromPublicKey(auctionFreelancer), amountWithoutComm, auctionAssetId58)]))
604- else throw(("Incorrect state. Must be: " + stateWait4Confirm))
605- else throw("Only auction customer can use this function")
606- }
607-
608-
609-@Verifier(tx)
610-func verify () = if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey))
611- then match tx {
612- case ttx: TransferTransaction =>
613- true
614- case stx: SetScriptTransaction =>
615- true
616- case _ =>
617- false
618- }
619- else false
62029

github/deemru/w8io/026f985 
55.92 ms