Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
separate alias for code hash
  • Loading branch information
krzysztofziobro committed Dec 29, 2022
commit 48e96994c81b312b3426a71242de6492e2cbb907
1 change: 1 addition & 0 deletions aleph-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub type KeyPair = PairSigner<AlephConfig, sr25519::Pair>;
pub type AccountId = subxt::ext::sp_core::crypto::AccountId32;
pub type Client = OnlineClient<AlephConfig>;
pub type BlockHash = H256;
pub type CodeHash = H256;

pub use connections::{Connection, RootConnection, SignedConnection, SudoCall};

Expand Down
24 changes: 9 additions & 15 deletions aleph-client/src/pallets/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use subxt::{

use crate::{
api, pallet_contracts::wasm::OwnerInfo, sp_weights::weight_v2::Weight, AccountId, BlockHash,
Connection, SignedConnection, TxStatus,
CodeHash, Connection, SignedConnection, TxStatus,
};

#[derive(Encode)]
Expand All @@ -23,11 +23,8 @@ pub struct ContractCallArgs {

#[async_trait::async_trait]
pub trait ContractsApi {
async fn get_owner_info(
&self,
code_hash: BlockHash,
at: Option<BlockHash>,
) -> Option<OwnerInfo>;
async fn get_owner_info(&self, code_hash: CodeHash, at: Option<BlockHash>)
-> Option<OwnerInfo>;
}

#[async_trait::async_trait]
Expand All @@ -41,7 +38,7 @@ pub trait ContractsUserApi {
#[allow(clippy::too_many_arguments)]
async fn instantiate(
&self,
code_hash: BlockHash,
code_hash: CodeHash,
balance: Balance,
gas_limit: Weight,
storage_limit: Option<Compact<u128>>,
Expand Down Expand Up @@ -69,11 +66,8 @@ pub trait ContractsUserApi {
data: Vec<u8>,
status: TxStatus,
) -> anyhow::Result<BlockHash>;
async fn remove_code(
&self,
code_hash: BlockHash,
status: TxStatus,
) -> anyhow::Result<BlockHash>;
async fn remove_code(&self, code_hash: CodeHash, status: TxStatus)
-> anyhow::Result<BlockHash>;
}

#[async_trait::async_trait]
Expand All @@ -85,7 +79,7 @@ pub trait ContractRpc {
impl ContractsApi for Connection {
async fn get_owner_info(
&self,
code_hash: BlockHash,
code_hash: CodeHash,
at: Option<BlockHash>,
) -> Option<OwnerInfo> {
let addrs = api::storage().contracts().owner_info_of(code_hash);
Expand All @@ -109,7 +103,7 @@ impl ContractsUserApi for SignedConnection {

async fn instantiate(
&self,
code_hash: BlockHash,
code_hash: CodeHash,
balance: Balance,
gas_limit: Weight,
storage_limit: Option<Compact<u128>>,
Expand Down Expand Up @@ -172,7 +166,7 @@ impl ContractsUserApi for SignedConnection {

async fn remove_code(
&self,
code_hash: BlockHash,
code_hash: CodeHash,
status: TxStatus,
) -> anyhow::Result<BlockHash> {
let tx = api::tx().contracts().remove_code(code_hash);
Expand Down
5 changes: 2 additions & 3 deletions bin/cliain/src/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ use aleph_client::{
pallets::contract::{ContractsApi, ContractsUserApi},
sp_weights::weight_v2::Weight,
waiting::{AlephWaiting, BlockStatus},
AccountId, Connection, SignedConnection, TxStatus,
AccountId, CodeHash, Connection, SignedConnection, TxStatus,
};
use codec::{Compact, Decode};
use contract_metadata::ContractMetadata;
use contract_transcode::ContractMessageTranscoder;
use log::{debug, info};
use serde::{Deserialize, Serialize};
use subxt::ext::sp_core::H256;

use crate::commands::{
ContractCall, ContractInstantiate, ContractInstantiateWithCode, ContractOptions,
Expand All @@ -26,7 +25,7 @@ use crate::commands::{
#[derive(Debug, Decode, Clone, Serialize, Deserialize)]
pub struct InstantiateWithCodeReturnValue {
pub contract: AccountId,
pub code_hash: H256,
pub code_hash: CodeHash,
}

fn storage_deposit(storage_deposit_limit: Option<u128>) -> Option<Compact<u128>> {
Expand Down