|
| 1 | +from hiero_sdk_python.account.account_id import AccountId |
| 2 | +from hiero_sdk_python.crypto.private_key import PrivateKey |
| 3 | +from hiero_sdk_python.crypto.public_key import PublicKey |
| 4 | +from hiero_sdk_python.hbar import Hbar |
| 5 | +from hiero_sdk_python.timestamp import Timestamp |
| 6 | +from hiero_sdk_python.Duration import Duration |
| 7 | +from hiero_sdk_python.tokens.token_id import TokenId |
| 8 | +from hiero_sdk_python.tokens.token_relationship import TokenRelationship |
| 9 | +from hiero_sdk_python.account.account_info import AccountInfo |
| 10 | + |
| 11 | +def create_mock_account_id() -> AccountId: |
| 12 | + """Create a mock AccountId.""" |
| 13 | + return AccountId.from_string("0.0.1234") |
| 14 | + |
| 15 | +def create_mock_public_key() -> PublicKey: |
| 16 | + """Generate a random ED25519 public key for demonstration.""" |
| 17 | + private_key_demo = PrivateKey.generate_ecdsa() |
| 18 | + public_key_demo = private_key_demo.public_key() |
| 19 | + return public_key_demo |
| 20 | + |
| 21 | +def create_mock_balance() -> Hbar: |
| 22 | + """Return a mock account balance.""" |
| 23 | + return Hbar(100) |
| 24 | + |
| 25 | +def create_mock_expiration_time() -> Timestamp: |
| 26 | + """Return a sample expiration timestamp (arbitrary future date).""" |
| 27 | + return Timestamp(seconds=1736539200,nanos=100) |
| 28 | + |
| 29 | +def create_mock_auto_renew_period() -> Duration: |
| 30 | + """Return a 90-day auto-renew period.""" |
| 31 | + return Duration(seconds=7776000) |
| 32 | + |
| 33 | +def create_mock_token_relationship() -> TokenRelationship: |
| 34 | + """Create a sample token relationship with a mock token.""" |
| 35 | + token_id = TokenId.from_string("0.0.9999") |
| 36 | + return TokenRelationship(token_id=token_id, balance=50) |
| 37 | + |
| 38 | +def build_mock_account_info() -> AccountInfo: |
| 39 | + """Construct a complete AccountInfo instance manually (no network calls).""" |
| 40 | + info = AccountInfo() |
| 41 | + info.account_id = create_mock_account_id() |
| 42 | + info.key = create_mock_public_key() |
| 43 | + info.balance = create_mock_balance() |
| 44 | + info.expiration_time = create_mock_expiration_time() |
| 45 | + info.auto_renew_period = create_mock_auto_renew_period() |
| 46 | + info.token_relationships = [create_mock_token_relationship()] |
| 47 | + info.account_memo = "Mock Account for Example" |
| 48 | + return info |
| 49 | + |
| 50 | +def print_account_info(info: AccountInfo) -> None: |
| 51 | + """Pretty-print key AccountInfo fields.""" |
| 52 | + print("📜 AccountInfo Example (Mock Data)") |
| 53 | + print(f"Account ID: {info.account_id}") |
| 54 | + print(f"Key: {info.key}") |
| 55 | + print(f"Balance: {info.balance}") |
| 56 | + print(f"Expiration Time: {info.expiration_time}") |
| 57 | + print(f"Auto Renew Period: {info.auto_renew_period}") |
| 58 | + print(f"Token Relationships: {info.token_relationships}") |
| 59 | + print(f"Memo: {info.account_memo}") |
| 60 | + |
| 61 | +def main(): |
| 62 | + """Run the AccountInfo example.""" |
| 63 | + info = build_mock_account_info() |
| 64 | + print_account_info(info) |
| 65 | + |
| 66 | +if __name__ == "__main__": |
| 67 | + main() |
0 commit comments