diff --git a/abi/ProfileV2.json b/abi/ProfileV2.json new file mode 100644 index 00000000..8f49f9d0 --- /dev/null +++ b/abi/ProfileV2.json @@ -0,0 +1,638 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "hubAddress", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "EmptyNodeId", + "type": "error" + }, + { + "inputs": [], + "name": "EmptySharesTokenName", + "type": "error" + }, + { + "inputs": [], + "name": "EmptySharesTokenSymbol", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint72", + "name": "identityId", + "type": "uint72" + }, + { + "internalType": "address", + "name": "wallet", + "type": "address" + } + ], + "name": "IdentityAlreadyExists", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "nodeId", + "type": "bytes" + } + ], + "name": "NodeIdAlreadyExists", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "caller", + "type": "address" + } + ], + "name": "OnlyProfileAdminFunction", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "caller", + "type": "address" + } + ], + "name": "OnlyProfileAdminOrOperationalAddressesFunction", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "caller", + "type": "address" + } + ], + "name": "OnlyWhitelistedAddressesFunction", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "operatorFee", + "type": "uint8" + } + ], + "name": "OperatorFeeOutOfRange", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "tokenName", + "type": "string" + } + ], + "name": "SharesTokenNameAlreadyExists", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "tokenSymbol", + "type": "string" + } + ], + "name": "SharesTokenSymbolAlreadyExists", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint16", + "name": "allowed", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "provided", + "type": "uint16" + } + ], + "name": "TooManyOperationalWallets", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "nowTimestamp", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "endTimestamp", + "type": "uint256" + } + ], + "name": "WithdrawalPeriodPending", + "type": "error" + }, + { + "inputs": [], + "name": "WithdrawalWasntInitiated", + "type": "error" + }, + { + "inputs": [], + "name": "ZeroAsk", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint72", + "name": "identityId", + "type": "uint72" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "nodeId", + "type": "bytes" + }, + { + "indexed": false, + "internalType": "uint96", + "name": "oldAccumulatedOperatorFee", + "type": "uint96" + }, + { + "indexed": false, + "internalType": "uint96", + "name": "newAccumulatedOperatorFee", + "type": "uint96" + } + ], + "name": "AccumulatedOperatorFeeRestaked", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint72", + "name": "identityId", + "type": "uint72" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "nodeId", + "type": "bytes" + }, + { + "indexed": false, + "internalType": "uint96", + "name": "oldAccumulatedOperatorFee", + "type": "uint96" + }, + { + "indexed": false, + "internalType": "uint96", + "name": "newAccumulatedOperatorFee", + "type": "uint96" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "withdrawalPeriodEnd", + "type": "uint256" + } + ], + "name": "AccumulatedOperatorFeeWithdrawalStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint72", + "name": "identityId", + "type": "uint72" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "nodeId", + "type": "bytes" + }, + { + "indexed": false, + "internalType": "uint96", + "name": "withdrawnAmount", + "type": "uint96" + } + ], + "name": "AccumulatedOperatorFeeWithdrawn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint72", + "name": "identityId", + "type": "uint72" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "nodeId", + "type": "bytes" + }, + { + "indexed": false, + "internalType": "uint96", + "name": "ask", + "type": "uint96" + } + ], + "name": "AskUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint72", + "name": "identityId", + "type": "uint72" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "nodeId", + "type": "bytes" + }, + { + "indexed": false, + "internalType": "address", + "name": "adminWallet", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "sharesContractAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint8", + "name": "initialOperatorFee", + "type": "uint8" + } + ], + "name": "ProfileCreated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint72", + "name": "identityId", + "type": "uint72" + } + ], + "name": "ProfileDeleted", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "adminWallet", + "type": "address" + }, + { + "internalType": "address[]", + "name": "operationalWallets", + "type": "address[]" + }, + { + "internalType": "bytes", + "name": "nodeId", + "type": "bytes" + }, + { + "internalType": "string", + "name": "sharesTokenName", + "type": "string" + }, + { + "internalType": "string", + "name": "sharesTokenSymbol", + "type": "string" + }, + { + "internalType": "uint8", + "name": "initialOperatorFee", + "type": "uint8" + } + ], + "name": "createProfile", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "hashingProxy", + "outputs": [ + { + "internalType": "contract HashingProxy", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "hub", + "outputs": [ + { + "internalType": "contract Hub", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "identityContract", + "outputs": [ + { + "internalType": "contract Identity", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "identityStorage", + "outputs": [ + { + "internalType": "contract IdentityStorageV2", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "nodeOperatorFeesStorage", + "outputs": [ + { + "internalType": "contract NodeOperatorFeesStorage", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "parametersStorage", + "outputs": [ + { + "internalType": "contract ParametersStorage", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "profileStorage", + "outputs": [ + { + "internalType": "contract ProfileStorage", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint72", + "name": "identityId", + "type": "uint72" + }, + { + "internalType": "uint96", + "name": "ask", + "type": "uint96" + } + ], + "name": "setAsk", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "_status", + "type": "bool" + } + ], + "name": "setStatus", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "shardingTableContract", + "outputs": [ + { + "internalType": "contract ShardingTableV2", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint72", + "name": "identityId", + "type": "uint72" + }, + { + "internalType": "uint96", + "name": "restakeAmount", + "type": "uint96" + } + ], + "name": "stakeAccumulatedOperatorFee", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "stakingContract", + "outputs": [ + { + "internalType": "contract StakingV2", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "stakingStorage", + "outputs": [ + { + "internalType": "contract StakingStorage", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint72", + "name": "identityId", + "type": "uint72" + }, + { + "internalType": "uint96", + "name": "withdrawalAmount", + "type": "uint96" + } + ], + "name": "startAccumulatedOperatorFeeWithdrawal", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "status", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "version", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "whitelistStorage", + "outputs": [ + { + "internalType": "contract WhitelistStorage", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint72", + "name": "identityId", + "type": "uint72" + } + ], + "name": "withdrawAccumulatedOperatorFee", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/contracts/v2/Profile.sol b/contracts/v2/Profile.sol new file mode 100644 index 00000000..41df3f60 --- /dev/null +++ b/contracts/v2/Profile.sol @@ -0,0 +1,296 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8.16; + +import {HashingProxy} from "../v1/HashingProxy.sol"; +import {Identity} from "../v1/Identity.sol"; +import {Shares} from "../v1/Shares.sol"; +import {IdentityStorageV2} from "./storage/IdentityStorage.sol"; +import {ParametersStorage} from "../v1/storage/ParametersStorage.sol"; +import {ProfileStorage} from "../v1/storage/ProfileStorage.sol"; +import {ShardingTableV2} from "./ShardingTable.sol"; +import {StakingStorage} from "../v1/storage/StakingStorage.sol"; +import {StakingV2} from "./Staking.sol"; +import {NodeOperatorFeesStorage} from "./storage/NodeOperatorFeesStorage.sol"; +import {WhitelistStorage} from "../v1/storage/WhitelistStorage.sol"; +import {ContractStatus} from "../v1/abstract/ContractStatus.sol"; +import {Initializable} from "../v1/interface/Initializable.sol"; +import {Named} from "../v1/interface/Named.sol"; +import {Versioned} from "../v1/interface/Versioned.sol"; +import {GeneralErrors} from "../v1/errors/GeneralErrors.sol"; +import {ProfileErrors} from "../v1/errors/ProfileErrors.sol"; +import {StakingErrors} from "../v1/errors/StakingErrors.sol"; +import {UnorderedIndexableContractDynamicSetLib} from "../v1/utils/UnorderedIndexableContractDynamicSet.sol"; +import {ADMIN_KEY, OPERATIONAL_KEY} from "../v1/constants/IdentityConstants.sol"; + +contract ProfileV2 is Named, Versioned, ContractStatus, Initializable { + event ProfileCreated( + uint72 indexed identityId, + bytes nodeId, + address adminWallet, + address sharesContractAddress, + uint8 initialOperatorFee + ); + event ProfileDeleted(uint72 indexed identityId); + event AskUpdated(uint72 indexed identityId, bytes nodeId, uint96 ask); + event AccumulatedOperatorFeeWithdrawalStarted( + uint72 indexed identityId, + bytes nodeId, + uint96 oldAccumulatedOperatorFee, + uint96 newAccumulatedOperatorFee, + uint256 withdrawalPeriodEnd + ); + event AccumulatedOperatorFeeWithdrawn(uint72 indexed identityId, bytes nodeId, uint96 withdrawnAmount); + event AccumulatedOperatorFeeRestaked( + uint72 indexed identityId, + bytes nodeId, + uint96 oldAccumulatedOperatorFee, + uint96 newAccumulatedOperatorFee + ); + + string private constant _NAME = "ProfileV2"; + string private constant _VERSION = "2.0.0"; + + HashingProxy public hashingProxy; + Identity public identityContract; + ShardingTableV2 public shardingTableContract; + StakingStorage public stakingStorage; + StakingV2 public stakingContract; + IdentityStorageV2 public identityStorage; + ParametersStorage public parametersStorage; + ProfileStorage public profileStorage; + WhitelistStorage public whitelistStorage; + NodeOperatorFeesStorage public nodeOperatorFeesStorage; + + // solhint-disable-next-line no-empty-blocks + constructor(address hubAddress) ContractStatus(hubAddress) {} + + modifier onlyIdentityOwner(uint72 identityId) { + _checkIdentityOwner(identityId); + _; + } + + modifier onlyAdmin(uint72 identityId) { + _checkAdmin(identityId); + _; + } + + modifier onlyOperational(uint72 identityId) { + _checkOperational(identityId); + _; + } + + modifier onlyWhitelisted() { + _checkWhitelist(); + _; + } + + function initialize() public onlyHubOwner { + hashingProxy = HashingProxy(hub.getContractAddress("HashingProxy")); + identityContract = Identity(hub.getContractAddress("Identity")); + shardingTableContract = ShardingTableV2(hub.getContractAddress("ShardingTable")); + stakingStorage = StakingStorage(hub.getContractAddress("StakingStorage")); + stakingContract = StakingV2(hub.getContractAddress("Staking")); + identityStorage = IdentityStorageV2(hub.getContractAddress("IdentityStorage")); + parametersStorage = ParametersStorage(hub.getContractAddress("ParametersStorage")); + profileStorage = ProfileStorage(hub.getContractAddress("ProfileStorage")); + whitelistStorage = WhitelistStorage(hub.getContractAddress("WhitelistStorage")); + nodeOperatorFeesStorage = NodeOperatorFeesStorage(hub.getContractAddress("NodeOperatorFeesStorage")); + } + + function name() external pure virtual override returns (string memory) { + return _NAME; + } + + function version() external pure virtual override returns (string memory) { + return _VERSION; + } + + function createProfile( + address adminWallet, + address[] calldata operationalWallets, + bytes calldata nodeId, + string calldata sharesTokenName, + string calldata sharesTokenSymbol, + uint8 initialOperatorFee + ) external onlyWhitelisted { + IdentityStorageV2 ids = identityStorage; + ProfileStorage ps = profileStorage; + NodeOperatorFeesStorage nofs = nodeOperatorFeesStorage; + Identity id = identityContract; + + if (ids.getIdentityId(msg.sender) != 0) { + revert ProfileErrors.IdentityAlreadyExists(ids.getIdentityId(msg.sender), msg.sender); + } + if (operationalWallets.length > parametersStorage.opWalletsLimitOnProfileCreation()) { + revert ProfileErrors.TooManyOperationalWallets( + parametersStorage.opWalletsLimitOnProfileCreation(), + uint16(operationalWallets.length) + ); + } + if (nodeId.length == 0) { + revert ProfileErrors.EmptyNodeId(); + } + if (ps.nodeIdsList(nodeId)) { + revert ProfileErrors.NodeIdAlreadyExists(nodeId); + } + if (keccak256(abi.encodePacked(sharesTokenName)) == keccak256(abi.encodePacked(""))) { + revert ProfileErrors.EmptySharesTokenName(); + } + if (keccak256(abi.encodePacked(sharesTokenSymbol)) == keccak256(abi.encodePacked(""))) { + revert ProfileErrors.EmptySharesTokenSymbol(); + } + if (ps.sharesNames(sharesTokenName)) { + revert ProfileErrors.SharesTokenNameAlreadyExists(sharesTokenName); + } + if (ps.sharesSymbols(sharesTokenSymbol)) { + revert ProfileErrors.SharesTokenSymbolAlreadyExists(sharesTokenSymbol); + } + if (initialOperatorFee > 100) { + revert ProfileErrors.OperatorFeeOutOfRange(initialOperatorFee); + } + uint72 identityId = id.createIdentity(msg.sender, adminWallet); + id.addOperationalWallets(identityId, operationalWallets); + + Shares sharesContract = new Shares(address(hub), sharesTokenName, sharesTokenSymbol); + + ps.createProfile(identityId, nodeId, address(sharesContract)); + _setAvailableNodeAddresses(identityId); + + nofs.addOperatorFee(identityId, initialOperatorFee, uint248(block.timestamp)); + + shardingTableContract.insertNode(identityId); + + emit ProfileCreated(identityId, nodeId, adminWallet, address(sharesContract), initialOperatorFee); + } + + function setAsk(uint72 identityId, uint96 ask) external onlyIdentityOwner(identityId) { + if (ask == 0) { + revert ProfileErrors.ZeroAsk(); + } + ProfileStorage ps = profileStorage; + ps.setAsk(identityId, ask); + + emit AskUpdated(identityId, ps.getNodeId(identityId), ask); + } + + function _setAvailableNodeAddresses(uint72 identityId) internal virtual { + ProfileStorage ps = profileStorage; + HashingProxy hp = hashingProxy; + + bytes memory nodeId = ps.getNodeId(identityId); + bytes32 nodeAddress; + + UnorderedIndexableContractDynamicSetLib.Contract[] memory hashFunctions = hp.getAllHashFunctions(); + require(hashFunctions.length <= parametersStorage.hashFunctionsLimit(), "Too many hash functions!"); + uint8 hashFunctionId; + for (uint8 i; i < hashFunctions.length; ) { + hashFunctionId = hashFunctions[i].id; + nodeAddress = hp.callHashFunction(hashFunctionId, nodeId); + ps.setNodeAddress(identityId, hashFunctionId, nodeAddress); + unchecked { + i++; + } + } + } + + function stakeAccumulatedOperatorFee(uint72 identityId, uint96 restakeAmount) external onlyAdmin(identityId) { + require(restakeAmount != 0, "Restake amount cannot be 0"); + + ProfileStorage ps = profileStorage; + + uint96 oldAccumulatedOperatorFee = ps.getAccumulatedOperatorFee(identityId); + + require(restakeAmount <= oldAccumulatedOperatorFee, "Restake must be <= balance"); + + ps.setAccumulatedOperatorFee(identityId, oldAccumulatedOperatorFee - restakeAmount); + stakingContract.addStake(msg.sender, identityId, restakeAmount); + + emit AccumulatedOperatorFeeRestaked( + identityId, + ps.getNodeId(identityId), + oldAccumulatedOperatorFee, + oldAccumulatedOperatorFee - restakeAmount + ); + } + + function startAccumulatedOperatorFeeWithdrawal( + uint72 identityId, + uint96 withdrawalAmount + ) external onlyAdmin(identityId) { + require(withdrawalAmount != 0, "Withdrawal amount cannot be 0"); + + ProfileStorage ps = profileStorage; + + uint96 oldAccumulatedOperatorFee = ps.getAccumulatedOperatorFee(identityId); + + require(withdrawalAmount <= oldAccumulatedOperatorFee, "Withdrawal must be <= balance"); + + ps.setAccumulatedOperatorFee(identityId, oldAccumulatedOperatorFee - withdrawalAmount); + ps.setAccumulatedOperatorFeeWithdrawalAmount( + identityId, + ps.getAccumulatedOperatorFeeWithdrawalAmount(identityId) + withdrawalAmount + ); + ps.setAccumulatedOperatorFeeWithdrawalTimestamp( + identityId, + block.timestamp + parametersStorage.stakeWithdrawalDelay() + ); + + emit AccumulatedOperatorFeeWithdrawalStarted( + identityId, + ps.getNodeId(identityId), + oldAccumulatedOperatorFee, + oldAccumulatedOperatorFee - withdrawalAmount, + block.timestamp + parametersStorage.stakeWithdrawalDelay() + ); + } + + function withdrawAccumulatedOperatorFee(uint72 identityId) external onlyAdmin(identityId) { + ProfileStorage ps = profileStorage; + + uint96 withdrawalAmount = ps.getAccumulatedOperatorFeeWithdrawalAmount(identityId); + + if (withdrawalAmount == 0) { + revert StakingErrors.WithdrawalWasntInitiated(); + } + if (ps.getAccumulatedOperatorFeeWithdrawalTimestamp(identityId) >= block.timestamp) { + revert StakingErrors.WithdrawalPeriodPending( + block.timestamp, + ps.getAccumulatedOperatorFeeWithdrawalTimestamp(identityId) + ); + } + ps.setAccumulatedOperatorFeeWithdrawalAmount(identityId, 0); + ps.setAccumulatedOperatorFeeWithdrawalTimestamp(identityId, 0); + ps.transferAccumulatedOperatorFee(msg.sender, withdrawalAmount); + + emit AccumulatedOperatorFeeWithdrawn(identityId, ps.getNodeId(identityId), withdrawalAmount); + } + + function _checkIdentityOwner(uint72 identityId) internal view virtual { + if ( + !identityStorage.keyHasPurpose(identityId, keccak256(abi.encodePacked(msg.sender)), ADMIN_KEY) && + !identityStorage.keyHasPurpose(identityId, keccak256(abi.encodePacked(msg.sender)), OPERATIONAL_KEY) + ) { + revert GeneralErrors.OnlyProfileAdminOrOperationalAddressesFunction(msg.sender); + } + } + + function _checkAdmin(uint72 identityId) internal view virtual { + if (!identityStorage.keyHasPurpose(identityId, keccak256(abi.encodePacked(msg.sender)), ADMIN_KEY)) { + revert GeneralErrors.OnlyProfileAdminFunction(msg.sender); + } + } + + function _checkOperational(uint72 identityId) internal view virtual { + if (!identityStorage.keyHasPurpose(identityId, keccak256(abi.encodePacked(msg.sender)), OPERATIONAL_KEY)) { + revert GeneralErrors.OnlyProfileOperationalWalletFunction(msg.sender); + } + } + + function _checkWhitelist() internal view virtual { + WhitelistStorage ws = whitelistStorage; + if (ws.whitelistingEnabled() && !ws.whitelisted(msg.sender)) { + revert GeneralErrors.OnlyWhitelistedAddressesFunction(msg.sender); + } + } +} diff --git a/deploy/035_deploy_profile_v2.ts b/deploy/035_deploy_profile_v2.ts new file mode 100644 index 00000000..4b916c5b --- /dev/null +++ b/deploy/035_deploy_profile_v2.ts @@ -0,0 +1,35 @@ +import { DeployFunction } from 'hardhat-deploy/types'; +import { HardhatRuntimeEnvironment } from 'hardhat/types'; + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + if ( + hre.helpers.isDeployed('Profile') && + (hre.helpers.contractDeployments.contracts['Profile'].version === undefined || + hre.helpers.contractDeployments.contracts['Profile'].version?.startsWith('1.')) + ) { + return; + } + + console.log('Deploying Profile V2...'); + + await hre.helpers.deploy({ + newContractName: 'ProfileV2', + newContractNameInHub: 'Profile', + }); +}; + +export default func; +func.tags = ['Profile', 'v2']; +func.dependencies = [ + 'Hub', + 'Identity', + 'IdentityStorageV2', + 'ParametersStorage', + 'ProfileStorage', + 'HashingProxy', + 'SHA256', + 'ShardingTableV2', + 'Staking', + 'WhitelistStorage', + 'NodeOperatorFeesStorage', +]; diff --git a/deploy/035_deploy_profile.ts b/deploy/036_deploy_profile.ts similarity index 63% rename from deploy/035_deploy_profile.ts rename to deploy/036_deploy_profile.ts index 63aabe4c..e63a8daa 100644 --- a/deploy/035_deploy_profile.ts +++ b/deploy/036_deploy_profile.ts @@ -2,6 +2,16 @@ import { DeployFunction } from 'hardhat-deploy/types'; import { HardhatRuntimeEnvironment } from 'hardhat/types'; const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + if ( + hre.helpers.isDeployed('Profile') && + (hre.helpers.contractDeployments.contracts['Profile'].version === undefined || + hre.helpers.contractDeployments.contracts['Profile'].version?.startsWith('2.')) + ) { + return; + } + + console.log('Deploying Profile V1...'); + await hre.helpers.deploy({ newContractName: 'Profile', }); @@ -17,7 +27,7 @@ func.dependencies = [ 'ProfileStorage', 'HashingProxy', 'SHA256', - 'Staking', + 'StakingV2', 'WhitelistStorage', 'NodeOperatorFeesStorage', ]; diff --git a/deploy/036_deploy_commit_manager_v2.ts b/deploy/037_deploy_commit_manager_v2.ts similarity index 100% rename from deploy/036_deploy_commit_manager_v2.ts rename to deploy/037_deploy_commit_manager_v2.ts diff --git a/deploy/037_deploy_commit_manager_v1.ts b/deploy/038_deploy_commit_manager_v1.ts similarity index 100% rename from deploy/037_deploy_commit_manager_v1.ts rename to deploy/038_deploy_commit_manager_v1.ts diff --git a/deploy/038_deploy_commit_manager_v2_u1.ts b/deploy/039_deploy_commit_manager_v2_u1.ts similarity index 100% rename from deploy/038_deploy_commit_manager_v2_u1.ts rename to deploy/039_deploy_commit_manager_v2_u1.ts diff --git a/deploy/039_deploy_commit_manager_v1_u1.ts b/deploy/040_deploy_commit_manager_v1_u1.ts similarity index 100% rename from deploy/039_deploy_commit_manager_v1_u1.ts rename to deploy/040_deploy_commit_manager_v1_u1.ts diff --git a/deploy/040_deploy_proof_manager_v1.ts b/deploy/041_deploy_proof_manager_v1.ts similarity index 100% rename from deploy/040_deploy_proof_manager_v1.ts rename to deploy/041_deploy_proof_manager_v1.ts diff --git a/deploy/041_deploy_proof_manager_v1_u1.ts b/deploy/042_deploy_proof_manager_v1_u1.ts similarity index 100% rename from deploy/041_deploy_proof_manager_v1_u1.ts rename to deploy/042_deploy_proof_manager_v1_u1.ts diff --git a/deploy/042_deploy_service_agreement_v1.ts b/deploy/043_deploy_service_agreement_v1.ts similarity index 100% rename from deploy/042_deploy_service_agreement_v1.ts rename to deploy/043_deploy_service_agreement_v1.ts diff --git a/deploy/043_deploy_content_asset_v2.ts b/deploy/044_deploy_content_asset_v2.ts similarity index 100% rename from deploy/043_deploy_content_asset_v2.ts rename to deploy/044_deploy_content_asset_v2.ts diff --git a/deploy/044_deploy_content_asset.ts b/deploy/045_deploy_content_asset.ts similarity index 100% rename from deploy/044_deploy_content_asset.ts rename to deploy/045_deploy_content_asset.ts diff --git a/deploy/045_deploy_paranet.ts b/deploy/046_deploy_paranet.ts similarity index 100% rename from deploy/045_deploy_paranet.ts rename to deploy/046_deploy_paranet.ts diff --git a/deploy/046_deploy_paranet_incentives_pool_factory.ts b/deploy/047_deploy_paranet_incentives_pool_factory.ts similarity index 100% rename from deploy/046_deploy_paranet_incentives_pool_factory.ts rename to deploy/047_deploy_paranet_incentives_pool_factory.ts diff --git a/deployments/base_sepolia_v8_test_contracts.json b/deployments/base_sepolia_v8_test_contracts.json index 4a2aa09d..13eb83e6 100644 --- a/deployments/base_sepolia_v8_test_contracts.json +++ b/deployments/base_sepolia_v8_test_contracts.json @@ -86,39 +86,39 @@ "deployed": true }, "IdentityStorage": { - "evmAddress": "0x678062306AE52291447Fc2EA0b739A529cD9e911", + "evmAddress": "0x0161431A5ea766daA82f0b327d7e5e628856Dc95", "version": "2.0.0", "gitBranch": "v8/curated-paranets", - "gitCommitHash": "2f42b4c1922decb1aa952cc93c8a7c556b6193cd", - "deploymentBlock": 16045460, - "deploymentTimestamp": 1727859211192, + "gitCommitHash": "055075ff63240e82a1ef3e0d1ec4e4edcfa4804c", + "deploymentBlock": 16136707, + "deploymentTimestamp": 1728041708659, "deployed": true }, "ShardingTableStorage": { - "evmAddress": "0xB3e3B2fa6431f39bB8C84F9FE2767575c73cbE1B", + "evmAddress": "0x10239c8B2Aaa1964c5b06948547ef28B61E5FCe1", "version": "2.0.0", "gitBranch": "v8/curated-paranets", - "gitCommitHash": "2f42b4c1922decb1aa952cc93c8a7c556b6193cd", - "deploymentBlock": 16045463, - "deploymentTimestamp": 1727859220685, + "gitCommitHash": "055075ff63240e82a1ef3e0d1ec4e4edcfa4804c", + "deploymentBlock": 16136712, + "deploymentTimestamp": 1728041714996, "deployed": true }, "StakingStorage": { - "evmAddress": "0x550c3d4D32c49E9dB7EC7aFb6646DC785A382Ed9", + "evmAddress": "0xb488A974253782e58027c8264ba3f2BE0462FEbe", "version": "1.0.0", "gitBranch": "v8/curated-paranets", - "gitCommitHash": "2f42b4c1922decb1aa952cc93c8a7c556b6193cd", - "deploymentBlock": 16045468, - "deploymentTimestamp": 1727859230374, + "gitCommitHash": "055075ff63240e82a1ef3e0d1ec4e4edcfa4804c", + "deploymentBlock": 16136715, + "deploymentTimestamp": 1728041725070, "deployed": true }, "ProfileStorage": { - "evmAddress": "0xfD189554E96a4e228F8e552Ba0d5198EAdbdeFB2", + "evmAddress": "0xB4beBbea70a42C5C7dF0941c1CaCFf9345e87790", "version": "1.0.0", "gitBranch": "v8/curated-paranets", - "gitCommitHash": "2f42b4c1922decb1aa952cc93c8a7c556b6193cd", - "deploymentBlock": 16045472, - "deploymentTimestamp": 1727859234311, + "gitCommitHash": "055075ff63240e82a1ef3e0d1ec4e4edcfa4804c", + "deploymentBlock": 16136720, + "deploymentTimestamp": 1728041735274, "deployed": true }, "ServiceAgreementStorageV1": { @@ -167,39 +167,39 @@ "deployed": true }, "ParanetsRegistry": { - "evmAddress": "0x7Db8F6fA5627FC66207F7c918455204C33771757", + "evmAddress": "0x08938EB44b97E74eb4DcBeCee0a79485469a3dD5", "version": "2.2.0", "gitBranch": "v8/curated-paranets", - "gitCommitHash": "2f42b4c1922decb1aa952cc93c8a7c556b6193cd", - "deploymentBlock": 16045497, - "deploymentTimestamp": 1727859289108, + "gitCommitHash": "055075ff63240e82a1ef3e0d1ec4e4edcfa4804c", + "deploymentBlock": 16136725, + "deploymentTimestamp": 1728041746545, "deployed": true }, "ParanetServicesRegistry": { - "evmAddress": "0x7bD42742c6ec4D49242d8d5142F0FE0175148443", + "evmAddress": "0xFb69598F2FA10Bd52C7EE8E0B4B37aC5e83630f8", "version": "2.1.0", "gitBranch": "v8/curated-paranets", - "gitCommitHash": "2f42b4c1922decb1aa952cc93c8a7c556b6193cd", - "deploymentBlock": 16045502, - "deploymentTimestamp": 1727859298993, + "gitCommitHash": "055075ff63240e82a1ef3e0d1ec4e4edcfa4804c", + "deploymentBlock": 16136731, + "deploymentTimestamp": 1728041757788, "deployed": true }, "ParanetKnowledgeAssetsRegistry": { - "evmAddress": "0x65FFD2776AE5455807A9e48018759De161Fb9DAd", + "evmAddress": "0x6226903A783b17940Cba6ae3029cBFD2c4bE7Bdf", "version": "2.0.0", "gitBranch": "v8/curated-paranets", - "gitCommitHash": "2f42b4c1922decb1aa952cc93c8a7c556b6193cd", - "deploymentBlock": 16045507, - "deploymentTimestamp": 1727859308677, + "gitCommitHash": "055075ff63240e82a1ef3e0d1ec4e4edcfa4804c", + "deploymentBlock": 16136736, + "deploymentTimestamp": 1728041763225, "deployed": true }, "ParanetKnowledgeMinersRegistry": { - "evmAddress": "0x7b1f0E5C67e1047ec90ec059F120F3cA6C98C8F1", + "evmAddress": "0x3Ce3d3d960E14eF1b6768287002950bEc9240f1c", "version": "2.0.1", "gitBranch": "v8/curated-paranets", - "gitCommitHash": "2f42b4c1922decb1aa952cc93c8a7c556b6193cd", - "deploymentBlock": 16045512, - "deploymentTimestamp": 1727859318419, + "gitCommitHash": "055075ff63240e82a1ef3e0d1ec4e4edcfa4804c", + "deploymentBlock": 16136739, + "deploymentTimestamp": 1728041773105, "deployed": true }, "Assertion": { @@ -230,12 +230,12 @@ "deployed": true }, "NodeOperatorFeesStorage": { - "evmAddress": "0x5A00F3Bf5CcA941151162f1791c90f94469d1707", + "evmAddress": "0x49E529c56F952C277815934a55B09B97FCc551a4", "version": "2.0.2", "gitBranch": "v8/curated-paranets", - "gitCommitHash": "2f42b4c1922decb1aa952cc93c8a7c556b6193cd", - "deploymentBlock": 16045530, - "deploymentTimestamp": 1727859354140, + "gitCommitHash": "055075ff63240e82a1ef3e0d1ec4e4edcfa4804c", + "deploymentBlock": 16136745, + "deploymentTimestamp": 1728041785658, "deployed": true }, "Staking": { @@ -248,12 +248,12 @@ "deployed": true }, "Profile": { - "evmAddress": "0x11e9f4E927520ED5bC00d290E93138C41c2ac274", - "version": "1.2.0", + "evmAddress": "0x068f0f5F898bdb6CDAB90D705F5201b83cb45538", + "version": "2.0.0", "gitBranch": "v8/curated-paranets", - "gitCommitHash": "2f42b4c1922decb1aa952cc93c8a7c556b6193cd", - "deploymentBlock": 16045537, - "deploymentTimestamp": 1727859368405, + "gitCommitHash": "055075ff63240e82a1ef3e0d1ec4e4edcfa4804c", + "deploymentBlock": 16136750, + "deploymentTimestamp": 1728041796716, "deployed": true }, "CommitManagerV1": {