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 endpoints for solana waitlist #2761

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

clD11
Copy link
Contributor

@clD11 clD11 commented Feb 12, 2025

Summary

This PR implements two endpoints so users can add and remove themselves to a Solana waitlist.

Users who are already linked to Solana should not be able to add themselves to the waitlist.

Closes #2762

Type of Change

  • Product feature
  • Bug fix
  • Performance improvement
  • Refactor
  • Other

Tested Environments

  • Development
  • Staging
  • Production

Before Requesting Review

  • Does your code build cleanly without any errors or warnings?
  • Have you used auto closing keywords?
  • Have you added tests for new functionality?
  • Have validated query efficiency for new database queries?
  • Have documented new functionality in README or in comments?
  • Have you squashed all intermediate commits?
  • Is there a clear title that explains what the PR does?
  • Have you used intuitive function, variable and other naming?
  • Have you requested security and/or privacy review if needed
  • Have you performed a self review of this PR?

Manual Test Plan

@clD11 clD11 self-assigned this Feb 12, 2025
@clD11 clD11 marked this pull request as ready for review February 12, 2025 11:50
@clD11 clD11 requested a review from jen140 as a code owner February 12, 2025 11:50
Copy link

[puLL-Merge] - brave-intl/bat-go@2761

Description

This PR adds support for a Solana waitlist feature to the bat-go wallet service. It includes new database tables, API endpoints for joining and leaving the waitlist, and various supporting code changes. The changes enable users to register their interest in using Solana functionality before it's fully available.

Changes

Changes

libs/datastore/postgres.go:

  • Updated migration version from 69 to 70

migrations/0070_create_solana_waitlist.down.sql & up.sql:

  • Added SQL scripts to create and drop the solana_waitlist table
  • Table contains payment_id (UUID, primary key) and joined_at (timestamp) columns

services/wallet/datastore.go:

  • Added constant depositProviderSolana
  • Added isSolana() helper method to CustodianLink

services/wallet/handler/handler.go:

  • New file adding Solana handler HTTP endpoints:
    • POST /v3/wallet/solana/waitlist
    • DELETE /v3/wallet/solana/waitlist/{paymentID}

services/wallet/service.go:

  • Added Solana waitlist repository interface and functionality
  • Added waitlist service methods SolanaAddToWaitlist and SolanaDeleteFromWaitlist
  • Updated route registration to include new Solana endpoints

services/wallet/storage/storage.go:

  • Added SolanaWaitlist type with methods for inserting and deleting waitlist entries
  • Added helper isUniqueConstraintViolation for handling unique constraint errors
sequenceDiagram
    participant Client
    participant API
    participant Service
    participant Database

    %% Join waitlist
    Client->>API: POST /v3/wallet/solana/waitlist
    API->>Service: SolanaAddToWaitlist()
    Service->>Database: Check if already linked
    Service->>Database: Insert into solana_waitlist
    Database-->>Service: Success/Error
    Service-->>API: Response
    API-->>Client: 201 Created / Error

    %% Leave waitlist  
    Client->>API: DELETE /v3/wallet/solana/waitlist/{id}
    API->>Service: SolanaDeleteFromWaitlist()
    Service->>Database: Delete from solana_waitlist
    Database-->>Service: Success/Error
    Service-->>API: Response
    API-->>Client: 200 OK / Error
Loading

suite.Require().NoError(err, "Failed to get postgres conn")

for _, table := range tables {
_, err = pg.RawDB().Exec("delete from " + table)

Choose a reason for hiding this comment

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

reported by reviewdog 🐶
[semgrep] String-formatted SQL query detected. This could lead to SQL injection if the string is not sanitized properly. Audit this call to ensure the SQL is not manipulable by external data.

Source: https://semgrep.dev/r/go.lang.security.audit.database.string-formatted-query.string-formatted-query


Cc @thypon @kdenhartog

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Test code that has been around for ages, file was renamed hence why its coming up now.

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

Successfully merging this pull request may close these issues.

Implement Solana waitlist feature
4 participants