Skip to content

Commit

Permalink
update deprecated methods
Browse files Browse the repository at this point in the history
  • Loading branch information
mangas committed May 28, 2024
1 parent 3492c62 commit 8bab219
Show file tree
Hide file tree
Showing 14 changed files with 143 additions and 110 deletions.
202 changes: 113 additions & 89 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ diesel-derive-enum = { version = "2.1.0", features = ["postgres"] }
diesel_derives = "2.1.4"
diesel-dynamic-schema = "0.2.1"
diesel_migrations = "2.1.0"
prost = "0.11.9"
prost-types = "0.11.9"
prost = "0.12.6"
prost-types = "0.12.6"
serde = { version = "1.0.126", features = ["rc"] }
serde_derive = "1.0.125"
serde_json = { version = "1.0", features = ["arbitrary_precision"] }
serde_regex = "1.1.0"
serde_yaml = "0.9.21"
sqlparser = "0.46.0"
syn = { version = "2.0.65", features = ["full"] }
tonic = { version = "0.8.3", features = ["tls-roots", "gzip"] }
tonic = { version = "0.11.0", features = ["tls-roots", "gzip"] }
tonic-build = { version = "0.11.0", features = ["prost"] }
wasmtime = "15.0.1"
wasmparser = "0.118.1"
Expand Down
2 changes: 1 addition & 1 deletion chain/arweave/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ impl FirehoseMapperTrait<Chain> for FirehoseMapper {
logger: &Logger,
response: &firehose::Response,
) -> Result<BlockStreamEvent<Chain>, FirehoseError> {
let step = ForkStep::from_i32(response.step).unwrap_or_else(|| {
let step = ForkStep::try_from(response.step).unwrap_or_else(|_| {
panic!(
"unknown step i32 value {}, maybe you forgot update & re-regenerate the protobuf definitions?",
response.step
Expand Down
3 changes: 2 additions & 1 deletion chain/cosmos/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use graph::blockchain::{BlockIngestor, NoopDecoderHook};
use graph::env::EnvVars;
use graph::prelude::MetricsRegistry;
use graph::substreams::Clock;
use std::convert::TryFrom;
use std::sync::Arc;

use graph::blockchain::block_stream::{BlockStreamError, BlockStreamMapper, FirehoseCursor};
Expand Down Expand Up @@ -381,7 +382,7 @@ impl FirehoseMapperTrait<Chain> for FirehoseMapper {
logger: &Logger,
response: &firehose::Response,
) -> Result<BlockStreamEvent<Chain>, FirehoseError> {
let step = ForkStep::from_i32(response.step).unwrap_or_else(|| {
let step = ForkStep::try_from(response.step).unwrap_or_else(|_| {
panic!(
"unknown step i32 value {}, maybe you forgot update & re-regenerate the protobuf definitions?",
response.step
Expand Down
2 changes: 1 addition & 1 deletion chain/ethereum/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ impl FirehoseMapperTrait<Chain> for FirehoseMapper {
logger: &Logger,
response: &firehose::Response,
) -> Result<BlockStreamEvent<Chain>, FirehoseError> {
let step = ForkStep::from_i32(response.step).unwrap_or_else(|| {
let step = ForkStep::try_from(response.step).unwrap_or_else(|_| {
panic!(
"unknown step i32 value {}, maybe you forgot update & re-regenerate the protobuf definitions?",
response.step
Expand Down
21 changes: 11 additions & 10 deletions chain/ethereum/src/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ impl TryInto<web3::types::Call> for Call {
.map_or_else(|| U256::from(0), |v| v.into()),
gas: U256::from(self.gas_limit),
input: Bytes::from(self.input.clone()),
call_type: CallType::from_i32(self.call_type)
.ok_or_else(|| format_err!("invalid call type: {}", self.call_type,))?
call_type: CallType::try_from(self.call_type)
.map_err(|_| graph::anyhow::anyhow!("invalid call type: {}", self.call_type))?
.into(),
})
}
Expand Down Expand Up @@ -300,13 +300,14 @@ impl TryInto<EthereumBlockWithCalls> for &Block {
match t.calls.len() {
0 => None,
_ => {
match CallType::from_i32(t.calls[0].call_type)
.ok_or_else(|| {
format_err!(
match CallType::try_from(t.calls[0].call_type).map_err(
|_| {
graph::anyhow::anyhow!(
"invalid call type: {}",
t.calls[0].call_type,
)
})? {
},
)? {
CallType::Create => {
Some(t.calls[0].address.try_decode_proto(
"transaction contract address",
Expand All @@ -322,9 +323,9 @@ impl TryInto<EthereumBlockWithCalls> for &Block {
.iter()
.map(|l| LogAt::new(l, self, t).try_into())
.collect::<Result<Vec<_>, Error>>()?,
status: TransactionTraceStatus::from_i32(t.status)
.ok_or_else(|| {
format_err!(
status: TransactionTraceStatus::try_from(t.status)
.map_err(|_| {
graph::anyhow::anyhow!(
"invalid transaction trace status: {}",
t.status
)
Expand Down Expand Up @@ -533,7 +534,7 @@ fn get_to_address(trace: &TransactionTrace) -> Result<Option<H160>, Error> {
// Try to detect contract creation transactions, which have no 'to' address
let is_contract_creation = trace.to.len() == 0
|| trace.calls.get(0).map_or(false, |call| {
CallType::from_i32(call.call_type)
CallType::try_from(call.call_type)
.map_or(false, |call_type| call_type == CallType::Create)
});

Expand Down
2 changes: 1 addition & 1 deletion chain/near/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ impl FirehoseMapperTrait<Chain> for FirehoseMapper {
logger: &Logger,
response: &firehose::Response,
) -> Result<BlockStreamEvent<Chain>, FirehoseError> {
let step = ForkStep::from_i32(response.step).unwrap_or_else(|| {
let step = ForkStep::try_from(response.step).unwrap_or_else(|_| {
panic!(
"unknown step i32 value {}, maybe you forgot update & re-regenerate the protobuf definitions?",
response.step
Expand Down
2 changes: 1 addition & 1 deletion chain/starknet/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ impl FirehoseMapperTrait<Chain> for FirehoseMapper {
logger: &Logger,
response: &firehose::Response,
) -> Result<BlockStreamEvent<Chain>, FirehoseError> {
let step = ForkStep::from_i32(response.step).unwrap_or_else(|| {
let step = ForkStep::try_from(response.step).unwrap_or_else(|_| {
panic!(
"unknown step i32 value {}, maybe you forgot update & re-regenerate the protobuf definitions?",
response.step
Expand Down
2 changes: 1 addition & 1 deletion chain/starknet/src/runtime/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl ToAscObj<AscTransaction> for codec::Transaction {
Ok(AscTransaction {
r#type: asc_new(
heap,
&codec::TransactionType::from_i32(self.r#type)
&codec::TransactionType::try_from(self.r#type)
.expect("invalid TransactionType value"),
gas,
)?,
Expand Down
1 change: 1 addition & 0 deletions graph/proto/substreams.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
syntax = "proto3";


package sf.substreams.v1;

import "google/protobuf/timestamp.proto";
Expand Down
2 changes: 1 addition & 1 deletion graph/src/blockchain/firehose_block_ingestor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ where
while let Some(message) = stream.next().await {
match message {
Ok(v) => {
let step = ForkStep::from_i32(v.step)
let step = ForkStep::try_from(v.step)
.expect("Fork step should always match to known value");

let result = match step {
Expand Down
3 changes: 3 additions & 0 deletions graph/src/firehose/sf.firehose.v2.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// This file is @generated by prost-build.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct A {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SingleBlockRequest {
#[prost(message, repeated, tag = "6")]
pub transforms: ::prost::alloc::vec::Vec<::prost_types::Any>,
Expand Down
3 changes: 3 additions & 0 deletions graph/src/substreams/sf.substreams.v1.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// This file is @generated by prost-build.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct A {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Package {
/// Needs to be one so this file can be used _directly_ as a
/// buf `Image` andor a ProtoSet for grpcurl and other tools
Expand Down
2 changes: 1 addition & 1 deletion substreams/substreams-trigger-filter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ crate-type = ["cdylib"]

[dependencies]
hex = { version = "0.4", default-features = false }
prost.workspace = true
prost = "0.11.9"
substreams = "0.5"
substreams-entity-change = "1.3"
substreams-near-core = "0.10.1"
Expand Down

0 comments on commit 8bab219

Please sign in to comment.