mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-16 19:01:02 +00:00
04b185e3d4
* seal: Change prefix "ext_" to "seal_" for contract callable functions The word Ext is a overloaded term in the context of substrate. It usually is a trait which abstracts away access to external resources usually in order to mock them away for the purpose of tests. The contract module has its own `Ext` trait in addition the the substrate `Ext` which makes things even more confusing. In order to differentiate the contract callable functions more clearly from this `Ext` concept we rename them to use the "seal_" prefix instead. This should change no behaviour at all. This is a pure renaming commit. * seal: Rename import module from "env" to "seal0" * seal: Fixup integration test * seal: Add more tests for new import module names
106 lines
2.1 KiB
WebAssembly Text Format
106 lines
2.1 KiB
WebAssembly Text Format
(module
|
|
(import "seal0" "seal_transfer" (func $seal_transfer (param i32 i32 i32 i32) (result i32)))
|
|
(import "seal0" "seal_set_storage" (func $seal_set_storage (param i32 i32 i32)))
|
|
(import "seal0" "seal_clear_storage" (func $seal_clear_storage (param i32)))
|
|
(import "seal0" "seal_set_rent_allowance" (func $seal_set_rent_allowance (param i32 i32)))
|
|
(import "seal0" "seal_input" (func $seal_input (param i32 i32)))
|
|
(import "env" "memory" (memory 1 1))
|
|
|
|
;; insert a value of 4 bytes into storage
|
|
(func $call_0
|
|
(call $seal_set_storage
|
|
(i32.const 1)
|
|
(i32.const 0)
|
|
(i32.const 4)
|
|
)
|
|
)
|
|
|
|
;; remove the value inserted by call_1
|
|
(func $call_1
|
|
(call $seal_clear_storage
|
|
(i32.const 1)
|
|
)
|
|
)
|
|
|
|
;; transfer 50 to CHARLIE
|
|
(func $call_2
|
|
(call $assert
|
|
(i32.eq
|
|
(call $seal_transfer (i32.const 68) (i32.const 8) (i32.const 76) (i32.const 8))
|
|
(i32.const 0)
|
|
)
|
|
)
|
|
)
|
|
|
|
;; 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 $seal_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 $seal_set_storage
|
|
(i32.const 0)
|
|
(i32.const 0)
|
|
(i32.const 4)
|
|
)
|
|
(call $seal_input
|
|
(i32.const 0)
|
|
(i32.const 64)
|
|
)
|
|
(call $seal_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")
|
|
)
|