From cbc1c50719cabdeb940a5a2a61082d933991cb39 Mon Sep 17 00:00:00 2001 From: Andrew Richardson Date: Fri, 1 Mar 2024 23:49:49 -0500 Subject: [PATCH] Update to latest OpenZeppelin base contracts Signed-off-by: Andrew Richardson --- samples/solidity/contracts/ERC1155MixedFungible.sol | 5 ++--- samples/solidity/package-lock.json | 8 ++++---- samples/solidity/package.json | 2 +- samples/solidity/test/ERC1155MixedFungible.ts | 4 ++-- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/samples/solidity/contracts/ERC1155MixedFungible.sol b/samples/solidity/contracts/ERC1155MixedFungible.sol index 44c3649..e526c1e 100644 --- a/samples/solidity/contracts/ERC1155MixedFungible.sol +++ b/samples/solidity/contracts/ERC1155MixedFungible.sol @@ -3,7 +3,6 @@ pragma solidity ^0.8.0; import '@openzeppelin/contracts/token/ERC1155/ERC1155.sol'; import '@openzeppelin/contracts/utils/Context.sol'; -import '@openzeppelin/contracts/utils/math/SafeMath.sol'; import './IERC1155MixedFungible.sol'; /** @@ -114,7 +113,7 @@ contract ERC1155MixedFungible is Context, ERC1155, IERC1155MixedFungible { // Indexes are 1-based. uint256 index = maxIndex[type_id] + 1; - maxIndex[type_id] = SafeMath.add(to.length, maxIndex[type_id]); + maxIndex[type_id] = to.length + maxIndex[type_id]; for (uint256 i = 0; i < to.length; ++i) { _mint(to[i], type_id | (index + i), 1, data); @@ -134,7 +133,7 @@ contract ERC1155MixedFungible is Context, ERC1155, IERC1155MixedFungible { // Indexes are 1-based. uint256 index = maxIndex[type_id] + 1; - maxIndex[type_id] = SafeMath.add(to.length, maxIndex[type_id]); + maxIndex[type_id] = to.length + maxIndex[type_id]; for (uint256 i = 0; i < to.length; ++i) { uint256 id = type_id | (index + i); diff --git a/samples/solidity/package-lock.json b/samples/solidity/package-lock.json index 548ce43..0133df1 100644 --- a/samples/solidity/package-lock.json +++ b/samples/solidity/package-lock.json @@ -8,7 +8,7 @@ "name": "@hyperledger/firefly-tokens-erc1155-contracts", "version": "0.0.2", "dependencies": { - "@openzeppelin/contracts": "^4.5.0" + "@openzeppelin/contracts": "^5.0.2" }, "devDependencies": { "@nomicfoundation/hardhat-toolbox": "^4.0.0", @@ -1493,9 +1493,9 @@ } }, "node_modules/@openzeppelin/contracts": { - "version": "4.9.5", - "resolved": "https://registry.npmjs.org/@openzeppelin/contracts/-/contracts-4.9.5.tgz", - "integrity": "sha512-ZK+W5mVhRppff9BE6YdR8CC52C8zAvsVAiWhEtQ5+oNxFE6h1WdeWo+FJSF8KKvtxxVYZ7MTP/5KoVpAU3aSWg==" + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@openzeppelin/contracts/-/contracts-5.0.2.tgz", + "integrity": "sha512-ytPc6eLGcHHnapAZ9S+5qsdomhjo6QBHTDRRBFfTxXIpsicMhVPouPgmUPebZZZGX7vt9USA+Z+0M0dSVtSUEA==" }, "node_modules/@scure/base": { "version": "1.1.5", diff --git a/samples/solidity/package.json b/samples/solidity/package.json index 9c26882..c6fccc7 100644 --- a/samples/solidity/package.json +++ b/samples/solidity/package.json @@ -6,7 +6,7 @@ "test": "hardhat test --network hardhat" }, "dependencies": { - "@openzeppelin/contracts": "^4.5.0" + "@openzeppelin/contracts": "^5.0.2" }, "devDependencies": { "@nomicfoundation/hardhat-toolbox": "^4.0.0", diff --git a/samples/solidity/test/ERC1155MixedFungible.ts b/samples/solidity/test/ERC1155MixedFungible.ts index e616575..e36c6ce 100644 --- a/samples/solidity/test/ERC1155MixedFungible.ts +++ b/samples/solidity/test/ERC1155MixedFungible.ts @@ -241,7 +241,7 @@ describe('ERC1155MixedFungible - Unit Tests', () => { 1, '0x00', ), - ).to.be.revertedWith('ERC1155: caller is not token owner or approved'); + ).to.be.revertedWithCustomError(deployedERC1155, 'ERC1155MissingApprovalForAll'); expect( await deployedERC1155 .connect(deployerSignerA) @@ -371,7 +371,7 @@ describe('ERC1155MixedFungible - Unit Tests', () => { 1, '0x00', ), - ).to.be.revertedWith('ERC1155: caller is not token owner or approved'); + ).to.be.revertedWithCustomError(deployedERC1155, 'ERC1155MissingApprovalForAll'); expect( await deployedERC1155 .connect(deployerSignerA)