1
This commit is contained in:
parent
3e8908628f
commit
82997fd32d
@ -11,7 +11,7 @@ async function recharge(session) {
|
||||
const accountAddress = bcutils.toNormalAddress(session.request('account_address'));
|
||||
const netId = session.request('net_id');
|
||||
const spender = bcutils.toNormalAddress(session.request('spender'));
|
||||
const value = session.request('value');
|
||||
const amount = session.request('amount');
|
||||
const currencyName = session.request('currency_name');
|
||||
const orderId = session.request('orderId');
|
||||
const bc = serviceFactory.create('BlockChain');
|
||||
@ -35,6 +35,8 @@ async function recharge(session) {
|
||||
}
|
||||
}
|
||||
|
||||
let currencyAddress = '';
|
||||
const nowTime = utils.getUtcTime();
|
||||
const calls = [];
|
||||
{
|
||||
const contractMeta = bc.getContractByName(currencyName);
|
||||
@ -47,6 +49,7 @@ async function recharge(session) {
|
||||
session.rspErr(500, 'currency meta type error');
|
||||
return;
|
||||
}
|
||||
currencyAddress = bcutils.toNormalAddress(contractMeta['address']);
|
||||
|
||||
const instance = bc.getInstanceByName(currencyName);
|
||||
if (!instance) {
|
||||
@ -55,11 +58,11 @@ async function recharge(session) {
|
||||
}
|
||||
let data = instance.methods.approve(
|
||||
spender,
|
||||
value).encodeABI();
|
||||
amount).encodeABI();
|
||||
calls.push({
|
||||
'trans_id' : '',
|
||||
'trans_req': {
|
||||
'to': bcutils.toNormalAddress(contractMeta['address']),
|
||||
'to': currencyAddress,
|
||||
'data': data
|
||||
}
|
||||
});
|
||||
@ -77,8 +80,13 @@ async function recharge(session) {
|
||||
return;
|
||||
}
|
||||
let data = instance.methods.buy(
|
||||
spender,
|
||||
value).encodeABI();
|
||||
accountAddress,
|
||||
orderId,
|
||||
currencyAddress,
|
||||
amount,
|
||||
nowTime,
|
||||
orderId
|
||||
).encodeABI();
|
||||
calls.push({
|
||||
'trans_id' : '',
|
||||
'trans_req': {
|
||||
|
Loading…
x
Reference in New Issue
Block a user