Skip to content

Commit

Permalink
Merge branch 'main' into feature/nodejs-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
luislucena16 authored Dec 23, 2023
2 parents 56c6b69 + a198bed commit 431cbe6
Show file tree
Hide file tree
Showing 39 changed files with 2,252 additions and 2,125 deletions.
4 changes: 1 addition & 3 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# Swaplace deployed contracts addresses
SWAPLACE_ADDRESS=0x5FbDB2315678afecb367f032d93F642f64180aa3
SWAPLACE_ADDRESS=0xD8E3580C1b6f117c5b35DdD01dd9e50d9487501D

# These are public known private keys and are here as an example.
# Funds in these accounts are at risk of being stolen.
DEPLOYER_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
SWAP_CREATOR_PRIVATE_KEY=0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d
SWAP_ACCEPTEE_PRIVATE_KEY=0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a

# Etherscan and similar services API keys
ETHERSCAN_API_KEY=YourApiKeyToken
Expand Down
7 changes: 4 additions & 3 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
trailingComma: "es5"
tabWidth: 4
semi: false
trailingComma: "all"
singleQuote: false
printWidth: 80
tabWidth: 2
semi: true
76 changes: 76 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Contribution Guidelines

Thank you for your interest in contributing to Swaplace! The project is an open source build by the community. We are welcome any type of contribution, suggestion or improvement, no matter how small.

### Contents

