mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 20:31:13 +00:00
add remaining RPCs
This commit is contained in:
@@ -15,11 +15,17 @@
|
||||
// along with subxt. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use subxt::{
|
||||
rpc::SubxtRpcApiClient,
|
||||
ClientBuilder,
|
||||
Config,
|
||||
DefaultConfig,
|
||||
DefaultExtra,
|
||||
};
|
||||
|
||||
type Hash = <DefaultConfig as Config>::Hash;
|
||||
type Header = <DefaultConfig as Config>::Header;
|
||||
type Extrinsic = <DefaultConfig as Config>::Header;
|
||||
|
||||
#[subxt::subxt(runtime_metadata_path = "examples/polkadot_metadata.scale")]
|
||||
pub mod polkadot {}
|
||||
|
||||
@@ -35,11 +41,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
let block_number = 1;
|
||||
|
||||
let block_hash = api
|
||||
.client
|
||||
.rpc()
|
||||
.block_hash(Some(block_number.into()))
|
||||
.await?;
|
||||
let block_hash = SubxtRpcApiClient::<Hash, Header, Extrinsic>::block_hash(
|
||||
api.client.rpc().inner(),
|
||||
Some(block_number.into()),
|
||||
)
|
||||
.await?;
|
||||
|
||||
if let Some(hash) = block_hash {
|
||||
println!("Block hash for block number {}: {}", block_number, hash);
|
||||
|
||||
@@ -24,13 +24,20 @@
|
||||
|
||||
use sp_keyring::AccountKeyring;
|
||||
use subxt::{
|
||||
rpc::SubxtRpcApiClient,
|
||||
ClientBuilder,
|
||||
Config,
|
||||
DefaultConfig,
|
||||
DefaultExtra,
|
||||
EventStorageSubscription,
|
||||
EventSubscription,
|
||||
PairSigner,
|
||||
};
|
||||
|
||||
type Hash = <DefaultConfig as Config>::Hash;
|
||||
type Header = <DefaultConfig as Config>::Header;
|
||||
type Extrinsic = <DefaultConfig as Config>::Header;
|
||||
|
||||
#[subxt::subxt(runtime_metadata_path = "examples/polkadot_metadata.scale")]
|
||||
pub mod polkadot {}
|
||||
|
||||
@@ -46,7 +53,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.await?
|
||||
.to_runtime_api::<polkadot::RuntimeApi<DefaultConfig, DefaultExtra<DefaultConfig>>>();
|
||||
|
||||
let sub = api.client.rpc().subscribe_events().await?;
|
||||
let sub = SubxtRpcApiClient::<Hash, Header, Extrinsic>::subscribe_events(
|
||||
api.client.rpc().inner(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
let sub = EventStorageSubscription::Imported(sub);
|
||||
let decoder = api.client.events_decoder();
|
||||
let mut sub = EventSubscription::<DefaultConfig>::new(sub, decoder);
|
||||
sub.filter_event::<polkadot::balances::events::Transfer>();
|
||||
|
||||
Reference in New Issue
Block a user