mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 09:21:04 +00:00
Proof of concept: Add a new runtime that uses pallet_contracts (#186)
* seal: Copy over a legacy version of pallet_contracts from substrate * seal: Fix substrate dependency pathes and add as dependency to runtime * seal: Adapt pallet to current substrate version * seal: Add contracts pallet to runtime * seal: Implement rpc runtime api * seal: Update to latest rpc output format * seal: Replace child trie by prefix trie * seal: Add contracts endpoint to the client * seal: fixup rpc test * Fix whitespace issue Co-authored-by: Sergei Shulepov <sergei@parity.io> * seal: Move pallet out of the runtime directory * seal: Create a seperate runtime for contracts * Move parachains to top level directory * seal: Disable rent for easier testing Co-authored-by: Sergei Shulepov <sergei@parity.io>
This commit is contained in:
committed by
GitHub
parent
10533db948
commit
8a6e29eef9
@@ -0,0 +1,74 @@
|
||||
(module
|
||||
(import "env" "ext_get_runtime_storage"
|
||||
(func $ext_get_runtime_storage (param i32 i32) (result 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_scratch_write" (func $ext_scratch_write (param i32 i32)))
|
||||
(import "env" "memory" (memory 1 1))
|
||||
|
||||
(func (export "deploy"))
|
||||
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
|
||||
(func $call (export "call")
|
||||
;; Load runtime storage for the first key and assert that it exists.
|
||||
(call $assert
|
||||
(i32.eq
|
||||
(call $ext_get_runtime_storage
|
||||
(i32.const 16)
|
||||
(i32.const 4)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
|
||||
;; assert $ext_scratch_size == 4
|
||||
(call $assert
|
||||
(i32.eq
|
||||
(call $ext_scratch_size)
|
||||
(i32.const 4)
|
||||
)
|
||||
)
|
||||
|
||||
;; copy contents of the scratch buffer into the contract's memory.
|
||||
(call $ext_scratch_read
|
||||
(i32.const 4) ;; Pointer in memory to the place where to copy.
|
||||
(i32.const 0) ;; Offset from the start of the scratch buffer.
|
||||
(i32.const 4) ;; Count of bytes to copy.
|
||||
)
|
||||
|
||||
;; assert that contents of the buffer is equal to the i32 value of 0x14144020.
|
||||
(call $assert
|
||||
(i32.eq
|
||||
(i32.load
|
||||
(i32.const 4)
|
||||
)
|
||||
(i32.const 0x14144020)
|
||||
)
|
||||
)
|
||||
|
||||
;; Load the second key and assert that it doesn't exist.
|
||||
(call $assert
|
||||
(i32.eq
|
||||
(call $ext_get_runtime_storage
|
||||
(i32.const 20)
|
||||
(i32.const 4)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; The first key, 4 bytes long.
|
||||
(data (i32.const 16) "\01\02\03\04")
|
||||
;; The second key, 4 bytes long.
|
||||
(data (i32.const 20) "\02\03\04\05")
|
||||
)
|
||||
Reference in New Issue
Block a user