From 82997fd32daa8a5ca7d9f7b7cb68fa2637f37fe0 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 26 Jul 2024 10:06:49 +0800 Subject: [PATCH] 1 --- server/web3sign/controllers/recharge.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/server/web3sign/controllers/recharge.js b/server/web3sign/controllers/recharge.js index 82e1b85..c927469 100644 --- a/server/web3sign/controllers/recharge.js +++ b/server/web3sign/controllers/recharge.js @@ -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': {