tx · FjAZtjo5hbAxmxCFrmMYHJUkpsrRagTYRFPqsunjKUQq

3MxViMkYCH3bTRfyFjMsoiwynP21hpaTjz2:  -0.01500000 Waves

2019.10.12 13:53 [716580] smart account 3MxViMkYCH3bTRfyFjMsoiwynP21hpaTjz2 > SELF 0.00000000 Waves

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

github/deemru/w8io/873ac7e 
818.75 ms