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

Rewrite in Typescript and a lot of improvements #21

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
23288ce
Add full test environment for Solidity contract
KevinTuncer Mar 30, 2022
b34de4b
Full rewrite of oracle-eos
KevinTuncer Mar 31, 2022
40e2173
oracle-eos.ts
KevinTuncer Mar 31, 2022
4a5c50a
oracle-eos.ts
KevinTuncer Apr 1, 2022
1408b97
- Set everything in a class
KevinTuncer Apr 10, 2022
9087d8a
Skip removed events on blockchain
KevinTuncer Apr 12, 2022
0e66a68
- Show contract configuration in RAM table
KevinTuncer Apr 14, 2022
9386e62
EOS Contract:
KevinTuncer Apr 15, 2022
c185ff5
EOSIO Contract
KevinTuncer Apr 15, 2022
b75a670
- Store contract version on stats table
KevinTuncer Apr 16, 2022
93ca2fa
Finish tests of the eosio teleport contract functions
KevinTuncer Apr 17, 2022
5a7dfef
EOSIO contract
KevinTuncer Apr 27, 2022
7ebfed5
Add more parameters to stats table
KevinTuncer Apr 30, 2022
be78be5
BugFix eth oracle check id
KevinTuncer May 5, 2022
ccb1e93
- Better error messages on eth oracles
KevinTuncer May 11, 2022
fdbef57
- Improvement of some spelling mistakes
KevinTuncer May 14, 2022
cfad464
- Set and comment the example config file for the oracles
KevinTuncer May 15, 2022
9aa1f35
Add comment in example config and edit the main md file
KevinTuncer May 16, 2022
db4406c
Add comment on config-example.js and make transfer function on EOSIO …
KevinTuncer May 17, 2022
13e87ef
Use key value object to store chain information on EOSIO table
KevinTuncer May 17, 2022
8144637
Fix test environment
KevinTuncer May 18, 2022
afe612a
Set eth test environment to the sample settings of the contract and m…
KevinTuncer May 18, 2022
3167c14
Oracles
KevinTuncer May 25, 2022
1060afb
Explanation about the version numbers
KevinTuncer Nov 25, 2022
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
11 changes: 9 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
oracle/node_modules
.vs
.vscode
config.js
contracts/teleporteos/node_modules
teleporteos.ts
eosio.token.ts
contracts/teleporteos/artifacts
build
node_modules
.eosproj
.secret
*.code-workspace
teleporteos.abi
teleporteos.wasm
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
The MIT License (MIT)
=====================

Copyright © `2020` `Dacoco GmbH`
Copyright © `2022` `Kevin Kei Tuncer`

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
Expand Down
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,31 @@

Contracts and tools to create a bridge between WAX tokens and an ERC-20 counterpart.

## Versions

