@@ -106,28 +106,34 @@ export function handleOrdersMatched(event: OrdersMatchedEvent): void {
106106 deal . timestamp = event . block . timestamp ;
107107 deal . save ( ) ;
108108
109- // params including bulk_cid reference a dataset bulk
110- const params = json . try_fromString ( viewedDeal . params ) ;
111- if ( params . isOk ) {
112- const bulkCid = params . value . toObject ( ) . getEntry ( 'bulk_cid' ) ;
113- if ( bulkCid ) {
114- // the same bulk is used by any deal using the same requestorder => we use requestorderHash as bulk ID
115- const bulkId = event . params . dealid . toHex ( ) ;
116- // create the bulk if not existing yet
117- const indexedBulk = Bulk . load ( bulkId ) ;
118- if ( ! indexedBulk ) {
119- let context = new DataSourceContext ( ) ;
120- // Pass onchain data that will be needed in file handlers
121- const domainSeparator = contract . eip712domain_separator ( ) ;
122- context . setString ( CONTEXT_DEAL , deal . id ) ;
123- context . setBigInt ( CONTEXT_BOT_FIRST , deal . botFirst ) ;
124- context . setBigInt ( CONTEXT_BOT_SIZE , deal . botSize ) ;
125- context . setBytes ( CONTEXT_DOMAIN_SEPARATOR_HASH , domainSeparator ) ;
126- DataSourceTemplate . createWithContext ( 'Bulk' , [ bulkCid . value . toString ( ) ] , context ) ;
109+ // if no dataset, check if params include a bulk_cid reference
110+ if ( deal . dataset == Address . zero ( ) . toHex ( ) ) {
111+ const params = json . try_fromString ( viewedDeal . params ) ;
112+ if ( params . isOk ) {
113+ const bulkCid = params . value . toObject ( ) . getEntry ( 'bulk_cid' ) ;
114+ if ( bulkCid ) {
115+ // the same bulk is used by any deal using the same requestorder => we use requestorderHash as bulk ID
116+ const bulkId = event . params . dealid . toHex ( ) ;
117+ // create the bulk if not existing yet
118+ const indexedBulk = Bulk . load ( bulkId ) ;
119+ if ( ! indexedBulk ) {
120+ let context = new DataSourceContext ( ) ;
121+ // Pass onchain data that will be needed in file handlers
122+ const domainSeparator = contract . eip712domain_separator ( ) ;
123+ context . setString ( CONTEXT_DEAL , deal . id ) ;
124+ context . setBigInt ( CONTEXT_BOT_FIRST , deal . botFirst ) ;
125+ context . setBigInt ( CONTEXT_BOT_SIZE , deal . botSize ) ;
126+ context . setBytes ( CONTEXT_DOMAIN_SEPARATOR_HASH , domainSeparator ) ;
127+ DataSourceTemplate . createWithContext (
128+ 'Bulk' ,
129+ [ bulkCid . value . toString ( ) ] ,
130+ context ,
131+ ) ;
132+ }
133+ // bulk may not be indexed, this is not an issue, the model will prune it
134+ deal . bulk = bulkId ;
135+ deal . save ( ) ;
127136 }
128- // bulk may not be indexed, this is not an issue, the model will prune it
129- deal . bulk = bulkId ;
130- deal . save ( ) ;
131137 }
132138 }
133139
0 commit comments