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

feat(gear-programs): vft-gateway & bridging-payment #84

Merged
merged 38 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
076d1ba
initial grc20-gateway and bridge-payment implementation
LouiseMedova Jun 24, 2024
9d06fd3
TO DO comments
LouiseMedova Jun 24, 2024
eeec0cb
implementation of handle_reply and critical in grc20-gateway
LouiseMedova Jun 25, 2024
108a83c
several fixes according to review & naming update
LouiseMedova Jul 3, 2024
35fc280
fixed build with updated sails
LouiseMedova Jul 11, 2024
cccc45e
changef sails-rtl to sails
LouiseMedova Jul 14, 2024
57c772f
merged relayer & Cargo.toml
LouiseMedova Jul 15, 2024
dde0881
Update gear-programs/bridging-payment/src/wasm/build.rs
LouiseMedova Jul 16, 2024
472a25b
Update Cargo.toml
LouiseMedova Jul 16, 2024
dbccf41
Update Cargo.toml
LouiseMedova Jul 16, 2024
a8304c7
Update gear-programs/bridging-payment/src/wasm/Cargo.toml
LouiseMedova Jul 16, 2024
7c7aa55
Update gear-programs/vft-gateway/src/services/mod.rs
LouiseMedova Jul 16, 2024
814d133
added functionality to bridge-payment to transfer tokens and make req…
LouiseMedova Aug 1, 2024
7391125
fixed build
LouiseMedova Aug 1, 2024
5d2a43a
updated contracts to v1.5.0
LouiseMedova Aug 14, 2024
76b90d7
merged main
LouiseMedova Aug 15, 2024
5e6ba15
finished merge
LouiseMedova Aug 15, 2024
fb6c00d
fixed warnings
LouiseMedova Aug 16, 2024
27118e5
added admins functions
LouiseMedova Aug 21, 2024
21701ff
Update gear-programs/bridging-payment/src/services/msg_tracker.rs
LouiseMedova Aug 21, 2024
39f5e98
Update gear-programs/bridging-payment/src/services/mod.rs
LouiseMedova Aug 21, 2024
fc5ebfd
Update gear-programs/vft-gateway/src/wasm/tests/utils.rs
LouiseMedova Aug 21, 2024
1117ef7
Update gear-programs/vft-gateway/src/wasm/tests/utils.rs
LouiseMedova Aug 21, 2024
2129d3c
Update gear-programs/vft-gateway/src/services/mod.rs
LouiseMedova Aug 21, 2024
c4aacb1
Update gear-programs/vft-gateway/src/services/mod.rs
LouiseMedova Aug 21, 2024
a032af6
Update gear-programs/vft-gateway/src/services/msg_tracker.rs
LouiseMedova Aug 21, 2024
5e33c7a
Update gear-programs/vft-gateway/src/services/token_operations.rs
LouiseMedova Aug 21, 2024
58fe8dc
fixed accroding review
LouiseMedova Aug 21, 2024
db82f77
fixed test
LouiseMedova Aug 21, 2024
db04eaa
Merge branch 'main' into lm-vara-contracts
LouiseMedova Aug 21, 2024
33cbc35
added query methods
LouiseMedova Aug 23, 2024
3e48e3e
fixed tests
LouiseMedova Aug 23, 2024
1546c17
fix clippy
LouiseMedova Aug 23, 2024
fc3b5ce
fix clippy
LouiseMedova Aug 23, 2024
00778e1
fix clippy
LouiseMedova Aug 26, 2024
e8aaf38
fixed tests
LouiseMedova Aug 26, 2024
11f6a23
fixed tests
LouiseMedova Aug 26, 2024
1a3ba49
fmt
LouiseMedova Aug 26, 2024
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
2,686 changes: 2,301 additions & 385 deletions Cargo.lock

Large diffs are not rendered by default.

