algonaut 0.9.0

A Rusty sdk for the Algorand blockchain.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
//! End-to-end tests for the ARC-56 `contract!` client against a live node.
//!
//! These deploy the generated `Vault` client and exercise the whole surface on
//! chain — deploy, an atomic group of typed-struct calls, a read-only simulate,
//! typed global-state reads, ARC-28 event decoding, the declared OptIn
//! lifecycle action, and a literal default argument.
//!
//! The suite is `[[test]] test = false`, so the default `cargo test` (and CI
//! without a node) skips it, and `make check-e2e` compile-checks it. Run it
//! against a local node with:
//!
//! ```sh
//! make sandbox     # a dev algod+kmd on :4001/:4002 with the dev token
//! make test-e2e    # = cargo test --test e2e
//! ```
//!
//! They self-fund: each test mints a fresh account and tops it up from the
//! sandbox's KMD default wallet, so no mnemonics or manual funding are needed.
//! `ALGOD_URL` / `ALGOD_TOKEN` / `KMD_URL` / `KMD_TOKEN` override the defaults.

use algonaut::abi::abi_type::AbiValue;
use algonaut::atomic::{AbiMethodReturnValue, AtomicGroupBuilder};
use algonaut::core::{Address, MicroAlgos};
use algonaut::transaction::account::Account;
use algonaut::transaction::{Pay, Signer};
use algonaut::{Algod, Kmd};
use std::env;
use std::sync::Arc;

algonaut::contract!("tests/fixtures/vault.arc56.json");

// A real, AlgoKit-produced spec. It is created through an ABI `createApplication`
// method (not a bare create), carries a `someNumber` TEAL template variable (a
// generated `deploy` parameter), and its `foo` method (an inline-nested struct
// arg) is omitted from the client rather than failing compilation.
algonaut::contract!("tests/fixtures/arc56_test.arc56.json");

// A spec that ships only precompiled `byteCode` (no TEAL `source`) and is
// created with a bare app-create. Its programs (`int 1`) approve any call, so
// `deploy` exercises the byteCode-only path end-to-end against a live node:
// the macro builds the approval/clear programs directly from the base64
// byteCode instead of compiling TEAL through algod.
algonaut::contract!("tests/fixtures/bytecode_bare.arc56.json");

fn env_or(key: &str, default: &str) -> String {
    env::var(key).unwrap_or_else(|_| default.to_owned())
}

fn algod() -> Algod {
    Algod::new(
        &env_or("ALGOD_URL", "http://localhost:4001"),
        &env_or("ALGOD_TOKEN", &"a".repeat(64)),
    )
    .expect("algod client")
}

fn kmd() -> Kmd {
    Kmd::new(
        &env_or("KMD_URL", "http://localhost:4002"),
        &env_or("KMD_TOKEN", &"a".repeat(64)),
    )
    .expect("kmd client")
}

/// Mint a fresh account and fund it from the sandbox KMD default wallet, so the
/// tests need no pre-funded mnemonic. KMD signs the dispensing payment; the
/// fresh account (whose key we hold) then signs the contract interactions.
async fn funded_account(algod: &Algod, kmd: &Kmd) -> Account {
    let account = Account::generate();

    let wallet_id = kmd
        .list_wallets()
        .await
        .expect("list wallets")
        .wallets
        .into_iter()
        .find(|w| w.name == "unencrypted-default-wallet")
        .expect("default wallet present (run `make sandbox`)")
        .id;
    let handle = kmd
        .init_wallet_handle(&wallet_id, "")
        .await
        .expect("init wallet handle")
        .wallet_handle_token;
    let dispenser: Address = kmd
        .list_keys(&handle)
        .await
        .expect("list keys")
        .addresses
        .first()
        .expect("a funded genesis account")
        .parse()
        .expect("genesis address parses");

    let params = algod.suggested_params().await.expect("suggested params");
    let pay = Pay::new(dispenser, account.address(), MicroAlgos(10_000_000))
        .build(&params)
        .expect("build funding payment");
    let signed = kmd
        .sign(&handle, "", &pay)
        .await
        .expect("kmd signs funding payment")
        .signed_transaction;
    algod
        .submit_raw(&signed)
        .await
        .expect("submit funding payment")
        .confirm()
        .await
        .expect("funding payment confirms");

    account
}

