Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup wasm fetch methods #9

Merged
merged 5 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
target/
.soroban/
.idea
.vscode
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ all: check build test
export RUSTFLAGS=-Dwarnings -Dclippy::all -Dclippy::pedantic

build:
cargo build

check:
cargo clippy --all-targets

test:
Expand Down
9 changes: 7 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pub type LogEvents = fn(
pub type LogResources = fn(resources: &SorobanResources) -> ();

#[derive(thiserror::Error, Debug)]
#[allow(deprecated)] // Can be removed once Error enum doesn't have any code marked deprecated inside
pub enum Error {
#[error(transparent)]
InvalidAddress(#[from] stellar_strkey::DecodeError),
Expand Down Expand Up @@ -94,7 +95,8 @@ pub enum Error {
UnexpectedContractCodeDataType(LedgerEntryData),
#[error("unexpected contract instance type: {0:?}")]
UnexpectedContractInstance(xdr::ScVal),
#[error("unexpected contract code got token")]
#[error("unexpected contract code got token {0:?}")]
#[deprecated(note = "To be removed in future versions")]
UnexpectedToken(ContractDataEntry),
#[error("Fee was too large {0}")]
LargeFee(u64),
Expand Down Expand Up @@ -633,6 +635,7 @@ pub struct Client {
http_client: Arc<HttpClient>,
}

#[allow(deprecated)] // Can be removed once Client doesn't have any code marked deprecated inside
impl Client {
///
/// # Errors
Expand Down Expand Up @@ -1065,6 +1068,7 @@ impl Client {

///
/// # Errors
#[deprecated(note = "To be removed in future versions, use get_ledger_entries()")]
pub async fn get_remote_wasm(&self, contract_id: &[u8; 32]) -> Result<Vec<u8>, Error> {
Ifropc marked this conversation as resolved.
Show resolved Hide resolved
match self.get_contract_data(contract_id).await? {
xdr::ContractDataEntry {
Expand All @@ -1081,7 +1085,8 @@ impl Client {

///
/// # Errors
pub async fn get_remote_wasm_from_hash(&self, hash: xdr::Hash) -> Result<Vec<u8>, Error> {
#[deprecated(note = "To be removed in future versions, use get_ledger_entries()")]
pub async fn get_remote_wasm_from_hash(&self, hash: Hash) -> Result<Vec<u8>, Error> {
let code_key = LedgerKey::ContractCode(xdr::LedgerKeyContractCode { hash: hash.clone() });
let contract_data = self.get_ledger_entries(&[code_key]).await?;
let entries = contract_data.entries.unwrap_or_default();
Expand Down
Loading