File tree Expand file tree Collapse file tree 3 files changed +90
-0
lines changed
Expand file tree Collapse file tree 3 files changed +90
-0
lines changed Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: UNLICENSED
2+ pragma solidity >= 0.8.0 ;
3+
4+ interface ArbWasm {
5+ /// @notice Activate a wasm program
6+ /// @param program the program to activate
7+ /// @return version the stylus version the program was activated against
8+ /// @return dataFee the data fee paid to store the activated program
9+ function activateProgram (
10+ address program
11+ ) external payable returns (uint16 version , uint256 dataFee );
12+ }
13+
14+ contract C is ArbWasm {
15+ function forwardActivateProgram (
16+ address target ,
17+ address program
18+ ) public payable returns (uint16 , uint256 ) {
19+ print ("target = {} " .format (target));
20+ (uint16 version , uint256 dataFee ) = ArbWasm (target).activateProgram {
21+ value: msg .value
22+ }(program);
23+ print ("version = {} " .format (version));
24+ print ("dataFee = {} " .format (dataFee));
25+ return (version, dataFee);
26+ }
27+
28+ function activateProgram (
29+ address program
30+ ) public payable returns (uint16 , uint256 ) {
31+ print ("program = {} " .format (program));
32+ uint256 value = msg .value ;
33+ print ("value = {} " .format (value));
34+ return (1 , 1000 );
35+ }
36+ }
37+
38+ contract D {
39+ function greet () public pure {
40+ print ("Hello! " );
41+ }
42+ }
Original file line number Diff line number Diff line change 1+ //! This test expects you to have a devnode running:
2+ //! <https://docs.arbitrum.io/run-arbitrum-node/run-nitro-dev-node>
3+ //!
4+ //! It also expects `cargo-stylus` and `cast` to be installed:
5+ //! - <https://github.com/OffchainLabs/cargo-stylus>
6+ //! - <https://book.getfoundry.sh/cast/>
7+ #![ warn( clippy:: pedantic) ]
8+
9+ use crate :: { call, deploy, send, MUTEX } ;
10+ use std:: path:: PathBuf ;
11+
12+ #[ test]
13+ fn arb_wasm ( ) {
14+ let _lock = MUTEX . lock ( ) ;
15+
16+ let ( tempdir, address_c) = deploy (
17+ PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) . join ( "integration/stylus/arb_wasm.sol" ) ,
18+ "C" ,
19+ true ,
20+ )
21+ . unwrap ( ) ;
22+ let dir_c = & tempdir;
23+
24+ let ( tempdir, address_d) = deploy (
25+ PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) . join ( "integration/stylus/arb_wasm.sol" ) ,
26+ "D" ,
27+ false ,
28+ )
29+ . unwrap ( ) ;
30+ let dir_d = & tempdir;
31+
32+ let stdout = send (
33+ dir_c,
34+ & address_c,
35+ [
36+ "forwardActivateProgram(address,address)" ,
37+ & format ! ( "0x{:0>40x}" , 0x71 ) ,
38+ & address_d,
39+ "--value=1000000000000000000" ,
40+ ] ,
41+ )
42+ . unwrap ( ) ;
43+ println ! ( "{}" , & stdout) ;
44+
45+ let stdout = call ( dir_d, & address_d, [ "greet()" ] ) . unwrap ( ) ;
46+ println ! ( "{}" , & stdout) ;
47+ }
Original file line number Diff line number Diff line change 11mod api;
2+ mod arb_wasm;
23mod counter;
34mod milestone_1;
45mod milestone_2;
You can’t perform that action at this time.
0 commit comments