Skip to content

Commit

Permalink
Pass node and provider ids to the auth extension
Browse files Browse the repository at this point in the history
  • Loading branch information
khssnv committed Oct 30, 2023
1 parent f1f1dfa commit fa3d661
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pallets/ddc-clusters/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ pub mod pallet {
.map_err(|_| Error::<T>::AttemptToAddNonExistentNode)?;
ensure!(node.get_cluster_id().is_none(), Error::<T>::NodeIsAlreadyAssigned);

// Node provider is staking.
let node_provider_stash =
<pallet_ddc_staking::Pallet<T>>::nodes(&node_pub_key).ok_or(Error::<T>::NoStake)?;
let maybe_edge_in_cluster =
Expand All @@ -137,13 +138,20 @@ pub mod pallet {
.is_some_and(|staking_cluster| staking_cluster == cluster_id);
ensure!(has_stake, Error::<T>::NoStake);

// Cluster extension smart contract allows joining.
// is_authorized(node_provider: AccountId, node: Vec<u8>, node_variant: u8) -> bool
let mut call_data = Vec::new();
call_data.extend_from_slice(&INK_SELECTOR_IS_AUTHORIZED);
call_data.append(&mut node_provider_stash.encode());
call_data.append(&mut node_pub_key.encode());
call_data.push(node_pub_key.variant_as_number());
let is_authorized: bool = pallet_contracts::Pallet::<T>::bare_call(
caller_id,
cluster.props.node_provider_auth_contract,
Default::default(),
EXTENSION_CALL_GAS_LIMIT,
None,
Vec::from(INK_SELECTOR_IS_AUTHORIZED),
call_data,
false,
)
.result?
Expand Down

0 comments on commit fa3d661

Please sign in to comment.