Skip to content

Add mintTo Function to Node License Contract. #432

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

Merged
merged 11 commits into from
Oct 2, 2024

Conversation

XDapps
Copy link
Contributor

@XDapps XDapps commented Sep 26, 2024

Ticket

Updated NodeLicense contract by adding a new mintTo function that allows the minter to pass in the address that the license should be minted to.

Testing: tested with test cases. Also deployed on Sepolia here .

Completed a test using mintTo on Sepolia and confirmed the recipient received the license via this transaction.

@@ -98,7 +98,7 @@ export function NodeLicenseTinyKeysTest(deployInfrastructure, poolConfigurations
await xai.connect(addr1).approve(await nodeLicense.getAddress(), priceInXai);

// Mint an NFT
await nodeLicense.connect(addr1).mintWithXai(1, "", false, priceInEther);
await nodeLicense.connect(addr1).mintWithXai(1, "", false, priceInXai);
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 test cases were failing due to this bug with the wrong value.

Copy link
Collaborator

Choose a reason for hiding this comment

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

They were never passing ?

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 going from memory, but I think there was originally a bug in the contract around an operator being reversed in this logic. That was caught and fixed when the contract was deployed on Sepolia for testing, but seems the test cases were never updated.

I think I remember when we found the bug on Sepolia, you asked me why the tests didn't catch it. and It seems this was the reason.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the operator part is mixed up but I do remember. This was caught in the audit, we were not expecting the final price to be higher and had to reverse that check. So this makes sense to me now, thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only ran test cases related to NodeLicense tests as the other test cases are still in the process of being cleaned up in another story.

@XDapps XDapps marked this pull request as ready for review September 27, 2024 12:46
* @param _amount The amount of tokens to mint.
* @param _promoCode The promo code.
*/
function mintTo(address _mintToAddress, uint256 _amount, string calldata _promoCode) public payable {
Copy link
Contributor

@craigbranscom craigbranscom Sep 27, 2024

Choose a reason for hiding this comment

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

We should double check the function name doesn't need to be mint instead of mintTo since this change is for a third party integration. If no change is needed let me know and I'll approve.

Copy link
Contributor Author

@XDapps XDapps Sep 27, 2024

Choose a reason for hiding this comment

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

I agree, I actually tried to just use mint with a different function signature and got errors because crossmint couldn't seem to differentiate between them, so I changed to mintTo and was able to get it to work. I have tested and confirmed that it works with crossmint. 👍

@craigbranscom craigbranscom self-requested a review September 30, 2024 13:18
Copy link
Collaborator

Choose a reason for hiding this comment

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

Again ? I see this in the thrid PR now... XD

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems unfortunately, the fix was not yet merged when this branch was created...

@@ -98,7 +98,7 @@ export function NodeLicenseTinyKeysTest(deployInfrastructure, poolConfigurations
await xai.connect(addr1).approve(await nodeLicense.getAddress(), priceInXai);

// Mint an NFT
await nodeLicense.connect(addr1).mintWithXai(1, "", false, priceInEther);
await nodeLicense.connect(addr1).mintWithXai(1, "", false, priceInXai);
Copy link
Collaborator

Choose a reason for hiding this comment

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

They were never passing ?

Comment on lines +442 to +449
it("Check minting an NFT and receiving it with ETH using the MintTo Function", async function() {
const {nodeLicense, addr1, addr2, fundsReceiver} = await loadFixture(deployInfrastructure);
const initialBalance = await ethers.provider.getBalance(fundsReceiver.address);
const price = await nodeLicense.price(1, "");
const totalSupplyBeforeMint = await nodeLicense.totalSupply();

// Mint an NFT to addr1 from addr2
await nodeLicense.connect(addr2).mintTo(addr1.address, 1, "", { value: price });
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we actually have coverage for minting with promoCode ?
I feel we should test minting multiple too as well as mint with promoCode, what do you think ?

Copy link
Contributor Author

@XDapps XDapps Oct 1, 2024

Choose a reason for hiding this comment

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

Added two new test cases:

  1. Check minting with a promo code using the mintTo function and receiving the correct funds.
  2. Check minting multiple keys and receiving them using the mintTo Function.

@XDapps XDapps requested a review from CryptITAustria October 1, 2024 18:25
Copy link
Collaborator

@CryptITAustria CryptITAustria left a comment

Choose a reason for hiding this comment

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

This is approved from my side. I would love for @craigbranscom to run these testcases locally and confirm everything is passing then we can merge. @XDapps Please make sure to have this documented and ping me before actually merging. Thank you.

@@ -98,7 +98,7 @@ export function NodeLicenseTinyKeysTest(deployInfrastructure, poolConfigurations
await xai.connect(addr1).approve(await nodeLicense.getAddress(), priceInXai);

// Mint an NFT
await nodeLicense.connect(addr1).mintWithXai(1, "", false, priceInEther);
await nodeLicense.connect(addr1).mintWithXai(1, "", false, priceInXai);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the operator part is mixed up but I do remember. This was caught in the audit, we were not expecting the final price to be higher and had to reverse that check. So this makes sense to me now, thanks.

@XDapps XDapps merged commit 76e5ea5 into fb-tiny-keys Oct 2, 2024
12 checks passed
@XDapps XDapps deleted the feat/jh/tk/add-mint-function-node-license branch October 2, 2024 18:33
Copy link
Contributor

🎉 This PR is included in version 1.2.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants