Skip to content

Commit

Permalink
Allowing zero price sale and tweet (#345)
Browse files Browse the repository at this point in the history
  • Loading branch information
avkr003 authored Feb 17, 2023
1 parent 2dfc971 commit 898f617
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 13 deletions.
4 changes: 2 additions & 2 deletions app/constants/FormField.scala
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ object FormField {

// MicroNumberFormField
val SEND_COIN_AMOUNT: MicroNumberFormField = MicroNumberFormField("SEND_COIN_AMOUNT", MicroNumber.smallest, MicroNumber(Int.MaxValue), 6)
val NFT_WHITELIST_SALE_PRICE: MicroNumberFormField = MicroNumberFormField("NFT_WHITELIST_SALE_PRICE", MicroNumber.smallest, MicroNumber(Int.MaxValue))
val PUBLIC_LISTING_PRICE: MicroNumberFormField = MicroNumberFormField("PUBLIC_LISTING_PRICE", MicroNumber.smallest, MicroNumber(Int.MaxValue), 6)
val NFT_WHITELIST_SALE_PRICE: MicroNumberFormField = MicroNumberFormField("NFT_WHITELIST_SALE_PRICE", MicroNumber.zero, MicroNumber(Int.MaxValue))
val PUBLIC_LISTING_PRICE: MicroNumberFormField = MicroNumberFormField("PUBLIC_LISTING_PRICE", MicroNumber.zero, MicroNumber(Int.MaxValue), 6)

// NestedFormField
val COLLECTION_PROPERTIES: NestedFormField = NestedFormField("COLLECTION_PROPERTIES")
Expand Down
5 changes: 4 additions & 1 deletion app/controllers/PublicListingController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,10 @@ class PublicListingController @Inject()(
countBuyerNFTsFromPublicListing <- countBuyerNFTsFromPublicListing
checkAlreadySold <- checkAlreadySold(nftOwners.map(_.nftId))
blockchainTransaction <- validateAndTransfer(nftOwners = nftOwners, verifyPassword = verifyPassword, publicListing = publicListing, buyerKey = buyerKey, sellerKey = sellerKey, balance = balance, nfts = nfts, countBuyerNFTsFromPublicListing = countBuyerNFTsFromPublicListing, checkAlreadySold = checkAlreadySold)
} yield PartialContent(views.html.blockchainTransaction.transactionSuccessful(blockchainTransaction))
} yield {
val tweetURI = if (collection.getTwitterUsername.isDefined) Option(s"https://twitter.com/intent/tweet?text=Just bought ${collection.name} NFTs at a huge discount via Early Access Sale on MantlePlace. @${collection.getTwitterUsername.get} @AssetMantle Check here &url=https://marketplace.assetmantle.one/collections/${collection.id}&hashtags=NFT") else None
PartialContent(views.html.blockchainTransaction.transactionSuccessful(blockchainTransaction, tweetURI))
}
).recover {
case baseException: BaseException => BadRequest(views.html.publicListing.buyNFT(BuyNFT.form.withGlobalError(baseException.failure.message), publicListingId = buyNFTData.publicListingId))
}
Expand Down
5 changes: 4 additions & 1 deletion app/controllers/SaleController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,10 @@ class SaleController @Inject()(
countBuyerNFTsFromSale <- countBuyerNFTsFromSale
checkAlreadySold <- checkAlreadySold(nftOwners.map(_.nftId))
blockchainTransaction <- validateAndTransfer(nftOwners = nftOwners, verifyPassword = verifyPassword, sale = sale, isWhitelistMember = isWhitelistMember, buyerKey = buyerKey, sellerKey = sellerKey, balance = balance, nfts = nfts, countBuyerNFTsFromSale = countBuyerNFTsFromSale, checkAlreadySold = checkAlreadySold)
} yield PartialContent(views.html.blockchainTransaction.transactionSuccessful(blockchainTransaction))
} yield {
val tweetURI = if (collection.getTwitterUsername.isDefined) Option(s"https://twitter.com/intent/tweet?text=Just bought ${collection.name} NFTs at a huge discount via Launchpad Sale on MantlePlace. @${collection.getTwitterUsername.get} @AssetMantle Check here &url=https://marketplace.assetmantle.one/collections/${collection.id}&hashtags=NFT") else None
PartialContent(views.html.blockchainTransaction.transactionSuccessful(blockchainTransaction, tweetURI))
}
).recover {
case baseException: BaseException => BadRequest(views.html.sale.buySaleNFT(BuySaleNFT.form.withGlobalError(baseException.failure.message), saleId = buySaleNFTData.saleId))
}
Expand Down
2 changes: 2 additions & 0 deletions app/models/master/Collection.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ case class Collection(id: String, creatorId: String, classificationId: Option[St

def getTwitter: Option[String] = this.socialProfiles.find(_.name == constants.Collection.SocialProfile.TWITTER).map("https://www.twitter.com/" + _.url)

def getTwitterUsername: Option[String] = this.socialProfiles.find(_.name == constants.Collection.SocialProfile.TWITTER).map(_.url)

def getInstagram: Option[String] = this.socialProfiles.find(_.name == constants.Collection.SocialProfile.INSTAGRAM).map("https://www.instagram.com/" + _.url)

def getProfileFileURL: Option[String] = this.profileFileName.map(x => constants.CommonConfig.AmazonS3.s3BucketURL + utilities.Collection.getOthersFileAwsKey(collectionId = this.id, fileName = x))
Expand Down
2 changes: 1 addition & 1 deletion app/service/Starter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ class Starter @Inject()(
// Delete redundant nft tags
def start(): Future[Unit] = {
(for {
_ <- uploadCollections()
_ <- validateAll()
} yield ()
).recover {
case exception: Exception => logger.error(exception.getLocalizedMessage)
Expand Down
29 changes: 21 additions & 8 deletions app/views/blockchainTransaction/transactionSuccessful.scala.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@import views.html.base.modal._
@import models.Trait.BlockchainTransaction
@import views.html.base.modal._

@(blockchainTx: BlockchainTransaction)(implicit requestHeader: RequestHeader, messagesProvider: MessagesProvider)
@(blockchainTx: BlockchainTransaction, tweetURI: Option[String] = None)(implicit requestHeader: RequestHeader, messagesProvider: MessagesProvider)

@if(blockchainTx.status.nonEmpty) {
@if(!blockchainTx.status.get) {
Expand All @@ -12,12 +12,25 @@
@successModal(heading = constants.View.BROADCASTING_BLOCKCHAIN_TRANSACTION_SUCCESS_TITLE, subHeading = constants.View.BLOCKCHAIN_TRANSACTION_SUCCESS_SUBTITLE)
<div class="form-address-box">
<div class="form-address-box-item">
<span class="address-box-label">@Messages(constants.View.HASH)</span>
<span class="address-box-text">
<span class="username-data" data-value="@blockchainTx.txHash">@blockchainTx.txHash</span>
<span class="form-copy-icon" onclick="copyToClipboard(this)"><img src="@routes.Assets.versioned("images/icon/copy.png")"/></span>
<span class="form-copy-message">@Messages(constants.View.TOOLTIP_COPIED)</span>
</span>
<span class="address-box-label">@Messages(constants.View.HASH)</span>
<span class="address-box-text">
<span class="username-data" data-value="@blockchainTx.txHash">@blockchainTx.txHash</span>
<span class="form-copy-icon" onclick="copyToClipboard(this)"><img src="@routes.Assets.versioned("images/icon/copy.png")"/></span>
<span class="form-copy-message">@Messages(constants.View.TOOLTIP_COPIED)</span>
</span>
</div>
</div>
@if(tweetURI.isDefined) {
@defining(tweetURI.get) { uri =>
<div class="horizontal-align">
<a href='@uri' target="_blank">
<button class="form-primary-button">
<span>
<img src="@routes.Assets.versioned("images/icon/twitterBlack.svg")" class="icon"/>
</span>
</button>
</a>
</div>
}
}
}

0 comments on commit 898f617

Please sign in to comment.