/// Deploy a fresh `Vault` from a freshly funded account.
async fn deploy_vault(algod: &Algod, kmd: &Kmd) -> (Vault, Address) {
    let account = funded_account(algod, kmd).await;
    let sender = account.address();
    let signer: Arc<dyn Signer> = Arc::new(account);
    let params = algod.suggested_params().await.expect("suggested params");
    let vault = Vault::deploy(algod, sender, signer, &params)
        .await
        .expect("deploy Vault");
    (vault, sender)
}

/// Deploy the real `ARC56Test` contract from a freshly funded account. Unlike
/// Vault, it is created through its ABI `createApplication()` method, and its
/// `someNumber` template variable is supplied as a `deploy` argument.
async fn deploy_arc56_test(algod: &Algod, kmd: &Kmd) -> (ARC56Test, Address) {
    let account = funded_account(algod, kmd).await;
    let sender = account.address();
    let signer: Arc<dyn Signer> = Arc::new(account);
    let params = algod.suggested_params().await.expect("suggested params");
    let client = ARC56Test::deploy(algod, sender, signer, &params, 1)
        .await
        .expect("deploy ARC56Test");
    (client, sender)
}

/// Deploy the `byteCode`-only `ByteCodeBare` contract from a freshly funded
/// account. Unlike Vault, the macro does not compile TEAL `source` through
/// algod — it builds the programs directly from the spec's precompiled
/// `byteCode`.
async fn deploy_bytecode_bare(algod: &Algod, kmd: &Kmd) -> (ByteCodeBare, Address) {
    let account = funded_account(algod, kmd).await;
    let sender = account.address();
    let signer: Arc<dyn Signer> = Arc::new(account);
    let params = algod.suggested_params().await.expect("suggested params");
    let client = ByteCodeBare::deploy(algod, sender, signer, &params)
        .await
        .expect("deploy ByteCodeBare");
    (client, sender)
}

#[tokio::test]
async fn deploy_creates_app() {
    let (vault, _) = deploy_vault(&algod(), &kmd()).await;
    assert!(vault.app_id().0 > 0, "deploy should create an application");
}

#[tokio::test]
async fn deploy_from_bytecode_creates_app() {
    let (client, _) = deploy_bytecode_bare(&algod(), &kmd()).await;
    assert!(
        client.app_id().0 > 0,
        "byteCode-only deploy should create an application"
    );
}

