Skip to content

Commit

Permalink
Make ABI loader private so we can use expect calls
Browse files Browse the repository at this point in the history
- Why private?
  - This functionality is out of scope for our SDK.
  - It wasn't being used outside this module.
- I think that it is ok to go with the simplest solution right now. We
  could refactor this to emit an error in the future if necessary.
  - It makes sense to use `expect`/`unwrap` here because the
    `include_str!` macro ensures that the ABI JSON string is present.
  • Loading branch information
jpcenteno committed Aug 28, 2023
1 parent 741d8df commit 392ef65
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/abi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ use std::str::FromStr;

const L1_DEFAULT_BRIDGE_INTERFACE: &str = include_str!("./IL1Bridge.json");

// FIXME this was taken from
pub fn load_contract(raw_abi_string: &str) -> Contract {
// Note that using `.expect` here is acceptable because we expect the value of
// `L1_DEFAULT_BRIDGE_INTERFACE` to be correct. In the future, we should refactor this piece of
// code to run in compile time.
fn load_contract(raw_abi_string: &str) -> Contract {
// Note that using `.expect` here is acceptable because this is a private function and we
// expect the value of `raw_abi_string` to be correct. In the future, we should refactor this
// piece of code to run in compile time.
#![allow(clippy::unwrap_used, clippy::expect_used)]
let abi_string = serde_json::Value::from_str(raw_abi_string)
.expect("Malformed contract abi file")
Expand Down

0 comments on commit 392ef65

Please sign in to comment.