Commit 4b49242e by Francisco Giordano

add non-upgrade-safe erc1155

parent bf0277b3
// SPDX-License-Identifier: MIT
pragma solidity ^0.5.0;
import "../token/ERC1155/ERC1155Burnable.sol";
contract ERC1155BurnableMock is ERC1155Burnable {
constructor(string memory uri) public ERC1155(uri) { }
function mint(address to, uint256 id, uint256 value, bytes memory data) public {
_mint(to, id, value, data);
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.5.0;
import "../token/ERC1155/ERC1155.sol";
/**
* @title ERC1155Mock
* This mock just publicizes internal functions for testing purposes
*/
contract ERC1155Mock is ERC1155 {
constructor (string memory uri) public ERC1155(uri) {
// solhint-disable-previous-line no-empty-blocks
}
function setURI(string memory newuri) public {
_setURI(newuri);
}
function mint(address to, uint256 id, uint256 value, bytes memory data) public {
_mint(to, id, value, data);
}
function mintBatch(address to, uint256[] memory ids, uint256[] memory values, bytes memory data) public {
_mintBatch(to, ids, values, data);
}
function burn(address owner, uint256 id, uint256 value) public {
_burn(owner, id, value);
}
function burnBatch(address owner, uint256[] memory ids, uint256[] memory values) public {
_burnBatch(owner, ids, values);
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.5.0;
import "../token/ERC1155/IERC1155Receiver.sol";
import "./ERC165Mock.sol";
contract ERC1155ReceiverMock is IERC1155Receiver, ERC165Mock {
bytes4 private _recRetval;
bool private _recReverts;
bytes4 private _batRetval;
bool private _batReverts;
event Received(address operator, address from, uint256 id, uint256 value, bytes data, uint256 gas);
event BatchReceived(address operator, address from, uint256[] ids, uint256[] values, bytes data, uint256 gas);
constructor (
bytes4 recRetval,
bool recReverts,
bytes4 batRetval,
bool batReverts
)
public
{
_recRetval = recRetval;
_recReverts = recReverts;
_batRetval = batRetval;
_batReverts = batReverts;
}
function onERC1155Received(
address operator,
address from,
uint256 id,
uint256 value,
bytes calldata data
)
external
returns(bytes4)
{
require(!_recReverts, "ERC1155ReceiverMock: reverting on receive");
emit Received(operator, from, id, value, data, gasleft());
return _recRetval;
}
function onERC1155BatchReceived(
address operator,
address from,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
)
external
returns(bytes4)
{
require(!_batReverts, "ERC1155ReceiverMock: reverting on batch receive");
emit BatchReceived(operator, from, ids, values, data, gasleft());
return _batRetval;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.5.0;
import "./ERC1155.sol";
/**
* @dev Extension of {ERC1155} that allows token holders to destroy both their
* own tokens and those that they have been approved to use.
*
* _Available since v3.1._
*/
contract ERC1155Burnable is ERC1155 {
function burn(address account, uint256 id, uint256 value) public {
require(
account == _msgSender() || isApprovedForAll(account, _msgSender()),
"ERC1155: caller is not owner nor approved"
);
_burn(account, id, value);
}
function burnBatch(address account, uint256[] memory ids, uint256[] memory values) public {
require(
account == _msgSender() || isApprovedForAll(account, _msgSender()),
"ERC1155: caller is not owner nor approved"
);
_burnBatch(account, ids, values);
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.5.0;
import "./ERC1155Receiver.sol";
/**
* @dev _Available since v3.1._
*/
contract ERC1155Holder is ERC1155Receiver {
function onERC1155Received(address, address, uint256, uint256, bytes memory) public returns (bytes4) {
return this.onERC1155Received.selector;
}
function onERC1155BatchReceived(address, address, uint256[] memory, uint256[] memory, bytes memory) public returns (bytes4) {
return this.onERC1155BatchReceived.selector;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.5.0;
import "./IERC1155Receiver.sol";
import "../../introspection/ERC165.sol";
/**
* @dev _Available since v3.1._
*/
contract ERC1155Receiver is ERC165, IERC1155Receiver {
constructor() public {
_registerInterface(
ERC1155Receiver(0).onERC1155Received.selector ^
ERC1155Receiver(0).onERC1155BatchReceived.selector
);
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.5.0;
import "../../introspection/IERC165.sol";
/**
* @dev Required interface of an ERC1155 compliant contract, as defined in the
* https://eips.ethereum.org/EIPS/eip-1155[EIP].
*
* _Available since v3.1._
*/
contract IERC1155 is IERC165 {
/**
* @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
*/
event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);
/**
* @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
* transfers.
*/
event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values);
/**
* @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
* `approved`.
*/
event ApprovalForAll(address indexed account, address indexed operator, bool approved);
/**
* @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
*
* If an {URI} event was emitted for `id`, the standard
* https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
* returned by {IERC1155MetadataURI-uri}.
*/
event URI(string value, uint256 indexed id);
/**
* @dev Returns the amount of tokens of token type `id` owned by `account`.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id) external view returns (uint256);
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory);
/**
* @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
*
* Emits an {ApprovalForAll} event.
*
* Requirements:
*
* - `operator` cannot be the caller.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address account, address operator) external view returns (bool);
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}.
* - `from` must have a balance of tokens of type `id` of at least `amount`.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external;
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function safeBatchTransferFrom(address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data) external;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.5.0;
import "./IERC1155.sol";
/**
* @dev Interface of the optional ERC1155MetadataExtension interface, as defined
* in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP].
*
* _Available since v3.1._
*/
contract IERC1155MetadataURI is IERC1155 {
/**
* @dev Returns the URI for token type `id`.
*
* If the `\{id\}` substring is present in the URI, it must be replaced by
* clients with the actual token type ID.
*/
function uri(uint256 id) external view returns (string memory);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.5.0;
import "../../introspection/IERC165.sol";
/**
* _Available since v3.1._
*/
contract IERC1155Receiver is IERC165 {
/**
@dev Handles the receipt of a single ERC1155 token type. This function is
called at the end of a `safeTransferFrom` after the balance has been updated.
To accept the transfer, this must return
`bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
(i.e. 0xf23a6e61, or its own function selector).
@param operator The address which initiated the transfer (i.e. msg.sender)
@param from The address which previously owned the token
@param id The ID of the token being transferred
@param value The amount of tokens being transferred
@param data Additional data with no specified format
@return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
*/
function onERC1155Received(
address operator,
address from,
uint256 id,
uint256 value,
bytes calldata data
)
external
returns(bytes4);
/**
@dev Handles the receipt of a multiple ERC1155 token types. This function
is called at the end of a `safeBatchTransferFrom` after the balances have
been updated. To accept the transfer(s), this must return
`bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
(i.e. 0xbc197c81, or its own function selector).
@param operator The address which initiated the batch transfer (i.e. msg.sender)
@param from The address which previously owned the token
@param ids An array containing ids of each token being transferred (order and length must match values array)
@param values An array containing amounts of each token being transferred (order and length must match ids array)
@param data Additional data with no specified format
@return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
*/
function onERC1155BatchReceived(
address operator,
address from,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
)
external
returns(bytes4);
}
= ERC 1155
[.readme-notice]
NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/token/erc1155
This set of interfaces and contracts are all related to the https://eips.ethereum.org/EIPS/eip-1155[ERC1155 Multi Token Standard].
The EIP consists of three interfaces which fulfill different roles, found here as {IERC1155}, {IERC1155MetadataURI} and {IERC1155Receiver}.
{ERC1155} implements the mandatory {IERC1155} interface, as well as the optional extension {IERC1155MetadataURI}, by relying on the substitution mechanism to use the same URI for all token types, dramatically reducing gas costs.
Additionally there are multiple custom extensions, including:
* designation of addresses that can pause token transfers for all users ({ERC1155Pausable}).
* destruction of own tokens ({ERC1155Burnable}).
NOTE: This core set of contracts is designed to be unopinionated, allowing developers to access the internal functions in ERC1155 (such as <<ERC1155-_mint-address-uint256-uint256-bytes-,`_mint`>>) and expose them as external functions in the way they prefer. On the other hand, xref:ROOT:erc1155.adoc#Presets[ERC1155 Presets] (such as {ERC1155PresetMinterPauser}) are designed using opinionated patterns to provide developers with ready to use, deployable contracts.
== Core
{{IERC1155}}
{{IERC1155MetadataURI}}
{{ERC1155}}
{{IERC1155Receiver}}
== Extensions
{{ERC1155Pausable}}
{{ERC1155Burnable}}
== Convenience
{{ERC1155Holder}}
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
"@openzeppelin/gsn-helpers": "^0.2.3", "@openzeppelin/gsn-helpers": "^0.2.3",
"@openzeppelin/gsn-provider": "^0.1.9", "@openzeppelin/gsn-provider": "^0.1.9",
"@openzeppelin/test-environment": "^0.1.2", "@openzeppelin/test-environment": "^0.1.2",
"@openzeppelin/test-helpers": "^0.5.4", "@openzeppelin/test-helpers": "^0.5.6",
"chai": "^4.2.0", "chai": "^4.2.0",
"concurrently": "^4.1.0", "concurrently": "^4.1.0",
"eslint": "^6.5.1", "eslint": "^6.5.1",
......
...@@ -27,6 +27,14 @@ const INTERFACES = { ...@@ -27,6 +27,14 @@ const INTERFACES = {
'symbol()', 'symbol()',
'tokenURI(uint256)', 'tokenURI(uint256)',
], ],
ERC1155: [
'balanceOf(address,uint256)',
'balanceOfBatch(address[],uint256[])',
'setApprovalForAll(address,bool)',
'isApprovedForAll(address,address)',
'safeTransferFrom(address,address,uint256,uint256,bytes)',
'safeBatchTransferFrom(address,address,uint256[],uint256[],bytes)',
],
}; };
const INTERFACE_IDS = {}; const INTERFACE_IDS = {};
......
const { accounts, contract } = require('@openzeppelin/test-environment');
const { BN, constants, expectEvent, expectRevert } = require('@openzeppelin/test-helpers');
const { ZERO_ADDRESS } = constants;
const { expect } = require('chai');
const { shouldBehaveLikeERC1155 } = require('./ERC1155.behavior');
const ERC1155Mock = contract.fromArtifact('ERC1155Mock');
describe('ERC1155', function () {
const [operator, tokenHolder, tokenBatchHolder, ...otherAccounts] = accounts;
const initialURI = 'https://token-cdn-domain/{id}.json';
beforeEach(async function () {
this.token = await ERC1155Mock.new(initialURI);
});
shouldBehaveLikeERC1155(otherAccounts);
describe('internal functions', function () {
const tokenId = new BN(1990);
const mintAmount = new BN(9001);
const burnAmount = new BN(3000);
const tokenBatchIds = [new BN(2000), new BN(2010), new BN(2020)];
const mintAmounts = [new BN(5000), new BN(10000), new BN(42195)];
const burnAmounts = [new BN(5000), new BN(9001), new BN(195)];
const data = '0x12345678';
describe('_mint', function () {
it('reverts with a zero destination address', async function () {
await expectRevert(
this.token.mint(ZERO_ADDRESS, tokenId, mintAmount, data),
'ERC1155: mint to the zero address'
);
});
context('with minted tokens', function () {
beforeEach(async function () {
({ logs: this.logs } = await this.token.mint(tokenHolder, tokenId, mintAmount, data, { from: operator }));
});
it('emits a TransferSingle event', function () {
expectEvent.inLogs(this.logs, 'TransferSingle', {
operator,
from: ZERO_ADDRESS,
to: tokenHolder,
id: tokenId,
value: mintAmount,
});
});
it('credits the minted amount of tokens', async function () {
expect(await this.token.balanceOf(tokenHolder, tokenId)).to.be.bignumber.equal(mintAmount);
});
});
});
describe('_mintBatch', function () {
it('reverts with a zero destination address', async function () {
await expectRevert(
this.token.mintBatch(ZERO_ADDRESS, tokenBatchIds, mintAmounts, data),
'ERC1155: mint to the zero address'
);
});
it('reverts if length of inputs do not match', async function () {
await expectRevert(
this.token.mintBatch(tokenBatchHolder, tokenBatchIds, mintAmounts.slice(1), data),
'ERC1155: ids and amounts length mismatch'
);
await expectRevert(
this.token.mintBatch(tokenBatchHolder, tokenBatchIds.slice(1), mintAmounts, data),
'ERC1155: ids and amounts length mismatch'
);
});
context('with minted batch of tokens', function () {
beforeEach(async function () {
({ logs: this.logs } = await this.token.mintBatch(
tokenBatchHolder,
tokenBatchIds,
mintAmounts,
data,
{ from: operator }
));
});
it('emits a TransferBatch event', function () {
expectEvent.inLogs(this.logs, 'TransferBatch', {
operator,
from: ZERO_ADDRESS,
to: tokenBatchHolder,
});
});
it('credits the minted batch of tokens', async function () {
const holderBatchBalances = await this.token.balanceOfBatch(
new Array(tokenBatchIds.length).fill(tokenBatchHolder),
tokenBatchIds
);
for (let i = 0; i < holderBatchBalances.length; i++) {
expect(holderBatchBalances[i]).to.be.bignumber.equal(mintAmounts[i]);
}
});
});
});
describe('_burn', function () {
it('reverts when burning the zero account\'s tokens', async function () {
await expectRevert(
this.token.burn(ZERO_ADDRESS, tokenId, mintAmount),
'ERC1155: burn from the zero address'
);
});
it('reverts when burning a non-existent token id', async function () {
await expectRevert(
this.token.burn(tokenHolder, tokenId, mintAmount),
'ERC1155: burn amount exceeds balance'
);
});
it('reverts when burning more than available tokens', async function () {
await this.token.mint(
tokenHolder,
tokenId,
mintAmount,
data,
{ from: operator }
);
await expectRevert(
this.token.burn(tokenHolder, tokenId, mintAmount.addn(1)),
'ERC1155: burn amount exceeds balance'
);
});
context('with minted-then-burnt tokens', function () {
beforeEach(async function () {
await this.token.mint(tokenHolder, tokenId, mintAmount, data);
({ logs: this.logs } = await this.token.burn(
tokenHolder,
tokenId,
burnAmount,
{ from: operator }
));
});
it('emits a TransferSingle event', function () {
expectEvent.inLogs(this.logs, 'TransferSingle', {
operator,
from: tokenHolder,
to: ZERO_ADDRESS,
id: tokenId,
value: burnAmount,
});
});
it('accounts for both minting and burning', async function () {
expect(await this.token.balanceOf(
tokenHolder,
tokenId
)).to.be.bignumber.equal(mintAmount.sub(burnAmount));
});
});
});
describe('_burnBatch', function () {
it('reverts when burning the zero account\'s tokens', async function () {
await expectRevert(
this.token.burnBatch(ZERO_ADDRESS, tokenBatchIds, burnAmounts),
'ERC1155: burn from the zero address'
);
});
it('reverts if length of inputs do not match', async function () {
await expectRevert(
this.token.burnBatch(tokenBatchHolder, tokenBatchIds, burnAmounts.slice(1)),
'ERC1155: ids and amounts length mismatch'
);
await expectRevert(
this.token.burnBatch(tokenBatchHolder, tokenBatchIds.slice(1), burnAmounts),
'ERC1155: ids and amounts length mismatch'
);
});
it('reverts when burning a non-existent token id', async function () {
await expectRevert(
this.token.burnBatch(tokenBatchHolder, tokenBatchIds, burnAmounts),
'ERC1155: burn amount exceeds balance'
);
});
context('with minted-then-burnt tokens', function () {
beforeEach(async function () {
await this.token.mintBatch(tokenBatchHolder, tokenBatchIds, mintAmounts, data);
({ logs: this.logs } = await this.token.burnBatch(
tokenBatchHolder,
tokenBatchIds,
burnAmounts,
{ from: operator }
));
});
it('emits a TransferBatch event', function () {
expectEvent.inLogs(this.logs, 'TransferBatch', {
operator,
from: tokenBatchHolder,
to: ZERO_ADDRESS,
// ids: tokenBatchIds,
// values: burnAmounts,
});
});
it('accounts for both minting and burning', async function () {
const holderBatchBalances = await this.token.balanceOfBatch(
new Array(tokenBatchIds.length).fill(tokenBatchHolder),
tokenBatchIds
);
for (let i = 0; i < holderBatchBalances.length; i++) {
expect(holderBatchBalances[i]).to.be.bignumber.equal(mintAmounts[i].sub(burnAmounts[i]));
}
});
});
});
});
describe('ERC1155MetadataURI', function () {
const firstTokenID = new BN('42');
const secondTokenID = new BN('1337');
it('emits no URI event in constructor', async function () {
await expectEvent.notEmitted.inConstruction(this.token, 'URI');
});
it('sets the initial URI for all token types', async function () {
expect(await this.token.uri(firstTokenID)).to.be.equal(initialURI);
expect(await this.token.uri(secondTokenID)).to.be.equal(initialURI);
});
describe('_setURI', function () {
const newURI = 'https://token-cdn-domain/{locale}/{id}.json';
it('emits no URI event', async function () {
const receipt = await this.token.setURI(newURI);
expectEvent.notEmitted(receipt, 'URI');
});
it('sets the new URI for all token types', async function () {
await this.token.setURI(newURI);
expect(await this.token.uri(firstTokenID)).to.be.equal(newURI);
expect(await this.token.uri(secondTokenID)).to.be.equal(newURI);
});
});
});
});
const { accounts, contract } = require('@openzeppelin/test-environment');
const { BN, expectRevert } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
const ERC1155BurnableMock = contract.fromArtifact('ERC1155BurnableMock');
describe('ERC1155Burnable', function () {
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 ERC1155BurnableMock.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 owner nor 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 owner nor approved'
);
});
});
});
const { accounts, contract } = require('@openzeppelin/test-environment');
const { BN } = require('@openzeppelin/test-helpers');
const ERC1155Holder = contract.fromArtifact('ERC1155Holder');
const ERC1155Mock = contract.fromArtifact('ERC1155Mock');
const { expect } = require('chai');
describe('ERC1155Holder', function () {
const [creator] = accounts;
const uri = 'https://token-cdn-domain/{id}.json';
const multiTokenIds = [new BN(1), new BN(2), new BN(3)];
const multiTokenAmounts = [new BN(1000), new BN(2000), new BN(3000)];
const transferData = '0x12345678';
beforeEach(async function () {
this.multiToken = await ERC1155Mock.new(uri, { from: creator });
this.holder = await ERC1155Holder.new();
await this.multiToken.mintBatch(creator, multiTokenIds, multiTokenAmounts, '0x', { from: creator });
});
it('receives ERC1155 tokens from a single ID', async function () {
await this.multiToken.safeTransferFrom(
creator,
this.holder.address,
multiTokenIds[0],
multiTokenAmounts[0],
transferData,
{ from: creator },
);
expect(await this.multiToken.balanceOf(this.holder.address, multiTokenIds[0]))
.to.be.bignumber.equal(multiTokenAmounts[0]);
for (let i = 1; i < multiTokenIds.length; i++) {
expect(await this.multiToken.balanceOf(this.holder.address, multiTokenIds[i])).to.be.bignumber.equal(new BN(0));
}
});
it('receives ERC1155 tokens from a multiple IDs', async function () {
for (let i = 0; i < multiTokenIds.length; i++) {
expect(await this.multiToken.balanceOf(this.holder.address, multiTokenIds[i])).to.be.bignumber.equal(new BN(0));
};
await this.multiToken.safeBatchTransferFrom(
creator,
this.holder.address,
multiTokenIds,
multiTokenAmounts,
transferData,
{ from: creator },
);
for (let i = 0; i < multiTokenIds.length; i++) {
expect(await this.multiToken.balanceOf(this.holder.address, multiTokenIds[i]))
.to.be.bignumber.equal(multiTokenAmounts[i]);
}
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment