Skip to content

Commit

Permalink
remove strkey lib use because it is just an extra type and we can use…
Browse files Browse the repository at this point in the history
… account id
  • Loading branch information
leighmcculloch committed Nov 6, 2024
1 parent 3d6498f commit 5706e65
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions cmd/soroban-cli/src/commands/contract/deploy/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,13 @@ impl NetworkRunnable for Cmd {
client
.verify_network_passphrase(Some(&network.network_passphrase))
.await?;

let MuxedAccount::Ed25519(bytes) = config.source_account()? else {
return Err(Error::OnlyEd25519AccountsAllowed);
};

let source_account = stellar_strkey::ed25519::PublicKey(bytes.into());
let source_account = AccountId(PublicKey::PublicKeyTypeEd25519(bytes));
let contract_id_preimage = ContractIdPreimage::Address(ContractIdPreimageFromAddress {
address: ScAddress::Account(AccountId(PublicKey::PublicKeyTypeEd25519(
source_account.0.into(),
))),
address: ScAddress::Account(source_account.clone()),
salt: Uint256(salt),
});
let contract_id =
Expand Down Expand Up @@ -271,7 +269,7 @@ impl NetworkRunnable for Cmd {
wasm_hash,
sequence + 1,
self.fee.fee,
&source_account,
source_account,
contract_id_preimage,
constructor_params.as_ref(),
)?;
Expand Down Expand Up @@ -317,7 +315,7 @@ fn build_create_contract_tx(
wasm_hash: Hash,
sequence: i64,
fee: u32,
key: &stellar_strkey::ed25519::PublicKey,
key: AccountId,
contract_id_preimage: ContractIdPreimage,
constructor_params: Option<&InvokeContractArgs>,
) -> Result<Transaction, Error> {
Expand Down Expand Up @@ -346,7 +344,7 @@ fn build_create_contract_tx(
}
};
let tx = Transaction {
source_account: MuxedAccount::Ed25519(key.0.into()),
source_account: key.into(),
fee,
seq_num: SequenceNumber(sequence),
cond: Preconditions::None,
Expand All @@ -372,20 +370,20 @@ mod tests {
let key =
&utils::parse_secret_key("SBFGFF27Y64ZUGFAIG5AMJGQODZZKV2YQKAVUUN4HNE24XZXD2OEUVUP")
.unwrap();
let source_account = stellar_strkey::ed25519::PublicKey(key.verifying_key().to_bytes());
let source_account = AccountId(PublicKey::PublicKeyTypeEd25519(Uint256(
key.verifying_key().to_bytes(),
)));

let contract_id_preimage = ContractIdPreimage::Address(ContractIdPreimageFromAddress {
address: ScAddress::Account(AccountId(PublicKey::PublicKeyTypeEd25519(
source_account.0.into(),
))),
address: ScAddress::Account(source_account.clone()),
salt: Uint256(salt),
});

let result = build_create_contract_tx(
Hash(hash),
300,
1,
&source_account,
source_account,
contract_id_preimage,
None,
);
Expand Down

0 comments on commit 5706e65

Please sign in to comment.