Fix .gitignore: stop tracking ignored files

This commit is contained in:
5t4l1n
2025-07-27 10:39:02 +05:30
parent b42747e9a3
commit 3a87ef0576
625 changed files with 88566 additions and 63 deletions
@@ -0,0 +1,67 @@
const { BN, expectRevert } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
const ERC1155Burnable = artifacts.require('$ERC1155Burnable');
contract('ERC1155Burnable', function (accounts) {
const [holder, operator, other] = accounts;
const uri = 'https://token.com';
const tokenIds = [new BN('42'), new BN('1137')];
const amounts = [new BN('3000'), new BN('9902')];
beforeEach(async function () {
this.token = await ERC1155Burnable.new(uri);
await this.token.$_mint(holder, tokenIds[0], amounts[0], '0x');
await this.token.$_mint(holder, tokenIds[1], amounts[1], '0x');
});
describe('burn', function () {
it('holder can burn their tokens', async function () {
await this.token.burn(holder, tokenIds[0], amounts[0].subn(1), { from: holder });
expect(await this.token.balanceOf(holder, tokenIds[0])).to.be.bignumber.equal('1');
});
it("approved operators can burn the holder's tokens", async function () {
await this.token.setApprovalForAll(operator, true, { from: holder });
await this.token.burn(holder, tokenIds[0], amounts[0].subn(1), { from: operator });
expect(await this.token.balanceOf(holder, tokenIds[0])).to.be.bignumber.equal('1');
});
it("unapproved accounts cannot burn the holder's tokens", async function () {
await expectRevert(
this.token.burn(holder, tokenIds[0], amounts[0].subn(1), { from: other }),
'ERC1155: caller is not token owner or approved',
);
});
});
describe('burnBatch', function () {
it('holder can burn their tokens', async function () {
await this.token.burnBatch(holder, tokenIds, [amounts[0].subn(1), amounts[1].subn(2)], { from: holder });
expect(await this.token.balanceOf(holder, tokenIds[0])).to.be.bignumber.equal('1');
expect(await this.token.balanceOf(holder, tokenIds[1])).to.be.bignumber.equal('2');
});
it("approved operators can burn the holder's tokens", async function () {
await this.token.setApprovalForAll(operator, true, { from: holder });
await this.token.burnBatch(holder, tokenIds, [amounts[0].subn(1), amounts[1].subn(2)], { from: operator });
expect(await this.token.balanceOf(holder, tokenIds[0])).to.be.bignumber.equal('1');
expect(await this.token.balanceOf(holder, tokenIds[1])).to.be.bignumber.equal('2');
});
it("unapproved accounts cannot burn the holder's tokens", async function () {
await expectRevert(
this.token.burnBatch(holder, tokenIds, [amounts[0].subn(1), amounts[1].subn(2)], { from: other }),
'ERC1155: caller is not token owner or approved',
);
});
});
});
@@ -0,0 +1,108 @@
const { BN, expectRevert } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
const ERC1155Pausable = artifacts.require('$ERC1155Pausable');
contract('ERC1155Pausable', function (accounts) {
const [holder, operator, receiver, other] = accounts;
const uri = 'https://token.com';
beforeEach(async function () {
this.token = await ERC1155Pausable.new(uri);
});
context('when token is paused', function () {
const firstTokenId = new BN('37');
const firstTokenAmount = new BN('42');
const secondTokenId = new BN('19842');
const secondTokenAmount = new BN('23');
beforeEach(async function () {
await this.token.setApprovalForAll(operator, true, { from: holder });
await this.token.$_mint(holder, firstTokenId, firstTokenAmount, '0x');
await this.token.$_pause();
});
it('reverts when trying to safeTransferFrom from holder', async function () {
await expectRevert(
this.token.safeTransferFrom(holder, receiver, firstTokenId, firstTokenAmount, '0x', { from: holder }),
'ERC1155Pausable: token transfer while paused',
);
});
it('reverts when trying to safeTransferFrom from operator', async function () {
await expectRevert(
this.token.safeTransferFrom(holder, receiver, firstTokenId, firstTokenAmount, '0x', { from: operator }),
'ERC1155Pausable: token transfer while paused',
);
});
it('reverts when trying to safeBatchTransferFrom from holder', async function () {
await expectRevert(
this.token.safeBatchTransferFrom(holder, receiver, [firstTokenId], [firstTokenAmount], '0x', { from: holder }),
'ERC1155Pausable: token transfer while paused',
);
});
it('reverts when trying to safeBatchTransferFrom from operator', async function () {
await expectRevert(
this.token.safeBatchTransferFrom(holder, receiver, [firstTokenId], [firstTokenAmount], '0x', {
from: operator,
}),
'ERC1155Pausable: token transfer while paused',
);
});
it('reverts when trying to mint', async function () {
await expectRevert(
this.token.$_mint(holder, secondTokenId, secondTokenAmount, '0x'),
'ERC1155Pausable: token transfer while paused',
);
});
it('reverts when trying to mintBatch', async function () {
await expectRevert(
this.token.$_mintBatch(holder, [secondTokenId], [secondTokenAmount], '0x'),
'ERC1155Pausable: token transfer while paused',
);
});
it('reverts when trying to burn', async function () {
await expectRevert(
this.token.$_burn(holder, firstTokenId, firstTokenAmount),
'ERC1155Pausable: token transfer while paused',
);
});
it('reverts when trying to burnBatch', async function () {
await expectRevert(
this.token.$_burnBatch(holder, [firstTokenId], [firstTokenAmount]),
'ERC1155Pausable: token transfer while paused',
);
});
describe('setApprovalForAll', function () {
it('approves an operator', async function () {
await this.token.setApprovalForAll(other, true, { from: holder });
expect(await this.token.isApprovedForAll(holder, other)).to.equal(true);
});
});
describe('balanceOf', function () {
it('returns the amount of tokens owned by the given address', async function () {
const balance = await this.token.balanceOf(holder, firstTokenId);
expect(balance).to.be.bignumber.equal(firstTokenAmount);
});
});
describe('isApprovedForAll', function () {
it('returns the approval of the operator', async function () {
expect(await this.token.isApprovedForAll(holder, operator)).to.equal(true);
});
});
});
});
@@ -0,0 +1,107 @@
const { BN } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
const ERC1155Supply = artifacts.require('$ERC1155Supply');
contract('ERC1155Supply', function (accounts) {
const [holder] = accounts;
const uri = 'https://token.com';
const firstTokenId = new BN('37');
const firstTokenAmount = new BN('42');
const secondTokenId = new BN('19842');
const secondTokenAmount = new BN('23');
beforeEach(async function () {
this.token = await ERC1155Supply.new(uri);
});
context('before mint', function () {
it('exist', async function () {
expect(await this.token.exists(firstTokenId)).to.be.equal(false);
});
it('totalSupply', async function () {
expect(await this.token.totalSupply(firstTokenId)).to.be.bignumber.equal('0');
});
});
context('after mint', function () {
context('single', function () {
beforeEach(async function () {
await this.token.$_mint(holder, firstTokenId, firstTokenAmount, '0x');
});
it('exist', async function () {
expect(await this.token.exists(firstTokenId)).to.be.equal(true);
});
it('totalSupply', async function () {
expect(await this.token.totalSupply(firstTokenId)).to.be.bignumber.equal(firstTokenAmount);
});
});
context('batch', function () {
beforeEach(async function () {
await this.token.$_mintBatch(
holder,
[firstTokenId, secondTokenId],
[firstTokenAmount, secondTokenAmount],
'0x',
);
});
it('exist', async function () {
expect(await this.token.exists(firstTokenId)).to.be.equal(true);
expect(await this.token.exists(secondTokenId)).to.be.equal(true);
});
it('totalSupply', async function () {
expect(await this.token.totalSupply(firstTokenId)).to.be.bignumber.equal(firstTokenAmount);
expect(await this.token.totalSupply(secondTokenId)).to.be.bignumber.equal(secondTokenAmount);
});
});
});
context('after burn', function () {
context('single', function () {
beforeEach(async function () {
await this.token.$_mint(holder, firstTokenId, firstTokenAmount, '0x');
await this.token.$_burn(holder, firstTokenId, firstTokenAmount);
});
it('exist', async function () {
expect(await this.token.exists(firstTokenId)).to.be.equal(false);
});
it('totalSupply', async function () {
expect(await this.token.totalSupply(firstTokenId)).to.be.bignumber.equal('0');
});
});
context('batch', function () {
beforeEach(async function () {
await this.token.$_mintBatch(
holder,
[firstTokenId, secondTokenId],
[firstTokenAmount, secondTokenAmount],
'0x',
);
await this.token.$_burnBatch(holder, [firstTokenId, secondTokenId], [firstTokenAmount, secondTokenAmount]);
});
it('exist', async function () {
expect(await this.token.exists(firstTokenId)).to.be.equal(false);
expect(await this.token.exists(secondTokenId)).to.be.equal(false);
});
it('totalSupply', async function () {
expect(await this.token.totalSupply(firstTokenId)).to.be.bignumber.equal('0');
expect(await this.token.totalSupply(secondTokenId)).to.be.bignumber.equal('0');
});
});
});
});
@@ -0,0 +1,66 @@
const { BN, expectEvent } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
const { artifacts } = require('hardhat');
const ERC1155URIStorage = artifacts.require('$ERC1155URIStorage');
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 ERC1155URIStorage.new(erc1155Uri);
await 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 ERC1155URIStorage.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 });
});
});
});