spectrum-finance / ergo-sdk-js Goto Github PK
View Code? Open in Web Editor NEWErgo JS SDK
License: Creative Commons Zero v1.0 Universal
Ergo JS SDK
License: Creative Commons Zero v1.0 Universal
If we try to use this package as an ESM module in Node (without any build tool), we get errors like this:
SyntaxError: Named export 'Explorer' not found. The requested module '@ergolabs/ergo-sdk' is a CommonJS module, which may not support all module.exports as named exports.
This happens because the type
or exports
field is missing in package.json
. Currently used module
field in package.json
is neither supported, nor the support is planned in Node. It was a proposal which was introduced by some bundlers like esbuild
, but Node introduced a more powerful exports
field.
Note that if this package is meant to be used only as an ESM module, adding a "type": "module"
will suffice.
It seems that Registers
type is not narrow enough:
ergo-sdk-js/src/entities/registers.ts
Line 31 in dbdd341
The user may provide any string value as key, which is not correct.
It can be fixed easily with a mapped type:
- export type Registers = {[key: string]: HexString}
+ export type Registers = {[Key in RegisterId]: HexString}
It seems that Registers
type is not narrow enough:
ergo-sdk-js/src/entities/registers.ts
Line 31 in dbdd341
The user may provide any string value as key, which is not correct.
It can be fixed easily with a mapped type:
- export type Registers = {[key: string]: HexString}
+ export type Registers = {[Key in RegisterId]: HexString}
I initially gave his a try by throwing together a quick create-react-app and adding the ergo-sdk-js dependency, without realising there is a workaround required for using web assembly with create-react-app.
It took me a while to work out why, I found the answer by looking at the readme of the ergo-lib-wasm-browser readme.
It would be good to add the same comment about the required workaround to this repositories readme. What do you think?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.