mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 13:21:01 +00:00
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
This commit is contained in:
committed by
GitHub
parent
a4427f3635
commit
25de5b5c78
@@ -1,10 +1,9 @@
|
||||
(module
|
||||
(import "env" "ext_transfer" (func $ext_transfer (param i32 i32 i32 i32) (result i32)))
|
||||
(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_scratch_size" (func $ext_scratch_size (result i32)))
|
||||
(import "env" "ext_scratch_read" (func $ext_scratch_read (param i32 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
|
||||
@@ -25,12 +24,7 @@
|
||||
|
||||
;; transfer 50 to CHARLIE
|
||||
(func $call_2
|
||||
(call $assert
|
||||
(i32.eq
|
||||
(call $ext_transfer (i32.const 68) (i32.const 8) (i32.const 76) (i32.const 8))
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(call $ext_transfer (i32.const 68) (i32.const 8) (i32.const 76) (i32.const 8))
|
||||
)
|
||||
|
||||
;; do nothing
|
||||
@@ -48,8 +42,10 @@
|
||||
;; 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
|
||||
(call $ext_scratch_size)
|
||||
(i32.load (i32.const 64))
|
||||
)
|
||||
(block $IF_ELSE
|
||||
(block $IF_2
|
||||
@@ -75,29 +71,27 @@
|
||||
;; Set into storage a 4 bytes value
|
||||
;; Set call set_rent_allowance with input
|
||||
(func (export "deploy")
|
||||
(local $input_size i32)
|
||||
(set_local $input_size
|
||||
(call $ext_scratch_size)
|
||||
)
|
||||
(call $ext_set_storage
|
||||
(i32.const 0)
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
)
|
||||
(call $ext_scratch_read
|
||||
(call $ext_input
|
||||
(i32.const 0)
|
||||
(i32.const 0)
|
||||
(get_local $input_size)
|
||||
(i32.const 64)
|
||||
)
|
||||
(call $ext_set_rent_allowance
|
||||
(i32.const 0)
|
||||
(get_local $input_size)
|
||||
(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")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user