-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gear-programs): vft-gateway & bridging-payment (#84)
Co-authored-by: mertwole <[email protected]>
- Loading branch information
1 parent
474aa3c
commit ec60c9f
Showing
41 changed files
with
5,159 additions
and
595 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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 |
---|---|---|
@@ -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(); | ||
} |
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 |
---|---|---|
@@ -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()) | ||
} | ||
} |
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,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, | ||
} |
Oops, something went wrong.