1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#![cfg_attr(not(feature = "std"), no_std)]
use codec::Codec;
use frame_support::inherent::Vec;
use sp_runtime::DispatchError;
use tidefi_primitives::{
BalanceInfo, BlockNumber, CurrencyBalance, CurrencyId, CurrencyMetadata, Stake,
};
type CurrenciesMetadata = (CurrencyId, CurrencyMetadata<Vec<u8>>);
type CurrenciesStake = (CurrencyId, Stake<BalanceInfo, BlockNumber>);
sp_api::decl_runtime_apis! {
pub trait TidefiApi<AccountId> where AccountId: Codec,
{
fn get_account_balance(account_id: AccountId, asset_id: CurrencyId) -> Result<CurrencyBalance<BalanceInfo>, DispatchError>;
fn get_account_balances(account_id: AccountId) -> Result<Vec<(CurrencyId, CurrencyBalance<BalanceInfo>)>, DispatchError>;
fn get_account_stakes(account_id: AccountId) -> Result<Vec<CurrenciesStake>, DispatchError>;
fn get_assets() -> Result<Vec<CurrenciesMetadata>, DispatchError>;
}
}