Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 56 additions & 40 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 37 additions & 3 deletions evm-tests/src/contracts/stakeWrap.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,32 @@ interface Staking {
) external;

function addStake(bytes32 hotkey, uint256 amount, uint256 netuid) external;

function removeStake(
bytes32 hotkey,
uint256 amount,
uint256 netuid
) external;
}

contract StakeWrap {
constructor() {}
address public owner;
constructor() {
owner = msg.sender;
}

modifier onlyOwner() {
require(msg.sender == owner, "Only owner can call this function");
_;
}

receive() external payable {}

function stake(bytes32 hotkey, uint256 netuid, uint256 amount) external {
function stake(
bytes32 hotkey,
uint256 netuid,
uint256 amount
) external onlyOwner {
// can't call precompile like this way, the call never go to runtime precompile
//Staking(ISTAKING_ADDRESS).addStake(hotkey, amount, netuid);

Expand All @@ -41,7 +60,7 @@ contract StakeWrap {
uint256 limitPrice,
uint256 amount,
bool allowPartial
) external {
) external onlyOwner {
// can't call precompile like this way, the call never go to runtime precompile
// Staking(ISTAKING_ADDRESS).addStakeLimit(
// hotkey,
Expand All @@ -62,4 +81,19 @@ contract StakeWrap {
(bool success, ) = ISTAKING_ADDRESS.call{gas: gasleft()}(data);
require(success, "addStakeLimit call failed");
}

function removeStake(
bytes32 hotkey,
uint256 netuid,
uint256 amount
) external onlyOwner {
bytes memory data = abi.encodeWithSelector(
Staking.removeStake.selector,
hotkey,
amount,
netuid
);
(bool success, ) = ISTAKING_ADDRESS.call{gas: gasleft()}(data);
require(success, "addStake call failed");
}
}
Loading
Loading