Skip to content

Commit

Permalink
fix node modules version for electron (cryptocoinjs#148)
Browse files Browse the repository at this point in the history
Electron uses NODE_MODULE_VERSION between 67 and 72. Previous used condition
NODE_MODULE_VERSION > NODE_11_0_MODULE_VERSION
broke building for Electron.
  • Loading branch information
fanatid authored May 31, 2019
1 parent bce4af7 commit 213e711
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"create-hash": "^1.2.0",
"drbg.js": "^1.0.1",
"elliptic": "^6.4.1",
"nan": "^2.13.2",
"nan": "^2.14.0",
"safe-buffer": "^5.1.2"
},
"devDependencies": {
Expand Down
8 changes: 4 additions & 4 deletions src/ecdsa.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ int nonce_function_custom(unsigned char *nonce32, const unsigned char *msg32, co
};

v8::Isolate *isolate = v8::Isolate::GetCurrent();
#if (NODE_MODULE_VERSION > NODE_11_0_MODULE_VERSION)
#if (NODE_MODULE_VERSION >= NODE_12_0_MODULE_VERSION)
v8::Local<v8::Value> result = noncefn_callback->Call(isolate->GetCurrentContext(), isolate->GetCurrentContext()->Global(), 5, argv).ToLocalChecked();
#else
v8::Local<v8::Value> result = noncefn_callback->Call(isolate->GetCurrentContext()->Global(), 5, argv);
Expand Down Expand Up @@ -52,7 +52,7 @@ NAN_METHOD(sign) {
if (!options->IsUndefined()) {
CHECK_TYPE_OBJECT(options, OPTIONS_TYPE_INVALID);

#if (NODE_MODULE_VERSION > NODE_11_0_MODULE_VERSION)
#if (NODE_MODULE_VERSION >= NODE_12_0_MODULE_VERSION)
v8::Local<v8::Value> data_value = options->Get(info.GetIsolate()->GetCurrentContext(), Nan::New<v8::String>("data").ToLocalChecked()).ToLocalChecked();
#else
v8::Local<v8::Value> data_value = options->Get(Nan::New<v8::String>("data").ToLocalChecked());
Expand All @@ -63,7 +63,7 @@ NAN_METHOD(sign) {
data = (void*) node::Buffer::Data(data_value);
}

#if (NODE_MODULE_VERSION > NODE_11_0_MODULE_VERSION)
#if (NODE_MODULE_VERSION >= NODE_12_0_MODULE_VERSION)
noncefn_callback = v8::Local<v8::Function>::Cast(options->Get(info.GetIsolate()->GetCurrentContext(), Nan::New<v8::String>("noncefn").ToLocalChecked()).ToLocalChecked());
#else
noncefn_callback = v8::Local<v8::Function>::Cast(options->Get(Nan::New<v8::String>("noncefn").ToLocalChecked()));
Expand All @@ -84,7 +84,7 @@ NAN_METHOD(sign) {
secp256k1_ecdsa_recoverable_signature_serialize_compact(secp256k1ctx, &output[0], &recid, &sig);

v8::Local<v8::Object> obj = Nan::New<v8::Object>();
#if (NODE_MODULE_VERSION > NODE_11_0_MODULE_VERSION)
#if (NODE_MODULE_VERSION >= NODE_12_0_MODULE_VERSION)
obj->Set(info.GetIsolate()->GetCurrentContext(), Nan::New<v8::String>("signature").ToLocalChecked(), COPY_BUFFER(&output[0], 64));
obj->Set(info.GetIsolate()->GetCurrentContext(), Nan::New<v8::String>("recovery").ToLocalChecked(), Nan::New<v8::Number>(recid));
#else
Expand Down
2 changes: 1 addition & 1 deletion src/publickey.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ NAN_METHOD(publicKeyCombine) {
std::unique_ptr<secp256k1_pubkey[]> public_keys(new secp256k1_pubkey[input_buffers->Length()]);
std::unique_ptr<secp256k1_pubkey*[]> ins(new secp256k1_pubkey*[input_buffers->Length()]);
for (unsigned int i = 0; i < input_buffers->Length(); ++i) {
#if (NODE_MODULE_VERSION > NODE_11_0_MODULE_VERSION)
#if (NODE_MODULE_VERSION >= NODE_12_0_MODULE_VERSION)
v8::Local<v8::Object> public_key_buffer = v8::Local<v8::Object>::Cast(input_buffers->Get(info.GetIsolate()->GetCurrentContext(), i).ToLocalChecked());
#else
v8::Local<v8::Object> public_key_buffer = v8::Local<v8::Object>::Cast(input_buffers->Get(i));
Expand Down
2 changes: 1 addition & 1 deletion src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#define COPY_BUFFER(data, datalen) Nan::CopyBuffer((const char*) data, (uint32_t) datalen).ToLocalChecked()

#if (NODE_MODULE_VERSION > NODE_11_0_MODULE_VERSION)
#if (NODE_MODULE_VERSION >= NODE_12_0_MODULE_VERSION)
#define UPDATE_COMPRESSED_VALUE(compressed, value, v_true, v_false) { \
if (!value->IsUndefined()) { \
CHECK_TYPE_BOOLEAN(value, COMPRESSED_TYPE_INVALID); \
Expand Down

0 comments on commit 213e711

Please sign in to comment.