diff --git a/packages/contracts/src/dollar/core/ERC1155Ubiquity.sol b/packages/contracts/src/dollar/core/ERC1155Ubiquity.sol index 6f82fe3c1..6c211deb5 100644 --- a/packages/contracts/src/dollar/core/ERC1155Ubiquity.sol +++ b/packages/contracts/src/dollar/core/ERC1155Ubiquity.sol @@ -18,7 +18,7 @@ import "../../../src/dollar/utils/SafeAddArray.sol"; * - TotalSupply per id * - Ubiquity Manager access control */ -contract ERC1155Ubiquity is +abstract contract ERC1155Ubiquity is Initializable, ERC1155BurnableUpgradeable, ERC1155PausableUpgradeable, @@ -84,7 +84,7 @@ contract ERC1155Ubiquity is function __ERC1155Ubiquity_init( address _manager, string memory _uri - ) public initializer onlyInitializing { + ) internal onlyInitializing { // init base contracts __ERC1155_init(_uri); __ERC1155Burnable_init(); @@ -98,7 +98,7 @@ contract ERC1155Ubiquity is /// @param _manager Address of the manager of the contract function __ERC1155Ubiquity_init_unchained( address _manager - ) public initializer onlyInitializing { + ) internal onlyInitializing { accessControl = IAccessControl(_manager); } diff --git a/packages/contracts/src/dollar/libraries/LibBondingCurve.sol b/packages/contracts/src/dollar/libraries/LibBondingCurve.sol index 65205c608..22544d998 100644 --- a/packages/contracts/src/dollar/libraries/LibBondingCurve.sol +++ b/packages/contracts/src/dollar/libraries/LibBondingCurve.sol @@ -5,6 +5,7 @@ import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import {LibAppStorage} from "./LibAppStorage.sol"; +import {UbiquiStick} from "../../ubiquistick/UbiquiStick.sol"; import "../../ubiquistick/interfaces/IUbiquiStick.sol"; import "../interfaces/IERC1155Ubiquity.sol"; import "./Constants.sol"; @@ -132,14 +133,13 @@ library LibBondingCurve { dollar.transferFrom(_recipient, address(this), _collateralDeposited); ss.poolBalance = ss.poolBalance + _collateralDeposited; - bytes memory tokReturned = toBytes(tokensReturned); ss.share[_recipient] += tokensReturned; ss.tokenIds += 1; - IERC1155Ubiquity bNFT = IERC1155Ubiquity( + UbiquiStick ubiquiStick = UbiquiStick( LibAppStorage.appStorage().ubiquiStickAddress ); - bNFT.mint(_recipient, ss.tokenIds, tokensReturned, tokReturned); + ubiquiStick.batchSafeMint(_recipient, tokensReturned); emit Deposit(_recipient, _collateralDeposited); } diff --git a/packages/contracts/test/diamond/facets/BondingCurveFacet.t.sol b/packages/contracts/test/diamond/facets/BondingCurveFacet.t.sol index fa33ea2d4..9a6e64880 100644 --- a/packages/contracts/test/diamond/facets/BondingCurveFacet.t.sol +++ b/packages/contracts/test/diamond/facets/BondingCurveFacet.t.sol @@ -4,7 +4,10 @@ pragma solidity 0.8.19; import "../DiamondTestSetup.sol"; import "../../../src/dollar/libraries/Constants.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; +import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; import {MockERC20} from "../../../src/dollar/mocks/MockERC20.sol"; +import {ERC1155Ubiquity} from "../../../src/dollar/core/ERC1155Ubiquity.sol"; +import {UbiquiStick} from "../../../src/ubiquistick/UbiquiStick.sol"; import "forge-std/Test.sol"; contract BondingCurveFacetTest is DiamondSetup { @@ -28,11 +31,17 @@ contract BondingCurveFacetTest is DiamondSetup { super.setUp(); vm.startPrank(admin); + IAccessControl.grantRole( GOVERNANCE_TOKEN_MINTER_ROLE, address(diamond) ); + // deploy UbiquiStick + UbiquiStick ubiquiStick = new UbiquiStick(); + ubiquiStick.setMinter(address(diamond)); + IManager.setUbiquistickAddress(address(ubiquiStick)); + vm.stopPrank(); } } diff --git a/packages/contracts/test/helpers/UUPSTestHelper.sol b/packages/contracts/test/helpers/UUPSTestHelper.sol index 696726e66..21769d096 100644 --- a/packages/contracts/test/helpers/UUPSTestHelper.sol +++ b/packages/contracts/test/helpers/UUPSTestHelper.sol @@ -8,7 +8,6 @@ import {UbiquityCreditToken} from "../../src/dollar/core/UbiquityCreditToken.sol import {StakingShare} from "../../src/dollar/core/StakingShare.sol"; import {CreditNft} from "../../src/dollar/core/CreditNft.sol"; import {ManagerFacet} from "../../src/dollar/facets/ManagerFacet.sol"; -import {ERC1155Ubiquity} from "../../src/dollar/core/ERC1155Ubiquity.sol"; import "../../src/dollar/libraries/Constants.sol"; import "forge-std/Test.sol"; @@ -27,7 +26,6 @@ contract UUPSTestHelper { UbiquityCreditToken creditToken; UbiquityDollarToken dollarToken; UbiquityGovernanceToken governanceToken; - ERC1155Ubiquity ubiquiStick; // proxies for core contracts ERC1967Proxy proxyCreditNft; @@ -88,22 +86,8 @@ contract UUPSTestHelper { address(proxyGovernanceToken) ); - // deploy UbiquiStick (not a core contract, not upgradeable) - // TODO: move from UUPSTestHelper to a more relevant place - initData = abi.encodeWithSignature( - "__ERC1155Ubiquity_init(address,string)", - diamond, - uri - ); - proxyUbiquiStick = new ERC1967Proxy( - address(new ERC1155Ubiquity()), - initData - ); - ubiquiStick = ERC1155Ubiquity(address(proxyUbiquiStick)); - // set addresses of the newly deployed contracts in the Diamond ManagerFacet managerFacet = ManagerFacet(diamond); - managerFacet.setUbiquistickAddress(address(ubiquiStick)); managerFacet.setStakingShareAddress(address(stakingShare)); managerFacet.setCreditTokenAddress(address(creditToken)); managerFacet.setDollarTokenAddress(address(dollarToken));