Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions masm/accounts/auth/no_auth.masm
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
use miden::protocol::native_account

#! Authorizes a transaction without signature checks and increments the account nonce.
#!
#! Inputs: []
#! Outputs: []
#!
#! Invocation: auth script
@auth_script
pub proc auth__basic
exec.native_account::incr_nonce drop
Expand Down
16 changes: 12 additions & 4 deletions masm/accounts/count_reader.masm
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,28 @@ use miden::core::sys
# The storage slot where the copied count is stored.
const COUNT_READER_SLOT = word("miden::tutorials::count_reader")

# => [account_id_suffix, account_id_prefix, PROC_HASH(4), foreign_procedure_inputs(16)]
#! Copies a count from a foreign account into this account's storage.
#!
#! Inputs: [account_id_suffix, account_id_prefix, PROC_HASH, foreign_procedure_inputs]
#! Outputs: []
#!
#! Where:
#! - account_id_{prefix,suffix} identify the foreign account.
#! - PROC_HASH is the foreign procedure hash.
#! - foreign_procedure_inputs are the inputs reserved for the foreign procedure call.
#!
#! Invocation: call
pub proc copy_count
exec.tx::execute_foreign_procedure
# => [count, pad(12)]

push.COUNT_READER_SLOT[0..2]
# [slot_id_prefix, slot_id_suffix, count, pad(12)]
# => [slot_id_prefix, slot_id_suffix, count, pad(12)]

exec.native_account::set_item
# => [OLD_VALUE, pad(12)]

dropw dropw dropw dropw
# => []

exec.sys::truncate_stack
# => []
end
9 changes: 5 additions & 4 deletions masm/accounts/counter.masm
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,29 @@ use miden::core::sys

const COUNTER_SLOT = word("miden::tutorials::counter")

#! Description: Reads the current counter value from active account storage.
#! Inputs: []
#! Outputs: [count]
#! Invocation: exec
pub proc get_count
push.COUNTER_SLOT[0..2] exec.active_account::get_item
# => [count]

exec.sys::truncate_stack
# => [count]
end

#! Description: Increments the active account counter by one and stores the updated value.
#! Inputs: []
#! Outputs: []
#! Invocation: exec
pub proc increment_count
push.COUNTER_SLOT[0..2] exec.active_account::get_item
# => [count]

add.1
# => [count+1]
# => [count]

push.COUNTER_SLOT[0..2] exec.native_account::set_item
# => []

exec.sys::truncate_stack
# => []
end