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

[r2r] update deps and solc version, add ERC721 and ERC1155 support #2

Merged
merged 23 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
12a815e
fix docker, update stack
laruh Nov 14, 2023
1226dad
"web3": "^4.2.2", "@openzeppelin/contracts": "^5.0.0", solc 0.8.23
laruh Nov 16, 2023
b6f524b
update ganache version
laruh Nov 16, 2023
2400009
update more deps
laruh Nov 16, 2023
db4e886
fix increase time problem, needed to mine block
laruh Nov 16, 2023
a902aa2
combine `evm_increaseTime` and `evm_mine` methods
laruh Nov 16, 2023
65d3386
format sol code
laruh Nov 17, 2023
a941a19
update readme, fix ReceivedSpent typo
laruh Nov 20, 2023
45c8fcd
update project structure info
laruh Nov 20, 2023
2ca81ec
add Erc721Token.sol and `erc721Payment`, `receiverSpendErc721` functions
laruh Nov 21, 2023
07753cf
add `senderRefundErc721` func and `ERC721` tests
laruh Nov 23, 2023
6b8182f
Erc1155Token.sol, add onERC1155Received etc funcs, add License
laruh Nov 23, 2023
133a9b6
add ERC1155 balance test
laruh Nov 23, 2023
8b9e696
ERC1155 payment funcs in EtomicSwap, ERC1155 tests
laruh Nov 24, 2023
71cb6a1
use `safeTransferFrom` for `ERC721`
laruh Nov 24, 2023
cb9d1fd
use selector for onERC1155Received funcs
laruh Nov 24, 2023
6d719d2
call erc721token.safeTransferFrom directly
laruh Nov 29, 2023
47caecb
call erc1155token.safeTransferFrom directly
laruh Nov 29, 2023
db3e251
add more checks in on...Received funcs, impl invalid secret
laruh Nov 30, 2023
fe6f40f
use solc version 0.8.20, mixedCase function arguments
laruh Dec 4, 2023
e8833c6
CEI pattern in EtomicSwap.sol
laruh Dec 4, 2023
c44a786
more mixedCase func args
laruh Dec 4, 2023
944973b
`msg.sender == tx.origin` check, remove redundant computation
laruh Dec 6, 2023
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
27 changes: 22 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Etomic Swap Smart Contracts for BarterDex platform.
# Etomic Swap Smart Contracts for Komodo SDK.
[![Build Status](https://travis-ci.org/artemii235/etomic-swap.svg?branch=master)](https://travis-ci.org/artemii235/etomic-swap)
Etomic swap Smart Contract is implemented to support ETH and ERC20 atomic swaps on BarterDex platform.
Etomic swap Smart Contract is implemented to support ETH and ERC20 atomic swaps on Komodo SDK.
Please note that this project is not production ready yet!

## Swap workflow
Expand All @@ -17,13 +17,14 @@ Despite example shows swap of ETH/ERC20 this approach will work also for ETH/ERC
## Project structure

1. `contracts` - Smart Contracts source code.
1. `migrations` - Deployment scripts.
1. `test` - Smart contracts unit tests.

## How to setup dev environment?

1. Install docker.
1. Run `docker-compose build`.
1. `cp .env.empty .env`.
1. Run `docker-compose build`.
1. Start containers `docker-compose up -d`.
1. Install project dependencies: `docker-compose exec workspace yarn`.
1. To run tests: `docker-compose exec workspace truffle test`.
Expand All @@ -35,5 +36,21 @@ Despite example shows swap of ETH/ERC20 this approach will work also for ETH/ERC
## Useful links for smart contracts development

1. Truffle suite - https://github.com/trufflesuite/truffle
1. Ganache-cli (EthereumJS Testrpc) - https://github.com/trufflesuite/ganache-cli
1. Zeppelin Solidity - https://github.com/OpenZeppelin/zeppelin-solidity
1. Ganache (EthereumJS Testrpc) - https://github.com/trufflesuite/ganache
1. OpenZeppelin Contracts - https://github.com/OpenZeppelin/openzeppelin-contracts

## Contribution Guide

- Run Docker tests to ensure that the project is set up successfully.
- Write tests for new contracts and functionalities.
- Run tests to confirm that new implementations work correctly.
- Format Solidity code before opening a pull request (PR). For formatting, you can use Remix Online IDE - https://remix.ethereum.org/

## Where Can I Write Solidity Code?

### Notes for Those Without an IDE:
Using Remix Online IDE is sufficient. There's no need to install anything locally.

### Notes for JetBrains or Visual Studio Code (VSCode) Users:
- These IDEs offer Solidity plugins, which can simplify your workflow. However, Remix Online IDE is also a viable option.
- To index JavaScript code, execute the Docker commands as mentioned. Necessary dependencies will be downloaded, enabling the IDE to index the rest of the code.
12 changes: 12 additions & 0 deletions contracts/Erc1155Token.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";

contract Erc1155Token is ERC1155 {
constructor(string memory tokenUri) ERC1155(tokenUri) {
uint256 tokenId = 1;
uint256 amount = 3;
_mint(msg.sender, tokenId, amount, "");
}
}
13 changes: 13 additions & 0 deletions contracts/Erc721Token.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";

contract Erc721Token is ERC721 {
constructor(string memory tokenName, string memory tokenSymbol)
ERC721(tokenName, tokenSymbol)
{
uint256 tokenId = 1;
_mint(msg.sender, tokenId);
}
}
Loading