Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spike foreign fungibles v2 #474

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Conversation

Daanvdplas
Copy link
Collaborator

@Daanvdplas Daanvdplas commented Feb 18, 2025

(Close annotations in the Files changed section by clicking the right corner 3 dots when reviewing because I only pushed the relevant bits)

Shows how we can implement the foreign fungibles functionality by creating a wrapper type in the fungibles pallet & api. This reduces the amount of duplicate code but adds some complexity to the pallet (i.e. benchmarking, types).

See latest commit to get a feel for the contract. This is just the fungibles contract updated and can both be used for the fungibles as foreign fungibles use case.

Fungibles contract without foreign_fungibles feature enabled: 14.5K (see latest commit), disabled: 22.8K (fungibles contract was 14.2K)

Integrations tests for transfer and balance_of are working.

@Daanvdplas Daanvdplas marked this pull request as draft February 18, 2025 11:56
@@ -499,7 +594,7 @@ pub mod pallet {
fn weight(request: &Self::Read) -> Weight {
use Read::*;
match request {
TotalSupply(_) => <T as Config>::WeightInfo::total_supply(),
TotalSupply(id) => <T as Config>::WeightInfo::total_supply(weight_param(id)),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hasn't been tested but applied to show how the weight can be handled for the read functions.

@Daanvdplas Daanvdplas force-pushed the daan/feat-foreign_fungibles_v2 branch from 253d80e to 142072c Compare February 18, 2025 12:22
@@ -108,10 +108,14 @@ mod benchmarks {

#[benchmark]
// Storage: `Assets`
fn total_supply() {
fn total_supply(a: Linear<0, 1>) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not tested but I was thinking to implement it this way if we went this route.

type TrustBackedAssetsInstance;
/// The asset instance for foreign assets.
type ForeignAssetsInstance;
type Balance: Parameter
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Complex Balance type unfortunately

ChainExtensionMethodApi, Result, StatusCode,
};

pub mod errors;
pub mod events;
pub mod traits;

#[derive(Debug, PartialEq, Eq, Clone)]
#[ink::scale_derive(Encode, Decode, TypeInfo)]
pub enum TokenId {
Copy link
Collaborator Author

@Daanvdplas Daanvdplas Feb 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only change required in the fungibles api crate apart from the XCM stuff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant