use crate::{GasInfo, SignedApi, result::Result};
use gear_core::{
ids::{ActorId, CodeId, MessageId},
rpc::{CalculateReplyForHandleResult, ReplyInfo},
};
use gsdk_codegen::at_block;
use subxt::utils::H256;
impl SignedApi {
pub async fn free_balance(&self) -> Result<u128> {
self.unsigned().free_balance(self.account_id()).await
}
pub async fn reserved_balance(&self) -> Result<u128> {
self.unsigned().reserved_balance(self.account_id()).await
}
pub async fn total_balance(&self) -> Result<u128> {
self.unsigned().total_balance(self.account_id()).await
}
#[at_block]
pub async fn calculate_create_gas_at(
&self,
code_id: CodeId,
payload: impl AsRef<[u8]>,
value: u128,
allow_other_panics: bool,
block_hash: Option<H256>,
) -> Result<GasInfo> {
self.unsigned()
.calculate_create_gas_at(
self.account_id(),
code_id,
payload,
value,
allow_other_panics,
block_hash,
)
.await
}
#[at_block]
pub async fn calculate_upload_gas_at(
&self,
code: impl AsRef<[u8]>,
payload: impl AsRef<[u8]>,
value: u128,
allow_other_panics: bool,
block_hash: Option<H256>,
) -> Result<GasInfo> {
self.unsigned()
.calculate_upload_gas_at(
self.account_id(),
code,
payload,
value,
allow_other_panics,
block_hash,
)
.await
}
#[at_block]
pub async fn calculate_handle_gas_at(
&self,
destination: ActorId,
payload: impl AsRef<[u8]>,
value: u128,
allow_other_panics: bool,
block_hash: Option<H256>,
) -> Result<GasInfo> {
self.unsigned()
.calculate_handle_gas_at(
self.account_id(),
destination,
payload,
value,
allow_other_panics,
block_hash,
)
.await
}
#[at_block]
pub async fn calculate_reply_gas_at(
&self,
message_id: MessageId,
payload: impl AsRef<[u8]>,
value: u128,
allow_other_panics: bool,
block_hash: Option<H256>,
) -> Result<GasInfo> {
self.unsigned()
.calculate_reply_gas_at(
self.account_id(),
message_id,
payload,
value,
allow_other_panics,
block_hash,
)
.await
}
#[at_block]
pub async fn calculate_reply_for_handle_at(
&self,
destination: ActorId,
payload: impl AsRef<[u8]>,
gas_limit: u64,
value: u128,
block_hash: Option<H256>,
) -> Result<ReplyInfo> {
self.unsigned()
.calculate_reply_for_handle_at(
self.account_id(),
destination,
payload,
gas_limit,
value,
block_hash,
)
.await
}
#[at_block]
pub async fn calculate_reply_for_handle_result_at(
&self,
destination: ActorId,
payload: impl AsRef<[u8]>,
gas_limit: u64,
value: u128,
block_hash: Option<H256>,
) -> Result<CalculateReplyForHandleResult> {
self.unsigned()
.calculate_reply_for_handle_result_at(
self.account_id(),
destination,
payload,
gas_limit,
value,
block_hash,
)
.await
}
}