mirror of
https://github.com/placeholder-soft/gifted-contracts-v2.git
synced 2026-01-12 15:23:44 +08:00
* feat: add NFT Vault * feat: add ts script to update config address * feat: update readme * add nodejs * chore: remove unused files; * deploy vault to dev * deploy vault to staging * deploy vault to prod
63 lines
1.9 KiB
Solidity
63 lines
1.9 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity ^0.8.20;
|
|
|
|
import {Script, console} from "forge-std/Script.sol";
|
|
import "../src/NFTVault.sol";
|
|
import "../src/UnifiedStore.sol";
|
|
|
|
contract DeployVault is Script {
|
|
NFTVault public nftVault;
|
|
UnifiedStore public unifiedStore;
|
|
|
|
address public manager;
|
|
|
|
function run() public {
|
|
deploy_contracts();
|
|
setup_roles();
|
|
update_unified_store();
|
|
}
|
|
|
|
function deploy_contracts() internal {
|
|
vm.startBroadcast(getAddressFromConfig("deployer"));
|
|
|
|
nftVault = new NFTVault();
|
|
|
|
vm.stopBroadcast();
|
|
}
|
|
|
|
function setup_roles() internal {
|
|
vm.startBroadcast(getAddressFromConfig("deployer"));
|
|
|
|
manager = getAddressFromConfig("manager");
|
|
nftVault.grantManagerRole(manager);
|
|
|
|
vm.stopBroadcast();
|
|
}
|
|
|
|
function update_unified_store() internal {
|
|
vm.startBroadcast(getAddressFromConfig("deployer"));
|
|
|
|
address unifiedStoreAddress = getAddressFromConfig("UnifiedStore");
|
|
unifiedStore = UnifiedStore(unifiedStoreAddress);
|
|
|
|
string[] memory keys = new string[](1);
|
|
address[] memory addresses = new address[](1);
|
|
|
|
keys[0] = "NFTVault";
|
|
addresses[0] = address(nftVault);
|
|
|
|
unifiedStore.setAddresses(keys, addresses);
|
|
|
|
vm.stopBroadcast();
|
|
}
|
|
|
|
function getAddressFromConfig(string memory key) internal view returns (address) {
|
|
string memory env = vm.envString("DEPLOY_ENV");
|
|
require(bytes(env).length > 0, "DEPLOY_ENV must be set");
|
|
string memory root = vm.projectRoot();
|
|
string memory path = string.concat(root, "/config/", env, "_addresses.json");
|
|
string memory json = vm.readFile(path);
|
|
bytes memory addressBytes = vm.parseJson(json, string.concat(".", vm.toString(block.chainid), ".", key));
|
|
return abi.decode(addressBytes, (address));
|
|
}
|
|
} |