Implement contract_getStorage RPC API (#3944)

This commit is contained in:
Sergei Pepyakin
2019-10-30 13:54:57 +01:00
committed by GitHub
parent 6c49ad4438
commit 5486d7add2
5 changed files with 147 additions and 15 deletions
+15
View File
@@ -664,6 +664,21 @@ impl_runtime_apis! {
Err(_) => ContractExecResult::Error,
}
}
fn get_storage(
address: AccountId,
key: [u8; 32],
) -> contracts_rpc_runtime_api::GetStorageResult {
Contracts::get_storage(address, key).map_err(|rpc_err| {
use contracts::GetStorageError;
use contracts_rpc_runtime_api::{GetStorageError as RpcGetStorageError};
/// Map the contract error into the RPC layer error.
match rpc_err {
GetStorageError::ContractDoesntExist => RpcGetStorageError::ContractDoesntExist,
GetStorageError::IsTombstone => RpcGetStorageError::IsTombstone,
}
})
}
}
impl transaction_payment_rpc_runtime_api::TransactionPaymentApi<