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
3 changes: 3 additions & 0 deletions ocp/integration/swap.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import (

// Swap is an integration that hooks into the swap worker
type Swap interface {
// OnSwapSubmitted allows for notification when the swap for when a swap is submitted
OnSwapSubmitted(ctx context.Context, owner *common.Account, fromMint, toMint *common.Account) error

// OnSwapFinalized allows for notifications based on events processed by the swap worker
OnSwapFinalized(ctx context.Context, owner *common.Account, isBuy bool, mint *common.Account, currencyName string, region currency.Code, valueReceived float64, isMintInit bool) error
}
3 changes: 3 additions & 0 deletions ocp/rpc/transaction/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type transactionServer struct {
auth *auth_util.RPCSignatureVerifier

submitIntentIntegration integration.SubmitIntent
swapIntegration integration.Swap

antispamGuard *antispam.Guard
amlGuard *aml.Guard
Expand All @@ -54,6 +55,7 @@ func NewTransactionServer(
data ocp_data.Provider,
mintDataProvider *currency_util.MintDataProvider,
submitIntentIntegration integration.SubmitIntent,
swapIntegration integration.Swap,
antispamGuard *antispam.Guard,
amlGuard *aml.Guard,
coinbaseClient *coinbase.Client,
Expand Down Expand Up @@ -100,6 +102,7 @@ func NewTransactionServer(
auth: auth_util.NewRPCSignatureVerifier(log, data),

submitIntentIntegration: submitIntentIntegration,
swapIntegration: swapIntegration,

antispamGuard: antispamGuard,
amlGuard: amlGuard,
Expand Down
5 changes: 5 additions & 0 deletions ocp/rpc/transaction/stateless_swap.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,11 @@ func (s *transactionServer) handleStablecoinStatelessSwap(
// Section: Submission
//

err = s.swapIntegration.OnSwapSubmitted(ctx, owner, fromMint, toMint)
if err != nil {
log.With(zap.Error(err)).Warn("failed to notify user of swap processing")
}

if initiateReq.WaitForFinalization {
if err := transaction_util.SubmitAndWaitForFinalization(ctx, s.data, &txn); err != nil {
if err == transaction_util.ErrTransactionFailed {
Expand Down
Loading