sendEth等方法增加参数, 是否只返回估算的价格
This commit is contained in:
parent
0ca92675fe
commit
df35252185
File diff suppressed because one or more lines are too long
44
js/main.js
44
js/main.js
@ -138,10 +138,12 @@ function getEthBalance(funId, account) {
|
|||||||
* send ETH from current account
|
* send ETH from current account
|
||||||
* @param {string} to: target account
|
* @param {string} to: target account
|
||||||
* @param {string} amount:
|
* @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
|
jc.wallet
|
||||||
.sendEth(to, amount)
|
.sendEth(to, amount, estimate)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
jsb.jcCallback(funId, JSON.stringify({ errcode: 0, data: result }));
|
jsb.jcCallback(funId, JSON.stringify({ errcode: 0, data: result }));
|
||||||
})
|
})
|
||||||
@ -197,9 +199,10 @@ function erc20Balance(funId, address, account) {
|
|||||||
/**
|
/**
|
||||||
* send ERC20 token to to
|
* send ERC20 token to to
|
||||||
*/
|
*/
|
||||||
function sendErc20(funId, address, to, amount) {
|
function sendErc20(funId, address, to, amount, estimate) {
|
||||||
|
estimate = (estimate || '0') | 0
|
||||||
jc.wallet
|
jc.wallet
|
||||||
.sendErc20(address, to, amount)
|
.sendErc20(address, to, amount, estimate)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
jsb.jcCallback(funId, JSON.stringify({ errcode: 0, data: 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) {
|
function showQRCode(funId, content) {
|
||||||
try {
|
try {
|
||||||
jsb.showQRCode(funId, content);
|
jsb.showQRCode(funId, content);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user