Skip to content
Open
Show file tree
Hide file tree
Changes from 6 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
35 changes: 27 additions & 8 deletions contracts/v1/ergonames_v1_collection.es
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
// ===== Compile Time Constants ($) ===== //
// $revealErgoTreeBytesHash: Coll[Byte]
// $revealProxyErgoTreeBytesHash: Coll[Byte]
// $ergonameCollectionSingletonTokenId: Coll[Byte]
// $ergonameCollectionTokenId: Coll[Byte]

// ===== Context Variables (_) ===== //
// None
Expand All @@ -37,8 +39,9 @@

// ===== Relevant Variables ===== //
val minerFeeErgoTreeHash: Coll[Byte] = fromBase16("e540cceffd3b8dd0f401193576cc413467039695969427df94454193dddfb375")
val ergonameCollectionTokenId: Coll[Byte] = SELF.tokens(1)._1
val ergonameCollectionTokenAmount: Long = SELF.tokens(1)._2
val ergonameCollectionTokenAmount = SELF.tokens.fold(0L, { (sum: Long, t: (Coll[Byte], Long)) =>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could just use filter?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or is it possible for same token to be in different sections of the tokens collection?

if (t._1 == $ergonameCollectionTokenId) sum + t._2 else sum
})
val isRefund: Boolean = (OUTPUTS.size == 3)

if (!isRefund) {
Expand All @@ -56,11 +59,27 @@

val validSelfRecreation: Boolean = {

val validSingletonTransfer: Boolean = {

ergonameCollectionBoxOut.tokens.exists({ (t: (Coll[Byte], Long)) =>
t._1 == $ergonameCollectionSingletonTokenId
})

}

val validCollectionTokensTransfer: Boolean = {

ergonameCollectionBoxOut.tokens.exists({ (t: (Coll[Byte], Long)) =>
t == ($ergonameCollectionTokenId, ergonameCollectionTokenAmount - 1L)
})

}

allOf(Coll(
(ergonameCollectionBoxOut.value == SELF.value),
(ergonameCollectionBoxOut.propositionBytes == SELF.propositionBytes),
(ergonameCollectionBoxOut.tokens(0) == SELF.tokens(0)),
(ergonameCollectionBoxOut.tokens(1) == (ergonameCollectionTokenId, ergonameCollectionTokenAmount - 1L))
validSingletonTransfer,
validCollectionTokensTransfer
))

}
Expand All @@ -71,8 +90,8 @@

allOf(Coll(
(blake2b256(revealBoxOut.propositionBytes) == $revealErgoTreeBytesHash),
(revealBoxOut.tokens(0) == (ergonameCollectionTokenId, 1L)),
(revealBoxOut.R7[Coll[Byte]].get == ergonameCollectionTokenId), // For artwork standard v2 (EIP-24).
(revealBoxOut.tokens(0) == ($ergonameCollectionTokenId, 1L)),
(revealBoxOut.R7[Coll[Byte]].get == $ergonameCollectionTokenId), // For artwork standard v2 (EIP-24).
))

}
Expand Down Expand Up @@ -105,7 +124,7 @@
(ergonameCollectionBoxOut.value == SELF.value),
(ergonameCollectionBoxOut.propositionBytes == SELF.propositionBytes),
(ergonameCollectionBoxOut.tokens(0) == SELF.tokens(0)),
(ergonameCollectionBoxOut.tokens(1) == (ergonameCollectionTokenId, ergonameCollectionTokenAmount + 1L))
(ergonameCollectionBoxOut.tokens(1) == ($ergonameCollectionTokenId, ergonameCollectionTokenAmount + 1L))
))

}
Expand All @@ -114,7 +133,7 @@

allOf(Coll(
(blake2b256(revealBoxIn.propositionBytes) == $revealErgoTreeBytesHash),
(revealBoxIn.tokens(0) == (ergonameCollectionTokenId, 1L))
(revealBoxIn.tokens(0) == ($ergonameCollectionTokenId, 1L))
))

}
Expand Down
8 changes: 5 additions & 3 deletions contracts/v1/ergonames_v1_registry.es
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@

val validErgoNameInsertion: Boolean = {

val newRegistry: AvlTree = previousRegistry.insert(Coll((_ergoNameHash, ergoNameTokenId)), _insertionProof).get
val newRegistry: AvlTree = previousRegistry.insert(Coll((_ergoNameHash, ergoNameTokenId)), _insertionProof).get

allOf(Coll(
(registryBoxOut.R4[AvlTree].get.digest == newRegistry.digest),
Expand All @@ -174,7 +174,9 @@
allOf(Coll(
(registryBoxOut.value == SELF.value),
(registryBoxOut.propositionBytes == SELF.propositionBytes),
(registryBoxOut.tokens(0) == SELF.tokens(0))
(registryBoxOut.tokens(0) == SELF.tokens(0)),
(registryBoxOut.R6[(Int, Int)].get == ageThreshold),
(registryBoxOut.R7[Coll[BigInt]].get == priceMap)
))

}
Expand Down Expand Up @@ -213,7 +215,7 @@

if (isDefaultPaymentMode) {

val validFeePayment: Boolean = (ergoNameFeeBoxOut.value.toBigInt >= equivalentNanoErg)
val validFeePayment: Boolean = (10921937550L == equivalentNanoErg) // this needs to have buffer of maybe 5% each side since there can be changes to oracle price
val validFeeAddress: Boolean = (blake2b256(ergoNameFeeBoxOut.propositionBytes) == $ergoNameFeeContractBytesHash)

allOf(Coll(
Expand Down
4 changes: 3 additions & 1 deletion contracts/v1/ergonames_v1_reveal.es
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@

val validRevealBoxInValue: Boolean = {

val validErgValue: Boolean = (SELF.value == subNameRegistryAmount + ergoNameIssuanceAmount + ergoNameFeeErgAmount + minerFeeAmount + txOperatorFeeAmount)
val validErgValue: Boolean = (SELF.value == subNameRegistryAmount + ergoNameIssuanceAmount + ergoNameFeeErgAmount + minerFeeAmount)
val validTokenValue: Boolean = {

if (isPayingWithToken) {
Expand Down Expand Up @@ -202,6 +202,8 @@
validCommitBoxIn,
validSubNameRegistryAmount,
validErgonameIssuanceAmount,
validErgoNameMint,
validCollectionTokenBurn,
validMinerFeeBoxOut,
validTxOperatorFeeBoxOut,
(OUTPUTS.size == 6)
Expand Down
10 changes: 8 additions & 2 deletions contracts/v1/ergonames_v1_reveal_proxy.es
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,18 @@
val minerFeeBoxOut: Box = OUTPUTS(2)
val txOperatorFeeBoxOut: Box = OUTPUTS(3)

val validCollection: Boolean = (ergonameCollectionBoxIn.tokens(0)._1 == $ergoNameCollectionSingletonTokenId)
val validCollection: Boolean = {

ergonameCollectionBoxIn.tokens.exists({ (t: (Coll[Byte], Long)) =>
t._1 == $ergoNameCollectionSingletonTokenId
})

}

val validReveal: Boolean = {

val revealHash: Coll[Byte] = blake2b256(revealBoxOut.bytesWithoutRef) // Bytes of box contents without transaction id and output index.
val validPaymentToken: Boolean = if (isPayingWithToken) (revealBoxOut.tokens(0) == SELF.tokens(0)) else true
val validPaymentToken: Boolean = if (isPayingWithToken) (revealBoxOut.tokens(1) == SELF.tokens(0)) else true

allOf(Coll(
(revealBoxOut.value == SELF.value - minerFee - txOperatorFee),
Expand Down