-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Create
BlastQuestFactory
to configure operator
- Loading branch information
1 parent
d0e7c24
commit eff2ea9
Showing
3 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity 0.8.19; | ||
|
||
import {QuestFactory} from "./QuestFactory.sol"; | ||
|
||
interface IBlastPoints { | ||
function configurePointsOperator(address operator) external; | ||
function configurePointsOperatorOnBehalf(address contractAddress, address operator) external; | ||
} | ||
|
||
contract BlastQuestFactory is QuestFactory { | ||
function configurePointsOperator(address operatorAddress) external onlyOwner { | ||
address BlastPointsAddress = 0x2536FE9ab3F511540F2f9e2eC2A805005C3Dd800; // BlastPoints Mainnet address | ||
IBlastPoints(BlastPointsAddress).configurePointsOperator(operatorAddress); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// SPDX-License-Identifier: Unlicense | ||
pragma solidity 0.8.19; | ||
|
||
// solhint-disable no-global-import, no-console | ||
import "forge-std/Test.sol"; | ||
import "forge-std/console.sol"; | ||
|
||
import {BlastQuestFactory} from "contracts/BlastQuestFactory.sol"; | ||
import {QuestFactory} from "contracts/QuestFactory.sol"; | ||
import {IQuestFactory} from "contracts/interfaces/IQuestFactory.sol"; | ||
import {Quest} from "contracts/Quest.sol"; | ||
import {Quest1155} from "contracts/Quest1155.sol"; | ||
import {LibClone} from "solady/utils/LibClone.sol"; | ||
import {LibString} from "solady/utils/LibString.sol"; | ||
import {ECDSA} from "openzeppelin-contracts/utils/cryptography/ECDSA.sol"; | ||
import {LibZip} from "solady/utils/LibZip.sol"; | ||
import {JSONParserLib} from "solady/utils/JSONParserLib.sol"; | ||
import {Errors} from "./helpers/Errors.sol"; | ||
import {Events} from "./helpers/Events.sol"; | ||
import {TestUtils} from "./helpers/TestUtils.sol"; | ||
import {QuestContractConstants as C} from "../contracts/libraries/QuestContractConstants.sol"; | ||
import {ProxyAdmin, ITransparentUpgradeableProxy} from "openzeppelin-contracts/proxy/transparent/ProxyAdmin.sol"; | ||
|
||
interface IBlastPoints { | ||
function configurePointsOperator(address operator) external; | ||
function configurePointsOperatorOnBehalf(address contractAddress, address operator) external; | ||
function operators(address operator) external returns (address); | ||
} | ||
|
||
// forge test --fork-url https://rpc.blast.io --match-path test/BlastQuestFactory.t.sol | ||
contract TestQuestFactory is Test, Errors, Events, TestUtils { | ||
using LibClone for address; | ||
using LibString for address; | ||
using LibString for string; | ||
using JSONParserLib for string; | ||
using LibString for uint256; | ||
|
||
QuestFactory questFactory; | ||
BlastQuestFactory blastQuestFactory; | ||
address owner; | ||
address random = makeAddr("random"); | ||
address blastPointsAddress = 0x2536FE9ab3F511540F2f9e2eC2A805005C3Dd800; // BlastPoints Mainnet address | ||
|
||
function setUp() public { | ||
questFactory = QuestFactory(C.QUEST_FACTORY_ADDRESS); | ||
owner = questFactory.owner(); | ||
|
||
vm.startPrank(owner); | ||
// upgrade QuestFactory to BlastQuestFactory | ||
ITransparentUpgradeableProxy questfactoryProxy = ITransparentUpgradeableProxy(C.QUEST_FACTORY_ADDRESS); | ||
ProxyAdmin(C.PROXY_ADMIN_ADDRESS).upgrade(questfactoryProxy, address(new BlastQuestFactory())); | ||
blastQuestFactory = BlastQuestFactory(C.QUEST_FACTORY_ADDRESS); | ||
vm.stopPrank(); | ||
} | ||
|
||
function test_configurePointsOperator() public { | ||
vm.deal(random, 1 ether); | ||
|
||
vm.prank(random); | ||
vm.expectRevert(); | ||
blastQuestFactory.configurePointsOperator(random); | ||
|
||
vm.prank(owner); | ||
blastQuestFactory.configurePointsOperator(owner); | ||
|
||
address operatorAddress = IBlastPoints(blastPointsAddress).operators(C.QUEST_FACTORY_ADDRESS); | ||
assertEq(operatorAddress, owner); | ||
} | ||
|
||
} |