1
This commit is contained in:
parent
41de2ea72b
commit
c7a7205f60
@ -35,30 +35,33 @@ async function recharge(session) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const currencyMeta = bc.getContractByName(currencyName);
|
||||||
|
if (!currencyMeta) {
|
||||||
|
session.rspErr(500, 'currency meta not found');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (currencyMeta['type'] != 'erc20') {
|
||||||
|
session.rspErr(500, 'currency meta type error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const gameMallMeta = bc.getContractByName(bccontract.GameItemMall_INSTANCE_NAME);
|
||||||
|
if (!gameMallMeta) {
|
||||||
|
session.rspErr(500, 'gamemall meta not found');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const currencyAddress = bcutils.toNormalAddress(currencyMeta['address']);
|
||||||
|
const gameMallAddress = bcutils.toNormalAddress(gameMallMeta['address']);
|
||||||
|
|
||||||
let currencyAddress = '';
|
|
||||||
const nowTime = utils.getUtcTime();
|
const nowTime = utils.getUtcTime();
|
||||||
const calls = [];
|
const calls = [];
|
||||||
{
|
{
|
||||||
const contractMeta = bc.getContractByName(currencyName);
|
|
||||||
if (!contractMeta) {
|
|
||||||
session.rspErr(500, 'currency meta not found');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
console.log(contractMeta);
|
|
||||||
if (contractMeta['type'] != 'erc20') {
|
|
||||||
session.rspErr(500, 'currency meta type error');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
currencyAddress = bcutils.toNormalAddress(contractMeta['address']);
|
|
||||||
|
|
||||||
const instance = bc.getInstanceByName(currencyName);
|
const instance = bc.getInstanceByName(currencyName);
|
||||||
if (!instance) {
|
if (!instance) {
|
||||||
session.rspErr(500, 'currency error');
|
session.rspErr(500, 'currency error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let data = instance.methods.approve(
|
let data = instance.methods.approve(
|
||||||
spender,
|
gameMallAddress,
|
||||||
amount).encodeABI();
|
amount).encodeABI();
|
||||||
calls.push({
|
calls.push({
|
||||||
'trans_id' : '',
|
'trans_id' : '',
|
||||||
@ -69,11 +72,6 @@ async function recharge(session) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const contractMeta = bc.getContractByName(bccontract.GameItemMall_INSTANCE_NAME);
|
|
||||||
if (!contractMeta) {
|
|
||||||
session.rspErr(500, 'gamemall meta not found');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const instance = bc.getInstanceByName(bccontract.GameItemMall_INSTANCE_NAME);
|
const instance = bc.getInstanceByName(bccontract.GameItemMall_INSTANCE_NAME);
|
||||||
if (!instance) {
|
if (!instance) {
|
||||||
@ -102,7 +100,7 @@ async function recharge(session) {
|
|||||||
calls.push({
|
calls.push({
|
||||||
'trans_id' : '',
|
'trans_id' : '',
|
||||||
'trans_req': {
|
'trans_req': {
|
||||||
'to': bcutils.toNormalAddress(contractMeta['address']),
|
'to': gameMallAddress,
|
||||||
'data': data
|
'data': data
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user