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

Add updated token URI & redeployment address #15

Merged
merged 5 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ The relevant contracts can be found at the following addresses on Flow Testnet:

|Contract|Address|
|---|---|
|`MaybeMintERC72`|[`0xdbC43Ba45381e02825b14322cDdd15eC4B3164E6`](https://evm-testnet.flowscan.io/address/0xdbc43ba45381e02825b14322cddd15ec4b3164e6?tab=contract_code)|
|`MaybeMintERC72`|[`0x2E2Ed0Cfd3AD2f1d34481277b3204d807Ca2F8c2`](https://evm-testnet.flowscan.io/address/0xdbc43ba45381e02825b14322cddd15ec4b3164e6?tab=contract_code)|
|`WFLOW`|[`0xd3bF53DAC106A0290B0483EcBC89d40FcC961f3e`](https://evm-testnet.flowscan.io/token/0xd3bF53DAC106A0290B0483EcBC89d40FcC961f3e?tab=contract_code)|
2 changes: 1 addition & 1 deletion cadence/tests/test_helpers.cdc

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion cadence/tests/wrap_and_mint_tests.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ fun setup() {
"MAYBE",
EVM.addressFromString(wflowAddress),
UInt256(1_000_000_000_000_000_000),
EVM.addressFromString(coaAddress)
EVM.addressFromString(coaAddress),
"https://ipfs.filebase.io/ipfs/QmXbjTVEbhfzhbjfMtG8ZRhjDowd8oB7j7MXBWfYtzpcmY"
]
// Encode constructor args as ABI and then as hex
let argsBytecode = String.encodeHex(EVM.encodeABI(
Expand Down
Binary file added solidity/metadata/maybe_mint_erc721_image.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions solidity/metadata/maybe_mint_erc721_metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "Maybe Mint ERC721",
"description": "Minting this NFT is onchain cred that you've completed the tutorial on batched EVM execution using Cadence!",
"external_url": "https://developers.flow.com",
"image": "https://ipfs.filebase.io/ipfs/QmW6KnodnbcNHMuB1L8fT13EMRUTEJ8SAQKQfTWKdTKht9",
"attributes": []
}
21 changes: 17 additions & 4 deletions solidity/src/MaybeMintERC721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,23 @@ contract MaybeMintERC721 is ERC721, Ownable {
uint256 public mintCost;
address public beneficiary;
uint256 public totalSupply;
string private uri;

error RandomRevert();
error InsufficientAllowance(address denomination, address sender, uint256 needed);

constructor(string memory _name, string memory _symbol, address _erc20, uint256 _mintCost, address _beneficiary)
ERC721(_name, _symbol)
Ownable(msg.sender)
{
constructor(
string memory _name,
string memory _symbol,
address _erc20,
uint256 _mintCost,
address _beneficiary,
string memory _uri
) ERC721(_name, _symbol) Ownable(msg.sender) {
denomination = IERC20(_erc20);
mintCost = _mintCost;
beneficiary = _beneficiary;
uri = _uri;
totalSupply = 0;
}

Expand All @@ -44,6 +50,13 @@ contract MaybeMintERC721 is ERC721, Ownable {
_maybeMint();
}

function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
if (_ownerOf(tokenId) == address(0)) {
revert ERC721NonexistentToken(tokenId);
}
return uri;
}

/**
* @dev Mint a new ERC721 token to the caller with some chance of failure.
* NOTE: Production systems using random minting should leverage a commit-reveal scheme
Expand Down
3 changes: 2 additions & 1 deletion solidity/test/MaybeMintERC721.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ contract MaybeMintERC721Test is Test {
uint256 internal mintCost = 1 ether;
string internal name = "Maybe Mint ERC721 Test";
string internal symbol = "MAYBE";
string internal uri = "https://url.doman/uri.json";

// Test values
address payable internal user = payable(address(101));
Expand All @@ -28,7 +29,7 @@ contract MaybeMintERC721Test is Test {
vm.deal(user, 10 ether);

erc20 = new ExampleERC20();
erc721 = new MaybeMintERC721(name, symbol, address(erc20), mintCost, beneficiary);
erc721 = new MaybeMintERC721(name, symbol, address(erc20), mintCost, beneficiary, uri);
}

function testMintRandomEvenSucceeds() public {
Expand Down