- [Open Source Guideline](#how-to-contribute)
- [Opening an Issue](#opening-issue)
- [Writing Commit Messages](#writing-commit-messages)
- [Submitting Pull Requests](#submiting-pull-requests)
- [Code Review](#code-review)
- [Coding Style](#coding-style)
- [Get in touch](#get-in-touch)

## How to Contribute

There are many ways to contribute, but here are a few steps to start:

1. Fork the repository in GitHub
2. Check if you have any issue, suggestion or improvement to work in.

- We manage all the issues using [GitHub Projects](https://github.com/orgs/blockful-io/projects/3)

3. Send a message in the issue like
`I'm interested in this issue` or ask for more information like `Hey, can you provide more information about this ... ?`and the mantainers will assigned or provide more context about your issue. **After that, you are asigned to the issue.**

4. If a task is already assigned but you believe you can expedite the process, feel free to comment, requesting to assist or speed up the task. Additionally, you may open a pull request directly because we prioritize both code efficiency and delivery speed. Thus, we encourage multiple individuals to review the same issues and debate together to enhance the code's security.

### Congratulations ! Now you can start work in the issue and everyone knows you are assigned.

## Opening Issue

Before opening an issue, please check if there is no issue open. If there is, feel free to comment or suggest more details. We are always open to feedback and receptive to suggestions!

- Before [creating an issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/creating-an-issue#creating-an-issue-from-a-project), check if your fork is updated.

## Writing Commit Messages

We are using [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)

Some examples below:

- feat: adds or remove a new feature
- fix: fixes a bug
- refactor: rewrite/restructure your code
- chore: changes to the build process or auxiliary tools and libraries such as documentation generation
- style: changes do not affect the meaning (white-space, formatting, missing semi-colons, etc)
- test: add missing tests or correcting existing tests
- docs: affect documentation only

## Submiting Pull Requests

You can resolve an issue and after that submit a pull request fixing an issue and remember to [reference that issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword#linking-a-pull-request-to-an-issue-using-a-keyword). When submit a PR, put the code below with the number of the issue you are closing
`Example: closes #1`

## Code Review

The maintainers will review your PR. If something is missing or a fix needs to be made, the maintainers will let you know in the PR comment.

## Coding Style

In Swaplace please use this .prettierrc.yml configuration to make the code standardized.

```
{
trailingComma: "all"
singleQuote: false
printWidth: 80
tabWidth: 2
semi: true
}
```

## Get in Touch

If you need to get in contact with the repository maintainers, please reach out in our [Discord](https://discord.gg/B6uDmm7hvC).
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This repository is subjected to incentives for the community to contribute to th

## Features

- **Create Swaps**: A Swap has an `owner` and an `allowed` address. The `owner` is the one that can cancel the swap while the `allowed` address is the one that can execute the swap but anyone can accept if it's set as the Zero Address. A Swap also has an `expiry` period in seconds. The Swap can only be executed before the expiry period is reached. The `Asset` type represents on one hand the bidding assets and on the other hand the asking assets.
- **Create Swaps**: A Swap has an `owner` and an `allowed` address. The `owner` is the one that can cancel the swap while the `allowed` address is the one that can execute the swap but anyone can accept if it's set as the Zero Address. A Swap also has an `expiry` period in seconds. The Swap can only be executed before the expiry period is reached. The `Asset` type represents on one hand the bidding assets and on the other hand the asking assets.

```
struct Swap {
Expand All @@ -31,11 +31,11 @@ This repository is subjected to incentives for the community to contribute to th
}
```

- **Accept Swaps**: You can accept swaps that have an `allowed` address equal to your or the `Zero Address`. As long as you provide the asked assets.
- **Accept Swaps**: You can accept swaps that have an `allowed` address equal to your or the `Zero Address`. As long as you provide the asked assets.

- **Cancel Swaps**: You can cancel swaps that haven't been `expired`.
- **Cancel Swaps**: You can cancel swaps that haven't been `expired`.

- **Swap Factory**: Aids new swap creations to be used on Swaplace. Check `contracts/SwapFactory.sol`.
- **Swap Factory**: Aids new swap creations to be used on Swaplace. Check `contracts/SwapFactory.sol`.

## Setup

Expand Down Expand Up @@ -138,4 +138,4 @@ yarn deploy <network>

## Contributing

- To know more about how you can contribute [see our notion page](https://blockful.notion.site/Swaplace-Call-for-Contributors-6e4895d2a7264f679439ab2c124603fe).
- To know more about how you can contribute [see our notion page](https://blockful.notion.site/Swaplace-Call-for-Contributors-6e4895d2a7264f679439ab2c124603fe).
52 changes: 24 additions & 28 deletions contracts/SwapFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,41 +26,37 @@ import {ISwapFactory} from "./interfaces/ISwapFactory.sol";
*
* - The `address` of the asset. This address can be from an ERC20 or ERC721 contract.
* - The `amount` or `id` of the asset. This amount can be the amount of ERC20 tokens
* or the id of an ERC721 token.
* or the ID of an ERC721 token.
*
* To use other standards, like ERC1155, you can wrap the ownership of the asset
* in an a trusted contract and Swap as an ERC721. This way, you can tokenize any
* on-chain execution and trade on Swaplace.
*/
abstract contract SwapFactory is ISwapFactory, ISwap, IErrors {
/**
* @dev See {ISwapFactory-makeAsset}.
*/
function makeAsset(
address addr,
uint256 amountOrId
) public pure virtual returns (Asset memory) {
return Asset(addr, amountOrId);
}
/**
* @dev See {ISwapFactory-makeAsset}.
*/
function makeAsset(
address addr,
uint256 amountOrId
) public pure virtual returns (Asset memory) {
return Asset(addr, amountOrId);
}

/**
* @dev See {ISwapFactory-makeSwap}.
*/
function makeSwap(
address owner,
address allowed,
uint256 expiry,
Asset[] memory biding,
Asset[] memory asking
) public view virtual returns (Swap memory) {
if (expiry < block.timestamp) {
revert InvalidExpiry(expiry);
}
/**
* @dev See {ISwapFactory-makeSwap}.
*/
function makeSwap(
address owner,
address allowed,
uint256 expiry,
Asset[] memory biding,
Asset[] memory asking
) public view virtual returns (Swap memory) {
if (expiry < block.timestamp) revert InvalidExpiry(expiry);

if (biding.length == 0 || asking.length == 0) {
revert InvalidAssetsLength();
}
if (biding.length == 0 || asking.length == 0) revert InvalidAssetsLength();

return Swap(owner, allowed, expiry, biding, asking);
}
return Swap(owner, allowed, expiry, biding, asking);
}
}
Loading

0 comments on commit 431cbe6

Please sign in to comment.