Skip to content

Commit

Permalink
asset: Add instance digest to storage on change
Browse files Browse the repository at this point in the history
Signed-off-by: Shreevatsa N <[email protected]>
  • Loading branch information
vatsa287 committed Apr 8, 2024
1 parent 2277977 commit baf4595
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
13 changes: 10 additions & 3 deletions pallets/asset/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,13 @@ pub mod pallet {
pub type VCAssetEntryOf<T> =
VCAssetEntry<AssetStatusOf, AssetCreatorOf<T>, BlockNumberFor<T>, EntryHashOf<T>>;

pub type VCAssetDistributionEntryOf<T> =
VCAssetDistributionEntry<AssetStatusOf, AssetCreatorOf<T>, BlockNumberFor<T>, AssetIdOf>;
pub type VCAssetDistributionEntryOf<T> = VCAssetDistributionEntry<
AssetStatusOf,
AssetCreatorOf<T>,
EntryHashOf<T>,
BlockNumberFor<T>,
AssetIdOf,
>;

pub type AssetDistributionEntryOf<T> = AssetDistributionEntry<
AssetDescriptionOf<T>,
Expand Down Expand Up @@ -598,6 +603,7 @@ pub mod pallet {
VCAssetDistributionEntryOf::<T> {
asset_qty: issuance_qty,
asset_instance_parent: entry.asset_id.clone(),
digest,
asset_instance_status: AssetStatusOf::ACTIVE,
asset_instance_issuer: issuer,
asset_instance_owner: entry.asset_owner,
Expand All @@ -622,7 +628,7 @@ pub mod pallet {
pub fn vc_transfer(
origin: OriginFor<T>,
entry: AssetTransferEntryOf<T>,
_digest: EntryHashOf<T>,
digest: EntryHashOf<T>,
) -> DispatchResult {
let owner = <T as Config>::EnsureOrigin::ensure_origin(origin)?.subject();

Expand Down Expand Up @@ -650,6 +656,7 @@ pub mod pallet {
&entry.asset_instance_id,
VCAssetDistributionEntryOf::<T> {
asset_instance_owner: entry.new_asset_owner.clone(),
digest,
created_at: block_number,
..instance
},
Expand Down
10 changes: 9 additions & 1 deletion pallets/asset/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,18 @@ pub struct AssetDistributionEntry<
#[derive(
Encode, Decode, Clone, RuntimeDebug, PartialEq, Eq, PartialOrd, Ord, TypeInfo, MaxEncodedLen,
)]
pub struct VCAssetDistributionEntry<AssetStatusOf, AssetCreatorOf, BlockNumber, AssetId> {
pub struct VCAssetDistributionEntry<
AssetStatusOf,
AssetCreatorOf,
EntryHashOf,
BlockNumber,
AssetId,
> {
pub asset_qty: AssetQtyOf,
/// asset parent reference
pub asset_instance_parent: AssetId,
/// asset instance digest
pub digest: EntryHashOf,
/// status of the asset
pub asset_instance_status: AssetStatusOf,
/// asset issuer
Expand Down

0 comments on commit baf4595

Please sign in to comment.