Skip to content

Commit

Permalink
feat: api fungibles pallet (#113)
Browse files Browse the repository at this point in the history
Co-authored-by: Frank Bell <[email protected]>
  • Loading branch information
2 people authored and chungquantin committed Sep 6, 2024
1 parent bfcd2bc commit c6a22af
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 621 deletions.
46 changes: 23 additions & 23 deletions pallets/api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
name = "pallet-api"
authors.workspace = true
description = "API pallet, enabling smart(er) contracts with the power of Polkadot"
edition.workspace = true
license.workspace = true
name = "pallet-api"
version = "0.1.0"

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
targets = [ "x86_64-unknown-linux-gnu" ]

[dependencies]
codec.workspace = true
Expand All @@ -31,30 +31,30 @@ sp-core.workspace = true
sp-io.workspace = true

[features]
default = ["std"]
default = [ "std" ]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
std = [
"codec/std",
"frame-benchmarking/std",
"frame-support/std",
"frame-system/std",
"pallet-assets/std",
"pallet-balances/std",
"pop-chain-extension/std",
"scale-info/std",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"sp-std/std",
"codec/std",
"frame-benchmarking/std",
"frame-support/std",
"frame-system/std",
"pallet-assets/std",
"pallet-balances/std",
"pop-chain-extension/std",
"scale-info/std",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"sp-std/std",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"sp-runtime/try-runtime",
"frame-support/try-runtime",
"frame-system/try-runtime",
"sp-runtime/try-runtime",
]
2 changes: 1 addition & 1 deletion primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ pub mod v0 {
}

/// Description of what went wrong when trying to complete an operation on a token.
#[derive(Encode, Decode, Clone, Debug, MaxEncodedLen, Eq, PartialEq, Ord, PartialOrd)]
#[derive(Encode, Decode, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "std", derive(TypeInfo))]
pub enum TokenError {
/// Funds are unavailable.
Expand Down
34 changes: 34 additions & 0 deletions runtime/devnet/src/config/api.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
use crate::{config::assets::TrustBackedAssetsInstance, fungibles, Runtime, RuntimeCall};
use codec::{Decode, Encode, MaxEncodedLen};
use frame_support::traits::Contains;

/// A query of runtime state.
#[derive(Encode, Decode, Debug, MaxEncodedLen)]
#[repr(u8)]
pub enum RuntimeRead<T: fungibles::Config> {
/// Fungible token queries.
#[codec(index = 150)]
Fungibles(fungibles::Read<T>),
}

impl fungibles::Config for Runtime {
type AssetsInstance = TrustBackedAssetsInstance;
type WeightInfo = fungibles::weights::SubstrateWeight<Runtime>;
}

/// A type to identify allowed calls to the Runtime from contracts. Used by Pop API
pub struct AllowedApiCalls;

impl Contains<RuntimeCall> for AllowedApiCalls {
fn contains(c: &RuntimeCall) -> bool {
use fungibles::Call as FungiblesCall;
matches!(
c,
RuntimeCall::Fungibles(
FungiblesCall::transfer { .. }
| FungiblesCall::approve { .. }
| FungiblesCall::increase_allowance { .. }
)
)
}
}
221 changes: 0 additions & 221 deletions runtime/devnet/src/extensions/mod.rs

This file was deleted.

Loading

0 comments on commit c6a22af

Please sign in to comment.