File tree Expand file tree Collapse file tree 2 files changed +16
-17
lines changed Expand file tree Collapse file tree 2 files changed +16
-17
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ use graphql_parser::query::{Name, Value};
33use std:: collections:: { BTreeMap , HashMap } ;
44use std:: str:: FromStr ;
55
6- use crate :: prelude:: format_err;
6+ use crate :: prelude:: { format_err, BigInt } ;
77use web3:: types:: { H160 , H256 } ;
88
99pub trait TryFromValue : Sized {
@@ -84,6 +84,19 @@ impl TryFromValue for H256 {
8484 }
8585}
8686
87+ impl TryFromValue for BigInt {
88+ fn try_from_value ( value : & Value ) -> Result < Self , Error > {
89+ match value {
90+ Value :: String ( s) => BigInt :: from_str ( s)
91+ . map_err ( |e| format_err ! ( "Cannot parse BigInt value from string `{}`: {}" , s, e) ) ,
92+ _ => Err ( format_err ! (
93+ "Cannot parse value into an BigInt: {:?}" ,
94+ value
95+ ) ) ,
96+ }
97+ }
98+ }
99+
87100impl < T > TryFromValue for Vec < T >
88101where
89102 T : TryFromValue ,
Original file line number Diff line number Diff line change 11use graphql_parser:: { query as q, query:: Name , schema as s, schema:: ObjectType } ;
22use std:: collections:: { BTreeMap , HashMap } ;
3- use std:: str:: FromStr ;
43
54use graph:: data:: graphql:: { TryFromValue , ValueList , ValueMap } ;
65use graph:: data:: subgraph:: schema:: SUBGRAPHS_ID ;
@@ -149,22 +148,9 @@ impl IndexingStatusWithoutNode {
149148 let number_key = format ! ( "{}Number" , prefix) ;
150149
151150 match (
151+ value. get_optional :: < H256 > ( hash_key. as_ref ( ) ) ?,
152152 value
153- . get_optional :: < q:: Value > ( hash_key. as_ref ( ) ) ?
154- . and_then ( |value| match value {
155- q:: Value :: String ( s) => Some ( s) ,
156- _ => None ,
157- } )
158- . map ( |s| H256 :: from_str ( s. as_ref ( ) ) )
159- . transpose ( ) ?,
160- value
161- . get_optional :: < q:: Value > ( number_key. as_ref ( ) ) ?
162- . and_then ( |value| match value {
163- q:: Value :: String ( s) => Some ( s) ,
164- _ => None ,
165- } )
166- . map ( |s| BigInt :: from_str ( s. as_ref ( ) ) )
167- . transpose ( ) ?
153+ . get_optional :: < BigInt > ( number_key. as_ref ( ) ) ?
168154 . map ( |n| n. to_u64 ( ) ) ,
169155 ) {
170156 // Only return an Ethereum block if we can parse both the block hash and number
You can’t perform that action at this time.
0 commit comments