34 changes: 25 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ members = [
"relayer",
"circuits/*",
"ethereum-common",
"gear-programs/bridging-payment",
"gear-programs/bridging-payment/src/wasm",
"gear-programs/vft-gateway",
"gear-programs/vft-gateway/src/wasm",
"gear-programs/*",
"gear-programs/checkpoint-light-client/io",
"utils-prometheus",
Expand All @@ -29,8 +33,10 @@ plonky2_u32 = { path = "./circuits/plonky2_u32" }
ethereum-client = { path = "./ethereum/client" }
ethereum-common = { path = "ethereum-common", default-features = false }

grc20_gateway = { path = "gear-programs/grc20-gateway" }
bridging_payment = { path = "gear-programs/bridging-payment" }
bridging_payment_wasm = { path = "gear-programs/bridging_payment/src/wasm" }
vft-gateway-app = { path = "gear-programs/vft-gateway" }
vft_gateway_wasm = { path = "gear-programs/vft-gateway/src/wasm" }
gear_proof_storage = { path = "gear-programs/proof-storage" }
checkpoint_light_client-io = { path = "gear-programs/checkpoint-light-client/io", default-features = false }
utils-prometheus = { path = "utils-prometheus" }
Expand Down Expand Up @@ -67,9 +73,11 @@ ethereum-types = { version = "0.14.1", default-features = false, features = [
"codec",
"rlp",
] }
extended_vft_wasm = { git = "https://github.com/gear-foundation/standards/", branch = "gstd-pinned-v1.5.0"}
ff = { version = "0.13.0", features = ["derive"] }
futures = { version = "0.3.30", features = ["executor"] }
futures-util = "0.3.28"
git-download = "0.1"
hash-db = { version = "0.15.2", default-features = false }
hash256-std-hasher = { version = "0.15.2", default-features = false }
hex = { version = "0.4.3", default-features = false }
Expand Down Expand Up @@ -112,18 +120,23 @@ tree_hash_derive = { git = "https://github.com/gear-tech/tree_hash.git", branch
unroll = "0.1.5"

# Gear/Substrate deps
gstd = { git = "https://github.com/gear-tech/gear.git", tag = "v1.5.0", features = [
"nightly",
] }
gmeta = { git = "https://github.com/gear-tech/gear.git", tag = "v1.5.0" }
gear-wasm-builder = { git = "https://github.com/gear-tech/gear.git", tag = "v1.5.0", default-features = false }
gsdk = { git = "https://github.com/gear-tech/gear.git", tag = "v1.5.0" }
gclient = { git = "https://github.com/gear-tech/gear.git", tag = "v1.5.0" }
gear-core = { git = "https://github.com/gear-tech/gear.git", tag = "v1.5.0" }
gstd = { version = "=1.5.0", features = ["nightly"] }
gtest = "=1.5.0"
gwasm-builder = { version = "=1.5.0", package = "gear-wasm-builder" }
gmeta = "=1.5.0"
gear-wasm-builder = { version = "=1.5.0", default-features = false }
gsdk = "=1.5.0"
gclient = "=1.5.0"
gear-core = "=1.5.0"
gbuiltin-bls381 = { git = "https://github.com/gear-tech/gear.git", tag = "v1.5.0" }
gbuiltin-eth-bridge = { git = "https://github.com/gear-tech/gear.git", tag = "v1.5.0" }
pallet-gear-eth-bridge-rpc-runtime-api = { git = "https://github.com/gear-tech/gear.git", tag = "v1.5.0", default-features = false, features = [
"std",
] }
sails-idl-gen = "0.3.0"
sails-client-gen = "0.3.0"
sails-rs = "0.3.0"

subxt = "0.32.1"
sc-consensus-grandpa = { version = "0.10.0-dev", git = "https://github.com/gear-tech/polkadot-sdk.git", branch = "gear-v1.4.0", default-features = false }
sp-runtime = { version = "24.0.0", git = "https://github.com/gear-tech/polkadot-sdk.git", branch = "gear-v1.4.0", default-features = false }
Expand Down Expand Up @@ -158,3 +171,6 @@ alloy = { version = "0.2.0", package = "alloy", features = [
"json-rpc",
"rpc-types",
] }

[patch.crates-io]
gsys = { git = "https://github.com/gear-tech/gear.git", tag = "v1.5.0" }
17 changes: 5 additions & 12 deletions gear-programs/bridging-payment/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,13 @@ version.workspace = true
edition.workspace = true

[dependencies]
grc20_gateway = { workspace = true, features = ["std"] }

gstd.workspace = true
sails-rs.workspace = true
parity-scale-codec.workspace = true
scale-info.workspace = true
primitive-types.workspace = true
gstd.workspace = true
gbuiltin-eth-bridge.workspace = true

[build-dependencies]
gear-wasm-builder.workspace = true

[lib]
crate-type = ["rlib"]
name = "bridging_payment"
git-download.workspace = true
sails-client-gen.workspace = true

[features]
std = []
default = ["std"]
26 changes: 25 additions & 1 deletion gear-programs/bridging-payment/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
use sails_client_gen::ClientGenerator;
use std::{env, path::PathBuf};

fn main() {
gear_wasm_builder::build();
let out_dir_path = PathBuf::from(env::var("OUT_DIR").unwrap());

let idl_file_path = PathBuf::from("../vft-gateway/src/wasm/vft-gateway.idl");

let client_rs_file_path = out_dir_path.join("vft-gateway.rs");

ClientGenerator::from_idl_path(&idl_file_path)
.generate_to(client_rs_file_path)
.unwrap();
let idl_file_path = out_dir_path.join("vft.idl");

let client_rs_file_path = out_dir_path.join("vft.rs");

git_download::repo("https://github.com/gear-foundation/standards")
.branch_name("master")
.add_file("extended-vft/wasm/extended_vft.idl", &idl_file_path)
.exec()
.unwrap();

ClientGenerator::from_idl_path(&idl_file_path)
.generate_to(client_rs_file_path)
.unwrap();
}
40 changes: 14 additions & 26 deletions gear-programs/bridging-payment/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,31 +1,19 @@
#![no_std]

use gstd::ActorId;
use parity_scale_codec::{Decode, Encode};
use primitive_types::U256;
use scale_info::TypeInfo;
use sails_rs::{gstd::GStdExecContext, program};
pub mod services;
use services::{BridgingPayment, InitConfig};
#[derive(Default)]
pub struct Program;

#[cfg(not(feature = "std"))]
mod wasm;
#[program]
impl Program {
pub fn new(init_config: InitConfig) -> Self {
BridgingPayment::<GStdExecContext>::seed(init_config, GStdExecContext::new());
Self
}

#[derive(Debug, Decode, Encode, TypeInfo)]
pub struct InitMessage {
pub grc20_gateway: ActorId,
pub fee: u128,
}

#[derive(Debug, Decode, Encode, TypeInfo)]
pub enum AdminMessage {
SetFee(u128),
ReclaimFees,
}

#[derive(Debug, Decode, Encode, TypeInfo)]
pub struct UserReply {
pub nonce: U256,
}

#[derive(Debug, Decode, Encode, TypeInfo)]
pub struct State {
pub fee: u128,
pub fn bridging_payment(&self) -> BridgingPayment<GStdExecContext> {
BridgingPayment::new(GStdExecContext::new())
}
}
22 changes: 22 additions & 0 deletions gear-programs/bridging-payment/src/services/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use sails_rs::prelude::*;

#[allow(clippy::enum_variant_names)]
#[derive(Debug, Encode, Decode, TypeInfo, Clone)]
pub enum Error {
SendFailure,
ReplyFailure,
TransferTokensDecode,
TokensTransferFailure,
RequestToGateWayDecode,
PayloadSize,
MintTokensDecode,
ReplyTimeout,
TokensRefunded,
TransactionFailure,
FailureInVftGateway,
ReplyHook,
GatewayMessageProcessingFailed,
InvalidMessageStatus,
MessageNotFound,
TransferTokensFailed,
}
Loading
Loading