Skip to content

Commit

Permalink
Enable printing contract-id and accept Bech32 address in forc-deploy (
Browse files Browse the repository at this point in the history
  • Loading branch information
kayagokalp authored Oct 25, 2022
1 parent 1d0b1af commit 444ffa9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions forc-plugins/forc-client/src/ops/deploy/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ pub async fn deploy(command: DeployCommand) -> Result<fuel_tx::ContractId> {
let root = contract.root();
let state_root = Contract::initial_state_root(storage_slots.iter());
let contract_id = contract.id(&salt, &root, &state_root);
info!("Contract id: 0x{}", hex::encode(contract_id));
let tx = TransactionBuilder::create(bytecode, salt, storage_slots.clone())
.params(TxParameters::new(command.gas_limit, command.gas_price))
.add_output(Output::contract_created(contract_id, state_root))
Expand Down
8 changes: 4 additions & 4 deletions forc-plugins/forc-client/src/ops/tx_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ use fuels_core::constants::BASE_ASSET_ID;
use fuels_signers::{provider::Provider, Wallet};
use fuels_types::bech32::Bech32Address;

fn prompt_address() -> Result<Address> {
fn prompt_address() -> Result<Bech32Address> {
print!("Please provide the address of the wallet you are going to sign this transaction with:");
std::io::stdout().flush()?;
let mut buf = String::new();
std::io::stdin().read_line(&mut buf)?;
Address::from_str(buf.trim()).map_err(Error::msg)
Bech32Address::from_str(buf.trim()).map_err(Error::msg)
}

fn prompt_signature(message: Message) -> Result<Signature> {
Expand Down Expand Up @@ -122,7 +122,7 @@ impl TransactionBuilderExt for TransactionBuilder {
let inputs = wallet
.get_asset_inputs_for_amount(asset_id, amount, signature_witness_index)
.await?;
let output = Output::change(address, 0, asset_id);
let output = Output::change(wallet.address().into(), 0, asset_id);

self.add_inputs(inputs).add_output(output);

Expand All @@ -140,7 +140,7 @@ impl TransactionBuilderExt for TransactionBuilder {
let address = if let Some(signing_key) = signing_key {
Address::from(*signing_key.public_key().hash())
} else {
prompt_address()?
Address::from(prompt_address()?)
};

// Insert dummy witness for signature
Expand Down

0 comments on commit 444ffa9

Please sign in to comment.