Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pallet): allow farmer to set extra fee on its nodes #726

Merged
merged 27 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
95f8880
feat: dedicated node extra fee
renauter Jun 7, 2023
bb6d2f0
chore: merge development
DylanVerstraete Jun 7, 2023
75bbda4
fix: ci
DylanVerstraete Jun 7, 2023
99359cc
feat: rework check before creating node contract
DylanVerstraete Jun 7, 2023
03e3e94
chore: rework syntax
DylanVerstraete Jun 7, 2023
9ca99fa
chore: revert farmer_share concept
renauter Jun 7, 2023
8e6295d
feat: dedicated node extra fee billing
renauter Jun 7, 2023
f37d57a
test: set dedicated node extra fee
renauter Jun 7, 2023
5d2483b
feat: add migration for locks
DylanVerstraete Jun 8, 2023
29d230a
chore: merge development
DylanVerstraete Jun 8, 2023
4abcd0b
chore: complete adr
DylanVerstraete Jun 8, 2023
5d4fe9a
fix: some general fixes and refactor
DylanVerstraete Jun 8, 2023
92c74d7
fix: rework test
DylanVerstraete Jun 9, 2023
0f00251
fix: go client bill event
DylanVerstraete Jun 9, 2023
c02830a
feat: add js client methods
DylanVerstraete Jun 9, 2023
4cadce0
feat: add go client methods
DylanVerstraete Jun 9, 2023
06950b2
fix: js client
DylanVerstraete Jun 9, 2023
7a14d2f
fix: go integration tests
DylanVerstraete Jun 9, 2023
8924cf1
chore: revert contract bill event type
DylanVerstraete Jun 12, 2023
ab050c0
chore: remove println
DylanVerstraete Jun 12, 2023
3bfe18c
chore: merge development
DylanVerstraete Jun 12, 2023
ebe5870
reviews and test rework
renauter Jun 12, 2023
1d8b942
chore: rework migration v11
renauter Jun 12, 2023
1ceaad4
feat: round costs before converting back to integer
renauter Jun 12, 2023
f41931f
chore: remove todo comment
renauter Jun 13, 2023
930f5cc
Merge remote-tracking branch 'origin' into development_feat_node_extr…
renauter Jun 13, 2023
e1cb885
chore: merge development
DylanVerstraete Jun 13, 2023
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
18 changes: 8 additions & 10 deletions substrate-node/pallets/pallet-smart-contract/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -757,19 +757,17 @@ impl<T: Config> Pallet<T> {

let farm = pallet_tfgrid::Farms::<T>::get(node.farm_id).ok_or(Error::<T>::FarmNotExists)?;

// If the user is trying to deploy on a node that has an active rent contract
// only allow the user who created the rent contract to actually deploy a node contract on it
let mut is_node_owner = false;
if let Some(contract_id) = ActiveRentContractForNode::<T>::get(node_id) {
let rent_contract =
Contracts::<T>::get(contract_id).ok_or(Error::<T>::ContractNotExists)?;
if rent_contract.twin_id != twin_id {
return Err(Error::<T>::NodeHasRentContract.into());
}
} else {
// If there is no active rent contract on node and farm is dedicated
if farm.dedicated_farm {
return Err(Error::<T>::NodeNotAvailableToDeploy.into());
}
is_node_owner = rent_contract.twin_id == twin_id;
renauter marked this conversation as resolved.
Show resolved Hide resolved
}

let fee = DedicatedNodesExtraFee::<T>::get(node_id).unwrap_or(0);
renauter marked this conversation as resolved.
Show resolved Hide resolved
// If the user is not the owner of the node and the node is not a dedicated node then we don't allow the creation of it.
renauter marked this conversation as resolved.
Show resolved Hide resolved
if !is_node_owner && farm.dedicated_farm || !is_node_owner && fee > 0 {
return Err(Error::<T>::NodeNotAvailableToDeploy.into());
renauter marked this conversation as resolved.
Show resolved Hide resolved
}

// If the contract with hash and node id exists and it's in any other state then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ fn test_create_node_contract_when_someone_else_has_rent_contract_fails() {
1,
None
),
Error::<TestRuntime>::NodeHasRentContract
Error::<TestRuntime>::NodeNotAvailableToDeploy
);
})
}
Expand Down