Skip to content

Conversation

@arcoraven
Copy link
Contributor

@arcoraven arcoraven commented Oct 28, 2024

PR-Codex overview

This PR focuses on refactoring the webhook handling for wallet balance notifications. It introduces a new type BackendWalletBalanceWebhookParams, modifies existing webhook event processing, and implements a mechanism to notify when the wallet balance is low.

Detailed summary

  • Renamed WalletBalanceWebhookSchema to BackendWalletBalanceWebhookParams.
  • Updated sendWebhookWorker.ts to handle WebhooksEventTypes.BACKEND_WALLET_BALANCE.
  • Added _enqueueBackendWalletBalanceWebhook method in SendWebhookQueue.
  • Implemented _notifyIfLowBalance in mineTransactionWorker to check and notify low wallet balances.
  • Removed the old sendBalanceWebhook function in webhook.ts.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

}
};

// TODO: Add retry logic upto
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was legacy from v1 and unused. Migrated to v2 queues and trigger it from mineTransactionWorker

walletAddress: getAddress(resultTransaction.from),
},
});
logger({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing unneeded logging.

const _notifyIfLowBalance = async (transaction: MinedTransaction) => {
const { isUserOp, chainId, from } = transaction;
if (isUserOp) {
// Skip for userOps since they may not use the wallet's gas balance.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't infinigods use smart wallet transactions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UserOps are primarily gas sponsored via Engine.
This check is useful for users sending non userOp transactions from backend wallets, which they're using too.

@arcoraven arcoraven merged commit 8c12183 into main Oct 30, 2024
@arcoraven arcoraven deleted the ph/fixLowWalletBalance branch October 30, 2024 02:44
@dcapitator
Copy link

dcapitator commented Oct 31, 2024

The wallet balance webhook is built to serve a case were we have few wallets or all the backend wallets are used to process arbitrary transactions.

What if we have thousands and we only want to listen to funding wallets or only wallets used for gasless Txs ??

Can that feature be considered ? Instead of listening to all backend wallets then we have an array of wallets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants