Skip to content

Commit

Permalink
[rooch-networkgh-2471] add args to the build command.
Browse files Browse the repository at this point in the history
  • Loading branch information
Feliciss committed Aug 21, 2024
1 parent 8370c5f commit 08f7a72
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
5 changes: 1 addition & 4 deletions crates/rooch-rpc-client/src/rooch_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
// SPDX-License-Identifier: Apache-2.0

use anyhow::{Ok, Result};
use hex::ToHex;
use jsonrpsee::http_client::HttpClient;
use moveos_types::h256::H256;
use moveos_types::moveos_std::account::Account;
use moveos_types::transaction::MoveAction;
use moveos_types::{access_path::AccessPath, state::ObjectState, transaction::FunctionCall};
use rooch_rpc_api::api::rooch_api::RoochAPIClient;
use rooch_rpc_api::jsonrpc_types::{
Expand All @@ -15,8 +13,7 @@ use rooch_rpc_api::jsonrpc_types::{
};
use rooch_rpc_api::jsonrpc_types::{
AccessPathView, AnnotatedFunctionResultView, BalanceInfoPageView, EventOptions, EventPageView,
FieldKeyView, ObjectIDView, RoochAddressView, StateOptions, StatePageView, StrView,
StructTagView,
FieldKeyView, ObjectIDView, RoochAddressView, StateOptions, StatePageView, StructTagView,
};
use rooch_rpc_api::jsonrpc_types::{ExecuteTransactionResponseView, ObjectStateView};
use rooch_rpc_api::jsonrpc_types::{
Expand Down
44 changes: 24 additions & 20 deletions crates/rooch/src/commands/transaction/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,31 @@

use crate::cli_types::{CommandAction, TransactionOptions, WalletContextOptions};
use async_trait::async_trait;
use move_core_types::{identifier::Identifier, language_storage::ModuleId};
use move_core_types::{
account_address::AccountAddress,
identifier::Identifier,
language_storage::{ModuleId, TypeTag},
};
use moveos_types::{move_types::FunctionId, transaction::MoveAction};
use rooch_framework::MOVEOS_STD_ADDRESS;
use rooch_rpc_api::jsonrpc_types::TransactionWithInfoPageView;
use rooch_rpc_client::wallet_context;
use rooch_types::{error::RoochResult, transaction::RoochTransactionData};

/// Get transactions by order
#[derive(Debug, clap::Parser)]
pub struct BuildCommand {
/// Transaction's hash
#[clap(long)]
pub cursor: Option<u64>,
#[clap(long, required = true)]
pub module_address: AccountAddress,

#[clap(long, required = true)]
pub module_name: String,

#[clap(long, required = true)]
pub function_name: String,

#[clap(long)]
pub limit: Option<u64>,
pub type_args: Vec<TypeTag>,

/// descending order
#[clap(short = 'd', long)]
descending_order: Option<bool>,
#[clap(long)]
pub args: Vec<Vec<u8>>,

#[clap(flatten)]
tx_options: TransactionOptions,
Expand All @@ -38,22 +43,21 @@ impl CommandAction<RoochTransactionData> for BuildCommand {
let sender = context.resolve_address(self.tx_options.sender)?.into();
let max_gas_amount = self.tx_options.max_gas_amount;

// TODO: actions for building a tx data
let mut bundles: Vec<Vec<u8>> = vec![];
let args = bcs::to_bytes(&bundles).unwrap();
let action = MoveAction::new_function_call(
FunctionId::new(
ModuleId::new(
MOVEOS_STD_ADDRESS,
Identifier::new("module_store".to_owned()).unwrap(),
self.module_address,
Identifier::new(self.module_name.to_owned()).unwrap(),
),
Identifier::new("publish_modules_entry".to_owned()).unwrap(),
Identifier::new(self.function_name.to_owned()).unwrap(),
),
vec![],
vec![args],
self.type_args,
self.args,
);

let tx_data = context.build_tx_data(sender, action, max_gas_amount);
let tx_data = context
.build_tx_data(sender, action, max_gas_amount)
.await?;
Ok(tx_data)
}
}

0 comments on commit 08f7a72

Please sign in to comment.