restucturization of recipients payment methods
All checks were successful
ci/woodpecker/push/billing_fees Pipeline was successful
ci/woodpecker/push/bff Pipeline was successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/chain_gateway Pipeline was successful
ci/woodpecker/push/fx_ingestor Pipeline was successful
ci/woodpecker/push/fx_oracle Pipeline was successful
ci/woodpecker/push/frontend Pipeline was successful
ci/woodpecker/push/nats Pipeline was successful
ci/woodpecker/push/ledger Pipeline was successful
ci/woodpecker/push/notification Pipeline was successful
ci/woodpecker/push/payments_orchestrator Pipeline was successful
All checks were successful
ci/woodpecker/push/billing_fees Pipeline was successful
ci/woodpecker/push/bff Pipeline was successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/chain_gateway Pipeline was successful
ci/woodpecker/push/fx_ingestor Pipeline was successful
ci/woodpecker/push/fx_oracle Pipeline was successful
ci/woodpecker/push/frontend Pipeline was successful
ci/woodpecker/push/nats Pipeline was successful
ci/woodpecker/push/ledger Pipeline was successful
ci/woodpecker/push/notification Pipeline was successful
ci/woodpecker/push/payments_orchestrator Pipeline was successful
This commit is contained in:
54
api/gateway/chain/storage/model/deposit.go
Normal file
54
api/gateway/chain/storage/model/deposit.go
Normal file
@@ -0,0 +1,54 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/tech/sendico/pkg/db/storable"
|
||||
"github.com/tech/sendico/pkg/mservice"
|
||||
moneyv1 "github.com/tech/sendico/pkg/proto/common/money/v1"
|
||||
)
|
||||
|
||||
type DepositStatus string
|
||||
|
||||
const (
|
||||
DepositStatusPending DepositStatus = "pending"
|
||||
DepositStatusConfirmed DepositStatus = "confirmed"
|
||||
DepositStatusFailed DepositStatus = "failed"
|
||||
)
|
||||
|
||||
// Deposit records an inbound transfer observed on-chain.
|
||||
type Deposit struct {
|
||||
storable.Base `bson:",inline" json:",inline"`
|
||||
|
||||
DepositRef string `bson:"depositRef" json:"depositRef"`
|
||||
WalletRef string `bson:"walletRef" json:"walletRef"`
|
||||
Network string `bson:"network" json:"network"`
|
||||
TokenSymbol string `bson:"tokenSymbol" json:"tokenSymbol"`
|
||||
ContractAddress string `bson:"contractAddress" json:"contractAddress"`
|
||||
Amount *moneyv1.Money `bson:"amount" json:"amount"`
|
||||
SourceAddress string `bson:"sourceAddress" json:"sourceAddress"`
|
||||
TxHash string `bson:"txHash" json:"txHash"`
|
||||
BlockID string `bson:"blockId,omitempty" json:"blockId,omitempty"`
|
||||
Status DepositStatus `bson:"status" json:"status"`
|
||||
ObservedAt time.Time `bson:"observedAt" json:"observedAt"`
|
||||
RecordedAt time.Time `bson:"recordedAt" json:"recordedAt"`
|
||||
LastStatusAt time.Time `bson:"lastStatusAt" json:"lastStatusAt"`
|
||||
}
|
||||
|
||||
// Collection implements storable.Storable.
|
||||
func (*Deposit) Collection() string {
|
||||
return mservice.ChainDeposits
|
||||
}
|
||||
|
||||
// Normalize standardizes case-sensitive fields.
|
||||
func (d *Deposit) Normalize() {
|
||||
d.DepositRef = strings.TrimSpace(d.DepositRef)
|
||||
d.WalletRef = strings.TrimSpace(d.WalletRef)
|
||||
d.Network = strings.TrimSpace(strings.ToLower(d.Network))
|
||||
d.TokenSymbol = strings.TrimSpace(strings.ToUpper(d.TokenSymbol))
|
||||
d.ContractAddress = strings.TrimSpace(strings.ToLower(d.ContractAddress))
|
||||
d.SourceAddress = strings.TrimSpace(strings.ToLower(d.SourceAddress))
|
||||
d.TxHash = strings.TrimSpace(strings.ToLower(d.TxHash))
|
||||
d.BlockID = strings.TrimSpace(d.BlockID)
|
||||
}
|
||||
91
api/gateway/chain/storage/model/transfer.go
Normal file
91
api/gateway/chain/storage/model/transfer.go
Normal file
@@ -0,0 +1,91 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/tech/sendico/pkg/db/storable"
|
||||
"github.com/tech/sendico/pkg/mservice"
|
||||
moneyv1 "github.com/tech/sendico/pkg/proto/common/money/v1"
|
||||
)
|
||||
|
||||
type TransferStatus string
|
||||
|
||||
const (
|
||||
TransferStatusPending TransferStatus = "pending"
|
||||
TransferStatusSigning TransferStatus = "signing"
|
||||
TransferStatusSubmitted TransferStatus = "submitted"
|
||||
TransferStatusConfirmed TransferStatus = "confirmed"
|
||||
TransferStatusFailed TransferStatus = "failed"
|
||||
TransferStatusCancelled TransferStatus = "cancelled"
|
||||
)
|
||||
|
||||
// ServiceFee represents a fee component applied to a transfer.
|
||||
type ServiceFee struct {
|
||||
FeeCode string `bson:"feeCode" json:"feeCode"`
|
||||
Amount *moneyv1.Money `bson:"amount" json:"amount"`
|
||||
Description string `bson:"description,omitempty" json:"description,omitempty"`
|
||||
}
|
||||
|
||||
type TransferDestination struct {
|
||||
ManagedWalletRef string `bson:"managedWalletRef,omitempty" json:"managedWalletRef,omitempty"`
|
||||
ExternalAddress string `bson:"externalAddress,omitempty" json:"externalAddress,omitempty"`
|
||||
Memo string `bson:"memo,omitempty" json:"memo,omitempty"`
|
||||
}
|
||||
|
||||
// Transfer models an on-chain transfer orchestrated by the gateway.
|
||||
type Transfer struct {
|
||||
storable.Base `bson:",inline" json:",inline"`
|
||||
|
||||
TransferRef string `bson:"transferRef" json:"transferRef"`
|
||||
IdempotencyKey string `bson:"idempotencyKey" json:"idempotencyKey"`
|
||||
OrganizationRef string `bson:"organizationRef" json:"organizationRef"`
|
||||
SourceWalletRef string `bson:"sourceWalletRef" json:"sourceWalletRef"`
|
||||
Destination TransferDestination `bson:"destination" json:"destination"`
|
||||
Network string `bson:"network" json:"network"`
|
||||
TokenSymbol string `bson:"tokenSymbol" json:"tokenSymbol"`
|
||||
ContractAddress string `bson:"contractAddress" json:"contractAddress"`
|
||||
RequestedAmount *moneyv1.Money `bson:"requestedAmount" json:"requestedAmount"`
|
||||
NetAmount *moneyv1.Money `bson:"netAmount" json:"netAmount"`
|
||||
Fees []ServiceFee `bson:"fees,omitempty" json:"fees,omitempty"`
|
||||
Status TransferStatus `bson:"status" json:"status"`
|
||||
TxHash string `bson:"txHash,omitempty" json:"txHash,omitempty"`
|
||||
FailureReason string `bson:"failureReason,omitempty" json:"failureReason,omitempty"`
|
||||
ClientReference string `bson:"clientReference,omitempty" json:"clientReference,omitempty"`
|
||||
LastStatusAt time.Time `bson:"lastStatusAt" json:"lastStatusAt"`
|
||||
}
|
||||
|
||||
// Collection implements storable.Storable.
|
||||
func (*Transfer) Collection() string {
|
||||
return mservice.ChainTransfers
|
||||
}
|
||||
|
||||
// TransferFilter describes the parameters for listing transfers.
|
||||
type TransferFilter struct {
|
||||
SourceWalletRef string
|
||||
DestinationWalletRef string
|
||||
Status TransferStatus
|
||||
Cursor string
|
||||
Limit int32
|
||||
}
|
||||
|
||||
// TransferList contains paginated transfer results.
|
||||
type TransferList struct {
|
||||
Items []*Transfer
|
||||
NextCursor string
|
||||
}
|
||||
|
||||
// Normalize trims strings for consistent indexes.
|
||||
func (t *Transfer) Normalize() {
|
||||
t.TransferRef = strings.TrimSpace(t.TransferRef)
|
||||
t.IdempotencyKey = strings.TrimSpace(t.IdempotencyKey)
|
||||
t.OrganizationRef = strings.TrimSpace(t.OrganizationRef)
|
||||
t.SourceWalletRef = strings.TrimSpace(t.SourceWalletRef)
|
||||
t.Network = strings.TrimSpace(strings.ToLower(t.Network))
|
||||
t.TokenSymbol = strings.TrimSpace(strings.ToUpper(t.TokenSymbol))
|
||||
t.ContractAddress = strings.TrimSpace(strings.ToLower(t.ContractAddress))
|
||||
t.Destination.ManagedWalletRef = strings.TrimSpace(t.Destination.ManagedWalletRef)
|
||||
t.Destination.ExternalAddress = strings.TrimSpace(strings.ToLower(t.Destination.ExternalAddress))
|
||||
t.Destination.Memo = strings.TrimSpace(t.Destination.Memo)
|
||||
t.ClientReference = strings.TrimSpace(t.ClientReference)
|
||||
}
|
||||
90
api/gateway/chain/storage/model/wallet.go
Normal file
90
api/gateway/chain/storage/model/wallet.go
Normal file
@@ -0,0 +1,90 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/tech/sendico/pkg/db/storable"
|
||||
"github.com/tech/sendico/pkg/mservice"
|
||||
moneyv1 "github.com/tech/sendico/pkg/proto/common/money/v1"
|
||||
)
|
||||
|
||||
type ManagedWalletStatus string
|
||||
|
||||
const (
|
||||
ManagedWalletStatusActive ManagedWalletStatus = "active"
|
||||
ManagedWalletStatusSuspended ManagedWalletStatus = "suspended"
|
||||
ManagedWalletStatusClosed ManagedWalletStatus = "closed"
|
||||
)
|
||||
|
||||
// ManagedWallet represents a user-controlled on-chain wallet managed by the service.
|
||||
type ManagedWallet struct {
|
||||
storable.Base `bson:",inline" json:",inline"`
|
||||
|
||||
IdempotencyKey string `bson:"idempotencyKey" json:"idempotencyKey"`
|
||||
WalletRef string `bson:"walletRef" json:"walletRef"`
|
||||
OrganizationRef string `bson:"organizationRef" json:"organizationRef"`
|
||||
OwnerRef string `bson:"ownerRef" json:"ownerRef"`
|
||||
Network string `bson:"network" json:"network"`
|
||||
TokenSymbol string `bson:"tokenSymbol" json:"tokenSymbol"`
|
||||
ContractAddress string `bson:"contractAddress" json:"contractAddress"`
|
||||
DepositAddress string `bson:"depositAddress" json:"depositAddress"`
|
||||
KeyReference string `bson:"keyReference,omitempty" json:"keyReference,omitempty"`
|
||||
Status ManagedWalletStatus `bson:"status" json:"status"`
|
||||
Metadata map[string]string `bson:"metadata,omitempty" json:"metadata,omitempty"`
|
||||
}
|
||||
|
||||
// Collection implements storable.Storable.
|
||||
func (*ManagedWallet) Collection() string {
|
||||
return mservice.ChainWallets
|
||||
}
|
||||
|
||||
// WalletBalance captures computed wallet balances.
|
||||
type WalletBalance struct {
|
||||
storable.Base `bson:",inline" json:",inline"`
|
||||
|
||||
WalletRef string `bson:"walletRef" json:"walletRef"`
|
||||
Available *moneyv1.Money `bson:"available" json:"available"`
|
||||
PendingInbound *moneyv1.Money `bson:"pendingInbound,omitempty" json:"pendingInbound,omitempty"`
|
||||
PendingOutbound *moneyv1.Money `bson:"pendingOutbound,omitempty" json:"pendingOutbound,omitempty"`
|
||||
CalculatedAt time.Time `bson:"calculatedAt" json:"calculatedAt"`
|
||||
}
|
||||
|
||||
// Collection implements storable.Storable.
|
||||
func (*WalletBalance) Collection() string {
|
||||
return mservice.ChainWalletBalances
|
||||
}
|
||||
|
||||
// ManagedWalletFilter describes list filters.
|
||||
type ManagedWalletFilter struct {
|
||||
OrganizationRef string
|
||||
OwnerRef string
|
||||
Network string
|
||||
TokenSymbol string
|
||||
Cursor string
|
||||
Limit int32
|
||||
}
|
||||
|
||||
// ManagedWalletList contains paginated wallet results.
|
||||
type ManagedWalletList struct {
|
||||
Items []*ManagedWallet
|
||||
NextCursor string
|
||||
}
|
||||
|
||||
// Normalize trims string fields for consistent indexing.
|
||||
func (m *ManagedWallet) Normalize() {
|
||||
m.IdempotencyKey = strings.TrimSpace(m.IdempotencyKey)
|
||||
m.WalletRef = strings.TrimSpace(m.WalletRef)
|
||||
m.OrganizationRef = strings.TrimSpace(m.OrganizationRef)
|
||||
m.OwnerRef = strings.TrimSpace(m.OwnerRef)
|
||||
m.Network = strings.TrimSpace(strings.ToLower(m.Network))
|
||||
m.TokenSymbol = strings.TrimSpace(strings.ToUpper(m.TokenSymbol))
|
||||
m.ContractAddress = strings.TrimSpace(strings.ToLower(m.ContractAddress))
|
||||
m.DepositAddress = strings.TrimSpace(strings.ToLower(m.DepositAddress))
|
||||
m.KeyReference = strings.TrimSpace(m.KeyReference)
|
||||
}
|
||||
|
||||
// Normalize trims wallet balance identifiers.
|
||||
func (b *WalletBalance) Normalize() {
|
||||
b.WalletRef = strings.TrimSpace(b.WalletRef)
|
||||
}
|
||||
Reference in New Issue
Block a user