diff --git a/api/gateway/chain/internal/service/gateway/commands/wallet/create.go b/api/gateway/chain/internal/service/gateway/commands/wallet/create.go index 9ca10caa..a33e58ee 100644 --- a/api/gateway/chain/internal/service/gateway/commands/wallet/create.go +++ b/api/gateway/chain/internal/service/gateway/commands/wallet/create.go @@ -132,7 +132,7 @@ func (c *createManagedWalletCommand) Execute(ctx context.Context, req *chainv1.C wallet := &model.ManagedWallet{ Describable: pkgmodel.Describable{ Name: name, - Description: desc.Description, + Description: description, }, IdempotencyKey: idempotencyKey, WalletRef: walletRef, diff --git a/api/gateway/chain/internal/service/gateway/service.go b/api/gateway/chain/internal/service/gateway/service.go index 03a0e2fc..cf43ad86 100644 --- a/api/gateway/chain/internal/service/gateway/service.go +++ b/api/gateway/chain/internal/service/gateway/service.go @@ -208,7 +208,7 @@ func (s *Service) startDiscoveryAnnouncers() { Service: "CRYPTO_RAIL_GATEWAY", Rail: "CRYPTO", Network: network.Name, - Operations: []string{"balance.read", "payin.crypto", "payout.crypto", "fee.send"}, + Operations: []string{"balance.read", "payin.crypto", "payout.crypto", "fee.send", "observe.confirm"}, Currencies: currencies, InvokeURI: s.invokeURI, Version: version, diff --git a/api/payments/orchestrator/internal/service/orchestrator/execution_plan.go b/api/payments/orchestrator/internal/service/orchestrator/execution_plan.go index 24194506..fa0d66a0 100644 --- a/api/payments/orchestrator/internal/service/orchestrator/execution_plan.go +++ b/api/payments/orchestrator/internal/service/orchestrator/execution_plan.go @@ -109,17 +109,26 @@ func updateExecutionStepFromTransfer(plan *model.ExecutionPlan, event *chainv1.T if transferRef == "" { return nil } - step := findExecutionStepByTransferRef(plan, transferRef) - if step == nil { - return nil - } - if step.TransferRef == "" { - step.TransferRef = transferRef - } if status := executionStepStatusFromTransferStatus(transfer.GetStatus()); status != "" { - setExecutionStepStatus(step, status) + var updated *model.ExecutionStep + for _, step := range plan.Steps { + if step == nil { + continue + } + if !strings.EqualFold(strings.TrimSpace(step.TransferRef), transferRef) { + continue + } + if step.TransferRef == "" { + step.TransferRef = transferRef + } + setExecutionStepStatus(step, status) + if updated == nil { + updated = step + } + } + return updated } - return step + return nil } func executionStepStatusFromTransferStatus(status chainv1.TransferStatus) string { diff --git a/api/payments/orchestrator/internal/service/orchestrator/payment_plan_helpers.go b/api/payments/orchestrator/internal/service/orchestrator/payment_plan_helpers.go index 9a115b6f..35d0fb2b 100644 --- a/api/payments/orchestrator/internal/service/orchestrator/payment_plan_helpers.go +++ b/api/payments/orchestrator/internal/service/orchestrator/payment_plan_helpers.go @@ -100,6 +100,53 @@ func blockStepConfirmed(plan *model.PaymentPlan, execPlan *model.ExecutionPlan) return false } +func linkRailObservation(payment *model.Payment, rail model.Rail, referenceID, dependsOn string) { + if payment == nil || payment.PaymentPlan == nil { + return + } + ref := strings.TrimSpace(referenceID) + if ref == "" { + return + } + plan := payment.PaymentPlan + execPlan := ensureExecutionPlanForPlan(payment, plan) + if execPlan == nil { + return + } + dep := strings.TrimSpace(dependsOn) + for idx, planStep := range plan.Steps { + if planStep == nil { + continue + } + if planStep.Rail != rail || planStep.Action != model.RailOperationObserveConfirm { + continue + } + if dep != "" { + matched := false + for _, entry := range planStep.DependsOn { + if strings.EqualFold(strings.TrimSpace(entry), dep) { + matched = true + break + } + } + if !matched { + continue + } + } + if idx >= len(execPlan.Steps) { + continue + } + execStep := execPlan.Steps[idx] + if execStep == nil { + execStep = &model.ExecutionStep{Code: planStepID(planStep, idx), Description: describePlanStep(planStep)} + execPlan.Steps[idx] = execStep + } + if execStep.TransferRef == "" { + execStep.TransferRef = ref + } + } +} + func planStepID(step *model.PaymentStep, idx int) string { if step != nil { if val := strings.TrimSpace(step.StepID); val != "" { diff --git a/api/payments/orchestrator/internal/service/orchestrator/payment_plan_steps.go b/api/payments/orchestrator/internal/service/orchestrator/payment_plan_steps.go index b1edb7ed..6c739d14 100644 --- a/api/payments/orchestrator/internal/service/orchestrator/payment_plan_steps.go +++ b/api/payments/orchestrator/internal/service/orchestrator/payment_plan_steps.go @@ -110,11 +110,15 @@ func (p *paymentExecutor) executeSendStep(ctx context.Context, payment *model.Pa if err != nil { return false, err } + stepID := planStepID(step, idx) execStep.TransferRef = strings.TrimSpace(result.ReferenceID) exec := ensureExecutionRefs(payment) if exec.ChainTransferRef == "" && execStep.TransferRef != "" { exec.ChainTransferRef = execStep.TransferRef } + if execStep.TransferRef != "" { + linkRailObservation(payment, step.Rail, execStep.TransferRef, stepID) + } setExecutionStepStatus(execStep, executionStepStatusSubmitted) return true, nil case model.RailCardPayout: diff --git a/api/payments/orchestrator/internal/service/orchestrator/provider_settlement.go b/api/payments/orchestrator/internal/service/orchestrator/provider_settlement.go index 66034c8f..0ad4a6b7 100644 --- a/api/payments/orchestrator/internal/service/orchestrator/provider_settlement.go +++ b/api/payments/orchestrator/internal/service/orchestrator/provider_settlement.go @@ -117,30 +117,5 @@ func paymentGatewayTargetChatID(payment *model.Payment) string { } func linkProviderSettlementObservation(payment *model.Payment, requestID string) { - if payment == nil || payment.PaymentPlan == nil || payment.ExecutionPlan == nil { - return - } - requestID = strings.TrimSpace(requestID) - if requestID == "" { - return - } - for idx, planStep := range payment.PaymentPlan.Steps { - if planStep == nil { - continue - } - if planStep.Rail != model.RailProviderSettlement || planStep.Action != model.RailOperationObserveConfirm { - continue - } - if idx >= len(payment.ExecutionPlan.Steps) { - continue - } - execStep := payment.ExecutionPlan.Steps[idx] - if execStep == nil { - execStep = &model.ExecutionStep{Code: planStepID(planStep, idx), Description: describePlanStep(planStep)} - payment.ExecutionPlan.Steps[idx] = execStep - } - if execStep.TransferRef == "" { - execStep.TransferRef = requestID - } - } + linkRailObservation(payment, model.RailProviderSettlement, requestID, "") }