forked from Phala-Network/phat-offchain-rollup
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rollup anchor for ink smart contract
- Loading branch information
1 parent
7dc2f9b
commit a9cc209
Showing
19 changed files
with
2,897 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[workspace] | ||
resolver = "2" | ||
members = [ | ||
"crates/phat_rollup_anchor_ink", | ||
"contracts/test_oracle", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[package] | ||
name = "test_oracle" | ||
version = "0.0.1" | ||
authors = ["GuiGou"] | ||
edition = "2021" | ||
|
||
[dependencies] | ||
ink = { version = "4.2", default-features = false } | ||
|
||
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } | ||
scale-info = { version = "2", default-features = false, features = ["derive"], optional = true } | ||
|
||
openbrush = { git = "https://github.com/727-Ventures/openbrush-contracts", version = "3.1.1", features = ["ownable", "access_control"], default-features = false } | ||
|
||
phat_rollup_anchor_ink = { path = "../../crates/phat_rollup_anchor_ink", default-features = false} | ||
|
||
[dev-dependencies] | ||
ink_e2e = { version = "4.2" } | ||
hex-literal = { version = "0.4.1" } | ||
|
||
[lib] | ||
path = "lib.rs" | ||
|
||
[features] | ||
default = ["std"] | ||
std = [ | ||
"ink/std", | ||
"scale/std", | ||
"scale-info/std", | ||
"openbrush/std", | ||
"phat_rollup_anchor_ink/std", | ||
] | ||
ink-as-dependency = [] | ||
e2e-tests = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Test Oracle | ||
|
||
Implements a simple oracle to get/display the price of trading pairs. It uses the crate `phat_rollup_anchor_ink`. | ||
It supports: | ||
- create a trading pair with an id and the token names. The name must match with the API id from CoinGecko. By example: `polkadot`, `astar`, `pha`, `usd`. Only an address granted as `MANAGER` can do it. | ||
- configure the attestor authorized to send the prices. Only an address granted as `MANAGER` can do it. | ||
- send a request to get the price of a given trading pair. Only an address granted as `MANAGER` can do it. | ||
- handle the messages to feed the trading pair. Only an address granted as `ATTESTOR` can do it. | ||
- display the trading pair with this id. | ||
- allow meta transactions to separate the attestor and the payer. | ||
|
||
By default, the contract owner is granted as `MANAGER` but it is not granted as `ATTESTOR`. | ||
|
||
## Build | ||
|
||
To build the contract: | ||
|
||
```bash | ||
cargo contract build | ||
``` | ||
|
||
## Run e2e tests | ||
|
||
Before you can run the test, you have to install a Substrate node with pallet-contracts. By default, `e2e tests` require that you install `substrate-contracts-node`. You do not need to run it in the background since the node is started for each test independently. To install the latest version: | ||
```bash | ||
cargo install contracts-node --git https://github.com/paritytech/substrate-contracts-node.git | ||
``` | ||
|
||
If you want to run any other node with pallet-contracts you need to change `CONTRACTS_NODE` environment variable: | ||
```bash | ||
export CONTRACTS_NODE="YOUR_CONTRACTS_NODE_PATH" | ||
``` | ||
|
||
And finally execute the following command to start e2e tests execution. | ||
```bash | ||
cargo test --features e2e-tests | ||
``` |
Oops, something went wrong.