filecoin-shipyard / js-lotus-client Goto Github PK
View Code? Open in Web Editor NEWLotus JS Client
Home Page: https://filecoin-shipyard.github.io/js-lotus-client/
License: Other
Lotus JS Client
Home Page: https://filecoin-shipyard.github.io/js-lotus-client/
License: Other
Reverse-proxies are handy due to browser single-origin policies and for exposing endpoints through firewalls.
I have some configurations to share for nginx and Caddy server that might be useful.
CORS headers are useful for the HTTP endpoint so the API endpoint can be on a separate origin from the app's website. (I think they are not required for Websockets).
The link to the official tutorial is resolving as follows:
ipfs resolve -r /ipfs/bafybeifhcj3uvtajrn23zzcdb7vh3dnd6grszu2x4owq5as7j33iigix6q/build/examples/network-inspector/overview/: no link named "examples" under QmbYziR7JMhitn9LcYyQosYZq8VeAjmkdQYuXAvWpFonPB
I updated the schema following the instructions in the repo which resulted in a new param becoming available labeled 'DataSelector' . I attempted to use the param to perform a partial retrieval and I was unable to successfully perform the partial retrieval. The Lotus Client instead performed a full retrieval. Execution via CLI works fine. Any assistance would be appreciated.
{ "jsonrpc": "2.0", "id": 1, "method": "Filecoin.ClientRetrieve", "params": [ { "Root": { "/": "QmdmQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7RgQm" }, "Piece": null, "DataSelector": "Links/0/Hash/Links/0/Hash/5", "Size": 133169152, "Total": "0", "UnsealPrice": "0", "PaymentInterval": 1048576, "PaymentIntervalIncrease": 1048576, "Client": "f1yhlxpl7lg3krlbwqcgtvkyecus5arqpobujfkoy", "Miner": "f08530", "MinerPeer": { "Address": "f010088", "ID": "12D3KooWRDb9V7e5WsHHSZHUtVcR9XgY3BBJSDDYr9YBncXfCjgY", "PieceCID": null } }, null ] }
If I used clientStartDeal, and this deal keep 'StorageDealTransferring' state for a long time. How can I stop it?:slightly_smiling_face:
This happened on the second attempt to store a deal on the miner. A previous attempt succeeded.
2020-04-10T17:28:08.013Z INFO provideradapter storageadapter/provider.go:57 publishing deal
2020-04-10T17:28:08.013Z INFO provideradapter storageadapter/provider.go:93 Jim message&{t05 t3sxk3wbrtf2mvyi3cw6fkqarv2mmkqdnmfd5pqemou2jthuxopljyjzj67ziitotfvrir3foxk527htz2obha 0 0 0 1000000 5 [129 129 130 137 216 42 88 38 0 1 85 193 31 32 134 69 240 28 118 44 76 135 234 37 138 150 11 157 155 1 206 231 235 181 112 146 199 147 43 60 23 177 0 214 20 28 25 2 0 88 49 3 138 34 215 158 101 247 38 87 173 97 18 167 166 49 63 50 104 66 16 43 54 65 28 219 20 233 103 132 222 103 40 96 193 31 64 115 112 28 16 110 113 59 37 21 134 21 114 115 67 0 235 7 25 39 225 25 40 69 67 0 1 244 67 0 1 252 64 88 97 2 134 72 29 43 13 45 148 167 74 196 14 80 134 206 229 51 98 98 71 210 209 87 179 247 83 195 84 116 41 113 58 13 239 129 44 139 15 76 90 82 247 242 102 172 178 85 67 38 0 163 212 199 100 26 175 109 20 250 32 31 128 24 227 175 89 168 111 172 135 107 140 59 122 190 28 248 201 205 185 186 5 249 55 102 109 5 231 190 50 203 202 122 24 18 153 125]}
2020-04-10T17:28:08.020Z INFO provideradapter storageadapter/provider.go:98 Jim message cidbafy2bzaceaper4vvd37e6pltmdfhr6ejnu2bb3m4mdlb7ipwdnsho2sb62ya4
2020-04-10T17:28:20.059Z WARN providerstates providerstates/provider_states.go:294 deal bafyreicchptmul6ydocvjgknege2elglojcx25zx3xvxo5nabwhdzcalzu failed: error calling node: publishing deal: publishing deal failed: exit 1
Lotus version:
0.3.0+gite4b5f1df.dirty+api0.2.0
lotus version 0.3.0+gite4b5f1df.dirty
(April 7th, running in Testground with 2048 byte sectors)
Purpose: demystify the API
Potential topics / sections:
The examples in the docs could have an option to select a provider. We could provide the following providers:
Hello, team!
Wondering if js-lotus-client is currently supporting the use case of claim your node? Like claim your node on blockchain explorer where user signs a message using lotus wallet sign fxxxxx xxxxxxxx
and some how the js library could verify (lotus wallet verify fxxxxx xxxxxxxxxx
) the result without connecting to an actual RPC endpoint? Is this doable?
Ideas:
Put the sector states into the JSON:
The go source lives here:
Use more ZenHub features to tame the backlog, organize into epics, set milestones, etc.
We want to build the library with vanilla javascript so it runs in web browsers without a compile step, but many applications will want to use TypeScript for stronger types. We can add a declaration file:
https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html
The @filecoin-shipyard/js-lotus-client-rpc library dynamically handles the method invocations... one approach might be to do some code generation from the schema in order to generate the declarations.
For generated API method documentation, having plain markdown is desirable as the documentation can be read directly on GitHub in the repo.
For a full documentation site, it is common these days for API docs to have interactive examples where it's easy to see the arguments and output.
MDX is a combination of React JSX and Markdown, so it might be useful for this:
I've previously used mdx-deck for presentations, and was happy with it.
I've spent a bit of time exploring options for "playgrounds" where we can post demos, tutorials and example code where developers can easily try them out or fork them.
https://scotch.io/tutorials/7-javascript-playgrounds-to-use-in-2019
Another option is https://glitch.com/
We could also explore options for self-hosting a playground.
This would require some research, but it would be interesting to many people to have an example of how to use Filecoin + Ethereum together (or potentially another blockchain).
The low-level Lotus JS Client RPC library method calls with have a 1:1 relationship with the exported JSON-RPC methods, so will shared much documentation in common (description, parameters, output, etc.). It would be good to link from the JS Client Docs to the documentation for the JSON-RPC methods.
Open Work Labs has done some preliminary work using Postman to document a subset of the JSON-RPC methods:
https://documenter.getpostman.com/view/4872192/SWLh5mUd?version=latest
Make a list of all the methods.
Also cross-reference against Go API, usage in the Lotus CLI, external code examples.
Figure out what assets are needed to ensure stakeholders are fully informed about the ongoing state of development
I've got a bit stack of paper index cards that needs to become GitHub issues...
I suspect the tokens were getting cached in the browser.
This would be useful for tests as well as for tutorials.
Ganache (formerly known as testrpc) is a similar tool for Ethereum: https://www.trufflesuite.com/ganache
WalletHas() should return false, but it reported true.
All of the JSON-RPC methods callable from the Go client are listed here:
https://github.com/filecoin-project/lotus/blob/master/api/apistruct/struct.go
Godoc.org automatically publishes any inline documentation, for example:
The methods are currently lacking the comments that godoc uses. Here is a blog post describing how to document go code:
The JS Client documentation will probably share many descriptions with the go and JSON-RPC documentation. Ideally there would be an easy way to jump to the go documentation for a particular method from the JS documentation. This might be particularly helpful in the beginning before the entire API has been wrapped.
In the docs, there will be a "Getting Started" section, which should help people to "get their feet wet" with the JS Client in the easiest way possible.
Beyond that, there should be a series of exercises (aka "quests") that guide the developers through various parts of the API that they'll need to learn in order to build things. As they proceed through the progression, they will learn the basics of the API plus gain knowledge about how Filecoin is organized. Later exercises will require prerequisite knowledge from earlier exercises. Earlier quests will be things that most developers will want to do, whereas later quests might only appeal to a smaller audience that is trying to do advanced, niche things.
Planning out the progression will assist efforts to prioritize where to spend development time as we build the Lotus JS Client. A fully developed quest will have good support in the library, unit tests, documentation and example code / demos.
I'll add some ideas for quests in follow-on comments.
JS API client calls exist for:
I used the MpoolPushMessage
,But it throw an error,
{
"id": 1,
"jsonrpc": "2.0",
"params": [
{
"Version": 9,
"To": "",
"From": "",
"Nonce": 0,
"Value": "1",
"GasPrice": "0",
"GasLimit": 9,
"Method": 1,
"Params": ""
}
],
"method": "Filecoin.MpoolPushMessage"
}
Error:
{"jsonrpc":"2.0","id":1,"error":{"code":-32602,"message":"wrong param count (method 'Filecoin.MpoolPushMessage'): 1 != 2"}}
Have some guides to show how to get started with some popular frameworks, possibly:
Ideas:
Go through the code for lotuspond
at:
https://github.com/filecoin-project/lotus/tree/master/lotuspond
Identify re-usable components that could go into the JS Client libraries, or things that might work well as demos or 'quests'.
Provide a support/compatibility grid for various target environments:
Make an "awesome list" for modules and projects related to the JS Client:
https://github.com/sindresorhus/awesome
It would be a good place to find modules that implement interfaces that work the JS Client core libraries and reference implementations.
It would also be great to list libraries that are complementary, and also list applications that use or extend the libraries.
It would be great to have the possibility to subscribe to wallet balance change, as this is a pretty common use case.
I saw inside the schema definition for testnet
that subscription is possible for the method ChainNotify, so I am interested if same is possible for method WalletBalance?
The t01003 miner logged: providerstates providerstates/provider_states.go:286 deal bafyreigtq2gxj7h6ijizd5ra2ku2nyiwvgja6g4dxa3psxz67g7h3xdneu failed: deal rejected: clientMarketBalance.Available too small
Including introducing wrappers for debugging if useful
Spend no more than 2 hours
The lotuspond
web app included in the Lotus source code base uses this library:
We could wrap that with the provider interface to provide support on Node.js. It also has a lot
of features that the lightweight browser provider won't support.
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.