|
@@ -4,6 +4,7 @@
|
|
|
*/
|
|
*/
|
|
|
import tools from "@/common/js/tools";
|
|
import tools from "@/common/js/tools";
|
|
|
import {ethers} from "ethers";
|
|
import {ethers} from "ethers";
|
|
|
|
|
+import web3 from "web3";
|
|
|
let tokenpocketBnb = {}
|
|
let tokenpocketBnb = {}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -100,9 +101,12 @@ tokenpocketBnb.getBalance=async function (selectedAddress) {
|
|
|
*/
|
|
*/
|
|
|
tokenpocketBnb.getGasPrice= async function (){
|
|
tokenpocketBnb.getGasPrice= async function (){
|
|
|
let gasPrice =await tokenpocketBnb.getProvider().request({ method: 'eth_gasPrice',params:[]})
|
|
let gasPrice =await tokenpocketBnb.getProvider().request({ method: 'eth_gasPrice',params:[]})
|
|
|
|
|
+ // gasPrice=web3.utils.hexToNumber(gasPrice)
|
|
|
|
|
+ console.log('gasPrice:'+gasPrice)
|
|
|
if(!gasPrice){
|
|
if(!gasPrice){
|
|
|
- gasPrice='0x0'
|
|
|
|
|
|
|
+ gasPrice='0x12a05f200'
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
return gasPrice;
|
|
return gasPrice;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -113,10 +117,11 @@ tokenpocketBnb.getGasPrice= async function (){
|
|
|
*/
|
|
*/
|
|
|
tokenpocketBnb.getEstimateGas= async function (data){
|
|
tokenpocketBnb.getEstimateGas= async function (data){
|
|
|
let estimateGas =await tokenpocketBnb.getProvider().request({ method: 'eth_estimateGas',params:[data]})
|
|
let estimateGas =await tokenpocketBnb.getProvider().request({ method: 'eth_estimateGas',params:[data]})
|
|
|
- console.log('estimateGas:'+estimateGas)
|
|
|
|
|
|
|
+ // estimateGas=web3.utils.hexToNumber(estimateGas)
|
|
|
if(!estimateGas){
|
|
if(!estimateGas){
|
|
|
estimateGas=100000
|
|
estimateGas=100000
|
|
|
}
|
|
}
|
|
|
|
|
+ console.log('estimateGas:',estimateGas)
|
|
|
return estimateGas;
|
|
return estimateGas;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -132,12 +137,13 @@ tokenpocketBnb.getTransactionData=async function (to,money){
|
|
|
data.to=to;
|
|
data.to=to;
|
|
|
data.from=tokenpocketBnb.getMyAddress();
|
|
data.from=tokenpocketBnb.getMyAddress();
|
|
|
data.gasPrice=await tokenpocketBnb.getGasPrice();
|
|
data.gasPrice=await tokenpocketBnb.getGasPrice();
|
|
|
- data.gasLimit=await tokenpocketBnb.getEstimateGas();
|
|
|
|
|
|
|
+ data.gas=await tokenpocketBnb.getEstimateGas();
|
|
|
data.chainId=chainId;
|
|
data.chainId=chainId;
|
|
|
if(tools.isDevelopment()){
|
|
if(tools.isDevelopment()){
|
|
|
- money=0.0001;
|
|
|
|
|
|
|
+ money=0.00001;
|
|
|
}
|
|
}
|
|
|
- data.value=ethers.utils.parseEther(money.toString()).toString();
|
|
|
|
|
|
|
+ console.log(money.toString())
|
|
|
|
|
+ data.value=web3.utils.numberToHex(ethers.utils.parseEther(money.toString()).toString());
|
|
|
console.log('value:'+data.value)
|
|
console.log('value:'+data.value)
|
|
|
return data;
|
|
return data;
|
|
|
}
|
|
}
|
|
@@ -149,6 +155,7 @@ tokenpocketBnb.getTransactionData=async function (to,money){
|
|
|
*/
|
|
*/
|
|
|
tokenpocketBnb.sendTransaction=function (data){
|
|
tokenpocketBnb.sendTransaction=function (data){
|
|
|
return new Promise(async (resolve, reject) => {
|
|
return new Promise(async (resolve, reject) => {
|
|
|
|
|
+ console.log(data)
|
|
|
try {
|
|
try {
|
|
|
let txHash = await tokenpocketBnb.getProvider().request({
|
|
let txHash = await tokenpocketBnb.getProvider().request({
|
|
|
method: 'eth_sendTransaction',
|
|
method: 'eth_sendTransaction',
|