Skip to content

Commit

Permalink
update: amountOrId variable
Browse files Browse the repository at this point in the history
Refactored the name of the variable amountOrCallOrId into just amountOrId
  • Loading branch information
Guilherme Costa Neves authored and Guilherme Costa Neves committed Oct 30, 2023
1 parent a2d25fb commit 000dd01
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Easily create and return the Asset type to use in your Swap by calling this func
```solidity
struct Asset {
address addr;
uint256 amountOrCallOrId;
uint256 amountOrId;
}
```

Expand Down
19 changes: 8 additions & 11 deletions contracts/SwapFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ error InvalidAddress(address caller);
error InvalidAmount(uint256 amount);
error InvalidAssetsLength();
error InvalidExpiryDate(uint256 timestamp);
error InvalidMismatchingLengths(uint256 addr, uint256 amountOrCallOrId);
error InvalidMismatchingLengths(uint256 addr, uint256 amountOrId);

/**
* ________ ___ ________ ________ ___ __ ________ ___ ___ ___
Expand All @@ -27,9 +27,9 @@ error InvalidMismatchingLengths(uint256 addr, uint256 amountOrCallOrId);
abstract contract SwapFactory is ISwapFactory, ISwap {
function makeAsset(
address addr,
uint256 amountOrCallOrId
uint256 amountOrId
) public pure returns (Asset memory) {
return Asset(addr, amountOrCallOrId);
return Asset(addr, amountOrId);
}

function makeSwap(
Expand Down Expand Up @@ -59,27 +59,24 @@ abstract contract SwapFactory is ISwapFactory, ISwap {
address allowed,
uint256 expiry,
address[] memory addrs,
uint256[] memory amountOrCallOrId,
uint256[] memory amountOrId,
uint256 bidFlipAsk
) public pure returns (Swap memory) {
if (addrs.length != amountOrCallOrId.length) {
revert InvalidMismatchingLengths(
addrs.length,
amountOrCallOrId.length
);
if (addrs.length != amountOrId.length) {
revert InvalidMismatchingLengths(addrs.length, amountOrId.length);
}

Asset[] memory biding = new Asset[](bidFlipAsk);
for (uint256 i = 0; i < bidFlipAsk; ) {
biding[i] = makeAsset(addrs[i], amountOrCallOrId[i]);
biding[i] = makeAsset(addrs[i], amountOrId[i]);
unchecked {
i++;
}
}

Asset[] memory asking = new Asset[](addrs.length - bidFlipAsk);
for (uint256 i = bidFlipAsk; i < addrs.length; ) {
asking[i - bidFlipAsk] = makeAsset(addrs[i], amountOrCallOrId[i]);
asking[i - bidFlipAsk] = makeAsset(addrs[i], amountOrId[i]);
unchecked {
i++;
}
Expand Down
4 changes: 2 additions & 2 deletions contracts/Swaplace.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ contract Swaplace is SwapFactory, DataPalace, ISwaplace, IERC165 {
ITransfer(assets[i].addr).transferFrom(
msg.sender,
swap.owner,
assets[i].amountOrCallOrId
assets[i].amountOrId
);
unchecked {
i++;
Expand All @@ -89,7 +89,7 @@ contract Swaplace is SwapFactory, DataPalace, ISwaplace, IERC165 {
ITransfer(assets[i].addr).transferFrom(
swap.owner,
msg.sender,
assets[i].amountOrCallOrId
assets[i].amountOrId
);
unchecked {
i++;
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/ISwap.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.17;
interface ISwap {
struct Asset {
address addr;
uint256 amountOrCallOrId;
uint256 amountOrId;
}

struct Swap {
Expand Down
4 changes: 2 additions & 2 deletions contracts/interfaces/ISwapFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {ISwap} from "./ISwap.sol";
interface ISwapFactory {
function makeAsset(
address addr,
uint256 amountOrCallOrId
uint256 amountOrId
) external pure returns (ISwap.Asset memory);

function makeSwap(
Expand All @@ -22,7 +22,7 @@ interface ISwapFactory {
address allowed,
uint256 expiry,
address[] memory addrs,
uint256[] memory amountOrCallOrId,
uint256[] memory amountOrId,
uint256 indexFlipToAsking
) external pure returns (ISwap.Swap memory);
}
2 changes: 1 addition & 1 deletion contracts/interfaces/ITransfer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ interface ITransfer {
function transferFrom(
address from,
address to,
uint256 amountOrCallOrId
uint256 amountOrId
) external;
}

0 comments on commit 000dd01

Please sign in to comment.