Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Assets balances
  • Loading branch information
Jegor Sidorenko committed Feb 13, 2023
commit fc48530259272820b3a03e5fac3a1a3f44c7776c
34 changes: 34 additions & 0 deletions parachains/runtimes/assets/statemine/src/assets_api.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// This file is part of Substrate.

// Copyright (C) 2018-2022 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

//! Runtime API definition for assets.

use codec::Codec;
use sp_std::vec::Vec;

sp_api::decl_runtime_apis! {
pub trait AssetsApi<AccountId, AssetBalance, AssetId>
where
AccountId: Codec,
AssetBalance: Codec,
AssetId: Codec,
{
/// Returns the list of asset id and non-zero balances the AccountId has.
fn account_balances(account: AccountId) -> Vec<(AssetId, AssetBalance)>;
}
}
13 changes: 13 additions & 0 deletions parachains/runtimes/assets/statemine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#[cfg(feature = "std")]
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));

pub mod assets_api;
pub mod constants;
mod weights;
pub mod xcm_config;
Expand Down Expand Up @@ -831,6 +832,18 @@ impl_runtime_apis! {
}
}

impl assets_api::AssetsApi<
Block,
AccountId,
Balance,
AssetIdForTrustBackedAssets,
> for Runtime
{
fn account_balances(account: AccountId) -> Vec<(AssetIdForTrustBackedAssets, Balance)> {
Assets::account_balances(account)
}
}

impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {
fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {
ParachainSystem::collect_collation_info(header)
Expand Down
34 changes: 34 additions & 0 deletions parachains/runtimes/assets/statemint/src/assets_api.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// This file is part of Substrate.

// Copyright (C) 2018-2022 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

//! Runtime API definition for assets.

use codec::Codec;
use sp_std::vec::Vec;

sp_api::decl_runtime_apis! {
pub trait AssetsApi<AccountId, AssetBalance, AssetId>
where
AccountId: Codec,
AssetBalance: Codec,
AssetId: Codec,
{
/// Returns the list of asset id and non-zero balances the AccountId has.
fn account_balances(account: AccountId) -> Vec<(AssetId, AssetBalance)>;
}
}
13 changes: 13 additions & 0 deletions parachains/runtimes/assets/statemint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#[cfg(feature = "std")]
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));

pub mod assets_api;
pub mod constants;
mod weights;
pub mod xcm_config;
Expand Down Expand Up @@ -828,6 +829,18 @@ impl_runtime_apis! {
}
}

impl assets_api::AssetsApi<
Block,
AccountId,
Balance,
AssetIdForTrustBackedAssets,
> for Runtime
{
fn account_balances(account: AccountId) -> Vec<(AssetIdForTrustBackedAssets, Balance)> {
Assets::account_balances(account)
}
}

impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {
fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {
ParachainSystem::collect_collation_info(header)
Expand Down
34 changes: 34 additions & 0 deletions parachains/runtimes/assets/westmint/src/assets_api.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// This file is part of Substrate.

// Copyright (C) 2018-2022 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

//! Runtime API definition for assets.

use codec::Codec;
use sp_std::vec::Vec;

sp_api::decl_runtime_apis! {
pub trait AssetsApi<AccountId, AssetBalance, AssetId>
where
AccountId: Codec,
AssetBalance: Codec,
AssetId: Codec,
{
/// Returns the list of asset id and non-zero balances the AccountId has.
fn account_balances(account: AccountId) -> Vec<(AssetId, AssetBalance)>;
}
}
13 changes: 13 additions & 0 deletions parachains/runtimes/assets/westmint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#[cfg(feature = "std")]
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));

pub mod assets_api;
pub mod constants;
mod weights;
pub mod xcm_config;
Expand Down Expand Up @@ -840,6 +841,18 @@ impl_runtime_apis! {
}
}

impl assets_api::AssetsApi<
Block,
AccountId,
Balance,
AssetIdForTrustBackedAssets,
> for Runtime
{
fn account_balances(account: AccountId) -> Vec<(AssetIdForTrustBackedAssets, Balance)> {
Assets::account_balances(account)
}
}

impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {
fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {
ParachainSystem::collect_collation_info(header)
Expand Down