Skip to content

Commit 0ec8819

Browse files
CentrilNeopallium
andauthored
MESH-1824: Empty perms default + MESH-1825: Contracts RPC (#1239)
* mesh-1824: make empty perms the default * mesh-1825: enable rpc for contracts * mesh-1825: address review comments * Fix comment. Co-authored-by: Robert Gabriel Jakabosky <[email protected]> Co-authored-by: Robert Gabriel Jakabosky <[email protected]>
1 parent 661f84a commit 0ec8819

File tree

14 files changed

+229
-56
lines changed

14 files changed

+229
-56
lines changed

Cargo.lock

Lines changed: 44 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ pallet-babe = { git = "https://github.com/PolymathNetwork/substrate", branch = "
2424
pallet-balances = { git = "https://github.com/PolymathNetwork/substrate", branch = "polymesh-develop" }
2525
pallet-contracts = { git = "https://github.com/PolymathNetwork/substrate", branch = "polymesh-develop" }
2626
pallet-contracts-primitives = { git = "https://github.com/PolymathNetwork/substrate", branch = "polymesh-develop" }
27-
#pallet-contracts-rpc = { git = "https://github.com/PolymathNetwork/substrate", branch = "polymesh-develop" }
28-
#pallet-contracts-rpc-runtime-api = { git = "https://github.com/PolymathNetwork/substrate", branch = "polymesh-develop" }
27+
pallet-contracts-rpc = { git = "https://github.com/PolymathNetwork/substrate", branch = "polymesh-develop" }
28+
pallet-contracts-rpc-runtime-api = { git = "https://github.com/PolymathNetwork/substrate", branch = "polymesh-develop" }
2929
pallet-grandpa = { git = "https://github.com/PolymathNetwork/substrate", branch = "polymesh-develop" }
3030
pallet-im-online = { git = "https://github.com/PolymathNetwork/substrate", branch = "polymesh-develop" }
3131
pallet-indices = { git = "https://github.com/PolymathNetwork/substrate", branch = "polymesh-develop" }
@@ -122,7 +122,7 @@ members = [
122122
"pallets/committee",
123123
"pallets/common",
124124
"pallets/compliance-manager",
125-
#"pallets/contracts",
125+
"pallets/contracts",
126126
"pallets/corporate-actions",
127127
"pallets/external-agents",
128128
"pallets/group",
@@ -212,8 +212,7 @@ frame-support = "4.0.0-dev"
212212
frame-system = "4.0.0-dev"
213213
frame-system-rpc-runtime-api = "4.0.0-dev"
214214
grandpa = { package = "sc-finality-grandpa", version = "0.10.0-dev" }
215-
#pallet-contracts = "4.0.0-dev"
216-
#pallet-contracts-rpc-runtime-api = "4.0.0-dev"
215+
pallet-contracts-rpc-runtime-api = "4.0.0-dev"
217216
pallet-babe = "4.0.0-dev"
218217
pallet-im-online = "4.0.0-dev"
219218
pallet-indices = "4.0.0-dev"

node-rpc/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ targets = ["x86_64-unknown-linux-gnu"]
1111

1212
[dependencies]
1313
polymesh-primitives = { path = "../primitives", default-features = false }
14-
#pallet-contracts-rpc = { version = "4.0.0-dev" }
14+
pallet-contracts-rpc = { version = "4.0.0-dev" }
1515
pallet-group-rpc = { path = "../pallets/group/rpc" }
1616
pallet-staking-rpc = { path = "../pallets/staking/rpc" }
1717
pallet-protocol-fee-rpc = { path = "../pallets/protocol-fee/rpc" }

node-rpc/src/lib.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
3131
#![warn(missing_docs)]
3232

33-
use polymesh_primitives::{AccountId, Block, BlockNumber, Hash, IdentityId, Index, Moment, Ticker};
33+
use polymesh_primitives::{
34+
AccountId, Balance, Block, BlockNumber, Hash, IdentityId, Index, Moment, Ticker,
35+
};
3436
use sc_client_api::AuxStore;
3537
use sc_consensus_babe::{Config, Epoch};
3638
use sc_consensus_epochs::SharedEpochChanges;
@@ -117,7 +119,7 @@ where
117119
+ Send
118120
+ 'static,
119121
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>,
120-
//C::Api: pallet_contracts_rpc::ContractsRuntimeApi<Block, AccountId, Balance, BlockNumber>,
122+
C::Api: pallet_contracts_rpc::ContractsRuntimeApi<Block, AccountId, Balance, BlockNumber, Hash>,
121123
C::Api: node_rpc::transaction_payment::TransactionPaymentRuntimeApi<Block, UE>,
122124
C::Api: pallet_staking_rpc::StakingRuntimeApi<Block>,
123125
C::Api: node_rpc::pips::PipsRuntimeApi<Block, AccountId>,
@@ -141,7 +143,7 @@ where
141143
pips::{Pips, PipsApi},
142144
transaction_payment::{TransactionPayment, TransactionPaymentApi},
143145
};
144-
//use pallet_contracts_rpc::{Contracts, ContractsApi};
146+
use pallet_contracts_rpc::{Contracts, ContractsApi};
145147
use pallet_group_rpc::{Group, GroupApi};
146148
use pallet_protocol_fee_rpc::{ProtocolFee, ProtocolFeeApi};
147149
use pallet_staking_rpc::{Staking, StakingApi};
@@ -181,7 +183,7 @@ where
181183
// Making synchronous calls in light client freezes the browser currently,
182184
// more context: https://github.com/PolymathNetwork/substrate/pull/3480
183185
// These RPCs should use an asynchronous caller instead.
184-
//io.extend_with(ContractsApi::to_delegate(Contracts::new(client.clone())));
186+
io.extend_with(ContractsApi::to_delegate(Contracts::new(client.clone())));
185187
io.extend_with(TransactionPaymentApi::to_delegate(TransactionPayment::new(
186188
client.clone(),
187189
)));

pallets/contracts/src/benchmarking.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ fn free_balance<T: Config>(acc: &T::AccountId) -> Balance {
6060
/// Returns the address of the new contract.
6161
fn instantiate<T: Config>(user: &User<T>, wasm: WasmModule<T>, salt: Vec<u8>) -> T::AccountId {
6262
let callee = Base::<T>::contract_address(&user.account(), &wasm.hash, &salt);
63-
Pallet::<T>::instantiate_with_code(
63+
Pallet::<T>::instantiate_with_code_perms(
6464
user.origin().into(),
6565
Base::<T>::subsistence_threshold(), // endowment
6666
Weight::MAX, // gas limit
@@ -201,7 +201,7 @@ benchmarks! {
201201

202202
// Pre-instantiate a contract so that one with the hash exists.
203203
let _ = instantiate::<T>(&user, wasm, salt());
204-
}: _(user.origin(), ENDOWMENT, Weight::MAX, hash, vec![], other_salt, Permissions::empty())
204+
}: instantiate(user.origin(), ENDOWMENT, Weight::MAX, hash, vec![], other_salt)
205205
verify {
206206
// Ensure contract has the full value.
207207
assert_eq!(free_balance::<T>(&addr), ENDOWMENT);
@@ -232,7 +232,7 @@ benchmarks! {
232232
// Construct the contract code + get addr.
233233
let wasm = WasmModule::<T>::sized(c);
234234
let addr = Base::<T>::contract_address(&user.account(), &wasm.hash, &salt);
235-
}: _(user.origin(), ENDOWMENT, Weight::MAX, wasm.code, vec![], salt, Permissions::empty())
235+
}: _(user.origin(), ENDOWMENT, Weight::MAX, wasm.code, vec![], salt)
236236
verify {
237237
// Ensure contract has the full value.
238238
assert_eq!(free_balance::<T>(&addr), ENDOWMENT);

0 commit comments

Comments
 (0)