Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing docs in sov-accounts #545

Merged
merged 5 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions module-system/module-implementations/sov-accounts/src/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -18,8 +20,8 @@ pub const UPDATE_ACCOUNT_MSG: [u8; 32] = [1; 32];
)]
#[derive(borsh::BorshDeserialize, borsh::BorshSerialize, Debug, PartialEq, Clone)]
pub enum CallMessage<C: sov_modules_api::Context> {
// 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),
}

Expand Down
16 changes: 13 additions & 3 deletions module-system/module-implementations/sov-accounts/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
pub mod hooks;
#![deny(missing_docs)]
#![doc = include_str!("../README.md")]
mod hooks;

mod call;
mod genesis;
Expand All @@ -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<C: sov_modules_api::Context> {
/// Public keys to initialize the rollup.
pub pub_keys: Vec<C::PublicKey>,
}

/// An account on the rollup.
#[derive(borsh::BorshDeserialize, borsh::BorshSerialize, Debug, PartialEq, Copy, Clone)]
pub struct Account<C: sov_modules_api::Context> {
/// 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<C: sov_modules_api::Context> {
/// 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<C::Address, C::PublicKey>,

/// Mapping from a public key to a corresponding account.
#[state]
pub(crate) accounts: sov_state::StateMap<C::PublicKey, Account<C>>,
}
Expand Down
11 changes: 10 additions & 1 deletion module-system/module-implementations/sov-accounts/src/query.rs
Original file line number Diff line number Diff line change
@@ -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,
}

Expand Down
2 changes: 2 additions & 0 deletions module-system/module-schemas/schemas/sov-accounts.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down