-
Notifications
You must be signed in to change notification settings - Fork 320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Buffer is not defined #475
Comments
@letchepare can you post this to https://stellar.stackexchange.com/? I think this is a problem with your built system, it should transpile Buffer to the Browser version. |
Hi Letchepare, I'm having a similar issue while building a stellar wallet. Have you found how to fix it ? thanks in advance |
Hi OsgoodSchlatter, Sorry about your pain. I had some with the Buffer reference too. It's defined in some environments/tools, like node and browserify, but not in others, like the webpack5-ed browser code I'm working on with stellar-base. My quick and dirty fix is to define window.Buffer = require('buffer/').Buffer in my application's entry point. A webpack plugin attempt could be in order, but that could be way to elegant for me. I might take another route to getting rid of the Buffer reference. I just ran into this yesterday so too early to say. I hope this helps. BE |
Can you please explain more @brianebert ? |
I hope this is soon enough, and please don't take my comments as expertise. If I remember correctly, a Stellar javascript library (stellar sdk or stellar base) calls or called on a global Buffer reference, which is available in node but not in the browser. I'm still resolving this by detecting the environment, and then executing: window.Buffer = require('buffer/').Buffer for code running in a browser. My code has the comment "// This is so Stellar stuff works in the browser" The buffer module is available at https://www.npmjs.com/package/buffer |
A follow-up on this. Webpack 4 used to include polyfills, so if you set webpack to version 4, it will work just fine. module.exports = {
resolve: {
fallback: {
buffer: require.resolve('buffer')
},
},
}; To your |
We are working to get modernizing the SDK as a priority (see #792) so that webpack5 can be used easily! |
Describe the bug
Error when trying to use StellarSdk.KeyPair.fromSecret() using angular
What version are you on?
Check
yarn.lock
orpackage-lock.json
to find out precisely what version of the SDK you're running.Using angular 8.2.14
and
"stellar-sdk": "^3.3.0"
To Reproduce
Steps to reproduce the behavior:
import * as StellarSdk from 'stellar-sdk';
this.keyPair = StellarSdk.Keypair.fromSecret(this.secretKey);
Where this.secreKey is a "SBTxxxxx" address
Expected behavior
I was expecting to have a KeyPair object
the OS i'm using is kunbuntu, idk if this is relevant
Thanks in advance for looking up into this bug or explaining to me how I could solve it, didn't find after an hour on internet :/
The text was updated successfully, but these errors were encountered: