Skip to content

Commit

Permalink
Merge pull request #149 from G7DAO/feat/SUM-898-handle-staking-middle…
Browse files Browse the repository at this point in the history
…ware

Fix: Use the same event name for the backend receipt event
  • Loading branch information
ogarciarevett authored Sep 28, 2024
2 parents 226f549 + 1a7510a commit 6240e81
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Basic `dependabot.yml` file with
# minimum configuration for two package managers

version: 2
updates:
# Enable version updates for npm
- package-ecosystem: "npm"
# Look for `package.json` and `lock` files in the `root` directory
directory: "/"
# Check the npm registry for updates every day (weekdays)
schedule:
interval: "daily"
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ contract MiddlewareStakerNativeTokenV1 is Initializable, AccessControlUpgradeabl
uint256 public totalStaked;
uint256 public totalPositions;

event StakedInMiddleware(address indexed user, uint256 indexed poolID, uint256 amount, uint256 positionTokenID, address indexed staker);
event UnstakeInitiatedInMiddleware(address indexed user, uint256 indexed positionTokenID, address indexed staker);
event UnstakedInMiddleware(address indexed user, uint256 indexed positionTokenID, uint256 amount, address indexed staker);
event Staked(address indexed user, uint256 indexed poolID, uint256 amount, uint256 positionTokenID, address indexed staker);
event UnstakeInitiated(address indexed user, uint256 indexed positionTokenID, address indexed staker);
event Unstaked(address indexed user, uint256 indexed positionTokenID, uint256 amount, address indexed staker);

error NotYourPosition(address caller);
error TransferFailed();
Expand Down Expand Up @@ -98,7 +98,7 @@ contract MiddlewareStakerNativeTokenV1 is Initializable, AccessControlUpgradeabl
totalStaked += msg.value;
totalPositions++;

emit StakedInMiddleware(playerAddress, poolID, msg.value, positionTokenID, msg.sender);
emit Staked(playerAddress, poolID, msg.value, positionTokenID, msg.sender);
return positionTokenID;
}

Expand All @@ -109,7 +109,7 @@ contract MiddlewareStakerNativeTokenV1 is Initializable, AccessControlUpgradeabl

stakerContract.initiateUnstake(positionTokenID);

emit UnstakeInitiatedInMiddleware(playerAddress, positionTokenID, msg.sender);
emit UnstakeInitiated(playerAddress, positionTokenID, msg.sender);
}

function unstake(uint256 positionTokenID, address playerAddress) external onlyRole(STAKER_ROLE) nonReentrant whenNotPaused {
Expand All @@ -127,7 +127,7 @@ contract MiddlewareStakerNativeTokenV1 is Initializable, AccessControlUpgradeabl
totalStaked -= position.amount;
totalPositions--;

emit UnstakedInMiddleware(playerAddress, positionTokenID, position.amount, msg.sender);
emit Unstaked(playerAddress, positionTokenID, position.amount, msg.sender);
}

function getUserPositions(address user) external view returns (uint256[] memory) {
Expand Down
14 changes: 7 additions & 7 deletions test/hardhatTests/middlewareStaker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('MiddlewareStakerNativeTokenV1', function () {

// Find the 'Staked' event
// @ts-ignore
const event = events?.find((e) => e.name === 'StakedInMiddleware');
const event = events?.find((e) => e.name === 'Staked');
return event?.args?.positionTokenID;
}

Expand Down Expand Up @@ -128,7 +128,7 @@ describe('MiddlewareStakerNativeTokenV1', function () {

// Find the 'Staked' event
// @ts-ignore
const event = events?.find((e) => e.name === 'StakedInMiddleware');
const event = events?.find((e) => e.name === 'Staked');
expect(event).to.not.be.undefined;

const positionTokenID = event!.args.positionTokenID;
Expand Down Expand Up @@ -168,7 +168,7 @@ describe('MiddlewareStakerNativeTokenV1', function () {
.filter((log) => log.address === middlewareStaker.target)
.map((log) => middlewareStaker.interface.parseLog(log));

const event = events.find((e) => e.name === 'UnstakeInitiatedInMiddleware');
const event = events.find((e) => e.name === 'UnstakeInitiated');
expect(event).to.not.be.undefined;
expect(event!.args.user).to.equal(playerAddress);
expect(event!.args.positionTokenID).to.equal(positionTokenID);
Expand Down Expand Up @@ -235,7 +235,7 @@ describe('MiddlewareStakerNativeTokenV1', function () {
.filter((log) => log.address === middlewareStaker.target)
.map((log) => middlewareStaker.interface.parseLog(log));

const event1 = events1?.find((e) => e?.name === 'StakedInMiddleware');
const event1 = events1?.find((e) => e?.name === 'Staked');
expect(event1).to.not.be.undefined;
const positionTokenID1 = event1!.args.positionTokenID;

Expand All @@ -247,7 +247,7 @@ describe('MiddlewareStakerNativeTokenV1', function () {
.filter((log) => log.address === middlewareStaker.target)
.map((log) => middlewareStaker.interface.parseLog(log));

const event2 = events2?.find((e) => e?.name === 'StakedInMiddleware');
const event2 = events2?.find((e) => e?.name === 'Staked');
expect(event2).to.not.be.undefined;
const positionTokenID2 = event2!.args.positionTokenID;

Expand Down Expand Up @@ -299,7 +299,7 @@ describe('MiddlewareStakerNativeTokenV1', function () {
.filter((log) => log.address === middlewareStaker.target)
.map((log) => middlewareStaker.interface.parseLog(log));

const event = events?.find((e) => e?.name === 'StakedInMiddleware');
const event = events?.find((e) => e?.name === 'Staked');
expect(event).to.not.be.undefined;
const positionTokenID = event!.args.positionTokenID;

Expand Down Expand Up @@ -338,7 +338,7 @@ describe('MiddlewareStakerNativeTokenV1', function () {
.filter((log) => log.address === middlewareStaker.target)
.map((log) => middlewareStaker.interface.parseLog(log));

const event = events?.find((e) => e?.name === 'StakedInMiddleware');
const event = events?.find((e) => e?.name === 'Staked');
expect(event).to.not.be.undefined;
const positionTokenID = event!.args.positionTokenID;

Expand Down

0 comments on commit 6240e81

Please sign in to comment.