Skip to content

Commit

Permalink
Fix cell hash commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Rexagon committed Aug 10, 2023
1 parent c83f559 commit af871d6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "fift"
description = "Rust implementation of the Fift esoteric language"
repository = "https://github.com/broxus/fift"
version = "0.1.7"
version = "0.1.8"
edition = "2021"
rust-version = "1.70"
include = ["src/**/*.rs", "src/**/*.fif", "LICENSE-*", "README.md"]
Expand Down
4 changes: 2 additions & 2 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "fift-cli"
description = "A CLI for the Fift esoteric language interpreter"
repository = "https://github.com/broxus/fift"
version = "0.1.7"
version = "0.1.8"
edition = "2021"
rust-version = "1.70"
include = ["src/**/*.rs", "src/**/*.fif", "LICENSE", "README.md"]
Expand All @@ -18,4 +18,4 @@ argh = "0.1"
console = "0.15"
rustyline = { version = "11.0", default-features = false }

fift = { path = "..", version = "0.1.7" }
fift = { path = "..", version = "0.1.8" }
9 changes: 4 additions & 5 deletions src/modules/cell_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use everscale_types::cell::{MAX_BIT_LEN, MAX_REF_COUNT};
use everscale_types::prelude::*;
use num_bigint::{BigInt, Sign};
use num_traits::Zero;
use sha2::Digest;

use crate::core::*;
use crate::util::*;
Expand Down Expand Up @@ -173,12 +172,12 @@ impl CellUtils {
#[cmd(name = "hashu", stack, args(as_uint = true))]
#[cmd(name = "hashB", stack, args(as_uint = false))]
fn interpret_cell_hash(stack: &mut Stack, as_uint: bool) -> Result<()> {
let bytes = stack.pop_bytes()?;
let hash = sha2::Sha256::digest(&*bytes);
let cell = stack.pop_cell()?;
let hash = cell.repr_hash();
if as_uint {
stack.push(BigInt::from_bytes_be(Sign::Plus, &hash))
stack.push(BigInt::from_bytes_be(Sign::Plus, hash.as_slice()))
} else {
stack.push(hash.to_vec())
stack.push(hash.as_slice().to_vec())
}
}

Expand Down

0 comments on commit af871d6

Please sign in to comment.