Documentation
¶
Index ¶
- Constants
- Variables
- func ParseStellarAsset(circleCurrency string, networkType utils.NetworkType) (data.Asset, error)
- type APIError
- type APIErrorDetail
- type AccountConfiguration
- type Balance
- type Balances
- type Client
- func (client *Client) GetAccountConfiguration(ctx context.Context) (*AccountConfiguration, error)
- func (client *Client) GetBusinessBalances(ctx context.Context) (*Balances, error)
- func (client *Client) GetTransferByID(ctx context.Context, id string) (*Transfer, error)
- func (client *Client) Ping(ctx context.Context) (bool, error)
- func (client *Client) PostTransfer(ctx context.Context, transferReq TransferRequest) (*Transfer, error)
- type ClientConfig
- type ClientConfigModel
- type ClientConfigModelInterface
- type ClientConfigUpdate
- type ClientFactory
- type ClientInterface
- type ClientOptions
- type ConfigurationResponse
- type Environment
- type ListBusinessBalancesResponse
- type MockClient
- func (_m *MockClient) GetAccountConfiguration(ctx context.Context) (*AccountConfiguration, error)
- func (_m *MockClient) GetBusinessBalances(ctx context.Context) (*Balances, error)
- func (_m *MockClient) GetTransferByID(ctx context.Context, id string) (*Transfer, error)
- func (_m *MockClient) Ping(ctx context.Context) (bool, error)
- func (_m *MockClient) PostTransfer(ctx context.Context, transferRequest TransferRequest) (*Transfer, error)
- type MockClientConfigModel
- type MockService
- func (_m *MockService) GetAccountConfiguration(ctx context.Context) (*AccountConfiguration, error)
- func (_m *MockService) GetBusinessBalances(ctx context.Context) (*Balances, error)
- func (_m *MockService) GetTransferByID(ctx context.Context, id string) (*Transfer, error)
- func (_m *MockService) Ping(ctx context.Context) (bool, error)
- func (_m *MockService) PostTransfer(ctx context.Context, transferRequest TransferRequest) (*Transfer, error)
- func (_m *MockService) SendPayment(ctx context.Context, paymentRequest PaymentRequest) (*Transfer, error)
- type PaymentRequest
- type RetryableError
- type Service
- func (s *Service) GetAccountConfiguration(ctx context.Context) (*AccountConfiguration, error)
- func (s *Service) GetBusinessBalances(ctx context.Context) (*Balances, error)
- func (s *Service) GetTransferByID(ctx context.Context, transferID string) (*Transfer, error)
- func (s *Service) Ping(ctx context.Context) (bool, error)
- func (s *Service) PostTransfer(ctx context.Context, transferRequest TransferRequest) (*Transfer, error)
- func (s *Service) SendPayment(ctx context.Context, paymentRequest PaymentRequest) (*Transfer, error)
- type ServiceInterface
- type ServiceOptions
- type Transfer
- type TransferAccount
- type TransferAccountType
- type TransferErrorCode
- type TransferRequest
- type TransferResponse
- type TransferStatus
- type WalletConfig
Constants ¶
const StellarChainCode = "XLM"
Variables ¶
var ( ErrUnsupportedCurrency = errors.New("unsupported Circle currency code") ErrUnsupportedCurrencyForNetwork = errors.New("unsupported Circle currency code for this network type") )
var AllowedAssetsMap = map[string]map[utils.NetworkType]data.Asset{ "USD": { utils.PubnetNetworkType: assets.USDCAssetPubnet, utils.TestnetNetworkType: assets.USDCAssetTestnet, }, "EUR": { utils.PubnetNetworkType: assets.EURCAssetPubnet, utils.TestnetNetworkType: assets.EURCAssetTestnet, }, }
AllowedAssetsMap is a map of Circle currency codes to Stellar assets, for each network type.
Functions ¶
func ParseStellarAsset ¶
ParseStellarAsset returns the Stellar asset for the given Circle currency code, or an error if the currency is not supported in the SDP.
Types ¶
type APIError ¶
type APIError struct { // Code is the Circle API error code. Code int `json:"code"` Message string `json:"message"` Errors []APIErrorDetail `json:"errors,omitempty"` // StatusCode is the HTTP status code. StatusCode int `json:"status_code,omitempty"` }
APIError represents the error response from Circle APIs.
type APIErrorDetail ¶
type APIErrorDetail struct { Error string `json:"error"` Message string `json:"message"` Location string `json:"location"` InvalidValue interface{} `json:"invalidValue,omitempty"` Constraints map[string]interface{} `json:"constraints,omitempty"` }
APIErrorDetail represents the detailed error information.
type AccountConfiguration ¶
type AccountConfiguration struct {
Payments WalletConfig `json:"payments,omitempty"`
}
AccountConfiguration represents the configuration settings of an account.
type Balances ¶
type Balances struct { Available []Balance `json:"available"` Unsettled []Balance `json:"unsettled"` }
Balances represents the available and unsettled balances for different currencies.
type Client ¶
Client provides methods to interact with the Circle API.
func (*Client) GetAccountConfiguration ¶
func (client *Client) GetAccountConfiguration(ctx context.Context) (*AccountConfiguration, error)
GetAccountConfiguration retrieves the configuration of the Circle Account.
func (*Client) GetBusinessBalances ¶
GetBusinessBalances retrieves the available and unsettled balances for different currencies.
func (*Client) GetTransferByID ¶
GetTransferByID retrieves a transfer by its ID.
Circle API documentation: https://developers.circle.com/circle-mint/reference/gettransfer.
func (*Client) Ping ¶
Ping checks that the service is running.
Circle API documentation: https://developers.circle.com/circle-mint/reference/ping.
func (*Client) PostTransfer ¶
func (client *Client) PostTransfer(ctx context.Context, transferReq TransferRequest) (*Transfer, error)
PostTransfer creates a new transfer.
Circle API documentation: https://developers.circle.com/circle-mint/reference/createtransfer.
type ClientConfig ¶
type ClientConfigModel ¶
type ClientConfigModel struct { DBConnectionPool db.DBConnectionPool Encrypter utils.PrivateKeyEncrypter }
func NewClientConfigModel ¶
func NewClientConfigModel(dbConnectionPool db.DBConnectionPool) *ClientConfigModel
func (*ClientConfigModel) Get ¶
func (m *ClientConfigModel) Get(ctx context.Context) (*ClientConfig, error)
Get retrieves the circle client config from the database if it exists.
func (*ClientConfigModel) GetDecryptedAPIKey ¶
func (m *ClientConfigModel) GetDecryptedAPIKey(ctx context.Context, passphrase string) (string, error)
GetDecryptedAPIKey retrieves the decrypted API key from the database.
func (*ClientConfigModel) Upsert ¶
func (m *ClientConfigModel) Upsert(ctx context.Context, configUpdate ClientConfigUpdate) error
Upsert insert or update the client configuration for Circle into the database.
type ClientConfigUpdate ¶
type ClientFactory ¶
type ClientFactory func(opts ClientOptions) ClientInterface
ClientFactory is a function that creates a ClientInterface.
type ClientInterface ¶
type ClientInterface interface { Ping(ctx context.Context) (bool, error) PostTransfer(ctx context.Context, transferRequest TransferRequest) (*Transfer, error) GetTransferByID(ctx context.Context, id string) (*Transfer, error) GetBusinessBalances(ctx context.Context) (*Balances, error) GetAccountConfiguration(ctx context.Context) (*AccountConfiguration, error) }
ClientInterface defines the interface for interacting with the Circle API.
func NewClient ¶
func NewClient(opts ClientOptions) ClientInterface
NewClient creates a new instance of Circle Client.
type ClientOptions ¶
type ClientOptions struct { NetworkType utils.NetworkType APIKey string TenantManager tenant.ManagerInterface MonitorService monitor.MonitorServiceInterface }
type ConfigurationResponse ¶
type ConfigurationResponse struct {
Data AccountConfiguration `json:"data,omitempty"`
}
ConfigurationResponse represents the response containing account configuration.
type Environment ¶
type Environment string
Environment holds the possible environments for the Circle API.
const ( Production Environment = "https://api.circle.com" Sandbox Environment = "https://api-sandbox.circle.com" )
type ListBusinessBalancesResponse ¶
type ListBusinessBalancesResponse struct {
Data Balances `json:"data,omitempty"`
}
ListBusinessBalancesResponse represents the response containing business balances.
type MockClient ¶
MockClient is an autogenerated mock type for the ClientInterface type
func NewMockClient ¶
func NewMockClient(t interface { mock.TestingT Cleanup(func()) }) *MockClient
NewMockClient creates a new instance of MockClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
func (*MockClient) GetAccountConfiguration ¶
func (_m *MockClient) GetAccountConfiguration(ctx context.Context) (*AccountConfiguration, error)
GetAccountConfiguration provides a mock function with given fields: ctx
func (*MockClient) GetBusinessBalances ¶
func (_m *MockClient) GetBusinessBalances(ctx context.Context) (*Balances, error)
GetBusinessBalances provides a mock function with given fields: ctx
func (*MockClient) GetTransferByID ¶
GetTransferByID provides a mock function with given fields: ctx, id
func (*MockClient) Ping ¶
func (_m *MockClient) Ping(ctx context.Context) (bool, error)
Ping provides a mock function with given fields: ctx
func (*MockClient) PostTransfer ¶
func (_m *MockClient) PostTransfer(ctx context.Context, transferRequest TransferRequest) (*Transfer, error)
PostTransfer provides a mock function with given fields: ctx, transferRequest
type MockClientConfigModel ¶
MockClientConfigModel is an autogenerated mock type for the ClientConfigModelInterface type
func NewMockClientConfigModel ¶
func NewMockClientConfigModel(t interface { mock.TestingT Cleanup(func()) }) *MockClientConfigModel
NewMockClientConfigModel creates a new instance of MockClientConfigModel. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
func (*MockClientConfigModel) Get ¶
func (_m *MockClientConfigModel) Get(ctx context.Context) (*ClientConfig, error)
Get provides a mock function with given fields: ctx
func (*MockClientConfigModel) GetDecryptedAPIKey ¶
func (_m *MockClientConfigModel) GetDecryptedAPIKey(ctx context.Context, passphrase string) (string, error)
GetDecryptedAPIKey provides a mock function with given fields: ctx, passphrase
func (*MockClientConfigModel) Upsert ¶
func (_m *MockClientConfigModel) Upsert(ctx context.Context, configUpdate ClientConfigUpdate) error
Upsert provides a mock function with given fields: ctx, configUpdate
type MockService ¶
MockService is an autogenerated mock type for the ServiceInterface type
func NewMockService ¶
func NewMockService(t interface { mock.TestingT Cleanup(func()) }) *MockService
NewMockService creates a new instance of MockService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
func (*MockService) GetAccountConfiguration ¶
func (_m *MockService) GetAccountConfiguration(ctx context.Context) (*AccountConfiguration, error)
GetAccountConfiguration provides a mock function with given fields: ctx
func (*MockService) GetBusinessBalances ¶
func (_m *MockService) GetBusinessBalances(ctx context.Context) (*Balances, error)
GetBusinessBalances provides a mock function with given fields: ctx
func (*MockService) GetTransferByID ¶
GetTransferByID provides a mock function with given fields: ctx, id
func (*MockService) Ping ¶
func (_m *MockService) Ping(ctx context.Context) (bool, error)
Ping provides a mock function with given fields: ctx
func (*MockService) PostTransfer ¶
func (_m *MockService) PostTransfer(ctx context.Context, transferRequest TransferRequest) (*Transfer, error)
PostTransfer provides a mock function with given fields: ctx, transferRequest
func (*MockService) SendPayment ¶
func (_m *MockService) SendPayment(ctx context.Context, paymentRequest PaymentRequest) (*Transfer, error)
SendPayment provides a mock function with given fields: ctx, paymentRequest
type PaymentRequest ¶
type PaymentRequest struct { SourceWalletID string DestinationStellarAddress string Amount string StellarAssetCode string IdempotencyKey string }
func (PaymentRequest) GetCircleAssetCode ¶
func (p PaymentRequest) GetCircleAssetCode() (string, error)
GetCircleAssetCode converts the request's Stellar asset code to a Circle's asset code.
func (PaymentRequest) Validate ¶
func (p PaymentRequest) Validate() error
type RetryableError ¶
type RetryableError struct {
// contains filtered or unexported fields
}
func (RetryableError) Error ¶
func (re RetryableError) Error() string
type Service ¶
type Service struct { ClientFactory ClientFactory ClientConfigModel ClientConfigModelInterface NetworkType utils.NetworkType EncryptionPassphrase string TenantManager tenant.ManagerInterface MonitorService monitor.MonitorServiceInterface }
func NewService ¶
func NewService(opts ServiceOptions) (*Service, error)
func (*Service) GetAccountConfiguration ¶
func (s *Service) GetAccountConfiguration(ctx context.Context) (*AccountConfiguration, error)
func (*Service) GetBusinessBalances ¶
func (*Service) GetTransferByID ¶
func (*Service) PostTransfer ¶
func (*Service) SendPayment ¶
type ServiceInterface ¶
type ServiceInterface interface { ClientInterface SendPayment(ctx context.Context, paymentRequest PaymentRequest) (*Transfer, error) }
ServiceInterface defines the interface for Circle related SDP operations.
type ServiceOptions ¶
type ServiceOptions struct { ClientFactory ClientFactory ClientConfigModel ClientConfigModelInterface TenantManager tenant.ManagerInterface NetworkType utils.NetworkType EncryptionPassphrase string MonitorService monitor.MonitorServiceInterface }
func (ServiceOptions) Validate ¶
func (o ServiceOptions) Validate() error
type Transfer ¶
type Transfer struct { ID string `json:"id"` Source TransferAccount `json:"source"` Destination TransferAccount `json:"destination"` Amount Balance `json:"amount"` TransactionHash string `json:"transactionHash,omitempty"` Status TransferStatus `json:"status"` ErrorCode TransferErrorCode `json:"errorCode,omitempty"` CreateDate time.Time `json:"createDate"` }
Transfer represents a transfer of funds from a Circle Endpoint to another. A circle endpoint can be a wallet, card, wire, or blockchain address.
type TransferAccount ¶
type TransferAccount struct { Type TransferAccountType `json:"type"` ID string `json:"id,omitempty"` Chain string `json:"chain,omitempty"` Address string `json:"address,omitempty"` AddressTag string `json:"addressTag,omitempty"` }
TransferAccount represents the source or destination of the transfer.
type TransferAccountType ¶
type TransferAccountType string
TransferAccountType represents the type of the source or destination of the transfer.
const ( TransferAccountTypeCard TransferAccountType = "card" TransferAccountTypeWire TransferAccountType = "wire" TransferAccountTypeBlockchain TransferAccountType = "blockchain" TransferAccountTypeWallet TransferAccountType = "wallet" )
type TransferErrorCode ¶
type TransferErrorCode string
const ( TransferErrorCodeInsufficientFunds TransferErrorCode = "insufficient_funds" TransferErrorCodeBlockchainError TransferErrorCode = "blockchain_error" TransferErrorCodeTransferDenied TransferErrorCode = "transfer_denied" TransferErrorCodeTransferFailed TransferErrorCode = "transfer_failed" )
type TransferRequest ¶
type TransferRequest struct { Source TransferAccount `json:"source"` Destination TransferAccount `json:"destination"` Amount Balance `json:"amount"` IdempotencyKey string `json:"idempotencyKey"` }
TransferRequest represents the request to create a new transfer.
type TransferResponse ¶
type TransferResponse struct {
Data Transfer `json:"data"`
}
TransferResponse represents the response from the Circle APIs.
type TransferStatus ¶
type TransferStatus string
const ( TransferStatusPending TransferStatus = "pending" TransferStatusComplete TransferStatus = "complete" // means success TransferStatusFailed TransferStatus = "failed" )
func (TransferStatus) ToPaymentStatus ¶
func (s TransferStatus) ToPaymentStatus() (data.PaymentStatus, error)
type WalletConfig ¶
type WalletConfig struct {
MasterWalletID string `json:"masterWalletId,omitempty"`
}
WalletConfig represents the wallet configuration with details such as the master wallet ID.