liskarchive / lisk-elements Goto Github PK
View Code? Open in Web Editor NEW⚙️ Library for sending Lisk transactions from the client or server
Home Page: https://lisk.io/
License: GNU General Public License v3.0
⚙️ Library for sending Lisk transactions from the client or server
Home Page: https://lisk.io/
License: GNU General Public License v3.0
Lisk JS does not work when required inside of a html5 web worker, affecting any 3rd party integration which rely on them.
To run the test-suite and static code analysis for each pull request or commit.
So you can sign and verify messages on a plain html/Js page, offline as download or online on the github page.
Update docs for the 0.4 release
Uncaught Invalid parameter value: 'limit'
In browser console it should throw and error saying something like:
> lisk.api().sendRequest('delegates/', {limit:undefined})
TypeError: sendRequest was called Invalid value 'undefined' of parameter 'limit'
In browser console:
> lisk.api().sendRequest('delegates/', {limit:undefined})
liskApi.js?e8ff:293 Uncaught TypeError: this.trimObj is not a function
at eval (eval at <anonymous> (http://localhost:8080/app.js:4799:2), <anonymous>:293:130)
at Array.reduce (native)
at LiskAPI.trimObj (eval at <anonymous> (http://localhost:8080/app.js:4799:2), <anonymous>:292:26)
at LiskAPI.serialiseHttpData (eval at <anonymous> (http://localhost:8080/app.js:4799:2), <anonymous>:282:20)
at LiskAPI.changeRequest (eval at <anonymous> (http://localhost:8080/app.js:4799:2), <anonymous>:247:59)
at LiskAPI.sendRequestPromise (eval at <anonymous> (http://localhost:8080/app.js:4799:2), <anonymous>:214:28)
at LiskAPI.sendRequest (eval at <anonymous> (http://localhost:8080/app.js:4799:2), <anonymous>:189:14)
at <anonymous>:1:12
It makes it difficult to figure out what actually went wrong if there are more calls and more parameters.
Some dependencies are complaining about necessary updates. This shall be done in a PR with dedicated research that nothing breaks.
We should update the code standards from ES5 to ES6/7. Initially using eslint which is already in-place. This should be done after #62 is resolved.
steps to replicate:
address = '16313739661670634666L'
callback = function (data) { console.log(data);}
lisk.api({node:'localhost', port: 4000}).listTransactions(address, callback);
VM332:1 Object {success: false, error: "Failed to get transactions: Parameter is not supported: random"}
lisk.api().listTransactions(address, callback);
VM332:1 Object {success: false, error: "Failed to get transactions: Parameter is not supported: random"}
Hello guys, I'm a License newbie as @Isabello knows, so I'm probably wrong.
This module is under the GNU General Public License v3.0 and my understanding is that any project using this code should also be under that same license.
http://stackoverflow.com/questions/3902754/mit-vs-gpl-license
Meaning, for example, that exchanges using it (Poloniex, bittrex, ...) should make their code open source if they are using that module.
Is my understanding of the license correct? Please enlighten me
The readme contains description for lisk-js 0.2
Rewrite the readme to cover setup for 0.3 and guide developers and users to the github page documentation.
If there is a failure to connect to a selected peer, then another peer on the same network should be chosen.
If there is a failure to connect to a selected peer, then the current behaviour results in another mainnet
peer being selected, regardless of whether a peer on another network was selected.
Select a localhost
peer even though there is no instance of Lisk running locally. Perform an API request. Connection will timeout / fail, resulting in a change of peer to one of the predefined mainnet
peers. If the intention was to connect to the testnet
or a local devnet
, the current behaviour would be undesirable.
Assuming, upon catching an error, the switch is being here: https://github.com/LiskHQ/lisk-js/blob/development/lib/api/liskApi.js#L203.
Then improve information available to selectNode
: https://github.com/LiskHQ/lisk-js/blob/development/lib/api/liskApi.js#L143, by allowing the developer to optionally indicate their chosen network using an appropriate nethash
.
Then if a nethash
is provided, restrict the peer selection to the chosen network. Allowing the switch to occur when matching. Throwing an error when there are no matching peers.
We should publish Istanbul coverage data to coveralls with every travis build.
if you use
lisk.transaction.createTransaction(undefined,1000000000,"passphrase","secondpassphrase");
you get a malformed transaction (ie with no recipientId)
Add documentation updates from 0.2 to 0.3
Including:
documentation of API wrapper
documentation of crypto modules
Wrap it into a github page
For reasons of compatibility when running lisk-js
on older JavaScript compilers, the distribution should be transpiled to the ES5 standard using https://babeljs.io/.
Fix travis and use the same logic as in the lisk core.
Add to package.json
https://github.com/LiskHQ/lisk/blob/development/package.json
Add travis as grunt task
https://github.com/LiskHQ/lisk/blob/development/Gruntfile.js
Add coveralls to display test coverage
Multisignature in the current behaviour is not complete in lisk-js.
Missing:
The reason is the body is missing from request sent. I will post pull request with fix.
In browser js console:
> lisk.api().sendRequest('delegates/', {limit:'10'}, (data) =>{console.log(data.ddd.sss)})
Promise {[[PromiseStatus]]: "pending", [[PromiseValue]]: undefined}
VM41213:1 TypeError: Cannot read property 'sss' of undefined
at lisk.api.sendRequest (<anonymous>:1:86)
at eval (eval at <anonymous> (app.js:4799), <anonymous>:195:11)
> lisk.api().sendRequest('delegates/', {limit:'10'}, (data) =>{try{console.log(data.ddd.sss)} catch(e) {console.log(e)}})
Promise {[[PromiseStatus]]: "pending", [[PromiseValue]]: undefined}
VM41213:1 TypeError: Cannot read property 'sss' of undefined
at lisk.api.sendRequest (<anonymous>:1:86)
at eval (eval at <anonymous> (app.js:4799), <anonymous>:195:11)
In browser js console:
> lisk.api().sendRequest('delegates/', {limit:'10'}, (data) =>{console.log(data.ddd.sss)})
Promise {[[PromiseStatus]]: "pending", [[PromiseValue]]: undefined}
> lisk.api().sendRequest('delegates/', {limit:'10'}, (data) =>{try{console.log(data.ddd.sss)} catch(e) {console.log(e)}})
Promise {[[PromiseStatus]]: "pending", [[PromiseValue]]: undefined}
VM41213:1 TypeError: Cannot read property 'sss' of undefined
at lisk.api.sendRequest (<anonymous>:1:86)
at eval (eval at <anonymous> (app.js:4799), <anonymous>:195:11)
There are several methods in the lisk-js API that aren't mentioned in the docs, look more like internal utility functions and shouldn't really be used by public, e.g. sendRequestPromise, getRandomPeer, banNode ...
If we expose these methods, people might use them in their projects and then we have to support them else we break other people's projects. On the other hand, if we make them private we can easily refactor and change their behaviour if necessary in the future.
There are several ways to emulate private methods in JavaScrtipt:
http://stackoverflow.com/questions/55611/javascript-private-methods
Introduced via: LiskArchive/lisk-sdk#470
Pull request is pending review and possibly requires further work. However, opening issue so we can add the required support for it in lisk-js when ready.
We should use https://istanbul.js.org/ to measure the amount of test coverage.
Tests are currently all running on Node.
The same tests should also be done in the Browser, to get sure it behaves as expected.
Create crypto submodules in order to achieve higher flexibility in regards of maintenance and understanding of the code.
See bellow the output of the "API" part of tests, esp. the last 12 tests show how long each took. Altogether the test suit takes 8 seconds when on pretty good internet connection. If I skip API tests (there is 45 of them), then the rest 228 tests take less than 2 seconds.
There are some nice tools to do the mocking:
http://stackoverflow.com/questions/8021956/node-js-mock-http-request-and-response
api
Lisk.api()
lisk.api()
✓ should create a new instance when using lisk.api()
✓ new lisk.api() should be Object
#listPeers
✓ should give a set of the peers
.currentPeer
✓ currentPeer should be set by default
#getNethash
✓ Nethash should be hardcoded variables
✓ should give corret Nethash for testnet
#setTestnet
✓ should set to testnet
#setNode
✓ should be able to set my own node
✓ should select a node when not explicitly set
#selectNode
✓ should return the node from initial settings when set
#getRandomPeer
✓ should give a random peer
#banNode
✓ should add current node to LSK.bannedPeers
#getFullUrl
✓ should give the full url inclusive port
✓ should give the full url without port and with SSL
#getURLPrefix
✓ should be http when ssl is false
✓ should be https when ssl is true
#trimObj
✓ should not be equal before trim
✓ should be equal after trim an Object in keys and value
✓ should accept numbers and strings as value
#toQueryString
✓ should create a http string from an object. Like { obj: "myval", key: "myval" } -> obj=myval&key=myval
#serialiseHttpData
✓ should create a http string from an object and trim.
#getAddressFromSecret
✓ should create correct address and publicKey
#checkRequest
✓ should identify GET requests
✓ should identify POST requests
✓ should identify PUT requests
✓ should identify NOACTION requests
#changeRequest
✓ should give the correct parameters for GET requests
✓ should give the correct parameters for GET requests with parameters
✓ should give the correct parameters for NOACTION requests
✓ should give the correct parameters for POST requests
✓ should give the correct parameters for PUT requests
#sendRequest
✓ should receive Height from a random public peer (206ms)
#listActiveDelegates
✓ should list active delegates (207ms)
#listStandyDelegates
✓ should list non-active delegates (93ms)
#searchDelegateByUsername
✓ should find a delegate by name (71ms)
#listBlocks
✓ should list amount of blocks defined (81ms)
#getBlock
✓ should get a block of certain height (1275ms)
#listTransactions
✓ should list transactions of a defined account (70ms)
#getTransaction
✓ should list a defined transaction (93ms)
#listVotes
✓ should list votes of an account (144ms)
#listVoters
✓ should list voters of an account (129ms)
#getAccount
✓ should get account information (82ms)
#sendLSK
✓ should send testnet LSK (118ms)
API wrapper and parseTransaction are not yet included in YUIdoc. This should be fixed.
Add asynchronous test for the API wrapper functions, checking if the server answer is as expected
Now it returns:
{
"official":[
"node01.lisk.io",
"node02.lisk.io",
"node03.lisk.io",
"node04.lisk.io",
"node05.lisk.io",
"node06.lisk.io",
"node07.lisk.io",
"node08.lisk.io"
],
"ssl":[
"login.lisk.io"
],
"testnet":[
"83.136.249.129"
],
"localhost":[
"localhost"
]
}
It should return:
{
"official":[
{"node" : "node01.lisk.io"},
{"node" : "node02.lisk.io"},
{"node" : "node03.lisk.io"},
{"node" : "node04.lisk.io"},
{"node" : "node05.lisk.io"},
{"node" : "node06.lisk.io"},
{"node" : "node07.lisk.io"},
{"node" : "node08.lisk.io"}
],
"ssl":[
{"node" : "login.lisk.io"}
],
"testnet":[
{"node" : "83.136.249.129"}
],
"localhost":[
{"node" : "localhost"}
]
}
in order to be able to specify other stuff for each peer, e.g. port, ssl.
Either using /docs folder on the main branch or with a seperate gh-page branch
Preferably using ESLint http://eslint.org/.
Courtesy of @4miners in: LiskArchive/lisk-nano#29.
Such feature is needed very much, can be useful for a lot of things and projects.
Output should be standardized, for example:
-----BEGIN LISK SIGNED MESSAGE-----
<message>
-----BEGIN SIGNATURE-----
<address>
<signature>
-----END LISK SIGNED MESSAGE-----
Some reference: https://bitcointalk.org/index.php?topic=990345.0
limit
parameter to lisk.api().listTransactions(address, callback);
lisk.api().listPeers();
that returns list of peers for the peer dropdown. It actually contains 3 lists: official, testnet, localhost.lisk.api().keepOnline(callback);
.lisk.api().getAccount(address);
that calls /api/accounts
{ transaction }
lisk.api().sendTransaction(address, amount, passphrase, secondPassphrase);
that creates and sends transactionorderBy = 'timestamp:desc'
parameter to lisk.api().listTransactions()
More on the proposed lisk.api().keepOnline(callback);
:
Right now Lisk Nano is using /api/loader/status/ call for this, but it also calls two other requests with the same frequency (every ~10 seconds): /api/accounts
and /api/transactions
. So lisk-js can be smarter and avoid the /api/loader/status
call if there was some other successful call recently. In addition, the /api/transactions
call could be cached and the cache purged only if balance
or unconfirmedBalance
in /api/accounts
changed, provided that /api/accounts
is called periodically.
Like sendLSK, addSecondSignature etc
In our usage instructions https://github.com/LiskHQ/lisk-js#usage we refer to a module generated by Browserify which does not exist. It should be shipped with each release.
lisk.api().listPeers() lists this in the testnet stack:
83.136.249.129
Which resolves to:
https://testnet-explorer.lisk.io/
It shouldn't really return an IP address, just:
testnet.lisk.io
We should extend lisk-js
to support much easier interaction with the lisk
API. This would enable lisk-js
to be used as a framework independent library in all our client interfaces.
To begin with, we should support the listing of collections, retrieval of single records and posting of all locally signed transactions to internally selected peers.
It should be made possible for the selected peer to be automatically negotiated, or manually selected by the developer.
We should document the lisk-js
source code using: http://yui.github.io/yuidoc/
New code can be documented immediately: http://yui.github.io/yuidoc/syntax/index.html
Existing code can we cover here, module by module.
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.