git.delta.rocks / unique-network / refs/commits / e8fdadb89923

difftreelog

source

pallets/contracts/fixtures/chain_extension.wat1.2 KiBsourcehistory
1;; Call chain extension by passing through input and output of this contract2(module3	(import "seal0" "seal_call_chain_extension"4		(func $seal_call_chain_extension (param i32 i32 i32 i32 i32) (result i32))5	)6	(import "seal0" "seal_input" (func $seal_input (param i32 i32)))7	(import "seal0" "seal_return" (func $seal_return (param i32 i32 i32)))8	(import "env" "memory" (memory 16 16))910	(func $assert (param i32)11		(block $ok12			(br_if $ok (get_local 0))13			(unreachable)14		)15	)1617	;; [0, 4) len of input output18	(data (i32.const 0) "\02")1920	;; [4, 12) buffer for input2122	;; [12, 16) len of output buffer23	(data (i32.const 12) "\02")2425	;; [16, inf) buffer for output2627	(func (export "deploy"))2829	(func (export "call")30		(call $seal_input (i32.const 4) (i32.const 0))3132		;; the chain extension passes through the input and returns it as output33		(call $seal_call_chain_extension34			(i32.load8_u (i32.const 4))	;; func_id35			(i32.const 4)				;; input_ptr36			(i32.load (i32.const 0))	;; input_len37			(i32.const 16)				;; output_ptr38			(i32.const 12)				;; output_len_ptr39		)4041		;; the chain extension passes through the func_id42		(call $assert (i32.eq (i32.load8_u (i32.const 4))))4344		(call $seal_return (i32.const 0) (i32.const 16) (i32.load (i32.const 12)))45	)46)