forked from storyprotocol/protocol-periphery-v1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUpgradeHelper.s.sol
106 lines (90 loc) · 4.62 KB
/
UpgradeHelper.s.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
/* solhint-disable no-console */
// external
import { console2 } from "forge-std/console2.sol";
import { Script } from "forge-std/Script.sol";
import { UpgradeableBeacon } from "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol";
// contract
import { DerivativeWorkflows } from "../../../contracts/workflows/DerivativeWorkflows.sol";
import { GroupingWorkflows } from "../../../contracts/workflows/GroupingWorkflows.sol";
import { LicenseAttachmentWorkflows } from "../../../contracts/workflows/LicenseAttachmentWorkflows.sol";
import { RegistrationWorkflows } from "../../../contracts/workflows/RegistrationWorkflows.sol";
import { RoyaltyWorkflows } from "../../../contracts/workflows/RoyaltyWorkflows.sol";
import { RoyaltyTokenDistributionWorkflows } from "../../../contracts/workflows/RoyaltyTokenDistributionWorkflows.sol";
import { SPGNFT } from "../../../contracts/SPGNFT.sol";
// script
import { BroadcastManager } from "../../utils/BroadcastManager.s.sol";
import { JsonDeploymentHandler } from "../../utils/JsonDeploymentHandler.s.sol";
import { StoryProtocolCoreAddressManager } from "../../utils/StoryProtocolCoreAddressManager.sol";
import { StoryProtocolPeripheryAddressManager } from "../../utils/StoryProtocolPeripheryAddressManager.sol";
import { StringUtil } from "../../utils/StringUtil.sol";
contract UpgradeHelper is
Script,
StoryProtocolCoreAddressManager,
StoryProtocolPeripheryAddressManager,
BroadcastManager,
JsonDeploymentHandler
{
using StringUtil for uint256;
/// @dev workflow contracts
DerivativeWorkflows internal derivativeWorkflows;
GroupingWorkflows internal groupingWorkflows;
LicenseAttachmentWorkflows internal licenseAttachmentWorkflows;
RegistrationWorkflows internal registrationWorkflows;
RoyaltyWorkflows internal royaltyWorkflows;
RoyaltyTokenDistributionWorkflows internal royaltyTokenDistributionWorkflows;
/// @dev SPGNFT contracts
SPGNFT internal spgNftImpl;
UpgradeableBeacon internal spgNftBeacon;
// TODO: change these four addresses when upgrading Story NFTs
address public orgNftAddr = address(0x1);
address public orgStoryNftFactoryAddr = address(0x2);
address public defaultOrgStoryNftBeaconAddr = address(0x3);
address public defaultOrgStoryNftTemplateAddr = address(0x4);
constructor() JsonDeploymentHandler("main") {}
function run() public virtual {
_readStoryProtocolCoreAddresses(); // StoryProtocolCoreAddressManager.s.sol
_readStoryProtocolPeripheryAddresses(); // StoryProtocolPeripheryAddressManager.s.sol
derivativeWorkflows = DerivativeWorkflows(derivativeWorkflowsAddr);
groupingWorkflows = GroupingWorkflows(groupingWorkflowsAddr);
licenseAttachmentWorkflows = LicenseAttachmentWorkflows(licenseAttachmentWorkflowsAddr);
registrationWorkflows = RegistrationWorkflows(registrationWorkflowsAddr);
royaltyWorkflows = RoyaltyWorkflows(royaltyWorkflowsAddr);
royaltyTokenDistributionWorkflows = RoyaltyTokenDistributionWorkflows(
royaltyTokenDistributionWorkflowsAddr
);
spgNftImpl = SPGNFT(spgNftImplAddr);
spgNftBeacon = UpgradeableBeacon(spgNftBeaconAddr);
}
function _predeploy(string memory contractKey) internal pure {
console2.log(string.concat("Deploying ", contractKey, "..."));
}
function _postdeploy(string memory contractKey, address newAddress) internal {
_writeAddress(contractKey, newAddress);
console2.log(string.concat(contractKey, " deployed to:"), newAddress);
}
function _writeAllAddresses() internal {
string[] memory contractKeys = new string[](8);
contractKeys[0] = "DerivativeWorkflows";
contractKeys[1] = "GroupingWorkflows";
contractKeys[2] = "LicenseAttachmentWorkflows";
contractKeys[3] = "RegistrationWorkflows";
contractKeys[4] = "RoyaltyWorkflows";
contractKeys[5] = "RoyaltyTokenDistributionWorkflows";
contractKeys[6] = "SPGNFTBeacon";
contractKeys[7] = "SPGNFTImpl";
address[] memory addresses = new address[](8);
addresses[0] = derivativeWorkflowsAddr;
addresses[1] = groupingWorkflowsAddr;
addresses[2] = licenseAttachmentWorkflowsAddr;
addresses[3] = registrationWorkflowsAddr;
addresses[4] = royaltyWorkflowsAddr;
addresses[5] = royaltyTokenDistributionWorkflowsAddr;
addresses[6] = spgNftBeaconAddr;
addresses[7] = spgNftImplAddr;
for (uint256 i = 0; i < contractKeys.length; i++) {
_writeAddress(contractKeys[i], addresses[i]);
}
}
}