Skip to content
This repository has been archived by the owner on Jun 7, 2019. It is now read-only.

Commit

Permalink
Merge branch 'development' into mocha-now
Browse files Browse the repository at this point in the history
  • Loading branch information
willclarktech committed Jul 6, 2017
2 parents 7463594 + c963418 commit 68c3ec6
Show file tree
Hide file tree
Showing 9 changed files with 4,139 additions and 86 deletions.
3 changes: 2 additions & 1 deletion eslint_ecma5.json → .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"no-undef": "error",
"no-unused-vars": ["error", { "vars": "all", "args": "after-used" }],
"strict": ["error", "global"],
"semi": ["error", "always"]
"semi": ["error", "always"],
"no-console": ["error", { "allow": ["error", "info"] }]
},
"env": {
"browser": true,
Expand Down
6 changes: 1 addition & 5 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ module.exports = function (grunt) {

grunt.initConfig({
eslint: {
options: {
configFile: 'eslint_ecma5.json',
reset: true
},
target: ['lib/**', 'test/**', '!test/mocha.opts', 'Gruntfile.js', 'index.js']
},

Expand Down Expand Up @@ -56,7 +52,7 @@ module.exports = function (grunt) {
src: 'test/.coverage-unit/*.info'
}
});

grunt.registerTask('eslint-fix', 'Run eslint and fix formatting', function () {
grunt.config.set('eslint.options.fix', true);
grunt.task.run('eslint');
Expand Down
46 changes: 13 additions & 33 deletions docs/example/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ <h1>API</h1>
<a href="#functions_getKeys" class="list-group-item sub-item" data-parent="#crypto_sub" style="padding-left: 34px;">getKeys</a>
<a href="#functions_verify" class="list-group-item sub-item" data-parent="#crypto_sub" style="padding-left: 34px;">verify</a>
<a href="#functions_verifySecondSignature" class="list-group-item sub-item" data-parent="#crypto_sub" style="padding-left: 34px;">verifySecondSignature</a>
<a href="#functions_fixedPoint" class="list-group-item sub-item" data-parent="#crypto_sub" style="padding-left: 34px;">fixedPoint</a>

<a href="#functions_bufferToHex" class="list-group-item sub-item" data-parent="#crypto_sub" style="padding-left: 34px;">bufferToHex</a>
<a href="#functions_hexToBuffer" class="list-group-item sub-item" data-parent="#crypto_sub" style="padding-left: 34px;">hexToBuffer</a>
Expand Down Expand Up @@ -277,11 +276,11 @@ <h3 id="functions_getBlock">getBlock</h3>
<div class="panel-body">
<div class="rows">
<div class="col-md-12">
<h3>Example <small>Get a single block by id</small></h3>
<h3>Example <small>Get a single block by height</small></h3>
<figure class="highlight">
<pre>
<code class="language-html" data-lang="html">
lisk.api().getBlock(blockId, callback);
lisk.api().getBlock(blockHeight, callback);
</code>
</pre>
</figure>
Expand Down Expand Up @@ -488,7 +487,7 @@ <h3>Example <small>GET - Retreive the current block height</small></h3>
<pre>
<code class="language-html" data-lang="html">

var liskBlockheight = lisk.api().sendRequest('blocks/getHeight', function (data) {
lisk.api().sendRequest('blocks/getHeight', function (data) {
var str = JSON.stringify(data);
document.getElementById('output').innerHTML = str;
});
Expand All @@ -502,7 +501,7 @@ <h3>Example <small>POST - Open a new account</small></h3>
<figure class="highlight">
<pre>
<code class="language-html" data-lang="html">
var liskNewAccount = lisk.api().sendRequest('accounts/open', { secret: 'my secret passphrase' }, function (data) {
lisk.api().sendRequest('accounts/open', { secret: 'my secret passphrase' }, function (data) {
var str = JSON.stringify(data);
document.getElementById('output').innerHTML = str;
});
Expand All @@ -525,7 +524,7 @@ <h3>Example <small>Get a unique hash for the currently selected network</small><
<figure class="highlight">
<pre>
<code class="language-html" data-lang="html">
var LSK = lisk.api().getNethash();
lisk.api().getNethash();
</code>
</pre>
</figure>
Expand Down Expand Up @@ -560,7 +559,7 @@ <h3>Example <small>Set the currently selected node</small></h3>
<figure class="highlight">
<pre>
<code class="language-html" data-lang="html">
var LSK = lisk.api().setNode('mynode.com');
lisk.api().setNode('mynode.com');
</code>
</pre>
</figure>
Expand All @@ -580,7 +579,7 @@ <h3>Example <small>Lists the peers configured for each network.</small></h3>
<figure class="highlight">
<pre>
<code class="language-html" data-lang="html">
var LSK = lisk.api().listPeers();
lisk.api().listPeers();
</code>
</pre>
</figure>
Expand Down Expand Up @@ -609,7 +608,7 @@ <h3>Example <small>Enable the SSL connecton protocol</small></h3>
<figure class="highlight">
<pre>
<code class="language-html" data-lang="html">
var LSK = lisk.api().setSSL(true); // or false
lisk.api().setSSL(true); // or false
</code>
</pre>
</figure>
Expand All @@ -628,7 +627,7 @@ <h3>Example <small>Toggle between the testnet and mainnet</small></h3>
<figure class="highlight">
<pre>
<code class="language-html" data-lang="html">
var LSK = lisk.api().setTestnet(true); // or false
lisk.api().setTestnet(true); // or false
</code>
</pre>
</figure>
Expand Down Expand Up @@ -679,7 +678,7 @@ <h3>Example <small>Get the LSK address from a given public key</small></h3>
<figure class="highlight">
<pre>
<code class="language-html" data-lang="html">
var keys = lisk.crypto.getAddress('5d036a858ce89f844491762eb89e2bfbd50a4a0a0da658e4b2628b25b117ae09');
var address = lisk.crypto.getAddress('5d036a858ce89f844491762eb89e2bfbd50a4a0a0da658e4b2628b25b117ae09');
</code>
</pre>
</figure>
Expand Down Expand Up @@ -886,25 +885,6 @@ <h3>Example <small>Verify the second signature of a transaction object</small></
</div>
</div>

<h3 id="functions_fixedPoint">fixedPoint</h3>

<div class="panel panel-default">
<div class="panel-body">
<div class="rows">
<div class="col-md-12">
<h3>Example <small>Convert a given floating point LSK amount to an integer representation</small></h3>
<figure class="highlight">
<pre>
<code class="language-html" data-lang="html">
var bigAmount = lisk.crypto.fixedPoint(amount);
</code>
</pre>
</figure>
</div>
</div>
</div>
</div>

<h3 id="functions_bufferToHex">bufferToHex</h3>

<div class="panel panel-default">
Expand Down Expand Up @@ -1008,7 +988,7 @@ <h3>Example <small>Formats the given plain message, signed message and public ke
</code>
</pre>
</figure>
<p>In order maintain formatting it is advised to wrap the resulting output within a <code>pre</code> tag.</p>
<p>In order to maintain formatting it is advised to wrap the resulting output within a <code>pre</code> tag.</p>
</div>
</div>
</div>
Expand Down Expand Up @@ -1097,7 +1077,7 @@ <h3>Example <small>Decrypts a message with secret, senderPublicKey and the nonce
<figure class="highlight">
<pre>
<code class="language-html" data-lang="html">
var encrypted = lisk.crypto.decryptMessageWithSecret(encryptedMessage, nonce, secret, senderPublicKey);
var decrypted = lisk.crypto.decryptMessageWithSecret(encryptedMessage, nonce, secret, senderPublicKey);
</code>
</pre>
</figure>
Expand All @@ -1109,7 +1089,7 @@ <h3>Example <small>Decrypts a message with secret, senderPublicKey and the nonce
</code>
</pre>
</figure>
<p>If successfull, returns the plain text of the senders message.</p>
<p>If successful, returns the plain text of the sender's message.</p>
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions lib/api/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ module.exports = {
*
* @return trimmed string
*/
trimObj: function rimObj(obj) {
trimObj: function trimObj(obj) {
if (!Array.isArray(obj) && typeof obj !== 'object') return obj;

return Object.keys(obj).reduce(function(acc, key) {
acc[key.trim()] = typeof obj[key] === 'string'
? obj[key].trim()
: Number.isInteger(obj[key])
? obj[key].toString()
: rimObj(obj[key]);
: trimObj(obj[key]);
return acc;
}, Array.isArray(obj) ? [] : {});
},
Expand Down
34 changes: 22 additions & 12 deletions lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,31 @@
* @type object
*/

var fixedPoint = Math.pow(10, 8);

var sendFee = 0.1 * fixedPoint;
var signatureFee = 5 * fixedPoint;
var delegateFee = 25 * fixedPoint;
var voteFee = 1 * fixedPoint;
var multisignatureFee = 5 * fixedPoint;
var dappFee = 25 * fixedPoint;

module.exports = {
fixedPoint: fixedPoint,
fees: {
send: 10000000,
signature: 500000000,
delegate: 2500000000,
vote: 100000000,
multisignature: 500000000,
dapp: 2500000000
send: sendFee,
signature: signatureFee,
delegate: delegateFee,
vote: voteFee,
multisignature: multisignatureFee,
dapp: dappFee,
},
fee: {
0: 10000000,
1: 500000000,
2: 2500000000,
3: 100000000,
4: 500000000,
5: 2500000000
0: sendFee,
1: signatureFee,
2: delegateFee,
3: voteFee,
4: multisignatureFee,
5: dappFee,
}
};
13 changes: 1 addition & 12 deletions lib/transactions/crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,14 @@ var constants = require('../constants.js');
var ByteBuffer = require('bytebuffer');
var bignum = require('browserify-bignum');

/**
* `fixedPoint` is the size we calculate numbers in. 10^8
* @property fixedPoint
* @static
* @final
* @type Number
*/

var fixedPoint = Math.pow(10, 8);

/**
* @method getTransactionBytes
* @param transaction Object
* @return {object}
*/

function getTransactionBytes (transaction) {

/**
* @method isSendTransaction
* @return {object}
Expand Down Expand Up @@ -528,7 +518,6 @@ module.exports = {
getAddress: getAddress,
verify: verify,
verifySecondSignature: verifySecondSignature,
fixedPoint: fixedPoint,

bufferToHex: cryptoModule.bufferToHex,
hexToBuffer: cryptoModule.hexToBuffer,
Expand Down
19 changes: 1 addition & 18 deletions test/transactions/crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('crypto.js', function () {
});

it('should has properties', function () {
var properties = ['getBytes', 'getHash', 'getId', 'getFee', 'sign', 'secondSign', 'getKeys', 'getAddress', 'verify', 'verifySecondSignature', 'fixedPoint'];
var properties = ['getBytes', 'getHash', 'getId', 'getFee', 'sign', 'secondSign', 'getKeys', 'getAddress', 'verify', 'verifySecondSignature'];
properties.forEach(function (property) {
(crypto).should.have.property(property);
});
Expand Down Expand Up @@ -171,23 +171,6 @@ describe('crypto.js', function () {
});
});

describe('fixedPoint', function () {

var fixedPoint = crypto.fixedPoint;

it('should be ok', function () {
(fixedPoint).should.be.ok;
});

it('should be number', function () {
(fixedPoint).should.be.type('number').and.not.NaN;
});

it('should be equal 100000000', function () {
(fixedPoint).should.be.equal(100000000);
});
});

describe('#sign', function () {

var sign = crypto.sign;
Expand Down
3 changes: 0 additions & 3 deletions test/transactions/multisignature.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,6 @@ describe('multisignature.js', function () {
var pubKey = lisk.crypto.getPrivateAndPublicKeyFromSecret(secret).publicKey;

(msigTransaction2.requesterPublicKey).should.be.equal(pubKey);

console.log(msigTransaction2);

});


Expand Down
Loading

0 comments on commit 68c3ec6

Please sign in to comment.