-
Notifications
You must be signed in to change notification settings - Fork 44
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
Add mintTo Function to Node License Contract. #432
Conversation
@@ -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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They were never passing ?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
…ithub.com/xai-foundation/sentry into feat/jh/tk/add-mint-function-node-license
There was a problem hiding this comment.
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.
* @param _amount The amount of tokens to mint. | ||
* @param _promoCode The promo code. | ||
*/ | ||
function mintTo(address _mintToAddress, uint256 _amount, string calldata _promoCode) public payable { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. 👍
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They were never passing ?
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 }); |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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:
- Check minting with a promo code using the mintTo function and receiving the correct funds.
- Check minting multiple keys and receiving them using the mintTo Function.
There was a problem hiding this 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); |
There was a problem hiding this comment.
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.
🎉 This PR is included in version 1.2.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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.