Skip to content

Commit

Permalink
fix: update RPC types
Browse files Browse the repository at this point in the history
  • Loading branch information
willemneal committed Oct 18, 2023
1 parent 9328de9 commit abe885d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions cmd/soroban-cli/src/commands/contract/extend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl Cmd {
if self.expiration_ledger_only {
println!("{expiration_ledger_seq}");
} else {
println!("New expiration ledger: {expiration_ledger_seq}");
println!("New ttl ledger: {expiration_ledger_seq}");
}

Ok(())
Expand Down Expand Up @@ -175,7 +175,7 @@ impl Cmd {

if operations[0].changes.is_empty() {
let entry = client.get_full_ledger_entries(&keys).await?;
let expire = entry.entries[0].expiration_ledger_seq;
let expire = entry.entries[0].live_until_ledger_seq;
if entry.latest_ledger + i64::from(extend_to) < i64::from(expire) {
return Ok(expire);
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/soroban-cli/src/commands/contract/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl Cmd {
.filter(|(k, _v)| keys.contains(k))
.map(|(key, (v, expiration))| {
Ok(FullLedgerEntry {
expiration_ledger_seq: expiration.unwrap_or_default(),
live_until_ledger_seq: expiration.unwrap_or_default(),
last_modified_ledger: latest_ledger,
key,
val: v.data,
Expand All @@ -141,7 +141,7 @@ impl Cmd {
for FullLedgerEntry {
key,
val,
expiration_ledger_seq,
live_until_ledger_seq: expiration_ledger_seq,
last_modified_ledger,
} in &entries.entries
{
Expand Down
10 changes: 5 additions & 5 deletions cmd/soroban-cli/src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,12 @@ pub struct LedgerEntryResult {
)]
pub last_modified_ledger: u32,
#[serde(
rename = "expirationLedgerSeq",
rename = "liveUntilLedgerSeqLedgerSeq",
skip_serializing_if = "Option::is_none",
deserialize_with = "deserialize_option_number_from_string",
default
)]
pub expiration_ledger_seq: Option<u32>,
pub live_until_ledger_seq_ledger_seq: Option<u32>,
}

#[derive(serde::Deserialize, serde::Serialize, Debug)]
Expand Down Expand Up @@ -435,7 +435,7 @@ pub struct FullLedgerEntry {
pub key: LedgerKey,
pub val: LedgerEntryData,
pub last_modified_ledger: u32,
pub expiration_ledger_seq: u32,
pub live_until_ledger_seq: u32,
}

#[derive(Debug)]
Expand Down Expand Up @@ -794,12 +794,12 @@ soroban config identity fund {address} --helper-url <url>"#
key,
xdr,
last_modified_ledger,
expiration_ledger_seq,
live_until_ledger_seq_ledger_seq,
}| {
Ok(FullLedgerEntry {
key: LedgerKey::from_xdr_base64(key)?,
val: LedgerEntryData::from_xdr_base64(xdr)?,
expiration_ledger_seq: expiration_ledger_seq.unwrap_or_default(),
live_until_ledger_seq: live_until_ledger_seq_ledger_seq.unwrap_or_default(),
last_modified_ledger: *last_modified_ledger,
})
},
Expand Down
4 changes: 2 additions & 2 deletions cmd/soroban-rpc/internal/test/simulate_transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func TestSimulateTransactionSucceeds(t *testing.T) {
assert.Equal(t, expectedTransactionData.Resources.Footprint, transactionData.Resources.Footprint)
assert.InDelta(t, uint32(expectedTransactionData.Resources.Instructions), uint32(transactionData.Resources.Instructions), 200000)
assert.InDelta(t, uint32(expectedTransactionData.Resources.ReadBytes), uint32(transactionData.Resources.ReadBytes), 10)
assert.InDelta(t, uint32(expectedTransactionData.Resources.WriteBytes), uint32(transactionData.Resources.WriteBytes), 100)
assert.InDelta(t, uint32(expectedTransactionData.Resources.WriteBytes), uint32(transactionData.Resources.WriteBytes), 300)
assert.InDelta(t, int64(expectedTransactionData.ResourceFee), int64(transactionData.ResourceFee), 1000)

// Then decode and check the result xdr, separately so we get a decent diff if it fails.
Expand Down Expand Up @@ -1122,7 +1122,7 @@ func TestSimulateSystemEvent(t *testing.T) {
require.NoError(t, err)

assert.InDelta(t, 7260, uint32(transactionData.Resources.ReadBytes), 200)
assert.InDelta(t, 98339, int64(transactionData.ResourceFee), 10)
assert.InDelta(t, 98339, int64(transactionData.ResourceFee), 2000)
assert.InDelta(t, 104, uint32(transactionData.Resources.WriteBytes), 15)
require.GreaterOrEqual(t, len(response.Events), 3)
}

0 comments on commit abe885d

Please sign in to comment.