@@ -541,6 +541,7 @@ impl StellarEscrowContract {
541541 save_trade ( & env, trade_id, & trade) ;
542542 events:: emit_trade_created ( & env, trade_id, seller. clone ( ) , buyer. clone ( ) , amount) ;
543543 events:: emit_compliance_passed ( & env, trade_id, seller, buyer, amount) ;
544+ analytics:: on_trade_created ( & env, amount, & trade. seller , & trade. buyer ) ;
544545 Ok ( trade_id)
545546 }
546547
@@ -827,8 +828,19 @@ impl StellarEscrowContract {
827828 }
828829 save_arbitrator_reputation ( & env, arbitrator, & rep) ;
829830 events:: emit_arb_rep_updated ( & env, arbitrator. clone ( ) , rep. resolved_count , rep. rating_sum , rep. rating_count ) ;
831+ let resolution_code: u8 = match resolution {
832+ DisputeResolution :: ReleaseToBuyer => 0 ,
833+ DisputeResolution :: ReleaseToSeller => 1 ,
834+ DisputeResolution :: Partial { .. } => 2 ,
835+ } ;
836+ analytics:: on_dispute_resolved ( & env, arbitrator, resolution_code) ;
830837 }
831838 Some ( ArbitrationConfig :: MultiSig ( config) ) => {
839+ let resolution_code: u8 = match resolution {
840+ DisputeResolution :: ReleaseToBuyer => 0 ,
841+ DisputeResolution :: ReleaseToSeller => 1 ,
842+ DisputeResolution :: Partial { .. } => 2 ,
843+ } ;
832844 for i in 0 ..config. arbitrators . len ( ) {
833845 let arb = config. arbitrators . get ( i) . unwrap ( ) ;
834846 let mut rep = storage:: get_arbitrator_reputation ( & env, arb) ;
@@ -840,28 +852,17 @@ impl StellarEscrowContract {
840852 }
841853 save_arbitrator_reputation ( & env, arb, & rep) ;
842854 events:: emit_arb_rep_updated ( & env, arb. clone ( ) , rep. resolved_count , rep. rating_sum , rep. rating_count ) ;
855+ analytics:: on_dispute_resolved ( & env, & arb, resolution_code) ;
843856 }
844857 // Clear votes after resolution
845858 storage:: clear_votes_for_trade ( & env, trade_id, & config. arbitrators ) ;
846859 }
847860 None => { }
848861 }
849- save_arbitrator_reputation ( & env, & arbitrator, & rep) ;
850- events:: emit_arb_rep_updated ( & env, arbitrator. clone ( ) , rep. resolved_count , rep. rating_sum , rep. rating_count ) ;
851- set_currency_fees ( & env, & trade. currency , new_fees) ;
852- let token = get_usdc_token ( & env) ?;
853- let token_client = TokenClient :: new ( & env, & token) ;
854- token_client. transfer ( & env. current_contract_address ( ) , & recipient, & ( payout as i128 ) ) ;
855- // Single read-modify-write for fees
856- add_accumulated_fees ( & env, trade. fee ) ?;
857- let resolution_code: u8 = match resolution {
858- DisputeResolution :: ReleaseToBuyer => 0 ,
859- DisputeResolution :: ReleaseToSeller => 1 ,
860- DisputeResolution :: Partial { .. } => 2 ,
861- } ;
862- analytics:: on_dispute_resolved ( & env, & arbitrator, resolution_code) ;
863- events:: emit_dispute_resolved ( & env, trade_id, resolution, recipient) ;
864- Ok ( ( ) ) for the arbitrator of a resolved dispute.
862+ Ok ( ( ) )
863+ }
864+
865+ /// Rate the arbitrator of a resolved dispute.
865866 /// Only the buyer or seller of the trade may rate, once each.
866867 pub fn rate_arbitrator ( env : Env , trade_id : u64 , rater : Address , stars : u32 ) -> Result < ( ) , ContractError > {
867868 if !is_initialized ( & env) {
0 commit comments