keepkey / keepkey.js

Superseded by https://github.com/shapeshift/hdwallet
MIT License
13 stars 9 forks source link

@keepkey/keepkey.js npm package crashes #37

Open marceloneil opened 5 years ago

marceloneil commented 5 years ago

I get this error while trying to import the keepkey.js package:

Uncaught TypeError: Cannot read property 'nested' of undefined

The issue seems to step from the compiled messageTypeRegistry.js file, as "proto.json" does not have a "default" key.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var proto_json_1 = require("./proto.json");
var messages_pb_1 = require("./kkProto/messages_pb");
var values = proto_json_1.default.nested.MessageType.values;
var messageTypeRegistry = Object.entries(values).reduce(function (registry, entry) {
    registry[entry[1]] = messages_pb_1.default[entry[0].split('_')[1]];
    return registry;
}, {});
exports.default = messageTypeRegistry;
//# sourceMappingURL=messageTypeRegistry.js.map
keepkeyjon commented 5 years ago

Does this help if you build from source?

diff --git a/src/messageTypeRegistry.ts b/src/messageTypeRegistry.ts
index e43d2a5..9f7ad2e 100644
--- a/src/messageTypeRegistry.ts
+++ b/src/messageTypeRegistry.ts
@@ -1,8 +1,7 @@
 import jspb from 'google-protobuf'
-import proto from './proto.json'
-import Messages from './kkProto/messages_pb'
-
-const { nested: { MessageType: { values } } } = proto
+import * as Messages from './kkProto/messages_pb'
+import * as proto from './proto.json'
+const { nested: { MessageType: { values } } } = proto as any

 const messageTypeRegistry: { [msgTypeEnum: number]: jspb.Message } = Object.entries(values).reduce((registry, entry: [string, number]) => {
   registry[entry[1]] = Messages[entry[0].split('_')[1]]