Skip to content

Commit

Permalink
feat(gear-programs): vft-gateway & bridging-payment (#84)
Browse files Browse the repository at this point in the history
Co-authored-by: mertwole <[email protected]>
  • Loading branch information
LouiseMedova and mertwole authored Aug 26, 2024
1 parent 474aa3c commit ec60c9f
Show file tree
Hide file tree
Showing 41 changed files with 5,159 additions and 595 deletions.
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

0 comments on commit ec60c9f

Please sign in to comment.