difftreelog
fix some rpc fixes
in: master
3 files changed
client/rpc/src/lib.rsdiffbeforeafterboth--- a/client/rpc/src/lib.rs
+++ b/client/rpc/src/lib.rs
@@ -412,47 +412,27 @@
}
}
-pub struct Unique<C, P> {
- client: Arc<C>,
- _marker: std::marker::PhantomData<P>,
-}
-
-impl<C, P> Unique<C, P> {
- pub fn new(client: Arc<C>) -> Self {
- Self {
- client,
- _marker: Default::default(),
+macro_rules! define_struct_for_server_api {
+ ($name:ident) => {
+ pub struct $name<C, P> {
+ client: Arc<C>,
+ _marker: std::marker::PhantomData<P>,
}
- }
-}
-
-pub struct AppPromotion<C, P> {
- client: Arc<C>,
- _marker: std::marker::PhantomData<P>,
-}
-
-impl<C, P> AppPromotion<C, P> {
- pub fn new(client: Arc<C>) -> Self {
- Self {
- client,
- _marker: Default::default(),
+
+ impl<C, P> $name<C, P> {
+ pub fn new(client: Arc<C>) -> Self {
+ Self {
+ client,
+ _marker: Default::default(),
+ }
+ }
}
- }
-}
-
-pub struct Rmrk<C, P> {
- client: Arc<C>,
- _marker: std::marker::PhantomData<P>,
+ };
}
-impl<C, P> Rmrk<C, P> {
- pub fn new(client: Arc<C>) -> Self {
- Self {
- client,
- _marker: Default::default(),
- }
- }
-}
+define_struct_for_server_api!(Unique);
+define_struct_for_server_api!(AppPromotion);
+define_struct_for_server_api!(Rmrk);
macro_rules! pass_method {
(
@@ -605,14 +585,14 @@
|v| v
.into_iter()
.map(|(b, a)| (b, a.to_string()))
- .collect::<Vec<_>>(), unique_api);
- pass_method!(total_staking_locked(staker: CrossAccountId) -> String => |v| v.to_string(), unique_api);
- pass_method!(pending_unstake(staker: Option<CrossAccountId>) -> String => |v| v.to_string(), unique_api);
+ .collect::<Vec<_>>(), app_promotion_api);
+ pass_method!(total_staking_locked(staker: CrossAccountId) -> String => |v| v.to_string(), app_promotion_api);
+ pass_method!(pending_unstake(staker: Option<CrossAccountId>) -> String => |v| v.to_string(), app_promotion_api);
pass_method!(pending_unstake_per_block(staker: CrossAccountId) -> Vec<(BlockNumber, String)> =>
|v| v
.into_iter()
.map(|(b, a)| (b, a.to_string()))
- .collect::<Vec<_>>(), unique_api);
+ .collect::<Vec<_>>(), app_promotion_api);
}
#[allow(deprecated)]
node/rpc/src/lib.rsdiffbeforeafterboth--- a/node/rpc/src/lib.rs
+++ b/node/rpc/src/lib.rs
@@ -38,7 +38,6 @@
use sp_block_builder::BlockBuilder;
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
use sc_service::TransactionPool;
-use uc_rpc::AppPromotion;
use std::{collections::BTreeMap, sync::Arc};
use up_common::types::opaque::{Hash, AccountId, RuntimeInstance, Index, Block, BlockNumber, Balance};
@@ -232,7 +231,7 @@
io.merge(Unique::new(client.clone()).into_rpc())?;
- // #[cfg(not(feature = "unique-runtime"))]
+ #[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]
io.merge(AppPromotion::new(client.clone()).into_rpc())?;
#[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 **/