From 6bffacc7f277a69d9a0ea4378a5c9f9b06bc82f9 Mon Sep 17 00:00:00 2001 From: baris <84373657+bars26@users.noreply.github.com> Date: Sat, 22 Aug 2026 14:32:17 +0300 Subject: [PATCH 1/9] fix(miden-bank): rename deposit method to avoid namespace collision --- examples/miden-bank/contracts/bank-account/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/miden-bank/contracts/bank-account/src/lib.rs b/examples/miden-bank/contracts/bank-account/src/lib.rs index 2715184..77a641a 100644 --- a/examples/miden-bank/contracts/bank-account/src/lib.rs +++ b/examples/miden-bank/contracts/bank-account/src/lib.rs @@ -103,7 +103,7 @@ trait Bank { /// Panics if the deposit amount exceeds `MAX_DEPOSIT_AMOUNT`. /// Panics if the resulting balance would exceed `MAX_BALANCE` (u64 overflow). /// Panics if the bank has not been initialized. - fn deposit(&mut self, depositor: AccountId, deposit_asset: Asset); + fn bank_deposit(&mut self, depositor: AccountId, deposit_asset: Asset); /// Withdraw assets back to the depositor. /// @@ -153,7 +153,7 @@ impl Bank for BankStorage { self.balances.get(key) } - fn deposit(&mut self, depositor: AccountId, deposit_asset: Asset) { + fn bank_deposit(&mut self, depositor: AccountId, deposit_asset: Asset) { // Ensure the bank is initialized before accepting deposits self.require_initialized(); From 5471351034846bd6bcc58823d8fce3fc0cd5732d Mon Sep 17 00:00:00 2001 From: baris <84373657+bars26@users.noreply.github.com> Date: Sat, 22 Aug 2026 15:50:16 +0300 Subject: [PATCH 2/9] Rename deposit function to bank_depositfix(miden-bank): update deposit note to use renamed method --- examples/miden-bank/contracts/deposit-note/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/miden-bank/contracts/deposit-note/src/lib.rs b/examples/miden-bank/contracts/deposit-note/src/lib.rs index 5f82e3c..0ff9bc5 100644 --- a/examples/miden-bank/contracts/deposit-note/src/lib.rs +++ b/examples/miden-bank/contracts/deposit-note/src/lib.rs @@ -18,7 +18,7 @@ pub struct Wallet; /// 1. Note is created by a user with fungible assets attached /// 2. Bank account consumes this note /// 3. Note script reads the sender (depositor) and assets -/// 4. For each asset, calls `account.deposit(depositor, asset)` +/// 4. For each asset, calls `account.bank_deposit(depositor, asset)` /// 5. Bank receives the asset and updates the depositor's balance /// /// # Note Inputs @@ -38,7 +38,7 @@ impl DepositNote { // Deposit each asset into the bank for asset in assets { - account.deposit(depositor, asset); + account.bank_deposit(depositor, asset); } } } From 1b008327ea657e94014baa66a4d14f481c83c7ff Mon Sep 17 00:00:00 2001 From: baris <84373657+bars26@users.noreply.github.com> Date: Sat, 22 Aug 2026 16:02:09 +0300 Subject: [PATCH 3/9] docs(miden-bank): update deposit method references Updated references from 'account.deposit' to 'account.bank_deposit' in the documentation to reflect changes in the deposit flow. --- docs/src/miden-bank/05-cross-component-calls.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/src/miden-bank/05-cross-component-calls.md b/docs/src/miden-bank/05-cross-component-calls.md index d8a6e39..e4b7871 100644 --- a/docs/src/miden-bank/05-cross-component-calls.md +++ b/docs/src/miden-bank/05-cross-component-calls.md @@ -19,7 +19,7 @@ By the end of this section, you will have: ## Building on Part 4 -In Part 4, you wrote `account.deposit(depositor, asset)` in the deposit note. But how does that call actually work? This part explains the binding system: +In Part 4, you wrote `account.bank_deposit(depositor, asset)` in the deposit note. But how does that call actually work? This part explains the binding system: ```text ┌────────────────────────────────────────────────────────────┐ @@ -28,7 +28,7 @@ In Part 4, you wrote `account.deposit(depositor, asset)` in the deposit note. Bu │ │ │ bank-account/ │ │ └── src/lib.rs miden build │ -│ fn deposit() ─────────────▶ generated-wit/ │ +│ fn bank_deposit() ─────────────▶ generated-wit/ │ │ fn withdraw() miden-bank-account.wit │ │ │ ┌───────────────────────────┐ │ @@ -37,7 +37,7 @@ In Part 4, you wrote `account.deposit(depositor, asset)` in the deposit note. Bu │ └── src/lib.rs │ │ │ #[account(bank_account::Bank)] │ │ │ pub struct Wallet; │ │ -│ account.deposit(...) ────────────▶ calls via binding│ +│ account.bank_deposit(...) ────────────▶ calls via binding│ │ │ └────────────────────────────────────────────────────────────┘ ``` @@ -112,7 +112,7 @@ impl DepositNote { // Deposit each asset into the bank for asset in assets { - account.deposit(depositor, asset); + account.bank_deposit(depositor, asset); } } } @@ -265,7 +265,7 @@ miden-bank-account.wit -These files enable the deposit note's `#[account(bank_account::Bank)]` wrapper to call `account.deposit()`. +These files enable the deposit note's `#[account(bank_account::Bank)]` wrapper to call `account.bank_deposit()`. ## Common Issues From 690b238171e74e2378159ac8bfc2c8b403d4c2cd Mon Sep 17 00:00:00 2001 From: baris <84373657+bars26@users.noreply.github.com> Date: Sun, 23 Aug 2026 01:40:56 +0300 Subject: [PATCH 4/9] docs(miden-bank): update deposit method references --- docs/src/miden-bank/04-note-scripts.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/src/miden-bank/04-note-scripts.md b/docs/src/miden-bank/04-note-scripts.md index 14a2d63..25eea97 100644 --- a/docs/src/miden-bank/04-note-scripts.md +++ b/docs/src/miden-bank/04-note-scripts.md @@ -28,7 +28,7 @@ Part 3: Part 4: ┌──────────────────┐ ┌──────────────────┐ │ Bank (complete) │ │ Bank (complete) │ │ ─────────────────│ │ ─────────────────│ -│ + deposit() │ │ + deposit() │ +│ + bank_deposit() │ │ + bank_deposit() │ │ + withdraw() │ │ + withdraw() │ └──────────────────┘ └──────────────────┘ ▲ @@ -258,9 +258,9 @@ The Miden compiler prints non-fatal `ERROR` lines about `MAST` serialization on 3. Note script runs depositor = get_sender() → User's AccountId assets = get_assets() → [100 tokens] - account.deposit(depositor, 100 tokens) + account.bank_deposit(depositor, 100 tokens) -4. Bank's deposit() method executes +4. Bank's bank_deposit() method executes - Validates initialization and amount - Updates balance: balances[User] += 100 - Adds asset to vault From 1c9c9a5233eecc3a8db8c134b2baa33e34f66c65 Mon Sep 17 00:00:00 2001 From: baris <84373657+bars26@users.noreply.github.com> Date: Sun, 23 Aug 2026 01:45:31 +0300 Subject: [PATCH 5/9] docs(miden-bank): update deposit method references --- docs/src/miden-bank/06-transaction-scripts.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/miden-bank/06-transaction-scripts.md b/docs/src/miden-bank/06-transaction-scripts.md index 8f8cb6b..5fae65d 100644 --- a/docs/src/miden-bank/06-transaction-scripts.md +++ b/docs/src/miden-bank/06-transaction-scripts.md @@ -33,7 +33,7 @@ In Parts 4-5, you created note scripts that execute when notes are consumed. Now │ • Process incoming assets • Setup, admin operations │ │ │ │ deposit-note/ init-tx-script/ │ -│ └── calls bank_account::deposit() └── calls account.initialize() +│ └── calls bank_account::bank_deposit() └── calls account.initialize() │ │ └────────────────────────────────────────────────────────────────┘ ``` From b370d86c95f0359986bcf9d340b971236ae99490 Mon Sep 17 00:00:00 2001 From: baris <84373657+bars26@users.noreply.github.com> Date: Sun, 23 Aug 2026 01:50:46 +0300 Subject: [PATCH 6/9] docs(miden-bank): update deposit method references --- docs/src/miden-bank/08-complete-flows.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/src/miden-bank/08-complete-flows.md b/docs/src/miden-bank/08-complete-flows.md index fc93188..1acd1c7 100644 --- a/docs/src/miden-bank/08-complete-flows.md +++ b/docs/src/miden-bank/08-complete-flows.md @@ -28,9 +28,9 @@ You've built all the pieces. Now let's see them work together: │ │ │ Components Built: │ │ ┌─────────────────────────────────────────────────────────┐ │ -│ │ bank-account │ Storage + deposit() + withdraw() │ │ +│ │ bank-account │ Storage + bank_deposit() + withdraw() │ │ │ ├─────────────────┼───────────────────────────────────────┤ │ -│ │ deposit-note │ Note script → bank_account::deposit() │ │ +│ │ deposit-note │ Note script → bank_account::bank_deposit() │ │ │ ├─────────────────┼───────────────────────────────────────┤ │ │ │ withdraw-note │ Note script → bank_account::withdraw() │ │ │ ├─────────────────┼───────────────────────────────────────┤ │ From 266644fa079edadf467253b7f99b641bece9b734 Mon Sep 17 00:00:00 2001 From: baris <84373657+bars26@users.noreply.github.com> Date: Sun, 23 Aug 2026 02:03:25 +0300 Subject: [PATCH 7/9] docs(miden-bank): update deposit method references Updated asset management documentation to reflect changes in deposit functions and added skeleton for withdraw function. --- docs/src/miden-bank/03-asset-management.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/miden-bank/03-asset-management.md b/docs/src/miden-bank/03-asset-management.md index df3e2c0..6359e50 100644 --- a/docs/src/miden-bank/03-asset-management.md +++ b/docs/src/miden-bank/03-asset-management.md @@ -27,7 +27,7 @@ Part 2: Part 3: ┌──────────────────┐ ┌──────────────────┐ │ Bank │ │ Bank │ │ ─────────────────│ ──► │ ─────────────────│ -│ + deposit() │ │ + deposit() │ ◄── COMPLETE +│ + bank_deposit() │ │ + bank_deposit() │ ◄── COMPLETE │ (skeleton) │ │ + balance tracking │ │ │ + vault operations │ │ │ + withdraw() │ ◄── NEW (skeleton) From c1eb428c97a07d9bef6b1a7ee28e2be021f1c350 Mon Sep 17 00:00:00 2001 From: baris <84373657+bars26@users.noreply.github.com> Date: Sun, 23 Aug 2026 02:07:18 +0300 Subject: [PATCH 8/9] docs(miden-bank): update deposit method references --- docs/src/miden-bank/02-constants-constraints.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/miden-bank/02-constants-constraints.md b/docs/src/miden-bank/02-constants-constraints.md index 2eb444f..68e41a3 100644 --- a/docs/src/miden-bank/02-constants-constraints.md +++ b/docs/src/miden-bank/02-constants-constraints.md @@ -29,7 +29,7 @@ Part 1: Part 2: │ ────────────────────────│ ──► │ ────────────────────────│ │ + initialize() │ │ + initialize() │ │ + get_depositor_balance()│ │ + get_depositor_balance()│ -│ │ │ + deposit() │ ◄── NEW (skeleton) +│ │ │ + bank_deposit() │ ◄── NEW (skeleton) │ │ │ + MAX_DEPOSIT_AMOUNT │ ◄── NEW constant │ │ │ + MAX_BALANCE │ ◄── NEW constant └─────────────────────────┘ └─────────────────────────┘ From d061ebd5fb10dee5297552543219a0a205ae4544 Mon Sep 17 00:00:00 2001 From: baris <84373657+bars26@users.noreply.github.com> Date: Sun, 23 Aug 2026 02:20:48 +0300 Subject: [PATCH 9/9] docs(miden-bank): fix remaining bank_deposit references --- docs/src/miden-bank/07-output-notes.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/src/miden-bank/07-output-notes.md b/docs/src/miden-bank/07-output-notes.md index e911c68..20e24df 100644 --- a/docs/src/miden-bank/07-output-notes.md +++ b/docs/src/miden-bank/07-output-notes.md @@ -93,7 +93,7 @@ impl Bank for BankStorage { // bound to the note metadata, so it cannot be spoofed by a malicious caller. let depositor = active_note::get_sender(); - // Verify this is a fungible asset — see `deposit()` for the rationale. + // Verify this is a fungible asset — see `bank_deposit()` for the rationale. assert!( withdraw_asset.value[1].as_canonical_u64() == 0, "Only fungible assets are supported" @@ -131,7 +131,7 @@ impl Bank for BankStorage { } ``` -The withdraw method derives the balance-map key inline by packing `depositor.prefix`, `depositor.suffix`, `withdraw_asset.key[3]`, and `withdraw_asset.key[2]` into a `Word`. In the v0.15 fungible-asset vault-key layout, `asset.key[3]` is the faucet id prefix and `asset.key[2]` is the faucet id suffix with the asset's metadata byte folded into its low 8 bits — so `key[2]` is NOT the raw faucet suffix. `withdraw()` and `deposit()` derive the key the same way so a withdrawal reconstructs the exact key the deposit was recorded under. +The withdraw method derives the balance-map key inline by packing `depositor.prefix`, `depositor.suffix`, `withdraw_asset.key[3]`, and `withdraw_asset.key[2]` into a `Word`. In the v0.15 fungible-asset vault-key layout, `asset.key[3]` is the faucet id prefix and `asset.key[2]` is the faucet id suffix with the asset's metadata byte folded into its low 8 bits — so `key[2]` is NOT the raw faucet suffix. `withdraw()` and `bank_deposit()` derive the key the same way so a withdrawal reconstructs the exact key the deposit was recorded under. :::danger Critical Security: Balance Validation Always validate `current_balance >= withdraw_amount` BEFORE subtraction. Miden uses modular field arithmetic - subtracting a larger value silently wraps to a massive positive number!