Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
10 changes: 8 additions & 2 deletions packages/core/solidity/src/erc721.test.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,15 @@ Generated by [AVA](https://avajs.dev).
Ownable(initialOwner)␊
{}␊
function safeMint(address to, string memory uri) public onlyOwner {␊
function safeMint(address to, string memory uri)␊
public␊
onlyOwner␊
returns (uint256)␊
{␊
uint256 tokenId = _nextTokenId++;␊
_safeMint(to, tokenId);␊
_setTokenURI(tokenId, uri);␊
return tokenId;␊
}␊
// The following functions are overrides required by Solidity.␊
Expand Down Expand Up @@ -404,9 +409,10 @@ Generated by [AVA](https://avajs.dev).
Ownable(initialOwner)␊
{}␊
function safeMint(address to) public onlyOwner {␊
function safeMint(address to) public onlyOwner returns (uint256) {␊
uint256 tokenId = _nextTokenId++;␊
_safeMint(to, tokenId);␊
return tokenId;␊
}␊
}␊
`
Expand Down
Binary file modified packages/core/solidity/src/erc721.test.ts.snap
Binary file not shown.
19 changes: 9 additions & 10 deletions packages/core/solidity/src/erc721.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Contract, ContractBuilder } from './contract';
import { BaseFunction, Contract, ContractBuilder } from './contract';
import { Access, setAccessControl, requireAccessControl } from './set-access-control';
import { addPauseFunctions } from './add-pausable';
import { supportsInterface } from './common-functions';
Expand Down Expand Up @@ -185,14 +185,16 @@ function addMintable(c: ContractBuilder, access: Access, incremental = false, ur
if (uriStorage) {
c.addFunctionCode('_setTokenURI(tokenId, uri);', fn);
}

if (incremental) c.addFunctionCode('return tokenId;', fn);
}

function addVotes(c: ContractBuilder, name: string, clockMode: ClockMode) {
const EIP712 = {
name: 'EIP712',
path: '@openzeppelin/contracts/utils/cryptography/EIP712.sol',
};
c.addParent(EIP712, [name, "1"]);
c.addParent(EIP712, [name, '1']);

const ERC721Votes = {
name: 'ERC721Votes',
Expand All @@ -219,9 +221,7 @@ const functions = defineFunctions({

tokenURI: {
kind: 'public' as const,
args: [
{ name: 'tokenId', type: 'uint256' },
],
args: [{ name: 'tokenId', type: 'uint256' }],
returns: ['string memory'],
mutability: 'view' as const,
},
Expand All @@ -242,13 +242,12 @@ const functions = defineFunctions({
},
});

function getMintFunction(incremental: boolean, uriStorage: boolean) {
const fn = {
function getMintFunction(incremental: boolean, uriStorage: boolean): BaseFunction {
const fn: BaseFunction = {
name: 'safeMint',
kind: 'public' as const,
args: [
{ name: 'to', type: 'address' },
],
args: [{ name: 'to', type: 'address' }],
returns: incremental ? ['uint256'] : undefined,
};

if (!incremental) {
Expand Down
Loading