Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: replaced HbarLimit module with the new HbarLimitService class (#…
…3110) * feat: replaced HbarLimit module with the new HbarLimitService class (#3024) * fix: converted constant HBAR_RATE_LIMIT_DURATION from var into function Signed-off-by: Logan Nguyen <[email protected]> * chore: added jsdoc to private vars in hapiService module Signed-off-by: Logan Nguyen <[email protected]> * feat: initialized an instance of HbarLimitService in relay.ts Signed-off-by: Logan Nguyen <[email protected]> * feat: integrated HbarLimitService instance into HapiService class Signed-off-by: Logan Nguyen <[email protected]> * feat: integrated HbarLimitService instance into SDKClient class Signed-off-by: Logan Nguyen <[email protected]> * feat: integrated HbarLimitService instance into MetricService class Signed-off-by: Logan Nguyen <[email protected]> * fix: modified addExpense to turn ethAddress to be optional Some queries like getAccountInfo, getBalanceInfo, FileContentsQuery, etc. also add expense to remainingBalance but don't necessarily need to have an originalCaller (ethAddress). Therefore, addExpense can accept nullable ethAddress value. Only when ethAddress or ipAddress is valid, utilize spendingPlan logic. Otherwise, skip completely. Signed-off-by: Logan Nguyen <[email protected]> * feat: added getRemainingBudget() getter Signed-off-by: Logan Nguyen <[email protected]> * feat: added originalCallerAddress to IExecuteTransactionEventPayload and IExecuteQueryEventPayload Signed-off-by: Logan Nguyen <[email protected]> * feat: removed metricService instance in relay Signed-off-by: Logan Nguyen <[email protected]> * feat: replaced hbarLimitter with hbarLimitService in MetricService class Signed-off-by: Logan Nguyen <[email protected]> * fix: added estimateFileTransactionsFee to Utils Signed-off-by: Logan Nguyen <[email protected]> * feat: added txConstructorName and updated log messages for shouldLimit Signed-off-by: Logan Nguyen <[email protected]> * fix: rework logic for estimateFileTransactionsFee Signed-off-by: Logan Nguyen <[email protected]> * feat: removed hbarLimiter instance in SDKClient classes Signed-off-by: Logan Nguyen <[email protected]> * feat: deleted HbarLimit module from codease Signed-off-by: Logan Nguyen <[email protected]> * feat: reverted logic reworked on estimateFileTransactionsFee Signed-off-by: Logan Nguyen <[email protected]> * feat: added preemptive rate limit logic to createFile() method Signed-off-by: Logan Nguyen <[email protected]> * test: updated hbarLimiter.spec.ts Signed-off-by: Logan Nguyen <[email protected]> * fix: added names for child loggers for spending plan repo Signed-off-by: Logan Nguyen <[email protected]> * chore: reverted "feat: added getRemainingBudget() getter" This reverts commit fd9e119 and updated related tests Signed-off-by: Logan Nguyen <[email protected]> * fix: updated log message Signed-off-by: Logan Nguyen <[email protected]> * test: added HBAR_DAILY_LIMIT_BASIC to localTestEnv Signed-off-by: Logan Nguyen <[email protected]> * fix: converted function HBAR_RATE_LIMIT_DURATION from function into var Signed-off-by: Logan Nguyen <[email protected]> * fix: reverted "feat: removed metricService instance in relay" This reverts commit e45c321. Signed-off-by: Logan Nguyen <[email protected]> * chore: updated log message Signed-off-by: Logan Nguyen <[email protected]> * fix: fixed failing test in hapiService Signed-off-by: Logan Nguyen <[email protected]> * fix: reverted ethAddress back to be a required param for addExpense Signed-off-by: Logan Nguyen <[email protected]> * fix: fixed failing test in hapiService.spec.ts Signed-off-by: Logan Nguyen <[email protected]> * fix: loaded env into prcess.env for constant module Signed-off-by: Logan Nguyen <[email protected]> * chore: removed duplicating doc for estimateFileTransactionsFee Signed-off-by: Logan Nguyen <[email protected]> * chore: sort imports Signed-off-by: Victor Yanev <[email protected]> * fix: removed ipAddresses from log in hbarLimitService Signed-off-by: Logan Nguyen <[email protected]> * fix: renamed isDailyBudgetExceeded -> isTotalBudgetExceeded Signed-off-by: Logan Nguyen <[email protected]> * fix: fixed conflicts after rebased Signed-off-by: Logan Nguyen <[email protected]> * fix: fixed acceptance test for exhausting HBAR case Signed-off-by: Logan Nguyen <[email protected]> * fix: renamed HBAR_DAILY_LIMIT_BASIC to HBAR_RATE_LIMIT_BASIC Signed-off-by: Logan Nguyen <[email protected]> * fix: overrode env vars for npm acceptancetest:hbarlimiter script Signed-off-by: Logan Nguyen <[email protected]> * fix: moved logic of adding expenses to totalBudget above hbarSpendingPlan Signed-off-by: Logan Nguyen <[email protected]> --------- Signed-off-by: Logan Nguyen <[email protected]> Signed-off-by: Victor Yanev <[email protected]> Co-authored-by: Victor Yanev <[email protected]> Signed-off-by: Logan Nguyen <[email protected]> * test: create e2e tests for basic spending plan limit (#3104) * Adds acceptance test for BASIC user spending plans Signed-off-by: Konstantina Blazhukova <[email protected]> Fixes failing acceptance test Signed-off-by: Konstantina Blazhukova <[email protected]> Revert accidental deletion of method Signed-off-by: Konstantina Blazhukova <[email protected]> * Fixes CI Signed-off-by: Konstantina Blazhukova <[email protected]> * Fixes failiing acceptance tests and improves setup Signed-off-by: Konstantina Blazhukova <[email protected]> Update hbarLimiter.spec.ts Signed-off-by: Logan Nguyen <[email protected]> * fix: switched back HBAR_RATE_LIMIT_DURATION Signed-off-by: Logan Nguyen <[email protected]> * fix: renamed HBAR_DAILY_LIMIT_BASIC to HBAR_RATE_LIMIT_BASIC Signed-off-by: Logan Nguyen <[email protected]> Update localAcceptance.env Signed-off-by: Logan Nguyen <[email protected]> * fix: fixed hbar limiter test Signed-off-by: Logan Nguyen <[email protected]> * fix: re-ordered test cases Signed-off-by: Logan Nguyen <[email protected]> * Improves test case and skips unecessary one Signed-off-by: Konstantina Blazhukova <[email protected]> * Improves unlinking of ip addresses Signed-off-by: Konstantina Blazhukova <[email protected]> * Revert "chore: remove unnecessary timeouts in tests" This reverts commit f688a4e. Signed-off-by: Konstantina Blazhukova <[email protected]> * Adds new deleteAll method in ipAddressRepository Signed-off-by: Konstantina Blazhukova <[email protected]> * Removes timeouts and adds logic to wait for limiter reset Signed-off-by: Konstantina Blazhukova <[email protected]> * Adds appropriate limits for acceptance tests Signed-off-by: Konstantina Blazhukova <[email protected]> * Adds new variables to .env Signed-off-by: Konstantina Blazhukova <[email protected]> * Improves test setup, removes unneeded limiter reset Signed-off-by: Konstantina Blazhukova <[email protected]> * Removes setting of env from terminal command, adds it to test setup instead Signed-off-by: Konstantina Blazhukova <[email protected]> * Adds necessary timeouts in tests relying on queries to mirror node Signed-off-by: Konstantina Blazhukova <[email protected]> * Fixes import in hbarLimiter spec Signed-off-by: Konstantina Blazhukova <[email protected]> * Removes unused imports, adds const where needed Signed-off-by: Konstantina Blazhukova <[email protected]> * Removes unused method Signed-off-by: Konstantina Blazhukova <[email protected]> * Makes improvements in ipAddressHbarRepo Signed-off-by: Konstantina Blazhukova <[email protected]> * Adds reset timestamp method to test Signed-off-by: Konstantina Blazhukova <[email protected]> * fix: added deleteAll() to EthAddressHbarSpendingPlanRepository class Signed-off-by: Logan Nguyen <[email protected]> * fix: reverted and cleaned up Signed-off-by: Logan Nguyen <[email protected]> * fix: removed duplicated test Signed-off-by: Logan Nguyen <[email protected]> --------- Signed-off-by: Konstantina Blazhukova <[email protected]> Signed-off-by: Logan Nguyen <[email protected]> Signed-off-by: Logan Nguyen <[email protected]> Update hbarLimiter.spec.ts Signed-off-by: Logan Nguyen <[email protected]> Update hbarLimiter.spec.ts Signed-off-by: Logan Nguyen <[email protected]> Co-Authored-By: Logan Nguyen <[email protected]> * chore: added info log after HbarLimiter is successfully configured Signed-off-by: Logan Nguyen <[email protected]> * chore: removed overriden variables in `acceptancetest:hbarlimiter` npm script Signed-off-by: Logan Nguyen <[email protected]> * fix: bumped HBAR_RATE_LIMIT_BASIC to 40 HBARs Signed-off-by: Logan Nguyen <[email protected]> * Shortens and improves logger name for new hbar plan repositories Signed-off-by: Konstantina Blazhukova <[email protected]> --------- Signed-off-by: Logan Nguyen <[email protected]> Signed-off-by: Victor Yanev <[email protected]> Signed-off-by: Konstantina Blazhukova <[email protected]> Co-authored-by: Victor Yanev <[email protected]> Co-authored-by: konstantinabl <[email protected]>
- Loading branch information