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

asset: Add instance digest to storage on change #421

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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