Skip to content

Commit

Permalink
feat: Add percentage fee handler pallet (#118)
Browse files Browse the repository at this point in the history
Add percentage fee handler pallet
  • Loading branch information
freddyli7 authored Aug 3, 2023
1 parent 1d7fc5a commit da8445c
Show file tree
Hide file tree
Showing 25 changed files with 1,222 additions and 108 deletions.
2 changes: 1 addition & 1 deletion .github/actions/install_toolchain/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ runs:
- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2023-02-03
toolchain: nightly-2023-06-01
override: true
target: wasm32-unknown-unknown
components: rustfmt
Expand Down
23 changes: 23 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ resolver = "2"
members = [
"access-segregator",
"basic-fee-handler",
"percentage-fee-handler",
"bridge",
"fee-handler-router",
"traits",
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile_e2e
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ ENV MPCADDR $mpc_address

RUN ["./scripts/e2e_setup.sh"]

ENTRYPOINT ["./node-template", "--dev", "--ws-external", "--base-path", "./db/"]
ENTRYPOINT ["./node-template", "--dev", "--rpc-external", "--base-path", "./db/"]
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ fmt:
test:
cargo test

# run unit test with benchmark
test-benchmark:
cargo test --features runtime-benchmarks

# license-check Checks for missing license crates
license-check:
@echo " > \033[Checking for license headers...\033[0m "
Expand All @@ -20,10 +24,14 @@ license-check:
build:
cargo build --release

# build the binary locally with benchmark
build-benchmark:
cargo build --release --features runtime-benchmarks

############################## Local node ############################
# launch the local node in dev mode
start-dev:
./target/release/node-template --dev --ws-external
./target/release/node-template --dev --rpc-external

# run setup js script to setup the local substrate node
# substrate node is required, run make start-dev first
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ This repo contains several substrate pallet implementation for Sygma protocol.
- Run docker container as local testnet

```sh
$ docker run -p 9944:9944 -it sygma-substrate-pallet --dev --ws-external
$ docker run -p 9944:9944 -it sygma-substrate-pallet --dev --rpc-external
```

## Interact via Polkadot JS App
Expand Down
6 changes: 3 additions & 3 deletions basic-fee-handler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub mod pallet {
use frame_system::pallet_prelude::*;
use sp_std::boxed::Box;
use sygma_traits::{DomainID, FeeHandler};
use xcm::latest::AssetId;
use xcm::latest::{AssetId, MultiAsset};

const STORAGE_VERSION: StorageVersion = StorageVersion::new(0);

Expand Down Expand Up @@ -96,8 +96,8 @@ pub mod pallet {
}

impl<T: Config> FeeHandler for Pallet<T> {
fn get_fee(domain: DomainID, asset: &AssetId) -> Option<u128> {
AssetFees::<T>::get((domain, asset))
fn get_fee(domain: DomainID, asset: MultiAsset) -> Option<u128> {
AssetFees::<T>::get((domain, &asset.id))
}
}

Expand Down
2 changes: 2 additions & 0 deletions bridge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ xcm-executor = { git = "https://github.com/paritytech/polkadot", branch = "relea
sygma-traits = { path = "../traits", default-features = false }
sygma-access-segregator = { path = "../access-segregator", default-features = false }
sygma-basic-feehandler = { path = "../basic-fee-handler", default-features = false }
sygma-percentage-feehandler = { path = "../percentage-fee-handler", default-features = false }
sygma-fee-handler-router = { path = "../fee-handler-router", default-features = false }

[dev-dependencies]
Expand Down Expand Up @@ -94,6 +95,7 @@ std = [
"sygma-traits/std",
"sygma-access-segregator/std",
"sygma-basic-feehandler/std",
"sygma-percentage-feehandler/std",
"sygma-fee-handler-router/std",
]
try-runtime = ["frame-support/try-runtime"]
Loading

0 comments on commit da8445c

Please sign in to comment.