Skip to content

Commit

Permalink
feat(projection): ignore burn transactions when projecting cip25 meta…
Browse files Browse the repository at this point in the history
  • Loading branch information
mkazlauskas committed Sep 14, 2023
1 parent 72e600c commit ab8bb29
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/projection/src/operators/Mappers/withNftMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ const getNftMetadataFromCip67 = ({ cip67 }: WithCIP67, logger: Logger) =>
);

const getNftMetadataFromCip25 = ({ mint }: WithMint, logger: Logger) =>
mint.map(({ assetId, txMetadata, policyId, assetName }): ProjectedNftMetadata | null => {
mint.map(({ assetId, txMetadata, policyId, assetName, quantity }): ProjectedNftMetadata | null => {
if (quantity < 1n) return null;
const nftMetadata = Asset.NftMetadata.fromMetadatum({ name: assetName, policyId }, txMetadata, logger);

if (!nftMetadata) return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const datumNftmetadata = {
describe('withNftMetadata', () => {
const assetId1 = Cardano.AssetId('7d878696b149b529807aa01b8e20785e0a0d470c32c13f53f08a55e344455630303032');
const assetId2 = Cardano.AssetId('7d878696b149b529807aa01b8e20785e0a0d470c32c13f53f08a55e344455638393230');
const assetId3 = Cardano.AssetId('7d878696b149b529807aa01b8e20785e0a0d470c32c13f53f08a55e344455638393233');
const otherProperties1 = new Map([
['Background', 'Ocean'],
['Body', 'Pale'],
Expand Down Expand Up @@ -97,6 +98,14 @@ describe('withNftMetadata', () => {
['name', 'DEV 0002']
])
],
[
Buffer.from(Cardano.AssetId.getAssetName(assetId3), 'hex').toString('utf8'),
new Map([
['image', 'ipfs://QmWmB37VZ9uc2cVe2fG31Xqjxw5VbUu4DMLkGt9LW6z7Up'],
['mediaType', 'image/jpeg'],
['name', 'Burned']
])
],
[
'DEV8920',
new Map([
Expand All @@ -121,7 +130,8 @@ describe('withNftMetadata', () => {
body: {
mint: new Map([
[assetId1, 1n],
[assetId2, 1n]
[assetId2, 1n],
[assetId3, -1n]
])
}
}
Expand Down

0 comments on commit ab8bb29

Please sign in to comment.