#[tokio::test]
async fn full_walkthrough() {
    let algod = algod();
    let (vault, sender) = deploy_vault(&algod, &kmd()).await;
    let params = algod.suggested_params().await.unwrap();

    // An atomic group of typed-struct calls: store(2,3), scale((4,5),10),
    // store_wrapped((6,7),"demo"). store sets total=5 and emits Counted(5);
    // store_wrapped sets total=6+7=13.
    let store = vault
        .store(Pair {
            first: 2,
            second: 3,
        })
        .build(&params);
    let scale = vault
        .scale(
            Pair {
                first: 4,
                second: 5,
            },
            10,
        )
        .build(&params);
    let wrapped = vault
        .store_wrapped(Wrapper {
            inner: Pair {
                first: 6,
                second: 7,
            },
            label: "demo".to_owned(),
        })
        .build(&params);

    let executed = AtomicGroupBuilder::new()
        .add_method_call(store)
        .add_method_call(scale)
        .add_method_call(wrapped)
        .build()
        .unwrap()
        .sign()
        .await
        .unwrap()
        .execute(&algod)
        .await
        .unwrap();
    assert!(executed.confirmed_round.is_some(), "group should confirm");

    // scale (2nd call) returns (4 + 5) * 10 = 90.
    match &executed.method_results[1].return_value {
        Ok(AbiMethodReturnValue::Some(value)) => assert_eq!(value, &AbiValue::from(90u64)),
        other => panic!("unexpected scale return: {other:?}"),
    }

    // ARC-28 events: store (the first call) logged Counted(5).
    let logs = executed.method_results[0]
        .transaction_info
        .logs
        .as_ref()
        .expect("store should produce a log");
    let raw: Vec<Vec<u8>> = logs.iter().map(|log| log.0.clone()).collect();
    assert_eq!(
        Vault::decode_events(&raw),
        vec![VaultEvent::Counted(AbiValue::Array(vec![AbiValue::from(
            5u64
        )]))],
    );

    // Read-only simulate: get_pair returns (total, total) = (13, 13).
    let simulated = vault.get_pair().simulate(&algod, &params).await.unwrap();
    match &simulated.method_results[0].return_value {
        Ok(AbiMethodReturnValue::Some(value)) => assert_eq!(
            value,
            &AbiValue::Array(vec![AbiValue::from(13u64), AbiValue::from(13u64)])
        ),
        other => panic!("unexpected get_pair return: {other:?}"),
    }

    // Typed global-state reads, decoded per the declared ARC-56 types.
    assert_eq!(
        vault.global_total(&algod).await.unwrap(),
        Some(AbiValue::from(13u64)),
    );
    assert_eq!(
        vault.global_owner(&algod).await.unwrap(),
        Some(AbiValue::Address(sender)),
    );
}

#[tokio::test]
async fn opt_in_via_enroll_succeeds() {
    let algod = algod();
    let (vault, sender) = deploy_vault(&algod, &kmd()).await;
    let params = algod.suggested_params().await.unwrap();

    // Before opting in, the caller has no local state: the `seen` accessor is
    // `None`.
    assert_eq!(
        vault.local_seen(&algod, &sender).await.unwrap(),
        None,
        "no local state before opt-in",
    );

    // `enroll` declares the OptIn call action; `.opt_in()` sets the on-complete,
    // and the contract approves the opt-in, writing local `seen = 1`.
    let opt_in = vault.enroll().opt_in().build(&params);
    let executed = AtomicGroupBuilder::new()
        .add_method_call(opt_in)
        .build()
        .unwrap()
        .sign()
        .await
        .unwrap()
        .execute(&algod)
        .await
        .unwrap();
    assert!(executed.confirmed_round.is_some(), "opt-in should confirm");

    // Typed local-state read for the opted-in account: `seen` is 1.
    assert_eq!(
        vault.local_seen(&algod, &sender).await.unwrap(),
        Some(AbiValue::from(1u64)),
        "opt-in records local seen = 1",
    );
}

#[tokio::test]
async fn incr_uses_literal_default_on_chain() {
    let algod = algod();
    let (vault, _) = deploy_vault(&algod, &kmd()).await;
    let params = algod.suggested_params().await.unwrap();

    // `incr`'s `step` is an `Option<u64>`. `None` uses the literal default of 1;
    // on a fresh deploy total=0, so incr(None) returns 0 + 1 = 1.
    let incr = vault.incr(None).build(&params);
    let executed = AtomicGroupBuilder::new()
        .add_method_call(incr)
        .build()
        .unwrap()
        .sign()
        .await
        .unwrap()
        .execute(&algod)
        .await
        .unwrap();
    match &executed.method_results[0].return_value {
        Ok(AbiMethodReturnValue::Some(value)) => assert_eq!(value, &AbiValue::from(1u64)),
        other => panic!("unexpected incr return: {other:?}"),
    }

    // `Some(v)` overrides the default: incr(Some(10)) returns 1 + 10 = 11.
    let incr_over = vault.incr(Some(10)).build(&params);
    let executed = AtomicGroupBuilder::new()
        .add_method_call(incr_over)
        .build()
        .unwrap()
        .sign()
        .await
        .unwrap()
        .execute(&algod)
        .await
        .unwrap();
    match &executed.method_results[0].return_value {
        Ok(AbiMethodReturnValue::Some(value)) => assert_eq!(value, &AbiValue::from(11u64)),
        other => panic!("unexpected incr override return: {other:?}"),
    }
}

