From cccad49ba8c451aae44b5b939b077300e5ac2afc Mon Sep 17 00:00:00 2001 From: Daanvdplas Date: Tue, 18 Feb 2025 13:17:17 +0100 Subject: [PATCH 1/2] spike foreign fungibles --- pallets/api/src/fungibles/mod.rs | 235 +++++++++++++------------- pop-api/src/v0/foreign_fungibles.rs | 243 +++++++++++++++++++++++++++ runtime/devnet/src/config/api/mod.rs | 58 ++++++- runtime/devnet/src/config/assets.rs | 26 +++ runtime/devnet/src/lib.rs | 6 +- 5 files changed, 447 insertions(+), 121 deletions(-) create mode 100644 pop-api/src/v0/foreign_fungibles.rs diff --git a/pallets/api/src/fungibles/mod.rs b/pallets/api/src/fungibles/mod.rs index 1b10f03ec..b66eefb7d 100644 --- a/pallets/api/src/fungibles/mod.rs +++ b/pallets/api/src/fungibles/mod.rs @@ -14,18 +14,20 @@ mod tests; pub mod weights; type AccountIdOf = ::AccountId; -type TokenIdOf = as Inspect<::AccountId>>::AssetId; -type TokenIdParameterOf = >>::AssetIdParameter; -type AssetsOf = pallet_assets::Pallet>; -type AssetsErrorOf = pallet_assets::Error>; -type AssetsInstanceOf = ::AssetsInstance; -type AssetsWeightInfoOf = >>::WeightInfo; -type BalanceOf = as Inspect<::AccountId>>::Balance; -type WeightOf = ::WeightInfo; +type AssetsInstanceOf = >::AssetsInstance; +type AssetsOf = pallet_assets::Pallet>; +type TokenIdOf = as Inspect>>::AssetId; +type TokenIdParameterOf = + >>::AssetIdParameter; +type AssetsErrorOf = pallet_assets::Error>; +type AssetsWeightInfoOf = + >>::WeightInfo; +type BalanceOf = as Inspect>>::Balance; +type WeightOf = >::WeightInfo; #[frame_support::pallet] pub mod pallet { - use core::cmp::Ordering::*; + use core::{cmp::Ordering::*, marker::PhantomData}; use frame_support::{ dispatch::{DispatchResult, DispatchResultWithPostInfo, WithPostDispatchInfo}, @@ -43,9 +45,12 @@ pub mod pallet { /// Configure the pallet by specifying the parameters and types on which it depends. #[pallet::config] - pub trait Config: frame_system::Config + pallet_assets::Config { + pub trait Config: + frame_system::Config + pallet_assets::Config + { /// Because this pallet emits events, it depends on the runtime's definition of an event. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// The instance of pallet-assets. type AssetsInstance; /// Weight information for dispatchables in this pallet. @@ -53,40 +58,40 @@ pub mod pallet { } #[pallet::pallet] - pub struct Pallet(_); + pub struct Pallet(PhantomData<(T, I)>); /// The events that can be emitted. #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum Event, I: 'static = ()> { /// Event emitted when allowance by `owner` to `spender` changes. // Differing style: event name abides by the PSP22 standard. Approval { /// The token. - token: TokenIdOf, + token: TokenIdOf, /// The owner providing the allowance. owner: AccountIdOf, /// The beneficiary of the allowance. spender: AccountIdOf, /// The new allowance amount. - value: BalanceOf, + value: BalanceOf, }, /// Event emitted when a token transfer occurs. // Differing style: event name abides by the PSP22 standard. Transfer { /// The token. - token: TokenIdOf, + token: TokenIdOf, /// The source of the transfer. `None` when minting. from: Option>, /// The recipient of the transfer. `None` when burning. to: Option>, /// The amount transferred (or minted/burned). - value: BalanceOf, + value: BalanceOf, }, /// Event emitted when a token is created. Created { /// The token identifier. - id: TokenIdOf, + id: TokenIdOf, /// The creator of the token. creator: AccountIdOf, /// The administrator of the token. @@ -95,7 +100,7 @@ pub mod pallet { } #[pallet::call] - impl Pallet { + impl, I: 'static> Pallet { /// Transfers `value` amount of tokens from the caller's account to account `to`. /// /// # Parameters @@ -103,15 +108,15 @@ pub mod pallet { /// - `to` - The recipient account. /// - `value` - The number of tokens to transfer. #[pallet::call_index(3)] - #[pallet::weight(AssetsWeightInfoOf::::transfer_keep_alive())] + #[pallet::weight(AssetsWeightInfoOf::::transfer_keep_alive())] pub fn transfer( origin: OriginFor, - token: TokenIdOf, + token: TokenIdOf, to: AccountIdOf, - value: BalanceOf, + value: BalanceOf, ) -> DispatchResult { let from = ensure_signed(origin.clone())?; - AssetsOf::::transfer_keep_alive( + AssetsOf::::transfer_keep_alive( origin, token.clone().into(), T::Lookup::unlookup(to.clone()), @@ -130,15 +135,15 @@ pub mod pallet { /// - `to` - The recipient account. /// - `value` - The number of tokens to transfer. #[pallet::call_index(4)] - #[pallet::weight(AssetsWeightInfoOf::::transfer_approved())] + #[pallet::weight(AssetsWeightInfoOf::::transfer_approved())] pub fn transfer_from( origin: OriginFor, - token: TokenIdOf, + token: TokenIdOf, from: AccountIdOf, to: AccountIdOf, - value: BalanceOf, + value: BalanceOf, ) -> DispatchResult { - AssetsOf::::transfer_approved( + AssetsOf::::transfer_approved( origin, token.clone().into(), T::Lookup::unlookup(from.clone()), @@ -156,53 +161,53 @@ pub mod pallet { /// - `spender` - The account that is allowed to spend the tokens. /// - `value` - The number of tokens to approve. #[pallet::call_index(5)] - #[pallet::weight(::WeightInfo::approve(1, 1))] + #[pallet::weight(>::WeightInfo::approve(1, 1))] pub fn approve( origin: OriginFor, - token: TokenIdOf, + token: TokenIdOf, spender: AccountIdOf, - value: BalanceOf, + value: BalanceOf, ) -> DispatchResultWithPostInfo { let owner = ensure_signed(origin.clone()) - .map_err(|e| e.with_weight(WeightOf::::approve(0, 0)))?; - let current_allowance = AssetsOf::::allowance(token.clone(), &owner, &spender); + .map_err(|e| e.with_weight(WeightOf::::approve(0, 0)))?; + let current_allowance = AssetsOf::::allowance(token.clone(), &owner, &spender); let weight = match value.cmp(¤t_allowance) { // If the new value is equal to the current allowance, do nothing. - Equal => WeightOf::::approve(0, 0), + Equal => WeightOf::::approve(0, 0), // If the new value is greater than the current allowance, approve the difference // because `approve_transfer` works additively (see `pallet-assets`). Greater => { - AssetsOf::::approve_transfer( + AssetsOf::::approve_transfer( origin, token.clone().into(), T::Lookup::unlookup(spender.clone()), value.saturating_sub(current_allowance), ) - .map_err(|e| e.with_weight(WeightOf::::approve(1, 0)))?; - WeightOf::::approve(1, 0) + .map_err(|e| e.with_weight(WeightOf::::approve(1, 0)))?; + WeightOf::::approve(1, 0) }, // If the new value is less than the current allowance, cancel the approval and // set the new value. Less => { - let token_param: TokenIdParameterOf = token.clone().into(); + let token_param: TokenIdParameterOf = token.clone().into(); let spender_source = T::Lookup::unlookup(spender.clone()); - AssetsOf::::cancel_approval( + AssetsOf::::cancel_approval( origin.clone(), token_param.clone(), spender_source.clone(), ) - .map_err(|e| e.with_weight(WeightOf::::approve(0, 1)))?; + .map_err(|e| e.with_weight(WeightOf::::approve(0, 1)))?; if value.is_zero() { - WeightOf::::approve(0, 1) + WeightOf::::approve(0, 1) } else { - AssetsOf::::approve_transfer( + AssetsOf::::approve_transfer( origin, token_param, spender_source, value, )?; - WeightOf::::approve(1, 1) + WeightOf::::approve(1, 1) } }, }; @@ -217,23 +222,23 @@ pub mod pallet { /// - `spender` - The account that is allowed to spend the tokens. /// - `value` - The number of tokens to increase the allowance by. #[pallet::call_index(6)] - #[pallet::weight(::WeightInfo::approve(1, 0))] + #[pallet::weight(>::WeightInfo::approve(1, 0))] pub fn increase_allowance( origin: OriginFor, - token: TokenIdOf, + token: TokenIdOf, spender: AccountIdOf, - value: BalanceOf, + value: BalanceOf, ) -> DispatchResultWithPostInfo { let owner = ensure_signed(origin.clone()) - .map_err(|e| e.with_weight(WeightOf::::approve(0, 0)))?; - AssetsOf::::approve_transfer( + .map_err(|e| e.with_weight(WeightOf::::approve(0, 0)))?; + AssetsOf::::approve_transfer( origin, token.clone().into(), T::Lookup::unlookup(spender.clone()), value, ) - .map_err(|e| e.with_weight(AssetsWeightInfoOf::::approve_transfer()))?; - let value = AssetsOf::::allowance(token.clone(), &owner, &spender); + .map_err(|e| e.with_weight(AssetsWeightInfoOf::::approve_transfer()))?; + let value = AssetsOf::::allowance(token.clone(), &owner, &spender); Self::deposit_event(Event::Approval { token, owner, spender, value }); Ok(().into()) } @@ -245,41 +250,41 @@ pub mod pallet { /// - `spender` - The account that is allowed to spend the tokens. /// - `value` - The number of tokens to decrease the allowance by. #[pallet::call_index(7)] - #[pallet::weight(::WeightInfo::approve(1, 1))] + #[pallet::weight(>::WeightInfo::approve(1, 1))] pub fn decrease_allowance( origin: OriginFor, - token: TokenIdOf, + token: TokenIdOf, spender: AccountIdOf, - value: BalanceOf, + value: BalanceOf, ) -> DispatchResultWithPostInfo { let owner = ensure_signed(origin.clone()) - .map_err(|e| e.with_weight(WeightOf::::approve(0, 0)))?; + .map_err(|e| e.with_weight(WeightOf::::approve(0, 0)))?; if value.is_zero() { - return Ok(Some(WeightOf::::approve(0, 0)).into()); + return Ok(Some(WeightOf::::approve(0, 0)).into()); } - let current_allowance = AssetsOf::::allowance(token.clone(), &owner, &spender); + let current_allowance = AssetsOf::::allowance(token.clone(), &owner, &spender); let spender_source = T::Lookup::unlookup(spender.clone()); - let token_param: TokenIdParameterOf = token.clone().into(); + let token_param: TokenIdParameterOf = token.clone().into(); // Cancel the approval and approve `new_allowance` if difference is more than zero. let new_allowance = - current_allowance.checked_sub(&value).ok_or(AssetsErrorOf::::Unapproved)?; - AssetsOf::::cancel_approval( + current_allowance.checked_sub(&value).ok_or(AssetsErrorOf::::Unapproved)?; + AssetsOf::::cancel_approval( origin.clone(), token_param.clone(), spender_source.clone(), ) - .map_err(|e| e.with_weight(WeightOf::::approve(0, 1)))?; + .map_err(|e| e.with_weight(WeightOf::::approve(0, 1)))?; let weight = if new_allowance.is_zero() { - WeightOf::::approve(0, 1) + WeightOf::::approve(0, 1) } else { - AssetsOf::::approve_transfer( + AssetsOf::::approve_transfer( origin, token_param, spender_source, new_allowance, )?; - WeightOf::::approve(1, 1) + WeightOf::::approve(1, 1) }; Self::deposit_event(Event::Approval { token, owner, spender, value: new_allowance }); Ok(Some(weight).into()) @@ -292,15 +297,15 @@ pub mod pallet { /// - `admin` - The account that will administer the token. /// - `min_balance` - The minimum balance required for accounts holding this token. #[pallet::call_index(11)] - #[pallet::weight(AssetsWeightInfoOf::::create())] + #[pallet::weight(AssetsWeightInfoOf::::create())] pub fn create( origin: OriginFor, - id: TokenIdOf, + id: TokenIdOf, admin: AccountIdOf, - min_balance: BalanceOf, + min_balance: BalanceOf, ) -> DispatchResult { let creator = ensure_signed(origin.clone())?; - AssetsOf::::create( + AssetsOf::::create( origin, id.clone().into(), T::Lookup::unlookup(admin.clone()), @@ -319,9 +324,9 @@ pub mod pallet { // - `destroy_approvals` // - `finish_destroy` #[pallet::call_index(12)] - #[pallet::weight(AssetsWeightInfoOf::::start_destroy())] - pub fn start_destroy(origin: OriginFor, token: TokenIdOf) -> DispatchResult { - AssetsOf::::start_destroy(origin, token.into()) + #[pallet::weight(AssetsWeightInfoOf::::start_destroy())] + pub fn start_destroy(origin: OriginFor, token: TokenIdOf) -> DispatchResult { + AssetsOf::::start_destroy(origin, token.into()) } /// Set the metadata for a token. @@ -332,15 +337,15 @@ pub mod pallet { /// - `symbol`: The exchange symbol for this token. /// - `decimals`: The number of decimals this token uses to represent one unit. #[pallet::call_index(16)] - #[pallet::weight(AssetsWeightInfoOf::::set_metadata(name.len() as u32, symbol.len() as u32))] + #[pallet::weight(AssetsWeightInfoOf::::set_metadata(name.len() as u32, symbol.len() as u32))] pub fn set_metadata( origin: OriginFor, - token: TokenIdOf, + token: TokenIdOf, name: Vec, symbol: Vec, decimals: u8, ) -> DispatchResult { - AssetsOf::::set_metadata(origin, token.into(), name, symbol, decimals) + AssetsOf::::set_metadata(origin, token.into(), name, symbol, decimals) } /// Clear the metadata for a token. @@ -348,9 +353,9 @@ pub mod pallet { /// # Parameters /// - `token` - The token to update. #[pallet::call_index(17)] - #[pallet::weight(AssetsWeightInfoOf::::clear_metadata())] - pub fn clear_metadata(origin: OriginFor, token: TokenIdOf) -> DispatchResult { - AssetsOf::::clear_metadata(origin, token.into()) + #[pallet::weight(AssetsWeightInfoOf::::clear_metadata())] + pub fn clear_metadata(origin: OriginFor, token: TokenIdOf) -> DispatchResult { + AssetsOf::::clear_metadata(origin, token.into()) } /// Creates `value` amount of tokens and assigns them to `account`, increasing the total @@ -361,14 +366,14 @@ pub mod pallet { /// - `account` - The account to be credited with the created tokens. /// - `value` - The number of tokens to mint. #[pallet::call_index(19)] - #[pallet::weight(AssetsWeightInfoOf::::mint())] + #[pallet::weight(AssetsWeightInfoOf::::mint())] pub fn mint( origin: OriginFor, - token: TokenIdOf, + token: TokenIdOf, account: AccountIdOf, - value: BalanceOf, + value: BalanceOf, ) -> DispatchResult { - AssetsOf::::mint( + AssetsOf::::mint( origin, token.clone().into(), T::Lookup::unlookup(account.clone()), @@ -385,19 +390,19 @@ pub mod pallet { /// - `account` - The account from which the tokens will be destroyed. /// - `value` - The number of tokens to destroy. #[pallet::call_index(20)] - #[pallet::weight(::WeightInfo::balance_of() + AssetsWeightInfoOf::::burn())] + #[pallet::weight(>::WeightInfo::balance_of() + AssetsWeightInfoOf::::burn())] pub fn burn( origin: OriginFor, - token: TokenIdOf, + token: TokenIdOf, account: AccountIdOf, - value: BalanceOf, + value: BalanceOf, ) -> DispatchResultWithPostInfo { - let current_balance = AssetsOf::::balance(token.clone(), &account); + let current_balance = AssetsOf::::balance(token.clone(), &account); if current_balance < value { - return Err(AssetsErrorOf::::BalanceLow - .with_weight(::WeightInfo::balance_of())); + return Err(AssetsErrorOf::::BalanceLow + .with_weight(>::WeightInfo::balance_of())); } - AssetsOf::::burn( + AssetsOf::::burn( origin, token.clone().into(), T::Lookup::unlookup(account.clone()), @@ -413,15 +418,15 @@ pub mod pallet { #[cfg_attr(feature = "std", derive(PartialEq, Clone))] #[repr(u8)] #[allow(clippy::unnecessary_cast)] - pub enum Read { + pub enum Read, I: 'static = ()> { /// Total token supply for a specified token. #[codec(index = 0)] - TotalSupply(TokenIdOf), + TotalSupply(TokenIdOf), /// Account balance for a specified `token` and `owner`. #[codec(index = 1)] BalanceOf { /// The token. - token: TokenIdOf, + token: TokenIdOf, /// The owner of the token. owner: AccountIdOf, }, @@ -429,7 +434,7 @@ pub mod pallet { #[codec(index = 2)] Allowance { /// The token. - token: TokenIdOf, + token: TokenIdOf, /// The owner of the token. owner: AccountIdOf, /// The spender with an allowance. @@ -437,28 +442,28 @@ pub mod pallet { }, /// Name of the specified token. #[codec(index = 8)] - TokenName(TokenIdOf), + TokenName(TokenIdOf), /// Symbol for the specified token. #[codec(index = 9)] - TokenSymbol(TokenIdOf), + TokenSymbol(TokenIdOf), /// Decimals for the specified token. #[codec(index = 10)] - TokenDecimals(TokenIdOf), + TokenDecimals(TokenIdOf), /// Whether a specified token exists. #[codec(index = 18)] - TokenExists(TokenIdOf), + TokenExists(TokenIdOf), } /// Results of state reads for the fungibles API. #[derive(Debug)] #[cfg_attr(feature = "std", derive(PartialEq, Clone))] - pub enum ReadResult { + pub enum ReadResult, I: 'static = ()> { /// Total token supply for a specified token. - TotalSupply(BalanceOf), + TotalSupply(BalanceOf), /// Account balance for a specified token and owner. - BalanceOf(BalanceOf), + BalanceOf(BalanceOf), /// Allowance for a spender approved by an owner, for a specified token. - Allowance(BalanceOf), + Allowance(BalanceOf), /// Name of the specified token, if available. TokenName(Option>), /// Symbol for the specified token, if available. @@ -469,7 +474,7 @@ pub mod pallet { TokenExists(bool), } - impl ReadResult { + impl, I: 'static> ReadResult { /// Encodes the result. pub fn encode(&self) -> Vec { use ReadResult::*; @@ -485,7 +490,7 @@ pub mod pallet { } } - impl crate::Read for Pallet { + impl, I: 'static> crate::Read for Pallet { /// The type of read requested. type Read = Read; /// The type or result returned. @@ -499,13 +504,13 @@ pub mod pallet { fn weight(request: &Self::Read) -> Weight { use Read::*; match request { - TotalSupply(_) => ::WeightInfo::total_supply(), - BalanceOf { .. } => ::WeightInfo::balance_of(), - Allowance { .. } => ::WeightInfo::allowance(), - TokenName(_) => ::WeightInfo::token_name(), - TokenSymbol(_) => ::WeightInfo::token_symbol(), - TokenDecimals(_) => ::WeightInfo::token_decimals(), - TokenExists(_) => ::WeightInfo::token_exists(), + TotalSupply(_) => >::WeightInfo::total_supply(), + BalanceOf { .. } => >::WeightInfo::balance_of(), + Allowance { .. } => >::WeightInfo::allowance(), + TokenName(_) => >::WeightInfo::token_name(), + TokenSymbol(_) => >::WeightInfo::token_symbol(), + TokenDecimals(_) => >::WeightInfo::token_decimals(), + TokenExists(_) => >::WeightInfo::token_exists(), } } @@ -516,23 +521,25 @@ pub mod pallet { fn read(request: Self::Read) -> Self::Result { use Read::*; match request { - TotalSupply(token) => ReadResult::TotalSupply(AssetsOf::::total_supply(token)), + TotalSupply(token) => + ReadResult::TotalSupply(AssetsOf::::total_supply(token)), BalanceOf { token, owner } => - ReadResult::BalanceOf(AssetsOf::::balance(token, owner)), + ReadResult::BalanceOf(AssetsOf::::balance(token, owner)), Allowance { token, owner, spender } => - ReadResult::Allowance(AssetsOf::::allowance(token, &owner, &spender)), + ReadResult::Allowance(AssetsOf::::allowance(token, &owner, &spender)), TokenName(token) => ReadResult::TokenName( - Some( as MetadataInspect>>::name(token)) + Some( as MetadataInspect>>::name(token)) .filter(|v| !v.is_empty()), ), TokenSymbol(token) => ReadResult::TokenSymbol( - Some( as MetadataInspect>>::symbol(token)) + Some( as MetadataInspect>>::symbol(token)) .filter(|v| !v.is_empty()), ), TokenDecimals(token) => ReadResult::TokenDecimals( - as MetadataInspect>>::decimals(token), + as MetadataInspect>>::decimals(token), ), - TokenExists(token) => ReadResult::TokenExists(AssetsOf::::asset_exists(token)), + TokenExists(token) => + ReadResult::TokenExists(AssetsOf::::asset_exists(token)), } } } diff --git a/pop-api/src/v0/foreign_fungibles.rs b/pop-api/src/v0/foreign_fungibles.rs new file mode 100644 index 000000000..5f476f3c1 --- /dev/null +++ b/pop-api/src/v0/foreign_fungibles.rs @@ -0,0 +1,243 @@ +use crate::{ + primitives::{AccountId, Balance}, + ChainExtensionMethodApi, Result, StatusCode, +}; + +pub type TokenId = xcm::Location; + +/// Transfers `value` amount of tokens from the caller's account to account `to`. +/// +/// # Parameters +/// - `token` - The token to transfer. +/// - `to` - The recipient account. +/// - `value` - The number of tokens to transfer. +#[inline] +pub fn transfer(token: TokenId, to: AccountId, value: Balance) -> Result<()> { + build_dispatch(TRANSFER) + .input::<(TokenId, AccountId, Balance)>() + .output::, true>() + .handle_error_code::() + .call(&(token, to, value)) +} + +/// Returns the account balance for a specified `token` and `owner`. Returns `0` if +/// the account is non-existent. +/// +/// # Parameters +/// - `token` - The token. +/// - `owner` - The account whose balance is being queried. +#[inline] +pub fn balance_of(token: TokenId, owner: AccountId) -> Result { + build_read_state(BALANCE_OF) + .input::<(TokenId, AccountId)>() + .output::, true>() + .handle_error_code::() + .call(&(token, owner)) +} + +const BALANCE_OF: u8 = 1; +const TRANSFER: u8 = 3; +const FOREIGN_FUNGIBLES: u8 = 152; + +// Helper method to build a dispatch call. +// +// Parameters: +// - 'dispatchable': The index of the dispatchable function within the module. +fn build_dispatch(dispatchable: u8) -> ChainExtensionMethodApi { + crate::v0::build_dispatch(FOREIGN_FUNGIBLES, dispatchable) +} + +// Helper method to build a call to read state. +// +// Parameters: +// - 'state_query': The index of the runtime state query. +fn build_read_state(state_query: u8) -> ChainExtensionMethodApi { + crate::v0::build_read_state(FOREIGN_FUNGIBLES, state_query) +} + +mod xcm { + extern crate alloc; + use alloc::sync::Arc; + + use codec::{Decode, Encode}; + + #[derive(Debug, PartialEq, Eq)] + #[ink::scale_derive(Encode, Decode, TypeInfo)] + pub struct Location { + /// The number of parent junctions at the beginning of this `Location`. + pub parents: u8, + /// The interior (i.e. non-parent) junctions that this `Location` contains. + pub interior: Junctions, + } + + #[derive(Debug, PartialEq, Eq)] + #[ink::scale_derive(Encode, Decode, TypeInfo)] + pub enum Junctions { + /// The interpreting consensus system. + Here, + /// A relative path comprising 1 junction. + X1(Arc<[Junction; 1]>), + /// A relative path comprising 2 junctions. + X2(Arc<[Junction; 2]>), + /// A relative path comprising 3 junctions. + X3(Arc<[Junction; 3]>), + /// A relative path comprising 4 junctions. + X4(Arc<[Junction; 4]>), + /// A relative path comprising 5 junctions. + X5(Arc<[Junction; 5]>), + /// A relative path comprising 6 junctions. + X6(Arc<[Junction; 6]>), + /// A relative path comprising 7 junctions. + X7(Arc<[Junction; 7]>), + /// A relative path comprising 8 junctions. + X8(Arc<[Junction; 8]>), + } + + #[derive(Debug, PartialEq, Eq)] + #[ink::scale_derive(Encode, Decode, TypeInfo)] + pub enum Junction { + /// An indexed parachain belonging to and operated by the context. + /// + /// Generally used when the context is a Polkadot Relay-chain. + Parachain(#[codec(compact)] u32), + /// A 32-byte identifier for an account of a specific network that is respected as a + /// sovereign endpoint within the context. + /// + /// Generally used when the context is a Substrate-based chain. + AccountId32 { network: Option, id: [u8; 32] }, + /// An 8-byte index for an account of a specific network that is respected as a sovereign + /// endpoint within the context. + /// + /// May be used when the context is a Frame-based chain and includes e.g. an indices + /// pallet. + AccountIndex64 { + network: Option, + #[codec(compact)] + index: u64, + }, + /// A 20-byte identifier for an account of a specific network that is respected as a + /// sovereign endpoint within the context. + /// + /// May be used when the context is an Ethereum or Bitcoin chain or smart-contract. + AccountKey20 { network: Option, key: [u8; 20] }, + /// An instanced, indexed pallet that forms a constituent part of the context. + /// + /// Generally used when the context is a Frame-based chain. + PalletInstance(u8), + /// A non-descript index within the context location. + /// + /// Usage will vary widely owing to its generality. + /// + /// NOTE: Try to avoid using this and instead use a more specific item. + GeneralIndex(#[codec(compact)] u128), + /// A nondescript array datum, 32 bytes, acting as a key within the context + /// location. + /// + /// Usage will vary widely owing to its generality. + /// + /// NOTE: Try to avoid using this and instead use a more specific item. + // Note this is implemented as an array with a length rather than using `BoundedVec` owing + // to the bound for ` + GeneralKey { length: u8, data: [u8; 32] }, + /// The unambiguous child. + /// + /// Not currently used except as a fallback when deriving context. + OnlyChild, + /// A pluralistic body existing within consensus. + /// + /// Typical to be used to represent a governance origin of a chain, but could in principle + /// be used to represent things such as multisigs also. + Plurality { id: BodyId, part: BodyPart }, + /// A global network capable of externalizing its own consensus. This is not generally + /// meaningful outside of the universal level. + GlobalConsensus(NetworkId), + } + + #[derive(Debug, PartialEq, Eq)] + #[ink::scale_derive(Encode, Decode, TypeInfo)] + pub enum NetworkId { + /// Network specified by the first 32 bytes of its genesis block. + ByGenesis([u8; 32]), + /// Network defined by the first 32-bytes of the hash and number of some block it contains. + ByFork { block_number: u64, block_hash: [u8; 32] }, + /// The Polkadot mainnet Relay-chain. + Polkadot, + /// The Kusama canary-net Relay-chain. + Kusama, + /// An Ethereum network specified by its chain ID. + Ethereum { + /// The EIP-155 chain ID. + #[codec(compact)] + chain_id: u64, + }, + /// The Bitcoin network, including hard-forks supported by Bitcoin Core development team. + BitcoinCore, + /// The Bitcoin network, including hard-forks supported by Bitcoin Cash developers. + BitcoinCash, + /// The Polkadot Bulletin chain. + PolkadotBulletin, + } + + #[derive(Debug, PartialEq, Eq)] + #[ink::scale_derive(Encode, Decode, TypeInfo)] + pub enum BodyId { + /// The only body in its context. + Unit, + /// A named body. + Moniker([u8; 4]), + /// An indexed body. + Index(#[codec(compact)] u32), + /// The unambiguous executive body (for Polkadot, this would be the Polkadot council). + Executive, + /// The unambiguous technical body (for Polkadot, this would be the Technical Committee). + Technical, + /// The unambiguous legislative body (for Polkadot, this could be considered the opinion of + /// a majority of lock-voters). + Legislative, + /// The unambiguous judicial body (this doesn't exist on Polkadot, but if it were to get a + /// "grand oracle", it may be considered as that). + Judicial, + /// The unambiguous defense body (for Polkadot, an opinion on the topic given via a public + /// referendum on the `staking_admin` track). + Defense, + /// The unambiguous administration body (for Polkadot, an opinion on the topic given via a + /// public referendum on the `general_admin` track). + Administration, + /// The unambiguous treasury body (for Polkadot, an opinion on the topic given via a public + /// referendum on the `treasurer` track). + Treasury, + } + + #[derive(Debug, PartialEq, Eq)] + #[ink::scale_derive(Encode, Decode, TypeInfo)] + pub enum BodyPart { + /// The body's declaration, under whatever means it decides. + Voice, + /// A given number of members of the body. + Members { + #[codec(compact)] + count: u32, + }, + /// A given number of members of the body, out of some larger caucus. + Fraction { + #[codec(compact)] + nom: u32, + #[codec(compact)] + denom: u32, + }, + /// No less than the given proportion of members of the body. + AtLeastProportion { + #[codec(compact)] + nom: u32, + #[codec(compact)] + denom: u32, + }, + /// More than the given proportion of members of the body. + MoreThanProportion { + #[codec(compact)] + nom: u32, + #[codec(compact)] + denom: u32, + }, + } +} diff --git a/runtime/devnet/src/config/api/mod.rs b/runtime/devnet/src/config/api/mod.rs index e49a4c7d9..4b92d7ad0 100644 --- a/runtime/devnet/src/config/api/mod.rs +++ b/runtime/devnet/src/config/api/mod.rs @@ -11,7 +11,7 @@ use sp_runtime::DispatchError; use versioning::*; use crate::{ - config::assets::{TrustBackedAssetsInstance, TrustBackedNftsInstance}, + config::assets::{ForeignAssetsInstance, TrustBackedAssetsInstance, TrustBackedNftsInstance}, fungibles, nonfungibles, Runtime, RuntimeCall, RuntimeEvent, }; @@ -32,10 +32,13 @@ type DecodesAs = pallet_api::extension::DecodesAs< pub enum RuntimeRead { /// Fungible token queries. #[codec(index = 150)] - Fungibles(fungibles::Read), + Fungibles(fungibles::Read), /// Non-fungible token queries. #[codec(index = 151)] NonFungibles(nonfungibles::Read), + /// Foreign fungible token queries. + #[codec(index = 152)] + ForeignFungibles(fungibles::Read), } impl Readable for RuntimeRead { @@ -48,6 +51,7 @@ impl Readable for RuntimeRead { match self { RuntimeRead::Fungibles(key) => fungibles::Pallet::weight(key), RuntimeRead::NonFungibles(key) => nonfungibles::Pallet::weight(key), + RuntimeRead::ForeignFungibles(key) => fungibles::Pallet::weight(key), } } @@ -57,6 +61,8 @@ impl Readable for RuntimeRead { RuntimeRead::Fungibles(key) => RuntimeResult::Fungibles(fungibles::Pallet::read(key)), RuntimeRead::NonFungibles(key) => RuntimeResult::NonFungibles(nonfungibles::Pallet::read(key)), + RuntimeRead::ForeignFungibles(key) => + RuntimeResult::ForeignFungibles(fungibles::Pallet::read(key)), } } } @@ -66,9 +72,11 @@ impl Readable for RuntimeRead { #[cfg_attr(test, derive(PartialEq, Clone))] pub enum RuntimeResult { /// Fungible token read results. - Fungibles(fungibles::ReadResult), + Fungibles(fungibles::ReadResult), /// Non-fungible token read results. NonFungibles(nonfungibles::ReadResult), + /// Foreign fungible token read results. + ForeignFungibles(fungibles::ReadResult), } impl RuntimeResult { @@ -77,16 +85,23 @@ impl RuntimeResult { match self { RuntimeResult::Fungibles(result) => result.encode(), RuntimeResult::NonFungibles(result) => result.encode(), + RuntimeResult::ForeignFungibles(result) => result.encode(), } } } -impl fungibles::Config for Runtime { +impl fungibles::Config for Runtime { type AssetsInstance = TrustBackedAssetsInstance; type RuntimeEvent = RuntimeEvent; type WeightInfo = fungibles::weights::SubstrateWeight; } +impl fungibles::Config for Runtime { + type AssetsInstance = ForeignAssetsInstance; + type RuntimeEvent = RuntimeEvent; + type WeightInfo = fungibles::weights::SubstrateWeight; +} + impl nonfungibles::Config for Runtime { type NftsInstance = TrustBackedNftsInstance; type RuntimeEvent = RuntimeEvent; @@ -183,7 +198,25 @@ impl> Contains f ) }; - T::BaseCallFilter::contains(c) && (contain_fungibles | contain_nonfungibles) + let contain_foreign_fungibles: bool = { + use fungibles::Call::*; + matches!( + c, + RuntimeCall::ForeignFungibles( + transfer { .. } | + transfer_from { .. } | + approve { .. } | increase_allowance { .. } | + decrease_allowance { .. } | + create { .. } | set_metadata { .. } | + start_destroy { .. } | + clear_metadata { .. } | + mint { .. } | burn { .. } + ) + ) + }; + + T::BaseCallFilter::contains(c) && + (contain_fungibles | contain_nonfungibles | contain_foreign_fungibles) } } @@ -216,7 +249,20 @@ impl Contains for Filter { ) }; - contain_fungibles | contain_nonfungibles + let contain_foreign_fungibles: bool = { + use fungibles::Read::*; + matches!( + r, + RuntimeRead::ForeignFungibles( + TotalSupply(..) | + BalanceOf { .. } | Allowance { .. } | + TokenName(..) | TokenSymbol(..) | + TokenDecimals(..) | TokenExists(..) + ) + ) + }; + + contain_fungibles | contain_nonfungibles | contain_foreign_fungibles } } diff --git a/runtime/devnet/src/config/assets.rs b/runtime/devnet/src/config/assets.rs index 704cf4c37..5dae9eb05 100644 --- a/runtime/devnet/src/config/assets.rs +++ b/runtime/devnet/src/config/assets.rs @@ -1,3 +1,4 @@ +use ::xcm::v5::Location; use frame_support::{ pallet_prelude::Get, parameter_types, @@ -146,6 +147,31 @@ impl pallet_assets::Config for Runtime { type WeightInfo = pallet_assets::weights::SubstrateWeight; } +pub(crate) type ForeignAssetsInstance = pallet_assets::Instance2; +pub type ForeignAssetsCall = pallet_assets::Call; +impl pallet_assets::Config for Runtime { + type ApprovalDeposit = ApprovalDeposit; + type AssetAccountDeposit = AssetAccountDeposit; + type AssetDeposit = AssetDeposit; + type AssetId = Location; + type AssetIdParameter = Location; + type Balance = Balance; + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHelper = (); + type CallbackHandle = (); + type CreateOrigin = AsEnsureOriginWithArg>; + type Currency = Balances; + type Extra = (); + type ForceOrigin = AssetsForceOrigin; + type Freezer = (); + type MetadataDepositBase = MetadataDepositBase; + type MetadataDepositPerByte = MetadataDepositPerByte; + type RemoveItemsLimit = ConstU32<1000>; + type RuntimeEvent = RuntimeEvent; + type StringLimit = AssetsStringLimit; + type WeightInfo = pallet_assets::weights::SubstrateWeight; +} + #[cfg(test)] mod tests { use frame_support::traits::StorageInfoTrait; diff --git a/runtime/devnet/src/lib.rs b/runtime/devnet/src/lib.rs index aca3c865a..7c7167885 100644 --- a/runtime/devnet/src/lib.rs +++ b/runtime/devnet/src/lib.rs @@ -648,10 +648,14 @@ mod runtime { pub type NftFractionalization = pallet_nft_fractionalization::Pallet; #[runtime::pallet_index(52)] pub type Assets = pallet_assets::Pallet; + #[runtime::pallet_index(53)] + pub type ForeignAssets = pallet_assets::Pallet; // Pop API #[runtime::pallet_index(150)] - pub type Fungibles = fungibles::Pallet; + pub type Fungibles = fungibles::Pallet; + #[runtime::pallet_index(152)] + pub type ForeignFungibles = fungibles::Pallet; #[runtime::pallet_index(151)] pub type NonFungibles = nonfungibles::Pallet; } From 184c11ece6249cf52f178f742fb1c1f498e911e3 Mon Sep 17 00:00:00 2001 From: Daanvdplas Date: Tue, 18 Feb 2025 14:02:27 +0100 Subject: [PATCH 2/2] show contract --- .../contracts/foreign_fungibles/Cargo.lock | 1705 +++++++++++++++++ .../contracts/foreign_fungibles/Cargo.toml | 23 + .../contracts/foreign_fungibles/lib.rs | 214 +++ 3 files changed, 1942 insertions(+) create mode 100644 pop-api/integration-tests/contracts/foreign_fungibles/Cargo.lock create mode 100755 pop-api/integration-tests/contracts/foreign_fungibles/Cargo.toml create mode 100644 pop-api/integration-tests/contracts/foreign_fungibles/lib.rs diff --git a/pop-api/integration-tests/contracts/foreign_fungibles/Cargo.lock b/pop-api/integration-tests/contracts/foreign_fungibles/Cargo.lock new file mode 100644 index 000000000..8c21ed2dc --- /dev/null +++ b/pop-api/integration-tests/contracts/foreign_fungibles/Cargo.lock @@ -0,0 +1,1705 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "Inflector" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" +dependencies = [ + "lazy_static", + "regex", +] + +[[package]] +name = "aead" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" +dependencies = [ + "crypto-common", + "generic-array", +] + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "array-bytes" +version = "6.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d5dde061bd34119e902bbb2d9b90c5692635cf59fb91d582c2b68043f1b8293" + +[[package]] +name = "array-init" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d62b7694a562cdf5a74227903507c56ab2cc8bdd1f781ed5cb4cf9c9f810bfc" + +[[package]] +name = "arrayref" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" + +[[package]] +name = "arrayvec" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" + +[[package]] +name = "autocfg" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "blake2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" +dependencies = [ + "digest", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bounded-collections" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32ed0a820ed50891d36358e997d27741a6142e382242df40ff01c89bcdcc7a2b" +dependencies = [ + "log", + "parity-scale-codec", + "scale-info", + "serde", +] + +[[package]] +name = "byte-slice-cast" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "cc" +version = "1.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c3d1b2e905a3a7b00a6141adb0e4c0bb941d11caf55349d863942a1cc44e3c9" +dependencies = [ + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "common-path" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2382f75942f4b3be3690fe4f86365e9c853c1587d6ee58212cebf6e2a9ccd101" + +[[package]] +name = "const_env" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e9e4f72c6e3398ca6da372abd9affd8f89781fe728869bbf986206e9af9627e" +dependencies = [ + "const_env_impl", +] + +[[package]] +name = "const_env_impl" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a4f51209740b5e1589e702b3044cdd4562cef41b6da404904192ffffb852d62" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "const_format" +version = "0.2.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "126f97965c8ad46d6d9163268ff28432e8f6a1196a55578867832e3049df63dd" +dependencies = [ + "const_format_proc_macros", +] + +[[package]] +name = "const_format_proc_macros" +version = "0.2.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d57c2eccfb16dbac1f4e61e206105db5820c9d26c3c472bc17c774259ef7744" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "rand_core", + "typenum", +] + +[[package]] +name = "curve25519-dalek" +version = "4.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" +dependencies = [ + "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", + "digest", + "fiat-crypto", + "rustc_version", + "subtle", + "zeroize", +] + +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "darling" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 1.0.109", +] + +[[package]] +name = "darling_macro" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" +dependencies = [ + "darling_core", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "derive-syn-parse" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d65d7ce8132b7c0e54497a4d9a55a1c2a0912a0d786cf894472ba818fba45762" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "derive_more" +version = "0.99.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3da29a38df43d6f156149c9b43ded5e018ddff2a855cf2cfd62e8cd7d079c69f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "derive_more" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", + "unicode-xid", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", + "subtle", +] + +[[package]] +name = "docify" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a772b62b1837c8f060432ddcc10b17aae1453ef17617a99bc07789252d2a5896" +dependencies = [ + "docify_macros", +] + +[[package]] +name = "docify_macros" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60e6be249b0a462a14784a99b19bf35a667bb5e09de611738bb7362fa4c95ff7" +dependencies = [ + "common-path", + "derive-syn-parse", + "once_cell", + "proc-macro2", + "quote", + "regex", + "syn 2.0.98", + "termcolor", + "toml", + "walkdir", +] + +[[package]] +name = "dyn-clone" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "feeef44e73baff3a26d371801df019877a9866a8c493d315ab00177843314f35" + +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + +[[package]] +name = "enumflags2" +version = "0.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba2f4b465f5318854c6f8dd686ede6c0a9dc67d4b1ac241cf0eb51521a309147" +dependencies = [ + "enumflags2_derive", +] + +[[package]] +name = "enumflags2_derive" +version = "0.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc4caf64a58d7a6d65ab00639b046ff54399a39f5f2554728895ace4b297cd79" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "environmental" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e48c92028aaa870e83d51c64e5d4e0b6981b360c522198c23959f219a4e1b15b" + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "fiat-crypto" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign_fungibles" +version = "0.1.0" +dependencies = [ + "ink", + "pop-api", +] + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "getrandom_or_panic" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ea1015b5a70616b688dc230cfe50c8af89d972cb132d5a622814d29773b10b9" +dependencies = [ + "rand", + "rand_core", +] + +[[package]] +name = "hashbrown" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "impl-serde" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" +dependencies = [ + "serde", +] + +[[package]] +name = "impl-trait-for-tuples" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0eb5a3343abf848c0984fe4604b2b105da9539376e24fc0a3b0007411ae4fd9" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "indexmap" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "ink" +version = "5.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15d7438a13d38fa8f4eebea8d1e7c2931058eafd0336c79f4141d4ed0162a412" +dependencies = [ + "derive_more 1.0.0", + "ink_env", + "ink_macro", + "ink_metadata", + "ink_prelude", + "ink_primitives", + "ink_storage", + "pallet-contracts-uapi", + "parity-scale-codec", + "scale-info", + "staging-xcm", +] + +[[package]] +name = "ink_allocator" +version = "5.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ec348ce75d284bc2e698187dc01da416a52dfa2d685e2a57d04e9e580447df0" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "ink_codegen" +version = "5.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2238f147295746f1fee4cf7dcdee6378c94e61fbf7b9f9f4bb2a7f918530801b" +dependencies = [ + "blake2", + "derive_more 1.0.0", + "either", + "heck", + "impl-serde", + "ink_ir", + "ink_primitives", + "itertools", + "parity-scale-codec", + "proc-macro2", + "quote", + "serde", + "serde_json", + "syn 2.0.98", +] + +[[package]] +name = "ink_engine" +version = "5.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273f2aa983d04a6476d3c5ac76ddbef07555664b88f923996e7465e261dda48" +dependencies = [ + "blake2", + "derive_more 1.0.0", + "ink_primitives", + "pallet-contracts-uapi", + "parity-scale-codec", + "secp256k1", + "sha2", + "sha3", +] + +[[package]] +name = "ink_env" +version = "5.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9ee6089a1836c2e92d00be97d42308b7fb2c2b51ff6150b1130166a58107092" +dependencies = [ + "blake2", + "cfg-if", + "const_env", + "derive_more 1.0.0", + "ink_allocator", + "ink_engine", + "ink_prelude", + "ink_primitives", + "ink_storage_traits", + "num-traits", + "pallet-contracts-uapi", + "parity-scale-codec", + "paste", + "rlibc", + "scale-decode", + "scale-encode", + "scale-info", + "schnorrkel", + "secp256k1", + "sha2", + "sha3", + "staging-xcm", + "static_assertions", +] + +[[package]] +name = "ink_ir" +version = "5.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e201688fb27ff97496a4231a393dd4befcc5a9c092d6bf231f0f5d409ef44f34" +dependencies = [ + "blake2", + "either", + "impl-serde", + "ink_prelude", + "itertools", + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "ink_macro" +version = "5.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ce9465553d3066a8e28bd94a94880289084c4ff12f1852312553e902fa1ffdd" +dependencies = [ + "ink_codegen", + "ink_ir", + "ink_primitives", + "parity-scale-codec", + "proc-macro2", + "quote", + "syn 2.0.98", + "synstructure", +] + +[[package]] +name = "ink_metadata" +version = "5.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27135c651274087ba0578d2c07866c31d8dd481ae8de5bb7295fe3931491aa80" +dependencies = [ + "derive_more 1.0.0", + "impl-serde", + "ink_prelude", + "ink_primitives", + "linkme", + "parity-scale-codec", + "scale-info", + "schemars", + "serde", +] + +[[package]] +name = "ink_prelude" +version = "5.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b29c9b7f686f4305f523bca5e2ae6f22a09531ec2bf0a9498cdc877959f70ad0" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "ink_primitives" +version = "5.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a530c1b352a53176ea718f3a65f15003e54e0474ec12353ea0e0e5bb60b25741" +dependencies = [ + "derive_more 1.0.0", + "ink_prelude", + "parity-scale-codec", + "scale-decode", + "scale-encode", + "scale-info", + "xxhash-rust", +] + +[[package]] +name = "ink_storage" +version = "5.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bed602a974481b194084b93957917f27e724c7561fd0de9b6f3c171590c839b" +dependencies = [ + "array-init", + "cfg-if", + "derive_more 1.0.0", + "ink_env", + "ink_metadata", + "ink_prelude", + "ink_primitives", + "ink_storage_traits", + "pallet-contracts-uapi", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "ink_storage_traits" +version = "5.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fde9b3f4a1e355682e5d13fd5639e5da4d0a2029537292e05a4255ea1169663e" +dependencies = [ + "ink_metadata", + "ink_prelude", + "ink_primitives", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "integer-sqrt" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "276ec31bcb4a9ee45f58bec6f9ec700ae4cf4f4f8f2fa7e06cb406bd5ffdd770" +dependencies = [ + "num-traits", +] + +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" + +[[package]] +name = "keccak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" +dependencies = [ + "cpufeatures", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.169" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" + +[[package]] +name = "linkme" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "566336154b9e58a4f055f6dd4cbab62c7dc0826ce3c0a04e63b2d2ecd784cdae" +dependencies = [ + "linkme-impl", +] + +[[package]] +name = "linkme-impl" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edbe595006d355eaf9ae11db92707d4338cd2384d16866131cc1afdbdd35d8d9" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "log" +version = "0.4.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "merlin" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58c38e2799fc0978b65dfff8023ec7843e2330bb462f19198840b34b6582397d" +dependencies = [ + "byteorder", + "keccak", + "rand_core", + "zeroize", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e" + +[[package]] +name = "pallet-contracts-uapi" +version = "9.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d7a51646d9ff1d91abd0186d2c074f0dfd3b1a2d55f08a229a2f2e4bc6d1e49" +dependencies = [ + "bitflags", + "paste", + "polkavm-derive", +] + +[[package]] +name = "parity-scale-codec" +version = "3.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9fde3d0718baf5bc92f577d652001da0f8d54cd03a7974e118d04fc888dc23d" +dependencies = [ + "arrayvec", + "bitvec", + "byte-slice-cast", + "const_format", + "impl-trait-for-tuples", + "parity-scale-codec-derive", + "rustversion", + "serde", +] + +[[package]] +name = "parity-scale-codec-derive" +version = "3.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "581c837bb6b9541ce7faa9377c20616e4fb7650f6b0f68bc93c827ee504fb7b3" +dependencies = [ + "proc-macro-crate 3.2.0", + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "polkavm-common" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d9428a5cfcc85c5d7b9fc4b6a18c4b802d0173d768182a51cc7751640f08b92" + +[[package]] +name = "polkavm-derive" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae8c4bea6f3e11cd89bb18bcdddac10bd9a24015399bd1c485ad68a985a19606" +dependencies = [ + "polkavm-derive-impl-macro", +] + +[[package]] +name = "polkavm-derive-impl" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c4fdfc49717fb9a196e74a5d28e0bc764eb394a2c803eb11133a31ac996c60c" +dependencies = [ + "polkavm-common", + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "polkavm-derive-impl-macro" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ba81f7b5faac81e528eb6158a6f3c9e0bb1008e0ffa19653bc8dea925ecb429" +dependencies = [ + "polkavm-derive-impl", + "syn 2.0.98", +] + +[[package]] +name = "pop-api" +version = "0.0.0" +dependencies = [ + "bitflags", + "enumflags2", + "ink", + "parity-scale-codec", + "pop-primitives", +] + +[[package]] +name = "pop-primitives" +version = "0.0.0" +dependencies = [ + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "proc-macro-crate" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" +dependencies = [ + "once_cell", + "toml_edit 0.19.15", +] + +[[package]] +name = "proc-macro-crate" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" +dependencies = [ + "toml_edit 0.22.24", +] + +[[package]] +name = "proc-macro2" +version = "1.0.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "regex" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" + +[[package]] +name = "rlibc" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc874b127765f014d792f16763a81245ab80500e2ad921ed4ee9e82481ee08fe" + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + +[[package]] +name = "rustversion" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4" + +[[package]] +name = "ryu" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "scale-bits" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "662d10dcd57b1c2a3c41c9cf68f71fb09747ada1ea932ad961aca7e2ca28315f" +dependencies = [ + "parity-scale-codec", + "scale-type-resolver", +] + +[[package]] +name = "scale-decode" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afc79ba56a1c742f5aeeed1f1801f3edf51f7e818f0a54582cac6f131364ea7b" +dependencies = [ + "derive_more 0.99.19", + "parity-scale-codec", + "scale-bits", + "scale-decode-derive", + "scale-type-resolver", + "smallvec", +] + +[[package]] +name = "scale-decode-derive" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5398fdb3c7bea3cb419bac4983aadacae93fe1a7b5f693f4ebd98c3821aad7a5" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "scale-encode" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "628800925a33794fb5387781b883b5e14d130fece9af5a63613867b8de07c5c7" +dependencies = [ + "derive_more 0.99.19", + "parity-scale-codec", + "scale-encode-derive", + "scale-type-resolver", + "smallvec", +] + +[[package]] +name = "scale-encode-derive" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a304e1af7cdfbe7a24e08b012721456cc8cecdedadc14b3d10513eada63233c" +dependencies = [ + "darling", + "proc-macro-crate 1.3.1", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "scale-info" +version = "2.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "346a3b32eba2640d17a9cb5927056b08f3de90f65b72fe09402c2ad07d684d0b" +dependencies = [ + "bitvec", + "cfg-if", + "derive_more 1.0.0", + "parity-scale-codec", + "scale-info-derive", + "schemars", + "serde", +] + +[[package]] +name = "scale-info-derive" +version = "2.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6630024bf739e2179b91fb424b28898baf819414262c5d376677dbff1fe7ebf" +dependencies = [ + "proc-macro-crate 3.2.0", + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "scale-type-resolver" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10b800069bfd43374e0f96f653e0d46882a2cb16d6d961ac43bea80f26c76843" +dependencies = [ + "smallvec", +] + +[[package]] +name = "schemars" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" +dependencies = [ + "dyn-clone", + "schemars_derive", + "serde", + "serde_json", +] + +[[package]] +name = "schemars_derive" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1eee588578aff73f856ab961cd2f79e36bc45d7ded33a7562adba4667aecc0e" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 2.0.98", +] + +[[package]] +name = "schnorrkel" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de18f6d8ba0aad7045f5feae07ec29899c1112584a38509a84ad7b04451eaa0" +dependencies = [ + "aead", + "arrayref", + "arrayvec", + "curve25519-dalek", + "getrandom_or_panic", + "merlin", + "rand_core", + "serde_bytes", + "sha2", + "subtle", + "zeroize", +] + +[[package]] +name = "secp256k1" +version = "0.28.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d24b59d129cdadea20aea4fb2352fa053712e5d713eee47d700cd4b2bc002f10" +dependencies = [ + "secp256k1-sys", +] + +[[package]] +name = "secp256k1-sys" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d1746aae42c19d583c3c1a8c646bfad910498e2051c551a7f2e3c0c9fbb7eb" +dependencies = [ + "cc", +] + +[[package]] +name = "semver" +version = "1.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f79dfe2d285b0488816f30e700a7438c5a73d816b5b7d3ac72fbc48b0d185e03" + +[[package]] +name = "serde" +version = "1.0.217" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_bytes" +version = "0.11.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "387cc504cb06bb40a96c8e04e951fe01854cf6bc921053c954e4a606d9675c6a" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_derive" +version = "1.0.217" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "serde_derive_internals" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "serde_json" +version = "1.0.138" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "serde_spanned" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" +dependencies = [ + "serde", +] + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sha3" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" +dependencies = [ + "digest", + "keccak", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "sp-arithmetic" +version = "26.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46d0d0a4c591c421d3231ddd5e27d828618c24456d51445d21a1f79fcee97c23" +dependencies = [ + "docify", + "integer-sqrt", + "num-traits", + "parity-scale-codec", + "scale-info", + "serde", + "sp-std", + "static_assertions", +] + +[[package]] +name = "sp-debug-derive" +version = "14.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48d09fa0a5f7299fb81ee25ae3853d26200f7a348148aed6de76be905c007dbe" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "sp-std" +version = "14.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12f8ee986414b0a9ad741776762f4083cd3a5128449b982a3919c4df36874834" + +[[package]] +name = "sp-weights" +version = "31.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93cdaf72a1dad537bbb130ba4d47307ebe5170405280ed1aa31fa712718a400e" +dependencies = [ + "bounded-collections", + "parity-scale-codec", + "scale-info", + "serde", + "smallvec", + "sp-arithmetic", + "sp-debug-derive", +] + +[[package]] +name = "staging-xcm" +version = "11.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aded0292274ad473250c22ed3deaf2d9ed47d15786d700e9e83ab7c1cad2ad44" +dependencies = [ + "array-bytes", + "bounded-collections", + "derivative", + "environmental", + "impl-trait-for-tuples", + "log", + "parity-scale-codec", + "scale-info", + "serde", + "sp-weights", + "xcm-procedural", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "toml" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd87a5cdd6ffab733b2f74bc4fd7ee5fff6634124999ac278c35fc78c6120148" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit 0.22.24", +] + +[[package]] +name = "toml_datetime" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.19.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow 0.5.40", +] + +[[package]] +name = "toml_edit" +version = "0.22.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "winnow 0.7.2", +] + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unicode-ident" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "winapi-util" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "winnow" +version = "0.5.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" +dependencies = [ + "memchr", +] + +[[package]] +name = "winnow" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59690dea168f2198d1a3b0cac23b8063efcd11012f10ae4698f284808c8ef603" +dependencies = [ + "memchr", +] + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + +[[package]] +name = "xcm-procedural" +version = "8.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4717a97970a9cda70d7db53cf50d2615c2f6f6b7c857445325b4a39ea7aa2cd" +dependencies = [ + "Inflector", + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "xxhash-rust" +version = "0.8.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdd20c5420375476fbd4394763288da7eb0cc0b8c11deed431a91562af7335d3" + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", +] diff --git a/pop-api/integration-tests/contracts/foreign_fungibles/Cargo.toml b/pop-api/integration-tests/contracts/foreign_fungibles/Cargo.toml new file mode 100755 index 000000000..abaabcfaf --- /dev/null +++ b/pop-api/integration-tests/contracts/foreign_fungibles/Cargo.toml @@ -0,0 +1,23 @@ +[package] +authors = [ "R0GUE " ] +edition = "2021" +name = "foreign_fungibles" +version = "0.1.0" + +[workspace] + +[dependencies] +ink = { version = "5.1.0", default-features = false } +pop-api = { path = "../../../../pop-api", default-features = false } + +[lib] +path = "lib.rs" + +[features] +default = [ "std" ] +e2e-tests = [ ] +ink-as-dependency = [ ] +std = [ + "ink/std", + "pop-api/std", +] diff --git a/pop-api/integration-tests/contracts/foreign_fungibles/lib.rs b/pop-api/integration-tests/contracts/foreign_fungibles/lib.rs new file mode 100644 index 000000000..fae2adc79 --- /dev/null +++ b/pop-api/integration-tests/contracts/foreign_fungibles/lib.rs @@ -0,0 +1,214 @@ +#![cfg_attr(not(feature = "std"), no_std, no_main)] + +/// 1. PSP-22 +/// 2. PSP-22 Metadata +/// 3. Management +/// 4. PSP-22 Mintable & Burnable +use ink::prelude::vec::Vec; +use pop_api::{ + v0::foreign_fungibles::{self as api, events::*, TokenId, *}, + StatusCode, +}; + +pub type Result = core::result::Result; + +#[ink::contract] +mod foreign_fungibles { + use super::*; + + #[ink(storage)] + #[derive(Default)] + pub struct ForeignFungibles; + + impl ForeignFungibles { + #[ink(constructor, payable)] + pub fn new() -> Self { + ink::env::debug_println!("PopApiFungiblesExample::new"); + Default::default() + } + + /// 1. PSP-22 Interface: + /// - total_supply + /// - balance_of + /// - allowance + /// - transfer + /// - transfer_from + /// - approve + /// - increase_allowance + /// - decrease_allowance + + #[ink(message)] + pub fn total_supply(&self, token: TokenId) -> Result { + api::total_supply(token) + } + + #[ink(message)] + pub fn balance_of(&self, token: TokenId, owner: AccountId) -> Result { + api::balance_of(token, owner) + } + + #[ink(message)] + pub fn allowance( + &self, + token: TokenId, + owner: AccountId, + spender: AccountId, + ) -> Result { + api::allowance(token, owner, spender) + } + + #[ink(message)] + pub fn transfer(&mut self, token: TokenId, to: AccountId, value: Balance) -> Result<()> { + api::transfer(token, to, value)?; + self.env().emit_event(Transfer { + from: Some(self.env().account_id()), + to: Some(to), + value, + }); + Ok(()) + } + + #[ink(message)] + pub fn transfer_from( + &mut self, + token: TokenId, + from: AccountId, + to: AccountId, + value: Balance, + // In the PSP-22 standard a `[u8]`, but the size needs to be known at compile time. + _data: Vec, + ) -> Result<()> { + api::transfer_from(token, from, to, value)?; + self.env().emit_event(Transfer { from: Some(from), to: Some(to), value }); + Ok(()) + } + + #[ink(message)] + pub fn approve( + &mut self, + token: TokenId, + spender: AccountId, + value: Balance, + ) -> Result<()> { + api::approve(token, spender, value)?; + self.env() + .emit_event(Approval { owner: self.env().account_id(), spender, value }); + Ok(()) + } + + #[ink(message)] + pub fn increase_allowance( + &mut self, + token: TokenId, + spender: AccountId, + value: Balance, + ) -> Result<()> { + api::increase_allowance(token, spender, value) + } + + #[ink(message)] + pub fn decrease_allowance( + &mut self, + token: TokenId, + spender: AccountId, + value: Balance, + ) -> Result<()> { + api::decrease_allowance(token, spender, value) + } + + /// 2. PSP-22 Metadata Interface: + /// - token_name + /// - token_symbol + /// - token_decimals + + #[ink(message)] + pub fn token_name(&self, token: TokenId) -> Result>> { + api::token_name(token) + } + + #[ink(message)] + pub fn token_symbol(&self, token: TokenId) -> Result>> { + api::token_symbol(token) + } + + #[ink(message)] + pub fn token_decimals(&self, token: TokenId) -> Result { + api::token_decimals(token) + } + + /// 3. Asset Management: + /// - create + /// - start_destroy + /// - set_metadata + /// - clear_metadata + /// - token_exists + + #[ink(message)] + pub fn create( + &mut self, + id: TokenId, + admin: AccountId, + min_balance: Balance, + ) -> Result<()> { + api::create(id.clone(), admin, min_balance)?; + self.env().emit_event(Created { id, creator: admin, admin }); + Ok(()) + } + + #[ink(message)] + pub fn start_destroy(&mut self, token: TokenId) -> Result<()> { + api::start_destroy(token.clone())?; + self.env().emit_event(DestroyStarted { token }); + Ok(()) + } + + #[ink(message)] + pub fn set_metadata( + &mut self, + token: TokenId, + name: Vec, + symbol: Vec, + decimals: u8, + ) -> Result<()> { + api::set_metadata(token.clone(), name.clone(), symbol.clone(), decimals)?; + self.env().emit_event(MetadataSet { token, name, symbol, decimals }); + Ok(()) + } + + #[ink(message)] + pub fn clear_metadata(&mut self, token: TokenId) -> Result<()> { + api::clear_metadata(token.clone())?; + self.env().emit_event(MetadataCleared { token }); + Ok(()) + } + + #[ink(message)] + pub fn token_exists(&self, token: TokenId) -> Result { + api::token_exists(token) + } + + /// 4. PSP-22 Mintable & Burnable Interface: + /// - mint + /// - burn + + #[ink(message)] + pub fn mint(&mut self, token: TokenId, account: AccountId, amount: Balance) -> Result<()> { + api::mint(token, account, amount) + } + + #[ink(message)] + pub fn burn(&mut self, token: TokenId, account: AccountId, amount: Balance) -> Result<()> { + api::burn(token, account, amount) + } + } + + #[cfg(test)] + mod tests { + use super::*; + + #[ink::test] + fn default_works() { + PopApiFungiblesExample::new(); + } + } +}