Update docs

This commit is contained in:
github-actions
2022-04-26 16:51:43 +00:00
parent d75a9e5480
commit 84526a0944
151 changed files with 17094 additions and 11955 deletions

View File

@ -0,0 +1,66 @@
const { BN, expectEvent } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
const { artifacts } = require('hardhat');
const ERC1155URIStorageMock = artifacts.require('ERC1155URIStorageMock');
contract(['ERC1155URIStorage'], function (accounts) {
const [ holder ] = accounts;
const erc1155Uri = 'https://token.com/nfts/';
const baseUri = 'https://token.com/';
const tokenId = new BN('1');
const amount = new BN('3000');
describe('with base uri set', function () {
beforeEach(async function () {
this.token = await ERC1155URIStorageMock.new(erc1155Uri);
this.token.setBaseURI(baseUri);
await this.token.mint(holder, tokenId, amount, '0x');
});
it('can request the token uri, returning the erc1155 uri if no token uri was set', async function () {
const receivedTokenUri = await this.token.uri(tokenId);
expect(receivedTokenUri).to.be.equal(erc1155Uri);
});
it('can request the token uri, returning the concatenated uri if a token uri was set', async function () {
const tokenUri = '1234/';
const receipt = await this.token.setURI(tokenId, tokenUri);
const receivedTokenUri = await this.token.uri(tokenId);
const expectedUri = `${baseUri}${tokenUri}`;
expect(receivedTokenUri).to.be.equal(expectedUri);
expectEvent(receipt, 'URI', { value: expectedUri, id: tokenId });
});
});
describe('with base uri set to the empty string', function () {
beforeEach(async function () {
this.token = await ERC1155URIStorageMock.new('');
await this.token.mint(holder, tokenId, amount, '0x');
});
it('can request the token uri, returning an empty string if no token uri was set', async function () {
const receivedTokenUri = await this.token.uri(tokenId);
expect(receivedTokenUri).to.be.equal('');
});
it('can request the token uri, returning the token uri if a token uri was set', async function () {
const tokenUri = 'ipfs://1234/';
const receipt = await this.token.setURI(tokenId, tokenUri);
const receivedTokenUri = await this.token.uri(tokenId);
expect(receivedTokenUri).to.be.equal(tokenUri);
expectEvent(receipt, 'URI', { value: tokenUri, id: tokenId });
});
});
});

View File

@ -67,7 +67,7 @@ contract('ERC20FlashMint', function (accounts) {
const receiver = await ERC3156FlashBorrowerMock.new(true, false);
await expectRevert(
this.token.flashLoan(receiver.address, this.token.address, loanAmount, '0x'),
'ERC20FlashMint: allowance does not allow refund',
'ERC20: insufficient allowance',
);
});

View File

@ -4,7 +4,8 @@ const { ZERO_ADDRESS, MAX_UINT256 } = constants;
const { shouldBehaveLikeERC20 } = require('../ERC20.behavior');
const ERC20Mock = artifacts.require('ERC20Mock');
const NotAnERC20 = artifacts.require('CallReceiverMock');
const ERC20Mock = artifacts.require('ERC20DecimalsMock');
const ERC20WrapperMock = artifacts.require('ERC20WrapperMock');
contract('ERC20', function (accounts) {
@ -16,8 +17,10 @@ contract('ERC20', function (accounts) {
const initialSupply = new BN(100);
beforeEach(async function () {
this.underlying = await ERC20Mock.new(name, symbol, initialHolder, initialSupply);
this.underlying = await ERC20Mock.new(name, symbol, 9);
this.token = await ERC20WrapperMock.new(this.underlying.address, `Wrapped ${name}`, `W${symbol}`);
await this.underlying.mint(initialHolder, initialSupply);
});
afterEach(async function () {
@ -32,8 +35,14 @@ contract('ERC20', function (accounts) {
expect(await this.token.symbol()).to.equal(`W${symbol}`);
});
it('has 18 decimals', async function () {
expect(await this.token.decimals()).to.be.bignumber.equal('18');
it('has the same decimals as the underlying token', async function () {
expect(await this.token.decimals()).to.be.bignumber.equal('9');
});
it('decimals default back to 18 if token has no metadata', async function () {
const noDecimals = await NotAnERC20.new();
const otherToken = await ERC20WrapperMock.new(noDecimals.address, `Wrapped ${name}`, `W${symbol}`);
expect(await otherToken.decimals()).to.be.bignumber.equal('18');
});
it('has underlying', async function () {