56 lines
1.5 KiB
Plaintext
56 lines
1.5 KiB
Plaintext
// Example 5: Creating and working with Accounts
|
|
|
|
print("=== Account Example ===\n");
|
|
|
|
// Get a context to work with
|
|
print("1. Getting context...");
|
|
let ctx = get_context(["alice", "bob"]);
|
|
print(" ✓ Context created: " + ctx.context_id());
|
|
|
|
// Create accounts with builder pattern
|
|
print("\n2. Creating accounts...");
|
|
|
|
let checking = new_account()
|
|
.address("checking_001")
|
|
.currency("USD");
|
|
|
|
print(" ✓ Created checking account");
|
|
|
|
let savings = new_account()
|
|
.address("savings_001")
|
|
.currency("USD");
|
|
|
|
print(" ✓ Created savings account");
|
|
|
|
let crypto = new_account()
|
|
.address("0x1234567890abcdef")
|
|
.currency("ETH");
|
|
|
|
print(" ✓ Created crypto account");
|
|
|
|
// Display account info
|
|
print("\n3. Account information...");
|
|
print(" Checking ID: " + checking.get_id());
|
|
print(" Checking address: " + checking.get_address());
|
|
print(" Checking currency: " + checking.get_currency());
|
|
|
|
print(" Savings ID: " + savings.get_id());
|
|
print(" Savings address: " + savings.get_address());
|
|
|
|
print(" Crypto ID: " + crypto.get_id());
|
|
print(" Crypto address: " + crypto.get_address());
|
|
print(" Crypto currency: " + crypto.get_currency());
|
|
|
|
// Save accounts to context
|
|
print("\n4. Saving accounts to context...");
|
|
let checking_id = ctx.save(checking);
|
|
print(" ✓ Saved checking account with ID: " + checking_id);
|
|
|
|
let savings_id = ctx.save(savings);
|
|
print(" ✓ Saved savings account with ID: " + savings_id);
|
|
|
|
let crypto_id = ctx.save(crypto);
|
|
print(" ✓ Saved crypto account with ID: " + crypto_id);
|
|
|
|
print("\n=== Account Example Complete ===");
|