pub struct ArkivClient { /* private fields */ }
Expand description
A client for interacting with the Arkiv system. Provides methods for account management, entity operations, balance queries, and event subscriptions.
§Example Usage
A client builder is provided for both ArkivClient
and ArkivRoClient
,
however, an instance of ArkivClient
can be dereferenced to ArkivRoClient
like so:
use arkiv_sdk::{ArkivClient, ArkivRoClient, PrivateKeySigner, Url};
let keypath = dirs::config_dir()
.ok_or("Failed to get config directory")?
.join("golembase")
.join("wallet.json");
let signer = PrivateKeySigner::decrypt_keystore(keypath, "password")?;
let url = Url::parse("http://localhost:8545")?;
let client = ArkivClient::builder()
.wallet(signer)
.rpc_url(url)
.build();
let ro_client: &ArkivRoClient = *client;
Implementations§
Source§impl ArkivClient
impl ArkivClient
pub async fn send_transaction( &self, tx: ArkivTransaction, ) -> Result<TransactionResult, Error>
Sourcepub async fn create_entities(
&self,
creates: Vec<Create>,
) -> Result<Vec<EntityResult>, Error>
pub async fn create_entities( &self, creates: Vec<Create>, ) -> Result<Vec<EntityResult>, Error>
Creates one or more new entities in Arkiv and returns their results. Sends a transaction to the storage contract and parses the resulting logs.
Sourcepub async fn update_entities(
&self,
updates: Vec<Update>,
) -> Result<Vec<EntityResult>, Error>
pub async fn update_entities( &self, updates: Vec<Update>, ) -> Result<Vec<EntityResult>, Error>
Updates one or more entities in Arkiv and returns their results. Sends a transaction to the storage contract and parses the resulting logs.
Sourcepub async fn delete_entities(
&self,
deletes: Vec<Hash>,
) -> Result<Vec<DeleteResult>, Error>
pub async fn delete_entities( &self, deletes: Vec<Hash>, ) -> Result<Vec<DeleteResult>, Error>
Deletes one or more entities in Arkiv and returns their results. Sends a transaction to the storage contract and parses the resulting logs.
Sourcepub async fn extend_entities(
&self,
extensions: Vec<Extend>,
) -> Result<Vec<ExtendResult>, Error>
pub async fn extend_entities( &self, extensions: Vec<Extend>, ) -> Result<Vec<ExtendResult>, Error>
Extends the BTL (block time to live) of one or more entities and returns their results. Sends a transaction to the storage contract and parses the resulting logs for old and new expiration blocks.
Sourcepub async fn create_raw_transaction(
&self,
payload: ArkivTransaction,
) -> Result<TransactionReceipt, Error>
pub async fn create_raw_transaction( &self, payload: ArkivTransaction, ) -> Result<TransactionReceipt, Error>
Creates and sends a raw transaction to the Arkiv storage contract. Encodes the transaction payload and sends it to the contract address.
Source§impl ArkivClient
impl ArkivClient
Sourcepub fn get_reqwest_client(&self) -> ClientRef<'_>
pub fn get_reqwest_client(&self) -> ClientRef<'_>
Gets the underlying Reqwest client used for HTTP requests.
Sourcepub fn get_owner_address(&self) -> Address
pub fn get_owner_address(&self) -> Address
Gets the Ethereum address of the client owner.
Sourcepub async fn get_chain_id(&self) -> Result<u64>
pub async fn get_chain_id(&self) -> Result<u64>
Gets the chain ID from the provider.
Returns the chain ID as a u64
.
Sourcepub async fn get_balance(&self, account: Address) -> Result<BigDecimal>
pub async fn get_balance(&self, account: Address) -> Result<BigDecimal>
Gets an account’s ETH balance as a BigDecimal
.
Sourcepub async fn get_current_block_number(&self) -> Result<u64>
pub async fn get_current_block_number(&self) -> Result<u64>
Gets the current block number from the chain.
Returns the latest block number as a u64
.
Sourcepub fn builder() -> ArkivClientBuilder
pub fn builder() -> ArkivClientBuilder
Creates a new builder for ArkivClient
with the given wallet and RPC URL.
Initializes the provider and sets up default configuration.
Methods from Deref<Target = ArkivRoClient>§
Sourcepub async fn get_entity_count(&self) -> Result<u64, Error>
pub async fn get_entity_count(&self) -> Result<u64, Error>
Gets the total count of entities in Arkiv. Returns the number of entities currently stored.
Sourcepub async fn get_all_entity_keys(&self) -> Result<Vec<Hash>, Error>
pub async fn get_all_entity_keys(&self) -> Result<Vec<Hash>, Error>
Gets the entity keys of all entities in Arkiv. Returns a vector of all entity keys.
Sourcepub async fn get_entities_of_owner(
&self,
address: Address,
) -> Result<Vec<Hash>, Error>
pub async fn get_entities_of_owner( &self, address: Address, ) -> Result<Vec<Hash>, Error>
Gets the entity keys of all entities owned by the given address. Returns a vector of entity keys for the specified owner.
Sourcepub async fn get_storage_value<T: TryFrom<Vec<u8>>>(
&self,
key: Hash,
) -> Result<T, Error>
pub async fn get_storage_value<T: TryFrom<Vec<u8>>>( &self, key: Hash, ) -> Result<T, Error>
Gets the storage value associated with the given entity key. Decodes the value from base64 and attempts to convert it to the requested type.
Sourcepub async fn query_entities(
&self,
query: &str,
) -> Result<Vec<SearchResult>, Error>
pub async fn query_entities( &self, query: &str, ) -> Result<Vec<SearchResult>, Error>
Queries entities in Arkiv based on annotations.
Returns a vector of SearchResult
matching the query string.
Sourcepub async fn query_entity_keys(&self, query: &str) -> Result<Vec<Hash>, Error>
pub async fn query_entity_keys(&self, query: &str) -> Result<Vec<Hash>, Error>
Queries entities in Arkiv based on annotations and returns only their keys. Returns a vector of entity keys matching the query string.
Sourcepub async fn get_entities_to_expire_at_block(
&self,
block_number: u64,
) -> Result<Vec<Hash>, Error>
pub async fn get_entities_to_expire_at_block( &self, block_number: u64, ) -> Result<Vec<Hash>, Error>
Gets all entity keys for entities that will expire at the given block number. Returns a vector of entity keys expiring at the specified block.
Sourcepub async fn get_entity_metadata(
&self,
key: Hash,
) -> Result<EntityMetaData, Error>
pub async fn get_entity_metadata( &self, key: Hash, ) -> Result<EntityMetaData, Error>
Gets metadata for a specific entity.
Returns an EntityMetaData
struct for the given entity key.
Trait Implementations§
Source§impl Clone for ArkivClient
impl Clone for ArkivClient
Source§fn clone(&self) -> ArkivClient
fn clone(&self) -> ArkivClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for ArkivClient
impl !RefUnwindSafe for ArkivClient
impl Send for ArkivClient
impl Sync for ArkivClient
impl Unpin for ArkivClient
impl !UnwindSafe for ArkivClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more