Skip to content

Commit

Permalink
push for visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Daanvdplas committed May 20, 2024
1 parent a13b9a0 commit d88ee51
Show file tree
Hide file tree
Showing 21 changed files with 829 additions and 639 deletions.
2 changes: 1 addition & 1 deletion pop-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ scale-info = { version = "2.6", default-features = false, features = ["derive"]
sp-io = { version = "23.0.0", default-features = false, features = ["disable_panic_handler", "disable_oom", "disable_allocator"] }
sp-runtime = { version = "24.0", default-features = false }

pop-primitives = { path = "../primitives", default-features = false }
pop-primitives = { path = "../primitives", features = ["devnet"], default-features = false }

[lib]
name = "pop_api"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "pop_api_trust_backed_assets_example"
name = "fungibles"
version = "0.1.0"
authors = ["[your_name] <[your_email]>"]
edition = "2021"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,48 @@
#![cfg_attr(not(feature = "std"), no_std, no_main)]

// Utilizing Trust Backed Assets with the Pop API.
//
// This example demonstrates interaction with trust backed assets via the assets pallet. Trust backed assets are originated
// and managed within Pop Network, harnessing the platform's inherent trust, security, and governance models.
use pop_api::assets::trust_backed as assets;
// Using fungible assets with the Pop API.
use pop_api::assets::fungibles;

#[derive(Debug, Copy, Clone, PartialEq, Eq, scale::Encode, scale::Decode)]
#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))]
pub enum ContractError {
AssetsError(assets::Error),
AssetsError(Error),
UnknownAsset,
}

impl From<assets::Error> for ContractError {
fn from(value: assets::Error) -> Self {
impl From<Error> for ContractError {
fn from(value: Error) -> Self {
ContractError::AssetsError(value)
}
}

#[ink::contract(env = pop_api::Environment)]
mod pop_api_assets_example {
mod fungibles {
use super::*;

#[ink(storage)]
#[derive(Default)]
pub struct PopApiAssetsExample;
pub struct Fungibles;

impl PopApiAssetsExample {
impl Fungibles {
#[ink(constructor, payable)]
pub fn new() -> Self {
ink::env::debug_println!("PopApiAssetsExample::new");
Default::default()
}

#[ink(message)]
pub fn mint_asset_through_runtime(
pub fn token_supply(id: AssetId) -> Result<Balance, ContractError> {
token_supply(id)?
}

#[ink(message)]
pub fn token_name(id: AssetId) -> Result<Option<Vec<u8>>, ContractError> {
token_name(id)
}

#[ink(message)]
pub fn mint_asset(
&mut self,
id: u32,
beneficiary: AccountId,
Expand Down
6 changes: 3 additions & 3 deletions pop-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pub mod primitives;
pub mod v0;

use crate::PopApiError::{Balances, Nfts, TrustBackedAssets, UnknownStatusCode};
use crate::PopApiError::{Balances, Nfts, Assets, UnknownStatusCode};
use ink::{prelude::vec::Vec, ChainExtensionInstance};
use primitives::{cross_chain::*, storage_keys::*};
pub use sp_runtime::{BoundedVec, MultiAddress, MultiSignature};
Expand All @@ -26,7 +26,7 @@ pub enum PopApiError {
SystemCallFiltered,
Balances(balances::Error),
Nfts(nfts::Error),
TrustBackedAssets(assets::trust_backed::Error),
Assets(assets::fungibles::Error),
Xcm(cross_chain::Error),
}

Expand All @@ -38,7 +38,7 @@ impl ink::env::chain_extension::FromStatusCode for PopApiError {
5 => Err(PopApiError::SystemCallFiltered),
10_000..=10_999 => Err(Balances((status_code - 10_000).try_into()?)),
50_000..=50_999 => Err(Nfts((status_code - 50_000).try_into()?)),
52_000..=52_999 => Err(TrustBackedAssets((status_code - 52_000).try_into()?)),
52_000..=52_999 => Err(Assets((status_code - 52_000).try_into()?)),
_ => Err(UnknownStatusCode(status_code)),
}
}
Expand Down
Loading

0 comments on commit d88ee51

Please sign in to comment.