Skip to content

Commit

Permalink
Merge pull request #798 from rndquu/refactor/move-ubiquistick
Browse files Browse the repository at this point in the history
Refactor/move ubiquistick
  • Loading branch information
rndquu authored Oct 2, 2023
2 parents bd43fae + d425427 commit bcb66d3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 22 deletions.
6 changes: 3 additions & 3 deletions packages/contracts/src/dollar/core/ERC1155Ubiquity.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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();
Expand All @@ -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);
}

Expand Down
6 changes: 3 additions & 3 deletions packages/contracts/src/dollar/libraries/LibBondingCurve.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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();
}
}
Expand Down
16 changes: 0 additions & 16 deletions packages/contracts/test/helpers/UUPSTestHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -27,7 +26,6 @@ contract UUPSTestHelper {
UbiquityCreditToken creditToken;
UbiquityDollarToken dollarToken;
UbiquityGovernanceToken governanceToken;
ERC1155Ubiquity ubiquiStick;

// proxies for core contracts
ERC1967Proxy proxyCreditNft;
Expand Down Expand Up @@ -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));
Expand Down

1 comment on commit bcb66d3

@ubiquibot
Copy link

@ubiquibot ubiquibot bot commented on bcb66d3 Oct 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.