implemented request_airdrop
This commit is contained in:
parent
b12810a706
commit
c5c0f86b45
|
@ -5,7 +5,7 @@ use crate::{
|
||||||
workers::{BlockListener, TxSender},
|
workers::{BlockListener, TxSender},
|
||||||
};
|
};
|
||||||
|
|
||||||
use std::{ops::Deref, sync::Arc};
|
use std::{ops::Deref, str::FromStr, sync::Arc};
|
||||||
|
|
||||||
use anyhow::bail;
|
use anyhow::bail;
|
||||||
use reqwest::Url;
|
use reqwest::Url;
|
||||||
|
@ -13,11 +13,12 @@ use reqwest::Url;
|
||||||
use jsonrpsee::server::ServerBuilder;
|
use jsonrpsee::server::ServerBuilder;
|
||||||
use solana_client::{
|
use solana_client::{
|
||||||
nonblocking::{rpc_client::RpcClient, tpu_client::TpuClient},
|
nonblocking::{rpc_client::RpcClient, tpu_client::TpuClient},
|
||||||
rpc_config::RpcContextConfig,
|
rpc_config::{RpcContextConfig, RpcRequestAirdropConfig},
|
||||||
rpc_response::{Response as RpcResponse, RpcBlockhash, RpcResponseContext, RpcVersionInfo},
|
rpc_response::{Response as RpcResponse, RpcBlockhash, RpcResponseContext, RpcVersionInfo},
|
||||||
};
|
};
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
commitment_config::{CommitmentConfig, CommitmentLevel},
|
commitment_config::{CommitmentConfig, CommitmentLevel},
|
||||||
|
pubkey::Pubkey,
|
||||||
transaction::VersionedTransaction,
|
transaction::VersionedTransaction,
|
||||||
};
|
};
|
||||||
use solana_transaction_status::TransactionStatus;
|
use solana_transaction_status::TransactionStatus;
|
||||||
|
@ -191,6 +192,23 @@ impl LiteRpcServer for LiteBridge {
|
||||||
feature_set: Some(version.feature_set),
|
feature_set: Some(version.feature_set),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn request_airdrop(
|
||||||
|
&self,
|
||||||
|
pubkey_str: String,
|
||||||
|
lamports: u64,
|
||||||
|
config: RpcRequestAirdropConfig,
|
||||||
|
) -> crate::rpc::Result<String> {
|
||||||
|
let pubkey = Pubkey::from_str(&pubkey_str).unwrap();
|
||||||
|
|
||||||
|
Ok(self
|
||||||
|
.tpu_client
|
||||||
|
.rpc_client()
|
||||||
|
.request_airdrop_with_config(&pubkey, lamports, config)
|
||||||
|
.await
|
||||||
|
.unwrap()
|
||||||
|
.to_string())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Deref for LiteBridge {
|
impl Deref for LiteBridge {
|
||||||
|
|
12
src/rpc.rs
12
src/rpc.rs
|
@ -1,6 +1,8 @@
|
||||||
use jsonrpsee::core::Error;
|
use jsonrpsee::core::Error;
|
||||||
use jsonrpsee::proc_macros::rpc;
|
use jsonrpsee::proc_macros::rpc;
|
||||||
use solana_client::rpc_config::{RpcContextConfig, RpcSignatureStatusConfig};
|
use solana_client::rpc_config::{
|
||||||
|
RpcContextConfig, RpcRequestAirdropConfig, RpcSignatureStatusConfig,
|
||||||
|
};
|
||||||
use solana_client::rpc_response::{Response as RpcResponse, RpcBlockhash, RpcVersionInfo};
|
use solana_client::rpc_response::{Response as RpcResponse, RpcBlockhash, RpcVersionInfo};
|
||||||
use solana_transaction_status::TransactionStatus;
|
use solana_transaction_status::TransactionStatus;
|
||||||
|
|
||||||
|
@ -32,4 +34,12 @@ pub trait LiteRpc {
|
||||||
|
|
||||||
#[method(name = "getVersion")]
|
#[method(name = "getVersion")]
|
||||||
fn get_version(&self) -> Result<RpcVersionInfo>;
|
fn get_version(&self) -> Result<RpcVersionInfo>;
|
||||||
|
|
||||||
|
#[method(name = "requestAirdrop")]
|
||||||
|
async fn request_airdrop(
|
||||||
|
&self,
|
||||||
|
pubkey_str: String,
|
||||||
|
lamports: u64,
|
||||||
|
config: RpcRequestAirdropConfig,
|
||||||
|
) -> Result<String>;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue