Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions eip-0023/contracts/update_contract.es
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// R4 the pub key of voter [GroupElement] (not used here)
// R5 the creation height of this box [Int]
// R6 the value voted for [Coll[Byte]] (hash of the new pool box script)
// R7 the reward token id in new box
// R8 the number of reward tokens in new box
// R7 the reward token id in new box (optional, if not present then reward token is preserved)
// R8 the number of reward tokens in new box (optional, if not present then reward token is preserved))

val poolNFT = fromBase64("RytLYlBlU2hWbVlxM3Q2dzl6JEMmRilKQE1jUWZUalc=") // TODO replace with actual

Expand Down Expand Up @@ -39,12 +39,18 @@
updateBoxOut.creationInfo._1 > SELF.creationInfo._1 &&
! (updateBoxOut.R4[Any].isDefined)

val rewardTokenPreserved = poolIn.tokens(1)._1 == rewardTokenId && // check reward token id is preserved
poolIn.tokens(1)._2 == rewardAmt // check reward token amt is preserved

def isValidBallot(b:Box) = if (b.tokens.size > 0) {
val validRewardToken = if (b.R7[Coll[Byte]].isDefined && b.R8[Long].isDefined) {
b.R7[Coll[Byte]].get == rewardTokenId && // check rewardTokenId voted for
b.R8[Long].get == rewardAmt // check rewardTokenAmt voted for
} else rewardTokenPreserved
b.tokens(0)._1 == ballotTokenId &&
b.R5[Int].get == SELF.creationInfo._1 && // ensure vote corresponds to this box by checking creation height
b.R6[Coll[Byte]].get == poolOutHash && // check proposition voted for
b.R7[Coll[Byte]].get == rewardTokenId && // check rewardTokenId voted for
b.R8[Long].get == rewardAmt // check rewardTokenAmt voted for
validRewardToken
} else false

val ballotBoxes = INPUTS.filter(isValidBallot)
Expand Down
2 changes: 1 addition & 1 deletion eip-0023/eip-0023.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ Before going into the transactions in the protocol, we first present the contrac
- [Refresh Contract](contracts/refresh_contract.es) `cs5c5QEirstI4ZlTyrbTjlPwWYHRW+QsedtpyOSBnH4=`
- [Oracle Contract](contracts/oracle_contract.es) `fhOYLO3s+NJCqTQDWUz0E+ffy2T1VG7ZnhSFs0RP948=`
- [Ballot Contract](contracts/ballot_contract.es) `2DnK+72bh+TxviNk8XfuYzLKtuF5jnqUJOzimt30NvI=`
- [Update Contract](contracts/update_contract.es) `3aIVTP5tRgCZHxaT3ZFw3XubRV5DJi0rKeo9bKVHlVw=`
- [Update Contract](contracts/update_contract.es) `pQ7Dgjq1pUyISroP+RWEDf+kVNYAWjeFHzW+cpImhsQ=`
Use this Scastie playground to calculate the above hashes - [https://scastie.scala-lang.org/hnTEm2lJQPG1wRYCqPz8LQ](https://scastie.scala-lang.org/hnTEm2lJQPG1wRYCqPz8LQ)
## Transactions

Expand Down