github.com/hyperledger/burrow@v0.34.5-0.20220512172541-77f09336001d/execution/solidity/ewasm.solang (about)

     1  interface E {
     2  	function get_vm() external returns (string memory);
     3  	function get_number() external returns (int);
     4  }
     5  
     6  event L (
     7  	int indexed f1,
     8  	string f2,
     9  	bool f3
    10  );
    11  
    12  contract ewasm is E {
    13  	function get_vm() public override pure returns (string memory) {
    14  		return "ewasm";
    15  	}
    16  
    17  	function get_number() public pure override returns (int) {
    18  		return 54321;
    19  	}
    20  
    21  	function call_get_vm(E e) public returns (string memory) {
    22  		// solc can't do this
    23  		return "ewasm called " + e.get_vm();
    24  	}
    25  
    26  	function call_get_number(E e) public returns (int) {
    27  		return e.get_number();
    28  	}
    29  
    30  	function try_revert() public pure {
    31  		revert();
    32  	}
    33  
    34  	function hash_tests() public pure {
    35  		bytes32 hash1 = keccak256("Hello, World!");
    36  
    37  		assert(hash1 == hex"acaf3289d7b601cbd114fb36c4d29c85bbfd5e133f14cb355c3fd8d99367964f");
    38  
    39  		bytes32 hash2 = sha256("Hello, World!");
    40  
    41  		assert(hash2 == hex"dffd6021bb2bd5b0af676290809ec3a53191dd81c7f70a4b28688a362182986f");
    42  
    43  		bytes20 hash3 = ripemd160("Hello, World!");
    44  
    45  		assert(hash3 == hex"527a6a4b9a6da75607546842e0e00105350b1aaf");
    46  	}
    47  
    48  	function test_events() public {
    49  		emit L(102, "Hello from wasm", true);
    50  	}
    51  
    52  	function test_print(int64 arg1, string arg2) public {
    53  		print("arg1:{} arg2:{}".format(arg1, arg2));
    54  	}
    55  }