-
Notifications
You must be signed in to change notification settings - Fork 91
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
Implements Account balance list cli #760
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
let coin_store_handle_opt: Option<ObjectID> = client | ||
.call_function(&ctx, call)? | ||
.into_result() | ||
.map(|values| { | ||
let value = values.get(0).expect("Expected return value"); | ||
let result = MoveOption::<ObjectID>::from_bytes(&value.value) | ||
.expect("Expected Option<ObjectID>"); | ||
result.into() | ||
})?; | ||
let coin_store_handle = coin_store_handle_opt | ||
// .expect(format!("Failed to get coin store handle via {}", addr).as_str()); | ||
.unwrap_or_else(|| panic!("Failed to get coin store handle via {}", addr)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Directly call the coin_module::coin_store_handle
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried it before, but there are some problems.
After binding coin_mudule
, await occurs here, with coin_mudule
maybe used later.
the trait Sync
is not implemented for dyn MoveFunctionCaller
, future is not Send
as this value is used across an await.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The client has already implemented the MoveFunctionCaller
.
rooch/crates/rooch/src/commands/session_key/commands/create.rs
Lines 71 to 79 in a635258
let session_key_module = client.as_module_binding::<SessionKeyModule>(); | |
let session_key = session_key_module | |
.get_session_key(sender.into(), &session_auth_key)? | |
.ok_or_else(|| { | |
RoochError::ViewFunctionError(format!( | |
"Failed to get session key via {}", | |
session_auth_key | |
)) | |
})?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The difference is whether MoveFunctionCaller
is called by async/await.
You can open these two lines of comments, cargo build to see the specific error.
rooch/crates/rooch/src/commands/account/commands/balance.rs
Lines 73 to 74 in 370bb0e
// let coin_module = client.as_module_binding::<CoinModule>(); | |
// let coin_store_handle_opt = coin_module.coin_store_handle(addr)?; |
/// Struct name as `<ADDRESS>::<MODULE_ID>::<STRUCT_NAME><TypeParam1?, TypeParam2?>` | ||
/// Example: `0x123::counter::Counter`, `0x123::counter::Box<0x123::counter::Counter>` | ||
#[clap(long = "coin_type")] | ||
/// The block number or block hash for get state, if absent, use latest block state_root. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line of code comment is probably a copying error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line of code comment is probably a copying error
fixed
address: Option<AccountAddressView>, | ||
|
||
/// Struct name as `<ADDRESS>::<MODULE_ID>::<STRUCT_NAME><TypeParam1?, TypeParam2?>` | ||
/// Example: `0x123::counter::Counter`, `0x123::counter::Box<0x123::counter::Counter>` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Give a coin struct_tag example
The and
We can remove the |
|
||
/// Struct name as `<ADDRESS>::<MODULE_ID>::<STRUCT_NAME><TypeParam1?, TypeParam2?>` | ||
/// Example: `0x123::counter::Counter`, `0x123::counter::Box<0x123::counter::Counter>` | ||
#[clap(long = "coin_type")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just use #[clap(long)]
. The CLI option should use -
instead of _
.
already remove |
@@ -256,7 +256,7 @@ impl AnnotatedCoinStoreView { | |||
} | |||
} | |||
|
|||
pub fn get_coin_type(&self) -> StructTagView { | |||
pub fn get_coin_type_(&self) -> StructTagView { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why need _
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This coin type contains 0x3::coin::Coin<>
, corresponding to the type of filed_value, in order to distinguish the cointype in BalanceInfo.
let coin_type_ = filed_value.type_; |
Ok(annotated_coin_store) | ||
} | ||
|
||
pub fn get_coin_type__(&self) -> StructTag { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there two _
I will merge the pr first |
resolve #744
Problems
1, It is hard to support converting from AnnotatedMoveValueView to AnnotatedMoveValue, mainly because of it hard to support convert SpecificStruct to AnnotatedMoveStruct. As a result, parsing AnnotatedCoinStoreView from the RPC API is very tedious. relative of #758
2, The current implementation of AnnotatedMoveValueView may be flawed. Coin balance defines the U256 type, but the type obtained from AnnotatedMoveValueView is U64(StrView(10000), and the expected type is U256(StrView(10000). May return U128(StrView(value) type.
3, Type_table exposes the method of obtaining the handle, is it reasonable to expose the handle, and will this method have security problems?
TODO
1, Coin balance needs to depend on CoinInfo to display the decimal point after processing decimals
2,Add test case for the balance command
Example
Result
Result