Skip to content

Commit

Permalink
Merge pull request #560 from Concordium/remove-check-on-padding-in-mo…
Browse files Browse the repository at this point in the history
…bile-wallets-library

Remove check on padding in mobile wallets library
  • Loading branch information
DOBEN authored Sep 25, 2024
2 parents 9ad276d + 13e3871 commit 13048aa
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
4 changes: 4 additions & 0 deletions mobile_wallet/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.25.3

- Changed the base64 schema decoding to allow padded and not padded strings.

## 0.25.2

- Allowed use of functions deprecated due to the removal of encrypted transfers in protocol version 7.
Expand Down
2 changes: 1 addition & 1 deletion mobile_wallet/Cargo.lock

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

2 changes: 1 addition & 1 deletion mobile_wallet/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mobile_wallet"
version = "0.25.2"
version = "0.25.3"
authors = ["Concordium AG <[email protected]>"]
edition = "2018"
license-file = "../../LICENSE-APACHE"
Expand Down
19 changes: 13 additions & 6 deletions mobile_wallet/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
use anyhow::{bail, ensure, Context};
use base64::Engine;
use base64::{
alphabet,
engine::{DecodePaddingMode, GeneralPurpose, GeneralPurposeConfig},
Engine,
};
use concordium_base::{
base::{self, Energy, Nonce},
cis2_types::{self, AdditionalData},
Expand Down Expand Up @@ -190,16 +194,19 @@ fn get_parameter_as_json(
let contract_name = receive_name.as_receive_name().contract_name();
let entrypoint_name = &receive_name.as_receive_name().entrypoint_name().to_string();

let decoding_specs = GeneralPurpose::new(
&alphabet::STANDARD,
GeneralPurposeConfig::new().with_decode_padding_mode(DecodePaddingMode::Indifferent),
);

let receive_schema: schema::Type = match schema {
SchemaInputType::Module(raw) => {
let module_schema = schema::VersionedModuleSchema::new(
&base64::engine::general_purpose::STANDARD.decode(raw)?,
schema_version,
)?;
let module_schema =
schema::VersionedModuleSchema::new(&decoding_specs.decode(raw)?, schema_version)?;
module_schema.get_receive_param_schema(contract_name, entrypoint_name)?
}
SchemaInputType::Parameter(raw) => {
contracts_common::from_bytes(&base64::engine::general_purpose::STANDARD.decode(raw)?)?
contracts_common::from_bytes(&decoding_specs.decode(raw)?)?
}
};

Expand Down

0 comments on commit 13048aa

Please sign in to comment.