11use { { project-name | snake_case} } as blueprint;
22use blueprint:: { TangleTaskManager , TASK_MANAGER_ADDRESS } ;
3- use blueprint_sdk:: alloy:: primitives:: Address ;
4- use blueprint_sdk:: logging:: info;
3+ use blueprint_sdk:: alloy:: primitives:: { address , Address , U256 } ;
4+ use blueprint_sdk:: logging:: { info, warn } ;
55use blueprint_sdk:: macros:: main;
66use blueprint_sdk:: runners:: core:: runner:: BlueprintRunner ;
77use blueprint_sdk:: runners:: eigenlayer:: bls:: EigenlayerBLSConfig ;
@@ -16,13 +16,34 @@ async fn main() {
1616 } ;
1717
1818 // Get the provider
19- let provider = get_provider_http ( & env. http_rpc_endpoint ) ;
19+ let rpc_endpoint = env. http_rpc_endpoint . clone ( ) ;
20+ let provider = get_provider_http ( & rpc_endpoint) ;
2021
2122 // Create an instance of your task manager
2223 let contract = TangleTaskManager :: new ( * TASK_MANAGER_ADDRESS , provider) ;
2324
2425 // Create the event handler from the job
25- let say_hello_job = blueprint:: SayHelloEventHandler :: new ( contract, context) ;
26+ let say_hello_job = blueprint:: SayHelloEventHandler :: new ( contract, context. clone ( ) ) ;
27+
28+ // Spawn a task to create a task - this is just for testing/example purposes
29+ info ! ( "Spawning a task to create a task on the contract..." ) ;
30+ blueprint_sdk:: tokio:: spawn ( async move {
31+ let provider = get_provider_http ( & rpc_endpoint) ;
32+ let contract = TangleTaskManager :: new ( * TASK_MANAGER_ADDRESS , provider) ;
33+ loop {
34+ blueprint_sdk:: tokio:: time:: sleep ( std:: time:: Duration :: from_secs ( 5 ) ) . await ;
35+ // We use the Anvil Account #4 as the Task generator address
36+ let task = contract
37+ . createNewTask ( U256 :: from ( 5 ) , 100u32 , vec ! [ 0 ] . into ( ) )
38+ . from ( address ! ( "15d34AAf54267DB7D7c367839AAf71A00a2C6A65" ) ) ;
39+ let receipt = task. send ( ) . await . unwrap ( ) . get_receipt ( ) . await . unwrap ( ) ;
40+ if receipt. status ( ) {
41+ info ! ( "Task created successfully" ) ;
42+ } else {
43+ warn ! ( "Task creation failed" ) ;
44+ }
45+ }
46+ } ) ;
2647
2748 info ! ( "Starting the event watcher ..." ) ;
2849 let eigen_config = EigenlayerBLSConfig :: new ( Address :: default ( ) , Address :: default ( ) ) ;
0 commit comments