Skip to content

Commit 97efc75

Browse files
committed
Merge branch 'devnet-ready' into trim_uids
2 parents 261ef5a + 01c90a7 commit 97efc75

File tree

7 files changed

+210
-118
lines changed

7 files changed

+210
-118
lines changed

Cargo.lock

Lines changed: 56 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

evm-tests/src/contracts/stakeWrap.sol

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,32 @@ interface Staking {
1515
) external;
1616

1717
function addStake(bytes32 hotkey, uint256 amount, uint256 netuid) external;
18+
19+
function removeStake(
20+
bytes32 hotkey,
21+
uint256 amount,
22+
uint256 netuid
23+
) external;
1824
}
1925

2026
contract StakeWrap {
21-
constructor() {}
27+
address public owner;
28+
constructor() {
29+
owner = msg.sender;
30+
}
31+
32+
modifier onlyOwner() {
33+
require(msg.sender == owner, "Only owner can call this function");
34+
_;
35+
}
36+
2237
receive() external payable {}
2338

24-
function stake(bytes32 hotkey, uint256 netuid, uint256 amount) external {
39+
function stake(
40+
bytes32 hotkey,
41+
uint256 netuid,
42+
uint256 amount
43+
) external onlyOwner {
2544
// can't call precompile like this way, the call never go to runtime precompile
2645
//Staking(ISTAKING_ADDRESS).addStake(hotkey, amount, netuid);
2746

@@ -41,7 +60,7 @@ contract StakeWrap {
4160
uint256 limitPrice,
4261
uint256 amount,
4362
bool allowPartial
44-
) external {
63+
) external onlyOwner {
4564
// can't call precompile like this way, the call never go to runtime precompile
4665
// Staking(ISTAKING_ADDRESS).addStakeLimit(
4766
// hotkey,
@@ -62,4 +81,19 @@ contract StakeWrap {
6281
(bool success, ) = ISTAKING_ADDRESS.call{gas: gasleft()}(data);
6382
require(success, "addStakeLimit call failed");
6483
}
84+
85+
function removeStake(
86+
bytes32 hotkey,
87+
uint256 netuid,
88+
uint256 amount
89+
) external onlyOwner {
90+
bytes memory data = abi.encodeWithSelector(
91+
Staking.removeStake.selector,
92+
hotkey,
93+
amount,
94+
netuid
95+
);
96+
(bool success, ) = ISTAKING_ADDRESS.call{gas: gasleft()}(data);
97+
require(success, "addStake call failed");
98+
}
6599
}

0 commit comments

Comments
 (0)