Skip to content

Commit

Permalink
Merge pull request #146 from 0xjoaovpsantos/issue-121-research-gas-an…
Browse files Browse the repository at this point in the history
…d-cost-efficiency-event-emission

[ISSUE-121] docs: research gas and cost efficiency for event emission
  • Loading branch information
0xneves authored Dec 22, 2023
2 parents 2d11cb6 + 40f9848 commit a198bed
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion contracts/Swaplace.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ contract Swaplace is SwapFactory, ISwaplace, IERC165 {

_swaps[swapId] = swap;

emit SwapCreated(swapId, msg.sender, swap.expiry);
emit SwapCreated(swapId, msg.sender, swap.allowed, swap.expiry);

return swapId;
}
Expand Down
5 changes: 3 additions & 2 deletions contracts/interfaces/ISwaplace.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ interface ISwaplace {
event SwapCreated(
uint256 indexed swapId,
address indexed owner,
uint256 indexed expiry
address indexed allowed,
uint256 expiry
);

/**
Expand Down Expand Up @@ -80,4 +81,4 @@ interface ISwaplace {
* If the `owner` is the zero address, then the Swap doesn't exist.
*/
function getSwap(uint256 swapId) external view returns (ISwap.Swap memory);
}
}
2 changes: 1 addition & 1 deletion docs/interfaces/ISwaplace.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Interface of the {Swaplace} implementation.
### SwapCreated

```solidity
event SwapCreated(uint256 swapId, address owner, uint256 expiry)
event SwapCreated(uint256 swapId, address owner, address allowed, uint256 expiry)
```

Emitted when a new Swap is created.
Expand Down
18 changes: 9 additions & 9 deletions test/TestSwaplace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe("Swaplace", async function () {

await expect(await Swaplace.connect(owner).createSwap(swap))
.to.emit(Swaplace, "SwapCreated")
.withArgs(await Swaplace.totalSwaps(), owner.address, swap.expiry);
.withArgs(await Swaplace.totalSwaps(), owner.address, swap.allowed, swap.expiry);
});

it("Should be able to create a 1-N swap with ERC20", async function () {
Expand All @@ -98,7 +98,7 @@ describe("Swaplace", async function () {

await expect(await Swaplace.connect(owner).createSwap(swap))
.to.emit(Swaplace, "SwapCreated")
.withArgs(await Swaplace.totalSwaps(), owner.address, swap.expiry);
.withArgs(await Swaplace.totalSwaps(), owner.address, swap.allowed, swap.expiry);
});

it("Should be able to create a N-N swap with ERC20", async function () {
Expand Down Expand Up @@ -128,7 +128,7 @@ describe("Swaplace", async function () {

await expect(await Swaplace.connect(owner).createSwap(swap))
.to.emit(Swaplace, "SwapCreated")
.withArgs(await Swaplace.totalSwaps(), owner.address, swap.expiry);
.withArgs(await Swaplace.totalSwaps(), owner.address, swap.allowed, swap.expiry);
});

it("Should be able to create a 1-1 swap with ERC721", async function () {
Expand All @@ -150,7 +150,7 @@ describe("Swaplace", async function () {

await expect(await Swaplace.connect(owner).createSwap(swap))
.to.emit(Swaplace, "SwapCreated")
.withArgs(await Swaplace.totalSwaps(), owner.address, swap.expiry);
.withArgs(await Swaplace.totalSwaps(), owner.address, swap.allowed, swap.expiry);
});

it("Should be able to create a 1-N swap with ERC721", async function () {
Expand All @@ -176,7 +176,7 @@ describe("Swaplace", async function () {

await expect(await Swaplace.connect(owner).createSwap(swap))
.to.emit(Swaplace, "SwapCreated")
.withArgs(await Swaplace.totalSwaps(), owner.address, swap.expiry);
.withArgs(await Swaplace.totalSwaps(), owner.address, swap.allowed, swap.expiry);
});

it("Should be able to create a N-N swap with ERC721", async function () {
Expand Down Expand Up @@ -206,7 +206,7 @@ describe("Swaplace", async function () {

await expect(await Swaplace.connect(owner).createSwap(swap))
.to.emit(Swaplace, "SwapCreated")
.withArgs(await Swaplace.totalSwaps(), owner.address, swap.expiry);
.withArgs(await Swaplace.totalSwaps(), owner.address, swap.allowed, swap.expiry);
});
});

Expand Down Expand Up @@ -302,7 +302,7 @@ describe("Swaplace", async function () {

await expect(await Swaplace.connect(owner).createSwap(swap))
.to.emit(Swaplace, "SwapCreated")
.withArgs(await Swaplace.totalSwaps(), owner.address, swap.expiry);
.withArgs(await Swaplace.totalSwaps(), owner.address, swap.allowed, swap.expiry);

await expect(
await Swaplace.connect(acceptee).acceptSwap(
Expand All @@ -325,7 +325,7 @@ describe("Swaplace", async function () {

await expect(await Swaplace.connect(owner).createSwap(swap))
.to.emit(Swaplace, "SwapCreated")
.withArgs(await Swaplace.totalSwaps(), owner.address, swap.expiry);
.withArgs(await Swaplace.totalSwaps(), owner.address, swap.allowed, swap.expiry);

await expect(
await Swaplace.connect(acceptee).acceptSwap(
Expand Down Expand Up @@ -390,7 +390,7 @@ describe("Swaplace", async function () {

await expect(await Swaplace.connect(owner).createSwap(swap))
.to.emit(Swaplace, "SwapCreated")
.withArgs(await Swaplace.totalSwaps(), owner.address, swap.expiry);
.withArgs(await Swaplace.totalSwaps(), owner.address, swap.allowed, swap.expiry);

await expect(
Swaplace.connect(acceptee).acceptSwap(await Swaplace.totalSwaps()),
Expand Down

0 comments on commit a198bed

Please sign in to comment.