Skip to content
This repository was archived by the owner on Mar 18, 2019. It is now read-only.

Commit 64cfb70

Browse files
authored
Merge pull request #42 from Loopring/arrow-function
use arrow functions and use ecma6
2 parents c512fc9 + e8c68b2 commit 64cfb70

File tree

8 files changed

+26
-26
lines changed

8 files changed

+26
-26
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Include the following script tags in your HTML:
3838
<script src="../bower_components/async/dist/async.js"></script>
3939
<script src="../bower_components/axios/dist/axios.min.js"></script>
4040
<script src="../bower_components/bignumber.js/bignumber.min.js"></script>
41-
<script src="../bower_components/axios/lib/bn.js"></script>
41+
<script src="../node_modules/bn.js/lib/bn.js"></script>
4242
<script src="../bower_components/lodash/dist/lodash.min.js"></script>
4343
<script src="../bower_components/loopring.js/dist/loopring.min.js"></script>
4444
```

dist/loopring.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/keystore.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ exports.decryptKeystoreToPkey = (keystore, password) =>
5050
return wallet;
5151
};
5252

53-
exports.pkeyToKeystore = function (privateKey, password)
53+
exports.pkeyToKeystore = (privateKey, password) =>
5454
{
5555
const salt = crypto.randomBytes(32);
5656
const iv = crypto.randomBytes(16);

src/order.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ function Order (data)
109109
'uint8'
110110
];
111111

112-
this.sign = function (privateKey)
112+
this.sign = (privateKey) =>
113113
{
114114
const validation = ajv.validate(orderSchema, data);
115115

@@ -161,7 +161,7 @@ function Order (data)
161161
};
162162
};
163163

164-
this.cancel = function (amount, privateKey)
164+
this.cancel = (amount, privateKey) =>
165165
{
166166
if (!r || !v || !s)
167167
{

src/relay.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ function relay (host)
337337
return new BigNumber(Number(await this.call(params, tag)));
338338
};
339339

340-
this.submitLoopringOrder = async function (order)
340+
this.submitLoopringOrder = async (order) =>
341341
{
342342
request.method = 'loopring_submitOrder';
343343
request.params = [order];
@@ -362,7 +362,7 @@ function relay (host)
362362
return this.sendSignedTx(tx.signedTx);
363363
};
364364

365-
this.getOrders = async function (filter)
365+
this.getOrders = async (filter) =>
366366
{
367367
request.method = 'loopring_getOrders';
368368
request.params = [filter];
@@ -381,7 +381,7 @@ function relay (host)
381381
});
382382
};
383383

384-
this.getDepth = async function (filter)
384+
this.getDepth = async (filter) =>
385385
{
386386
request.method = 'loopring_getDepth';
387387
request.params = [ filter ];
@@ -400,7 +400,7 @@ function relay (host)
400400
});
401401
};
402402

403-
this.getTicker = async function (market)
403+
this.getTicker = async (market) =>
404404
{
405405
request.method = 'loopring_getTicker';
406406
request.params = [market];
@@ -419,7 +419,7 @@ function relay (host)
419419
});
420420
};
421421

422-
this.getFills = async function (filter)
422+
this.getFills = async (filter) =>
423423
{
424424
// filter:market, address, pageIndex, pageSize,contractVersion
425425
request.method = 'loopring_getFills';
@@ -439,7 +439,7 @@ function relay (host)
439439
});
440440
};
441441

442-
this.getTrend = async function (market)
442+
this.getTrend = async (market) =>
443443
{
444444
// filter:market
445445
request.method = 'loopring_getTrend';
@@ -459,7 +459,7 @@ function relay (host)
459459
});
460460
};
461461

462-
this.getRingMined = async function (filter)
462+
this.getRingMined = async (filter) =>
463463
{
464464
// filter:ringHash, orderHash, miner, pageIndex, pageSize,contractVersion
465465
request.method = 'loopring_getRingMined';
@@ -479,7 +479,7 @@ function relay (host)
479479
});
480480
};
481481

482-
this.getBalances = async function (address)
482+
this.getBalances = async (address) =>
483483
{
484484
request.method = 'loopring_getBalance';
485485
request.params = [{ address }];

src/signer.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const transactionSchema = {
5959
};
6060

6161
const ajv = new Ajv();
62-
exports.solSHA3 = function (types, data)
62+
exports.solSHA3 = (types, data) =>
6363
{
6464
const hash = abi.soliditySHA3(types, data);
6565
return hash;
@@ -82,7 +82,7 @@ exports.signEthTx = (tx, privateKey) =>
8282
return '0x' + ethTx.serialize().toString('hex');
8383
};
8484

85-
exports.generateCancelOrderData = function (order)
85+
exports.generateCancelOrderData = (order) =>
8686
{
8787
const data = abi.rawEncode([
8888
'address[3]',
@@ -114,42 +114,42 @@ exports.generateCancelOrderData = function (order)
114114
return '0x' + method + data;
115115
};
116116

117-
exports.generateCutOffData = function (timestamp)
117+
exports.generateCutOffData = (timestamp) =>
118118
{
119119
const method = abi.methodID('setCutoff', ['uint']).toString('hex');
120120
const data = abi.rawEncode(['uint'], [timestamp]).toString('hex');
121121
return '0x' + method + data;
122122
};
123123

124-
exports.generateApproveData = function (address, amount)
124+
exports.generateApproveData = (address, amount) =>
125125
{
126126
const method = abi.methodID('approve', ['address', 'uint']).toString('hex');
127127
const data = abi.rawEncode(['address', 'uint'], [address, amount]).toString('hex');
128128
return '0x' + method + data;
129129
};
130130

131-
exports.generateWithdrawData = function (amount)
131+
exports.generateWithdrawData = (amount) =>
132132
{
133133
const method = abi.methodID('withdraw', ['uint']).toString('hex');
134134
const data = abi.rawEncode(['uint'], [amount]).toString('hex');
135135
return '0x' + method + data;
136136
};
137137

138-
exports.generateTransferData = function (address, amount)
138+
exports.generateTransferData = (address, amount) =>
139139
{
140140
const method = abi.methodID('transfer', ['address', 'uint']).toString('hex');
141141
const data = abi.rawEncode(['address', 'uint'], [address, amount]).toString('hex');
142142
return '0x' + method + data;
143143
};
144144

145-
exports.generateBalanceOfData = function (address)
145+
exports.generateBalanceOfData = (address) =>
146146
{
147147
const method = abi.methodID('balanceOf', ['address']).toString('hex');
148148
const data = abi.rawEncode(['address'], [address]).toString('hex');
149149
return '0x' + method + data;
150150
};
151151

152-
exports.generateAllowanceData = function (owner, spender)
152+
exports.generateAllowanceData = (owner, spender) =>
153153
{
154154
const method = abi.methodID('allowance', ['address', 'address']).toString('hex');
155155
const data = abi.rawEncode(['address', 'address'], [owner, spender]).toString('hex');

src/wallet.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ function Wallet ()
2626
let publicKey;
2727
let address;
2828

29-
this.generate = function ()
29+
this.generate = () =>
3030
{
3131
privateKey = crypto.randomBytes(32);
3232
publicKey = ethereumUtil.privateToPublic(privateKey);
3333
address = ethereumUtil.publicToAddress(publicKey);
3434
};
3535

36-
this.setPrivateKey = function (key)
36+
this.setPrivateKey = (key) =>
3737
{
3838
if (typeof key === 'string')
3939
{
@@ -44,12 +44,12 @@ function Wallet ()
4444
address = ethereumUtil.publicToAddress(publicKey);
4545
};
4646

47-
this.getAddress = function ()
47+
this.getAddress = () =>
4848
{
4949
return ethereumUtil.toChecksumAddress('0x' + address.toString('hex'));
5050
};
5151

52-
this.toKeystore = function (password)
52+
this.toKeystore = (password) =>
5353
{
5454
return keystore.pkeyToKeystore(privateKey, password);
5555
};

webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ module.exports = {
3939
parallel: true,
4040
uglifyOptions: {
4141
beautify: false,
42-
ecma: 5,
42+
ecma: 6,
4343
compress: true,
4444
comments: false
4545
}

0 commit comments

Comments
 (0)