Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. let startHeight = 384120
  2. let finishHeight = startHeight + 3000
  3. let startPrice = 100000
  4. #extracting the sender’s address from the transaction
  5. let this = extract(tx.sender)
  6. let token = base58'8jfD2JBLe23XtCCSQoTx5eAW5QCU6Mbxi3r78aNQLcNf'
  7. match tx {
  8. case d : DataTransaction =>
  9. #checking if the price is defined in the state
  10. let currentPrice = if isDefined(getInteger(this, "price"))
  11. #extracting the price from the state
  12. then extract(getInteger(this, "price"))
  13. else startPrice
  14.  
  15. #extracting the price from the transaction
  16. let newPrice = extract(getInteger(d.data, "price"))
  17. let priceIsBigger = newPrice > currentPrice
  18. let fee = 700000
  19. let hasMoney = wavesBalance(tx.sender) + fee >= newPrice
  20.  
  21. #making sure there are two fields in the current transaction and the sender is the same as the same as stated in the transaction
  22. let correctFields = size(d.data) == 2 &&
  23. d.sender == addressFromString(extract(getString(d.data,"sender")))
  24. startHeight <= height && height <= finishHeight && priceIsBigger && hasMoney && correctFields
  25. case e : ExchangeTransaction =>
  26. let senderIsWinner = e.sender == addressFromString(extract(getString(this, "sender"))) #making sure that the item is exchanged by the actual winner
  27. let correctAssetPair = e.sellOrder.assetPair.amountAsset == token && ! isDefined(e.sellOrder.assetPair.priceAsset)
  28. let correctAmount = e.amount == 1
  29. let correctPrice = e.price == extract(getInteger(this, "price"))
  30. height > finishHeight && senderIsWinner && correctAssetPair && correctAmount && correctPrice
  31. case _ => false
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement