difftreelog
fix some rpc fixes
in: master
3 files changed
client/rpc/src/lib.rsdiffbeforeafterboth412 }412 }413}413}414414415pub struct Unique<C, P> {415macro_rules! define_struct_for_server_api {416 client: Arc<C>,416 ($name:ident) => {417 _marker: std::marker::PhantomData<P>,417 pub struct $name<C, P> {418}418 client: Arc<C>,419419 _marker: std::marker::PhantomData<P>,420 }421 420impl<C, P> Unique<C, P> {422 impl<C, P> $name<C, P> {421 pub fn new(client: Arc<C>) -> Self {423 pub fn new(client: Arc<C>) -> Self {422 Self {424 Self {423 client,425 client,424 _marker: Default::default(),426 _marker: Default::default(),425 }427 }426 }428 }427}429 }428430 };429pub struct AppPromotion<C, P> {431}430 client: Arc<C>,432431 _marker: std::marker::PhantomData<P>,433define_struct_for_server_api!(Unique);432}433434impl<C, P> AppPromotion<C, P> {434define_struct_for_server_api!(AppPromotion);435 pub fn new(client: Arc<C>) -> Self {436 Self {437 client,438 _marker: Default::default(),439 }440 }441}442443pub struct Rmrk<C, P> {444 client: Arc<C>,445 _marker: std::marker::PhantomData<P>,446}447448impl<C, P> Rmrk<C, P> {435define_struct_for_server_api!(Rmrk);449 pub fn new(client: Arc<C>) -> Self {450 Self {451 client,452 _marker: Default::default(),453 }454 }455}456436457macro_rules! pass_method {437macro_rules! pass_method {458 (438 (605 |v| v585 |v| v606 .into_iter()586 .into_iter()607 .map(|(b, a)| (b, a.to_string()))587 .map(|(b, a)| (b, a.to_string()))608 .collect::<Vec<_>>(), unique_api);588 .collect::<Vec<_>>(), app_promotion_api);609 pass_method!(total_staking_locked(staker: CrossAccountId) -> String => |v| v.to_string(), unique_api);589 pass_method!(total_staking_locked(staker: CrossAccountId) -> String => |v| v.to_string(), app_promotion_api);610 pass_method!(pending_unstake(staker: Option<CrossAccountId>) -> String => |v| v.to_string(), unique_api);590 pass_method!(pending_unstake(staker: Option<CrossAccountId>) -> String => |v| v.to_string(), app_promotion_api);611 pass_method!(pending_unstake_per_block(staker: CrossAccountId) -> Vec<(BlockNumber, String)> =>591 pass_method!(pending_unstake_per_block(staker: CrossAccountId) -> Vec<(BlockNumber, String)> =>612 |v| v592 |v| v613 .into_iter()593 .into_iter()614 .map(|(b, a)| (b, a.to_string()))594 .map(|(b, a)| (b, a.to_string()))615 .collect::<Vec<_>>(), unique_api);595 .collect::<Vec<_>>(), app_promotion_api);616}596}617597618#[allow(deprecated)]598#[allow(deprecated)]node/rpc/src/lib.rsdiffbeforeafterboth38use sp_block_builder::BlockBuilder;38use sp_block_builder::BlockBuilder;39use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};39use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};40use sc_service::TransactionPool;40use sc_service::TransactionPool;41use uc_rpc::AppPromotion;42use std::{collections::BTreeMap, sync::Arc};41use std::{collections::BTreeMap, sync::Arc};434244use up_common::types::opaque::{Hash, AccountId, RuntimeInstance, Index, Block, BlockNumber, Balance};43use up_common::types::opaque::{Hash, AccountId, RuntimeInstance, Index, Block, BlockNumber, Balance};232231233 io.merge(Unique::new(client.clone()).into_rpc())?;232 io.merge(Unique::new(client.clone()).into_rpc())?;234233235 // #[cfg(not(feature = "unique-runtime"))]234 #[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]236 io.merge(AppPromotion::new(client.clone()).into_rpc())?;235 io.merge(AppPromotion::new(client.clone()).into_rpc())?;237236238 #[cfg(not(feature = "unique-runtime"))]237 #[cfg(not(feature = "unique-runtime"))]tests/src/interfaces/augment-api-query.tsdiffbeforeafterboth6import '@polkadot/api-base/types/storage';6import '@polkadot/api-base/types/storage';778import type { ApiTypes, AugmentedQuery, QueryableStorageEntry } from '@polkadot/api-base/types';8import type { ApiTypes, AugmentedQuery, QueryableStorageEntry } from '@polkadot/api-base/types';9import type { BTreeMap, Bytes, Option, U256, U8aFixed, Vec, bool, u128, u16, u32, u64 } from '@polkadot/types-codec';9import type { BTreeMap, Bytes, Option, U256, U8aFixed, Vec, bool, u128, u16, u32, u64, u8 } from '@polkadot/types-codec';10import type { AnyNumber, ITuple } from '@polkadot/types-codec/types';10import type { AnyNumber, ITuple } from '@polkadot/types-codec/types';11import type { AccountId32, H160, H256 } from '@polkadot/types/interfaces/runtime';11import type { AccountId32, H160, H256 } from '@polkadot/types/interfaces/runtime';12import type { CumulusPalletDmpQueueConfigData, CumulusPalletDmpQueuePageIndexData, CumulusPalletParachainSystemRelayStateSnapshotMessagingStateSnapshot, CumulusPalletXcmpQueueInboundChannelDetails, CumulusPalletXcmpQueueOutboundChannelDetails, CumulusPalletXcmpQueueQueueConfigData, EthereumBlock, EthereumLog, EthereumReceiptReceiptV3, EthereumTransactionTransactionV2, FpRpcTransactionStatus, FrameSupportWeightsPerDispatchClassU64, FrameSystemAccountInfo, FrameSystemEventRecord, FrameSystemLastRuntimeUpgradeInfo, FrameSystemPhase, OrmlVestingVestingSchedule, PalletBalancesAccountData, PalletBalancesBalanceLock, PalletBalancesReleases, PalletBalancesReserveData, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmContractHelpersSponsoringModeT, PalletNonfungibleItemData, PalletRefungibleItemData, PalletTransactionPaymentReleases, PalletTreasuryProposal, PalletUniqueSchedulerScheduledV3, PhantomTypeUpDataStructs, PolkadotCorePrimitivesOutboundHrmpMessage, PolkadotPrimitivesV2AbridgedHostConfiguration, PolkadotPrimitivesV2PersistedValidationData, PolkadotPrimitivesV2UpgradeRestriction, SpRuntimeDigest, SpTrieStorageProof, UpDataStructsCollection, UpDataStructsCollectionStats, UpDataStructsProperties, UpDataStructsPropertiesMapPropertyPermission, UpDataStructsPropertyPermission, UpDataStructsPropertyScope, UpDataStructsSponsorshipStateBasicCrossAccountIdRepr, UpDataStructsTokenChild } from '@polkadot/types/lookup';12import type { CumulusPalletDmpQueueConfigData, CumulusPalletDmpQueuePageIndexData, CumulusPalletParachainSystemRelayStateSnapshotMessagingStateSnapshot, CumulusPalletXcmpQueueInboundChannelDetails, CumulusPalletXcmpQueueOutboundChannelDetails, CumulusPalletXcmpQueueQueueConfigData, EthereumBlock, EthereumLog, EthereumReceiptReceiptV3, EthereumTransactionTransactionV2, FpRpcTransactionStatus, FrameSupportWeightsPerDispatchClassU64, FrameSystemAccountInfo, FrameSystemEventRecord, FrameSystemLastRuntimeUpgradeInfo, FrameSystemPhase, OrmlVestingVestingSchedule, PalletBalancesAccountData, PalletBalancesBalanceLock, PalletBalancesReleases, PalletBalancesReserveData, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmContractHelpersSponsoringModeT, PalletNonfungibleItemData, PalletRefungibleItemData, PalletTransactionPaymentReleases, PalletTreasuryProposal, PalletUniqueSchedulerScheduledV3, PhantomTypeUpDataStructs, PolkadotCorePrimitivesOutboundHrmpMessage, PolkadotPrimitivesV2AbridgedHostConfiguration, PolkadotPrimitivesV2PersistedValidationData, PolkadotPrimitivesV2UpgradeRestriction, SpRuntimeDigest, SpTrieStorageProof, UpDataStructsCollection, UpDataStructsCollectionStats, UpDataStructsProperties, UpDataStructsPropertiesMapPropertyPermission, UpDataStructsPropertyPermission, UpDataStructsPropertyScope, UpDataStructsSponsorshipStateBasicCrossAccountIdRepr, UpDataStructsTokenChild } from '@polkadot/types/lookup';512 };512 };513 promotion: {513 promotion: {514 admin: AugmentedQuery<ApiType, () => Observable<Option<AccountId32>>, []> & QueryableStorageEntry<ApiType, []>;514 admin: AugmentedQuery<ApiType, () => Observable<Option<AccountId32>>, []> & QueryableStorageEntry<ApiType, []>;515 /**515 /**516 * Stores the address of the staker for which the last revenue recalculation was performed.516 * Stores hash a record for which the last revenue recalculation was performed.517 * If `None`, then recalculation has not yet been performed or calculations have been completed for all stakers.517 * If `None`, then recalculation has not yet been performed or calculations have been completed for all stakers.518 **/518 **/519 lastCalcucaltedStaker: AugmentedQuery<ApiType, () => Observable<Option<AccountId32>>, []> & QueryableStorageEntry<ApiType, []>;519 nextCalculatedRecord: AugmentedQuery<ApiType, () => Observable<Option<ITuple<[AccountId32, u32]>>>, []> & QueryableStorageEntry<ApiType, []>;520 /**520 /**521 * Next target block when interest is recalculated521 * Next target block when interest is recalculated522 **/522 **/529 * Amount of tokens staked by account in the blocknumber.529 * Amount of tokens staked by account in the blocknumber.530 **/530 **/531 staked: AugmentedQuery<ApiType, (arg1: AccountId32 | string | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<ITuple<[u128, u32]>>, [AccountId32, u32]> & QueryableStorageEntry<ApiType, [AccountId32, u32]>;531 staked: AugmentedQuery<ApiType, (arg1: AccountId32 | string | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<ITuple<[u128, u32]>>, [AccountId32, u32]> & QueryableStorageEntry<ApiType, [AccountId32, u32]>;532 /**533 * Amount of stakes for an Account534 **/535 stakesPerAccount: AugmentedQuery<ApiType, (arg: AccountId32 | string | Uint8Array) => Observable<u8>, [AccountId32]> & QueryableStorageEntry<ApiType, [AccountId32]>;532 /**536 /**533 * A block when app-promotion has started .I think this is redundant, because we only need `NextInterestBlock`.537 * A block when app-promotion has started .I think this is redundant, because we only need `NextInterestBlock`.534 **/538 **/