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

Fix massa-client read only call #4493

Merged
merged 4 commits into from
Oct 27, 2023
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions massa-client/src/cmds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,7 @@ impl Command {
}
}
Command::read_only_execute_smart_contract => {
if parameters.len() < 2 || parameters.len() > 4 {
if parameters.len() < 2 || parameters.len() > 5 {
bail!("wrong number of parameters");
}

Expand Down Expand Up @@ -1165,7 +1165,7 @@ impl Command {
}
}
Command::read_only_call => {
if parameters.len() < 4 || parameters.len() > 6 {
if parameters.len() < 4 || parameters.len() > 8 {
bail!("wrong number of parameters");
}

Expand Down
3 changes: 2 additions & 1 deletion massa-ledger-exports/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ test-exports = ["tempfile", "massa_models/test-exports"]
displaydoc = {workspace = true}
serde = {workspace = true, "features" = ["derive"]}
serde_json = {workspace = true} # BOM UPGRADE Revert to "1.0" if problem
serde_with = { workspace = true }
tempfile = {workspace = true, "optional" = true} # BOM UPGRADE Revert to {"version": "3.3", "optional": true} if problem
thiserror = {workspace = true}
nom = {workspace = true}
Expand All @@ -21,4 +22,4 @@ massa_serialization = {workspace = true}
massa_db_exports = {workspace = true}

[dev-dependencies]
massa_hash = {workspace = true}
massa_hash = {workspace = true}
22 changes: 4 additions & 18 deletions massa-ledger-exports/src/ledger_changes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,24 @@ use nom::error::{context, ContextError, ParseError};
use nom::multi::length_count;
use nom::sequence::tuple;
use nom::{IResult, Parser};
use serde::{ser::SerializeSeq, Deserialize, Serialize};
use serde::{Deserialize, Serialize};
use serde_with::serde_as;
use std::collections::{hash_map, BTreeMap};
use std::ops::Bound::Included;

/// represents an update to one or more fields of a `LedgerEntry`
#[serde_as]
#[derive(Default, Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
pub struct LedgerEntryUpdate {
/// change the balance
pub balance: SetOrKeep<Amount>,
/// change the executable bytecode
pub bytecode: SetOrKeep<Bytecode>,
/// change datastore entries
#[serde(serialize_with = "as_array")]
#[serde_as(as = "Vec<(_, _)>")]
pub datastore: BTreeMap<Vec<u8>, SetOrDelete<Vec<u8>>>,
Leo-Besancon marked this conversation as resolved.
Show resolved Hide resolved
}

// Serializer for `datastore` field of `LedgerEntryUpdate`
fn as_array<S>(
datastore: &BTreeMap<Vec<u8>, SetOrDelete<Vec<u8>>>,
serializer: S,
) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
let mut seq = serializer.serialize_seq(Some(datastore.len()))?;
for (key, value) in datastore {
seq.serialize_element(&(&key, &value))?;
}

seq.end()
}

/// Serializer for `datastore` field of `LedgerEntryUpdate`
pub struct DatastoreUpdateSerializer {
u64_serializer: U64VarIntSerializer,
Expand Down