add common crate

Signed-off-by: xermicus <cyrill@parity.io>
This commit is contained in:
xermicus
2024-03-22 16:19:18 +01:00
parent 50f2dd9b74
commit c52a8d0f20
65 changed files with 839 additions and 271 deletions
@@ -16,7 +16,7 @@ where
let offset = context.builder().build_int_add(
offset,
context.field_const(
(era_compiler_common::BYTE_LENGTH_X32 + era_compiler_common::BYTE_LENGTH_FIELD) as u64,
(revive_common::BYTE_LENGTH_X32 + revive_common::BYTE_LENGTH_FIELD) as u64,
),
"datacopy_contract_hash_offset",
)?;
@@ -61,12 +61,12 @@ where
for (index, chunk) in source
.chars()
.collect::<Vec<char>>()
.chunks(era_compiler_common::BYTE_LENGTH_FIELD * 2)
.chunks(revive_common::BYTE_LENGTH_FIELD * 2)
.enumerate()
{
let mut value_string = chunk.iter().collect::<String>();
value_string.push_str(
"0".repeat((era_compiler_common::BYTE_LENGTH_FIELD * 2) - chunk.len())
"0".repeat((revive_common::BYTE_LENGTH_FIELD * 2) - chunk.len())
.as_str(),
);
@@ -309,7 +309,7 @@ impl Instruction {
..
} => {
let mut key_extended =
"0".repeat(era_compiler_common::BYTE_LENGTH_FIELD * 2 - value.len());
"0".repeat(revive_common::BYTE_LENGTH_FIELD * 2 - value.len());
key_extended.push_str(value.as_str());
*value = mapping.get(key_extended.as_str()).cloned().ok_or_else(|| {
+4 -6
View File
@@ -103,7 +103,7 @@ impl Assembly {
hash_data_mapping: &BTreeMap<String, String>,
) -> anyhow::Result<BTreeMap<String, String>> {
let mut index_path_mapping = BTreeMap::new();
let index = "0".repeat(era_compiler_common::BYTE_LENGTH_FIELD * 2);
let index = "0".repeat(revive_common::BYTE_LENGTH_FIELD * 2);
index_path_mapping.insert(index, full_path.to_owned());
let dependencies = match self.data.as_mut() {
@@ -115,8 +115,7 @@ impl Assembly {
continue;
}
let mut index_extended =
"0".repeat(era_compiler_common::BYTE_LENGTH_FIELD * 2 - index.len());
let mut index_extended = "0".repeat(revive_common::BYTE_LENGTH_FIELD * 2 - index.len());
index_extended.push_str(index.as_str());
*data = match data {
@@ -154,7 +153,7 @@ impl Assembly {
hash_data_mapping: &BTreeMap<String, String>,
) -> anyhow::Result<BTreeMap<String, String>> {
let mut index_path_mapping = BTreeMap::new();
let index = "0".repeat(era_compiler_common::BYTE_LENGTH_FIELD * 2);
let index = "0".repeat(revive_common::BYTE_LENGTH_FIELD * 2);
index_path_mapping.insert(index, full_path.to_owned());
let dependencies = match self
@@ -168,8 +167,7 @@ impl Assembly {
None => return Ok(index_path_mapping),
};
for (index, data) in dependencies.iter_mut() {
let mut index_extended =
"0".repeat(era_compiler_common::BYTE_LENGTH_FIELD * 2 - index.len());
let mut index_extended = "0".repeat(revive_common::BYTE_LENGTH_FIELD * 2 - index.len());
index_extended.push_str(index.as_str());
*data = match data {