Files
pezkuwi-subxt/substrate/frame/contracts/fixtures/set_rent.wat
T
Alexander Theißen 25de5b5c78 seal: Rework contracts API (#6573)
* Transition getter functions to not use scratch buffer

* Remove scratch buffer from ext_get_storage

* Remove scratch buffer from ext_call

* Remove scratch buffer from ext_instantiate

* Add ext_input and remove scratch buffer

* Rework error handling (changes RPC exposed data)

* ext_return passes a flags field instead of a return code
	* Flags is only for seal and not for the caller
	* flags: u32 replaced status_code: u8 in RPC exposed type
* API functions use a unified error type (ReturnCode)
* ext_transfer now traps on error to be consistent with call and instantiate

* Remove the no longer used `Dispatched` event

* Updated inline documentation

* Prevent skipping of copying the output for getter API

* Return gas_consumed from the RPC contracts call interface

* Updated COMPLEXTITY.md

* Rename ext_gas_price to ext_weight_to_fee

* Align comments with spaces

* Removed no longer used `ExecError`

* Remove possible panic in `from_typed_value`

* Use a struct as associated data for SpecialTrap::Return

* Fix nits in COMPLEXITY.md

* Renamed SpecialTrap to TrapReason

* Fix test

* Finish renaming special_trap -> trap_reason

* Remove no longer used get_runtime_storage

* fixup! Remove no longer used get_runtime_storage

* Removed tabs for comment aligment
2020-07-09 13:07:02 +00:00

101 lines
2.0 KiB
WebAssembly Text Format

(module
(import "env" "ext_transfer" (func $ext_transfer (param i32 i32 i32 i32)))
(import "env" "ext_set_storage" (func $ext_set_storage (param i32 i32 i32)))
(import "env" "ext_clear_storage" (func $ext_clear_storage (param i32)))
(import "env" "ext_set_rent_allowance" (func $ext_set_rent_allowance (param i32 i32)))
(import "env" "ext_input" (func $ext_input (param i32 i32)))
(import "env" "memory" (memory 1 1))
;; insert a value of 4 bytes into storage
(func $call_0
(call $ext_set_storage
(i32.const 1)
(i32.const 0)
(i32.const 4)
)
)
;; remove the value inserted by call_1
(func $call_1
(call $ext_clear_storage
(i32.const 1)
)
)
;; transfer 50 to CHARLIE
(func $call_2
(call $ext_transfer (i32.const 68) (i32.const 8) (i32.const 76) (i32.const 8))
)
;; do nothing
(func $call_else)
(func $assert (param i32)
(block $ok
(br_if $ok
(get_local 0)
)
(unreachable)
)
)
;; Dispatch the call according to input size
(func (export "call")
(local $input_size i32)
(i32.store (i32.const 64) (i32.const 64))
(call $ext_input (i32.const 1024) (i32.const 64))
(set_local $input_size
(i32.load (i32.const 64))
)
(block $IF_ELSE
(block $IF_2
(block $IF_1
(block $IF_0
(br_table $IF_0 $IF_1 $IF_2 $IF_ELSE
(get_local $input_size)
)
(unreachable)
)
(call $call_0)
return
)
(call $call_1)
return
)
(call $call_2)
return
)
(call $call_else)
)
;; Set into storage a 4 bytes value
;; Set call set_rent_allowance with input
(func (export "deploy")
(call $ext_set_storage
(i32.const 0)
(i32.const 0)
(i32.const 4)
)
(call $ext_input
(i32.const 0)
(i32.const 64)
)
(call $ext_set_rent_allowance
(i32.const 0)
(i32.load (i32.const 64))
)
)
;; Encoding of 10 in balance
(data (i32.const 0) "\28")
;; Size of the buffer at address 0
(data (i32.const 64) "\40")
;; encoding of Charlies's account id
(data (i32.const 68) "\03")
;; encoding of 50 balance
(data (i32.const 76) "\32")
)