Skip to content

Commit

Permalink
feat: use fuel-abi-types 0.5.0 (#1381)
Browse files Browse the repository at this point in the history
This PR bumps `fuel-abi-types` to `0.5.0` which internally changes the `log_id` type from `u64` to `String`.
  • Loading branch information
hal3e committed May 16, 2024
1 parent 8f092b9 commit e05ef2d
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ env:
FUEL_CORE_PATCH_BRANCH:
RUST_VERSION: 1.76.0
FORC_VERSION: 0.58.0
FORC_PATCH_BRANCH: ""
FORC_PATCH_BRANCH: "esdrubal/abi_hash_ids"
FORC_PATCH_REVISION: ""
NEXTEST_HIDE_PROGRESS_BAR: "true"
NEXTEST_STATUS_LEVEL: "fail"
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ bytes = { version = "1.5.0", default-features = false }
chrono = "0.4.31"
elliptic-curve = { version = "0.13.8", default-features = false }
eth-keystore = "0.5.0"
fuel-abi-types = "0.4.0"
fuel-abi-types = "0.5.0"
futures = "0.3.29"
hex = { version = "0.4.3", default-features = false }
itertools = "0.12.0"
Expand Down
3 changes: 3 additions & 0 deletions e2e/Forc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,6 @@ members = [
'sway/types/scripts/script_u256',
'sway/types/scripts/script_vectors',
]

[patch.'https://github.com/fuellabs/sway']
std = { git = "https://github.com/fuellabs/sway", branch = "esdrubal/abi_hash_ids" }
2 changes: 1 addition & 1 deletion e2e/tests/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1345,7 +1345,7 @@ async fn test_log_results() -> Result<()> {
let log = response.decode_logs();

let expected_err = format!(
"codec: missing log formatter for log_id: `LogId({:?}, 128)`, data: `{:?}`. \
"codec: missing log formatter for log_id: `LogId({:?}, \"128\")`, data: `{:?}`. \
Consider adding external contracts using `with_contracts()`",
contract_instance.id().hash,
[0u8; 8]
Expand Down
8 changes: 4 additions & 4 deletions packages/fuels-code-gen/src/program_bindings/abigen/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub(crate) fn log_formatters_instantiation_code(

#[derive(Debug)]
struct ResolvedLog {
log_id: u64,
log_id: String,
log_formatter: TokenStream,
}

Expand All @@ -29,7 +29,7 @@ fn resolve_logs(logged_types: &[FullLoggedType]) -> Vec<ResolvedLog> {
.expect("Failed to resolve log type");

ResolvedLog {
log_id: l.log_id,
log_id: l.log_id.clone(),
log_formatter: quote! {
::fuels::core::codec::LogFormatter::new::<#resolved_type>()
},
Expand All @@ -42,11 +42,11 @@ fn generate_log_id_log_formatter_pairs(resolved_logs: &[ResolvedLog]) -> Vec<Tok
resolved_logs
.iter()
.map(|r| {
let id = r.log_id;
let id = &r.log_id;
let log_formatter = &r.log_formatter;

quote! {
(#id, #log_formatter)
(#id.to_string(), #log_formatter)
}
})
.collect()
Expand Down
10 changes: 6 additions & 4 deletions packages/fuels-core/src/codec/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl Debug for LogFormatter {

/// Holds a unique log ID
#[derive(Debug, Clone, Default, PartialEq, Eq, Hash)]
pub struct LogId(ContractId, u64);
pub struct LogId(ContractId, String);

/// Struct used to pass the log mappings from the Abigen
#[derive(Debug, Clone, Default)]
Expand Down Expand Up @@ -201,15 +201,17 @@ impl<'a, I: Iterator<Item = &'a Receipt>> ExtractLogIdData for I {
data: Some(data),
id,
..
} => Some((LogId(*id, *rb), data.clone())),
Receipt::Log { ra, rb, id, .. } => Some((LogId(*id, *rb), ra.to_be_bytes().to_vec())),
} => Some((LogId(*id, (*rb).to_string()), data.clone())),
Receipt::Log { ra, rb, id, .. } => {
Some((LogId(*id, (*rb).to_string()), ra.to_be_bytes().to_vec()))
}
_ => None,
})
}
}

pub fn log_formatters_lookup(
log_id_log_formatter_pairs: Vec<(u64, LogFormatter)>,
log_id_log_formatter_pairs: Vec<(String, LogFormatter)>,
contract_id: ContractId,
) -> HashMap<LogId, LogFormatter> {
log_id_log_formatter_pairs
Expand Down

0 comments on commit e05ef2d

Please sign in to comment.