@stardust-collective/dag4-xchain-ethereum
Advanced tools
Comparing version 0.1.13 to 0.1.14
@@ -74,2 +74,3 @@ "use strict"; | ||
this.provider = null; | ||
this.lastBlock = null; | ||
} | ||
@@ -76,0 +77,0 @@ async getTokenBalances() { |
@@ -21,2 +21,5 @@ "use strict"; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -27,2 +30,3 @@ exports.XChainEthClient = exports.utils = void 0; | ||
const token_contract_service_1 = require("./token-contract-service"); | ||
const erc_20_abi_1 = __importDefault(require("erc-20-abi")); | ||
const utils = __importStar(require("@xchainjs/xchain-util")); | ||
@@ -39,2 +43,12 @@ exports.utils = utils; | ||
} | ||
async estimateTokenTransferGasLimit(recipient, contractAddress, txAmount, defaultValue) { | ||
try { | ||
const contract = new ethers_1.ethers.Contract(contractAddress, erc_20_abi_1.default, this.getProvider()); | ||
const gasLimit = await contract.estimateGas.transfer(recipient, txAmount, { from: this.getAddress() }); | ||
return gasLimit.toNumber(); | ||
} | ||
catch (e) { | ||
return defaultValue; | ||
} | ||
} | ||
isValidEthereumAddress(address) { | ||
@@ -41,0 +55,0 @@ return ethers_1.ethers.utils.isAddress(address); |
@@ -71,2 +71,3 @@ import { ethers } from 'ethers'; | ||
this.provider = null; | ||
this.lastBlock = null; | ||
} | ||
@@ -73,0 +74,0 @@ async getTokenBalances() { |
import { BigNumber, ethers, FixedNumber } from 'ethers'; | ||
import { Client } from '@xchainjs/xchain-ethereum'; | ||
import { tokenContractService } from './token-contract-service'; | ||
import ERC_20_ABI from 'erc-20-abi'; | ||
import * as utils from '@xchainjs/xchain-util'; | ||
@@ -15,2 +16,12 @@ export { utils }; | ||
} | ||
async estimateTokenTransferGasLimit(recipient, contractAddress, txAmount, defaultValue) { | ||
try { | ||
const contract = new ethers.Contract(contractAddress, ERC_20_ABI, this.getProvider()); | ||
const gasLimit = await contract.estimateGas.transfer(recipient, txAmount, { from: this.getAddress() }); | ||
return gasLimit.toNumber(); | ||
} | ||
catch (e) { | ||
return defaultValue; | ||
} | ||
} | ||
isValidEthereumAddress(address) { | ||
@@ -17,0 +28,0 @@ return ethers.utils.isAddress(address); |
{ | ||
"name": "@stardust-collective/dag4-xchain-ethereum", | ||
"version": "0.1.13", | ||
"version": "0.1.14", | ||
"description": "Cross chain communication with Ethereum", | ||
@@ -5,0 +5,0 @@ "author": "Frank Fox", |
import { ExplorerUrl, InfuraCreds } from '@xchainjs/xchain-ethereum'; | ||
import { Network } from '@xchainjs/xchain-client'; | ||
import { ethers } from 'ethers'; | ||
import { BigNumber, ethers } from 'ethers'; | ||
import { Client } from '@xchainjs/xchain-ethereum'; | ||
@@ -17,2 +17,3 @@ import * as utils from '@xchainjs/xchain-util'; | ||
constructor({ network, explorerUrl, privateKey, etherscanApiKey, infuraCreds }: XClientEthParams); | ||
estimateTokenTransferGasLimit(recipient: string, contractAddress: string, txAmount: BigNumber, defaultValue?: number): Promise<number>; | ||
isValidEthereumAddress(address: string): boolean; | ||
@@ -19,0 +20,0 @@ getTransactionCount(address: string, chainId?: number): Promise<number>; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
40082
553