Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions activity/localization.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ func InjectLocalizedText(ctx context.Context, ocpData ocp_data.Provider, userOwn
case *activitypb.Notification_WithdrewCrypto:
localizedText = "Withdrew"

switch typed.WithdrewCrypto.SwapState {
case activitypb.SwapState_SWAP_STATE_SUCCEEDED, activitypb.SwapState_SWAP_STATE_NONE:
localizedText = "Withdrew"
case activitypb.SwapState_SWAP_STATE_FAILED:
localizedText = "Withdrawal Failed"
case activitypb.SwapState_SWAP_STATE_PENDING:
localizedText = "Withdrawing"
default:
return errors.New("unsupported swap state")
}

case *activitypb.Notification_DepositedCrypto:
localizedText = "Added"

Expand Down
17 changes: 13 additions & 4 deletions activity/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
ocp_intent "github.com/code-payments/ocp-server/ocp/data/intent"
ocp_swap "github.com/code-payments/ocp-server/ocp/data/swap"
"github.com/code-payments/ocp-server/pointer"
"github.com/code-payments/ocp-server/usdc"
)

const (
Expand Down Expand Up @@ -289,11 +290,19 @@ func (s *Server) toLocalizedNotifications(ctx context.Context, log *zap.Logger,
notification.State = activitypb.NotificationState_NOTIFICATION_STATE_PENDING
}

notification.AdditionalMetadata = &activitypb.Notification_SoldCrypto{SoldCrypto: &activitypb.SoldCryptoNotificationMetadata{
SwapState: swapState,
}}
if swapRecord.ToMint == usdc.Mint {
notification.AdditionalMetadata = &activitypb.Notification_WithdrewCrypto{WithdrewCrypto: &activitypb.WithdrewCryptoNotificationMetadata{
SwapState: swapState,
}}
} else {
notification.AdditionalMetadata = &activitypb.Notification_SoldCrypto{SoldCrypto: &activitypb.SoldCryptoNotificationMetadata{
SwapState: swapState,
}}
}
} else if intentMetadata.IsWithdrawal {
notification.AdditionalMetadata = &activitypb.Notification_WithdrewCrypto{WithdrewCrypto: &activitypb.WithdrewCryptoNotificationMetadata{}}
notification.AdditionalMetadata = &activitypb.Notification_WithdrewCrypto{WithdrewCrypto: &activitypb.WithdrewCryptoNotificationMetadata{
SwapState: activitypb.SwapState_SWAP_STATE_NONE,
}}
} else {
notification.AdditionalMetadata = &activitypb.Notification_GaveCrypto{GaveCrypto: &activitypb.GaveCryptoNotificationMetadata{}}
}
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ go 1.26.0
require (
firebase.google.com/go/v4 v4.18.0
github.com/ReneKroon/ttlcache v1.7.0
github.com/code-payments/flipcash2-protobuf-api v1.4.1-0.20260429155359-7b31c1a41cf0
github.com/code-payments/flipcash2-protobuf-api v1.5.0
github.com/code-payments/ocp-protobuf-api v1.10.0
github.com/code-payments/ocp-server v1.11.1-0.20260428231936-0d49436103e3
github.com/code-payments/ocp-server v1.12.0
github.com/devsisters/go-applereceipt v0.0.0-20240805020915-fa22a0160fc2
github.com/georgysavva/scany/v2 v2.1.4
github.com/google/uuid v1.6.0
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ github.com/cockroachdb/cockroach-go/v2 v2.2.0 h1:/5znzg5n373N/3ESjHF5SMLxiW4RKB0
github.com/cockroachdb/cockroach-go/v2 v2.2.0/go.mod h1:u3MiKYGupPPjkn3ozknpMUpxPaNLTFWAya419/zv6eI=
github.com/code-payments/code-vm-indexer v1.2.0 h1:rSHpBMiT9BKgmKcXg/VIoi/h0t7jNxGx07Qz59m+6Q0=
github.com/code-payments/code-vm-indexer v1.2.0/go.mod h1:vn91YN2qNqb+gGJeZe2+l+TNxVmEEiRHXXnIn2Y40h8=
github.com/code-payments/flipcash2-protobuf-api v1.4.1-0.20260429155359-7b31c1a41cf0 h1:bGP8kCBfG1wHJ/DVmn025AInix2qthNjxQllmqWNjJA=
github.com/code-payments/flipcash2-protobuf-api v1.4.1-0.20260429155359-7b31c1a41cf0/go.mod h1:s/1pOsb4FTRD+LcvRKGjfmm6ygRS/m1ep34EIW0fuDs=
github.com/code-payments/flipcash2-protobuf-api v1.5.0 h1:3aXu61v5FDsjU9n/w5Z5l31ZEDXJ+JrvNwLZ5JySWZ8=
github.com/code-payments/flipcash2-protobuf-api v1.5.0/go.mod h1:s/1pOsb4FTRD+LcvRKGjfmm6ygRS/m1ep34EIW0fuDs=
github.com/code-payments/ocp-protobuf-api v1.10.0 h1:8GEDLh3NShOYz6J7a9VOCqu+xJSd7xR42pewaPfkiE4=
github.com/code-payments/ocp-protobuf-api v1.10.0/go.mod h1:tw6BooY5a8l6CtSZnKOruyKII0W04n89pcM4BizrgG8=
github.com/code-payments/ocp-server v1.11.1-0.20260428231936-0d49436103e3 h1:c7f2HxXM7w6yBawsvDnr+DOWEbxEEembhHk/fleKVzY=
github.com/code-payments/ocp-server v1.11.1-0.20260428231936-0d49436103e3/go.mod h1:988X7GYc48DZihgfsv/1rKyFhp+SM00b2uR74NbuMYA=
github.com/code-payments/ocp-server v1.12.0 h1:d1hRjFJzxg7ie/03tpFateW5QKn32m6ic9BKjOSDJvk=
github.com/code-payments/ocp-server v1.12.0/go.mod h1:988X7GYc48DZihgfsv/1rKyFhp+SM00b2uR74NbuMYA=
github.com/containerd/continuity v0.4.3 h1:6HVkalIp+2u1ZLH1J/pYX2oBVXlJZvh1X1A7bEZ9Su8=
github.com/containerd/continuity v0.4.3/go.mod h1:F6PTNCKepoxEaXLQp3wDAjygEnImnZ/7o4JzpodfroQ=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
Expand Down
Loading