Skip to content

Commit

Permalink
fix: revert node contract update extrinsic
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanVerstraete committed Aug 22, 2022
1 parent cfe820c commit 401ec48
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion substrate-node/charts/substrate-node/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ name: substrate-node
description: Tfchain node
type: application
version: 0.2.4
appVersion: "2.1.0-b2"
appVersion: "2.1.0-b3"
5 changes: 4 additions & 1 deletion substrate-node/pallets/pallet-smart-contract/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,10 @@ pub mod pallet {
origin: OriginFor<T>,
contract_id: u64,
deployment_hash: DeploymentHash,
deployment_data: DeploymentDataInput<T>,
) -> DispatchResultWithPostInfo {
let account_id = ensure_signed(origin)?;
Self::_update_node_contract(account_id, contract_id, deployment_hash)
Self::_update_node_contract(account_id, contract_id, deployment_hash, deployment_data)
}

#[pallet::weight(10_000 + T::DbWeight::get().writes(1))]
Expand Down Expand Up @@ -650,6 +651,7 @@ impl<T: Config> Pallet<T> {
account_id: T::AccountId,
contract_id: u64,
deployment_hash: DeploymentHash,
deployment_data: DeploymentDataInput<T>,
) -> DispatchResultWithPostInfo {
let mut contract = Contracts::<T>::get(contract_id).ok_or(Error::<T>::ContractNotExists)?;
let twin =
Expand Down Expand Up @@ -680,6 +682,7 @@ impl<T: Config> Pallet<T> {
);

node_contract.deployment_hash = deployment_hash;
node_contract.deployment_data = deployment_data;

// override values
contract.contract_type = types::ContractData::NodeContract(node_contract);
Expand Down
9 changes: 6 additions & 3 deletions substrate-node/pallets/pallet-smart-contract/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ fn test_update_node_contract_works() {
assert_ok!(SmartContractModule::update_node_contract(
Origin::signed(alice()),
1,
new_hash
new_hash,
get_deployment_data()
));

let node_contract = types::NodeContract {
Expand Down Expand Up @@ -219,7 +220,8 @@ fn test_update_node_contract_not_exists_fails() {
SmartContractModule::update_node_contract(
Origin::signed(alice()),
1,
generate_deployment_hash()
generate_deployment_hash(),
get_deployment_data()
),
Error::<TestRuntime>::ContractNotExists
);
Expand All @@ -244,7 +246,8 @@ fn test_update_node_contract_wrong_twins_fails() {
SmartContractModule::update_node_contract(
Origin::signed(bob()),
1,
generate_deployment_hash()
generate_deployment_hash(),
get_deployment_data()
),
Error::<TestRuntime>::TwinNotAuthorizedToUpdateContract
);
Expand Down
2 changes: 1 addition & 1 deletion substrate-node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("substrate-threefold"),
impl_name: create_runtime_str!("substrate-threefold"),
authoring_version: 1,
spec_version: 105,
spec_version: 106,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 2,
Expand Down

0 comments on commit 401ec48

Please sign in to comment.