#[tokio::test]
async fn get_pair_simulate_decoded_returns_typed_struct() {
    let algod = algod();
    let (vault, _) = deploy_vault(&algod, &kmd()).await;
    let params = algod.suggested_params().await.unwrap();

    // store(2,3) sets total = 5.
    let store = vault
        .store(Pair {
            first: 2,
            second: 3,
        })
        .build(&params);
    AtomicGroupBuilder::new()
        .add_method_call(store)
        .build()
        .unwrap()
        .sign()
        .await
        .unwrap()
        .execute(&algod)
        .await
        .unwrap();

    // get_pair's return carries a `struct: "Pair"` overlay, so `simulate_decoded`
    // returns the typed `Pair` directly (total, total) = (5, 5).
    let pair: Pair = vault
        .get_pair()
        .simulate_decoded(&algod, &params)
        .await
        .unwrap();
    assert_eq!(pair.first, 5);
    assert_eq!(pair.second, 5);

    // A scalar return decodes too: scale((4,5),10) returns (4 + 5) * 10 = 90.
    let scaled: u64 = vault
        .scale(
            Pair {
                first: 4,
                second: 5,
            },
            10,
        )
        .simulate_decoded(&algod, &params)
        .await
        .unwrap();
    assert_eq!(scaled, 90);
}

#[tokio::test]
async fn arc56_test_deploys_via_abi_create() {
    // The real, AlgoKit-produced contract is created on-chain through its ABI
    // `createApplication()` method (the generated `deploy` passes that method's
    // selector as the create transaction's app argument) with its `someNumber`
    // TEAL template variable substituted at deploy time. Its other methods need
    // features beyond this client (an inline-nested struct arg, a box
    // reference), so the deploy itself is what this exercises end-to-end.
    let (client, _) = deploy_arc56_test(&algod(), &kmd()).await;
    assert!(
        client.app_id().0 > 0,
        "ABI-method create with a substituted template variable should create the app"
    );
}

#[tokio::test]
async fn non_creator_can_call_and_owner_stays_the_creator() {
    // Vault records `owner = Txn.Sender` at create and never changes it, so a
    // second account calling the app exercises the caller != creator case: the
    // call succeeds (no access control), `total` reflects it, but `owner` stays
    // the deployer.
    let algod = algod();
    let kmd = kmd();

    // Account A deploys; the contract records owner = A.
    let (vault, creator) = deploy_vault(&algod, &kmd).await;

    // A different funded account B binds a client to the same app id.
    let caller = funded_account(&algod, &kmd).await;
    let caller_addr = caller.address();
    assert_ne!(
        caller_addr, creator,
        "the caller must differ from the creator"
    );
    let caller_signer: Arc<dyn Signer> = Arc::new(caller);
    let as_caller = Vault::new(vault.app_id(), caller_addr, caller_signer);

    // B calls store(8,9): total = 8 + 9 = 17. Vault has no access control, so a
    // non-creator's call confirms.
    let params = algod.suggested_params().await.unwrap();
    let store = as_caller
        .store(Pair {
            first: 8,
            second: 9,
        })
        .build(&params);
    let executed = AtomicGroupBuilder::new()
        .add_method_call(store)
        .build()
        .unwrap()
        .sign()
        .await
        .unwrap()
        .execute(&algod)
        .await
        .unwrap();
    assert!(
        executed.confirmed_round.is_some(),
        "a non-creator's call should confirm"
    );

    // `total` reflects B's call...
    assert_eq!(
        vault.global_total(&algod).await.unwrap(),
        Some(AbiValue::from(17u64)),
        "store(8,9) sets total = 8 + 9",
    );
    // ...but `owner` is still A: set at create, untouched by `store`.
    assert_eq!(
        vault.global_owner(&algod).await.unwrap(),
        Some(AbiValue::Address(creator)),
        "owner stays the creator even though a different account called",
    );
}

