diff --git a/ocp/integration/swap.go b/ocp/integration/swap.go index 62261c5..e78b967 100644 --- a/ocp/integration/swap.go +++ b/ocp/integration/swap.go @@ -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 } diff --git a/ocp/rpc/transaction/server.go b/ocp/rpc/transaction/server.go index 3add3c8..cc93526 100644 --- a/ocp/rpc/transaction/server.go +++ b/ocp/rpc/transaction/server.go @@ -32,6 +32,7 @@ type transactionServer struct { auth *auth_util.RPCSignatureVerifier submitIntentIntegration integration.SubmitIntent + swapIntegration integration.Swap antispamGuard *antispam.Guard amlGuard *aml.Guard @@ -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, @@ -100,6 +102,7 @@ func NewTransactionServer( auth: auth_util.NewRPCSignatureVerifier(log, data), submitIntentIntegration: submitIntentIntegration, + swapIntegration: swapIntegration, antispamGuard: antispamGuard, amlGuard: amlGuard, diff --git a/ocp/rpc/transaction/stateless_swap.go b/ocp/rpc/transaction/stateless_swap.go index 85b04c0..0723fc5 100644 --- a/ocp/rpc/transaction/stateless_swap.go +++ b/ocp/rpc/transaction/stateless_swap.go @@ -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 {