-
Notifications
You must be signed in to change notification settings - Fork 37
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
RFC: monorepo jellyfish development #29
Conversation
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the overall structure on the planning.
* @param url | ||
*/ | ||
jsonrpc(url: string): JellyfishJsonRpc { | ||
return new JellyfishJsonRpc(url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would call it new Jellyfish()
if it makes sense so it's clean when it's used externally.
new Jellyfish(url, {
useNodeWallet: false, // default to false
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely will pay more attention to this, I rewrote that part a few times.
Thanks for taking part in this RFC, the implementation style will be locked and slowly patched into main. Things under consideration are:
|
This is an early 1st milestone RFC to tackle DeFiChain JS Library Protocol Implementation/Interfacing technical design. There will be 4 milestones in total (protocols, wallet, remote & documentation) and this being the biggest unit of work due to the mono repo and utility and toolchain setup.
The purpose of this RFC is to provide a feedback loop before new features or significant change/implementation get introduced to the DeFiChain ecosystem. Extra attention is required for this as this repo is meant to be used by the masses. As this is an RFC, NOT A CODE REVIEW, some codes are missing and this is not to be merged.
For the reviewer, the question is 'does this make sense for the JS ecosystem' & 'is this easy to use'?
Jellyfish Monorepo
@defichain/testcontainers
Similar to testcontainers in the Java ecosystem, this library provide a lightweight, throwaway instances of
regtest
,testnet
ormainnet
provisioned automatically in Docker container.@defichain/testcontainers
encapsulate on top ofdefi/defichain:latest
and directly interface with the Docker REST API. see #20With
@defichain/testcontainers
, it allows the JS ecosystem to:jellyfish-core
development with integration test guaranteesUsage Example
@defichain/jellyfish-core
@defichain/jellyfish-core
the protocol agnostic DeFiChain client implementation with APIs separated into their category.Implementation Details
*.d.ts
file will be exported for developer QOLclient.'category'.'method'()
exampleclient.mining.getMintingInfo()
rpc/mining.cpp#getmintinginfo
client.transaction.sendRawTransaction(tx)
rpc/sendrawtransaction.cpp#sendrawtransaction
The client:
https://github.com/DeFiCh/jellyfish/blob/36d11134b74e9285ae36229fdaa3f33876bf3cee/packages/jellyfish-core/src/core.ts#L8-L12
The protocol interfacing, with strongly typed interfaces:
https://github.com/DeFiCh/jellyfish/blob/36d11134b74e9285ae36229fdaa3f33876bf3cee/packages/jellyfish-core/src/methods/mining.ts#L3-L23
This allow library consumer to use it as follow:
@defichain/jellyfish-jsonrpc
Nothing really special about this package, it just imlements
@defichain/jellyfish-core
in the JSON-RPC 1.0 specification. 2 dependencies with 4 deeply are selected,jsonbig
as JS number is implemented with IEEE-754, defi must not use floating point arithmetic for obvious reason (need to write TDD to guarantee this behavior) see #18.cross-fetch
a isomorphicfetch
client that is RN, Node.JS and browser compatible. See #17https://github.com/DeFiCh/jellyfish/blob/36d11134b74e9285ae36229fdaa3f33876bf3cee/packages/jellyfish-jsonrpc/src/jsonrpc.ts#L1-L3
https://github.com/DeFiCh/jellyfish/blob/36d11134b74e9285ae36229fdaa3f33876bf3cee/packages/jellyfish-jsonrpc/src/jsonrpc.ts#L21-L29
@defichain/jellyfish
This is the entrypoint for most dApp developer. Distributed as
@defichain/jellyfish
, it is a bundler that creates 4 types of JavaScript packages for public use. This package provides conventional defaults and bundle all code required for dApps building. For library consumer, it is plug and play, they don't need to care how it works underneath.1.
dist/jellyfish.cjs.js
for node.jsCommon JS for Node.JS users, plug and play no transpiler required.
2.
dist/jellyfish.umd.js
for browserFor the global CDN users, this allows developer to just declare jellyfish.js script and use it on any webpage.
All library code that are required for jellyfish to work on their browser are automatically bundled into the fat javascript file. (20 KB+) This included
bignumber
,JSONBig
,jellyfish-jsonrpc
and in the future all other jellyfish tools e.g.jellyfish-wallet
. The bundler is set to polyfill on >0.25% of all browser and target node 12 and above implementation.3.
dist/jellyfish.esm.js
for ES moduleFor webpack, parcel, and variety of users that want to use their own bundler (tree shaking), ES modules packages are also provided.
4.
dist/jellyfish.d.ts
for TS typesTypeScript's types are also exported for convenience’s sake, removes the need for
@types/jellyfish
.Next?
If all is approved this implementation style will be internally frozen and slowly patched into main.