Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minting contract #22

Merged
merged 43 commits into from
Jul 25, 2022
Merged

Minting contract #22

merged 43 commits into from
Jul 25, 2022

Conversation

rynoV
Copy link
Contributor

@rynoV rynoV commented Jul 14, 2022

Closes #21. Also closes #8 and purchase metadata is tested and working with this branch. All changes from #10 are included here because they were used for minting. Merging into calum/purchase-metadata to make it clearer what changes were for metadata and what was for minting.

This PR also includes changes to the parsing of the metadata received from blockfrost, because the nfts minted via CTL have a different metadata format. So the previously minted nfts still on the marketplace won't work after this PR.

@rynoV rynoV added the enhancement New feature or request label Jul 14, 2022
@rynoV rynoV self-assigned this Jul 14, 2022
@rynoV rynoV changed the base branch from neil/typescript-api to calum/purchase-metadata July 15, 2022 21:31
Copy link
Contributor Author

@rynoV rynoV left a comment

Choose a reason for hiding this comment

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

Made issues for the non-critical TODO items

src/Seabug/Contract/Mint.purs Show resolved Hide resolved
@@ -51,8 +65,7 @@ newtype MintParams = MintParams
price :: Natural
, lockLockup :: BigInt
, lockLockupEnd :: Slot
, fakeAuthor :: Maybe PaymentPubKeyHash
, feeVaultKeys :: Array PubKeyHash -- `List` is also an option
, feeVaultKeys :: Array PubKeyHash -- TODO: check if this is needed
Copy link
Contributor Author

Choose a reason for hiding this comment

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

#28

Copy link
Member

Choose a reason for hiding this comment

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

Yes, to derive hash of fee vault script

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm guessing that's Dao.hs? And we won't be using this for a while?

src/Seabug/CallContract.purs Show resolved Hide resolved
src/Seabug/Contract/CnftMint.purs Show resolved Hide resolved
src/Seabug/Contract/MarketPlaceListNft.purs Outdated Show resolved Hide resolved
-- I put too low. The old nfts are caught above because their
-- metadata won't be parsed.
guard $ (unwrap metadata.seabugMetadata # _.ownerPrice) >=
(Natural.fromInt' (10 * 1000000))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The contract fails if the price is too low, 10 ada was the amount I arrived at as a "minimum". I made some other NFTs lower than this so they need to be filtered out

Copy link
Contributor

Choose a reason for hiding this comment

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

do we know why this fails?

Copy link
Member

@t4ccer t4ccer Jul 21, 2022

Choose a reason for hiding this comment

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

When price is lower than min ADA you can't really pay, so 2 ADA should work

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll just update this to use our minAdaOnlyUTxOValue then

Comment on lines +14 to +15
- Uncomment [this line](https://github.com/mlabs-haskell/seabug-contracts/blob/cda88824f87e0b961b738c66a428b7ade77454be/index.js#L39)
- Update the image info [here](https://github.com/mlabs-haskell/seabug-contracts/blob/cda88824f87e0b961b738c66a428b7ade77454be/src/Seabug/Seabug.purs#L34)
Copy link
Contributor

Choose a reason for hiding this comment

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

we're using branch specific links here, we'll want to change this to main when we merge up

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are permalinks so they should continue to work (I think). The lines will probably get moved around, but this seems like a good way to do this since it should be easy to figure out what lines need to be acted on by comparing the old linked version with the updated version

index.js Outdated Show resolved Hide resolved
src/Seabug/CallContract.purs Outdated Show resolved Hide resolved
src/Seabug/CnftMintPolicy.purs Outdated Show resolved Hide resolved
@rynoV rynoV linked an issue Jul 22, 2022 that may be closed by this pull request
@rynoV rynoV mentioned this pull request Jul 22, 2022
2 tasks
@rynoV rynoV mentioned this pull request Jul 22, 2022
7 tasks
Seems likely to break things when used across multiple branches
flake.nix Show resolved Hide resolved
@@ -68,6 +68,6 @@ marketPlaceListNft = do
-- I put too low. The old nfts are caught above because their
-- metadata won't be parsed.
guard $ (unwrap metadata.seabugMetadata # _.ownerPrice) >=
(Natural.fromInt' (10 * 1000000))
(Natural.fromBigInt' minAdaOnlyUTxOValue)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we verify a 2ada nft can still be bought?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Confirmed that a minAdaOnlyUTxOValue (actually 1 ada) priced nft can be bought, this is the purchase transaction: https://testnet.cardanoscan.io/transaction/dace69f58dc611579bd5c7a7cf0de1d4b307f11f9fce01663bc7799cc6fd799c

Copy link
Contributor

Choose a reason for hiding this comment

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

neato!

networkId <- getNetworkId
addr <- liftContractM "Cannot get user address" $
payPubKeyHashEnterpriseAddress networkId owner
payPubKeyHashBaseAddress networkId owner ownerStake
Copy link
Contributor

Choose a reason for hiding this comment

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

Verify this won't be a breaking change, I believe the onchain is coded such that staking addresses aren't permitted right now. We'll need to update that to merge this if this breaks, or move this out to another PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Minting the token purchased in the above transaction was done with this change, so it seems okay?

Copy link
Contributor

Choose a reason for hiding this comment

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

Huh, the source code really looked like it wouldn't allow this, well good to know

Copy link
Member

Choose a reason for hiding this comment

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

Staking (enterprise) addresses aren't allowed when changing owner iirc, should work fine for minting. Payment for changing owner has to be sent to address without staking key though.

Copy link
Contributor

Choose a reason for hiding this comment

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

How did the 1 ada cost buy transaction pass then? Was the ownerstake perhaps still Nothing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@samuelWilliams99 I think because the buy contract doesn't use a staking key, it uses the ownPaymentPubKeyHash of the buyer

Copy link
Contributor

Choose a reason for hiding this comment

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

oh of course! Sorry thats my bad - I thought this change was in the buy contract, but i see its for minting 😅
Okay, Im happy with this then, lets merge :D

@samuelWilliams99 samuelWilliams99 changed the base branch from calum/purchase-metadata to neil/typescript-api July 25, 2022 17:19
@rynoV
Copy link
Contributor Author

rynoV commented Jul 25, 2022

Verified fetching a single nft still works after merge

@rynoV rynoV merged commit 6e70895 into neil/typescript-api Jul 25, 2022
@t4ccer t4ccer deleted the calum/minting-contract branch July 25, 2022 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants