Skip to content

Commit

Permalink
Update lockKeeper in server nodes on devnet
Browse files Browse the repository at this point in the history
  • Loading branch information
SvineruS committed Oct 24, 2023
1 parent 895a41e commit d31e21a
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 11 deletions.
22 changes: 21 additions & 1 deletion contracts/staking/ServerNodes_Manager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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) {
Expand Down
42 changes: 33 additions & 9 deletions deployments/30746.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)",
Expand Down Expand Up @@ -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"
}
},
Expand Down Expand Up @@ -885,4 +909,4 @@
"fullyQualifiedName": "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol:ERC1967Proxy"
}
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down

0 comments on commit d31e21a

Please sign in to comment.