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

[cmd]Cmd View Object optimize #613

Closed
jolestar opened this issue Jun 5, 2020 · 3 comments
Closed

[cmd]Cmd View Object optimize #613

jolestar opened this issue Jun 5, 2020 · 3 comments
Labels
area:cli Issue about cli. enhancement Enhancement

Comments

@jolestar
Copy link
Member

jolestar commented Jun 5, 2020

当前 console 显示的结果中的字段是重新定义 View Object 来展示的。
这样有几个缺点:

  1. 每次都需要转换,如果忘记转换就会导致 console 的输出很不友好。
  2. 修改 Origin Object 的时候可能忘记修改了 View Object。
  3. List View 和 Item View 需要展示的字段可能不一样。
  4. 用户无法要求展示完整的字段。

可以尝试通过定义 macro 的方式,自动生成 View Object,并且其中的字段是分展示级别的。

在或者配合 GraphQL 提供一种统一的查询检索方式?

@jolestar jolestar added enhancement Enhancement area:cli Issue about cli. labels Jun 5, 2020
@jolestar jolestar added this to the proxima milestone Jun 5, 2020
@jolestar jolestar mentioned this issue Jul 9, 2020
17 tasks
@jolestar jolestar removed this from the proxima milestone Jul 13, 2020
@jolestar jolestar added this to the starcoin-0.5 milestone Aug 6, 2020
@jolestar jolestar added this to the starcoin-1.0 milestone Jan 13, 2021
@jolestar
Copy link
Member Author

统一使用 JSON Rpc 的 ViewObject

@yubing744
Copy link

ViewObject

这个 ViewObject 有相关资料吗?

@jolestar
Copy link
Member Author

ViewObject

这个 ViewObject 有相关资料吗?

比较方便的是看 rust rpc 的代码, 比如

#[derive(Clone, Debug, Hash, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
pub struct BlockHeaderView {
pub block_hash: HashValue,
/// Parent hash.
pub parent_hash: HashValue,
/// Block timestamp.
pub timestamp: StrView<u64>,
/// Block number.
pub number: StrView<BlockNumber>,
/// Block author.
pub author: AccountAddress,
/// Block author auth key.
pub author_auth_key: Option<AuthenticationKey>,
/// The transaction accumulator root hash after executing this block.
pub txn_accumulator_root: HashValue,
/// The block accumulator root hash.
pub block_accumulator_root: HashValue,
/// The last transaction state_root of this block after execute.
pub state_root: HashValue,
/// Gas used for contracts execution.
pub gas_used: StrView<u64>,
/// Block difficulty
#[schemars(with = "String")]
pub difficulty: U256,
/// hash for block body
pub body_hash: HashValue,
/// The chain id
pub chain_id: u8,
/// Consensus nonce field.
pub nonce: u32,
/// block header extra
pub extra: BlockHeaderExtra,
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:cli Issue about cli. enhancement Enhancement
Projects
None yet
Development

No branches or pull requests

3 participants