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

difftreelog

source

pallets/contracts/fixtures/self_destruct.wat2.4 KiBsourcehistory
1(module2	(import "seal0" "seal_input" (func $seal_input (param i32 i32)))3	(import "seal0" "seal_address" (func $seal_address (param i32 i32)))4	(import "seal0" "seal_call" (func $seal_call (param i32 i32 i64 i32 i32 i32 i32 i32 i32) (result i32)))5	(import "seal0" "seal_terminate" (func $seal_terminate (param i32 i32)))6	(import "env" "memory" (memory 1 1))78	;; [0, 32) reserved for $seal_address output910	;; [32, 36) length of the buffer11	(data (i32.const 32) "\20")1213	;; [36, 68) Address of django14	(data (i32.const 36)15		"\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04"16		"\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04"17	)1819	;; [68, 72) reserved for output of $seal_input2021	;; [72, 76) length of the buffer22	(data (i32.const 72) "\04")2324	;; [76, inf) zero initialized2526	(func $assert (param i32)27		(block $ok28			(br_if $ok29				(get_local 0)30			)31			(unreachable)32		)33	)3435	(func (export "deploy"))3637	(func (export "call")38		;; If the input data is not empty, then recursively call self with empty input data.39		;; This should trap instead of self-destructing since a contract cannot be removed live in40		;; the execution stack cannot be removed. If the recursive call traps, then trap here as41		;; well.42		(call $seal_input (i32.const 68) (i32.const 72))43		(if (i32.load (i32.const 72))44			(then45				(call $seal_address (i32.const 0) (i32.const 32))4647				;; Expect address to be 8 bytes.48				(call $assert49					(i32.eq50						(i32.load (i32.const 32))51						(i32.const 32)52					)53				)5455				;; Recursively call self with empty input data.56				(call $assert57					(i32.eq58						(call $seal_call59							(i32.const 0)	;; Pointer to own address60							(i32.const 32)	;; Length of own address61							(i64.const 0)	;; How much gas to devote for the execution. 0 = all.62							(i32.const 76)	;; Pointer to the buffer with value to transfer63							(i32.const 8)	;; Length of the buffer with value to transfer64							(i32.const 0)	;; Pointer to input data buffer address65							(i32.const 0)	;; Length of input data buffer66							(i32.const 4294967295) ;; u32 max sentinel value: do not copy output67							(i32.const 0) ;; Length is ignored in this case68						)69						(i32.const 0)70					)71				)72			)73			(else74				;; Try to terminate and give balance to django.75				(call $seal_terminate76					(i32.const 36)	;; Pointer to beneficiary address77					(i32.const 32)	;; Length of beneficiary address78				)79				(unreachable) ;; seal_terminate never returns80			)81		)82	)83)