//
//  IndusBitTest.m
//  IndusBitTest
//
//  Created by IndusBit Team
//  Copyright © 2023 IndusBit. All rights reserved.
//

#import "IndusBitTest.h"

@implementation IndusBitTest

RCT_EXPORT_MODULE()

+ (BOOL)requiresMainQueueSetup {
    return NO;
}

RCT_EXPORT_METHOD(multiply:(nonnull NSNumber *)a
                  b:(nonnull NSNumber *)b
                  resolver:(RCTPromiseResolveBlock)resolve
                  rejecter:(RCTPromiseRejectBlock)reject)
{
    @try {
        double result = [a doubleValue] * [b doubleValue];
        NSNumber *resultNum = @(result);
        resolve(resultNum);
    } 
    @catch (NSException *exception) {
        NSError *error = [NSError errorWithDomain:@"IndusBitTest" 
                                            code:500 
                                        userInfo:@{
                                            @"message": exception.reason ?: @"Unknown error"
                                        }];
        reject(@"CALCULATION_ERROR", 
               @"Error performing multiplication", 
               error);
    }
}

@end 