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

feat: add mint and call #35

Merged
merged 3 commits into from
Sep 4, 2024
Merged

feat: add mint and call #35

merged 3 commits into from
Sep 4, 2024

Conversation

vittominacori
Copy link
Owner

Add an extension with a _mintAndCall method.

This method allows to mint tokens to a receiver contract and then call the onTransferReceived callback.

Closes #34

Note

_mintAndCall is an internal method, and you should call it from your derived contract.

For instance, you may choose to check if the receiver is a contract or an EOA and call the _mint method instead.

pragma solidity ^0.8.20;
 
// other imports
import "erc-payable-token/contracts/token/ERC1363/extensions/ERC1363Mintable.sol";

contract MyToken is ERC1363Mintable, Ownable {
    // your stuff

    function safeMint(address account, uint256 value, bytes memory data) public onlyOwner {
        if (account.code.length == 0) {
            _mint(account, value);
        } else {
            _mintAndCall(account, value, data);
        }
    }

    // your stuff
}

@vittominacori vittominacori self-assigned this Sep 4, 2024
Copy link

codecov bot commented Sep 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (a8a0e0a) to head (1eca174).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master       #35   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            4         6    +2     
  Lines           80        85    +5     
  Branches        15        13    -2     
=========================================
+ Hits            80        85    +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@vittominacori vittominacori merged commit 39aaea5 into master Sep 4, 2024
7 checks passed
@vittominacori vittominacori deleted the feat/add-mint-and-call branch September 4, 2024 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add safeMint or Public Method to Trigger onTransferReceived After Minting in ERC1363
1 participant