Skip to content

Commit

Permalink
Merge pull request #229 from OriginTrail/fix/add-stake-bug
Browse files Browse the repository at this point in the history
Fixed bug in _addStake function, added identityId to SharesMinted/Burned events
  • Loading branch information
br41nl3t authored Feb 9, 2024
2 parents 0fd41d7 + 1566b8f commit af18417
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
12 changes: 12 additions & 0 deletions abi/StakingV2.json
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,12 @@
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint72",
"name": "identityId",
"type": "uint72"
},
{
"indexed": true,
"internalType": "address",
Expand Down Expand Up @@ -285,6 +291,12 @@
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint72",
"name": "identityId",
"type": "uint72"
},
{
"indexed": true,
"internalType": "address",
Expand Down
11 changes: 7 additions & 4 deletions contracts/v2/Staking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ contract StakingV2 is Named, Versioned, ContractStatus, Initializable {
uint96 newStake
);
event SharesMinted(
uint72 indexed identityId,
address indexed sharesContractAddress,
address indexed delegator,
uint256 sharesMintedAmount,
Expand All @@ -54,6 +55,7 @@ contract StakingV2 is Named, Versioned, ContractStatus, Initializable {
);
event StakeWithdrawn(uint72 indexed identityId, bytes nodeId, address indexed staker, uint96 withdrawnStakeAmount);
event SharesBurned(
uint72 indexed identityId,
address indexed sharesContractAddress,
address indexed delegator,
uint256 sharesBurnedAmount,
Expand Down Expand Up @@ -157,7 +159,7 @@ contract StakingV2 is Named, Versioned, ContractStatus, Initializable {
newStake,
withdrawalPeriodEnd
);
emit SharesBurned(address(sharesContract), msg.sender, sharesToBurn, sharesContract.totalSupply());
emit SharesBurned(identityId, address(sharesContract), msg.sender, sharesToBurn, sharesContract.totalSupply());
}

function withdrawStake(uint72 identityId) external {
Expand Down Expand Up @@ -291,13 +293,14 @@ contract StakingV2 is Named, Versioned, ContractStatus, Initializable {
ss.setTotalStake(identityId, newStake);
tknc.transferFrom(sender, address(ss), stakeAmount);

if (!sts.nodeExists(identityId) && newStake >= params.minimumStake())
if (!sts.nodeExists(identityId) && newStake >= params.minimumStake()) {
if (sts.nodesCount() >= params.shardingTableSizeLimit()) revert ShardingTableErrors.ShardingTableIsFull();

shardingTableContract.insertNode(identityId);
shardingTableContract.insertNode(identityId);
}

emit StakeIncreased(identityId, ps.getNodeId(identityId), sender, oldStake, newStake);
emit SharesMinted(address(sharesContract), sender, sharesMinted, sharesContract.totalSupply());
emit SharesMinted(identityId, address(sharesContract), sender, sharesMinted, sharesContract.totalSupply());
}

function _checkAdmin(uint72 identityId) internal view virtual {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dkg-evm-module",
"version": "4.2.2",
"version": "4.2.3",
"description": "Smart contracts for OriginTrail V6",
"main": "index.ts",
"files": [
Expand Down

0 comments on commit af18417

Please sign in to comment.