Skip to content

Commit

Permalink
Make Client generic
Browse files Browse the repository at this point in the history
  • Loading branch information
ascjones committed Nov 27, 2023
1 parent a74d787 commit a7870f7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
12 changes: 4 additions & 8 deletions crates/extrinsics/src/contract_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ use std::fmt::{
use scale::Decode;
use std::option::Option;
use subxt::{
backend::{
legacy::LegacyRpcMethods,
BlockRef,
},
backend::legacy::LegacyRpcMethods,
dynamic::DecodedValueThunk,
error::DecodeError,
ext::{
Expand All @@ -51,17 +48,17 @@ use subxt::{
storage::dynamic,
utils::AccountId32,
Config,
OnlineClient,
};

/// Return the account data for an account ID.
async fn get_account_balance<C: Config>(
account: &C::AccountId,
rpc: &LegacyRpcMethods<C>,
client: &Client,
client: &OnlineClient<C>,
) -> Result<AccountData>
where
C::AccountId: AsRef<[u8]>,
BlockRef<sp_core::H256>: From<C::Hash>,
{
let storage_query =
subxt::dynamic::storage("System", "Account", vec![Value::from_bytes(account)]);
Expand All @@ -82,12 +79,11 @@ where
pub async fn fetch_contract_info<C: Config>(
contract: &C::AccountId,
rpc: &LegacyRpcMethods<C>,
client: &Client,
client: &OnlineClient<C>,
) -> Result<ContractInfo>
where
C::AccountId: AsRef<[u8]> + Display + IntoVisitor,
DecodeError: From<<<C::AccountId as IntoVisitor>::Visitor as Visitor>::Error>,
BlockRef<sp_core::H256>: From<C::Hash>,
{
let best_block = get_best_block(rpc).await?;

Expand Down
8 changes: 3 additions & 5 deletions crates/extrinsics/src/contract_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ use subxt::{
rpc_params,
RpcClient,
},
BlockRef,
},
error::DecodeError,
ext::scale_decode::{
Expand All @@ -50,7 +49,6 @@ use subxt::{
use super::{
fetch_contract_info,
url_to_string,
Client,
ContractInfo,
DefaultConfig,
TrieId,
Expand All @@ -64,7 +62,7 @@ impl<C: Config> ContractStorage<C>
where
C::AccountId: AsRef<[u8]> + Display + IntoVisitor,
DecodeError: From<<<C::AccountId as IntoVisitor>::Visitor as Visitor>::Error>,
BlockRef<sp_core::H256>: From<C::Hash>,
// BlockRef<sp_core::H256>: From<C::Hash>,
{
pub fn new(rpc: ContractStorageRpc<C>) -> Self {
Self { rpc }
Expand Down Expand Up @@ -219,14 +217,14 @@ pub struct ContractStorageCell {
pub struct ContractStorageRpc<C: Config> {
rpc_client: RpcClient,
rpc_methods: LegacyRpcMethods<C>,
client: Client,
client: OnlineClient<C>,
}

impl<C: Config> ContractStorageRpc<C>
where
C::AccountId: AsRef<[u8]> + Display + IntoVisitor,
DecodeError: From<<<C::AccountId as IntoVisitor>::Visitor as Visitor>::Error>,
BlockRef<sp_core::H256>: From<C::Hash>,
// BlockRef<sp_core::H256>: From<C::Hash>,
{
/// Create a new instance of the ContractsRpc.
pub async fn new(url: &url::Url) -> Result<Self> {
Expand Down

0 comments on commit a7870f7

Please sign in to comment.