File tree Expand file tree Collapse file tree 6 files changed +73
-0
lines changed Expand file tree Collapse file tree 6 files changed +73
-0
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ macro_rules! authorize {
54
54
if !$process. contains_program( program. id( ) ) {
55
55
log( "Adding program to the process" ) ;
56
56
$process. add_program( & program) . map_err( |e| e. to_string( ) ) ?;
57
+ $process. add_program( & program) . map_err( |e| e. to_string( ) ) ?;
57
58
}
58
59
}
59
60
@@ -138,6 +139,7 @@ macro_rules! execute_program {
138
139
if !$process. contains_program( program. id( ) ) {
139
140
log( "Adding program to the process" ) ;
140
141
$process. add_program( & program) . map_err( |e| e. to_string( ) ) ?;
142
+ $process. add_program( & program) . map_err( |e| e. to_string( ) ) ?;
141
143
}
142
144
}
143
145
Original file line number Diff line number Diff line change @@ -365,3 +365,45 @@ impl ProgramManager {
365
365
cost_in_microcredits_v2 ( & stack, & function_id) . map_err ( |e| e. to_string ( ) )
366
366
}
367
367
}
368
+
369
+ #[ cfg( test) ]
370
+ mod tests {
371
+ use super :: * ;
372
+ use crate :: {
373
+ Metadata ,
374
+ array,
375
+ utilities:: test:: { HELLO_PROGRAM , PROVABLE_API } ,
376
+ } ;
377
+
378
+ async fn test_execute_added_program ( ) {
379
+ // Generate the private key.
380
+ let private_key = PrivateKey :: new ( ) ;
381
+
382
+ // Download the fee prover.
383
+ let fee_prover_uri = Metadata :: fee_public ( ) . prover ;
384
+ let fee_proving_key_bytes = reqwest:: get ( fee_prover_uri) . await . unwrap ( ) . bytes ( ) . await . unwrap ( ) . to_vec ( ) ;
385
+ let fee_prover = ProvingKey :: from_bytes ( & fee_proving_key_bytes) . unwrap ( ) ;
386
+ let fee_verifier = VerifyingKey :: fee_public_verifier ( ) ;
387
+
388
+ // Create the execution.
389
+ let transaction = ProgramManager :: execute (
390
+ & private_key,
391
+ HELLO_PROGRAM ,
392
+ "main" ,
393
+ array ! [ "5u32" , "5u32" ] ,
394
+ 0.0 ,
395
+ None ,
396
+ Some ( PROVABLE_API . to_string ( ) ) ,
397
+ None ,
398
+ None ,
399
+ None ,
400
+ Some ( fee_prover) ,
401
+ Some ( fee_verifier) ,
402
+ None ,
403
+ )
404
+ . await
405
+ . unwrap ( ) ;
406
+
407
+ assert ! ( transaction. is_execute( ) ) ;
408
+ }
409
+ }
Original file line number Diff line number Diff line change @@ -118,6 +118,7 @@ impl ProgramManager {
118
118
// If the process does not already contain the program, add it
119
119
if !process. contains_program ( import. id ( ) ) {
120
120
process. add_program ( & import) . map_err ( |err| err. to_string ( ) ) ?;
121
+ process. add_program ( & import) . map_err ( |err| err. to_string ( ) ) ?;
121
122
}
122
123
}
123
124
}
Original file line number Diff line number Diff line change @@ -22,3 +22,6 @@ pub use plaintext::*;
22
22
23
23
pub mod programs;
24
24
pub use programs:: * ;
25
+
26
+ pub mod uri;
27
+ pub use uri:: * ;
Original file line number Diff line number Diff line change @@ -18,6 +18,14 @@ use crate::{array, object};
18
18
19
19
use js_sys:: { Array , Object } ;
20
20
21
+ pub const HELLO_PROGRAM : & str = r#"program hello.aleo;
22
+ function main:
23
+ input r0 as u32.public;
24
+ input r1 as u32.private;
25
+ add r0 r1 into r2;
26
+ output r2 as u32.private;
27
+ "# ;
28
+
21
29
pub const PUZZLE_SPINNER_V002 : & str = r#"import puzzle_arcade_coin_v002.aleo;
22
30
import puzzle_arcade_ticket_v002.aleo;
23
31
Original file line number Diff line number Diff line change
1
+ // Copyright (C) 2019-2025 Provable Inc.
2
+ // This file is part of the Provable SDK library.
3
+
4
+ // The Provable SDK library is free software: you can redistribute it and/or modify
5
+ // it under the terms of the GNU General Public License as published by
6
+ // the Free Software Foundation, either version 3 of the License, or
7
+ // (at your option) any later version.
8
+
9
+ // The Provable SDK library is distributed in the hope that it will be useful,
10
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ // GNU General Public License for more details.
13
+
14
+ // You should have received a copy of the GNU General Public License
15
+ // along with the Provable SDK library. If not, see <https://www.gnu.org/licenses/>.
16
+
17
+ pub const PROVABLE_API : & str = "https://api.explorer.provable.com/v1" ;
You can’t perform that action at this time.
0 commit comments