@xchainjs/xchain-evm
Advanced tools
Comparing version 0.3.7 to 0.4.1
@@ -51,2 +51,6 @@ import { Provider, TransactionResponse } from '@ethersproject/abstract-provider'; | ||
/** | ||
* @deprecated this function eventually will be removed use getAddressAsync instead | ||
*/ | ||
getAddress(walletIndex?: number): Address; | ||
/** | ||
* Get the current address. | ||
@@ -62,3 +66,3 @@ * | ||
*/ | ||
getAddress(walletIndex?: number): Address; | ||
getAddressAsync(walletIndex?: number): Promise<Address>; | ||
/** | ||
@@ -65,0 +69,0 @@ * Get etherjs wallet interface. |
@@ -439,2 +439,14 @@ import { BaseXChainClient, Network, FeeOption, checkFeeBounds, standardFeeRates, FeeType } from '@xchainjs/xchain-client'; | ||
/** | ||
* @deprecated this function eventually will be removed use getAddressAsync instead | ||
*/ | ||
getAddress(walletIndex = 0) { | ||
if (walletIndex < 0) { | ||
throw new Error('index must be greater than or equal to zero'); | ||
} | ||
if (!this.hdNode) { | ||
throw new Error('HDNode is not defined. Make sure phrase has been provided.'); | ||
} | ||
return this.hdNode.derivePath(this.getFullDerivationPath(walletIndex)).address.toLowerCase(); | ||
} | ||
/** | ||
* Get the current address. | ||
@@ -450,10 +462,6 @@ * | ||
*/ | ||
getAddress(walletIndex = 0) { | ||
if (walletIndex < 0) { | ||
throw new Error('index must be greater than or equal to zero'); | ||
} | ||
if (!this.hdNode) { | ||
throw new Error('HDNode is not defined. Make sure phrase has been provided.'); | ||
} | ||
return this.hdNode.derivePath(this.getFullDerivationPath(walletIndex)).address.toLowerCase(); | ||
getAddressAsync(walletIndex = 0) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.getAddress(walletIndex); | ||
}); | ||
} | ||
@@ -578,3 +586,3 @@ /** | ||
const filteredParams = { | ||
address: (params === null || params === void 0 ? void 0 : params.address) || this.getAddress(), | ||
address: (params === null || params === void 0 ? void 0 : params.address) || (yield this.getAddressAsync()), | ||
offset: params === null || params === void 0 ? void 0 : params.offset, | ||
@@ -681,3 +689,3 @@ limit: params === null || params === void 0 ? void 0 : params.limit, | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const sender = this.getAddress(walletIndex || 0); | ||
const sender = yield this.getAddressAsync(walletIndex || 0); | ||
const gasPrice = BigNumber.from((yield this.estimateGasPrices().then((prices) => prices[feeOption])) | ||
@@ -848,2 +856,14 @@ // .catch(() => getDefaultGasPrices()[feeOption]) | ||
} | ||
try { | ||
const gasPrice = yield this.getProvider().getGasPrice(); | ||
// x2 and x10 is too abusive | ||
return { | ||
[FeeOption.Average]: baseAmount(gasPrice.toNumber(), this.gasAssetDecimals), | ||
[FeeOption.Fast]: baseAmount(gasPrice.toNumber() * 1.5, this.gasAssetDecimals), | ||
[FeeOption.Fastest]: baseAmount(gasPrice.toNumber() * 2, this.gasAssetDecimals), | ||
}; | ||
} | ||
catch (error) { | ||
console.warn(`Can not get gasPrice from provider: ${error}`); | ||
} | ||
} | ||
@@ -870,5 +890,5 @@ // If chain data providers fail, THORCHAIN as fallback | ||
return { | ||
[FeeOption.Average]: baseAmount(defaultRatesInGwei[FeeOption.Average] * Math.pow(10, 9), this.gasAssetDecimals), | ||
[FeeOption.Fast]: baseAmount(defaultRatesInGwei[FeeOption.Fast] * Math.pow(10, 9), this.gasAssetDecimals), | ||
[FeeOption.Fastest]: baseAmount(defaultRatesInGwei[FeeOption.Fastest] * Math.pow(10, 9), this.gasAssetDecimals), | ||
[FeeOption.Average]: baseAmount(defaultRatesInGwei[FeeOption.Average], this.gasAssetDecimals), | ||
[FeeOption.Fast]: baseAmount(defaultRatesInGwei[FeeOption.Fast], this.gasAssetDecimals), | ||
[FeeOption.Fastest]: baseAmount(defaultRatesInGwei[FeeOption.Fastest], this.gasAssetDecimals), | ||
}; | ||
@@ -898,3 +918,3 @@ }); | ||
gasEstimate = yield contract.estimateGas.transfer(recipient, txAmount, { | ||
from: from || this.getAddress(), | ||
from: from || (yield this.getAddressAsync()), | ||
}); | ||
@@ -905,3 +925,3 @@ } | ||
const transactionRequest = { | ||
from: from || this.getAddress(), | ||
from: from || (yield this.getAddressAsync()), | ||
to: recipient, | ||
@@ -908,0 +928,0 @@ value: txAmount, |
@@ -443,2 +443,14 @@ 'use strict'; | ||
/** | ||
* @deprecated this function eventually will be removed use getAddressAsync instead | ||
*/ | ||
getAddress(walletIndex = 0) { | ||
if (walletIndex < 0) { | ||
throw new Error('index must be greater than or equal to zero'); | ||
} | ||
if (!this.hdNode) { | ||
throw new Error('HDNode is not defined. Make sure phrase has been provided.'); | ||
} | ||
return this.hdNode.derivePath(this.getFullDerivationPath(walletIndex)).address.toLowerCase(); | ||
} | ||
/** | ||
* Get the current address. | ||
@@ -454,10 +466,6 @@ * | ||
*/ | ||
getAddress(walletIndex = 0) { | ||
if (walletIndex < 0) { | ||
throw new Error('index must be greater than or equal to zero'); | ||
} | ||
if (!this.hdNode) { | ||
throw new Error('HDNode is not defined. Make sure phrase has been provided.'); | ||
} | ||
return this.hdNode.derivePath(this.getFullDerivationPath(walletIndex)).address.toLowerCase(); | ||
getAddressAsync(walletIndex = 0) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.getAddress(walletIndex); | ||
}); | ||
} | ||
@@ -582,3 +590,3 @@ /** | ||
const filteredParams = { | ||
address: (params === null || params === void 0 ? void 0 : params.address) || this.getAddress(), | ||
address: (params === null || params === void 0 ? void 0 : params.address) || (yield this.getAddressAsync()), | ||
offset: params === null || params === void 0 ? void 0 : params.offset, | ||
@@ -685,3 +693,3 @@ limit: params === null || params === void 0 ? void 0 : params.limit, | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const sender = this.getAddress(walletIndex || 0); | ||
const sender = yield this.getAddressAsync(walletIndex || 0); | ||
const gasPrice = ethers.BigNumber.from((yield this.estimateGasPrices().then((prices) => prices[feeOption])) | ||
@@ -852,2 +860,14 @@ // .catch(() => getDefaultGasPrices()[feeOption]) | ||
} | ||
try { | ||
const gasPrice = yield this.getProvider().getGasPrice(); | ||
// x2 and x10 is too abusive | ||
return { | ||
[xchainClient.FeeOption.Average]: xchainUtil.baseAmount(gasPrice.toNumber(), this.gasAssetDecimals), | ||
[xchainClient.FeeOption.Fast]: xchainUtil.baseAmount(gasPrice.toNumber() * 1.5, this.gasAssetDecimals), | ||
[xchainClient.FeeOption.Fastest]: xchainUtil.baseAmount(gasPrice.toNumber() * 2, this.gasAssetDecimals), | ||
}; | ||
} | ||
catch (error) { | ||
console.warn(`Can not get gasPrice from provider: ${error}`); | ||
} | ||
} | ||
@@ -874,5 +894,5 @@ // If chain data providers fail, THORCHAIN as fallback | ||
return { | ||
[xchainClient.FeeOption.Average]: xchainUtil.baseAmount(defaultRatesInGwei[xchainClient.FeeOption.Average] * Math.pow(10, 9), this.gasAssetDecimals), | ||
[xchainClient.FeeOption.Fast]: xchainUtil.baseAmount(defaultRatesInGwei[xchainClient.FeeOption.Fast] * Math.pow(10, 9), this.gasAssetDecimals), | ||
[xchainClient.FeeOption.Fastest]: xchainUtil.baseAmount(defaultRatesInGwei[xchainClient.FeeOption.Fastest] * Math.pow(10, 9), this.gasAssetDecimals), | ||
[xchainClient.FeeOption.Average]: xchainUtil.baseAmount(defaultRatesInGwei[xchainClient.FeeOption.Average], this.gasAssetDecimals), | ||
[xchainClient.FeeOption.Fast]: xchainUtil.baseAmount(defaultRatesInGwei[xchainClient.FeeOption.Fast], this.gasAssetDecimals), | ||
[xchainClient.FeeOption.Fastest]: xchainUtil.baseAmount(defaultRatesInGwei[xchainClient.FeeOption.Fastest], this.gasAssetDecimals), | ||
}; | ||
@@ -902,3 +922,3 @@ }); | ||
gasEstimate = yield contract.estimateGas.transfer(recipient, txAmount, { | ||
from: from || this.getAddress(), | ||
from: from || (yield this.getAddressAsync()), | ||
}); | ||
@@ -909,3 +929,3 @@ } | ||
const transactionRequest = { | ||
from: from || this.getAddress(), | ||
from: from || (yield this.getAddressAsync()), | ||
to: recipient, | ||
@@ -912,0 +932,0 @@ value: txAmount, |
{ | ||
"name": "@xchainjs/xchain-evm", | ||
"version": "0.3.7", | ||
"version": "0.4.1", | ||
"description": "Genereic EVM client for XChainJS", | ||
@@ -37,6 +37,6 @@ "keywords": [ | ||
"devDependencies": { | ||
"@xchainjs/xchain-client": "^0.15.2", | ||
"@xchainjs/xchain-client": "^0.15.3", | ||
"@xchainjs/xchain-crypto": "^0.3.0", | ||
"@xchainjs/xchain-util": "^0.13.1", | ||
"@xchainjs/xchain-evm-providers": "^0.1.2", | ||
"@xchainjs/xchain-evm-providers": "^0.1.3", | ||
"axios": "^1.3.6", | ||
@@ -46,3 +46,3 @@ "ethers": "^5.7.2" | ||
"peerDependencies": { | ||
"@xchainjs/xchain-client": "^0.15.2", | ||
"@xchainjs/xchain-client": "^0.15.3", | ||
"@xchainjs/xchain-crypto": "^0.3.0", | ||
@@ -53,2 +53,2 @@ "@xchainjs/xchain-util": "^0.13.1", | ||
} | ||
} | ||
} |
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
235095
3728