Skip to content

Commit 060429e

Browse files
committed
supplycommit: use provided asset ID in metadata lookup if set
If an asset ID is supplied, use it when fetching asset metadata in FetchLatestAssetMetadata.
1 parent d8de559 commit 060429e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

universe/supplycommit/env.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,24 @@ func FetchLatestAssetMetadata(ctx context.Context, lookup AssetLookup,
268268

269269
var zero proof.MetaReveal
270270

271+
// If the asset specifier has an asset ID, then we'll use that to
272+
// fetch the asset metadata.
273+
if assetSpec.HasId() {
274+
assetID, err := assetSpec.UnwrapIdOrErr()
275+
if err != nil {
276+
return zero, err
277+
}
278+
279+
metaReveal, err := lookup.FetchAssetMetaForAsset(ctx, assetID)
280+
if err != nil {
281+
return zero, fmt.Errorf("faild to fetch asset meta: %w",
282+
err)
283+
}
284+
285+
return *metaReveal, nil
286+
}
287+
288+
// Otherwise, we'll need to fetch the asset group using the group key.
271289
groupKey, err := assetSpec.UnwrapGroupKeyOrErr()
272290
if err != nil {
273291
return zero, err

0 commit comments

Comments
 (0)