This commit is contained in:
aozhiwei 2024-07-25 14:30:40 +08:00
parent f04b0b2046
commit 123e1760c5
2 changed files with 20 additions and 1 deletions

View File

@ -11,6 +11,7 @@ async function approveErc20(session) {
const netId = session.request('net_id');
const spender = bcutils.toNormalAddress(session.request('spender'));
const value = session.request('value');
const currencyName = session.request('currency_name');
const bc = serviceFactory.create('BlockChain');
{
const ret = await bc.init(netId);
@ -31,6 +32,24 @@ async function approveErc20(session) {
return;
}
}
const instance = bc.getInstanceByName(currencyName);
if (!instance) {
session.rspErr(500, 'currency error');
return;
}
let data = instance.methods.approve
(
spender,
value).encodeABI();
session.rspData({
'trans_id' : '',
'trans_req': {
'to': '',
'data': data
}
});
} catch (e) {
session.rspErr(1, 1);
utils.safeDumpErrStack(e);

View File

@ -9,7 +9,7 @@ async function init() {
add('activate721nft');
add('nftunlock');
add('minthero');
add('erc20');
add('erc');
}
exports.init = init;