Skip to content

Commit

Permalink
Merge pull request #78 from valory-xyz/dual_fallback
Browse files Browse the repository at this point in the history
refactor: adding fallback for staking staticcall
  • Loading branch information
kupermind authored Mar 4, 2025
2 parents 59e507e + 095c333 commit dd9e9a4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
14 changes: 14 additions & 0 deletions contracts/dual_token/DualStakingToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -319,4 +319,18 @@ contract DualStakingToken is ERC721TokenReceiver {

_locked = 1;
}

/// @dev Staticcall to all the other incoming data.
fallback() external {
address instance = stakingInstance;
assembly {
calldatacopy(0, 0, calldatasize())
let success := staticcall(gas(), instance, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
if eq(success, 0) {
revert(0, returndatasize())
}
return(0, returndatasize())
}
}
}
8 changes: 8 additions & 0 deletions test/StakingDualToken.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,14 @@ describe("Staking Dual Token", function () {
dualStakingToken.stake(serviceId)
).to.be.revertedWithCustomError(dualStakingToken, "AlreadyStaked");

const instance = await ethers.getContractAt("StakingToken", dualStakingToken.address);
const numAgentInstances = await instance.numAgentInstances();
expect(numAgentInstances).to.equal(serviceParams.numAgentInstances);
const rewardsPerSecond = await instance.rewardsPerSecond();
expect(rewardsPerSecond).to.equal(serviceParams.rewardsPerSecond);
const activityChecker = await instance.activityChecker();
expect(activityChecker).to.equal(serviceParams.activityChecker);

// Restore a previous state of blockchain
snapshot.restore();
});
Expand Down

0 comments on commit dd9e9a4

Please sign in to comment.