diff --git a/extended-vft/client/build.rs b/extended-vft/client/build.rs deleted file mode 100644 index 6d330da..0000000 --- a/extended-vft/client/build.rs +++ /dev/null @@ -1,17 +0,0 @@ -use sails_client_gen::ClientGenerator; -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("extended_vft.idl"); - - // Generate IDL file for the program - sails_idl_gen::generate_idl_to_file::(&idl_file_path) - .unwrap(); - - // Generate client code from IDL file - ClientGenerator::from_idl_path(&idl_file_path) - .with_mocks("mocks") - .generate_to(PathBuf::from(env::var("OUT_DIR").unwrap()).join("extended_vft_client.rs")) - .unwrap(); -} diff --git a/extended-vft/client/src/lib.rs b/extended-vft/client/src/lib.rs index 39b9c03..35e2803 100644 --- a/extended-vft/client/src/lib.rs +++ b/extended-vft/client/src/lib.rs @@ -1,4 +1,522 @@ #![no_std] -// Incorporate code generated based on the IDL file -include!(concat!(env!("OUT_DIR"), "/extended_vft_client.rs")); +// Code generated by sails-client-gen. DO NOT EDIT. +#[allow(unused_imports)] +use sails_rs::collections::BTreeMap; +#[allow(unused_imports)] +use sails_rs::{ + calls::{Activation, Call, Query, Remoting, RemotingAction}, + prelude::*, + String, +}; +pub struct ExtendedVftFactory { + #[allow(dead_code)] + remoting: R, +} +impl ExtendedVftFactory { + #[allow(unused)] + pub fn new(remoting: R) -> Self { + Self { remoting } + } +} +impl traits::ExtendedVftFactory for ExtendedVftFactory { + type Args = R::Args; + fn new(&self, name: String, symbol: String, decimals: u8) -> impl Activation { + RemotingAction::<_, extended_vft_factory::io::New>::new( + self.remoting.clone(), + (name, symbol, decimals), + ) + } +} + +pub mod extended_vft_factory { + use super::*; + pub mod io { + use super::*; + use sails_rs::calls::ActionIo; + pub struct New(()); + impl New { + #[allow(dead_code)] + pub fn encode_call(name: String, symbol: String, decimals: u8) -> Vec { + ::encode_call(&(name, symbol, decimals)) + } + } + impl ActionIo for New { + const ROUTE: &'static [u8] = &[12, 78, 101, 119]; + type Params = (String, String, u8); + type Reply = (); + } + } +} +pub struct Vft { + remoting: R, +} +impl Vft { + pub fn new(remoting: R) -> Self { + Self { remoting } + } +} +impl traits::Vft for Vft { + type Args = R::Args; + fn burn(&mut self, from: ActorId, value: U256) -> impl Call { + RemotingAction::<_, vft::io::Burn>::new(self.remoting.clone(), (from, value)) + } + fn grant_admin_role(&mut self, to: ActorId) -> impl Call { + RemotingAction::<_, vft::io::GrantAdminRole>::new(self.remoting.clone(), to) + } + fn grant_burner_role(&mut self, to: ActorId) -> impl Call { + RemotingAction::<_, vft::io::GrantBurnerRole>::new(self.remoting.clone(), to) + } + fn grant_minter_role(&mut self, to: ActorId) -> impl Call { + RemotingAction::<_, vft::io::GrantMinterRole>::new(self.remoting.clone(), to) + } + fn mint(&mut self, to: ActorId, value: U256) -> impl Call { + RemotingAction::<_, vft::io::Mint>::new(self.remoting.clone(), (to, value)) + } + fn revoke_admin_role(&mut self, from: ActorId) -> impl Call { + RemotingAction::<_, vft::io::RevokeAdminRole>::new(self.remoting.clone(), from) + } + fn revoke_burner_role(&mut self, from: ActorId) -> impl Call { + RemotingAction::<_, vft::io::RevokeBurnerRole>::new(self.remoting.clone(), from) + } + fn revoke_minter_role(&mut self, from: ActorId) -> impl Call { + RemotingAction::<_, vft::io::RevokeMinterRole>::new(self.remoting.clone(), from) + } + fn approve( + &mut self, + spender: ActorId, + value: U256, + ) -> impl Call { + RemotingAction::<_, vft::io::Approve>::new(self.remoting.clone(), (spender, value)) + } + fn transfer(&mut self, to: ActorId, value: U256) -> impl Call { + RemotingAction::<_, vft::io::Transfer>::new(self.remoting.clone(), (to, value)) + } + fn transfer_from( + &mut self, + from: ActorId, + to: ActorId, + value: U256, + ) -> impl Call { + RemotingAction::<_, vft::io::TransferFrom>::new(self.remoting.clone(), (from, to, value)) + } + fn admins(&self) -> impl Query, Args = R::Args> { + RemotingAction::<_, vft::io::Admins>::new(self.remoting.clone(), ()) + } + fn burners(&self) -> impl Query, Args = R::Args> { + RemotingAction::<_, vft::io::Burners>::new(self.remoting.clone(), ()) + } + fn minters(&self) -> impl Query, Args = R::Args> { + RemotingAction::<_, vft::io::Minters>::new(self.remoting.clone(), ()) + } + fn allowance( + &self, + owner: ActorId, + spender: ActorId, + ) -> impl Query { + RemotingAction::<_, vft::io::Allowance>::new(self.remoting.clone(), (owner, spender)) + } + fn balance_of(&self, account: ActorId) -> impl Query { + RemotingAction::<_, vft::io::BalanceOf>::new(self.remoting.clone(), account) + } + fn decimals(&self) -> impl Query { + RemotingAction::<_, vft::io::Decimals>::new(self.remoting.clone(), ()) + } + fn name(&self) -> impl Query { + RemotingAction::<_, vft::io::Name>::new(self.remoting.clone(), ()) + } + fn symbol(&self) -> impl Query { + RemotingAction::<_, vft::io::Symbol>::new(self.remoting.clone(), ()) + } + fn total_supply(&self) -> impl Query { + RemotingAction::<_, vft::io::TotalSupply>::new(self.remoting.clone(), ()) + } +} + +pub mod vft { + use super::*; + + pub mod io { + use super::*; + use sails_rs::calls::ActionIo; + pub struct Burn(()); + impl Burn { + #[allow(dead_code)] + pub fn encode_call(from: ActorId, value: U256) -> Vec { + ::encode_call(&(from, value)) + } + } + impl ActionIo for Burn { + const ROUTE: &'static [u8] = &[12, 86, 102, 116, 16, 66, 117, 114, 110]; + type Params = (ActorId, U256); + type Reply = bool; + } + pub struct GrantAdminRole(()); + impl GrantAdminRole { + #[allow(dead_code)] + pub fn encode_call(to: ActorId) -> Vec { + ::encode_call(&to) + } + } + impl ActionIo for GrantAdminRole { + const ROUTE: &'static [u8] = &[ + 12, 86, 102, 116, 56, 71, 114, 97, 110, 116, 65, 100, 109, 105, 110, 82, 111, 108, + 101, + ]; + type Params = ActorId; + type Reply = (); + } + pub struct GrantBurnerRole(()); + impl GrantBurnerRole { + #[allow(dead_code)] + pub fn encode_call(to: ActorId) -> Vec { + ::encode_call(&to) + } + } + impl ActionIo for GrantBurnerRole { + const ROUTE: &'static [u8] = &[ + 12, 86, 102, 116, 60, 71, 114, 97, 110, 116, 66, 117, 114, 110, 101, 114, 82, 111, + 108, 101, + ]; + type Params = ActorId; + type Reply = (); + } + pub struct GrantMinterRole(()); + impl GrantMinterRole { + #[allow(dead_code)] + pub fn encode_call(to: ActorId) -> Vec { + ::encode_call(&to) + } + } + impl ActionIo for GrantMinterRole { + const ROUTE: &'static [u8] = &[ + 12, 86, 102, 116, 60, 71, 114, 97, 110, 116, 77, 105, 110, 116, 101, 114, 82, 111, + 108, 101, + ]; + type Params = ActorId; + type Reply = (); + } + pub struct Mint(()); + impl Mint { + #[allow(dead_code)] + pub fn encode_call(to: ActorId, value: U256) -> Vec { + ::encode_call(&(to, value)) + } + } + impl ActionIo for Mint { + const ROUTE: &'static [u8] = &[12, 86, 102, 116, 16, 77, 105, 110, 116]; + type Params = (ActorId, U256); + type Reply = bool; + } + pub struct RevokeAdminRole(()); + impl RevokeAdminRole { + #[allow(dead_code)] + pub fn encode_call(from: ActorId) -> Vec { + ::encode_call(&from) + } + } + impl ActionIo for RevokeAdminRole { + const ROUTE: &'static [u8] = &[ + 12, 86, 102, 116, 60, 82, 101, 118, 111, 107, 101, 65, 100, 109, 105, 110, 82, 111, + 108, 101, + ]; + type Params = ActorId; + type Reply = (); + } + pub struct RevokeBurnerRole(()); + impl RevokeBurnerRole { + #[allow(dead_code)] + pub fn encode_call(from: ActorId) -> Vec { + ::encode_call(&from) + } + } + impl ActionIo for RevokeBurnerRole { + const ROUTE: &'static [u8] = &[ + 12, 86, 102, 116, 64, 82, 101, 118, 111, 107, 101, 66, 117, 114, 110, 101, 114, 82, + 111, 108, 101, + ]; + type Params = ActorId; + type Reply = (); + } + pub struct RevokeMinterRole(()); + impl RevokeMinterRole { + #[allow(dead_code)] + pub fn encode_call(from: ActorId) -> Vec { + ::encode_call(&from) + } + } + impl ActionIo for RevokeMinterRole { + const ROUTE: &'static [u8] = &[ + 12, 86, 102, 116, 64, 82, 101, 118, 111, 107, 101, 77, 105, 110, 116, 101, 114, 82, + 111, 108, 101, + ]; + type Params = ActorId; + type Reply = (); + } + pub struct Approve(()); + impl Approve { + #[allow(dead_code)] + pub fn encode_call(spender: ActorId, value: U256) -> Vec { + ::encode_call(&(spender, value)) + } + } + impl ActionIo for Approve { + const ROUTE: &'static [u8] = &[12, 86, 102, 116, 28, 65, 112, 112, 114, 111, 118, 101]; + type Params = (ActorId, U256); + type Reply = bool; + } + pub struct Transfer(()); + impl Transfer { + #[allow(dead_code)] + pub fn encode_call(to: ActorId, value: U256) -> Vec { + ::encode_call(&(to, value)) + } + } + impl ActionIo for Transfer { + const ROUTE: &'static [u8] = + &[12, 86, 102, 116, 32, 84, 114, 97, 110, 115, 102, 101, 114]; + type Params = (ActorId, U256); + type Reply = bool; + } + pub struct TransferFrom(()); + impl TransferFrom { + #[allow(dead_code)] + pub fn encode_call(from: ActorId, to: ActorId, value: U256) -> Vec { + ::encode_call(&(from, to, value)) + } + } + impl ActionIo for TransferFrom { + const ROUTE: &'static [u8] = &[ + 12, 86, 102, 116, 48, 84, 114, 97, 110, 115, 102, 101, 114, 70, 114, 111, 109, + ]; + type Params = (ActorId, ActorId, U256); + type Reply = bool; + } + pub struct Admins(()); + impl Admins { + #[allow(dead_code)] + pub fn encode_call() -> Vec { + ::encode_call(&()) + } + } + impl ActionIo for Admins { + const ROUTE: &'static [u8] = &[12, 86, 102, 116, 24, 65, 100, 109, 105, 110, 115]; + type Params = (); + type Reply = Vec; + } + pub struct Burners(()); + impl Burners { + #[allow(dead_code)] + pub fn encode_call() -> Vec { + ::encode_call(&()) + } + } + impl ActionIo for Burners { + const ROUTE: &'static [u8] = &[12, 86, 102, 116, 28, 66, 117, 114, 110, 101, 114, 115]; + type Params = (); + type Reply = Vec; + } + pub struct Minters(()); + impl Minters { + #[allow(dead_code)] + pub fn encode_call() -> Vec { + ::encode_call(&()) + } + } + impl ActionIo for Minters { + const ROUTE: &'static [u8] = &[12, 86, 102, 116, 28, 77, 105, 110, 116, 101, 114, 115]; + type Params = (); + type Reply = Vec; + } + pub struct Allowance(()); + impl Allowance { + #[allow(dead_code)] + pub fn encode_call(owner: ActorId, spender: ActorId) -> Vec { + ::encode_call(&(owner, spender)) + } + } + impl ActionIo for Allowance { + const ROUTE: &'static [u8] = &[ + 12, 86, 102, 116, 36, 65, 108, 108, 111, 119, 97, 110, 99, 101, + ]; + type Params = (ActorId, ActorId); + type Reply = U256; + } + pub struct BalanceOf(()); + impl BalanceOf { + #[allow(dead_code)] + pub fn encode_call(account: ActorId) -> Vec { + ::encode_call(&account) + } + } + impl ActionIo for BalanceOf { + const ROUTE: &'static [u8] = + &[12, 86, 102, 116, 36, 66, 97, 108, 97, 110, 99, 101, 79, 102]; + type Params = ActorId; + type Reply = U256; + } + pub struct Decimals(()); + impl Decimals { + #[allow(dead_code)] + pub fn encode_call() -> Vec { + ::encode_call(&()) + } + } + impl ActionIo for Decimals { + const ROUTE: &'static [u8] = + &[12, 86, 102, 116, 32, 68, 101, 99, 105, 109, 97, 108, 115]; + type Params = (); + type Reply = u8; + } + pub struct Name(()); + impl Name { + #[allow(dead_code)] + pub fn encode_call() -> Vec { + ::encode_call(&()) + } + } + impl ActionIo for Name { + const ROUTE: &'static [u8] = &[12, 86, 102, 116, 16, 78, 97, 109, 101]; + type Params = (); + type Reply = String; + } + pub struct Symbol(()); + impl Symbol { + #[allow(dead_code)] + pub fn encode_call() -> Vec { + ::encode_call(&()) + } + } + impl ActionIo for Symbol { + const ROUTE: &'static [u8] = &[12, 86, 102, 116, 24, 83, 121, 109, 98, 111, 108]; + type Params = (); + type Reply = String; + } + pub struct TotalSupply(()); + impl TotalSupply { + #[allow(dead_code)] + pub fn encode_call() -> Vec { + ::encode_call(&()) + } + } + impl ActionIo for TotalSupply { + const ROUTE: &'static [u8] = &[ + 12, 86, 102, 116, 44, 84, 111, 116, 97, 108, 83, 117, 112, 112, 108, 121, + ]; + type Params = (); + type Reply = U256; + } + } + + #[allow(dead_code)] + #[cfg(not(target_arch = "wasm32"))] + pub mod events { + use super::*; + use sails_rs::events::*; + #[derive(PartialEq, Debug, Encode, Decode)] + #[codec(crate = sails_rs::scale_codec)] + pub enum VftEvents { + Minted { + to: ActorId, + value: U256, + }, + Burned { + from: ActorId, + value: U256, + }, + Approval { + owner: ActorId, + spender: ActorId, + value: U256, + }, + Transfer { + from: ActorId, + to: ActorId, + value: U256, + }, + } + impl EventIo for VftEvents { + const ROUTE: &'static [u8] = &[12, 86, 102, 116]; + const EVENT_NAMES: &'static [&'static [u8]] = &[ + &[24, 77, 105, 110, 116, 101, 100], + &[24, 66, 117, 114, 110, 101, 100], + &[32, 65, 112, 112, 114, 111, 118, 97, 108], + &[32, 84, 114, 97, 110, 115, 102, 101, 114], + ]; + type Event = Self; + } + pub fn listener>>(remoting: R) -> impl Listener { + RemotingListener::<_, VftEvents>::new(remoting) + } + } +} + +pub mod traits { + use super::*; + #[allow(dead_code)] + pub trait ExtendedVftFactory { + type Args; + #[allow(clippy::new_ret_no_self)] + #[allow(clippy::wrong_self_convention)] + fn new( + &self, + name: String, + symbol: String, + decimals: u8, + ) -> impl Activation; + } + + #[allow(clippy::type_complexity)] + pub trait Vft { + type Args; + fn burn( + &mut self, + from: ActorId, + value: U256, + ) -> impl Call; + fn grant_admin_role(&mut self, to: ActorId) -> impl Call; + fn grant_burner_role(&mut self, to: ActorId) -> impl Call; + fn grant_minter_role(&mut self, to: ActorId) -> impl Call; + fn mint(&mut self, to: ActorId, value: U256) + -> impl Call; + fn revoke_admin_role(&mut self, from: ActorId) + -> impl Call; + fn revoke_burner_role( + &mut self, + from: ActorId, + ) -> impl Call; + fn revoke_minter_role( + &mut self, + from: ActorId, + ) -> impl Call; + fn approve( + &mut self, + spender: ActorId, + value: U256, + ) -> impl Call; + fn transfer( + &mut self, + to: ActorId, + value: U256, + ) -> impl Call; + fn transfer_from( + &mut self, + from: ActorId, + to: ActorId, + value: U256, + ) -> impl Call; + fn admins(&self) -> impl Query, Args = Self::Args>; + fn burners(&self) -> impl Query, Args = Self::Args>; + fn minters(&self) -> impl Query, Args = Self::Args>; + fn allowance( + &self, + owner: ActorId, + spender: ActorId, + ) -> impl Query; + fn balance_of(&self, account: ActorId) -> impl Query; + fn decimals(&self) -> impl Query; + fn name(&self) -> impl Query; + fn symbol(&self) -> impl Query; + fn total_supply(&self) -> impl Query; + } +} diff --git a/extended-vft/idl_and_client/extended_vft.idl b/extended-vft/extended_vft.idl similarity index 100% rename from extended-vft/idl_and_client/extended_vft.idl rename to extended-vft/extended_vft.idl diff --git a/extended-vft/idl_and_client/extended_vft_client.rs b/extended-vft/idl_and_client/extended_vft_client.rs deleted file mode 100644 index d5e3bbc..0000000 --- a/extended-vft/idl_and_client/extended_vft_client.rs +++ /dev/null @@ -1,520 +0,0 @@ -// Code generated by sails-client-gen. DO NOT EDIT. -#[allow(unused_imports)] -use sails_rs::collections::BTreeMap; -#[allow(unused_imports)] -use sails_rs::{ - String, - calls::{Activation, Call, Query, Remoting, RemotingAction}, - prelude::*, -}; -pub struct ExtendedVftFactory { - #[allow(dead_code)] - remoting: R, -} -impl ExtendedVftFactory { - #[allow(unused)] - pub fn new(remoting: R) -> Self { - Self { remoting } - } -} -impl traits::ExtendedVftFactory for ExtendedVftFactory { - type Args = R::Args; - fn new(&self, name: String, symbol: String, decimals: u8) -> impl Activation { - RemotingAction::<_, extended_vft_factory::io::New>::new( - self.remoting.clone(), - (name, symbol, decimals), - ) - } -} - -pub mod extended_vft_factory { - use super::*; - pub mod io { - use super::*; - use sails_rs::calls::ActionIo; - pub struct New(()); - impl New { - #[allow(dead_code)] - pub fn encode_call(name: String, symbol: String, decimals: u8) -> Vec { - ::encode_call(&(name, symbol, decimals)) - } - } - impl ActionIo for New { - const ROUTE: &'static [u8] = &[12, 78, 101, 119]; - type Params = (String, String, u8); - type Reply = (); - } - } -} -pub struct Vft { - remoting: R, -} -impl Vft { - pub fn new(remoting: R) -> Self { - Self { remoting } - } -} -impl traits::Vft for Vft { - type Args = R::Args; - fn burn(&mut self, from: ActorId, value: U256) -> impl Call { - RemotingAction::<_, vft::io::Burn>::new(self.remoting.clone(), (from, value)) - } - fn grant_admin_role(&mut self, to: ActorId) -> impl Call { - RemotingAction::<_, vft::io::GrantAdminRole>::new(self.remoting.clone(), to) - } - fn grant_burner_role(&mut self, to: ActorId) -> impl Call { - RemotingAction::<_, vft::io::GrantBurnerRole>::new(self.remoting.clone(), to) - } - fn grant_minter_role(&mut self, to: ActorId) -> impl Call { - RemotingAction::<_, vft::io::GrantMinterRole>::new(self.remoting.clone(), to) - } - fn mint(&mut self, to: ActorId, value: U256) -> impl Call { - RemotingAction::<_, vft::io::Mint>::new(self.remoting.clone(), (to, value)) - } - fn revoke_admin_role(&mut self, from: ActorId) -> impl Call { - RemotingAction::<_, vft::io::RevokeAdminRole>::new(self.remoting.clone(), from) - } - fn revoke_burner_role(&mut self, from: ActorId) -> impl Call { - RemotingAction::<_, vft::io::RevokeBurnerRole>::new(self.remoting.clone(), from) - } - fn revoke_minter_role(&mut self, from: ActorId) -> impl Call { - RemotingAction::<_, vft::io::RevokeMinterRole>::new(self.remoting.clone(), from) - } - fn approve( - &mut self, - spender: ActorId, - value: U256, - ) -> impl Call { - RemotingAction::<_, vft::io::Approve>::new(self.remoting.clone(), (spender, value)) - } - fn transfer(&mut self, to: ActorId, value: U256) -> impl Call { - RemotingAction::<_, vft::io::Transfer>::new(self.remoting.clone(), (to, value)) - } - fn transfer_from( - &mut self, - from: ActorId, - to: ActorId, - value: U256, - ) -> impl Call { - RemotingAction::<_, vft::io::TransferFrom>::new(self.remoting.clone(), (from, to, value)) - } - fn admins(&self) -> impl Query, Args = R::Args> { - RemotingAction::<_, vft::io::Admins>::new(self.remoting.clone(), ()) - } - fn burners(&self) -> impl Query, Args = R::Args> { - RemotingAction::<_, vft::io::Burners>::new(self.remoting.clone(), ()) - } - fn minters(&self) -> impl Query, Args = R::Args> { - RemotingAction::<_, vft::io::Minters>::new(self.remoting.clone(), ()) - } - fn allowance( - &self, - owner: ActorId, - spender: ActorId, - ) -> impl Query { - RemotingAction::<_, vft::io::Allowance>::new(self.remoting.clone(), (owner, spender)) - } - fn balance_of(&self, account: ActorId) -> impl Query { - RemotingAction::<_, vft::io::BalanceOf>::new(self.remoting.clone(), account) - } - fn decimals(&self) -> impl Query { - RemotingAction::<_, vft::io::Decimals>::new(self.remoting.clone(), ()) - } - fn name(&self) -> impl Query { - RemotingAction::<_, vft::io::Name>::new(self.remoting.clone(), ()) - } - fn symbol(&self) -> impl Query { - RemotingAction::<_, vft::io::Symbol>::new(self.remoting.clone(), ()) - } - fn total_supply(&self) -> impl Query { - RemotingAction::<_, vft::io::TotalSupply>::new(self.remoting.clone(), ()) - } -} - -pub mod vft { - use super::*; - - pub mod io { - use super::*; - use sails_rs::calls::ActionIo; - pub struct Burn(()); - impl Burn { - #[allow(dead_code)] - pub fn encode_call(from: ActorId, value: U256) -> Vec { - ::encode_call(&(from, value)) - } - } - impl ActionIo for Burn { - const ROUTE: &'static [u8] = &[12, 86, 102, 116, 16, 66, 117, 114, 110]; - type Params = (ActorId, U256); - type Reply = bool; - } - pub struct GrantAdminRole(()); - impl GrantAdminRole { - #[allow(dead_code)] - pub fn encode_call(to: ActorId) -> Vec { - ::encode_call(&to) - } - } - impl ActionIo for GrantAdminRole { - const ROUTE: &'static [u8] = &[ - 12, 86, 102, 116, 56, 71, 114, 97, 110, 116, 65, 100, 109, 105, 110, 82, 111, 108, - 101, - ]; - type Params = ActorId; - type Reply = (); - } - pub struct GrantBurnerRole(()); - impl GrantBurnerRole { - #[allow(dead_code)] - pub fn encode_call(to: ActorId) -> Vec { - ::encode_call(&to) - } - } - impl ActionIo for GrantBurnerRole { - const ROUTE: &'static [u8] = &[ - 12, 86, 102, 116, 60, 71, 114, 97, 110, 116, 66, 117, 114, 110, 101, 114, 82, 111, - 108, 101, - ]; - type Params = ActorId; - type Reply = (); - } - pub struct GrantMinterRole(()); - impl GrantMinterRole { - #[allow(dead_code)] - pub fn encode_call(to: ActorId) -> Vec { - ::encode_call(&to) - } - } - impl ActionIo for GrantMinterRole { - const ROUTE: &'static [u8] = &[ - 12, 86, 102, 116, 60, 71, 114, 97, 110, 116, 77, 105, 110, 116, 101, 114, 82, 111, - 108, 101, - ]; - type Params = ActorId; - type Reply = (); - } - pub struct Mint(()); - impl Mint { - #[allow(dead_code)] - pub fn encode_call(to: ActorId, value: U256) -> Vec { - ::encode_call(&(to, value)) - } - } - impl ActionIo for Mint { - const ROUTE: &'static [u8] = &[12, 86, 102, 116, 16, 77, 105, 110, 116]; - type Params = (ActorId, U256); - type Reply = bool; - } - pub struct RevokeAdminRole(()); - impl RevokeAdminRole { - #[allow(dead_code)] - pub fn encode_call(from: ActorId) -> Vec { - ::encode_call(&from) - } - } - impl ActionIo for RevokeAdminRole { - const ROUTE: &'static [u8] = &[ - 12, 86, 102, 116, 60, 82, 101, 118, 111, 107, 101, 65, 100, 109, 105, 110, 82, 111, - 108, 101, - ]; - type Params = ActorId; - type Reply = (); - } - pub struct RevokeBurnerRole(()); - impl RevokeBurnerRole { - #[allow(dead_code)] - pub fn encode_call(from: ActorId) -> Vec { - ::encode_call(&from) - } - } - impl ActionIo for RevokeBurnerRole { - const ROUTE: &'static [u8] = &[ - 12, 86, 102, 116, 64, 82, 101, 118, 111, 107, 101, 66, 117, 114, 110, 101, 114, 82, - 111, 108, 101, - ]; - type Params = ActorId; - type Reply = (); - } - pub struct RevokeMinterRole(()); - impl RevokeMinterRole { - #[allow(dead_code)] - pub fn encode_call(from: ActorId) -> Vec { - ::encode_call(&from) - } - } - impl ActionIo for RevokeMinterRole { - const ROUTE: &'static [u8] = &[ - 12, 86, 102, 116, 64, 82, 101, 118, 111, 107, 101, 77, 105, 110, 116, 101, 114, 82, - 111, 108, 101, - ]; - type Params = ActorId; - type Reply = (); - } - pub struct Approve(()); - impl Approve { - #[allow(dead_code)] - pub fn encode_call(spender: ActorId, value: U256) -> Vec { - ::encode_call(&(spender, value)) - } - } - impl ActionIo for Approve { - const ROUTE: &'static [u8] = &[12, 86, 102, 116, 28, 65, 112, 112, 114, 111, 118, 101]; - type Params = (ActorId, U256); - type Reply = bool; - } - pub struct Transfer(()); - impl Transfer { - #[allow(dead_code)] - pub fn encode_call(to: ActorId, value: U256) -> Vec { - ::encode_call(&(to, value)) - } - } - impl ActionIo for Transfer { - const ROUTE: &'static [u8] = - &[12, 86, 102, 116, 32, 84, 114, 97, 110, 115, 102, 101, 114]; - type Params = (ActorId, U256); - type Reply = bool; - } - pub struct TransferFrom(()); - impl TransferFrom { - #[allow(dead_code)] - pub fn encode_call(from: ActorId, to: ActorId, value: U256) -> Vec { - ::encode_call(&(from, to, value)) - } - } - impl ActionIo for TransferFrom { - const ROUTE: &'static [u8] = &[ - 12, 86, 102, 116, 48, 84, 114, 97, 110, 115, 102, 101, 114, 70, 114, 111, 109, - ]; - type Params = (ActorId, ActorId, U256); - type Reply = bool; - } - pub struct Admins(()); - impl Admins { - #[allow(dead_code)] - pub fn encode_call() -> Vec { - ::encode_call(&()) - } - } - impl ActionIo for Admins { - const ROUTE: &'static [u8] = &[12, 86, 102, 116, 24, 65, 100, 109, 105, 110, 115]; - type Params = (); - type Reply = Vec; - } - pub struct Burners(()); - impl Burners { - #[allow(dead_code)] - pub fn encode_call() -> Vec { - ::encode_call(&()) - } - } - impl ActionIo for Burners { - const ROUTE: &'static [u8] = &[12, 86, 102, 116, 28, 66, 117, 114, 110, 101, 114, 115]; - type Params = (); - type Reply = Vec; - } - pub struct Minters(()); - impl Minters { - #[allow(dead_code)] - pub fn encode_call() -> Vec { - ::encode_call(&()) - } - } - impl ActionIo for Minters { - const ROUTE: &'static [u8] = &[12, 86, 102, 116, 28, 77, 105, 110, 116, 101, 114, 115]; - type Params = (); - type Reply = Vec; - } - pub struct Allowance(()); - impl Allowance { - #[allow(dead_code)] - pub fn encode_call(owner: ActorId, spender: ActorId) -> Vec { - ::encode_call(&(owner, spender)) - } - } - impl ActionIo for Allowance { - const ROUTE: &'static [u8] = &[ - 12, 86, 102, 116, 36, 65, 108, 108, 111, 119, 97, 110, 99, 101, - ]; - type Params = (ActorId, ActorId); - type Reply = U256; - } - pub struct BalanceOf(()); - impl BalanceOf { - #[allow(dead_code)] - pub fn encode_call(account: ActorId) -> Vec { - ::encode_call(&account) - } - } - impl ActionIo for BalanceOf { - const ROUTE: &'static [u8] = - &[12, 86, 102, 116, 36, 66, 97, 108, 97, 110, 99, 101, 79, 102]; - type Params = ActorId; - type Reply = U256; - } - pub struct Decimals(()); - impl Decimals { - #[allow(dead_code)] - pub fn encode_call() -> Vec { - ::encode_call(&()) - } - } - impl ActionIo for Decimals { - const ROUTE: &'static [u8] = - &[12, 86, 102, 116, 32, 68, 101, 99, 105, 109, 97, 108, 115]; - type Params = (); - type Reply = u8; - } - pub struct Name(()); - impl Name { - #[allow(dead_code)] - pub fn encode_call() -> Vec { - ::encode_call(&()) - } - } - impl ActionIo for Name { - const ROUTE: &'static [u8] = &[12, 86, 102, 116, 16, 78, 97, 109, 101]; - type Params = (); - type Reply = String; - } - pub struct Symbol(()); - impl Symbol { - #[allow(dead_code)] - pub fn encode_call() -> Vec { - ::encode_call(&()) - } - } - impl ActionIo for Symbol { - const ROUTE: &'static [u8] = &[12, 86, 102, 116, 24, 83, 121, 109, 98, 111, 108]; - type Params = (); - type Reply = String; - } - pub struct TotalSupply(()); - impl TotalSupply { - #[allow(dead_code)] - pub fn encode_call() -> Vec { - ::encode_call(&()) - } - } - impl ActionIo for TotalSupply { - const ROUTE: &'static [u8] = &[ - 12, 86, 102, 116, 44, 84, 111, 116, 97, 108, 83, 117, 112, 112, 108, 121, - ]; - type Params = (); - type Reply = U256; - } - } - - #[allow(dead_code)] - #[cfg(not(target_arch = "wasm32"))] - pub mod events { - use super::*; - use sails_rs::events::*; - #[derive(PartialEq, Debug, Encode, Decode)] - #[codec(crate = sails_rs::scale_codec)] - pub enum VftEvents { - Minted { - to: ActorId, - value: U256, - }, - Burned { - from: ActorId, - value: U256, - }, - Approval { - owner: ActorId, - spender: ActorId, - value: U256, - }, - Transfer { - from: ActorId, - to: ActorId, - value: U256, - }, - } - impl EventIo for VftEvents { - const ROUTE: &'static [u8] = &[12, 86, 102, 116]; - const EVENT_NAMES: &'static [&'static [u8]] = &[ - &[24, 77, 105, 110, 116, 101, 100], - &[24, 66, 117, 114, 110, 101, 100], - &[32, 65, 112, 112, 114, 111, 118, 97, 108], - &[32, 84, 114, 97, 110, 115, 102, 101, 114], - ]; - type Event = Self; - } - pub fn listener>>(remoting: R) -> impl Listener { - RemotingListener::<_, VftEvents>::new(remoting) - } - } -} - -pub mod traits { - use super::*; - #[allow(dead_code)] - pub trait ExtendedVftFactory { - type Args; - #[allow(clippy::new_ret_no_self)] - #[allow(clippy::wrong_self_convention)] - fn new( - &self, - name: String, - symbol: String, - decimals: u8, - ) -> impl Activation; - } - - #[allow(clippy::type_complexity)] - pub trait Vft { - type Args; - fn burn( - &mut self, - from: ActorId, - value: U256, - ) -> impl Call; - fn grant_admin_role(&mut self, to: ActorId) -> impl Call; - fn grant_burner_role(&mut self, to: ActorId) -> impl Call; - fn grant_minter_role(&mut self, to: ActorId) -> impl Call; - fn mint(&mut self, to: ActorId, value: U256) - -> impl Call; - fn revoke_admin_role(&mut self, from: ActorId) - -> impl Call; - fn revoke_burner_role( - &mut self, - from: ActorId, - ) -> impl Call; - fn revoke_minter_role( - &mut self, - from: ActorId, - ) -> impl Call; - fn approve( - &mut self, - spender: ActorId, - value: U256, - ) -> impl Call; - fn transfer( - &mut self, - to: ActorId, - value: U256, - ) -> impl Call; - fn transfer_from( - &mut self, - from: ActorId, - to: ActorId, - value: U256, - ) -> impl Call; - fn admins(&self) -> impl Query, Args = Self::Args>; - fn burners(&self) -> impl Query, Args = Self::Args>; - fn minters(&self) -> impl Query, Args = Self::Args>; - fn allowance( - &self, - owner: ActorId, - spender: ActorId, - ) -> impl Query; - fn balance_of(&self, account: ActorId) -> impl Query; - fn decimals(&self) -> impl Query; - fn name(&self) -> impl Query; - fn symbol(&self) -> impl Query; - fn total_supply(&self) -> impl Query; - } -} diff --git a/extended-vmt/build.rs b/extended-vmt/build.rs deleted file mode 100644 index b64d3e9..0000000 --- a/extended-vmt/build.rs +++ /dev/null @@ -1,61 +0,0 @@ -use sails_client_gen::ClientGenerator; -use std::{ - env, - fs, - path::PathBuf, -}; - -fn main() { - // Build contract to get .opt.wasm - sails_rs::build_wasm(); - - // if the env var exists, it will not generate the contract idl and client - if env::var("__GEAR_WASM_BUILDER_NO_BUILD").is_ok() { - return; - } - - // Path where the file "Cargo.toml" is located (points to the root of the project) - // 'CARGO_MANIFEST_DIR' specifies this directory in en::var - let cargo_toml_path = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); - - // Path where the client and idl files will be generated - // 'OUT_DIR' points to a temporary directory used by the compiler - // to store files generated at compile time. - let outdir_path = PathBuf::from(env::var("OUT_DIR").unwrap()); - - // Path where the file "extended_vmt.idl" and "extended_vmt_client.rs" - // files will be created - let outdir_idl_path = outdir_path.clone().join("extended_vmt.idl"); - let outdir_client_path = outdir_path.clone().join("extended_vmt_client.rs"); - - // Path where the "idl_and_client" directory will be created, it will stores the idl and - // client from contract - let idl_and_client_dir_path = cargo_toml_path.clone().join("idl_and_client"); - - // This generate the contract IDL - sails_idl_gen::generate_idl_to_file::(outdir_idl_path.clone()) - .unwrap(); - - // Generator of the clients of the contract - ClientGenerator::from_idl_path(&outdir_idl_path) - .generate_to(outdir_client_path.clone()) - .unwrap(); - - // if directory already exists, it will remove it, to avoid errors - if idl_and_client_dir_path.exists() { - match fs::remove_dir_all(idl_and_client_dir_path.clone()) { - Ok(_) => {}, - Err(e) => println!("Error: {:?}", e), - } - } - - // create the "idl_and_client" directory to store the contract idl and client - let _ = fs::create_dir(idl_and_client_dir_path.clone()); - - // Then, copies the client and idl that is in the OUT_DIR path in the "idl_and_client" directory - fs::copy(outdir_client_path, idl_and_client_dir_path.clone().join("extended_vmt_client.rs")) - .unwrap(); - - fs::copy(outdir_idl_path, idl_and_client_dir_path.join("extended_vmt.idl")) - .unwrap(); -} diff --git a/extended-vmt/client/build.rs b/extended-vmt/client/build.rs deleted file mode 100644 index 6954f36..0000000 --- a/extended-vmt/client/build.rs +++ /dev/null @@ -1,17 +0,0 @@ -use sails_client_gen::ClientGenerator; -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("extended_vmt.idl"); - - // Generate IDL file for the program - sails_idl_gen::generate_idl_to_file::(&idl_file_path) - .unwrap(); - - // Generate client code from IDL file - ClientGenerator::from_idl_path(&idl_file_path) - .with_mocks("mocks") - .generate_to(PathBuf::from(env::var("OUT_DIR").unwrap()).join("extended_vmt_client.rs")) - .unwrap(); -} diff --git a/extended-vmt/client/src/lib.rs b/extended-vmt/client/src/lib.rs index a8a634e..3b55c34 100644 --- a/extended-vmt/client/src/lib.rs +++ b/extended-vmt/client/src/lib.rs @@ -1,4 +1,688 @@ #![no_std] -// Incorporate code generated based on the IDL file -include!(concat!(env!("OUT_DIR"), "/extended_vmt_client.rs")); +// Code generated by sails-client-gen. DO NOT EDIT. +#[allow(unused_imports)] +use sails_rs::collections::BTreeMap; +#[allow(unused_imports)] +use sails_rs::{ + calls::{Activation, Call, Query, Remoting, RemotingAction}, + prelude::*, + String, +}; +pub struct ExtendedVmtFactory { + #[allow(dead_code)] + remoting: R, +} +impl ExtendedVmtFactory { + #[allow(unused)] + pub fn new(remoting: R) -> Self { + Self { remoting } + } +} +impl traits::ExtendedVmtFactory for ExtendedVmtFactory { + type Args = R::Args; + fn new(&self, name: String, symbol: String, decimals: u8) -> impl Activation { + RemotingAction::<_, extended_vmt_factory::io::New>::new( + self.remoting.clone(), + (name, symbol, decimals), + ) + } +} + +pub mod extended_vmt_factory { + use super::*; + pub mod io { + use super::*; + use sails_rs::calls::ActionIo; + pub struct New(()); + impl New { + #[allow(dead_code)] + pub fn encode_call(name: String, symbol: String, decimals: u8) -> Vec { + ::encode_call(&(name, symbol, decimals)) + } + } + impl ActionIo for New { + const ROUTE: &'static [u8] = &[12, 78, 101, 119]; + type Params = (String, String, u8); + type Reply = (); + } + } +} +pub struct Vmt { + remoting: R, +} +impl Vmt { + pub fn new(remoting: R) -> Self { + Self { remoting } + } +} +impl traits::Vmt for Vmt { + type Args = R::Args; + fn burn( + &mut self, + from: ActorId, + id: U256, + amount: U256, + ) -> impl Call { + RemotingAction::<_, vmt::io::Burn>::new(self.remoting.clone(), (from, id, amount)) + } + fn burn_batch( + &mut self, + from: ActorId, + ids: Vec, + amounts: Vec, + ) -> impl Call { + RemotingAction::<_, vmt::io::BurnBatch>::new(self.remoting.clone(), (from, ids, amounts)) + } + fn grant_admin_role(&mut self, to: ActorId) -> impl Call { + RemotingAction::<_, vmt::io::GrantAdminRole>::new(self.remoting.clone(), to) + } + fn grant_burner_role(&mut self, to: ActorId) -> impl Call { + RemotingAction::<_, vmt::io::GrantBurnerRole>::new(self.remoting.clone(), to) + } + fn grant_minter_role(&mut self, to: ActorId) -> impl Call { + RemotingAction::<_, vmt::io::GrantMinterRole>::new(self.remoting.clone(), to) + } + fn mint( + &mut self, + to: ActorId, + id: U256, + amount: U256, + token_metadata: Option, + ) -> impl Call { + RemotingAction::<_, vmt::io::Mint>::new( + self.remoting.clone(), + (to, id, amount, token_metadata), + ) + } + fn mint_batch( + &mut self, + to: ActorId, + ids: Vec, + amounts: Vec, + token_metadata: Vec>, + ) -> impl Call { + RemotingAction::<_, vmt::io::MintBatch>::new( + self.remoting.clone(), + (to, ids, amounts, token_metadata), + ) + } + fn revoke_admin_role(&mut self, from: ActorId) -> impl Call { + RemotingAction::<_, vmt::io::RevokeAdminRole>::new(self.remoting.clone(), from) + } + fn revoke_burner_role(&mut self, from: ActorId) -> impl Call { + RemotingAction::<_, vmt::io::RevokeBurnerRole>::new(self.remoting.clone(), from) + } + fn revoke_minter_role(&mut self, from: ActorId) -> impl Call { + RemotingAction::<_, vmt::io::RevokeMinterRole>::new(self.remoting.clone(), from) + } + /// Approves an `ActorId` (account) to transfer tokens on behalf of the owner (sender). + /// If the approval is successful, it emits an `Approval` event. + fn approve(&mut self, to: ActorId) -> impl Call { + RemotingAction::<_, vmt::io::Approve>::new(self.remoting.clone(), to) + } + /// Transfers multiple tokens in batch from one account (`from`) to another (`to`). + /// This method transfers multiple token IDs and amounts simultaneously. + fn batch_transfer_from( + &mut self, + from: ActorId, + to: ActorId, + ids: Vec, + amounts: Vec, + ) -> impl Call { + RemotingAction::<_, vmt::io::BatchTransferFrom>::new( + self.remoting.clone(), + (from, to, ids, amounts), + ) + } + /// Transfers tokens from one account (`from`) to another (`to`) if the sender is allowed. + /// Emits a `Transfer` event after a successful transfer. + fn transfer_from( + &mut self, + from: ActorId, + to: ActorId, + id: U256, + amount: U256, + ) -> impl Call { + RemotingAction::<_, vmt::io::TransferFrom>::new( + self.remoting.clone(), + (from, to, id, amount), + ) + } + fn admins(&self) -> impl Query, Args = R::Args> { + RemotingAction::<_, vmt::io::Admins>::new(self.remoting.clone(), ()) + } + fn burners(&self) -> impl Query, Args = R::Args> { + RemotingAction::<_, vmt::io::Burners>::new(self.remoting.clone(), ()) + } + fn minters(&self) -> impl Query, Args = R::Args> { + RemotingAction::<_, vmt::io::Minters>::new(self.remoting.clone(), ()) + } + /// Returns the token balance of an account (`account`) for a specific token ID (`id`). + fn balance_of(&self, account: ActorId, id: U256) -> impl Query { + RemotingAction::<_, vmt::io::BalanceOf>::new(self.remoting.clone(), (account, id)) + } + /// Returns token account balances (`accounts`) for specific token identifiers (`ids`). + fn balance_of_batch( + &self, + accounts: Vec, + ids: Vec, + ) -> impl Query, Args = R::Args> { + RemotingAction::<_, vmt::io::BalanceOfBatch>::new(self.remoting.clone(), (accounts, ids)) + } + /// Returns the number of decimal places used for this token. + fn decimals(&self) -> impl Query { + RemotingAction::<_, vmt::io::Decimals>::new(self.remoting.clone(), ()) + } + /// Checks if a specific operator (`operator`) is approved to transfer tokens on behalf of `account`. + /// Returns true if the operator is approved. + fn is_approved( + &self, + account: ActorId, + operator: ActorId, + ) -> impl Query { + RemotingAction::<_, vmt::io::IsApproved>::new(self.remoting.clone(), (account, operator)) + } + /// Returns the name of the token. + fn name(&self) -> impl Query { + RemotingAction::<_, vmt::io::Name>::new(self.remoting.clone(), ()) + } + /// Returns the symbol of the token. + fn symbol(&self) -> impl Query { + RemotingAction::<_, vmt::io::Symbol>::new(self.remoting.clone(), ()) + } + /// Returns the total supply of tokens in circulation. + fn total_supply(&self) -> impl Query, Args = R::Args> { + RemotingAction::<_, vmt::io::TotalSupply>::new(self.remoting.clone(), ()) + } +} + +pub mod vmt { + use super::*; + + pub mod io { + use super::*; + use sails_rs::calls::ActionIo; + pub struct Burn(()); + impl Burn { + #[allow(dead_code)] + pub fn encode_call(from: ActorId, id: U256, amount: U256) -> Vec { + ::encode_call(&(from, id, amount)) + } + } + impl ActionIo for Burn { + const ROUTE: &'static [u8] = &[12, 86, 109, 116, 16, 66, 117, 114, 110]; + type Params = (ActorId, U256, U256); + type Reply = (); + } + pub struct BurnBatch(()); + impl BurnBatch { + #[allow(dead_code)] + pub fn encode_call(from: ActorId, ids: Vec, amounts: Vec) -> Vec { + ::encode_call(&(from, ids, amounts)) + } + } + impl ActionIo for BurnBatch { + const ROUTE: &'static [u8] = &[ + 12, 86, 109, 116, 36, 66, 117, 114, 110, 66, 97, 116, 99, 104, + ]; + type Params = (ActorId, Vec, Vec); + type Reply = (); + } + pub struct GrantAdminRole(()); + impl GrantAdminRole { + #[allow(dead_code)] + pub fn encode_call(to: ActorId) -> Vec { + ::encode_call(&to) + } + } + impl ActionIo for GrantAdminRole { + const ROUTE: &'static [u8] = &[ + 12, 86, 109, 116, 56, 71, 114, 97, 110, 116, 65, 100, 109, 105, 110, 82, 111, 108, + 101, + ]; + type Params = ActorId; + type Reply = (); + } + pub struct GrantBurnerRole(()); + impl GrantBurnerRole { + #[allow(dead_code)] + pub fn encode_call(to: ActorId) -> Vec { + ::encode_call(&to) + } + } + impl ActionIo for GrantBurnerRole { + const ROUTE: &'static [u8] = &[ + 12, 86, 109, 116, 60, 71, 114, 97, 110, 116, 66, 117, 114, 110, 101, 114, 82, 111, + 108, 101, + ]; + type Params = ActorId; + type Reply = (); + } + pub struct GrantMinterRole(()); + impl GrantMinterRole { + #[allow(dead_code)] + pub fn encode_call(to: ActorId) -> Vec { + ::encode_call(&to) + } + } + impl ActionIo for GrantMinterRole { + const ROUTE: &'static [u8] = &[ + 12, 86, 109, 116, 60, 71, 114, 97, 110, 116, 77, 105, 110, 116, 101, 114, 82, 111, + 108, 101, + ]; + type Params = ActorId; + type Reply = (); + } + pub struct Mint(()); + impl Mint { + #[allow(dead_code)] + pub fn encode_call( + to: ActorId, + id: U256, + amount: U256, + token_metadata: Option, + ) -> Vec { + ::encode_call(&(to, id, amount, token_metadata)) + } + } + impl ActionIo for Mint { + const ROUTE: &'static [u8] = &[12, 86, 109, 116, 16, 77, 105, 110, 116]; + type Params = (ActorId, U256, U256, Option); + type Reply = (); + } + pub struct MintBatch(()); + impl MintBatch { + #[allow(dead_code)] + pub fn encode_call( + to: ActorId, + ids: Vec, + amounts: Vec, + token_metadata: Vec>, + ) -> Vec { + ::encode_call(&(to, ids, amounts, token_metadata)) + } + } + impl ActionIo for MintBatch { + const ROUTE: &'static [u8] = &[ + 12, 86, 109, 116, 36, 77, 105, 110, 116, 66, 97, 116, 99, 104, + ]; + type Params = ( + ActorId, + Vec, + Vec, + Vec>, + ); + type Reply = (); + } + pub struct RevokeAdminRole(()); + impl RevokeAdminRole { + #[allow(dead_code)] + pub fn encode_call(from: ActorId) -> Vec { + ::encode_call(&from) + } + } + impl ActionIo for RevokeAdminRole { + const ROUTE: &'static [u8] = &[ + 12, 86, 109, 116, 60, 82, 101, 118, 111, 107, 101, 65, 100, 109, 105, 110, 82, 111, + 108, 101, + ]; + type Params = ActorId; + type Reply = (); + } + pub struct RevokeBurnerRole(()); + impl RevokeBurnerRole { + #[allow(dead_code)] + pub fn encode_call(from: ActorId) -> Vec { + ::encode_call(&from) + } + } + impl ActionIo for RevokeBurnerRole { + const ROUTE: &'static [u8] = &[ + 12, 86, 109, 116, 64, 82, 101, 118, 111, 107, 101, 66, 117, 114, 110, 101, 114, 82, + 111, 108, 101, + ]; + type Params = ActorId; + type Reply = (); + } + pub struct RevokeMinterRole(()); + impl RevokeMinterRole { + #[allow(dead_code)] + pub fn encode_call(from: ActorId) -> Vec { + ::encode_call(&from) + } + } + impl ActionIo for RevokeMinterRole { + const ROUTE: &'static [u8] = &[ + 12, 86, 109, 116, 64, 82, 101, 118, 111, 107, 101, 77, 105, 110, 116, 101, 114, 82, + 111, 108, 101, + ]; + type Params = ActorId; + type Reply = (); + } + pub struct Approve(()); + impl Approve { + #[allow(dead_code)] + pub fn encode_call(to: ActorId) -> Vec { + ::encode_call(&to) + } + } + impl ActionIo for Approve { + const ROUTE: &'static [u8] = &[12, 86, 109, 116, 28, 65, 112, 112, 114, 111, 118, 101]; + type Params = ActorId; + type Reply = bool; + } + pub struct BatchTransferFrom(()); + impl BatchTransferFrom { + #[allow(dead_code)] + pub fn encode_call( + from: ActorId, + to: ActorId, + ids: Vec, + amounts: Vec, + ) -> Vec { + ::encode_call(&(from, to, ids, amounts)) + } + } + impl ActionIo for BatchTransferFrom { + const ROUTE: &'static [u8] = &[ + 12, 86, 109, 116, 68, 66, 97, 116, 99, 104, 84, 114, 97, 110, 115, 102, 101, 114, + 70, 114, 111, 109, + ]; + type Params = (ActorId, ActorId, Vec, Vec); + type Reply = (); + } + pub struct TransferFrom(()); + impl TransferFrom { + #[allow(dead_code)] + pub fn encode_call(from: ActorId, to: ActorId, id: U256, amount: U256) -> Vec { + ::encode_call(&(from, to, id, amount)) + } + } + impl ActionIo for TransferFrom { + const ROUTE: &'static [u8] = &[ + 12, 86, 109, 116, 48, 84, 114, 97, 110, 115, 102, 101, 114, 70, 114, 111, 109, + ]; + type Params = (ActorId, ActorId, U256, U256); + type Reply = (); + } + pub struct Admins(()); + impl Admins { + #[allow(dead_code)] + pub fn encode_call() -> Vec { + ::encode_call(&()) + } + } + impl ActionIo for Admins { + const ROUTE: &'static [u8] = &[12, 86, 109, 116, 24, 65, 100, 109, 105, 110, 115]; + type Params = (); + type Reply = Vec; + } + pub struct Burners(()); + impl Burners { + #[allow(dead_code)] + pub fn encode_call() -> Vec { + ::encode_call(&()) + } + } + impl ActionIo for Burners { + const ROUTE: &'static [u8] = &[12, 86, 109, 116, 28, 66, 117, 114, 110, 101, 114, 115]; + type Params = (); + type Reply = Vec; + } + pub struct Minters(()); + impl Minters { + #[allow(dead_code)] + pub fn encode_call() -> Vec { + ::encode_call(&()) + } + } + impl ActionIo for Minters { + const ROUTE: &'static [u8] = &[12, 86, 109, 116, 28, 77, 105, 110, 116, 101, 114, 115]; + type Params = (); + type Reply = Vec; + } + pub struct BalanceOf(()); + impl BalanceOf { + #[allow(dead_code)] + pub fn encode_call(account: ActorId, id: U256) -> Vec { + ::encode_call(&(account, id)) + } + } + impl ActionIo for BalanceOf { + const ROUTE: &'static [u8] = + &[12, 86, 109, 116, 36, 66, 97, 108, 97, 110, 99, 101, 79, 102]; + type Params = (ActorId, U256); + type Reply = U256; + } + pub struct BalanceOfBatch(()); + impl BalanceOfBatch { + #[allow(dead_code)] + pub fn encode_call(accounts: Vec, ids: Vec) -> Vec { + ::encode_call(&(accounts, ids)) + } + } + impl ActionIo for BalanceOfBatch { + const ROUTE: &'static [u8] = &[ + 12, 86, 109, 116, 56, 66, 97, 108, 97, 110, 99, 101, 79, 102, 66, 97, 116, 99, 104, + ]; + type Params = (Vec, Vec); + type Reply = Vec; + } + pub struct Decimals(()); + impl Decimals { + #[allow(dead_code)] + pub fn encode_call() -> Vec { + ::encode_call(&()) + } + } + impl ActionIo for Decimals { + const ROUTE: &'static [u8] = + &[12, 86, 109, 116, 32, 68, 101, 99, 105, 109, 97, 108, 115]; + type Params = (); + type Reply = u8; + } + pub struct IsApproved(()); + impl IsApproved { + #[allow(dead_code)] + pub fn encode_call(account: ActorId, operator: ActorId) -> Vec { + ::encode_call(&(account, operator)) + } + } + impl ActionIo for IsApproved { + const ROUTE: &'static [u8] = &[ + 12, 86, 109, 116, 40, 73, 115, 65, 112, 112, 114, 111, 118, 101, 100, + ]; + type Params = (ActorId, ActorId); + type Reply = bool; + } + pub struct Name(()); + impl Name { + #[allow(dead_code)] + pub fn encode_call() -> Vec { + ::encode_call(&()) + } + } + impl ActionIo for Name { + const ROUTE: &'static [u8] = &[12, 86, 109, 116, 16, 78, 97, 109, 101]; + type Params = (); + type Reply = String; + } + pub struct Symbol(()); + impl Symbol { + #[allow(dead_code)] + pub fn encode_call() -> Vec { + ::encode_call(&()) + } + } + impl ActionIo for Symbol { + const ROUTE: &'static [u8] = &[12, 86, 109, 116, 24, 83, 121, 109, 98, 111, 108]; + type Params = (); + type Reply = String; + } + pub struct TotalSupply(()); + impl TotalSupply { + #[allow(dead_code)] + pub fn encode_call() -> Vec { + ::encode_call(&()) + } + } + impl ActionIo for TotalSupply { + const ROUTE: &'static [u8] = &[ + 12, 86, 109, 116, 44, 84, 111, 116, 97, 108, 83, 117, 112, 112, 108, 121, + ]; + type Params = (); + type Reply = Vec<(U256, U256)>; + } + } + + #[allow(dead_code)] + #[cfg(not(target_arch = "wasm32"))] + pub mod events { + use super::*; + use sails_rs::events::*; + #[derive(PartialEq, Debug, Encode, Decode)] + #[codec(crate = sails_rs::scale_codec)] + pub enum VmtEvents { + Minted { + to: ActorId, + ids: Vec, + amounts: Vec, + }, + Burned { + from: ActorId, + ids: Vec, + amounts: Vec, + }, + Approval { + from: ActorId, + to: ActorId, + }, + Transfer { + from: ActorId, + to: ActorId, + ids: Vec, + amounts: Vec, + }, + } + impl EventIo for VmtEvents { + const ROUTE: &'static [u8] = &[12, 86, 109, 116]; + const EVENT_NAMES: &'static [&'static [u8]] = &[ + &[24, 77, 105, 110, 116, 101, 100], + &[24, 66, 117, 114, 110, 101, 100], + &[32, 65, 112, 112, 114, 111, 118, 97, 108], + &[32, 84, 114, 97, 110, 115, 102, 101, 114], + ]; + type Event = Self; + } + pub fn listener>>(remoting: R) -> impl Listener { + RemotingListener::<_, VmtEvents>::new(remoting) + } + } +} +#[derive(PartialEq, Clone, Debug, Encode, Decode, TypeInfo)] +#[codec(crate = sails_rs::scale_codec)] +#[scale_info(crate = sails_rs::scale_info)] +pub struct TokenMetadata { + pub title: Option, + pub description: Option, + pub media: Option, + pub reference: Option, +} + +pub mod traits { + use super::*; + #[allow(dead_code)] + pub trait ExtendedVmtFactory { + type Args; + #[allow(clippy::new_ret_no_self)] + #[allow(clippy::wrong_self_convention)] + fn new( + &self, + name: String, + symbol: String, + decimals: u8, + ) -> impl Activation; + } + + #[allow(clippy::type_complexity)] + pub trait Vmt { + type Args; + fn burn( + &mut self, + from: ActorId, + id: U256, + amount: U256, + ) -> impl Call; + fn burn_batch( + &mut self, + from: ActorId, + ids: Vec, + amounts: Vec, + ) -> impl Call; + fn grant_admin_role(&mut self, to: ActorId) -> impl Call; + fn grant_burner_role(&mut self, to: ActorId) -> impl Call; + fn grant_minter_role(&mut self, to: ActorId) -> impl Call; + fn mint( + &mut self, + to: ActorId, + id: U256, + amount: U256, + token_metadata: Option, + ) -> impl Call; + fn mint_batch( + &mut self, + to: ActorId, + ids: Vec, + amounts: Vec, + token_metadata: Vec>, + ) -> impl Call; + fn revoke_admin_role(&mut self, from: ActorId) + -> impl Call; + fn revoke_burner_role( + &mut self, + from: ActorId, + ) -> impl Call; + fn revoke_minter_role( + &mut self, + from: ActorId, + ) -> impl Call; + fn approve(&mut self, to: ActorId) -> impl Call; + fn batch_transfer_from( + &mut self, + from: ActorId, + to: ActorId, + ids: Vec, + amounts: Vec, + ) -> impl Call; + fn transfer_from( + &mut self, + from: ActorId, + to: ActorId, + id: U256, + amount: U256, + ) -> impl Call; + fn admins(&self) -> impl Query, Args = Self::Args>; + fn burners(&self) -> impl Query, Args = Self::Args>; + fn minters(&self) -> impl Query, Args = Self::Args>; + fn balance_of( + &self, + account: ActorId, + id: U256, + ) -> impl Query; + fn balance_of_batch( + &self, + accounts: Vec, + ids: Vec, + ) -> impl Query, Args = Self::Args>; + fn decimals(&self) -> impl Query; + fn is_approved( + &self, + account: ActorId, + operator: ActorId, + ) -> impl Query; + fn name(&self) -> impl Query; + fn symbol(&self) -> impl Query; + fn total_supply(&self) -> impl Query, Args = Self::Args>; + } +} diff --git a/extended-vmt/idl_and_client/extended_vmt.idl b/extended-vmt/extended_vmt.idl similarity index 100% rename from extended-vmt/idl_and_client/extended_vmt.idl rename to extended-vmt/extended_vmt.idl diff --git a/extended-vmt/idl_and_client/extended_vmt_client.rs b/extended-vmt/idl_and_client/extended_vmt_client.rs deleted file mode 100644 index fc24960..0000000 --- a/extended-vmt/idl_and_client/extended_vmt_client.rs +++ /dev/null @@ -1,686 +0,0 @@ -// Code generated by sails-client-gen. DO NOT EDIT. -#[allow(unused_imports)] -use sails_rs::collections::BTreeMap; -#[allow(unused_imports)] -use sails_rs::{ - calls::{Activation, Call, Query, Remoting, RemotingAction}, - prelude::*, - String, -}; -pub struct ExtendedVmtFactory { - #[allow(dead_code)] - remoting: R, -} -impl ExtendedVmtFactory { - #[allow(unused)] - pub fn new(remoting: R) -> Self { - Self { remoting } - } -} -impl traits::ExtendedVmtFactory for ExtendedVmtFactory { - type Args = R::Args; - fn new(&self, name: String, symbol: String, decimals: u8) -> impl Activation { - RemotingAction::<_, extended_vmt_factory::io::New>::new( - self.remoting.clone(), - (name, symbol, decimals), - ) - } -} - -pub mod extended_vmt_factory { - use super::*; - pub mod io { - use super::*; - use sails_rs::calls::ActionIo; - pub struct New(()); - impl New { - #[allow(dead_code)] - pub fn encode_call(name: String, symbol: String, decimals: u8) -> Vec { - ::encode_call(&(name, symbol, decimals)) - } - } - impl ActionIo for New { - const ROUTE: &'static [u8] = &[12, 78, 101, 119]; - type Params = (String, String, u8); - type Reply = (); - } - } -} -pub struct Vmt { - remoting: R, -} -impl Vmt { - pub fn new(remoting: R) -> Self { - Self { remoting } - } -} -impl traits::Vmt for Vmt { - type Args = R::Args; - fn burn( - &mut self, - from: ActorId, - id: U256, - amount: U256, - ) -> impl Call { - RemotingAction::<_, vmt::io::Burn>::new(self.remoting.clone(), (from, id, amount)) - } - fn burn_batch( - &mut self, - from: ActorId, - ids: Vec, - amounts: Vec, - ) -> impl Call { - RemotingAction::<_, vmt::io::BurnBatch>::new(self.remoting.clone(), (from, ids, amounts)) - } - fn grant_admin_role(&mut self, to: ActorId) -> impl Call { - RemotingAction::<_, vmt::io::GrantAdminRole>::new(self.remoting.clone(), to) - } - fn grant_burner_role(&mut self, to: ActorId) -> impl Call { - RemotingAction::<_, vmt::io::GrantBurnerRole>::new(self.remoting.clone(), to) - } - fn grant_minter_role(&mut self, to: ActorId) -> impl Call { - RemotingAction::<_, vmt::io::GrantMinterRole>::new(self.remoting.clone(), to) - } - fn mint( - &mut self, - to: ActorId, - id: U256, - amount: U256, - token_metadata: Option, - ) -> impl Call { - RemotingAction::<_, vmt::io::Mint>::new( - self.remoting.clone(), - (to, id, amount, token_metadata), - ) - } - fn mint_batch( - &mut self, - to: ActorId, - ids: Vec, - amounts: Vec, - token_metadata: Vec>, - ) -> impl Call { - RemotingAction::<_, vmt::io::MintBatch>::new( - self.remoting.clone(), - (to, ids, amounts, token_metadata), - ) - } - fn revoke_admin_role(&mut self, from: ActorId) -> impl Call { - RemotingAction::<_, vmt::io::RevokeAdminRole>::new(self.remoting.clone(), from) - } - fn revoke_burner_role(&mut self, from: ActorId) -> impl Call { - RemotingAction::<_, vmt::io::RevokeBurnerRole>::new(self.remoting.clone(), from) - } - fn revoke_minter_role(&mut self, from: ActorId) -> impl Call { - RemotingAction::<_, vmt::io::RevokeMinterRole>::new(self.remoting.clone(), from) - } - /// Approves an `ActorId` (account) to transfer tokens on behalf of the owner (sender). - /// If the approval is successful, it emits an `Approval` event. - fn approve(&mut self, to: ActorId) -> impl Call { - RemotingAction::<_, vmt::io::Approve>::new(self.remoting.clone(), to) - } - /// Transfers multiple tokens in batch from one account (`from`) to another (`to`). - /// This method transfers multiple token IDs and amounts simultaneously. - fn batch_transfer_from( - &mut self, - from: ActorId, - to: ActorId, - ids: Vec, - amounts: Vec, - ) -> impl Call { - RemotingAction::<_, vmt::io::BatchTransferFrom>::new( - self.remoting.clone(), - (from, to, ids, amounts), - ) - } - /// Transfers tokens from one account (`from`) to another (`to`) if the sender is allowed. - /// Emits a `Transfer` event after a successful transfer. - fn transfer_from( - &mut self, - from: ActorId, - to: ActorId, - id: U256, - amount: U256, - ) -> impl Call { - RemotingAction::<_, vmt::io::TransferFrom>::new( - self.remoting.clone(), - (from, to, id, amount), - ) - } - fn admins(&self) -> impl Query, Args = R::Args> { - RemotingAction::<_, vmt::io::Admins>::new(self.remoting.clone(), ()) - } - fn burners(&self) -> impl Query, Args = R::Args> { - RemotingAction::<_, vmt::io::Burners>::new(self.remoting.clone(), ()) - } - fn minters(&self) -> impl Query, Args = R::Args> { - RemotingAction::<_, vmt::io::Minters>::new(self.remoting.clone(), ()) - } - /// Returns the token balance of an account (`account`) for a specific token ID (`id`). - fn balance_of(&self, account: ActorId, id: U256) -> impl Query { - RemotingAction::<_, vmt::io::BalanceOf>::new(self.remoting.clone(), (account, id)) - } - /// Returns token account balances (`accounts`) for specific token identifiers (`ids`). - fn balance_of_batch( - &self, - accounts: Vec, - ids: Vec, - ) -> impl Query, Args = R::Args> { - RemotingAction::<_, vmt::io::BalanceOfBatch>::new(self.remoting.clone(), (accounts, ids)) - } - /// Returns the number of decimal places used for this token. - fn decimals(&self) -> impl Query { - RemotingAction::<_, vmt::io::Decimals>::new(self.remoting.clone(), ()) - } - /// Checks if a specific operator (`operator`) is approved to transfer tokens on behalf of `account`. - /// Returns true if the operator is approved. - fn is_approved( - &self, - account: ActorId, - operator: ActorId, - ) -> impl Query { - RemotingAction::<_, vmt::io::IsApproved>::new(self.remoting.clone(), (account, operator)) - } - /// Returns the name of the token. - fn name(&self) -> impl Query { - RemotingAction::<_, vmt::io::Name>::new(self.remoting.clone(), ()) - } - /// Returns the symbol of the token. - fn symbol(&self) -> impl Query { - RemotingAction::<_, vmt::io::Symbol>::new(self.remoting.clone(), ()) - } - /// Returns the total supply of tokens in circulation. - fn total_supply(&self) -> impl Query, Args = R::Args> { - RemotingAction::<_, vmt::io::TotalSupply>::new(self.remoting.clone(), ()) - } -} - -pub mod vmt { - use super::*; - - pub mod io { - use super::*; - use sails_rs::calls::ActionIo; - pub struct Burn(()); - impl Burn { - #[allow(dead_code)] - pub fn encode_call(from: ActorId, id: U256, amount: U256) -> Vec { - ::encode_call(&(from, id, amount)) - } - } - impl ActionIo for Burn { - const ROUTE: &'static [u8] = &[12, 86, 109, 116, 16, 66, 117, 114, 110]; - type Params = (ActorId, U256, U256); - type Reply = (); - } - pub struct BurnBatch(()); - impl BurnBatch { - #[allow(dead_code)] - pub fn encode_call(from: ActorId, ids: Vec, amounts: Vec) -> Vec { - ::encode_call(&(from, ids, amounts)) - } - } - impl ActionIo for BurnBatch { - const ROUTE: &'static [u8] = &[ - 12, 86, 109, 116, 36, 66, 117, 114, 110, 66, 97, 116, 99, 104, - ]; - type Params = (ActorId, Vec, Vec); - type Reply = (); - } - pub struct GrantAdminRole(()); - impl GrantAdminRole { - #[allow(dead_code)] - pub fn encode_call(to: ActorId) -> Vec { - ::encode_call(&to) - } - } - impl ActionIo for GrantAdminRole { - const ROUTE: &'static [u8] = &[ - 12, 86, 109, 116, 56, 71, 114, 97, 110, 116, 65, 100, 109, 105, 110, 82, 111, 108, - 101, - ]; - type Params = ActorId; - type Reply = (); - } - pub struct GrantBurnerRole(()); - impl GrantBurnerRole { - #[allow(dead_code)] - pub fn encode_call(to: ActorId) -> Vec { - ::encode_call(&to) - } - } - impl ActionIo for GrantBurnerRole { - const ROUTE: &'static [u8] = &[ - 12, 86, 109, 116, 60, 71, 114, 97, 110, 116, 66, 117, 114, 110, 101, 114, 82, 111, - 108, 101, - ]; - type Params = ActorId; - type Reply = (); - } - pub struct GrantMinterRole(()); - impl GrantMinterRole { - #[allow(dead_code)] - pub fn encode_call(to: ActorId) -> Vec { - ::encode_call(&to) - } - } - impl ActionIo for GrantMinterRole { - const ROUTE: &'static [u8] = &[ - 12, 86, 109, 116, 60, 71, 114, 97, 110, 116, 77, 105, 110, 116, 101, 114, 82, 111, - 108, 101, - ]; - type Params = ActorId; - type Reply = (); - } - pub struct Mint(()); - impl Mint { - #[allow(dead_code)] - pub fn encode_call( - to: ActorId, - id: U256, - amount: U256, - token_metadata: Option, - ) -> Vec { - ::encode_call(&(to, id, amount, token_metadata)) - } - } - impl ActionIo for Mint { - const ROUTE: &'static [u8] = &[12, 86, 109, 116, 16, 77, 105, 110, 116]; - type Params = (ActorId, U256, U256, Option); - type Reply = (); - } - pub struct MintBatch(()); - impl MintBatch { - #[allow(dead_code)] - pub fn encode_call( - to: ActorId, - ids: Vec, - amounts: Vec, - token_metadata: Vec>, - ) -> Vec { - ::encode_call(&(to, ids, amounts, token_metadata)) - } - } - impl ActionIo for MintBatch { - const ROUTE: &'static [u8] = &[ - 12, 86, 109, 116, 36, 77, 105, 110, 116, 66, 97, 116, 99, 104, - ]; - type Params = ( - ActorId, - Vec, - Vec, - Vec>, - ); - type Reply = (); - } - pub struct RevokeAdminRole(()); - impl RevokeAdminRole { - #[allow(dead_code)] - pub fn encode_call(from: ActorId) -> Vec { - ::encode_call(&from) - } - } - impl ActionIo for RevokeAdminRole { - const ROUTE: &'static [u8] = &[ - 12, 86, 109, 116, 60, 82, 101, 118, 111, 107, 101, 65, 100, 109, 105, 110, 82, 111, - 108, 101, - ]; - type Params = ActorId; - type Reply = (); - } - pub struct RevokeBurnerRole(()); - impl RevokeBurnerRole { - #[allow(dead_code)] - pub fn encode_call(from: ActorId) -> Vec { - ::encode_call(&from) - } - } - impl ActionIo for RevokeBurnerRole { - const ROUTE: &'static [u8] = &[ - 12, 86, 109, 116, 64, 82, 101, 118, 111, 107, 101, 66, 117, 114, 110, 101, 114, 82, - 111, 108, 101, - ]; - type Params = ActorId; - type Reply = (); - } - pub struct RevokeMinterRole(()); - impl RevokeMinterRole { - #[allow(dead_code)] - pub fn encode_call(from: ActorId) -> Vec { - ::encode_call(&from) - } - } - impl ActionIo for RevokeMinterRole { - const ROUTE: &'static [u8] = &[ - 12, 86, 109, 116, 64, 82, 101, 118, 111, 107, 101, 77, 105, 110, 116, 101, 114, 82, - 111, 108, 101, - ]; - type Params = ActorId; - type Reply = (); - } - pub struct Approve(()); - impl Approve { - #[allow(dead_code)] - pub fn encode_call(to: ActorId) -> Vec { - ::encode_call(&to) - } - } - impl ActionIo for Approve { - const ROUTE: &'static [u8] = &[12, 86, 109, 116, 28, 65, 112, 112, 114, 111, 118, 101]; - type Params = ActorId; - type Reply = bool; - } - pub struct BatchTransferFrom(()); - impl BatchTransferFrom { - #[allow(dead_code)] - pub fn encode_call( - from: ActorId, - to: ActorId, - ids: Vec, - amounts: Vec, - ) -> Vec { - ::encode_call(&(from, to, ids, amounts)) - } - } - impl ActionIo for BatchTransferFrom { - const ROUTE: &'static [u8] = &[ - 12, 86, 109, 116, 68, 66, 97, 116, 99, 104, 84, 114, 97, 110, 115, 102, 101, 114, - 70, 114, 111, 109, - ]; - type Params = (ActorId, ActorId, Vec, Vec); - type Reply = (); - } - pub struct TransferFrom(()); - impl TransferFrom { - #[allow(dead_code)] - pub fn encode_call(from: ActorId, to: ActorId, id: U256, amount: U256) -> Vec { - ::encode_call(&(from, to, id, amount)) - } - } - impl ActionIo for TransferFrom { - const ROUTE: &'static [u8] = &[ - 12, 86, 109, 116, 48, 84, 114, 97, 110, 115, 102, 101, 114, 70, 114, 111, 109, - ]; - type Params = (ActorId, ActorId, U256, U256); - type Reply = (); - } - pub struct Admins(()); - impl Admins { - #[allow(dead_code)] - pub fn encode_call() -> Vec { - ::encode_call(&()) - } - } - impl ActionIo for Admins { - const ROUTE: &'static [u8] = &[12, 86, 109, 116, 24, 65, 100, 109, 105, 110, 115]; - type Params = (); - type Reply = Vec; - } - pub struct Burners(()); - impl Burners { - #[allow(dead_code)] - pub fn encode_call() -> Vec { - ::encode_call(&()) - } - } - impl ActionIo for Burners { - const ROUTE: &'static [u8] = &[12, 86, 109, 116, 28, 66, 117, 114, 110, 101, 114, 115]; - type Params = (); - type Reply = Vec; - } - pub struct Minters(()); - impl Minters { - #[allow(dead_code)] - pub fn encode_call() -> Vec { - ::encode_call(&()) - } - } - impl ActionIo for Minters { - const ROUTE: &'static [u8] = &[12, 86, 109, 116, 28, 77, 105, 110, 116, 101, 114, 115]; - type Params = (); - type Reply = Vec; - } - pub struct BalanceOf(()); - impl BalanceOf { - #[allow(dead_code)] - pub fn encode_call(account: ActorId, id: U256) -> Vec { - ::encode_call(&(account, id)) - } - } - impl ActionIo for BalanceOf { - const ROUTE: &'static [u8] = - &[12, 86, 109, 116, 36, 66, 97, 108, 97, 110, 99, 101, 79, 102]; - type Params = (ActorId, U256); - type Reply = U256; - } - pub struct BalanceOfBatch(()); - impl BalanceOfBatch { - #[allow(dead_code)] - pub fn encode_call(accounts: Vec, ids: Vec) -> Vec { - ::encode_call(&(accounts, ids)) - } - } - impl ActionIo for BalanceOfBatch { - const ROUTE: &'static [u8] = &[ - 12, 86, 109, 116, 56, 66, 97, 108, 97, 110, 99, 101, 79, 102, 66, 97, 116, 99, 104, - ]; - type Params = (Vec, Vec); - type Reply = Vec; - } - pub struct Decimals(()); - impl Decimals { - #[allow(dead_code)] - pub fn encode_call() -> Vec { - ::encode_call(&()) - } - } - impl ActionIo for Decimals { - const ROUTE: &'static [u8] = - &[12, 86, 109, 116, 32, 68, 101, 99, 105, 109, 97, 108, 115]; - type Params = (); - type Reply = u8; - } - pub struct IsApproved(()); - impl IsApproved { - #[allow(dead_code)] - pub fn encode_call(account: ActorId, operator: ActorId) -> Vec { - ::encode_call(&(account, operator)) - } - } - impl ActionIo for IsApproved { - const ROUTE: &'static [u8] = &[ - 12, 86, 109, 116, 40, 73, 115, 65, 112, 112, 114, 111, 118, 101, 100, - ]; - type Params = (ActorId, ActorId); - type Reply = bool; - } - pub struct Name(()); - impl Name { - #[allow(dead_code)] - pub fn encode_call() -> Vec { - ::encode_call(&()) - } - } - impl ActionIo for Name { - const ROUTE: &'static [u8] = &[12, 86, 109, 116, 16, 78, 97, 109, 101]; - type Params = (); - type Reply = String; - } - pub struct Symbol(()); - impl Symbol { - #[allow(dead_code)] - pub fn encode_call() -> Vec { - ::encode_call(&()) - } - } - impl ActionIo for Symbol { - const ROUTE: &'static [u8] = &[12, 86, 109, 116, 24, 83, 121, 109, 98, 111, 108]; - type Params = (); - type Reply = String; - } - pub struct TotalSupply(()); - impl TotalSupply { - #[allow(dead_code)] - pub fn encode_call() -> Vec { - ::encode_call(&()) - } - } - impl ActionIo for TotalSupply { - const ROUTE: &'static [u8] = &[ - 12, 86, 109, 116, 44, 84, 111, 116, 97, 108, 83, 117, 112, 112, 108, 121, - ]; - type Params = (); - type Reply = Vec<(U256, U256)>; - } - } - - #[allow(dead_code)] - #[cfg(not(target_arch = "wasm32"))] - pub mod events { - use super::*; - use sails_rs::events::*; - #[derive(PartialEq, Debug, Encode, Decode)] - #[codec(crate = sails_rs::scale_codec)] - pub enum VmtEvents { - Minted { - to: ActorId, - ids: Vec, - amounts: Vec, - }, - Burned { - from: ActorId, - ids: Vec, - amounts: Vec, - }, - Approval { - from: ActorId, - to: ActorId, - }, - Transfer { - from: ActorId, - to: ActorId, - ids: Vec, - amounts: Vec, - }, - } - impl EventIo for VmtEvents { - const ROUTE: &'static [u8] = &[12, 86, 109, 116]; - const EVENT_NAMES: &'static [&'static [u8]] = &[ - &[24, 77, 105, 110, 116, 101, 100], - &[24, 66, 117, 114, 110, 101, 100], - &[32, 65, 112, 112, 114, 111, 118, 97, 108], - &[32, 84, 114, 97, 110, 115, 102, 101, 114], - ]; - type Event = Self; - } - pub fn listener>>(remoting: R) -> impl Listener { - RemotingListener::<_, VmtEvents>::new(remoting) - } - } -} -#[derive(PartialEq, Clone, Debug, Encode, Decode, TypeInfo)] -#[codec(crate = sails_rs::scale_codec)] -#[scale_info(crate = sails_rs::scale_info)] -pub struct TokenMetadata { - pub title: Option, - pub description: Option, - pub media: Option, - pub reference: Option, -} - -pub mod traits { - use super::*; - #[allow(dead_code)] - pub trait ExtendedVmtFactory { - type Args; - #[allow(clippy::new_ret_no_self)] - #[allow(clippy::wrong_self_convention)] - fn new( - &self, - name: String, - symbol: String, - decimals: u8, - ) -> impl Activation; - } - - #[allow(clippy::type_complexity)] - pub trait Vmt { - type Args; - fn burn( - &mut self, - from: ActorId, - id: U256, - amount: U256, - ) -> impl Call; - fn burn_batch( - &mut self, - from: ActorId, - ids: Vec, - amounts: Vec, - ) -> impl Call; - fn grant_admin_role(&mut self, to: ActorId) -> impl Call; - fn grant_burner_role(&mut self, to: ActorId) -> impl Call; - fn grant_minter_role(&mut self, to: ActorId) -> impl Call; - fn mint( - &mut self, - to: ActorId, - id: U256, - amount: U256, - token_metadata: Option, - ) -> impl Call; - fn mint_batch( - &mut self, - to: ActorId, - ids: Vec, - amounts: Vec, - token_metadata: Vec>, - ) -> impl Call; - fn revoke_admin_role(&mut self, from: ActorId) - -> impl Call; - fn revoke_burner_role( - &mut self, - from: ActorId, - ) -> impl Call; - fn revoke_minter_role( - &mut self, - from: ActorId, - ) -> impl Call; - fn approve(&mut self, to: ActorId) -> impl Call; - fn batch_transfer_from( - &mut self, - from: ActorId, - to: ActorId, - ids: Vec, - amounts: Vec, - ) -> impl Call; - fn transfer_from( - &mut self, - from: ActorId, - to: ActorId, - id: U256, - amount: U256, - ) -> impl Call; - fn admins(&self) -> impl Query, Args = Self::Args>; - fn burners(&self) -> impl Query, Args = Self::Args>; - fn minters(&self) -> impl Query, Args = Self::Args>; - fn balance_of( - &self, - account: ActorId, - id: U256, - ) -> impl Query; - fn balance_of_batch( - &self, - accounts: Vec, - ids: Vec, - ) -> impl Query, Args = Self::Args>; - fn decimals(&self) -> impl Query; - fn is_approved( - &self, - account: ActorId, - operator: ActorId, - ) -> impl Query; - fn name(&self) -> impl Query; - fn symbol(&self) -> impl Query; - fn total_supply(&self) -> impl Query, Args = Self::Args>; - } -} diff --git a/extended-vnft/client/build.rs b/extended-vnft/client/build.rs deleted file mode 100644 index dc7a87f..0000000 --- a/extended-vnft/client/build.rs +++ /dev/null @@ -1,17 +0,0 @@ -use sails_client_gen::ClientGenerator; -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("extended_vnft.idl"); - - // Generate IDL file for the program - sails_idl_gen::generate_idl_to_file::(&idl_file_path) - .unwrap(); - - // Generate client code from IDL file - ClientGenerator::from_idl_path(&idl_file_path) - .with_mocks("mocks") - .generate_to(PathBuf::from(env::var("OUT_DIR").unwrap()).join("extended_vnft_client.rs")) - .unwrap(); -} diff --git a/extended-vnft/client/src/lib.rs b/extended-vnft/client/src/lib.rs index 42f5283..fb3c5ec 100644 --- a/extended-vnft/client/src/lib.rs +++ b/extended-vnft/client/src/lib.rs @@ -1,4 +1,582 @@ #![no_std] -// Incorporate code generated based on the IDL file -include!(concat!(env!("OUT_DIR"), "/extended_vnft_client.rs")); +// Code generated by sails-client-gen. DO NOT EDIT. +#[allow(unused_imports)] +use sails_rs::collections::BTreeMap; +#[allow(unused_imports)] +use sails_rs::{ + calls::{Activation, Call, Query, Remoting, RemotingAction}, + prelude::*, + String, +}; +pub struct ExtendedVnftFactory { + #[allow(dead_code)] + remoting: R, +} +impl ExtendedVnftFactory { + #[allow(unused)] + pub fn new(remoting: R) -> Self { + Self { remoting } + } +} +impl traits::ExtendedVnftFactory for ExtendedVnftFactory { + type Args = R::Args; + fn new(&self, name: String, symbol: String) -> impl Activation { + RemotingAction::<_, extended_vnft_factory::io::New>::new( + self.remoting.clone(), + (name, symbol), + ) + } +} + +pub mod extended_vnft_factory { + use super::*; + pub mod io { + use super::*; + use sails_rs::calls::ActionIo; + pub struct New(()); + impl New { + #[allow(dead_code)] + pub fn encode_call(name: String, symbol: String) -> Vec { + ::encode_call(&(name, symbol)) + } + } + impl ActionIo for New { + const ROUTE: &'static [u8] = &[12, 78, 101, 119]; + type Params = (String, String); + type Reply = (); + } + } +} +pub struct Vnft { + remoting: R, +} +impl Vnft { + pub fn new(remoting: R) -> Self { + Self { remoting } + } +} +impl traits::Vnft for Vnft { + type Args = R::Args; + fn burn(&mut self, from: ActorId, token_id: U256) -> impl Call { + RemotingAction::<_, vnft::io::Burn>::new(self.remoting.clone(), (from, token_id)) + } + fn grant_admin_role(&mut self, to: ActorId) -> impl Call { + RemotingAction::<_, vnft::io::GrantAdminRole>::new(self.remoting.clone(), to) + } + fn grant_burner_role(&mut self, to: ActorId) -> impl Call { + RemotingAction::<_, vnft::io::GrantBurnerRole>::new(self.remoting.clone(), to) + } + fn grant_minter_role(&mut self, to: ActorId) -> impl Call { + RemotingAction::<_, vnft::io::GrantMinterRole>::new(self.remoting.clone(), to) + } + fn mint( + &mut self, + to: ActorId, + token_metadata: TokenMetadata, + ) -> impl Call { + RemotingAction::<_, vnft::io::Mint>::new(self.remoting.clone(), (to, token_metadata)) + } + fn revoke_admin_role(&mut self, from: ActorId) -> impl Call { + RemotingAction::<_, vnft::io::RevokeAdminRole>::new(self.remoting.clone(), from) + } + fn revoke_burner_role(&mut self, from: ActorId) -> impl Call { + RemotingAction::<_, vnft::io::RevokeBurnerRole>::new(self.remoting.clone(), from) + } + fn revoke_minter_role(&mut self, from: ActorId) -> impl Call { + RemotingAction::<_, vnft::io::RevokeMinterRole>::new(self.remoting.clone(), from) + } + fn approve( + &mut self, + approved: ActorId, + token_id: U256, + ) -> impl Call { + RemotingAction::<_, vnft::io::Approve>::new(self.remoting.clone(), (approved, token_id)) + } + fn transfer(&mut self, to: ActorId, token_id: U256) -> impl Call { + RemotingAction::<_, vnft::io::Transfer>::new(self.remoting.clone(), (to, token_id)) + } + fn transfer_from( + &mut self, + from: ActorId, + to: ActorId, + token_id: U256, + ) -> impl Call { + RemotingAction::<_, vnft::io::TransferFrom>::new( + self.remoting.clone(), + (from, to, token_id), + ) + } + fn admins(&self) -> impl Query, Args = R::Args> { + RemotingAction::<_, vnft::io::Admins>::new(self.remoting.clone(), ()) + } + fn burners(&self) -> impl Query, Args = R::Args> { + RemotingAction::<_, vnft::io::Burners>::new(self.remoting.clone(), ()) + } + fn minters(&self) -> impl Query, Args = R::Args> { + RemotingAction::<_, vnft::io::Minters>::new(self.remoting.clone(), ()) + } + fn token_id(&self) -> impl Query { + RemotingAction::<_, vnft::io::TokenId>::new(self.remoting.clone(), ()) + } + fn token_metadata_by_id( + &self, + token_id: U256, + ) -> impl Query, Args = R::Args> { + RemotingAction::<_, vnft::io::TokenMetadataById>::new(self.remoting.clone(), token_id) + } + fn tokens_for_owner( + &self, + owner: ActorId, + ) -> impl Query, Args = R::Args> { + RemotingAction::<_, vnft::io::TokensForOwner>::new(self.remoting.clone(), owner) + } + fn balance_of(&self, owner: ActorId) -> impl Query { + RemotingAction::<_, vnft::io::BalanceOf>::new(self.remoting.clone(), owner) + } + fn get_approved(&self, token_id: U256) -> impl Query { + RemotingAction::<_, vnft::io::GetApproved>::new(self.remoting.clone(), token_id) + } + fn name(&self) -> impl Query { + RemotingAction::<_, vnft::io::Name>::new(self.remoting.clone(), ()) + } + fn owner_of(&self, token_id: U256) -> impl Query { + RemotingAction::<_, vnft::io::OwnerOf>::new(self.remoting.clone(), token_id) + } + fn symbol(&self) -> impl Query { + RemotingAction::<_, vnft::io::Symbol>::new(self.remoting.clone(), ()) + } +} + +pub mod vnft { + use super::*; + + pub mod io { + use super::*; + use sails_rs::calls::ActionIo; + pub struct Burn(()); + impl Burn { + #[allow(dead_code)] + pub fn encode_call(from: ActorId, token_id: U256) -> Vec { + ::encode_call(&(from, token_id)) + } + } + impl ActionIo for Burn { + const ROUTE: &'static [u8] = &[16, 86, 110, 102, 116, 16, 66, 117, 114, 110]; + type Params = (ActorId, U256); + type Reply = (); + } + pub struct GrantAdminRole(()); + impl GrantAdminRole { + #[allow(dead_code)] + pub fn encode_call(to: ActorId) -> Vec { + ::encode_call(&to) + } + } + impl ActionIo for GrantAdminRole { + const ROUTE: &'static [u8] = &[ + 16, 86, 110, 102, 116, 56, 71, 114, 97, 110, 116, 65, 100, 109, 105, 110, 82, 111, + 108, 101, + ]; + type Params = ActorId; + type Reply = (); + } + pub struct GrantBurnerRole(()); + impl GrantBurnerRole { + #[allow(dead_code)] + pub fn encode_call(to: ActorId) -> Vec { + ::encode_call(&to) + } + } + impl ActionIo for GrantBurnerRole { + const ROUTE: &'static [u8] = &[ + 16, 86, 110, 102, 116, 60, 71, 114, 97, 110, 116, 66, 117, 114, 110, 101, 114, 82, + 111, 108, 101, + ]; + type Params = ActorId; + type Reply = (); + } + pub struct GrantMinterRole(()); + impl GrantMinterRole { + #[allow(dead_code)] + pub fn encode_call(to: ActorId) -> Vec { + ::encode_call(&to) + } + } + impl ActionIo for GrantMinterRole { + const ROUTE: &'static [u8] = &[ + 16, 86, 110, 102, 116, 60, 71, 114, 97, 110, 116, 77, 105, 110, 116, 101, 114, 82, + 111, 108, 101, + ]; + type Params = ActorId; + type Reply = (); + } + pub struct Mint(()); + impl Mint { + #[allow(dead_code)] + pub fn encode_call(to: ActorId, token_metadata: super::TokenMetadata) -> Vec { + ::encode_call(&(to, token_metadata)) + } + } + impl ActionIo for Mint { + const ROUTE: &'static [u8] = &[16, 86, 110, 102, 116, 16, 77, 105, 110, 116]; + type Params = (ActorId, super::TokenMetadata); + type Reply = (); + } + pub struct RevokeAdminRole(()); + impl RevokeAdminRole { + #[allow(dead_code)] + pub fn encode_call(from: ActorId) -> Vec { + ::encode_call(&from) + } + } + impl ActionIo for RevokeAdminRole { + const ROUTE: &'static [u8] = &[ + 16, 86, 110, 102, 116, 60, 82, 101, 118, 111, 107, 101, 65, 100, 109, 105, 110, 82, + 111, 108, 101, + ]; + type Params = ActorId; + type Reply = (); + } + pub struct RevokeBurnerRole(()); + impl RevokeBurnerRole { + #[allow(dead_code)] + pub fn encode_call(from: ActorId) -> Vec { + ::encode_call(&from) + } + } + impl ActionIo for RevokeBurnerRole { + const ROUTE: &'static [u8] = &[ + 16, 86, 110, 102, 116, 64, 82, 101, 118, 111, 107, 101, 66, 117, 114, 110, 101, + 114, 82, 111, 108, 101, + ]; + type Params = ActorId; + type Reply = (); + } + pub struct RevokeMinterRole(()); + impl RevokeMinterRole { + #[allow(dead_code)] + pub fn encode_call(from: ActorId) -> Vec { + ::encode_call(&from) + } + } + impl ActionIo for RevokeMinterRole { + const ROUTE: &'static [u8] = &[ + 16, 86, 110, 102, 116, 64, 82, 101, 118, 111, 107, 101, 77, 105, 110, 116, 101, + 114, 82, 111, 108, 101, + ]; + type Params = ActorId; + type Reply = (); + } + pub struct Approve(()); + impl Approve { + #[allow(dead_code)] + pub fn encode_call(approved: ActorId, token_id: U256) -> Vec { + ::encode_call(&(approved, token_id)) + } + } + impl ActionIo for Approve { + const ROUTE: &'static [u8] = + &[16, 86, 110, 102, 116, 28, 65, 112, 112, 114, 111, 118, 101]; + type Params = (ActorId, U256); + type Reply = (); + } + pub struct Transfer(()); + impl Transfer { + #[allow(dead_code)] + pub fn encode_call(to: ActorId, token_id: U256) -> Vec { + ::encode_call(&(to, token_id)) + } + } + impl ActionIo for Transfer { + const ROUTE: &'static [u8] = &[ + 16, 86, 110, 102, 116, 32, 84, 114, 97, 110, 115, 102, 101, 114, + ]; + type Params = (ActorId, U256); + type Reply = (); + } + pub struct TransferFrom(()); + impl TransferFrom { + #[allow(dead_code)] + pub fn encode_call(from: ActorId, to: ActorId, token_id: U256) -> Vec { + ::encode_call(&(from, to, token_id)) + } + } + impl ActionIo for TransferFrom { + const ROUTE: &'static [u8] = &[ + 16, 86, 110, 102, 116, 48, 84, 114, 97, 110, 115, 102, 101, 114, 70, 114, 111, 109, + ]; + type Params = (ActorId, ActorId, U256); + type Reply = (); + } + pub struct Admins(()); + impl Admins { + #[allow(dead_code)] + pub fn encode_call() -> Vec { + ::encode_call(&()) + } + } + impl ActionIo for Admins { + const ROUTE: &'static [u8] = &[16, 86, 110, 102, 116, 24, 65, 100, 109, 105, 110, 115]; + type Params = (); + type Reply = Vec; + } + pub struct Burners(()); + impl Burners { + #[allow(dead_code)] + pub fn encode_call() -> Vec { + ::encode_call(&()) + } + } + impl ActionIo for Burners { + const ROUTE: &'static [u8] = + &[16, 86, 110, 102, 116, 28, 66, 117, 114, 110, 101, 114, 115]; + type Params = (); + type Reply = Vec; + } + pub struct Minters(()); + impl Minters { + #[allow(dead_code)] + pub fn encode_call() -> Vec { + ::encode_call(&()) + } + } + impl ActionIo for Minters { + const ROUTE: &'static [u8] = + &[16, 86, 110, 102, 116, 28, 77, 105, 110, 116, 101, 114, 115]; + type Params = (); + type Reply = Vec; + } + pub struct TokenId(()); + impl TokenId { + #[allow(dead_code)] + pub fn encode_call() -> Vec { + ::encode_call(&()) + } + } + impl ActionIo for TokenId { + const ROUTE: &'static [u8] = + &[16, 86, 110, 102, 116, 28, 84, 111, 107, 101, 110, 73, 100]; + type Params = (); + type Reply = U256; + } + pub struct TokenMetadataById(()); + impl TokenMetadataById { + #[allow(dead_code)] + pub fn encode_call(token_id: U256) -> Vec { + ::encode_call(&token_id) + } + } + impl ActionIo for TokenMetadataById { + const ROUTE: &'static [u8] = &[ + 16, 86, 110, 102, 116, 68, 84, 111, 107, 101, 110, 77, 101, 116, 97, 100, 97, 116, + 97, 66, 121, 73, 100, + ]; + type Params = U256; + type Reply = Option; + } + pub struct TokensForOwner(()); + impl TokensForOwner { + #[allow(dead_code)] + pub fn encode_call(owner: ActorId) -> Vec { + ::encode_call(&owner) + } + } + impl ActionIo for TokensForOwner { + const ROUTE: &'static [u8] = &[ + 16, 86, 110, 102, 116, 56, 84, 111, 107, 101, 110, 115, 70, 111, 114, 79, 119, 110, + 101, 114, + ]; + type Params = ActorId; + type Reply = Vec<(U256, super::TokenMetadata)>; + } + pub struct BalanceOf(()); + impl BalanceOf { + #[allow(dead_code)] + pub fn encode_call(owner: ActorId) -> Vec { + ::encode_call(&owner) + } + } + impl ActionIo for BalanceOf { + const ROUTE: &'static [u8] = &[ + 16, 86, 110, 102, 116, 36, 66, 97, 108, 97, 110, 99, 101, 79, 102, + ]; + type Params = ActorId; + type Reply = U256; + } + pub struct GetApproved(()); + impl GetApproved { + #[allow(dead_code)] + pub fn encode_call(token_id: U256) -> Vec { + ::encode_call(&token_id) + } + } + impl ActionIo for GetApproved { + const ROUTE: &'static [u8] = &[ + 16, 86, 110, 102, 116, 44, 71, 101, 116, 65, 112, 112, 114, 111, 118, 101, 100, + ]; + type Params = U256; + type Reply = ActorId; + } + pub struct Name(()); + impl Name { + #[allow(dead_code)] + pub fn encode_call() -> Vec { + ::encode_call(&()) + } + } + impl ActionIo for Name { + const ROUTE: &'static [u8] = &[16, 86, 110, 102, 116, 16, 78, 97, 109, 101]; + type Params = (); + type Reply = String; + } + pub struct OwnerOf(()); + impl OwnerOf { + #[allow(dead_code)] + pub fn encode_call(token_id: U256) -> Vec { + ::encode_call(&token_id) + } + } + impl ActionIo for OwnerOf { + const ROUTE: &'static [u8] = + &[16, 86, 110, 102, 116, 28, 79, 119, 110, 101, 114, 79, 102]; + type Params = U256; + type Reply = ActorId; + } + pub struct Symbol(()); + impl Symbol { + #[allow(dead_code)] + pub fn encode_call() -> Vec { + ::encode_call(&()) + } + } + impl ActionIo for Symbol { + const ROUTE: &'static [u8] = &[16, 86, 110, 102, 116, 24, 83, 121, 109, 98, 111, 108]; + type Params = (); + type Reply = String; + } + } + + #[allow(dead_code)] + #[cfg(not(target_arch = "wasm32"))] + pub mod events { + use super::*; + use sails_rs::events::*; + #[derive(PartialEq, Debug, Encode, Decode)] + #[codec(crate = sails_rs::scale_codec)] + pub enum VnftEvents { + Minted { + to: ActorId, + token_metadata: TokenMetadata, + }, + Burned { + from: ActorId, + token_id: U256, + }, + Transfer { + from: ActorId, + to: ActorId, + token_id: U256, + }, + Approval { + owner: ActorId, + approved: ActorId, + token_id: U256, + }, + } + impl EventIo for VnftEvents { + const ROUTE: &'static [u8] = &[16, 86, 110, 102, 116]; + const EVENT_NAMES: &'static [&'static [u8]] = &[ + &[24, 77, 105, 110, 116, 101, 100], + &[24, 66, 117, 114, 110, 101, 100], + &[32, 84, 114, 97, 110, 115, 102, 101, 114], + &[32, 65, 112, 112, 114, 111, 118, 97, 108], + ]; + type Event = Self; + } + pub fn listener>>(remoting: R) -> impl Listener { + RemotingListener::<_, VnftEvents>::new(remoting) + } + } +} +#[derive(PartialEq, Clone, Debug, Encode, Decode, TypeInfo)] +#[codec(crate = sails_rs::scale_codec)] +#[scale_info(crate = sails_rs::scale_info)] +pub struct TokenMetadata { + pub name: String, + pub description: String, + pub media: String, + pub reference: String, +} + +pub mod traits { + use super::*; + #[allow(dead_code)] + pub trait ExtendedVnftFactory { + type Args; + #[allow(clippy::new_ret_no_self)] + #[allow(clippy::wrong_self_convention)] + fn new(&self, name: String, symbol: String) -> impl Activation; + } + + #[allow(clippy::type_complexity)] + pub trait Vnft { + type Args; + fn burn( + &mut self, + from: ActorId, + token_id: U256, + ) -> impl Call; + fn grant_admin_role(&mut self, to: ActorId) -> impl Call; + fn grant_burner_role(&mut self, to: ActorId) -> impl Call; + fn grant_minter_role(&mut self, to: ActorId) -> impl Call; + fn mint( + &mut self, + to: ActorId, + token_metadata: TokenMetadata, + ) -> impl Call; + fn revoke_admin_role(&mut self, from: ActorId) + -> impl Call; + fn revoke_burner_role( + &mut self, + from: ActorId, + ) -> impl Call; + fn revoke_minter_role( + &mut self, + from: ActorId, + ) -> impl Call; + fn approve( + &mut self, + approved: ActorId, + token_id: U256, + ) -> impl Call; + fn transfer( + &mut self, + to: ActorId, + token_id: U256, + ) -> impl Call; + fn transfer_from( + &mut self, + from: ActorId, + to: ActorId, + token_id: U256, + ) -> impl Call; + fn admins(&self) -> impl Query, Args = Self::Args>; + fn burners(&self) -> impl Query, Args = Self::Args>; + fn minters(&self) -> impl Query, Args = Self::Args>; + fn token_id(&self) -> impl Query; + fn token_metadata_by_id( + &self, + token_id: U256, + ) -> impl Query, Args = Self::Args>; + fn tokens_for_owner( + &self, + owner: ActorId, + ) -> impl Query, Args = Self::Args>; + fn balance_of(&self, owner: ActorId) -> impl Query; + fn get_approved(&self, token_id: U256) -> impl Query; + fn name(&self) -> impl Query; + fn owner_of(&self, token_id: U256) -> impl Query; + fn symbol(&self) -> impl Query; + } +} diff --git a/extended-vnft/idl_and_client/extended_vnft.idl b/extended-vnft/extended_vnft.idl similarity index 100% rename from extended-vnft/idl_and_client/extended_vnft.idl rename to extended-vnft/extended_vnft.idl diff --git a/extended-vnft/idl_and_client/extended_vnft_client.rs b/extended-vnft/idl_and_client/extended_vnft_client.rs deleted file mode 100644 index 42972cb..0000000 --- a/extended-vnft/idl_and_client/extended_vnft_client.rs +++ /dev/null @@ -1,580 +0,0 @@ -// Code generated by sails-client-gen. DO NOT EDIT. -#[allow(unused_imports)] -use sails_rs::collections::BTreeMap; -#[allow(unused_imports)] -use sails_rs::{ - calls::{Activation, Call, Query, Remoting, RemotingAction}, - prelude::*, - String, -}; -pub struct ExtendedVnftFactory { - #[allow(dead_code)] - remoting: R, -} -impl ExtendedVnftFactory { - #[allow(unused)] - pub fn new(remoting: R) -> Self { - Self { remoting } - } -} -impl traits::ExtendedVnftFactory for ExtendedVnftFactory { - type Args = R::Args; - fn new(&self, name: String, symbol: String) -> impl Activation { - RemotingAction::<_, extended_vnft_factory::io::New>::new( - self.remoting.clone(), - (name, symbol), - ) - } -} - -pub mod extended_vnft_factory { - use super::*; - pub mod io { - use super::*; - use sails_rs::calls::ActionIo; - pub struct New(()); - impl New { - #[allow(dead_code)] - pub fn encode_call(name: String, symbol: String) -> Vec { - ::encode_call(&(name, symbol)) - } - } - impl ActionIo for New { - const ROUTE: &'static [u8] = &[12, 78, 101, 119]; - type Params = (String, String); - type Reply = (); - } - } -} -pub struct Vnft { - remoting: R, -} -impl Vnft { - pub fn new(remoting: R) -> Self { - Self { remoting } - } -} -impl traits::Vnft for Vnft { - type Args = R::Args; - fn burn(&mut self, from: ActorId, token_id: U256) -> impl Call { - RemotingAction::<_, vnft::io::Burn>::new(self.remoting.clone(), (from, token_id)) - } - fn grant_admin_role(&mut self, to: ActorId) -> impl Call { - RemotingAction::<_, vnft::io::GrantAdminRole>::new(self.remoting.clone(), to) - } - fn grant_burner_role(&mut self, to: ActorId) -> impl Call { - RemotingAction::<_, vnft::io::GrantBurnerRole>::new(self.remoting.clone(), to) - } - fn grant_minter_role(&mut self, to: ActorId) -> impl Call { - RemotingAction::<_, vnft::io::GrantMinterRole>::new(self.remoting.clone(), to) - } - fn mint( - &mut self, - to: ActorId, - token_metadata: TokenMetadata, - ) -> impl Call { - RemotingAction::<_, vnft::io::Mint>::new(self.remoting.clone(), (to, token_metadata)) - } - fn revoke_admin_role(&mut self, from: ActorId) -> impl Call { - RemotingAction::<_, vnft::io::RevokeAdminRole>::new(self.remoting.clone(), from) - } - fn revoke_burner_role(&mut self, from: ActorId) -> impl Call { - RemotingAction::<_, vnft::io::RevokeBurnerRole>::new(self.remoting.clone(), from) - } - fn revoke_minter_role(&mut self, from: ActorId) -> impl Call { - RemotingAction::<_, vnft::io::RevokeMinterRole>::new(self.remoting.clone(), from) - } - fn approve( - &mut self, - approved: ActorId, - token_id: U256, - ) -> impl Call { - RemotingAction::<_, vnft::io::Approve>::new(self.remoting.clone(), (approved, token_id)) - } - fn transfer(&mut self, to: ActorId, token_id: U256) -> impl Call { - RemotingAction::<_, vnft::io::Transfer>::new(self.remoting.clone(), (to, token_id)) - } - fn transfer_from( - &mut self, - from: ActorId, - to: ActorId, - token_id: U256, - ) -> impl Call { - RemotingAction::<_, vnft::io::TransferFrom>::new( - self.remoting.clone(), - (from, to, token_id), - ) - } - fn admins(&self) -> impl Query, Args = R::Args> { - RemotingAction::<_, vnft::io::Admins>::new(self.remoting.clone(), ()) - } - fn burners(&self) -> impl Query, Args = R::Args> { - RemotingAction::<_, vnft::io::Burners>::new(self.remoting.clone(), ()) - } - fn minters(&self) -> impl Query, Args = R::Args> { - RemotingAction::<_, vnft::io::Minters>::new(self.remoting.clone(), ()) - } - fn token_id(&self) -> impl Query { - RemotingAction::<_, vnft::io::TokenId>::new(self.remoting.clone(), ()) - } - fn token_metadata_by_id( - &self, - token_id: U256, - ) -> impl Query, Args = R::Args> { - RemotingAction::<_, vnft::io::TokenMetadataById>::new(self.remoting.clone(), token_id) - } - fn tokens_for_owner( - &self, - owner: ActorId, - ) -> impl Query, Args = R::Args> { - RemotingAction::<_, vnft::io::TokensForOwner>::new(self.remoting.clone(), owner) - } - fn balance_of(&self, owner: ActorId) -> impl Query { - RemotingAction::<_, vnft::io::BalanceOf>::new(self.remoting.clone(), owner) - } - fn get_approved(&self, token_id: U256) -> impl Query { - RemotingAction::<_, vnft::io::GetApproved>::new(self.remoting.clone(), token_id) - } - fn name(&self) -> impl Query { - RemotingAction::<_, vnft::io::Name>::new(self.remoting.clone(), ()) - } - fn owner_of(&self, token_id: U256) -> impl Query { - RemotingAction::<_, vnft::io::OwnerOf>::new(self.remoting.clone(), token_id) - } - fn symbol(&self) -> impl Query { - RemotingAction::<_, vnft::io::Symbol>::new(self.remoting.clone(), ()) - } -} - -pub mod vnft { - use super::*; - - pub mod io { - use super::*; - use sails_rs::calls::ActionIo; - pub struct Burn(()); - impl Burn { - #[allow(dead_code)] - pub fn encode_call(from: ActorId, token_id: U256) -> Vec { - ::encode_call(&(from, token_id)) - } - } - impl ActionIo for Burn { - const ROUTE: &'static [u8] = &[16, 86, 110, 102, 116, 16, 66, 117, 114, 110]; - type Params = (ActorId, U256); - type Reply = (); - } - pub struct GrantAdminRole(()); - impl GrantAdminRole { - #[allow(dead_code)] - pub fn encode_call(to: ActorId) -> Vec { - ::encode_call(&to) - } - } - impl ActionIo for GrantAdminRole { - const ROUTE: &'static [u8] = &[ - 16, 86, 110, 102, 116, 56, 71, 114, 97, 110, 116, 65, 100, 109, 105, 110, 82, 111, - 108, 101, - ]; - type Params = ActorId; - type Reply = (); - } - pub struct GrantBurnerRole(()); - impl GrantBurnerRole { - #[allow(dead_code)] - pub fn encode_call(to: ActorId) -> Vec { - ::encode_call(&to) - } - } - impl ActionIo for GrantBurnerRole { - const ROUTE: &'static [u8] = &[ - 16, 86, 110, 102, 116, 60, 71, 114, 97, 110, 116, 66, 117, 114, 110, 101, 114, 82, - 111, 108, 101, - ]; - type Params = ActorId; - type Reply = (); - } - pub struct GrantMinterRole(()); - impl GrantMinterRole { - #[allow(dead_code)] - pub fn encode_call(to: ActorId) -> Vec { - ::encode_call(&to) - } - } - impl ActionIo for GrantMinterRole { - const ROUTE: &'static [u8] = &[ - 16, 86, 110, 102, 116, 60, 71, 114, 97, 110, 116, 77, 105, 110, 116, 101, 114, 82, - 111, 108, 101, - ]; - type Params = ActorId; - type Reply = (); - } - pub struct Mint(()); - impl Mint { - #[allow(dead_code)] - pub fn encode_call(to: ActorId, token_metadata: super::TokenMetadata) -> Vec { - ::encode_call(&(to, token_metadata)) - } - } - impl ActionIo for Mint { - const ROUTE: &'static [u8] = &[16, 86, 110, 102, 116, 16, 77, 105, 110, 116]; - type Params = (ActorId, super::TokenMetadata); - type Reply = (); - } - pub struct RevokeAdminRole(()); - impl RevokeAdminRole { - #[allow(dead_code)] - pub fn encode_call(from: ActorId) -> Vec { - ::encode_call(&from) - } - } - impl ActionIo for RevokeAdminRole { - const ROUTE: &'static [u8] = &[ - 16, 86, 110, 102, 116, 60, 82, 101, 118, 111, 107, 101, 65, 100, 109, 105, 110, 82, - 111, 108, 101, - ]; - type Params = ActorId; - type Reply = (); - } - pub struct RevokeBurnerRole(()); - impl RevokeBurnerRole { - #[allow(dead_code)] - pub fn encode_call(from: ActorId) -> Vec { - ::encode_call(&from) - } - } - impl ActionIo for RevokeBurnerRole { - const ROUTE: &'static [u8] = &[ - 16, 86, 110, 102, 116, 64, 82, 101, 118, 111, 107, 101, 66, 117, 114, 110, 101, - 114, 82, 111, 108, 101, - ]; - type Params = ActorId; - type Reply = (); - } - pub struct RevokeMinterRole(()); - impl RevokeMinterRole { - #[allow(dead_code)] - pub fn encode_call(from: ActorId) -> Vec { - ::encode_call(&from) - } - } - impl ActionIo for RevokeMinterRole { - const ROUTE: &'static [u8] = &[ - 16, 86, 110, 102, 116, 64, 82, 101, 118, 111, 107, 101, 77, 105, 110, 116, 101, - 114, 82, 111, 108, 101, - ]; - type Params = ActorId; - type Reply = (); - } - pub struct Approve(()); - impl Approve { - #[allow(dead_code)] - pub fn encode_call(approved: ActorId, token_id: U256) -> Vec { - ::encode_call(&(approved, token_id)) - } - } - impl ActionIo for Approve { - const ROUTE: &'static [u8] = - &[16, 86, 110, 102, 116, 28, 65, 112, 112, 114, 111, 118, 101]; - type Params = (ActorId, U256); - type Reply = (); - } - pub struct Transfer(()); - impl Transfer { - #[allow(dead_code)] - pub fn encode_call(to: ActorId, token_id: U256) -> Vec { - ::encode_call(&(to, token_id)) - } - } - impl ActionIo for Transfer { - const ROUTE: &'static [u8] = &[ - 16, 86, 110, 102, 116, 32, 84, 114, 97, 110, 115, 102, 101, 114, - ]; - type Params = (ActorId, U256); - type Reply = (); - } - pub struct TransferFrom(()); - impl TransferFrom { - #[allow(dead_code)] - pub fn encode_call(from: ActorId, to: ActorId, token_id: U256) -> Vec { - ::encode_call(&(from, to, token_id)) - } - } - impl ActionIo for TransferFrom { - const ROUTE: &'static [u8] = &[ - 16, 86, 110, 102, 116, 48, 84, 114, 97, 110, 115, 102, 101, 114, 70, 114, 111, 109, - ]; - type Params = (ActorId, ActorId, U256); - type Reply = (); - } - pub struct Admins(()); - impl Admins { - #[allow(dead_code)] - pub fn encode_call() -> Vec { - ::encode_call(&()) - } - } - impl ActionIo for Admins { - const ROUTE: &'static [u8] = &[16, 86, 110, 102, 116, 24, 65, 100, 109, 105, 110, 115]; - type Params = (); - type Reply = Vec; - } - pub struct Burners(()); - impl Burners { - #[allow(dead_code)] - pub fn encode_call() -> Vec { - ::encode_call(&()) - } - } - impl ActionIo for Burners { - const ROUTE: &'static [u8] = - &[16, 86, 110, 102, 116, 28, 66, 117, 114, 110, 101, 114, 115]; - type Params = (); - type Reply = Vec; - } - pub struct Minters(()); - impl Minters { - #[allow(dead_code)] - pub fn encode_call() -> Vec { - ::encode_call(&()) - } - } - impl ActionIo for Minters { - const ROUTE: &'static [u8] = - &[16, 86, 110, 102, 116, 28, 77, 105, 110, 116, 101, 114, 115]; - type Params = (); - type Reply = Vec; - } - pub struct TokenId(()); - impl TokenId { - #[allow(dead_code)] - pub fn encode_call() -> Vec { - ::encode_call(&()) - } - } - impl ActionIo for TokenId { - const ROUTE: &'static [u8] = - &[16, 86, 110, 102, 116, 28, 84, 111, 107, 101, 110, 73, 100]; - type Params = (); - type Reply = U256; - } - pub struct TokenMetadataById(()); - impl TokenMetadataById { - #[allow(dead_code)] - pub fn encode_call(token_id: U256) -> Vec { - ::encode_call(&token_id) - } - } - impl ActionIo for TokenMetadataById { - const ROUTE: &'static [u8] = &[ - 16, 86, 110, 102, 116, 68, 84, 111, 107, 101, 110, 77, 101, 116, 97, 100, 97, 116, - 97, 66, 121, 73, 100, - ]; - type Params = U256; - type Reply = Option; - } - pub struct TokensForOwner(()); - impl TokensForOwner { - #[allow(dead_code)] - pub fn encode_call(owner: ActorId) -> Vec { - ::encode_call(&owner) - } - } - impl ActionIo for TokensForOwner { - const ROUTE: &'static [u8] = &[ - 16, 86, 110, 102, 116, 56, 84, 111, 107, 101, 110, 115, 70, 111, 114, 79, 119, 110, - 101, 114, - ]; - type Params = ActorId; - type Reply = Vec<(U256, super::TokenMetadata)>; - } - pub struct BalanceOf(()); - impl BalanceOf { - #[allow(dead_code)] - pub fn encode_call(owner: ActorId) -> Vec { - ::encode_call(&owner) - } - } - impl ActionIo for BalanceOf { - const ROUTE: &'static [u8] = &[ - 16, 86, 110, 102, 116, 36, 66, 97, 108, 97, 110, 99, 101, 79, 102, - ]; - type Params = ActorId; - type Reply = U256; - } - pub struct GetApproved(()); - impl GetApproved { - #[allow(dead_code)] - pub fn encode_call(token_id: U256) -> Vec { - ::encode_call(&token_id) - } - } - impl ActionIo for GetApproved { - const ROUTE: &'static [u8] = &[ - 16, 86, 110, 102, 116, 44, 71, 101, 116, 65, 112, 112, 114, 111, 118, 101, 100, - ]; - type Params = U256; - type Reply = ActorId; - } - pub struct Name(()); - impl Name { - #[allow(dead_code)] - pub fn encode_call() -> Vec { - ::encode_call(&()) - } - } - impl ActionIo for Name { - const ROUTE: &'static [u8] = &[16, 86, 110, 102, 116, 16, 78, 97, 109, 101]; - type Params = (); - type Reply = String; - } - pub struct OwnerOf(()); - impl OwnerOf { - #[allow(dead_code)] - pub fn encode_call(token_id: U256) -> Vec { - ::encode_call(&token_id) - } - } - impl ActionIo for OwnerOf { - const ROUTE: &'static [u8] = - &[16, 86, 110, 102, 116, 28, 79, 119, 110, 101, 114, 79, 102]; - type Params = U256; - type Reply = ActorId; - } - pub struct Symbol(()); - impl Symbol { - #[allow(dead_code)] - pub fn encode_call() -> Vec { - ::encode_call(&()) - } - } - impl ActionIo for Symbol { - const ROUTE: &'static [u8] = &[16, 86, 110, 102, 116, 24, 83, 121, 109, 98, 111, 108]; - type Params = (); - type Reply = String; - } - } - - #[allow(dead_code)] - #[cfg(not(target_arch = "wasm32"))] - pub mod events { - use super::*; - use sails_rs::events::*; - #[derive(PartialEq, Debug, Encode, Decode)] - #[codec(crate = sails_rs::scale_codec)] - pub enum VnftEvents { - Minted { - to: ActorId, - token_metadata: TokenMetadata, - }, - Burned { - from: ActorId, - token_id: U256, - }, - Transfer { - from: ActorId, - to: ActorId, - token_id: U256, - }, - Approval { - owner: ActorId, - approved: ActorId, - token_id: U256, - }, - } - impl EventIo for VnftEvents { - const ROUTE: &'static [u8] = &[16, 86, 110, 102, 116]; - const EVENT_NAMES: &'static [&'static [u8]] = &[ - &[24, 77, 105, 110, 116, 101, 100], - &[24, 66, 117, 114, 110, 101, 100], - &[32, 84, 114, 97, 110, 115, 102, 101, 114], - &[32, 65, 112, 112, 114, 111, 118, 97, 108], - ]; - type Event = Self; - } - pub fn listener>>(remoting: R) -> impl Listener { - RemotingListener::<_, VnftEvents>::new(remoting) - } - } -} -#[derive(PartialEq, Clone, Debug, Encode, Decode, TypeInfo)] -#[codec(crate = sails_rs::scale_codec)] -#[scale_info(crate = sails_rs::scale_info)] -pub struct TokenMetadata { - pub name: String, - pub description: String, - pub media: String, - pub reference: String, -} - -pub mod traits { - use super::*; - #[allow(dead_code)] - pub trait ExtendedVnftFactory { - type Args; - #[allow(clippy::new_ret_no_self)] - #[allow(clippy::wrong_self_convention)] - fn new(&self, name: String, symbol: String) -> impl Activation; - } - - #[allow(clippy::type_complexity)] - pub trait Vnft { - type Args; - fn burn( - &mut self, - from: ActorId, - token_id: U256, - ) -> impl Call; - fn grant_admin_role(&mut self, to: ActorId) -> impl Call; - fn grant_burner_role(&mut self, to: ActorId) -> impl Call; - fn grant_minter_role(&mut self, to: ActorId) -> impl Call; - fn mint( - &mut self, - to: ActorId, - token_metadata: TokenMetadata, - ) -> impl Call; - fn revoke_admin_role(&mut self, from: ActorId) - -> impl Call; - fn revoke_burner_role( - &mut self, - from: ActorId, - ) -> impl Call; - fn revoke_minter_role( - &mut self, - from: ActorId, - ) -> impl Call; - fn approve( - &mut self, - approved: ActorId, - token_id: U256, - ) -> impl Call; - fn transfer( - &mut self, - to: ActorId, - token_id: U256, - ) -> impl Call; - fn transfer_from( - &mut self, - from: ActorId, - to: ActorId, - token_id: U256, - ) -> impl Call; - fn admins(&self) -> impl Query, Args = Self::Args>; - fn burners(&self) -> impl Query, Args = Self::Args>; - fn minters(&self) -> impl Query, Args = Self::Args>; - fn token_id(&self) -> impl Query; - fn token_metadata_by_id( - &self, - token_id: U256, - ) -> impl Query, Args = Self::Args>; - fn tokens_for_owner( - &self, - owner: ActorId, - ) -> impl Query, Args = Self::Args>; - fn balance_of(&self, owner: ActorId) -> impl Query; - fn get_approved(&self, token_id: U256) -> impl Query; - fn name(&self) -> impl Query; - fn owner_of(&self, token_id: U256) -> impl Query; - fn symbol(&self) -> impl Query; - } -}