The version numbers are necessary to make all teleports compatible with custom frontends. This project is called version 1 and is a backwards compatible fork of the origin [Alien Worlds teleport](https://github.com/Alien-Worlds/alienteleport). The project of [SavAct](https://github.com/SavAct/eosioteleport) is a fork of version 1 and is called version 2. Each fork brings up a lot of new features and reduces the running costs.

[Version 2](https://github.com/SavAct/eosioteleport) is not backwards compatible, but recommended for new projects because it offers the most advantages, is fully tested and already used by real world applications.

## Contracts

There are contracts available for both EOSIO chains and Ethereum, both should be deployed
on their respective chains.
There are contracts available for both EOSIO chains and Ethereum, both should be deployed on their respective chains.
After deploying the EOSIO contract call the `ini` function to initialize it. Each ETH chain must be registered on the EOSIO contract with the `addchain` function.

## Process

Transferring from EOSIO -> ETH requires depositing the tokens to the EOSIO contract with a standard transfer (no memo required),
Transferring from EOSIO -> ETH requires depositing the tokens to the EOSIO contract with a standard transfer (no memo required),
then teleporting the tokens using the `teleport` action.

Transferring from ETH -> EOSIO simply requires callint the `teleport` function on the Ethereum contract.

You can use the SavAct WebApp as frontend by entering your EOSIO contract and network. For direct selection add your settings to the URL
[https://savact.app/#/_trx_/teleport?bridge=**other.worlds**&eosio=**WAX**&eth=**BSC**](https://savact.app/#/_trx_/teleport?bridge=other.worlds&eosio=WAX&eth=BSC)

The app is only compatible with the EOSIO teleport contract of version 1 and higher. For more information see its [README.md](./contracts/teleporteos/README.md)

To add your teleport in a select box of the SavAct WebApp, feel free to request the admins of https://t.me/SavActGroup

## Oracles

Oracle accounts must be registered using the `regoracle` (EOSIO) or `regOracle` (Ethereum) functions.
Expand All @@ -25,4 +38,3 @@ Oracles can then call the received function on each contract when they see a tra
1. Copy config-example.js to config.js
2. Change the configuration settings to match your tokens
3. Start the oracle using the following command `CONFIG=./[path/to/config] oracle-eos|eth.js`

125 changes: 125 additions & 0 deletions contracts/teleporteos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# New features
- Optional fix and variable fees which fund the oracles
- Freeze options for specific parts of the contract
- Adjustable number of needed oracle confirmations for a receiving teleport
- Adjustable minimum amount for deposits and teleports
- Option to delete old teleport and cancel entries without losing consensus
- Store all needed bridge data in stats table for interoperability with custom front end apps

# Note
This version reduces the EOSIO RAM by half and therefore its running costs. Further reductions need breaking changes, therefore a second version will be provided by [SavAct](https://github.com/SavAct).

# Deployment and initialization

0. The EOSIO account of the contract needs the `eosio.code` permission activated.
1. Deploy the contract
2. Run the ini action of the contract with the following parameters
```
ACTION ini(asset min, uint64_t fixfee, double varfee, bool freeze, uint32_t threshold);
```
- ***min*** Minimum amount for a deposit and teleport
- ***fixfee*** Fix fee for teleports and receipts. Together with the variable fee (varfee) the resulting fee has to be less than the minimum transfer amount (min).
- ***varfee*** Variable fee for teleports and receipts. This has to be between 0 and 0.20 which equals to 0% and 20%.
- ***freeze*** True to freeze the contract until you unfreeze it with the freeze action.
- ***threshold*** Amount of needed oracle confirmations for a receiving teleport

3. Add the allowed ethereum chains
```
ACTION addchain(string name, uint8_t chain_id, string teleaddr, string tokenaddr);
```
- ***name*** Name of the chain to bridge
- ***abbreviation*** Short name of the chain
- ***chain_id*** Identification number for this new chain
- ***net_id*** Unique network id to distinguish different chains. See "ChainID" for ethereum based chains on https://chainlist.org/
- ***teleaddr*** Teleport contract address
- ***tokenaddr*** Token contract address

With the freeze action you can freeze and unfreeze specific parts of the contract
```
ACTION freeze(const bool in, const bool out, const bool oracles, const bool cancel);
```
- ***in*** True to freeze incoming funds, false to unfreeze
- ***out*** True to freeze outgoing funds, false to unfreeze
- ***oracles*** True to freeze oracles, false to unfreeze
- ***cancel*** True to freeze cancel action, false to unfreeze

Register oracles with regoracle
- ***oracle_name*** EOSIO account name of the oracle
```
ACTION regoracle(name oracle_name);
```

## Upgrade from running teleport contract of alien world

Just deploy the contract over the old teleport contract account, run the ini action and add all connected chains by executing the addchain action.

**Note:** Additional tables are included in this upgrade, the structure of the old tables is not changed.

## Maintenance

To pay off collected fees to the oracles run payoracles
```
ACTION payoracles();
```

Use delteles to free the EOSIO RAM of completed and canceled teleports
***to_id*** Delete all entries until this id
```
ACTION delteles(uint64_t to_id);
```

**Note:** You can use the [SavAct WebApp](https://savact.app/#/_trx_/teleport/setup) in combination with the [Anchor Wallet by Greymass](https://greymass.com/en/anchor/) to execute these actions.


# Install test suite on windows

You need to activate the windows feature Hyper-V, but it is not available on Windows 10 Home. You might need to upgrade your Windows to Windows Pro.

## Activate WSL 2
Start windows PowerShell as administrator and run the following commands
```
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
```

```
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
```

```
wsl --set-default-version 2
```

## Set up Linux environment
Install Debian from Microsoft store, start it, create your user account and run the following commands
```
sudo apt-get update
```
```
sudo apt-get upgrade
```
For yarn installation via npm
```
sudo apt-get install npm
```
Install yarn globally
```
sudo npm install --global yarn
```
Navigate in the console to the folder teleporteos in which you can install the modules (**run the following command again if it fails**)
```
sudo yarn install
```

## Set up docker
Install and start Docker, check for updates and install them. Open the Dockers menu by double clicking the icon in the task bar and go to settings ⚙️.

Check "Use the WSL 2 based engine"

Enable Debian in the settings at Resources / WSL INTEGRATION

## Run tests

Docker must be running. Start the tests with the following command in the debian console
```
sudo yarn test
```
Loading