//
//  JSIUtils.cpp
//  jsi-rn-wallet-core
//
//  Created by Oscar on 24.03.22.
//

#include "JSIUtils.hpp"
#include <vector>
#include "logs.h"
#include <iostream>
#ifdef ANDROID
#else
#include <Security/Security.h>
#include <CoreFoundation/CFBundle.h>
#endif // ANDROID

using namespace std;
using namespace facebook;

const string TAG = "[jsi-rn-wallet-core]";

jsi::Value walletUtf8BytesToString(jsi::Runtime &rt, TWString *bytes)
{
  string bytesString = TWStringUTF8Bytes(bytes);
  return jsi::String::createFromUtf8(rt, bytesString);
}

/// Throws a JS Error with a tag for users to understand where is it coming from
void throwJSError(jsi::Runtime &rt, string method, string msg)
{
  string finalMsg = TAG + "/" + method + ": " + msg;
  throwJSError(rt, finalMsg.c_str());
}

void throwJSError(jsi::Runtime &rt, string msg)
{
  string finalMsg = TAG + ": " + msg;
  facebook::jsi::JSError(rt, finalMsg.c_str());
}

