11// Copyright 2023-, Edge & Node, GraphOps, and Semiotic Labs.
22// SPDX-License-Identifier: Apache-2.0
33
4- use alloy:: {
5- dyn_abi:: Eip712Domain ,
6- signers:: {
7- k256,
8- local:: { coins_bip39:: English , MnemonicBuilder , PrivateKeySigner } ,
4+ use indexer_allocation:: Allocation ;
5+ use thegraph_core:: {
6+ alloy:: {
7+ primitives:: { Address , ChainId } ,
8+ signers:: {
9+ k256,
10+ local:: { coins_bip39:: English , MnemonicBuilder , PrivateKeySigner } ,
11+ } ,
12+ sol_types:: Eip712Domain ,
913 } ,
14+ attestation,
15+ attestation:: Attestation ,
16+ DeploymentId ,
1017} ;
11- use thegraph_core:: { attestation, Address , Attestation , ChainId , DeploymentId } ;
12-
13- use indexer_allocation:: Allocation ;
1418
1519pub fn derive_key_pair (
1620 indexer_mnemonic : & str ,
@@ -92,7 +96,7 @@ fn wallet_for_allocation(
9296 // range [0, 100] and checking for a match
9397 for i in 0 ..100 {
9498 // The allocation was either created at the epoch it intended to or one
95- // epoch later. So try both both .
99+ // epoch later. So try both.
96100 for created_at_epoch in [ allocation. created_at_epoch , allocation. created_at_epoch - 1 ] {
97101 // The allocation ID is the address of a unique key pair, we just
98102 // need to find the right one by enumerating them all
@@ -117,12 +121,12 @@ fn wallet_for_allocation(
117121
118122#[ cfg( test) ]
119123mod tests {
120- use alloy:: primitives:: U256 ;
121124 use std:: str:: FromStr ;
122- use test_log:: test;
123125
124126 use indexer_allocation:: { Allocation , AllocationStatus , SubgraphDeployment } ;
125127 use test_assets:: DISPUTE_MANAGER_ADDRESS ;
128+ use test_log:: test;
129+ use thegraph_core:: alloy:: primitives:: { address, U256 } ;
126130
127131 use super :: * ;
128132
@@ -142,7 +146,7 @@ mod tests {
142146 )
143147 . unwrap( )
144148 . address( ) ,
145- Address :: from_str ( "0xfa44c72b753a66591f241c7dc04e8178c30e13af" ) . unwrap ( )
149+ address! ( "fa44c72b753a66591f241c7dc04e8178c30e13af" )
146150 ) ;
147151
148152 assert_eq ! (
@@ -157,7 +161,7 @@ mod tests {
157161 )
158162 . unwrap( )
159163 . address( ) ,
160- Address :: from_str ( "0xa171cd12c3dde7eb8fe7717a0bcd06f3ffa65658" ) . unwrap ( )
164+ address! ( "a171cd12c3dde7eb8fe7717a0bcd06f3ffa65658" )
161165 ) ;
162166 }
163167
@@ -166,7 +170,7 @@ mod tests {
166170 // Note that we use `derive_key_pair` to derive the private key
167171
168172 let allocation = Allocation {
169- id : Address :: from_str ( "0xa171cd12c3dde7eb8fe7717a0bcd06f3ffa65658" ) . unwrap ( ) ,
173+ id : address ! ( "a171cd12c3dde7eb8fe7717a0bcd06f3ffa65658" ) ,
170174 status : AllocationStatus :: Null ,
171175 subgraph_deployment : SubgraphDeployment {
172176 id : DeploymentId :: from_str (
@@ -192,7 +196,7 @@ mod tests {
192196 INDEXER_OPERATOR_MNEMONIC ,
193197 & allocation,
194198 1 ,
195- * DISPUTE_MANAGER_ADDRESS
199+ DISPUTE_MANAGER_ADDRESS
196200 )
197201 . unwrap( )
198202 . signer
@@ -213,7 +217,7 @@ mod tests {
213217
214218 let allocation = Allocation {
215219 // Purposefully wrong address
216- id : Address :: from_str ( "0xdeadbeefcafebabedeadbeefcafebabedeadbeef" ) . unwrap ( ) ,
220+ id : address ! ( "deadbeefcafebabedeadbeefcafebabedeadbeef" ) ,
217221 status : AllocationStatus :: Null ,
218222 subgraph_deployment : SubgraphDeployment {
219223 id : DeploymentId :: from_str (
@@ -237,7 +241,7 @@ mod tests {
237241 INDEXER_OPERATOR_MNEMONIC ,
238242 & allocation,
239243 1 ,
240- * DISPUTE_MANAGER_ADDRESS
244+ DISPUTE_MANAGER_ADDRESS
241245 )
242246 . is_err( ) ) ;
243247 }
0 commit comments