Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add wallet history (transactions, balances) to coinbase providers #658

Merged
merged 3 commits into from
Nov 29, 2024

Conversation

monilpat
Copy link
Collaborator

@monilpat monilpat commented Nov 28, 2024


Relates to:

Enhance Providers with Wallet History (Transactions and Balances)

Risks

Low.

  • The new functionality fetches and formats wallet balances and transactions.
  • Possible risks include:
    • Increased response time for providers due to the added API calls.
    • Dependency on the Coinbase SDK for accurate data retrieval.

Background

What does this PR do?

This PR enhances the massPayoutProvider, tradeProvider, and chargeProvider to include wallet balances and recent transactions in their responses. Additionally:

  1. A reusable utility function getWalletDetails is introduced to:
    • Fetch wallet balances.
    • Retrieve recent wallet transactions.
    • Format and return this data.
  2. The getAssetType helper function is added to determine the asset type (e.g., ETH, USDC) for transactions.

What kind of change is this?

Feature (non-breaking change which adds functionality)
This PR extends existing providers to include wallet details, making them more informative and versatile.

Why are we doing this? Any context or related work?

This enhancement allows users to:

  • View current wallet balances alongside provider data (e.g., payouts, trades, or charges).
  • Understand recent wallet activity, including transaction timestamps, asset types, and statuses.
    The goal is to provide a unified source of wallet-related insights within each provider.

Documentation changes needed?

Yes.
The functionality of the affected providers now includes wallet details. The documentation should reflect:

  1. Input parameters: No changes required.
  2. Output: Providers now return wallet balances and recent transactions in addition to their existing data.

Testing

Where should a reviewer start?

  1. Review the getWalletDetails function in utils.ts for implementation details.
  2. Check the updated massPayoutProvider, tradeProvider, and chargeProvider for integration of wallet details.

Detailed testing steps

  1. Configure the Coinbase SDK with a valid wallet and network (e.g., Ethereum mainnet).
  2. Call the following providers:
    • massPayoutProvider.get()
    • tradeProvider.get()
    • chargeProvider.get()
  3. Verify:
    • Balances include correct asset types and amounts.
    • Transactions include valid timestamps, asset types, statuses, and URLs.
    • Original provider data (e.g., CSV records, charges, or trades) remains unaffected.
  4. Test scenarios with:
    • Wallets containing no balances or transactions.
    • Wallets with multiple assets.
  5. Edge cases:
    • Unsupported networks or invalid wallet configurations.
    • Handling of unknown token types in getAssetType.

Screenshots

Before

massPayoutProvider Output:

{
  "csvRecords": [
    {
      "address": "0x123...",
      "amount": 0.01,
      "status": "Success",
      "errorCode": "",
      "transactionUrl": "https://etherscan.io/tx/0x..."
    }
  ]
}

After

massPayoutProvider Output:

{
  "csvRecords": [
    {
      "address": "0x123...",
      "amount": 0.01,
      "status": "Success",
      "errorCode": "",
      "transactionUrl": "https://etherscan.io/tx/0x..."
    }
  ],
  "balances": [
    { "asset": "ETH", "amount": "1.23" },
    { "asset": "USDC", "amount": "500.45" }
  ],
  "transactionHistory": [
    {
      "timestamp": "2024-11-26T14:15:22Z",
      "amount": "100",
      "asset": "USDC",
      "status": "Completed",
      "transactionUrl": "https://etherscan.io/tx/0x..."
    }
  ]
}
Screenshot 2024-11-28 at 2 13 08 PM

Deploy Notes

No special deployment steps are required. Ensure:

  • The Coinbase SDK is configured correctly with API keys and secrets.
  • The environment supports the required network IDs.

Database changes

None.

Deployment instructions

Standard deployment.

@monilpat monilpat marked this pull request as ready for review November 28, 2024 22:26
@lalalune lalalune merged commit 62e7417 into elizaOS:main Nov 29, 2024
2 checks passed
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.

2 participants