@@ -62,6 +62,7 @@ export enum ConditionArgType {
6262}
6363
6464interface BundleContext {
65+ selfContained : boolean ;
6566 announcementCoinIds : Record < string , Uint8Array > ;
6667 announcementPuzzleHashes : Record < string , Uint8Array > ;
6768 announcementMessages : Record < string , Uint8Array > ;
@@ -80,11 +81,15 @@ interface DeserializedCoinSpend {
8081 conditions : Program [ ] ;
8182}
8283
83- export function parseSpendBundle ( spendBundle : SpendBundle ) : ParsedSpendBundle {
84+ export function parseSpendBundle (
85+ spendBundle : SpendBundle ,
86+ selfContained : boolean ,
87+ ) : ParsedSpendBundle {
8488 const clvm = new Clvm ( ) ;
8589
8690 const deserializedCoinSpends : DeserializedCoinSpend [ ] = [ ] ;
8791 const announcements : BundleContext = {
92+ selfContained,
8893 announcementCoinIds : { } ,
8994 announcementPuzzleHashes : { } ,
9095 announcementMessages : { } ,
@@ -321,7 +326,10 @@ function parseCondition(
321326 type : ConditionArgType . Copiable ,
322327 } ;
323328
324- if ( ! ctx . coinAnnouncementAssertions . has ( announcementId ) ) {
329+ if (
330+ ! ctx . coinAnnouncementAssertions . has ( announcementId ) &&
331+ ctx . selfContained
332+ ) {
325333 warning = 'Not asserted' ;
326334 }
327335 }
@@ -345,7 +353,7 @@ function parseCondition(
345353 value : `0x${ toHex ( ctx . announcementCoinIds [ announcementId ] ) } ` ,
346354 type : ConditionArgType . CoinId ,
347355 } ;
348- } else {
356+ } else if ( ctx . selfContained ) {
349357 warning = 'Announcement does not exist' ;
350358 }
351359
@@ -384,7 +392,10 @@ function parseCondition(
384392 type : ConditionArgType . Copiable ,
385393 } ;
386394
387- if ( ! ctx . puzzleAnnouncementAssertions . has ( announcementId ) ) {
395+ if (
396+ ! ctx . puzzleAnnouncementAssertions . has ( announcementId ) &&
397+ ctx . selfContained
398+ ) {
388399 warning = 'Not asserted' ;
389400 }
390401 }
@@ -408,7 +419,7 @@ function parseCondition(
408419 value : `0x${ toHex ( ctx . announcementPuzzleHashes [ announcementId ] ) } ` ,
409420 type : ConditionArgType . Copiable ,
410421 } ;
411- } else {
422+ } else if ( ctx . selfContained ) {
412423 warning = 'Announcement does not exist' ;
413424 }
414425
@@ -428,7 +439,10 @@ function parseCondition(
428439 type : ConditionArgType . CoinId ,
429440 } ;
430441
431- if ( ! ctx . spentCoinIds . has ( toHex ( assertConcurrentSpend . coinId ) ) ) {
442+ if (
443+ ! ctx . spentCoinIds . has ( toHex ( assertConcurrentSpend . coinId ) ) &&
444+ ctx . selfContained
445+ ) {
432446 warning = 'Coin not spent' ;
433447 }
434448 }
@@ -443,7 +457,10 @@ function parseCondition(
443457 type : ConditionArgType . Copiable ,
444458 } ;
445459
446- if ( ! ctx . spentPuzzleHashes . has ( toHex ( assertConcurrentPuzzle . puzzleHash ) ) ) {
460+ if (
461+ ! ctx . spentPuzzleHashes . has ( toHex ( assertConcurrentPuzzle . puzzleHash ) ) &&
462+ ctx . selfContained
463+ ) {
447464 warning = 'Puzzle not spent' ;
448465 }
449466 }
@@ -576,7 +593,7 @@ function parseCondition(
576593 type = ConditionType . Assertion ;
577594 name = 'ASSERT_EPHEMERAL' ;
578595
579- if ( ! ctx . createdCoinIds . has ( toHex ( coin . coinId ( ) ) ) ) {
596+ if ( ! ctx . createdCoinIds . has ( toHex ( coin . coinId ( ) ) ) && ctx . selfContained ) {
580597 warning = 'Coin not created ephemerally in this bundle' ;
581598 }
582599 }
0 commit comments