Skip to content

Commit

Permalink
Update PolymeshContracts pallet.
Browse files Browse the repository at this point in the history
  • Loading branch information
Neopallium committed Jan 14, 2025
1 parent f90320a commit 647a348
Show file tree
Hide file tree
Showing 3 changed files with 159 additions and 113 deletions.
15 changes: 10 additions & 5 deletions pallets/contracts/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use codec::Encode;
use frame_benchmarking::{account, benchmarks};
use frame_support::StorageMap;
use frame_support::{storage::unhashed, traits::tokens::currency::Currency};
use frame_system::{Pallet as System, RawOrigin};
use pallet_contracts::benchmarking::code::body::DynInstr::{Counter, Regular};
Expand Down Expand Up @@ -65,10 +66,10 @@ where

fn on_instantiate_transfer(caller: &T::AccountId, contract: &T::AccountId) -> DispatchResult {
// Get the caller's identity.
let did =
Identity::<T>::get_identity(&caller).ok_or(Error::<T>::InstantiatorWithNoIdentity)?;
let did = IdentityPallet::<T>::get_identity(&caller)
.ok_or(Error::<T>::InstantiatorWithNoIdentity)?;
// Check if contact is already linked.
match Identity::<T>::get_identity(&contract) {
match IdentityPallet::<T>::get_identity(&contract) {
Some(contract_did) => {
if contract_did != did && ParentDid::get(contract_did) != Some(did) {
// Contract address already linked to a different identity.
Expand All @@ -80,7 +81,11 @@ where
}
None => {
// Linked new contract address to caller's identity. With empty permissions.
Identity::<T>::unsafe_join_identity(did, Permissions::empty(), contract.clone());
IdentityPallet::<T>::unsafe_join_identity(
did,
Permissions::empty(),
contract.clone(),
);
Ok(())
}
}
Expand Down Expand Up @@ -357,7 +362,7 @@ benchmarks! {
.map(|i| {
let primary_user = funded_user::<T>(SEED + i);
let secondary_key: T::AccountId = account("key", i, SEED);
Identity::<T>::unsafe_join_identity(
IdentityPallet::<T>::unsafe_join_identity(
primary_user.did(),
secondary_key_permission.clone(),
secondary_key.clone(),
Expand Down
2 changes: 1 addition & 1 deletion pallets/contracts/src/chain_extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type Identity<T> = pallet_identity::Pallet<T>;
const MAX_DECODE_DEPTH: u32 = 10;

/// ExtrinsicId
#[derive(Encode, Decode, TypeInfo)]
#[derive(Encode, Decode, MaxEncodedLen, TypeInfo)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct ExtrinsicId(u8, u8);
Expand Down
Loading

0 comments on commit 647a348

Please sign in to comment.