Skip to content

Commit

Permalink
chore: renamed vars
Browse files Browse the repository at this point in the history
Signed-off-by: Logan Nguyen <[email protected]>
  • Loading branch information
quiet-node committed Sep 17, 2024
1 parent 46b980d commit a431881
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
18 changes: 9 additions & 9 deletions packages/relay/src/lib/hbarlimiter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,21 +240,21 @@ export default class HbarLimit {
const fileCreateFeeInCents = constants.NETWORK_FEES_IN_CENTS.FILE_CREATE_PER_5_KB;

// The first chunk goes in with FileCreateTransaciton, the rest are FileAppendTransactions
const fileAppend5kbTransactions = Math.floor(callDataSize / fileChunkSize) - 1;
const fileAppendfinalChunkSize = callDataSize % fileChunkSize;
const fileAppendTransactions = Math.floor(callDataSize / fileChunkSize) - 1;
const lastFileAppendChunkSize = callDataSize % fileChunkSize;

const fileAppendTxFeeInCents_5kb = constants.NETWORK_FEES_IN_CENTS.FILE_APPEND_PER_5_KB;
const fileAppendTxFeeInCents_finalChunk =
const fileAppendFeeInCents = constants.NETWORK_FEES_IN_CENTS.FILE_APPEND_PER_5_KB;
const lastFileAppendChunkFeeInCents =
constants.NETWORK_FEES_IN_CENTS.FILE_APPEND_BASE_FEE +
fileAppendfinalChunkSize * constants.NETWORK_FEES_IN_CENTS.FILE_APPEND_RATE_PER_BYTE;
lastFileAppendChunkSize * constants.NETWORK_FEES_IN_CENTS.FILE_APPEND_RATE_PER_BYTE;

const totalFileTransactionFeeInCents =
const totalTxFeeInCents =
fileCreateTransactions * fileCreateFeeInCents +
fileAppendTxFeeInCents_5kb * fileAppend5kbTransactions +
fileAppendTxFeeInCents_finalChunk;
fileAppendFeeInCents * fileAppendTransactions +
lastFileAppendChunkFeeInCents;

const estimatedTxFee = Math.round(
(totalFileTransactionFeeInCents / currentNetworkExchangeRateInCents) * constants.HBAR_TO_TINYBAR_COEF,
(totalTxFeeInCents / currentNetworkExchangeRateInCents) * constants.HBAR_TO_TINYBAR_COEF,
);

return estimatedTxFee;
Expand Down
20 changes: 9 additions & 11 deletions packages/relay/tests/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -930,22 +930,20 @@ export const estimateFileTransactionsFee = (
const fileCreateFeeInCents = constants.NETWORK_FEES_IN_CENTS.FILE_CREATE_PER_5_KB;

// The first chunk goes in with FileCreateTransaciton, the rest are FileAppendTransactions
const fileAppend5kbTransactions = Math.floor(callDataSize / fileChunkSize) - 1;
const fileAppendfinalChunkSize = callDataSize % fileChunkSize;
const fileAppendTransactions = Math.floor(callDataSize / fileChunkSize) - 1;
const lastFileAppendChunkSize = callDataSize % fileChunkSize;

const fileAppendTxFeeInCents_5kb = constants.NETWORK_FEES_IN_CENTS.FILE_APPEND_PER_5_KB;
const fileAppendTxFeeInCents_finalChunk =
const fileAppendFeeInCents = constants.NETWORK_FEES_IN_CENTS.FILE_APPEND_PER_5_KB;
const lastFileAppendChunkFeeInCents =
constants.NETWORK_FEES_IN_CENTS.FILE_APPEND_BASE_FEE +
fileAppendfinalChunkSize * constants.NETWORK_FEES_IN_CENTS.FILE_APPEND_RATE_PER_BYTE;
lastFileAppendChunkSize * constants.NETWORK_FEES_IN_CENTS.FILE_APPEND_RATE_PER_BYTE;

const totalFileTransactionFeeInCents =
const totalTxFeeInCents =
fileCreateTransactions * fileCreateFeeInCents +
fileAppendTxFeeInCents_5kb * fileAppend5kbTransactions +
fileAppendTxFeeInCents_finalChunk;
fileAppendFeeInCents * fileAppendTransactions +
lastFileAppendChunkFeeInCents;

const estimatedTxFee = Math.round(
(totalFileTransactionFeeInCents / exchangeRateInCents) * constants.HBAR_TO_TINYBAR_COEF,
);
const estimatedTxFee = Math.round((totalTxFeeInCents / exchangeRateInCents) * constants.HBAR_TO_TINYBAR_COEF);

return estimatedTxFee;
};

0 comments on commit a431881

Please sign in to comment.