sendEth等方法增加参数, 是否只返回估算的价格

This commit is contained in:
cebgcontract 2022-12-16 13:44:48 +08:00
parent 0ca92675fe
commit df35252185
2 changed files with 52 additions and 16 deletions

File diff suppressed because one or more lines are too long

View File

@ -138,10 +138,12 @@ function getEthBalance(funId, account) {
* send ETH from current account
* @param {string} to: target account
* @param {string} amount:
* @param {number} estimate: 1: only estimate gas price
*/
function sendEth(funId, to, amount) {
function sendEth(funId, to, amount, estimate) {
estimate = (estimate || '0') | 0
jc.wallet
.sendEth(to, amount)
.sendEth(to, amount, estimate)
.then((result) => {
jsb.jcCallback(funId, JSON.stringify({ errcode: 0, data: result }));
})
@ -197,9 +199,10 @@ function erc20Balance(funId, address, account) {
/**
* send ERC20 token to to
*/
function sendErc20(funId, address, to, amount) {
function sendErc20(funId, address, to, amount, estimate) {
estimate = (estimate || '0') | 0
jc.wallet
.sendErc20(address, to, amount)
.sendErc20(address, to, amount, estimate)
.then((result) => {
jsb.jcCallback(funId, JSON.stringify({ errcode: 0, data: result }));
})
@ -208,6 +211,39 @@ function sendErc20(funId, address, to, amount) {
});
}
/**
* send ERC721 NFT to to
*/
function sendErc721(funId, address, to, tokenId, estimate) {
estimate = (estimate || '0') | 0
jc.wallet
.sendNFT(address, to, tokenId, estimate)
.then((result) => {
jsb.jcCallback(funId, JSON.stringify({ errcode: 0, data: result }));
})
.catch((err) => {
jsb.jcCallback(funId, JSON.stringify({ errcode: 1, errmsg: err }));
});
}
/**
* send ERC1155 to to
*/
function sendErc1155(funId, address, to, tokenIds, amounts, estimate) {
tokenIds = JSON.parse(tokenIds);
amounts = JSON.parse(amounts);
estimate = (estimate || '0') | 0
jc.wallet
.sendErc1155(address, to, tokenIds, amounts, estimate)
.then((result) => {
jsb.jcCallback(funId, JSON.stringify({ errcode: 0, data: result }));
})
.catch((err) => {
jsb.jcCallback(funId, JSON.stringify({ errcode: 1, errmsg: err }));
});
}
function showQRCode(funId, content) {
try {
jsb.showQRCode(funId, content);