blockchain33
Advanced tools
Comparing version 0.0.49 to 0.0.50
@@ -134,2 +134,3 @@ import "reflect-metadata"; | ||
getBalanceEth(net: NET | number, address: string): Promise<number>; | ||
getTransactionsCount(net: NET | number, privateKey: string): Promise<number>; | ||
getAddressFromPrivateKey(netId: number, privateKey: string): string; | ||
@@ -136,0 +137,0 @@ getProvider<T>(net: NET | number, privateKey?: string): T; |
@@ -297,2 +297,11 @@ "use strict"; | ||
} | ||
getTransactionsCount(net, privateKey) { | ||
if (Number.isInteger(net)) | ||
net = this.getNet(net); | ||
else | ||
net = net; | ||
const provider = this.getProvider(net.id); | ||
const signer = new ethers_1.Wallet(privateKey, provider); | ||
return signer.getTransactionCount("pending"); | ||
} | ||
getAddressFromPrivateKey(netId, privateKey) { | ||
@@ -494,5 +503,6 @@ const config = this.getConfig(netId); | ||
const gasPrice = await this.getGasPrice(net); | ||
const nonce = await this.getTransactionsCount(net, privateKey); | ||
if (!deadline) | ||
deadline = new Date().getTime(); | ||
return this.getLimitter(net).schedule(() => contract.swapETHForExactTokens(amountOut, path, to, deadline, { value, gasPrice })); | ||
return this.getLimitter(net).schedule(() => contract.swapETHForExactTokens(amountOut, path, to, deadline, { value, gasPrice, nonce })); | ||
} | ||
@@ -502,5 +512,6 @@ async swapExactETHForTokens(net, privateKey, value, amountOutMin, path, to, deadline, router = net_i_1.SwapRouterVersion.UNISWAP_V2) { | ||
const gasPrice = await this.getGasPrice(net); | ||
const nonce = await this.getTransactionsCount(net, privateKey); | ||
if (!deadline) | ||
deadline = new Date().getTime(); | ||
return this.getLimitter(net).schedule(() => contract.swapExactETHForTokens(amountOutMin, path, to, deadline, { value, gasPrice })); | ||
return this.getLimitter(net).schedule(() => contract.swapExactETHForTokens(amountOutMin, path, to, deadline, { value, gasPrice, nonce })); | ||
} | ||
@@ -510,5 +521,6 @@ async swapExactTokensForTokens(net, privateKey, amountIn, amountOutMin, path, to, deadline, router = net_i_1.SwapRouterVersion.UNISWAP_V2) { | ||
const gasPrice = await this.getGasPrice(net); | ||
const nonce = await this.getTransactionsCount(net, privateKey); | ||
if (!deadline) | ||
deadline = new Date().getTime(); | ||
return this.getLimitter(net).schedule(() => contract.swapExactTokensForTokens(amountIn, amountOutMin, path, to, deadline, { gasPrice })); | ||
return this.getLimitter(net).schedule(() => contract.swapExactTokensForTokens(amountIn, amountOutMin, path, to, deadline, { gasPrice, nonce })); | ||
} | ||
@@ -518,5 +530,6 @@ async swapExactTokensForTokensSupportingFeeOnTransferTokens(net, privateKey, amountIn, amountOutMin, path, to, deadline, router = net_i_1.SwapRouterVersion.UNISWAP_V2) { | ||
const gasPrice = await this.getGasPrice(net); | ||
const nonce = await this.getTransactionsCount(net, privateKey); | ||
if (!deadline) | ||
deadline = new Date().getTime(); | ||
return this.getLimitter(net).schedule(() => contract.swapExactTokensForTokensSupportingFeeOnTransferTokens(amountIn, amountOutMin, path, to, deadline, { gasPrice })); | ||
return this.getLimitter(net).schedule(() => contract.swapExactTokensForTokensSupportingFeeOnTransferTokens(amountIn, amountOutMin, path, to, deadline, { gasPrice, nonce })); | ||
} | ||
@@ -526,5 +539,6 @@ async swapTokensForExactTokens(net, privateKey, amountOut, amountInMax, path, to, deadline, router = net_i_1.SwapRouterVersion.UNISWAP_V2) { | ||
const gasPrice = await this.getGasPrice(net); | ||
const nonce = await this.getTransactionsCount(net, privateKey); | ||
if (!deadline) | ||
deadline = new Date().getTime(); | ||
return this.getLimitter(net).schedule(() => contract.swapTokensForExactTokens(amountOut, amountInMax, path, to, deadline, { gasPrice })); | ||
return this.getLimitter(net).schedule(() => contract.swapTokensForExactTokens(amountOut, amountInMax, path, to, deadline, { gasPrice, nonce })); | ||
} | ||
@@ -534,5 +548,6 @@ async swapTokensForExactETH(net, privateKey, amountOut, amountInMax, path, to, deadline, router = net_i_1.SwapRouterVersion.UNISWAP_V2) { | ||
const gasPrice = await this.getGasPrice(net); | ||
const nonce = await this.getTransactionsCount(net, privateKey); | ||
if (!deadline) | ||
deadline = new Date().getTime(); | ||
return this.getLimitter(net).schedule(() => contract.swapTokensForExactETH(amountOut, amountInMax, path, to, deadline, { gasPrice })); | ||
return this.getLimitter(net).schedule(() => contract.swapTokensForExactETH(amountOut, amountInMax, path, to, deadline, { gasPrice, nonce })); | ||
} | ||
@@ -542,5 +557,6 @@ async swapExactTokensForETH(net, privateKey, amountIn, amountOutMin, path, to, deadline, router = net_i_1.SwapRouterVersion.UNISWAP_V2) { | ||
const gasPrice = await this.getGasPrice(net); | ||
const nonce = await this.getTransactionsCount(net, privateKey); | ||
if (!deadline) | ||
deadline = new Date().getTime(); | ||
return this.getLimitter(net).schedule(() => contract.swapExactTokensForETH(amountIn, amountOutMin, path, to, deadline, { gasPrice })); | ||
return this.getLimitter(net).schedule(() => contract.swapExactTokensForETH(amountIn, amountOutMin, path, to, deadline, { gasPrice, nonce })); | ||
} | ||
@@ -569,2 +585,3 @@ async getAllowance(net, tokenAddress, ownerAddress, spenderAddress) { | ||
const gasPrice = await this.getGasPrice(net); | ||
const nonce = await this.getTransactionsCount(net, privateKey); | ||
const limitter = this.getLimitter(net.id); | ||
@@ -579,3 +596,4 @@ if (net.symbol === net_i_1.Symbol.TRX) { | ||
const contract = new ethers_1.Contract(tokenAddress, erc20_1.default, wallet); | ||
return await limitter.schedule(() => contract.approve(spender, amount, { gasPrice })); | ||
return await limitter.schedule(() => contract.approve(spender, amount, { gasPrice, nonce | ||
})); | ||
} | ||
@@ -582,0 +600,0 @@ } |
@@ -11,3 +11,3 @@ { | ||
], | ||
"version": "0.0.49", | ||
"version": "0.0.50", | ||
"description": "utilities for All blockchain like EVM (ETH)", | ||
@@ -14,0 +14,0 @@ "main": "dist/blockchain.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
572510
5585