forked from Nova-reward/Nova-Rewards
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.rs
More file actions
722 lines (630 loc) · 24.7 KB
/
Copy pathlib.rs
File metadata and controls
722 lines (630 loc) · 24.7 KB
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
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
//! # Nova Token Contract
//!
//! A Soroban token contract implementing ERC20-like fungible token functionality.
//!
//! ## Features
//! - Token initialization, mint, burn, and transfer
//! - Approve/allowance functionality with expiration ledger enforcement
//! - Events emitted on all state-changing operations
//! - [`transfer_from`](NovaToken::transfer_from) support for allowance-based transfers
//! - Expired allowances are treated as zero (delegated spending is safe)
//!
//! ## Usage
//! ```ignore
//! // Initialize
//! client.initialize(&admin);
//!
//! // Mint tokens to a user
//! client.mint(&user, &1_000_000);
//!
//! // Transfer between accounts
//! client.transfer(&from, &to, &500_000);
//!
//! // Approve a spender with an expiration ledger and use transfer_from
//! client.approve(&owner, &spender, &200_000, &expiration_ledger);
//! client.transfer_from(&spender, &owner, &recipient, &100_000);
//! ```
#![no_std]
use soroban_sdk::{contract, contractimpl, contracttype, symbol_short, Address, Env};
// ============================================
// Storage Keys
// ============================================
#[contracttype]
enum DataKey {
Admin,
Initialized,
Balance(Address),
/// Stores AllowanceValue { amount, expiration_ledger } keyed by (owner, spender)
Allowance(Address, Address),
TotalSupply,
}
// ============================================
// Allowance value — amount + expiry
// ============================================
/// Stores the approved amount and the ledger sequence number after which the
/// allowance is considered expired (inclusive: valid while current_ledger <= expiration_ledger).
#[contracttype]
#[derive(Clone, Debug)]
pub struct AllowanceValue {
pub amount: i128,
pub expiration_ledger: u32,
}
// ============================================
// Contract
// ============================================
#[contract]
pub struct NovaToken;
#[contractimpl]
impl NovaToken {
/// Initializes the token contract with the admin allowed to mint.
///
/// # Parameters
/// - `admin` – Address that will be authorized to call [`mint`](NovaToken::mint).
///
/// # Panics
/// - `"already initialized"` if called more than once.
pub fn initialize(env: Env, admin: Address) {
if env.storage().instance().has(&DataKey::Admin) {
panic!("already initialized");
}
env.storage().instance().set(&DataKey::Initialized, &true);
env.storage().instance().set(&DataKey::Admin, &admin);
env.storage().instance().set(&DataKey::TotalSupply, &0_i128);
}
// ========================================
// Internal Helpers
// ========================================
/// Returns the configured token admin.
fn admin(env: &Env) -> Address {
env.storage().instance().get(&DataKey::Admin).unwrap()
}
/// Reads a wallet balance from persistent storage and refreshes its TTL.
fn balance_of(env: &Env, addr: &Address) -> i128 {
let key = DataKey::Balance(addr.clone());
let balance = env.storage().persistent().get(&key).unwrap_or(0i128);
if env.storage().persistent().has(&key) {
// Extend TTL by 31 days (2,678,400 ledgers at 5s/ledger)
env.storage()
.persistent()
.extend_ttl(&key, 2_678_400, 2_678_400);
}
balance
}
/// Stores a wallet balance and refreshes the persistent entry TTL.
fn set_balance(env: &Env, addr: &Address, amount: i128) {
let key = DataKey::Balance(addr.clone());
env.storage().persistent().set(&key, &amount);
// Extend TTL by 31 days
env.storage()
.persistent()
.extend_ttl(&key, 2_678_400, 2_678_400);
}
// ========================================
// Token Operations
// ========================================
/// Mints new tokens to a recipient.
///
/// # Parameters
/// - `to` – Recipient address.
/// - `amount` – Number of tokens to mint (must be > 0).
///
/// # Authorization
/// Requires admin authorization.
///
/// # Events
/// Emits `("nova_tok", "mint")` with data `(to: Address, amount: i128)`.
///
/// # Panics
/// - `"amount must be positive"` if `amount <= 0`.
pub fn mint(env: Env, to: Address, amount: i128) {
Self::admin(&env).require_auth();
assert!(amount > 0, "amount must be positive");
let new_bal = Self::balance_of(&env, &to).saturating_add(amount);
Self::set_balance(&env, &to, new_bal);
let supply: i128 = env
.storage()
.instance()
.get(&DataKey::TotalSupply)
.unwrap_or(0);
env.storage()
.instance()
.set(&DataKey::TotalSupply, &supply.saturating_add(amount));
env.events().publish(
(symbol_short!("nova_tok"), symbol_short!("mint")),
(to, amount),
);
}
/// Burns tokens from the caller's balance.
///
/// # Parameters
/// - `from` – Address whose tokens are burned.
/// - `amount` – Number of tokens to burn (must be > 0).
///
/// # Authorization
/// Requires `from` authorization.
///
/// # Events
/// Emits `("nova_tok", "burn")` with data `(from: Address, amount: i128)`.
///
/// # Panics
/// - `"amount must be positive"` if `amount <= 0`.
/// - `"insufficient balance"` if `from` holds fewer tokens than `amount`.
pub fn burn(env: Env, from: Address, amount: i128) {
from.require_auth();
assert!(amount > 0, "amount must be positive");
let bal = Self::balance_of(&env, &from);
assert!(bal >= amount, "insufficient balance");
Self::set_balance(&env, &from, bal - amount);
let supply: i128 = env
.storage()
.instance()
.get(&DataKey::TotalSupply)
.unwrap_or(0);
env.storage()
.instance()
.set(&DataKey::TotalSupply, &supply.saturating_sub(amount));
env.events().publish(
(symbol_short!("nova_tok"), symbol_short!("burn")),
(from, amount),
);
}
/// Transfers tokens between two accounts.
///
/// # Parameters
/// - `from` – Sender address.
/// - `to` – Recipient address.
/// - `amount` – Number of tokens to transfer (must be > 0).
///
/// # Authorization
/// Requires `from` authorization.
///
/// # Events
/// Emits `("nova_tok", "transfer")` with data `(from: Address, to: Address, amount: i128)`.
///
/// # Panics
/// - `"amount must be positive"` if `amount <= 0`.
/// - `"insufficient balance"` if `from` holds fewer tokens than `amount`.
pub fn transfer(env: Env, from: Address, to: Address, amount: i128) {
from.require_auth();
assert!(amount > 0, "amount must be positive");
let from_bal = Self::balance_of(&env, &from);
assert!(from_bal >= amount, "insufficient balance");
Self::set_balance(&env, &from, from_bal - amount);
let to_bal = Self::balance_of(&env, &to);
Self::set_balance(&env, &to, to_bal + amount);
env.events().publish(
(symbol_short!("nova_tok"), symbol_short!("transfer")),
(from, to, amount),
);
}
/// Transfer tokens from `from` to `to` using allowance.
///
/// The `spender` must have a sufficient, non-expired allowance granted by `from`
/// via [`approve`](NovaToken::approve). Expired allowances are treated as zero.
///
/// # Parameters
/// - `spender` – Address spending the allowance.
/// - `from` – Token owner whose allowance is consumed.
/// - `to` – Recipient address.
/// - `amount` – Number of tokens to transfer (must be > 0).
///
/// # Authorization
/// Requires `spender` authorization.
///
/// # Events
/// Emits `("nova_tok", "xfer_from")` with data `(spender, from, to, amount)`.
///
/// # Panics
/// - `"amount must be positive"` if `amount <= 0`.
/// - `"allowance expired"` if the allowance's `expiration_ledger` is in the past.
/// - `"insufficient allowance"` if spender's allowance is less than `amount`.
/// - `"insufficient balance"` if `from` holds fewer tokens than `amount`.
pub fn transfer_from(env: Env, spender: Address, from: Address, to: Address, amount: i128) {
spender.require_auth();
assert!(amount > 0, "amount must be positive");
let allowance_key = DataKey::Allowance(from.clone(), spender.clone());
let allowance: AllowanceValue =
env.storage()
.persistent()
.get(&allowance_key)
.unwrap_or(AllowanceValue {
amount: 0,
expiration_ledger: 0,
});
// Treat expired allowances as zero
let current_ledger = env.ledger().sequence();
assert!(
current_ledger <= allowance.expiration_ledger,
"allowance expired"
);
assert!(allowance.amount >= amount, "insufficient allowance");
// Deduct allowance and persist
let new_amount = allowance.amount - amount;
let updated = AllowanceValue {
amount: new_amount,
expiration_ledger: allowance.expiration_ledger,
};
env.storage().persistent().set(&allowance_key, &updated);
env.storage()
.persistent()
.extend_ttl(&allowance_key, 2_678_400, 2_678_400);
// Transfer tokens
let from_bal = Self::balance_of(&env, &from);
assert!(from_bal >= amount, "insufficient balance");
Self::set_balance(&env, &from, from_bal - amount);
let to_bal = Self::balance_of(&env, &to);
Self::set_balance(&env, &to, to_bal + amount);
env.events().publish(
(symbol_short!("nova_tok"), symbol_short!("xfer_from")),
(spender, from, to, amount),
);
}
// ========================================
// Allowance Functions
// ========================================
/// Approve `spender` to spend up to `amount` on behalf of `owner` until `expiration_ledger`.
///
/// Overwrites any existing allowance. Set `amount` to `0` to revoke.
/// The allowance is valid while `current_ledger <= expiration_ledger`.
///
/// # Parameters
/// - `owner` – Token owner granting the allowance.
/// - `spender` – Address authorized to spend.
/// - `amount` – Maximum tokens the spender may transfer.
/// - `expiration_ledger` – Ledger sequence number after which the allowance expires.
/// Must be >= current ledger sequence (unless `amount == 0` for revocation).
///
/// # Authorization
/// Requires `owner` authorization.
///
/// # Events
/// Emits `("nova_tok", "approve")` with data `(owner, spender, amount, expiration_ledger)`.
///
/// # Panics
/// - `"expiration_ledger must be >= current ledger"` if `expiration_ledger` is in the past
/// and `amount > 0`.
pub fn approve(
env: Env,
owner: Address,
spender: Address,
amount: i128,
expiration_ledger: u32,
) {
owner.require_auth();
// Reject stale approvals for non-zero amounts
if amount > 0 {
assert!(
expiration_ledger >= env.ledger().sequence(),
"expiration_ledger must be >= current ledger"
);
}
let key = DataKey::Allowance(owner.clone(), spender.clone());
let value = AllowanceValue {
amount,
expiration_ledger,
};
env.storage().persistent().set(&key, &value);
// Extend TTL by 31 days
env.storage()
.persistent()
.extend_ttl(&key, 2_678_400, 2_678_400);
env.events().publish(
(symbol_short!("nova_tok"), symbol_short!("approve")),
(owner, spender, amount, expiration_ledger),
);
}
/// Increase allowance for `spender` by `amount`.
///
/// The existing `expiration_ledger` is preserved. If no allowance exists yet,
/// `expiration_ledger` must be supplied via a fresh [`approve`](NovaToken::approve) call.
///
/// # Parameters
/// - `owner` – Token owner.
/// - `spender` – Address whose allowance is increased.
/// - `amount` – Amount to add to the existing allowance (must be > 0).
///
/// # Authorization
/// Requires `owner` authorization.
///
/// # Events
/// Emits `("nova_tok", "inc_allow")` with data `(owner, spender, new_allowance)`.
///
/// # Panics
/// - `"amount must be positive"` if `amount <= 0`.
/// - `"no existing allowance to increase"` if no allowance record exists.
pub fn increase_allowance(env: Env, owner: Address, spender: Address, amount: i128) {
owner.require_auth();
assert!(amount > 0, "amount must be positive");
let key = DataKey::Allowance(owner.clone(), spender.clone());
let existing: AllowanceValue = env
.storage()
.persistent()
.get(&key)
.expect("no existing allowance to increase");
let new_amount = existing.amount.saturating_add(amount);
let updated = AllowanceValue {
amount: new_amount,
expiration_ledger: existing.expiration_ledger,
};
env.storage().persistent().set(&key, &updated);
env.storage()
.persistent()
.extend_ttl(&key, 2_678_400, 2_678_400);
env.events().publish(
(symbol_short!("nova_tok"), symbol_short!("inc_allow")),
(owner, spender, new_amount),
);
}
/// Decrease allowance for `spender` by `amount`. Saturates at zero.
///
/// # Parameters
/// - `owner` – Token owner.
/// - `spender` – Address whose allowance is decreased.
/// - `amount` – Amount to subtract from the existing allowance (must be > 0).
///
/// # Authorization
/// Requires `owner` authorization.
///
/// # Events
/// Emits `("nova_tok", "dec_allow")` with data `(owner, spender, new_allowance)`.
///
/// # Panics
/// - `"amount must be positive"` if `amount <= 0`.
pub fn decrease_allowance(env: Env, owner: Address, spender: Address, amount: i128) {
owner.require_auth();
assert!(amount > 0, "amount must be positive");
let key = DataKey::Allowance(owner.clone(), spender.clone());
let existing: AllowanceValue =
env.storage()
.persistent()
.get(&key)
.unwrap_or(AllowanceValue {
amount: 0,
expiration_ledger: 0,
});
let new_amount = existing.amount.saturating_sub(amount);
let updated = AllowanceValue {
amount: new_amount,
expiration_ledger: existing.expiration_ledger,
};
env.storage().persistent().set(&key, &updated);
env.storage()
.persistent()
.extend_ttl(&key, 2_678_400, 2_678_400);
env.events().publish(
(symbol_short!("nova_tok"), symbol_short!("dec_allow")),
(owner, spender, new_amount),
);
}
// ========================================
// Read-only Functions
// ========================================
/// Returns the current token balance for an address.
///
/// # Parameters
/// - `addr` – Address to query.
///
/// # Returns
/// Token balance in base units (`i128`). Returns `0` if no balance is recorded.
pub fn balance(env: Env, addr: Address) -> i128 {
Self::balance_of(&env, &addr)
}
/// Returns the remaining allowance recorded for an owner and spender pair.
///
/// Returns `0` if no allowance is set **or** if the allowance has expired.
///
/// # Parameters
/// - `owner` – Token owner who granted the allowance.
/// - `spender` – Address authorized to spend.
///
/// # Returns
/// Remaining allowance in base units. Returns `0` if no allowance is set or it has expired.
pub fn total_supply(env: Env) -> i128 {
env.storage()
.instance()
.get(&DataKey::TotalSupply)
.unwrap_or(0)
}
pub fn allowance(env: Env, owner: Address, spender: Address) -> i128 {
let key = DataKey::Allowance(owner, spender);
let value: AllowanceValue = match env.storage().persistent().get(&key) {
Some(v) => v,
None => return 0,
};
// Extend TTL by 31 days
env.storage()
.persistent()
.extend_ttl(&key, 2_678_400, 2_678_400);
// Expired allowances are treated as zero
if env.ledger().sequence() > value.expiration_ledger {
return 0;
}
value.amount
}
}
// ============================================
// Tests
// ============================================
#[cfg(test)]
mod tests {
use super::*;
use soroban_sdk::{
testutils::{Address as _, Ledger},
Env,
};
fn setup() -> (Env, Address, NovaTokenClient<'static>) {
let env = Env::default();
env.mock_all_auths();
let id = env.register(NovaToken, ());
let client = NovaTokenClient::new(&env, &id);
let admin = Address::generate(&env);
client.initialize(&admin);
(env, admin, client)
}
/// Returns a ledger sequence far enough in the future to be a valid expiry.
fn future_ledger(env: &Env) -> u32 {
env.ledger().sequence() + 10_000
}
#[test]
fn test_mint_emits_event() {
let (env, _admin, client) = setup();
let user = Address::generate(&env);
client.mint(&user, &500);
assert_eq!(client.balance(&user), 500);
}
#[test]
fn test_burn_emits_event() {
let (env, _admin, client) = setup();
let user = Address::generate(&env);
client.mint(&user, &200);
client.burn(&user, &50);
assert_eq!(client.balance(&user), 150);
}
#[test]
fn test_transfer_emits_event() {
let (env, _admin, client) = setup();
let alice = Address::generate(&env);
let bob = Address::generate(&env);
client.mint(&alice, &300);
client.transfer(&alice, &bob, &100);
assert_eq!(client.balance(&alice), 200);
assert_eq!(client.balance(&bob), 100);
}
#[test]
fn test_approve_emits_event() {
let (env, _admin, client) = setup();
let owner = Address::generate(&env);
let spender = Address::generate(&env);
let expiry = future_ledger(&env);
client.approve(&owner, &spender, &1000, &expiry);
assert_eq!(client.allowance(&owner, &spender), 1000);
}
// ── transfer_from ─────────────────────────────────────────────────────────
#[test]
fn test_transfer_from() {
let (env, _admin, client) = setup();
let owner = Address::generate(&env);
let spender = Address::generate(&env);
let recipient = Address::generate(&env);
let expiry = future_ledger(&env);
client.mint(&owner, &500);
client.approve(&owner, &spender, &200, &expiry);
assert_eq!(client.allowance(&owner, &spender), 200);
client.transfer_from(&spender, &owner, &recipient, &150);
assert_eq!(client.balance(&owner), 350); // 500 - 150
assert_eq!(client.balance(&recipient), 150);
assert_eq!(client.allowance(&owner, &spender), 50); // 200 - 150
}
#[test]
#[should_panic(expected = "insufficient allowance")]
fn test_transfer_from_insufficient_allowance() {
let (env, _admin, client) = setup();
let owner = Address::generate(&env);
let spender = Address::generate(&env);
let recipient = Address::generate(&env);
let expiry = future_ledger(&env);
client.mint(&owner, &500);
client.approve(&owner, &spender, &100, &expiry);
// Trying to transfer more than allowed — must panic
client.transfer_from(&spender, &owner, &recipient, &150);
}
// ── Allowance expiry ──────────────────────────────────────────────────────
#[test]
fn test_expired_allowance_reads_as_zero() {
let (env, _admin, client) = setup();
let owner = Address::generate(&env);
let spender = Address::generate(&env);
// Approve at ledger 0, expiry = ledger 5
client.approve(&owner, &spender, &1000, &5);
// Advance ledger past expiry
env.ledger().with_mut(|l| l.sequence_number = 6);
assert_eq!(client.allowance(&owner, &spender), 0);
}
#[test]
#[should_panic(expected = "allowance expired")]
fn test_transfer_from_expired_allowance_panics() {
let (env, _admin, client) = setup();
let owner = Address::generate(&env);
let spender = Address::generate(&env);
let recipient = Address::generate(&env);
client.mint(&owner, &500);
// Approve with expiry at ledger 5
client.approve(&owner, &spender, &200, &5);
// Advance ledger past expiry
env.ledger().with_mut(|l| l.sequence_number = 6);
// Must panic with "allowance expired"
client.transfer_from(&spender, &owner, &recipient, &100);
}
#[test]
fn test_allowance_valid_at_expiration_ledger() {
let (env, _admin, client) = setup();
let owner = Address::generate(&env);
let spender = Address::generate(&env);
let recipient = Address::generate(&env);
client.mint(&owner, &500);
// Approve with expiry at ledger 10
client.approve(&owner, &spender, &200, &10);
// Advance ledger to exactly the expiration ledger — still valid
env.ledger().with_mut(|l| l.sequence_number = 10);
client.transfer_from(&spender, &owner, &recipient, &100);
assert_eq!(client.balance(&recipient), 100);
}
// ── Stale approval rejection ──────────────────────────────────────────────
#[test]
#[should_panic(expected = "expiration_ledger must be >= current ledger")]
fn test_approve_with_past_expiry_panics() {
let (env, _admin, client) = setup();
let owner = Address::generate(&env);
let spender = Address::generate(&env);
// Advance ledger to 100, then try to approve with expiry 50 (past)
env.ledger().with_mut(|l| l.sequence_number = 100);
client.approve(&owner, &spender, &1000, &50);
}
#[test]
fn test_approve_zero_amount_allows_past_expiry() {
// Revoking (amount=0) should not require a future expiry
let (env, _admin, client) = setup();
let owner = Address::generate(&env);
let spender = Address::generate(&env);
env.ledger().with_mut(|l| l.sequence_number = 100);
// amount=0 revocation — expiry 0 is fine
client.approve(&owner, &spender, &0, &0);
assert_eq!(client.allowance(&owner, &spender), 0);
}
// ── increase / decrease allowance ─────────────────────────────────────────
#[test]
fn test_increase_allowance() {
let (env, _admin, client) = setup();
let owner = Address::generate(&env);
let spender = Address::generate(&env);
let expiry = future_ledger(&env);
client.approve(&owner, &spender, &100, &expiry);
client.increase_allowance(&owner, &spender, &50);
assert_eq!(client.allowance(&owner, &spender), 150);
}
#[test]
fn test_decrease_allowance() {
let (env, _admin, client) = setup();
let owner = Address::generate(&env);
let spender = Address::generate(&env);
let expiry = future_ledger(&env);
client.approve(&owner, &spender, &100, &expiry);
client.decrease_allowance(&owner, &spender, &30);
assert_eq!(client.allowance(&owner, &spender), 70);
}
// ── Other edge cases ──────────────────────────────────────────────────────
#[test]
#[should_panic(expected = "insufficient balance")]
fn test_burn_insufficient_balance() {
let (env, _admin, client) = setup();
let user = Address::generate(&env);
client.mint(&user, &10);
client.burn(&user, &100); // Should panic
}
#[test]
#[should_panic(expected = "already initialized")]
fn test_reinitialize_is_blocked() {
let (env, admin, client) = setup();
client.initialize(&admin);
}
}