mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 20:27:58 +00:00
f517900a48
This PR introduces: - XCM host functions `xcm_send`, `xcm_execute` - An Xcm trait into the config. that proxy these functions to to `pallet_xcm`, or disable their usage by using `()`. - A mock_network and xcm_test files to test the newly added xcm-related functions. --------- Co-authored-by: Keith Yeung <kungfukeith11@gmail.com> Co-authored-by: Sasha Gryaznov <hi@agryaznov.com> Co-authored-by: command-bot <> Co-authored-by: Francisco Aguirre <franciscoaguirreperez@gmail.com> Co-authored-by: Alexander Theißen <alex.theissen@me.com>
60 lines
1.5 KiB
WebAssembly Text Format
60 lines
1.5 KiB
WebAssembly Text Format
;; This passes its input to `seal_xcm_send` and returns the return value to its caller.
|
|
(module
|
|
(import "seal0" "xcm_send" (func $xcm_send (param i32 i32 i32 i32) (result i32)))
|
|
(import "seal0" "seal_input" (func $seal_input (param i32 i32)))
|
|
(import "seal0" "seal_return" (func $seal_return (param i32 i32 i32)))
|
|
(import "env" "memory" (memory 1 1))
|
|
|
|
;; 0x1000 = 4k in little endian
|
|
;; size of input buffer
|
|
(data (i32.const 0) "\00\10")
|
|
|
|
(func $assert (param i32)
|
|
(block $ok
|
|
(br_if $ok
|
|
(get_local 0)
|
|
)
|
|
(unreachable)
|
|
)
|
|
)
|
|
|
|
(func (export "call")
|
|
|
|
;; Receive the encoded call
|
|
(call $seal_input
|
|
(i32.const 4) ;; Pointer to the input buffer
|
|
(i32.const 0) ;; Size of the length buffer
|
|
)
|
|
|
|
;; Input data layout.
|
|
;; [0..4) - size of the call
|
|
;; [4..7) - dest
|
|
;; [7..) - message
|
|
|
|
;; Call xcm_send with provided input.
|
|
(call $assert
|
|
(i32.eq
|
|
(call $xcm_send
|
|
(i32.const 4) ;; Pointer where the dest is stored
|
|
(i32.const 7) ;; Pointer where the message is stored
|
|
(i32.sub
|
|
(i32.load (i32.const 0)) ;; length of the input buffer
|
|
(i32.const 3) ;; Size of the XCM dest
|
|
)
|
|
(i32.const 100) ;; Pointer to the where the message_id is stored
|
|
)
|
|
(i32.const 0)
|
|
)
|
|
)
|
|
|
|
;; Return the the message_id
|
|
(call $seal_return
|
|
(i32.const 0) ;; flags
|
|
(i32.const 100) ;; Pointer to returned value
|
|
(i32.const 32) ;; length of returned value
|
|
)
|
|
)
|
|
|
|
(func (export "deploy"))
|
|
)
|