diff --git a/CHANGELOG.md b/CHANGELOG.md index ad410852..145b2755 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- added: `EdgeStreamTransactionOptions.spamThreshold`. + ## 2.12.0 (2024-08-12) - added: `EdgeCurrencyEngine.otherMethodsWithKeys`. These methods will be added to `EdgeCurrencyEngine.otherMethods`, but the core will insert private keys as the first parameter. diff --git a/src/core/currency/wallet/currency-wallet-api.ts b/src/core/currency/wallet/currency-wallet-api.ts index 663f8b96..0c2aef27 100644 --- a/src/core/currency/wallet/currency-wallet-api.ts +++ b/src/core/currency/wallet/currency-wallet-api.ts @@ -1,4 +1,4 @@ -import { div, eq, mul } from 'biggystring' +import { abs, div, eq, lt, mul } from 'biggystring' import { Disklet } from 'disklet' import { base64 } from 'rfc4648' import { bridgifyObject, onMethod, watchMethod } from 'yaob' @@ -251,6 +251,7 @@ export function makeCurrencyWalletApi( beforeDate, firstBatchSize = batchSize, searchString, + spamThreshold = '0', tokenId = null } = opts const { currencyCode } = @@ -326,6 +327,7 @@ export function makeCurrencyWalletApi( const edgeTx = combineTxWithFile(input, tx, file, tokenId) if (!searchStringFilter(ai, edgeTx, searchString)) continue if (!dateFilter(edgeTx, afterDate, beforeDate)) continue + if (!tx.isSend && lt(abs(nativeAmount), spamThreshold)) continue out.push(edgeTx) } @@ -339,7 +341,12 @@ export function makeCurrencyWalletApi( async getTransactions( opts: EdgeGetTransactionsOptions ): Promise { - const { endDate: beforeDate, startDate: afterDate, searchString } = opts + const { + endDate: beforeDate, + startDate: afterDate, + searchString, + spamThreshold + } = opts const upgradedCurrency = upgradeCurrencyCode({ allTokens: input.props.state.accounts[accountId].allTokens[pluginId], currencyInfo: plugin.currencyInfo, @@ -350,7 +357,8 @@ export function makeCurrencyWalletApi( ...upgradedCurrency, afterDate, beforeDate, - searchString + searchString, + spamThreshold }) // We have no length, so iterate to get everything: diff --git a/src/types/types.ts b/src/types/types.ts index 65c4b008..b863bace 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -791,6 +791,7 @@ export interface EdgeGetTransactionsOptions { startDate?: Date endDate?: Date searchString?: string + spamThreshold?: string tokenId: EdgeTokenId } @@ -816,6 +817,9 @@ export interface EdgeStreamTransactionOptions { /** Only return transactions matching this string */ searchString?: string + /** Filter incoming transactions with a `nativeAmount` below this */ + spamThreshold?: string + /** The token to query, or undefined for the main currency */ tokenId: EdgeTokenId }