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

Commit

Permalink
update according to h5dex
Browse files Browse the repository at this point in the history
  • Loading branch information
lyddream committed Sep 5, 2018
1 parent 8d4873f commit fa1046f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/common/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {keccak} from 'ethereumjs-util';
import {keccak, hashPersonalMessage} from 'ethereumjs-util';
import {toHex, toBig} from './formatter';

/**
Expand Down Expand Up @@ -28,3 +28,7 @@ export function calculateGas (gasPrice, gasLimit)
{
return toBig(gasPrice).times(gasLimit).div(1e9);
}

export default {
hashPersonalMessage
};
34 changes: 33 additions & 1 deletion src/relay/rpc/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ export default class Account
{
return getNonce(this.host, owner);
}
getAllEstimatedAllocatedAmount (params)
{
return getAllEstimatedAllocatedAmount(this.host, params);
}
}

/**
Expand Down Expand Up @@ -208,7 +212,7 @@ export function getTransactions (host, filter)
*/
export function getEstimatedAllocatedAllowance (host, filter)
{
const {owner, token, delegateAddress} = filter;
const {owner} = filter;
try
{
validator.validate({value: owner, type: 'ETH_ADDRESS'});
Expand Down Expand Up @@ -376,3 +380,31 @@ export async function getNonce (host, owner)
body
});
}
/**
*
* @param host
* @param owner
* @param delegateAddress
* @return {Promise.<*>}
*/
export async function getAllEstimatedAllocatedAmount (host, {owner, delegateAddress})
{
try
{
validator.validate({value: owner, type: 'ETH_ADDRESS'});
validator.validate({value: delegateAddress, type: 'ETH_ADDRESS'});
}
catch (e)
{
return Promise.resolve(new Response(code.PARAM_INVALID.code, code.PARAM_INVALID.msg));
}
let body = {};
body.method = 'loopring_getAllEstimatedAllocatedAmount';
body.params = [{owner, delegateAddress}];
body.id = id();
body.jsonrpc = '2.0';
return request(host, {
method: 'post',
body
});
}

0 comments on commit fa1046f

Please sign in to comment.