@@ -4237,62 +4237,6 @@ impl NakamotoChainState {
4237
4237
) ;
4238
4238
e
4239
4239
} ) ?;
4240
-
4241
- let mainnet = clarity_tx. config . mainnet ;
4242
-
4243
- if evaluated_epoch. includes_sip_031 ( ) {
4244
- println ! (
4245
- "\n \n NEW TENURE {} {} (parent: {}) {:?} {}\n \n " ,
4246
- coinbase_height,
4247
- burn_header_height,
4248
- parent_burn_height,
4249
- evaluated_epoch,
4250
- tx_receipts. len( )
4251
- ) ;
4252
-
4253
- let sip_031_mint_and_transfer_amount =
4254
- SIP031EmissionInterval :: get_sip_031_emission_at_height (
4255
- u64:: from ( burn_header_height) ,
4256
- mainnet,
4257
- ) ;
4258
-
4259
- if sip_031_mint_and_transfer_amount > 0 {
4260
- let boot_code_address = boot_code_addr ( mainnet) ;
4261
- let boot_code_auth = boot_code_tx_auth ( boot_code_address. clone ( ) ) ;
4262
-
4263
- let recipient = PrincipalData :: Contract ( boot_code_id ( SIP_031_NAME , mainnet) ) ;
4264
-
4265
- let mint_and_account_receipt =
4266
- clarity_tx. connection ( ) . as_transaction ( |tx_conn| {
4267
- tx_conn
4268
- . with_clarity_db ( |db| {
4269
- db. increment_ustx_liquid_supply (
4270
- sip_031_mint_and_transfer_amount,
4271
- )
4272
- . map_err ( |e| e. into ( ) )
4273
- } )
4274
- . expect ( "FATAL: `SIP-031 mint` overflowed" ) ;
4275
- StacksChainState :: account_credit (
4276
- tx_conn,
4277
- & recipient,
4278
- u64:: try_from ( sip_031_mint_and_transfer_amount)
4279
- . expect ( "FATAL: transferred more STX than exist" ) ,
4280
- ) ;
4281
- } ) ;
4282
-
4283
- let event = STXEventType :: STXMintEvent ( STXMintEventData {
4284
- recipient,
4285
- amount : sip_031_mint_and_transfer_amount,
4286
- } ) ;
4287
-
4288
- /*
4289
- .events
4290
- .push(StacksTransactionEvent::STXEvent(event));
4291
-
4292
- tx_receipts.push(sip_031_initialization_receipt);
4293
- */
4294
- }
4295
- }
4296
4240
}
4297
4241
4298
4242
let auto_unlock_events = if evaluated_epoch >= StacksEpochId :: Epoch21 {
@@ -4880,6 +4824,49 @@ impl NakamotoChainState {
4880
4824
}
4881
4825
}
4882
4826
4827
+ if new_tenure {
4828
+ if evaluated_epoch. includes_sip_031 ( ) {
4829
+ let mainnet = clarity_tx. config . mainnet ;
4830
+
4831
+ let sip_031_mint_and_transfer_amount =
4832
+ SIP031EmissionInterval :: get_sip_031_emission_at_height (
4833
+ chain_tip_burn_header_height. into ( ) ,
4834
+ mainnet,
4835
+ ) ;
4836
+
4837
+ if sip_031_mint_and_transfer_amount > 0 {
4838
+ let recipient = PrincipalData :: Contract ( boot_code_id ( SIP_031_NAME , mainnet) ) ;
4839
+
4840
+ clarity_tx. connection ( ) . as_transaction ( |tx_conn| {
4841
+ tx_conn
4842
+ . with_clarity_db ( |db| {
4843
+ db. increment_ustx_liquid_supply ( sip_031_mint_and_transfer_amount)
4844
+ . map_err ( |e| e. into ( ) )
4845
+ } )
4846
+ . expect ( "FATAL: `SIP-031 mint` overflowed" ) ;
4847
+ StacksChainState :: account_credit (
4848
+ tx_conn,
4849
+ & recipient,
4850
+ u64:: try_from ( sip_031_mint_and_transfer_amount)
4851
+ . expect ( "FATAL: transferred more STX than exist" ) ,
4852
+ ) ;
4853
+ } ) ;
4854
+
4855
+ if let Some ( receipt) = tx_receipts. get_mut ( 0 ) {
4856
+ if receipt. is_coinbase_tx ( ) {
4857
+ let event = STXEventType :: STXMintEvent ( STXMintEventData {
4858
+ recipient,
4859
+ amount : sip_031_mint_and_transfer_amount,
4860
+ } ) ;
4861
+ receipt. events . push ( StacksTransactionEvent :: STXEvent ( event) ) ;
4862
+ }
4863
+ } else {
4864
+ warn ! ( "Unable to attach SIP-031 mint events, block's first transaction is not a coinbase transaction" )
4865
+ }
4866
+ }
4867
+ }
4868
+ }
4869
+
4883
4870
// verify that the resulting chainstate matches the block's state root
4884
4871
let root_hash = clarity_tx. seal ( ) ;
4885
4872
if root_hash != block. header . state_index_root {
0 commit comments