Skip to content

Commit

Permalink
chore: restore the miden_sdk_account_test source code
Browse files Browse the repository at this point in the history
and extract the basic wallet rust sdk test
  • Loading branch information
greenhat committed May 24, 2024
1 parent b8343a4 commit 466680d
Show file tree
Hide file tree
Showing 10 changed files with 5,791 additions and 66 deletions.
2,533 changes: 2,518 additions & 15 deletions tests/integration/expected/rust_sdk_account_test/miden_sdk_account_test.hir

Large diffs are not rendered by default.

1,847 changes: 1,822 additions & 25 deletions tests/integration/expected/rust_sdk_account_test/miden_sdk_account_test.wat

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,279 @@
(component
;; Component Imports
(lower ((digest 0x0000000000000000000000000000000000000000000000000000000000000000) (type (func (abi canon) (param felt) (param felt) (param felt) (param felt) (result felt felt felt felt)))) (#miden:tx_kernel/account #add_asset)
(lower ((digest 0x0000000000000000000000000000000000000000000000000000000000000000) (type (func (abi canon) (param felt) (param felt) (param felt) (param felt) (result felt felt felt felt)))) (#miden:tx_kernel/account #remove_asset)
(lower ((digest 0x0000000000000000000000000000000000000000000000000000000000000000) (type (func (abi canon) (param felt) (param felt) (param felt) (param felt) (param felt) (param felt) (param felt) (param felt) (param felt) (param felt) (result felt)))) (#miden:tx_kernel/tx #create_note)

;; Modules
(module #rust_sdk_basic_wallet
;; Constants
(const (id 0) 0x00100000)

;; Global Variables
(global (export #__stack_pointer) (id 0) (type i32) (const 0))

;; Functions
(func (export #receive_asset) (param i32)
(block 0 (param v0 i32)
(let (v1 i32) (const.i32 0))
(let (v2 i32) (global.load i32 (global.symbol #__stack_pointer)))
(let (v3 i32) (const.i32 32))
(let (v4 i32) (sub.wrapping v2 v3))
(let (v5 (ptr i32)) (global.symbol #__stack_pointer))
(store v5 v4)
(call #miden_sdk_tx_kernel::add_asset v4 v0)
(let (v6 i32) (const.i32 32))
(let (v7 i32) (add.wrapping v4 v6))
(let (v8 (ptr i32)) (global.symbol #__stack_pointer))
(store v8 v7)
(br (block 1)))

(block 1
(ret))
)

(func (export #send_asset)
(param i32) (param felt) (param felt) (param i32)
(block 0
(param v0 i32)
(param v1 felt)
(param v2 felt)
(param v3 i32)
(let (v4 i32) (const.i32 0))
(let (v5 i32) (global.load i32 (global.symbol #__stack_pointer)))
(let (v6 i32) (const.i32 32))
(let (v7 i32) (sub.wrapping v5 v6))
(let (v8 (ptr i32)) (global.symbol #__stack_pointer))
(store v8 v7)
(call #miden_sdk_tx_kernel::remove_asset v7 v0)
(let (v9 felt) (call #miden_sdk_tx_kernel::create_note v7 v1 v2 v3))
(let (v10 i32) (const.i32 32))
(let (v11 i32) (add.wrapping v7 v10))
(let (v12 (ptr i32)) (global.symbol #__stack_pointer))
(store v12 v11)
(br (block 1)))

(block 1
(ret))
)

(func (export #miden_sdk_tx_kernel::add_asset)
(param i32) (param i32)
(block 0 (param v0 i32) (param v1 i32)
(let (v2 i32) (const.i32 0))
(let (v3 i32) (global.load i32 (global.symbol #__stack_pointer)))
(let (v4 i32) (const.i32 32))
(let (v5 i32) (sub.wrapping v3 v4))
(let (v6 (ptr i32)) (global.symbol #__stack_pointer))
(store v6 v5)
(let (v7 u32) (cast v1))
(let (v8 (ptr felt)) (inttoptr v7))
(let (v9 felt) (load v8))
(let (v10 u32) (cast v1))
(let (v11 u32) (add.checked v10 8))
(let (v12 (ptr felt)) (inttoptr v11))
(let (v13 felt) (load v12))
(let (v14 u32) (cast v1))
(let (v15 u32) (add.checked v14 16))
(let (v16 (ptr felt)) (inttoptr v15))
(let (v17 felt) (load v16))
(let (v18 u32) (cast v1))
(let (v19 u32) (add.checked v18 24))
(let (v20 (ptr felt)) (inttoptr v19))
(let (v21 felt) (load v20))
(let [(v22 felt) (v23 felt) (v24 felt) (v25 felt)] (call (#miden:tx_kernel/account #add_asset) v9 v13 v17 v21))
(let (v26 u32) (cast v5))
(let (v27 (ptr felt)) (inttoptr v26))
(store v27 v22)
(let (v28 u32) (add.checked v26 8))
(let (v29 (ptr felt)) (inttoptr v28))
(store v29 v23)
(let (v30 u32) (add.checked v26 16))
(let (v31 (ptr felt)) (inttoptr v30))
(store v31 v24)
(let (v32 u32) (add.checked v26 24))
(let (v33 (ptr felt)) (inttoptr v32))
(store v33 v25)
(let (v34 i32) (const.i32 24))
(let (v35 i32) (add.wrapping v0 v34))
(let (v36 i32) (const.i32 24))
(let (v37 i32) (add.wrapping v5 v36))
(let (v38 u32) (cast v37))
(let (v39 (ptr i64)) (inttoptr v38))
(let (v40 i64) (load v39))
(let (v41 u32) (cast v35))
(let (v42 (ptr i64)) (inttoptr v41))
(store v42 v40)
(let (v43 i32) (const.i32 16))
(let (v44 i32) (add.wrapping v0 v43))
(let (v45 i32) (const.i32 16))
(let (v46 i32) (add.wrapping v5 v45))
(let (v47 u32) (cast v46))
(let (v48 (ptr i64)) (inttoptr v47))
(let (v49 i64) (load v48))
(let (v50 u32) (cast v44))
(let (v51 (ptr i64)) (inttoptr v50))
(store v51 v49)
(let (v52 i32) (const.i32 8))
(let (v53 i32) (add.wrapping v0 v52))
(let (v54 i32) (const.i32 8))
(let (v55 i32) (add.wrapping v5 v54))
(let (v56 u32) (cast v55))
(let (v57 (ptr i64)) (inttoptr v56))
(let (v58 i64) (load v57))
(let (v59 u32) (cast v53))
(let (v60 (ptr i64)) (inttoptr v59))
(store v60 v58)
(let (v61 u32) (cast v5))
(let (v62 (ptr i64)) (inttoptr v61))
(let (v63 i64) (load v62))
(let (v64 u32) (cast v0))
(let (v65 (ptr i64)) (inttoptr v64))
(store v65 v63)
(let (v66 i32) (const.i32 32))
(let (v67 i32) (add.wrapping v5 v66))
(let (v68 (ptr i32)) (global.symbol #__stack_pointer))
(store v68 v67)
(br (block 1)))

(block 1
(ret))
)

(func (export #miden_sdk_tx_kernel::remove_asset)
(param i32) (param i32)
(block 0 (param v0 i32) (param v1 i32)
(let (v2 i32) (const.i32 0))
(let (v3 i32) (global.load i32 (global.symbol #__stack_pointer)))
(let (v4 i32) (const.i32 32))
(let (v5 i32) (sub.wrapping v3 v4))
(let (v6 (ptr i32)) (global.symbol #__stack_pointer))
(store v6 v5)
(let (v7 u32) (cast v1))
(let (v8 (ptr felt)) (inttoptr v7))
(let (v9 felt) (load v8))
(let (v10 u32) (cast v1))
(let (v11 u32) (add.checked v10 8))
(let (v12 (ptr felt)) (inttoptr v11))
(let (v13 felt) (load v12))
(let (v14 u32) (cast v1))
(let (v15 u32) (add.checked v14 16))
(let (v16 (ptr felt)) (inttoptr v15))
(let (v17 felt) (load v16))
(let (v18 u32) (cast v1))
(let (v19 u32) (add.checked v18 24))
(let (v20 (ptr felt)) (inttoptr v19))
(let (v21 felt) (load v20))
(let [(v22 felt) (v23 felt) (v24 felt) (v25 felt)] (call (#miden:tx_kernel/account #remove_asset) v9 v13 v17 v21))
(let (v26 u32) (cast v5))
(let (v27 (ptr felt)) (inttoptr v26))
(store v27 v22)
(let (v28 u32) (add.checked v26 8))
(let (v29 (ptr felt)) (inttoptr v28))
(store v29 v23)
(let (v30 u32) (add.checked v26 16))
(let (v31 (ptr felt)) (inttoptr v30))
(store v31 v24)
(let (v32 u32) (add.checked v26 24))
(let (v33 (ptr felt)) (inttoptr v32))
(store v33 v25)
(let (v34 i32) (const.i32 24))
(let (v35 i32) (add.wrapping v0 v34))
(let (v36 i32) (const.i32 24))
(let (v37 i32) (add.wrapping v5 v36))
(let (v38 u32) (cast v37))
(let (v39 (ptr i64)) (inttoptr v38))
(let (v40 i64) (load v39))
(let (v41 u32) (cast v35))
(let (v42 (ptr i64)) (inttoptr v41))
(store v42 v40)
(let (v43 i32) (const.i32 16))
(let (v44 i32) (add.wrapping v0 v43))
(let (v45 i32) (const.i32 16))
(let (v46 i32) (add.wrapping v5 v45))
(let (v47 u32) (cast v46))
(let (v48 (ptr i64)) (inttoptr v47))
(let (v49 i64) (load v48))
(let (v50 u32) (cast v44))
(let (v51 (ptr i64)) (inttoptr v50))
(store v51 v49)
(let (v52 i32) (const.i32 8))
(let (v53 i32) (add.wrapping v0 v52))
(let (v54 i32) (const.i32 8))
(let (v55 i32) (add.wrapping v5 v54))
(let (v56 u32) (cast v55))
(let (v57 (ptr i64)) (inttoptr v56))
(let (v58 i64) (load v57))
(let (v59 u32) (cast v53))
(let (v60 (ptr i64)) (inttoptr v59))
(store v60 v58)
(let (v61 u32) (cast v5))
(let (v62 (ptr i64)) (inttoptr v61))
(let (v63 i64) (load v62))
(let (v64 u32) (cast v0))
(let (v65 (ptr i64)) (inttoptr v64))
(store v65 v63)
(let (v66 i32) (const.i32 32))
(let (v67 i32) (add.wrapping v5 v66))
(let (v68 (ptr i32)) (global.symbol #__stack_pointer))
(store v68 v67)
(br (block 1)))

(block 1
(ret))
)

(func (export #miden_sdk_tx_kernel::create_note)
(param i32) (param felt) (param felt) (param i32) (result felt)
(block 0
(param v0 i32)
(param v1 felt)
(param v2 felt)
(param v3 i32)
(let (v5 u32) (cast v0))
(let (v6 (ptr felt)) (inttoptr v5))
(let (v7 felt) (load v6))
(let (v8 u32) (cast v0))
(let (v9 u32) (add.checked v8 8))
(let (v10 (ptr felt)) (inttoptr v9))
(let (v11 felt) (load v10))
(let (v12 u32) (cast v0))
(let (v13 u32) (add.checked v12 16))
(let (v14 (ptr felt)) (inttoptr v13))
(let (v15 felt) (load v14))
(let (v16 u32) (cast v0))
(let (v17 u32) (add.checked v16 24))
(let (v18 (ptr felt)) (inttoptr v17))
(let (v19 felt) (load v18))
(let (v20 u32) (cast v3))
(let (v21 (ptr felt)) (inttoptr v20))
(let (v22 felt) (load v21))
(let (v23 u32) (cast v3))
(let (v24 u32) (add.checked v23 8))
(let (v25 (ptr felt)) (inttoptr v24))
(let (v26 felt) (load v25))
(let (v27 u32) (cast v3))
(let (v28 u32) (add.checked v27 16))
(let (v29 (ptr felt)) (inttoptr v28))
(let (v30 felt) (load v29))
(let (v31 u32) (cast v3))
(let (v32 u32) (add.checked v31 24))
(let (v33 (ptr felt)) (inttoptr v32))
(let (v34 felt) (load v33))
(let (v35 felt) (call (#miden:tx_kernel/tx #create_note) v7 v11 v15 v19 v1 v2 v22 v26 v30 v34))
(br (block 1 v35)))

(block 1 (param v4 felt)
(ret v4))
)

;; Imports
(func (import #miden:tx_kernel/account #add_asset)
(param felt) (param felt) (param felt) (param felt) (result felt felt felt felt))
(func (import #miden:tx_kernel/account #remove_asset)
(param felt) (param felt) (param felt) (param felt) (result felt felt felt felt))
(func (import #miden:tx_kernel/tx #create_note)
(param felt) (param felt) (param felt) (param felt) (param felt) (param felt) (param felt) (param felt) (param felt) (param felt) (result felt))
)

)
Loading

0 comments on commit 466680d

Please sign in to comment.