Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Commit

Permalink
Merge pull request #686 from jimni1222/suggestGasPrice
Browse files Browse the repository at this point in the history
Rename function to suggestGasPrice
  • Loading branch information
jimni1222 authored Jul 19, 2022
2 parents 380dadf + 9c5b3c1 commit 1674972
Show file tree
Hide file tree
Showing 26 changed files with 32 additions and 32 deletions.
8 changes: 4 additions & 4 deletions packages/caver-klay/caver-klay-accounts/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,14 +394,14 @@ Accounts.prototype._getRoleKey = function _getRoleKey(tx, account) {
}

/**
* _suggestedGasPrice returns suggested gas price.
* _suggestGasPrice suggests a gas price.
* This function will be used to set gasPrice field if that is omitted.
* Before common architecture does not support newly added transaction types.
*
* @method _suggestedGasPrice
* @method _suggestGasPrice
* @return {string}
*/
Accounts.prototype._suggestedGasPrice = async function _suggestedGasPrice() {
Accounts.prototype._suggestGasPrice = async function _suggestGasPrice() {
const header = await this._klaytnCall.getHeader('latest')
const bf = utils.hexToNumber(header.baseFeePerGas || '0x0')

Expand Down Expand Up @@ -909,7 +909,7 @@ Accounts.prototype.signTransaction = function signTransaction() {
// Otherwise, get the missing info from the Klaytn Node
return Promise.all([
isNot(tx.chainId) ? _this._klaytnCall.getChainId() : tx.chainId,
isNot(tx.gasPrice) ? _this._suggestedGasPrice() : tx.gasPrice,
isNot(tx.gasPrice) ? _this._suggestGasPrice() : tx.gasPrice,
isNot(tx.nonce) ? _this._klaytnCall.getTransactionCount(tx.from, 'pending') : tx.nonce,
]).then(function(args) {
if (isNot(args[0]) || isNot(args[1]) || isNot(args[2])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,17 @@ class AbstractTransaction {
}

/**
* Returns a suggested gas price to use in the transaction.
* Suggests a gas price to use in the transaction.
* If `baseFee` is bigger than `0` in the header,
* then returns `baseFee * 2`.
* If not, calls `klay_gasPrice` to return unit price of the gas.
*
* @example
* const result = await tx.suggestedGasPrice()
* const result = await tx.suggestGasPrice()
*
* @return {string} gas price
*/
async suggestedGasPrice() {
async suggestGasPrice() {
const bfStr = await this.getBaseFee()
const baseFee = utils.hexToNumber(bfStr)

Expand All @@ -196,7 +196,7 @@ class AbstractTransaction {
/**
* Calls `klay_gasPrice` klay rpc call.
* Note that when Klaytn network use dynamic gas fee,
* you need to use `tx.suggestedGasPrice` function in the gasPrice field.
* you need to use `tx.suggestGasPrice` function in the gasPrice field.
*
* @example
* const result = await tx.getGasPrice()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class AccountUpdate extends AbstractTransaction {
async fillTransaction() {
const [chainId, gasPrice, nonce] = await Promise.all([
isNot(this.chainId) ? this.getChainId() : this.chainId,
isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice,
isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice,
isNot(this.nonce) ? this.getNonce(this.from) : this.nonce,
])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class FeeDelegatedAccountUpdate extends AbstractFeeDelegatedTransaction {
async fillTransaction() {
const [chainId, gasPrice, nonce] = await Promise.all([
isNot(this.chainId) ? this.getChainId() : this.chainId,
isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice,
isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice,
isNot(this.nonce) ? this.getNonce(this.from) : this.nonce,
])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class FeeDelegatedAccountUpdateWithRatio extends AbstractFeeDelegatedWithRatioTr
async fillTransaction() {
const [chainId, gasPrice, nonce] = await Promise.all([
isNot(this.chainId) ? this.getChainId() : this.chainId,
isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice,
isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice,
isNot(this.nonce) ? this.getNonce(this.from) : this.nonce,
])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class Cancel extends AbstractTransaction {
async fillTransaction() {
const [chainId, gasPrice, nonce] = await Promise.all([
isNot(this.chainId) ? this.getChainId() : this.chainId,
isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice,
isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice,
isNot(this.nonce) ? this.getNonce(this.from) : this.nonce,
])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class FeeDelegatedCancel extends AbstractFeeDelegatedTransaction {
async fillTransaction() {
const [chainId, gasPrice, nonce] = await Promise.all([
isNot(this.chainId) ? this.getChainId() : this.chainId,
isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice,
isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice,
isNot(this.nonce) ? this.getNonce(this.from) : this.nonce,
])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class FeeDelegatedCancelWithRatio extends AbstractFeeDelegatedWithRatioTransacti
async fillTransaction() {
const [chainId, gasPrice, nonce] = await Promise.all([
isNot(this.chainId) ? this.getChainId() : this.chainId,
isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice,
isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice,
isNot(this.nonce) ? this.getNonce(this.from) : this.nonce,
])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class ChainDataAnchoring extends AbstractTransaction {
async fillTransaction() {
const [chainId, gasPrice, nonce] = await Promise.all([
isNot(this.chainId) ? this.getChainId() : this.chainId,
isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice,
isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice,
isNot(this.nonce) ? this.getNonce(this.from) : this.nonce,
])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class FeeDelegatedChainDataAnchoring extends AbstractFeeDelegatedTransaction {
async fillTransaction() {
const [chainId, gasPrice, nonce] = await Promise.all([
isNot(this.chainId) ? this.getChainId() : this.chainId,
isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice,
isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice,
isNot(this.nonce) ? this.getNonce(this.from) : this.nonce,
])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class FeeDelegatedChainDataAnchoringWithRatio extends AbstractFeeDelegatedWithRa
async fillTransaction() {
const [chainId, gasPrice, nonce] = await Promise.all([
isNot(this.chainId) ? this.getChainId() : this.chainId,
isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice,
isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice,
isNot(this.nonce) ? this.getNonce(this.from) : this.nonce,
])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ class EthereumAccessList extends AbstractTransaction {
async fillTransaction() {
const [chainId, gasPrice, nonce] = await Promise.all([
isNot(this.chainId) ? this.getChainId() : this.chainId,
isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice,
isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice,
isNot(this.nonce) ? this.getNonce(this.from) : this.nonce,
])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ class EthereumDynamicFee extends AbstractTransaction {
isNot(this.chainId) ? this.getChainId() : this.chainId,
isNotMaxPriorityFeePerGas ? this.getMaxPriorityFeePerGas() : this.maxPriorityFeePerGas,
isNot(this.nonce) ? this.getNonce(this.from) : this.nonce,
isNotMaxFeePerGas ? this.suggestedGasPrice() : this.maxFeePerGas,
isNotMaxFeePerGas ? this.suggestGasPrice() : this.maxFeePerGas,
])

this.chainId = chainId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ class LegacyTransaction extends AbstractTransaction {
async fillTransaction() {
const [chainId, gasPrice, nonce] = await Promise.all([
isNot(this.chainId) ? this.getChainId() : this.chainId,
isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice,
isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice,
isNot(this.nonce) ? this.getNonce(this.from) : this.nonce,
])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ class FeeDelegatedSmartContractDeploy extends AbstractFeeDelegatedTransaction {
async fillTransaction() {
const [chainId, gasPrice, nonce] = await Promise.all([
isNot(this.chainId) ? this.getChainId() : this.chainId,
isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice,
isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice,
isNot(this.nonce) ? this.getNonce(this.from) : this.nonce,
])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ class FeeDelegatedSmartContractDeployWithRatio extends AbstractFeeDelegatedWithR
async fillTransaction() {
const [chainId, gasPrice, nonce] = await Promise.all([
isNot(this.chainId) ? this.getChainId() : this.chainId,
isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice,
isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice,
isNot(this.nonce) ? this.getNonce(this.from) : this.nonce,
])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ class SmartContractDeploy extends AbstractTransaction {
async fillTransaction() {
const [chainId, gasPrice, nonce] = await Promise.all([
isNot(this.chainId) ? this.getChainId() : this.chainId,
isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice,
isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice,
isNot(this.nonce) ? this.getNonce(this.from) : this.nonce,
])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class FeeDelegatedSmartContractExecution extends AbstractFeeDelegatedTransaction
async fillTransaction() {
const [chainId, gasPrice, nonce] = await Promise.all([
isNot(this.chainId) ? this.getChainId() : this.chainId,
isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice,
isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice,
isNot(this.nonce) ? this.getNonce(this.from) : this.nonce,
])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class FeeDelegatedSmartContractExecutionWithRatio extends AbstractFeeDelegatedWi
async fillTransaction() {
const [chainId, gasPrice, nonce] = await Promise.all([
isNot(this.chainId) ? this.getChainId() : this.chainId,
isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice,
isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice,
isNot(this.nonce) ? this.getNonce(this.from) : this.nonce,
])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class SmartContractExecution extends AbstractTransaction {
async fillTransaction() {
const [chainId, gasPrice, nonce] = await Promise.all([
isNot(this.chainId) ? this.getChainId() : this.chainId,
isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice,
isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice,
isNot(this.nonce) ? this.getNonce(this.from) : this.nonce,
])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class FeeDelegatedValueTransfer extends AbstractFeeDelegatedTransaction {
async fillTransaction() {
const [chainId, gasPrice, nonce] = await Promise.all([
isNot(this.chainId) ? this.getChainId() : this.chainId,
isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice,
isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice,
isNot(this.nonce) ? this.getNonce(this.from) : this.nonce,
])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class FeeDelegatedValueTransferWithRatio extends AbstractFeeDelegatedWithRatioTr
async fillTransaction() {
const [chainId, gasPrice, nonce] = await Promise.all([
isNot(this.chainId) ? this.getChainId() : this.chainId,
isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice,
isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice,
isNot(this.nonce) ? this.getNonce(this.from) : this.nonce,
])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class ValueTransfer extends AbstractTransaction {
async fillTransaction() {
const [chainId, gasPrice, nonce] = await Promise.all([
isNot(this.chainId) ? this.getChainId() : this.chainId,
isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice,
isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice,
isNot(this.nonce) ? this.getNonce(this.from) : this.nonce,
])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class FeeDelegatedValueTransferMemo extends AbstractFeeDelegatedTransaction {
async fillTransaction() {
const [chainId, gasPrice, nonce] = await Promise.all([
isNot(this.chainId) ? this.getChainId() : this.chainId,
isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice,
isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice,
isNot(this.nonce) ? this.getNonce(this.from) : this.nonce,
])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class FeeDelegatedValueTransferMemoWithRatio extends AbstractFeeDelegatedWithRat
async fillTransaction() {
const [chainId, gasPrice, nonce] = await Promise.all([
isNot(this.chainId) ? this.getChainId() : this.chainId,
isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice,
isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice,
isNot(this.nonce) ? this.getNonce(this.from) : this.nonce,
])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ class ValueTransferMemo extends AbstractTransaction {
async fillTransaction() {
const [chainId, gasPrice, nonce] = await Promise.all([
isNot(this.chainId) ? this.getChainId() : this.chainId,
isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice,
isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice,
isNot(this.nonce) ? this.getNonce(this.from) : this.nonce,
])

Expand Down

0 comments on commit 1674972

Please sign in to comment.