diff --git a/module-system/module-implementations/sov-accounts/src/call.rs b/module-system/module-implementations/sov-accounts/src/call.rs index a736da4c89..2d94aa74fd 100644 --- a/module-system/module-implementations/sov-accounts/src/call.rs +++ b/module-system/module-implementations/sov-accounts/src/call.rs @@ -4,8 +4,10 @@ use sov_state::WorkingSet; use crate::Accounts; +/// To update the account's public key, the sender must sign this message as proof of possession of the new key. pub const UPDATE_ACCOUNT_MSG: [u8; 32] = [1; 32]; +/// Represents the available call messages for interacting with the sov-accounts module. #[cfg_attr( feature = "native", derive(serde::Serialize), @@ -18,8 +20,8 @@ pub const UPDATE_ACCOUNT_MSG: [u8; 32] = [1; 32]; )] #[derive(borsh::BorshDeserialize, borsh::BorshSerialize, Debug, PartialEq, Clone)] pub enum CallMessage { - // Updates a PublicKey for the corresponding Account. - // The sender must be in possession of the new PublicKey. + /// Updates a public key for the corresponding Account. + /// The sender must be in possession of the new key. UpdatePublicKey(C::PublicKey, C::Signature), } diff --git a/module-system/module-implementations/sov-accounts/src/lib.rs b/module-system/module-implementations/sov-accounts/src/lib.rs index 81a16c4924..f4ad5c728f 100644 --- a/module-system/module-implementations/sov-accounts/src/lib.rs +++ b/module-system/module-implementations/sov-accounts/src/lib.rs @@ -1,4 +1,6 @@ -pub mod hooks; +#![deny(missing_docs)] +#![doc = include_str!("../README.md")] +mod hooks; mod call; mod genesis; @@ -7,33 +9,41 @@ mod query; #[cfg(test)] mod tests; -pub use call::CallMessage; +pub use call::{CallMessage, UPDATE_ACCOUNT_MSG}; #[cfg(feature = "native")] pub use query::{AccountsRpcImpl, AccountsRpcServer, Response}; use sov_modules_api::Error; use sov_modules_macros::ModuleInfo; use sov_state::WorkingSet; -/// Initial configuration for sov-bank module. +/// Initial configuration for sov-accounts module. pub struct AccountConfig { + /// Public keys to initialize the rollup. pub pub_keys: Vec, } +/// An account on the rollup. #[derive(borsh::BorshDeserialize, borsh::BorshSerialize, Debug, PartialEq, Copy, Clone)] pub struct Account { + /// The address of the account. pub addr: C::Address, + /// The current nonce value associated with the account. pub nonce: u64, } +/// A module responsible for managing accounts on the rollup. #[cfg_attr(feature = "native", derive(sov_modules_macros::ModuleCallJsonSchema))] #[derive(ModuleInfo, Clone)] pub struct Accounts { + /// The address of the sov-accounts module. #[address] pub address: C::Address, + /// Mapping from an account address to a corresponding public key. #[state] pub(crate) public_keys: sov_state::StateMap, + /// Mapping from a public key to a corresponding account. #[state] pub(crate) accounts: sov_state::StateMap>, } diff --git a/module-system/module-implementations/sov-accounts/src/query.rs b/module-system/module-implementations/sov-accounts/src/query.rs index 67e74dff1f..19ca8667ee 100644 --- a/module-system/module-implementations/sov-accounts/src/query.rs +++ b/module-system/module-implementations/sov-accounts/src/query.rs @@ -1,12 +1,21 @@ +#![allow(missing_docs)] use sov_modules_api::AddressBech32; use sov_modules_macros::rpc_gen; use sov_state::WorkingSet; use crate::{Account, Accounts}; +/// This is the response returned from the accounts_getAccount endpoint. #[derive(Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize)] pub enum Response { - AccountExists { addr: AddressBech32, nonce: u64 }, + /// The account corresponding to the given public key exists. + AccountExists { + /// The address of the account, + addr: AddressBech32, + /// The nonce of the account. + nonce: u64, + }, + /// The account corresponding to the given public key does not exist. AccountEmpty, } diff --git a/module-system/module-schemas/schemas/sov-accounts.json b/module-system/module-schemas/schemas/sov-accounts.json index 945a916866..1d3da7809a 100644 --- a/module-system/module-schemas/schemas/sov-accounts.json +++ b/module-system/module-schemas/schemas/sov-accounts.json @@ -1,8 +1,10 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "CallMessage", + "description": "Represents the available call messages for interacting with the sov-accounts module.", "oneOf": [ { + "description": "Updates a public key for the corresponding Account. The sender must be in possession of the new key.", "type": "object", "required": [ "UpdatePublicKey"