Skip to content

Commit

Permalink
bug: it seems get_ledger_entries can't get expiration
Browse files Browse the repository at this point in the history
  • Loading branch information
willemneal committed Sep 13, 2023
1 parent b9f132c commit cbde332
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions cmd/soroban-cli/src/commands/contract/bump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ use std::{
};

use clap::{command, Parser};
use sha2::{Digest, Sha256};
use soroban_env_host::xdr::{
BumpFootprintExpirationOp, Error as XdrError, ExpirationEntry, ExtensionPoint, Hash,
LedgerEntry, LedgerEntryChange, LedgerEntryData, LedgerFootprint, LedgerKey,
LedgerKeyContractCode, LedgerKeyContractData, Memo, MuxedAccount, Operation, OperationBody,
Preconditions, ReadXdr, ScAddress, ScSpecTypeDef, ScVal, SequenceNumber, SorobanResources,
SorobanTransactionData, Transaction, TransactionExt, TransactionMeta, TransactionMetaV3,
Uint256,
LedgerKeyContractCode, LedgerKeyContractData, LedgerKeyExpiration, Memo, MuxedAccount,
Operation, OperationBody, Preconditions, ReadXdr, ScAddress, ScSpecTypeDef, ScVal,
SequenceNumber, SorobanResources, SorobanTransactionData, Transaction, TransactionExt,
TransactionMeta, TransactionMetaV3, Uint256, WriteXdr,
};
use stellar_strkey::DecodeError;

Expand Down Expand Up @@ -165,7 +166,7 @@ impl Cmd {
ext: ExtensionPoint::V0,
resources: SorobanResources {
footprint: LedgerFootprint {
read_only: vec![needle].try_into()?,
read_only: vec![needle.clone()].try_into()?,
read_write: vec![].try_into()?,
},
instructions: 0,
Expand All @@ -179,7 +180,19 @@ impl Cmd {
let (result, meta, events) = client
.prepare_and_send_transaction(&tx, &key, &[], &network.network_passphrase, None, None)
.await?;

let entries = client
.get_ledger_entries(&[
LedgerKey::Expiration(LedgerKeyExpiration {
key_hash: Hash(
Sha256::digest(needle.clone().to_xdr_base64()?.as_bytes()).into(),
),
}),
needle,
])
.await?;
let entries = entries.entries.ok_or(Error::LedgerEntryNotFound)?;
tracing::trace!("entries:\n{entries:#?}");
tracing::trace!("{:#?}", LedgerEntryData::from_xdr_base64(&entries[0].xdr));
tracing::trace!(?result);
tracing::trace!("Meta:\n {meta:#?}");
if !events.is_empty() {
Expand Down

0 comments on commit cbde332

Please sign in to comment.