Git Product home page Git Product logo

Comments (6)

christroutner avatar christroutner commented on August 31, 2024

@ekkis can you expand on how the bug manifests itself in SLP-SDK? What is the problem that it causes, exactly?

from slp-sdk.

ekkis avatar ekkis commented on August 31, 2024

the lodash owner has agreed to apply a patch, so this should be ok. will post more when done

from slp-sdk.

ekkis avatar ekkis commented on August 31, 2024

after a long and painful path, I couldn't figure out how to fix that pile of doodoo so I need to revert back to you guys. here's an example of how this breaks:

const jsp = require('js-prototype-lib');
jsp.install()

const SLP = require('slp-sdk');
var slp = new SLP({restURL: 'https://rest.bitcoin.com/v2/'});
var ret = slp.Mnemonic.toSeed('').toString('hex').substr(0, 16);
console.log(ret);

if you run the above (using the latest 3.3.0 version of SLP), you'll get something like:

/Users/ekkis/dev/now/node_modules/lodash/lodash.js:17045
names.push({ 'name': methodName, 'func': lodashFunc });
^

TypeError: names.push is not a function
at /Users/ekkis/dev/now/node_modules/lodash/lodash.js:17045:15
at /Users/ekkis/dev/now/node_modules/lodash/lodash.js:4911:15
at baseForOwn (/Users/ekkis/dev/now/node_modules/lodash/lodash.js:2996:24)
at runInContext (/Users/ekkis/dev/now/node_modules/lodash/lodash.js:17039:5)
at Object. (/Users/ekkis/dev/now/node_modules/lodash/lodash.js:17080:11)
at Object. (/Users/ekkis/dev/now/node_modules/lodash/lodash.js:17107:3)
at Module._compile (internal/modules/cjs/loader.js:721:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:560:12)

which can be solved by applying the following patch:

~/dev/now $ cat patches/lodash+4.17.11.patch 
diff --git a/node_modules/lodash/lodash.js b/node_modules/lodash/lodash.js
index cb139dd..9730f52 100644
--- a/node_modules/lodash/lodash.js
+++ b/node_modules/lodash/lodash.js
@@ -17039,8 +17039,11 @@
     baseForOwn(LazyWrapper.prototype, function(func, methodName) {
       var lodashFunc = lodash[methodName];
       if (lodashFunc) {
-        var key = (lodashFunc.name + ''),
-            names = realNames[key] || (realNames[key] = []);
+        var key = (lodashFunc.name + ''), names;
+		if (realNames.hasOwnProperty(key))
+			names = realNames[key];
+		else
+            names = realNames[key] = [];
 
         names.push({ 'name': methodName, 'func': lodashFunc });
       }

please help?

from slp-sdk.

christroutner avatar christroutner commented on August 31, 2024

I tried recreating the bug. Thank you for the concise code example.

This is the code I tried first and everything ran perfectly:

// Used for debugging and iterrogating JS objects.
const util = require("util");
util.inspect.defaultOptions = {depth: 1};

const SLP = require('slp-sdk')
var slp = new SLP()

let val

// Creates a Buffer
val = slp.Mnemonic.toSeed('')

// Converts the Buffer to a string
val = val.toString('hex')

console.log(`val: ${util.inspect(val)}`)
// val: '4ed8d4b17698ddeaa1f1559f152f87b5d472f725ca86d341bd0276f1b61197e21dd5a391f9f5ed7340ff4d4513aab9cce44f9497a5e7ed85fd818876b6eb402e'

let ret = val.substr(0,16)

console.log(`ret: ${util.inspect(ret)}`)
// ret: '4ed8d4b17698ddea'

It was only when I added this code at the top, that the bug you're reporting manifested itself:

const jsp = require('js-prototype-lib');
jsp.install()

I checked out the npm entry for js-prototype-lib and it says right at the top:

The argument could be made that its use is unadvisable within browsers as your mileage may vary due to the instability of these implementations...

I've never used the js-prototype-lib and I haven't heard of any reports of any other users using this library or having an issue with lodash.

The obvious solution to me, seems to be avoiding the use of this library.

from slp-sdk.

christroutner avatar christroutner commented on August 31, 2024

I ran npm list lodash. Lodash is not a direct dependency of slp-sdk. It's a dependency of a dependency. There isn't anything we can do within the slp-sdk repo to fix this issue.

from slp-sdk.

ekkis avatar ekkis commented on August 31, 2024

I've submitted a patch to lodash that fixes this problem and it has been accepted: lodash/lodash#4290

I've also requested of the Babel team to upgrade to the fixed version of lodash: babel/babel#9966

when that team upgrades I'll need you guys to upgrade

from slp-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.