Files
pezkuwi-subxt/substrate/frame/contracts/fixtures/data/set_code_hash.wat
T
PG Herveou 64effd0e6f Contracts move fixtures to new crate (#2246)
Small PR that introduce a new crate that will host RISC-V & wasm
fixtures for testing pallet-contracts
2023-11-10 13:22:47 +02:00

44 lines
1.0 KiB
WebAssembly Text Format

(module
(import "seal0" "seal_input" (func $seal_input (param i32 i32)))
(import "seal0" "seal_return" (func $seal_return (param i32 i32 i32)))
(import "seal0" "seal_set_code_hash" (func $seal_set_code_hash (param i32) (result i32)))
(import "env" "memory" (memory 1 1))
;; [0, 32) here we store input
;; [32, 36) input size
(data (i32.const 32) "\20")
;; [36, 40) return value
(data (i32.const 36) "\01")
(func $assert (param i32)
(block $ok
(br_if $ok
(get_local 0)
)
(unreachable)
)
)
(func (export "call")
(local $exit_code i32)
(call $seal_input (i32.const 0) (i32.const 32))
(set_local $exit_code
(call $seal_set_code_hash (i32.const 0)) ;; Pointer to the input data.
)
(call $assert
(i32.eq (get_local $exit_code) (i32.const 0)) ;; ReturnCode::Success
)
;; we return 1 after setting new code_hash
;; next `call` will NOT return this value, because contract code has been changed
(call $seal_return (i32.const 0) (i32.const 36) (i32.const 4))
)
(func (export "deploy"))
)