#[tokio::test]
async fn account_reference_round_trips() {
    use algonaut::atomic::AbiMethodReturnValue;
    let algod = algod();
    let (vault, _) = deploy_vault(&algod, &kmd()).await;
    let params = algod.suggested_params().await.unwrap();

    // A fresh account passed as an `account` reference; the contract echoes the
    // address it resolves from the Accounts foreign array.
    let target = Account::generate();
    let executed = AtomicGroupBuilder::new()
        .add_method_call(vault.who(target.address()).build(&params))
        .build()
        .unwrap()
        .sign()
        .await
        .unwrap()
        .execute(&algod)
        .await
        .unwrap();
    match &executed.method_results[0].return_value {
        Ok(AbiMethodReturnValue::Some(value)) => {
            assert_eq!(value, &AbiValue::Address(target.address()))
        }
        other => panic!("unexpected who return: {other:?}"),
    }
}

#[tokio::test]
async fn array_arguments_sum_on_chain() {
    use algonaut::atomic::AbiMethodReturnValue;
    let algod = algod();
    let (vault, _) = deploy_vault(&algod, &kmd()).await;
    let params = algod.suggested_params().await.unwrap();

    // Dynamic array: sum([10,20,30]) = 60.
    let dynamic = vault.sum(vec![10u64, 20, 30]).build(&params);
    // Static array: sum3([1,2,3]) = 6.
    let stat = vault.sum3([1u64, 2, 3]).build(&params);
    let executed = AtomicGroupBuilder::new()
        .add_method_call(dynamic)
        .add_method_call(stat)
        .build()
        .unwrap()
        .sign()
        .await
        .unwrap()
        .execute(&algod)
        .await
        .unwrap();
    match &executed.method_results[0].return_value {
        Ok(AbiMethodReturnValue::Some(v)) => assert_eq!(v, &AbiValue::from(60u64)),
        other => panic!("unexpected sum return: {other:?}"),
    }
    match &executed.method_results[1].return_value {
        Ok(AbiMethodReturnValue::Some(v)) => assert_eq!(v, &AbiValue::from(6u64)),
        other => panic!("unexpected sum3 return: {other:?}"),
    }
}

#[tokio::test]
async fn tuple_and_ufixed_arguments_round_trip_on_chain() {
    use algonaut::abi::macro_support::Ufixed;
    use algonaut::atomic::AbiMethodReturnValue;
    let algod = algod();
    let (vault, _) = deploy_vault(&algod, &kmd()).await;
    let params = algod.suggested_params().await.unwrap();

    // Anonymous tuple argument: add_pair((4, 5)) = 9. The generated client
    // takes a plain Rust `(u64, u64)` (no named-struct overlay on this method).
    let pair = vault.add_pair((4u64, 5u64)).build(&params);
    // ufixed64x2 argument: price_raw(1.50) returns the raw, unscaled 150 (the
    // `Ufixed` newtype wraps the already-scaled integer; on the wire it is the
    // same big-endian uint64 the contract reads back).
    let price = vault.price_raw(Ufixed::new(150u64)).build(&params);
    let executed = AtomicGroupBuilder::new()
        .add_method_call(pair)
        .add_method_call(price)
        .build()
        .unwrap()
        .sign()
        .await
        .unwrap()
        .execute(&algod)
        .await
        .unwrap();
    match &executed.method_results[0].return_value {
        Ok(AbiMethodReturnValue::Some(v)) => assert_eq!(v, &AbiValue::from(9u64)),
        other => panic!("unexpected add_pair return: {other:?}"),
    }
    match &executed.method_results[1].return_value {
        Ok(AbiMethodReturnValue::Some(v)) => assert_eq!(v, &AbiValue::from(150u64)),
        other => panic!("unexpected price_raw return: {other:?}"),
    }
}

