Skip to content

Commit

Permalink
better check for initcode
Browse files Browse the repository at this point in the history
  • Loading branch information
crystalin committed Nov 27, 2024
1 parent 880b0d6 commit 6168a11
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions pallets/moonbeam-foreign-assets/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
// along with Moonbeam. If not, see <http://www.gnu.org/licenses/>.

use std::fs;
use std::path::Path;
use std::io::prelude::*;
use std::path::Path;

// Length of encoded constructor parameters
const PARAMS_LEN: usize = 256;
Expand All @@ -41,16 +41,12 @@ fn main() {

let file_path = "resources/foreign_erc20_initcode.bin";

if Path::new(file_path).exists() {
let existing_content = fs::read(file_path).expect("Unable to read file");
let existing_hex_code = hex::encode(existing_content);

if existing_hex_code == hex_str {
println!("File already exists and matches the expected hex code.");
return;
}
} else {
println!("File does not exist or does not match the expected hex code.");
if Path::new(file_path).exists() {
let existing_content = fs::read(file_path).expect("Unable to read file");
let existing_hex_code = hex::encode(existing_content);
if existing_hex_code == hex::encode(&bytecode[..bytecode_end]) {
return;
}
}

let mut file = fs::File::create(file_path)
Expand Down

0 comments on commit 6168a11

Please sign in to comment.