Skip to content

Commit

Permalink
fix(gear-programs): Use local idl file in windows env (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
vobradovich authored Sep 9, 2024
1 parent c697769 commit 4d63233
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 4 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ curl -L https://foundry.paradigm.xyz | bash
foundryup
```

> [!NOTE]
> To build `ring` crate follow [BUILDING.md](https://github.com/gear-tech/ring/blob/main/BUILDING.md).
### Run relayer

Build workspace:
Expand Down
9 changes: 8 additions & 1 deletion gear-programs/bridging-payment/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,23 @@ fn main() {
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");

#[cfg(not(target_family = "windows"))]
let idl_file_path = out_dir_path.join("vft.idl");
#[cfg(not(target_family = "windows"))]
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();

// use local copy of `vft.idl` to build on windows
#[cfg(target_family = "windows")]
let idl_file_path =
PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()).join("../vft-gateway/vft.idl");

ClientGenerator::from_idl_path(&idl_file_path)
.generate_to(client_rs_file_path)
.unwrap();
Expand Down
10 changes: 7 additions & 3 deletions gear-programs/vft-gateway/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@ use std::{env, path::PathBuf};

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

let idl_file_path = out_dir_path.join("vft.idl");

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

#[cfg(not(target_family = "windows"))]
let idl_file_path = out_dir_path.join("vft.idl");
#[cfg(not(target_family = "windows"))]
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();

// use local copy of `vft.idl` to build on windows
#[cfg(target_family = "windows")]
let idl_file_path = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()).join("vft.idl");

ClientGenerator::from_idl_path(&idl_file_path)
.generate_to(client_rs_file_path)
.unwrap();
Expand Down
33 changes: 33 additions & 0 deletions gear-programs/vft-gateway/vft.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
constructor {
New : (name: str, symbol: str, decimals: u8);
};

service Vft {
Burn : (from: actor_id, value: u256) -> bool;
GrantAdminRole : (to: actor_id) -> null;
GrantBurnerRole : (to: actor_id) -> null;
GrantMinterRole : (to: actor_id) -> null;
Mint : (to: actor_id, value: u256) -> bool;
RevokeAdminRole : (from: actor_id) -> null;
RevokeBurnerRole : (from: actor_id) -> null;
RevokeMinterRole : (from: actor_id) -> null;
Approve : (spender: actor_id, value: u256) -> bool;
Transfer : (to: actor_id, value: u256) -> bool;
TransferFrom : (from: actor_id, to: actor_id, value: u256) -> bool;
query Admins : () -> vec actor_id;
query Burners : () -> vec actor_id;
query Minters : () -> vec actor_id;
query Allowance : (owner: actor_id, spender: actor_id) -> u256;
query BalanceOf : (account: actor_id) -> u256;
query Decimals : () -> u8;
query Name : () -> str;
query Symbol : () -> str;
query TotalSupply : () -> u256;

events {
Minted: struct { to: actor_id, value: u256 };
Burned: struct { from: actor_id, value: u256 };
Approval: struct { owner: actor_id, spender: actor_id, value: u256 };
Transfer: struct { from: actor_id, to: actor_id, value: u256 };
}
};

0 comments on commit 4d63233

Please sign in to comment.