Skip to content

Commit

Permalink
Appease linter
Browse files Browse the repository at this point in the history
  • Loading branch information
2opremio committed Sep 29, 2022
1 parent 233efe1 commit 7c580bb
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@ use std::num::ParseIntError;
use std::{fmt::Debug, fs, io};

use clap::Parser;
use ed25519_dalek;
use ed25519_dalek::Signer;
use hex::FromHexError;
use jsonrpsee_core;
use jsonrpsee_core::client::ClientT;
use jsonrpsee_core::rpc_params;
use jsonrpsee_http_client;
use jsonrpsee_http_client::HttpClientBuilder;
use rand::Rng;
use sha2::{Digest, Sha256};
Expand Down Expand Up @@ -209,8 +206,8 @@ fn build_create_contract_tx(
let contract_signature = key.sign(&contract_hash);

let preimage = HashIdPreimage::ContractIdFromEd25519(HashIdPreimageEd25519ContractId {
ed25519: Uint256(key.public.as_bytes().clone()),
salt: Uint256(salt.into()),
ed25519: Uint256(key.public.to_bytes()),
salt: Uint256(salt),
});
let preimage_xdr = preimage.to_xdr()?;
let contract_id = Sha256::digest(preimage_xdr);
Expand Down Expand Up @@ -239,7 +236,7 @@ fn build_create_contract_tx(
let op = Operation {
source_account: None,
body: OperationBody::InvokeHostFunction(InvokeHostFunctionOp {
function: HostFunction::CreateContract,
function: HostFunction::CreateContractWithEd25519,
parameters: parameters.into(),
footprint: LedgerFootprint {
read_only: Default::default(),
Expand All @@ -248,8 +245,8 @@ fn build_create_contract_tx(
}),
};
let tx = Transaction {
source_account: MuxedAccount::Ed25519(Uint256(key.public.as_bytes().clone())),
fee: fee,
source_account: MuxedAccount::Ed25519(Uint256(key.public.to_bytes())),
fee,
seq_num: SequenceNumber(sequence),
cond: Preconditions::None,
memo: Memo::None,
Expand All @@ -272,7 +269,7 @@ fn build_create_contract_tx(
};

let envelope = TransactionEnvelope::Tx(TransactionV1Envelope {
tx: tx,
tx,
signatures: vec![decorated_signature].try_into()?,
});

Expand All @@ -281,7 +278,7 @@ fn build_create_contract_tx(

fn parse_private_key(strkey: &str) -> Result<ed25519_dalek::Keypair, Error> {
let seed =
StrkeyPrivateKeyEd25519::from_string(&strkey).map_err(|_| Error::CannotParsePrivateKey)?;
StrkeyPrivateKeyEd25519::from_string(strkey).map_err(|_| Error::CannotParsePrivateKey)?;
let secret_key =
ed25519_dalek::SecretKey::from_bytes(&seed.0).map_err(|_| Error::CannotParsePrivateKey)?;
let public_key = (&secret_key).into();
Expand All @@ -294,7 +291,6 @@ fn parse_private_key(strkey: &str) -> Result<ed25519_dalek::Keypair, Error> {
#[cfg(test)]
mod tests {
use super::*;
use jsonrpsee_http_client::types::Response;

#[test]
fn test_parse_private_key() {
Expand Down

0 comments on commit 7c580bb

Please sign in to comment.