Skip to content

SDP 1687 update wallet patch endpoint - #697

Merged
dpohr merged 11 commits into
developfrom
SDP-1687-update-wallet-patch-endpoint
Jun 11, 2025
Merged

SDP 1687 update wallet patch endpoint#697
dpohr merged 11 commits into
developfrom
SDP-1687-update-wallet-patch-endpoint

Conversation

@dpohr

@dpohr dpohr commented Jun 5, 2025

Copy link
Copy Markdown
Contributor

What

Extended the PATCH /wallets/:wallet_id endpoint to support updating all wallet fields (name, homepage, sep_10_client_domain, deep_link_schema, and assets) instead of just the enabled status.

Why

The existing PATCH endpoint only supported toggling the enabled/disabled status of wallets, which was insufficient for comprehensive wallet management.
In case of any changes the only way was to do it is via direct database manipulations, with these PR we will reduce direct DB interactions and extend capabilities of the API

Known limitations

Depends on #696

  • Title follows SDP-1234: Add new feature or Chore: Refactor package xyz format. The Jira ticket code was included if available.
  • PR has a focused scope and doesn't mix features with refactoring
  • Tests are included (if applicable)
  • CHANGELOG.md is updated (if applicable)
  • CONFIG/SECRETS changes are updated in helmcharts and deployments (if applicable)
  • Preview deployment works as expected
  • Ready for production

@dpohr dpohr self-assigned this Jun 5, 2025
@dpohr
dpohr had a problem deploying to Anchor Integration Tests June 5, 2025 13:04 — with GitHub Actions Failure
@dpohr
dpohr temporarily deployed to Receiver Registration - E2E Integration Tests (Stellar) June 5, 2025 13:04 — with GitHub Actions Inactive
@dpohr
dpohr temporarily deployed to Receiver Registration - E2E Integration Tests (Stellar) June 5, 2025 13:05 — with GitHub Actions Inactive
@dpohr
dpohr temporarily deployed to Anchor Integration Tests June 5, 2025 13:05 — with GitHub Actions Inactive
@stellar-jenkins

Copy link
Copy Markdown

Something went wrong with PR preview build please check

@dpohr
dpohr temporarily deployed to Receiver Registration - E2E Integration Tests (Stellar) June 5, 2025 13:11 — with GitHub Actions Inactive
@dpohr
dpohr temporarily deployed to Anchor Integration Tests June 5, 2025 13:11 — with GitHub Actions Inactive
@dpohr
dpohr marked this pull request as ready for review June 6, 2025 15:47
@dpohr
dpohr temporarily deployed to Receiver Registration - E2E Integration Tests (Stellar) June 10, 2025 08:34 — with GitHub Actions Inactive
@dpohr
dpohr temporarily deployed to Anchor Integration Tests June 10, 2025 08:34 — with GitHub Actions Inactive
@dpohr
dpohr temporarily deployed to Anchor Integration Tests June 10, 2025 11:12 — with GitHub Actions Inactive
@dpohr
dpohr temporarily deployed to Receiver Registration - E2E Integration Tests (Stellar) June 10, 2025 11:12 — with GitHub Actions Inactive
@dpohr
dpohr requested review from marwen-abid and philipliu June 10, 2025 11:57

@marwen-abid marwen-abid left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM! Plz feel free to merge after addressing the comments.

