Skip to content

Commit

Permalink
fix: fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
MrWad3r committed Feb 24, 2025
1 parent 21ada7f commit 7a32728
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/abi/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ impl Contract {
pub fn encode_init_data(
&self,
pubkey: &ed25519_dalek::VerifyingKey,
tokens: &[NamedAbiValue]
tokens: &[NamedAbiValue],
) -> Result<Cell> {
if self.abi_version < AbiVersion::V2_4 {
self.encode_init_data_internal(pubkey, tokens)
Expand Down
21 changes: 12 additions & 9 deletions src/abi/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::sync::Arc;
use bytes::Bytes;
use num_bigint::BigInt;
use std::sync::Arc;

use crate::abi::*;
use crate::abi::contract::ContractInitData;
use crate::abi::*;
use crate::models::StdAddr;
use crate::prelude::{Cell, CellBuilder, CellFamily, HashBytes, RawDict, Store};

Expand Down Expand Up @@ -44,26 +44,29 @@ fn decode_json_abi_v24() {
let key = ed25519_dalek::SigningKey::from([0u8; 32]);
let pubkey = ed25519_dalek::VerifyingKey::from(&key);

if let Err(e) = contract.encode_init_data(&pubkey, &[NamedAbiValue {
name: Arc::from("a"),
value: AbiValue::Int(128, BigInt::from(0)),
}]) {
if let Err(e) = contract.encode_init_data(
&pubkey,
&[NamedAbiValue {
name: Arc::from("a"),
value: AbiValue::Int(128, BigInt::from(0)),
}],
) {
println!("Expected to fail because of unexpected field name. Err: {e:?}");
}


let init_values = vec![NamedAbiValue {
name: Arc::from("b"),
value: AbiValue::Int(128, BigInt::from(0)),
}];

let cell = contract.encode_init_data(&pubkey, init_values.as_ref()).unwrap();
let cell = contract
.encode_init_data(&pubkey, init_values.as_ref())
.unwrap();

let fields = contract.decode_init_data(cell.as_ref()).unwrap();

assert_eq!(init_values, fields);


let function = contract.find_function_by_id(0x01234567, true).unwrap();
assert_eq!(function.input_id, 0x01234567);
assert_eq!(function.name.as_ref(), "has_id");
Expand Down
2 changes: 1 addition & 1 deletion src/abi/value/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ impl AbiValue {
AbiType::Address => {
ok!(preload_bits(1, slice));
Ok(Self::Address(AnyAddr::load_from(slice).map(Box::new)?))
},
}
AbiType::Bytes => load_bytes(version, last, slice).map(Self::Bytes),
AbiType::FixedBytes(len) => {
load_fixed_bytes(*len, version, last, slice).map(Self::FixedBytes)
Expand Down

0 comments on commit 7a32728

Please sign in to comment.