Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE-121] docs: research gas and cost efficiency for event emission #146

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
2 changes: 1 addition & 1 deletion contracts/Swaplace.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,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
Loading