Skip to content

Commit

Permalink
Made Windows target(s) able to run tests when depending on `substream…
Browse files Browse the repository at this point in the history
…s-ethereum` crate.
  • Loading branch information
maoueh committed Oct 19, 2022
1 parent aa4edb8 commit 5f638d8
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 19 deletions.
11 changes: 8 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@

## Next

* Made Windows target(s) able to run tests when depending on `substreams-ethereum` crate.

* Adding `allow` attribute(s) to remove warnings for code generated by ABI generator (should be good now).

## [0.6.0](https://github.com/streaminfast/substreams-ethereum/releases/tag/v0.6.0)

* Bump substreams to 0.3.0
* Adding cargo flags to remove warnings for code generation
* Bump `substreams` to 0.3.0.

* Adding `allow` attribute(s) to remove warnings for code generated by ABI generator.

## [0.5.0](https://github.com/streaminfast/substreams-ethereum/releases/tag/v0.5.0)

* Bump substreams
* Bump `substreams`.

## [0.4.0](https://github.com/streamingfast/substreams-ethereum/releases/tag/v0.4.0)

Expand Down
6 changes: 2 additions & 4 deletions abigen-tests/src/abi/tests.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const INTERNAL_ERR: &'static str = "`ethabi_derive` internal error";
/// Contract's functions.
#[allow(dead_code)]
#[allow(unused_variables)]
#[allow(unused_imports)]
#[allow(dead_code, unused_imports, unused_variables)]
pub mod functions {
use substreams_ethereum::scalar::EthBigInt;
use super::INTERNAL_ERR;
Expand Down Expand Up @@ -1310,7 +1308,7 @@
}
}
/// Contract's events.
#[allow(dead_code)]
#[allow(dead_code, unused_imports, unused_variables)]
pub mod events {
use substreams_ethereum::scalar::EthBigInt;
use super::INTERNAL_ERR;
Expand Down
12 changes: 4 additions & 8 deletions abigen/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,15 @@ impl Contract {
// #constructor

/// Contract's functions.
#[allow(dead_code)]
#[allow(unused_variables)]
#[allow(unused_imports)]
#[allow(dead_code, unused_imports, unused_variables)]
pub mod functions {
use substreams_ethereum::scalar::EthBigInt;
use super::INTERNAL_ERR;
#(#functions)*
}

/// Contract's events.
#[allow(dead_code)]
#[allow(dead_code, unused_imports, unused_variables)]
pub mod events {
use substreams_ethereum::scalar::EthBigInt;
use super::INTERNAL_ERR;
Expand Down Expand Up @@ -131,16 +129,14 @@ mod test {
const INTERNAL_ERR: &'static str = "`ethabi_derive` internal error";

/// Contract's functions.
#[allow(dead_code)]
#[allow(unused_variables)]
#[allow(unused_imports)]
#[allow(dead_code, unused_imports, unused_variables)]
pub mod functions {
use substreams_ethereum::scalar::EthBigInt ;
use super::INTERNAL_ERR;
}

/// Contract's events.
#[allow(dead_code)]
#[allow(dead_code, unused_imports, unused_variables)]
pub mod events {
use substreams_ethereum::scalar::EthBigInt ;
use super::INTERNAL_ERR;
Expand Down
1 change: 1 addition & 0 deletions core/src/externs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod rpc {
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "rpc")]
extern "C" {
pub fn eth_call(rpc_call_offset: *const u8, rpc_call_len: u32, rpc_response_ptr: *const u8);
Expand Down
12 changes: 8 additions & 4 deletions core/src/rpc.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::pb::eth::rpc::{RpcCall, RpcCalls, RpcResponse, RpcResponses};
use crate::{externs, Function};
use substreams::memory;
use crate::Function;
use substreams::proto;

pub trait RPCDecodable<R> {
Expand Down Expand Up @@ -57,12 +56,17 @@ impl RpcBatch {
}
}

#[cfg_attr(not(target_arch = "wasm32"), allow(unused_variables))]
fn eth_call_internal(input: Vec<u8>) -> Vec<u8> {
#[cfg(target_arch = "wasm32")]
unsafe {
let rpc_response_ptr = memory::alloc(8);
externs::rpc::eth_call(input.as_ptr(), input.len() as u32, rpc_response_ptr);
let rpc_response_ptr = substreams::memory::alloc(8);
crate::externs::rpc::eth_call(input.as_ptr(), input.len() as u32, rpc_response_ptr);
return memory::get_output_data(rpc_response_ptr);
}

#[cfg(not(target_arch = "wasm32"))]
unimplemented!("this method is not implemented outside of 'wasm32' target compilation")
}

pub fn eth_call(input: &RpcCalls) -> RpcResponses {
Expand Down

0 comments on commit 5f638d8

Please sign in to comment.