Conversation
9b55194 to
f9c86ae
Compare
f9c86ae to
1932ac3
Compare
| "start.cache": "node -r sucrase/register src/indexCache.ts", | ||
| "start.rates": "node -r sucrase/register src/indexRates.ts", | ||
| "start.api": "node -r sucrase/register src/indexApi.ts", | ||
| "start.destroyPartition": "node -r sucrase/register src/bin/destroyPartition.ts", |
There was a problem hiding this comment.
Optional
I'd argue to keep the colon over the dot as a separator just because colon has become the de facto standard. Not worth being different from the rest of codebases here.
There was a problem hiding this comment.
But they are such a pain to type.
| datelog(e) | ||
| process.exit(1) | ||
| } | ||
| process.exit(0) |
There was a problem hiding this comment.
The reason why this was hanging is because of we don't cleanup the setTimeout in promiseTimeout util. This should be fixed as a separate commit.
src/partners/lifi.ts
Outdated
| try { | ||
| tx = asTransfer(rawTx) | ||
| } catch (e) { | ||
| datelog(e) |
There was a problem hiding this comment.
createScopedLog already logs the date ISO string. So this try-catch is unnecessary.
src/partners/lifi.ts
Outdated
| } | ||
| return standardTx | ||
| } catch (e) { | ||
| datelog(e) |
There was a problem hiding this comment.
Why are we catching just to log and rethrow when createScopedLog is already doing this?
| default: { | ||
| // No token support: | ||
| // these chains don't support tokens | ||
| throw new Error('Tokens are not supported for this chain') |
There was a problem hiding this comment.
| Plugin ID | Token Support Details |
|---|---|
| eos | Has customTokenTemplate - supports custom tokens via contract address |
| telos | Has customTokenTemplate - supports custom tokens via contract address |
| wax | Has customTokenTemplate - supports custom tokens via contract address |
| filecoin | Has customTokenTemplate - supports custom tokens via contract address |
| zano | Has builtinTokens (TALLY, BTCx) and customTokenTemplate for Asset IDs |
These are tokens that Edge may have token support for that will cause this error to through if a transaction is detected with a token. Is that possible? Does the exchange plugins not support token swaps for these chains?
There was a problem hiding this comment.
Yes. Exchange plugins do not support token swaps for the above chains. We want these to error so that we notice a plugin stops synchronizing, and then we could explicitly add support.
| transaction.depositChainPluginId != null && | ||
| transaction.depositTokenId !== undefined && | ||
| transaction.payoutChainPluginId != null && | ||
| transaction.payoutTokenId !== undefined | ||
| ) { | ||
| return await updateTxValuesV3(transaction) | ||
| } | ||
|
|
||
| if ( | ||
| transaction.depositChainPluginId != null && | ||
| transaction.depositTokenId !== undefined && | ||
| isFiatCurrency(transaction.payoutCurrency) | ||
| ) { | ||
| return await updateTxValuesV3(transaction) | ||
| } | ||
|
|
||
| if ( | ||
| isFiatCurrency(transaction.depositCurrency) && | ||
| transaction.payoutChainPluginId != null && | ||
| transaction.payoutTokenId !== undefined | ||
| ) { | ||
| return await updateTxValuesV3(transaction) | ||
| } |
There was a problem hiding this comment.
Why not one if condition that is a disjunction of the three if conditions?
| await setupDatabase(config.couchDbFullpath, setup, options) | ||
| ) | ||
| ) | ||
| if (config.couchUris == null) { |
There was a problem hiding this comment.
If we're going to require couchUris, then make sure there is some default structure in the config? Otherwise, the commit prehook fails because the tests fail.
src/types.ts
Outdated
| }) | ||
|
|
||
| // v3/rates response cleaner (matches GUI's shape) | ||
| const asV3CryptoAsset = asObject({ |
There was a problem hiding this comment.
Would like these cleaners to be called asRatesV3*.
Add revolut
Have all plugins just set to undefined for now
1932ac3 to
6de5280
Compare
| if (paymentMethod == null) { | ||
| throw new Error(`Unknown payment method: ${tx.paymentMethod} for ${tx.id}`) | ||
| } | ||
| return paymentMethod |
There was a problem hiding this comment.
Moonpay mobile_wallet case now throws instead of returning null
High Severity
The refactored getFiatPaymentType function has a behavioral regression for the mobile_wallet payment method. When cardType is not 'apple_pay' or 'google_pay' (e.g., it's 'card' or missing), paymentMethod is set to null. The check on line 309 then throws an error for this case. The original implementation would return null without throwing, allowing these transactions to process with a null payment type.
There was a problem hiding this comment.
we want it to throw so the plugin fails, and we properly edit the code to add the new types.
Clear the timeout when the promise resolves or rejects to prevent the process from hanging due to uncancelled timers.
6de5280 to
579527a
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 4 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| body: JSON.stringify(ratesRequest) | ||
| }) | ||
| const ratesResponseJson = await ratesResponse.json() | ||
| const rates = asRatesV3Params(ratesResponseJson) |
There was a problem hiding this comment.
Missing HTTP response validation in V3 rates fetch
Medium Severity
The new updateTxValuesV3 function fetches rates from the V3 API but doesn't check ratesResponse.ok before parsing the response. Unlike the existing V2 getExchangeRate function (lines 379-386) which properly checks for HTTP errors and logs rate limiting, the V3 function proceeds directly to ratesResponse.json() and asRatesV3Params(). When the API returns an error (4xx, 5xx), this produces unhelpful cleaner errors instead of the actual API error message, and rate limiting goes undetected.
| transfers: asArray(asUnknown) | ||
| }) | ||
|
|
||
| type Transfer = ReturnType<typeof asTransfer> |
There was a problem hiding this comment.
| tx.sending.gasToken?.symbol ?? | ||
| depositToken?.coinKey ?? | ||
| depositToken?.symbol | ||
| const payoutChainCodeUnmappped = |
There was a problem hiding this comment.
Typo in variable name with extra letter
Low Severity
The variable payoutChainCodeUnmappped has three 'p's in "Unmapped" instead of two. This is inconsistent with the correctly spelled depositChainCodeUnmapped variable. While functional, this typo makes the code harder to read and search for.
Additional Locations (1)
| : payoutEvmChainId | ||
|
|
||
| const depositTokenType = tokenTypes[depositChainPluginId ?? ''] | ||
| const payoutTokenType = tokenTypes[payoutChainPluginId ?? ''] |
There was a problem hiding this comment.
Unnecessary null coalescing after null guard
Low Severity
Lines 252, 256, 259, and 260 use ?? '' null coalescing on depositChainPluginId and payoutChainPluginId, but these variables are guaranteed to be non-null at this point because lines 244-246 throw an error if either is null. The fallback values can never be reached, making the ?? '' patterns unnecessary.
CHANGELOG
Does this branch warrant an entry to the CHANGELOG?
Dependencies
noneDescription
noneNote
Introduces chain/token metadata and rate-calculation upgrades, plus minor stability/config changes.
StandardTxwithdeposit/payoutChainPluginId,deposit/payoutEvmChainId, anddeposit/payoutTokenId. Update most partners to include these fields;lifinow fully populates them and setspayoutTxidandusdValuecorrectly.ratesEngineusingpluginId/tokenIdviahttps://rates3.edge.app/v3/rates; fallback path uses thev2rates API with improved fiat handling and same-currency short-circuit.orderId;initDbsnow requirescouchUrisand always uses pooled Couch; defaultcouchUrisprovided inconfig.moonpayaddsrevolutpayment type and consolidates mapping;banxaadds ACH mapping.start.*;destroyPartitionexits with codes on success/failure; demo tightens API key check.See
CHANGELOG.mdfor details.Written by Cursor Bugbot for commit 579527a. This will update automatically on new commits. Configure here.