From d31e21ab17a6e93b37a78d94466ab2fed5ee734e Mon Sep 17 00:00:00 2001 From: svin Date: Tue, 24 Oct 2023 17:55:14 +0300 Subject: [PATCH] Update lockKeeper in server nodes on devnet --- contracts/staking/ServerNodes_Manager.sol | 22 +++++++++++- deployments/30746.json | 42 ++++++++++++++++++----- package.json | 2 +- 3 files changed, 55 insertions(+), 11 deletions(-) diff --git a/contracts/staking/ServerNodes_Manager.sol b/contracts/staking/ServerNodes_Manager.sol index 968c3c2b..2ca6500f 100644 --- a/contracts/staking/ServerNodes_Manager.sol +++ b/contracts/staking/ServerNodes_Manager.sol @@ -108,7 +108,7 @@ contract ServerNodes_Manager is UUPSUpgradeable, IStakeManager, IOnBlockListener lockedWithdraws[nodeAddress] = lockKeeper.lockSingle{value: amount + canceledAmount}( msg.sender, address(0), uint64(block.timestamp + unstakeLockTime), amount + canceledAmount, - string(abi.encodePacked("ServerNodes unstake: ", nodeAddress)) + string(abi.encodePacked("ServerNodes unstake: ", _addressToString(nodeAddress))) ); emit StakeChanged(nodeAddress, msg.sender, - int(amount)); @@ -237,6 +237,11 @@ contract ServerNodes_Manager is UUPSUpgradeable, IStakeManager, IOnBlockListener function _authorizeUpgrade(address) internal override onlyRole(DEFAULT_ADMIN_ROLE) {} + + function _upgrade(address newLockKeeper) public onlyRole(DEFAULT_ADMIN_ROLE) { + lockKeeper = LockKeeper(newLockKeeper); + } + // PRIVATE METHODS @@ -288,6 +293,21 @@ contract ServerNodes_Manager is UUPSUpgradeable, IStakeManager, IOnBlockListener return 100 - nativePercent; } + function _addressToString(address x) internal pure returns (string memory) { + bytes memory s = new bytes(40); + for (uint i = 0; i < 20; i++) { + uint8 b = uint8(uint(uint160(x)) / (2**(8*(19 - i)))); + uint8 hi = (b / 16); + uint8 lo = (b - 16 * hi); + s[2*i] = _char(hi); + s[2*i+1] = _char(lo); + } + return string(s); + } + function _char(uint8 b) internal pure returns (bytes1 c) { + return bytes1(b + (b < 10 ? 0x30 : 0x57)); + } + receive() external payable {} modifier onlyNodeOwner(address nodeAddress) { diff --git a/deployments/30746.json b/deployments/30746.json index ca1f19dc..fa724210 100644 --- a/deployments/30746.json +++ b/deployments/30746.json @@ -673,25 +673,48 @@ "fullyQualifiedName": "contracts/multisig/Multisig.sol:Multisig" }, "LockKeeper": { - "address": "0xdC103bf9a3789f78958f365321F3BA07e369667A", + "address": "0x2C55f7d6B1c2aF6b06Fba942e01B39Ae1dd7B9D7", "abi": [ - "constructor()", + "event AdminChanged(address previousAdmin, address newAdmin)", + "event BeaconUpgraded(address indexed beacon)", "event Claim(uint256 indexed lockId, address indexed userAddress, uint256 amount)", + "event Initialized(uint8 version)", "event LockCanceled(uint256 indexed lockId, uint256 canceledAmount)", "event Locked(uint256 indexed lockId, address indexed receiver, address indexed token, address locker, uint64 lockTime, uint64 firstUnlockTime, uint64 unlockPeriod, uint64 totalClaims, uint256 intervalAmount, string description)", - "function allUserLocks(address user) view returns (uint256[], tuple(address locker, address receiver, address token, uint64 firstUnlockTime, uint64 unlockPeriod, uint64 totalClaims, uint64 timesClaimed, uint256 intervalAmount)[])", + "event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole)", + "event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender)", + "event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender)", + "event Upgraded(address indexed implementation)", + "function DEFAULT_ADMIN_ROLE() view returns (bytes32)", + "function allUserLocks(address user) view returns (uint256[], tuple(address locker, address receiver, address token, uint64 firstUnlockTime, uint64 unlockPeriod, uint64 totalClaims, uint64 timesClaimed, uint256 intervalAmount, string description)[])", "function autoClaim()", "function cancelLock(uint256 lockId) returns (uint256 unclaimedAmount)", "function claim(uint256 lockId)", "function claimAll()", - "function getLock(uint256 id) view returns (tuple(address locker, address receiver, address token, uint64 firstUnlockTime, uint64 unlockPeriod, uint64 totalClaims, uint64 timesClaimed, uint256 intervalAmount))", + "function getAllLocks() view returns (tuple(address locker, address receiver, address token, uint64 firstUnlockTime, uint64 unlockPeriod, uint64 totalClaims, uint64 timesClaimed, uint256 intervalAmount, string description)[])", + "function getAllLocksIds() view returns (uint256[])", + "function getLock(uint256 id) view returns (tuple(address locker, address receiver, address token, uint64 firstUnlockTime, uint64 unlockPeriod, uint64 totalClaims, uint64 timesClaimed, uint256 intervalAmount, string description))", + "function getRoleAdmin(bytes32 role) view returns (bytes32)", + "function grantRole(bytes32 role, address account)", + "function hasRole(bytes32 role, address account) view returns (bool)", + "function initialize()", "function latestLockId() view returns (uint256)", "function lockLinear(address receiver, address token, uint64 firstUnlockTime, uint64 totalClaims, uint64 unlockPeriod, uint256 unlockAmount, string description) payable returns (uint256)", "function lockSingle(address receiver, address token, uint64 unlockTime, uint256 amount, string description) payable returns (uint256)", - "function onBlock()" + "function onBlock()", + "function proxiableUUID() view returns (bytes32)", + "function renounceRole(bytes32 role, address account)", + "function revokeRole(bytes32 role, address account)", + "function supportsInterface(bytes4 interfaceId) view returns (bool)", + "function upgradeTo(address newImplementation)", + "function upgradeToAndCall(address newImplementation, bytes data) payable" ], - "deployTx": "0xf325eb35d7a832d104794e7e72a0f5b85aff5cb3b059c915d93b51b557bdcfe7", - "fullyQualifiedName": "contracts/LockKeeper.sol:LockKeeper" + "deployTx": "0x77d7c681badddb4eeda4bc6774e6973556809edb580cf13ce8b78f1ec0f36974", + "fullyQualifiedName": "contracts/LockKeeper.sol:LockKeeper", + "proxy": { + "implementation": "0xEBf3C264A54fB892901c43BF831f53C8bBdB2C43", + "fullyQualifiedName": "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol:ERC1967Proxy" + } }, "ServerNodesManager_RewardsBank": { "address": "0x450A606B9D42D081CE58bC5cDF6acA380acF7731", @@ -728,6 +751,7 @@ "event Unpaused(address account)", "event Upgraded(address indexed implementation)", "function DEFAULT_ADMIN_ROLE() view returns (bytes32)", + "function _upgrade(address newLockKeeper)", "function addStake(address nodeAddress) payable", "function airBond() view returns (address)", "function changeMinStakeAmount(uint256 newMinStakeAmount)", @@ -770,7 +794,7 @@ "deployTx": "0x9afda1b30db816a8f76295add9526ea7cd5ad86ed60bdf1fcaee72b2ce5db246", "fullyQualifiedName": "contracts/staking/ServerNodes_Manager.sol:ServerNodes_Manager", "proxy": { - "implementation": "0x5b4Dc8dA222eb0e19581D95Ff08b8809caE1d801", + "implementation": "0x13BAE98762100CD918f936dA98e186E9a88A5C1E", "fullyQualifiedName": "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol:ERC1967Proxy" } }, @@ -885,4 +909,4 @@ "fullyQualifiedName": "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol:ERC1967Proxy" } } -} +} \ No newline at end of file diff --git a/package.json b/package.json index e8536096..c49370fe 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@airdao/airdao-node-contracts", - "version": "1.2.0", + "version": "1.2.1", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", "files": [