Comment thread internal/data/wallets.go
setClauses = append(setClauses, fmt.Sprintf("enabled = $%d", argCount))
args = append(args, *update.Enabled)
argCount++
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You can use Rebind to not have to track the argCount.

		var setClauses []string
		var args []any

		if update.Name != nil {
			setClauses = append(setClauses, "name = ?")
			args = append(args, *update.Name)
		}
		if update.Homepage != nil {
			setClauses = append(setClauses, "homepage = ?")
			args = append(args, *update.Homepage)
		}
		if update.SEP10ClientDomain != nil {
			setClauses = append(setClauses, "sep_10_client_domain = ?")
			args = append(args, *update.SEP10ClientDomain)
		}
		if update.DeepLinkSchema != nil {
			setClauses = append(setClauses, "deep_link_schema = ?")
			args = append(args, *update.DeepLinkSchema)
		}
		if update.Enabled != nil {
			setClauses = append(setClauses, "enabled = ?")
			args = append(args, *update.Enabled)
		}

		if len(setClauses) == 0 && update.AssetsIDs == nil {
			return nil, fmt.Errorf("no fields provided for update")
		}

		var w Wallet

		if len(setClauses) > 0 {
			setClauses = append(setClauses, "updated_at = NOW()")
			query := dbTx.Rebind(fmt.Sprintf(`
				UPDATE wallets 
				SET %s
				WHERE id = ? AND deleted_at IS NULL
				RETURNING *
			`, strings.Join(setClauses, ", ")))

homepage := strings.TrimSpace(*reqBody.Homepage)
wv.Check(homepage != "", "homepage", "homepage cannot be empty")

homepageURL, err := url.ParseRequestURI(homepage)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I believe you don't need to parse the URL before hand, you can just use ValidateURLScheme directly which also checks if the URL is valid.
e.g.

		schemes := []string{"https"}
		if !h.IsPubnet() {
			schemes = append(schemes, "http")
		}
		validator.CheckError(utils.ValidateURLScheme(*reqBody.PrivacyPolicyLink, schemes...), "privacy_policy_link", "")

},
},
{
name: "🔴 fails when no fields provided",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we include a test that checks for whitespace trimming?

@dpohr
dpohr temporarily deployed to Receiver Registration - E2E Integration Tests (Stellar) June 11, 2025 13:39 — with GitHub Actions Inactive
@dpohr
dpohr temporarily deployed to Anchor Integration Tests June 11, 2025 13:39 — with GitHub Actions Inactive
@dpohr
dpohr temporarily deployed to Anchor Integration Tests June 11, 2025 13:46 — with GitHub Actions Inactive
@dpohr
dpohr temporarily deployed to Receiver Registration - E2E Integration Tests (Stellar) June 11, 2025 13:46 — with GitHub Actions Inactive
@dpohr
dpohr merged commit c9b05f4 into develop Jun 11, 2025
@dpohr
dpohr deleted the SDP-1687-update-wallet-patch-endpoint branch June 11, 2025 14:03
philipliu added a commit that referenced this pull request Jun 13, 2025
* SDP-1689 Prevent unregistering user-managed wallets and wallets with in-progress payments. (#683)

* Feat: Turn on service account use in the ap deployment in the helm chart (#679)

### What

Turn on the service account in the helm chart for the ap deployment

### Why

Currently the serviceaccount name is commented out while all the other deployments have the serviceaccountname set up

* Bump vite (#654)

* Bump the minor-and-patch group across 1 directory with 6 updates (#690)

* Bump the minor-and-patch group across 1 directory with 6 updates

Bumps the minor-and-patch group with 6 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [github.com/getsentry/sentry-go](https://github.com/getsentry/sentry-go) | `0.32.0` | `0.33.0` |
| [github.com/nyaruka/phonenumbers](https://github.com/nyaruka/phonenumbers) | `1.6.1` | `1.6.3` |
| [github.com/segmentio/kafka-go](https://github.com/segmentio/kafka-go) | `0.4.47` | `0.4.48` |
| [github.com/twilio/twilio-go](https://github.com/twilio/twilio-go) | `1.25.1` | `1.26.1` |
| [golang.org/x/crypto](https://github.com/golang/crypto) | `0.37.0` | `0.38.0` |
| [golang.org/x/net](https://github.com/golang/net) | `0.39.0` | `0.40.0` |



Updates `github.com/getsentry/sentry-go` from 0.32.0 to 0.33.0
- [Release notes](https://github.com/getsentry/sentry-go/releases)
- [Changelog](https://github.com/getsentry/sentry-go/blob/master/CHANGELOG.md)
- [Commits](getsentry/sentry-go@v0.32.0...v0.33.0)

Updates `github.com/nyaruka/phonenumbers` from 1.6.1 to 1.6.3
- [Release notes](https://github.com/nyaruka/phonenumbers/releases)
- [Changelog](https://github.com/nyaruka/phonenumbers/blob/main/CHANGELOG.md)
- [Commits](nyaruka/phonenumbers@v1.6.1...v1.6.3)

Updates `github.com/segmentio/kafka-go` from 0.4.47 to 0.4.48
- [Release notes](https://github.com/segmentio/kafka-go/releases)
- [Commits](segmentio/kafka-go@v0.4.47...v0.4.48)

Updates `github.com/twilio/twilio-go` from 1.25.1 to 1.26.1
- [Release notes](https://github.com/twilio/twilio-go/releases)
- [Changelog](https://github.com/twilio/twilio-go/blob/main/CHANGES.md)
- [Commits](twilio/twilio-go@v1.25.1...v1.26.1)

Updates `golang.org/x/crypto` from 0.37.0 to 0.38.0
- [Commits](golang/crypto@v0.37.0...v0.38.0)

Updates `golang.org/x/net` from 0.39.0 to 0.40.0
- [Commits](golang/net@v0.39.0...v0.40.0)

---
updated-dependencies:
- dependency-name: github.com/getsentry/sentry-go
  dependency-version: 0.33.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: github.com/nyaruka/phonenumbers
  dependency-version: 1.6.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: github.com/segmentio/kafka-go
  dependency-version: 0.4.48
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: github.com/twilio/twilio-go
  dependency-version: 1.26.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: golang.org/x/crypto
  dependency-version: 0.38.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: golang.org/x/net
  dependency-version: 0.40.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* Update CHANGELOG.md

* Update go.list

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Marcelo Salloum <[email protected]>

* SDP 1685 add create receiver endpoint (#687)

* SDP 1685 add create receiver endpoint

* SDP 1685 receiver shadowing fix

* SDP-1685 discussions fix

* Add badges to the README.md file (#691)

### What

Add Several badges to the README.md:

<img width="969" alt="Screenshot 2025-05-23 at 2 19 10 PM" src="https://github.com/user-attachments/assets/d0a45bb4-4d35-4ccb-a9c7-798e16845ffe" />

This includes the DeepWiki badge, which ensures DeepWiki will re-index this repo once a week.

### Why

📈  Kaizen

* chore: bump version to 3.7.1

* Fix stellar.expert pubnet URL configuration in helm chart

* SDP-1630: add api key auth to all SDP endpoints (#681)

* SDP-1630 add api keys middleware

* SDP-1630 fix existing tests

* SDP 1630 merge develop

* SDP 1630

* SDP 1630 gofumpt

* SDP 1630

* SDP 1630 changelog update

* SDP 1630 keys parsing improve

* SDP 1630 update remote debug template file

* SDP-1630 resolve discussions

* SDP 1630 resolve discussion

* SDP 1686 create wallet endpoint update (#696)

* SDP 1686 create wallet endpoint update

* SDP-1686

* SDP-1686 fix test

* SDP-1686

* SDP 1687 update wallet patch endpoint (#697)

* SDP 1686 create wallet endpoint update

* SDP-1686

* SDP-1686 fix test

* SDP-1687 update PATCH endpoint

* SDP 1687 update chengelog

* SDP 1687

* SDP-1687 linter fix

* SDP-1687 discussions fix

* SDP-1687

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Marwen Abid <[email protected]>
Co-authored-by: Traver Tischio <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Marcelo Salloum <[email protected]>
Co-authored-by: Denys <[email protected]>
Co-authored-by: Marcelo Salloum dos Santos <[email protected]>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
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