#[tokio::test]
async fn box_put_get_round_trips() {
    use algonaut::atomic::AbiMethodReturnValue;
    use algonaut::core::MicroAlgos;
    use algonaut::transaction::Pay;
    let algod = algod();
    let kmd = kmd();
    let account = funded_account(&algod, &kmd).await;
    let sender = account.address();
    let signer: Arc<dyn Signer> = Arc::new(account);
    let params = algod.suggested_params().await.unwrap();
    let vault = Vault::deploy(&algod, sender, Arc::clone(&signer), &params)
        .await
        .expect("deploy Vault");

    // A box raises the app account's min balance, so fund the app account.
    let fund = Pay::new(sender, vault.app_id().address(), MicroAlgos(200_000))
        .build(&params)
        .expect("build app funding");
    AtomicGroupBuilder::new()
        .add_transaction(algonaut::atomic::TransactionWithSigner::new(
            fund,
            Arc::clone(&signer),
        ))
        .build()
        .unwrap()
        .sign()
        .await
        .unwrap()
        .execute(&algod)
        .await
        .unwrap();

    // box_put("k", 42) writes the box; the box reference must be attached.
    let put = vault
        .box_put("k".to_owned(), 42)
        .box_ref(b"k".to_vec())
        .build(&params);
    AtomicGroupBuilder::new()
        .add_method_call(put)
        .build()
        .unwrap()
        .sign()
        .await
        .unwrap()
        .execute(&algod)
        .await
        .unwrap();

    // box_get("k") reads it back as 42.
    let get = vault
        .box_get("k".to_owned())
        .box_ref(b"k".to_vec())
        .build(&params);
    let executed = AtomicGroupBuilder::new()
        .add_method_call(get)
        .build()
        .unwrap()
        .sign()
        .await
        .unwrap()
        .execute(&algod)
        .await
        .unwrap();
    match &executed.method_results[0].return_value {
        Ok(AbiMethodReturnValue::Some(v)) => assert_eq!(v, &AbiValue::from(42u64)),
        other => panic!("unexpected box_get return: {other:?}"),
    }

    // The same box is also readable through the generated box-map accessor,
    // which reads algod's box endpoint directly (no method call) and decodes
    // the raw 8-byte value per the map's AVMUint64 value type.
    assert_eq!(
        vault.box_boxes(&algod, "k").await.unwrap(),
        Some(AbiValue::from(42u64)),
        "box-map accessor reads the box `k` written by box_put",
    );
    // A box that was never written reads back as absent (404 → None).
    assert_eq!(
        vault.box_boxes(&algod, "missing").await.unwrap(),
        None,
        "an unwritten box reads as None",
    );
}

#[tokio::test]
async fn payment_transaction_argument_round_trips() {
    use algonaut::atomic::TransactionWithSigner;
    use algonaut::core::MicroAlgos;
    use algonaut::transaction::Pay;
    let algod = algod();
    let kmd = kmd();
    let account = funded_account(&algod, &kmd).await;
    let sender = account.address();
    let signer: Arc<dyn Signer> = Arc::new(account);
    let params = algod.suggested_params().await.unwrap();
    let vault = Vault::deploy(&algod, sender, Arc::clone(&signer), &params)
        .await
        .expect("deploy Vault");

    // A payment to the app account, supplied as a transaction argument; the
    // builder places it immediately before the method call. The amount clears
    // the app account's 100_000 µAlgo base min balance, so the receiving app
    // account stays valid.
    let pay = Pay::new(sender, vault.app_id().address(), MicroAlgos(200_000))
        .build(&params)
        .expect("build pay");
    let call = vault
        .deposit(
            TransactionWithSigner::new(pay, Arc::clone(&signer)),
            200_000u64,
        )
        .build(&params);
    let executed = AtomicGroupBuilder::new()
        .add_method_call(call)
        .build()
        .unwrap()
        .sign()
        .await
        .unwrap()
        .execute(&algod)
        .await
        .unwrap();
    assert!(
        executed.confirmed_round.is_some(),
        "the grouped payment + method call should confirm"
    );
}