are the TypeScript types derived from the structures defined in the smart contract Rust files for NearSocial's social-db:
account.rs
type Balance = bigint;
type StorageUsage = number;
interface Account {
storage_balance: Balance;
used_bytes: StorageUsage;
permissions: Map<PermissionKey, Permission>;
node_id: NodeId;
storage_tracker: StorageTracker;
shared_storage?: AccountSharedStorage;
}
interface PartialAccount {
storage_balance: Balance;
used_bytes: StorageUsage;
permissions: Array<[PermissionKey, Permission]>;
node_id: NodeId;
}
interface VAccount {
V0: AccountV0;
Current: Account;
}
node.rs
interface Node {
node_id: NodeId;
block_height: BlockHeight;
children: Map<string, NodeValue>;
}
interface ValueAtHeight {
value: string;
block_height: BlockHeight;
}
enum NodeValue {
Value(ValueAtHeight),
Node(NodeId),
DeletedEntry(BlockHeight)
}
interface PartialNode {
node_id: NodeId;
block_height: BlockHeight;
children: Array<[string, NodeValue]>;
from_index: number;
num_children: number;
}
interface VNode {
Current: Node;
}
permission.rs
enum PermissionKey {
AccountId(AccountId),
SignerPublicKey(PublicKey)
}
enum Permission {
Granted(Set<NodeId>)
}
type NodeId = number;
type BlockHeight = bigint;
type PublicKey = string; // Example representation, adjust based on actual public key format used
shared_storage.rs
interface SharedStoragePool {
total_storage_balance: Balance;
available_storage_balance: Balance;
owner_id: AccountId;
recipients: Map<AccountId, Balance>;
}
interface VSharedStoragePool {
V0: SharedStoragePoolV0;
Current: SharedStoragePool;
}
interface AccountSharedStorage {
shared_bytes: StorageUsage;
pool_account_id: AccountId;
}
storage_tracker.rs
interface StorageTracker {
total_used_bytes: StorageUsage;
session_used_bytes: StorageUsage;
session_start_storage_usage: StorageUsage;
}
upgrade.rs
interface UpgradeNotice {
upgrade_status: UpgradeStatus;
new_code_hash: string; // Example format, actual type based on how hashes are stored
}
enum UpgradeStatus {
Scheduled,
Completed
}
utils.rs
These are typically helper functions or utilities and may not have direct data structures to translate. However, utility functions or common constants could be adapted into TypeScript as needed for the project's requirements.