feat: initial implementation of ERC1046 (#933)
* feat: initial implementation of ERC1046
This commit is contained in:
13
contracts/mocks/ERC20WithMetadataMock.sol
Normal file
13
contracts/mocks/ERC20WithMetadataMock.sol
Normal file
@ -0,0 +1,13 @@
|
||||
pragma solidity ^0.4.21;
|
||||
|
||||
import "../token/ERC20/StandardToken.sol";
|
||||
import "../proposals/ERC1046/TokenMetadata.sol";
|
||||
|
||||
|
||||
contract ERC20WithMetadataMock is StandardToken, ERC20WithMetadata {
|
||||
function ERC20WithMetadataMock(string _tokenURI)
|
||||
ERC20WithMetadata(_tokenURI)
|
||||
public
|
||||
{
|
||||
}
|
||||
}
|
||||
0
contracts/proposals/.gitkeep
Normal file
0
contracts/proposals/.gitkeep
Normal file
29
contracts/proposals/ERC1046/TokenMetadata.sol
Normal file
29
contracts/proposals/ERC1046/TokenMetadata.sol
Normal file
@ -0,0 +1,29 @@
|
||||
pragma solidity ^0.4.21;
|
||||
|
||||
import "../../token/ERC20/ERC20.sol";
|
||||
|
||||
|
||||
/**
|
||||
* @title ERC-1047 Token Metadata
|
||||
* @dev See https://eips.ethereum.org/EIPS/eip-1046
|
||||
* @dev tokenURI must respond with a URI that implements https://eips.ethereum.org/EIPS/eip-1047
|
||||
* @dev TODO - update https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/token/ERC721/ERC721.sol#L17 when 1046 is finalized
|
||||
*/
|
||||
contract ERC20TokenMetadata is ERC20 {
|
||||
function tokenURI() external view returns (string);
|
||||
}
|
||||
|
||||
|
||||
contract ERC20WithMetadata is ERC20TokenMetadata {
|
||||
string private tokenURI_ = "";
|
||||
|
||||
function ERC20WithMetadata(string _tokenURI)
|
||||
public
|
||||
{
|
||||
tokenURI_ = _tokenURI;
|
||||
}
|
||||
|
||||
function tokenURI() external view returns (string) {
|
||||
return tokenURI_;
|
||||
}
|
||||
}
|
||||
18
test/proposals/ERC1046/TokenMetadata.test.js
Normal file
18
test/proposals/ERC1046/TokenMetadata.test.js
Normal file
@ -0,0 +1,18 @@
|
||||
const ERC20WithMetadata = artifacts.require('ERC20WithMetadataMock');
|
||||
|
||||
require('chai')
|
||||
.use(require('chai-as-promised'))
|
||||
.should();
|
||||
|
||||
const metadataURI = 'https://example.com';
|
||||
|
||||
describe('ERC20WithMetadata', function () {
|
||||
before(async function () {
|
||||
this.token = await ERC20WithMetadata.new(metadataURI);
|
||||
});
|
||||
|
||||
it('responds with the metadata', async function () {
|
||||
const got = await this.token.tokenURI();
|
||||
got.should.eq(metadataURI);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user