Documentation
¶
Index ¶
- Variables
- func InitializeTransactionData(req CreateTransactionRequest) ([]byte, error)
- type BlockProcessing
- type BlockchainEvent
- type BlockchainEventResponse
- type BlockchainTriggerConfig
- type Contract
- type ContractDeployRequest
- type ContractDeployResponse
- type ContractResponse
- type ContractStatus
- type ContractVerification
- type ContractVerifyRequest
- type ContractVerifyResponse
- type CreateTransactionRequest
- type CreateWalletRequest
- type CronTriggerConfig
- type DeploymentData
- type DepositTracker
- type EntropySource
- type EventNotification
- type EventSubscription
- type EventSubscriptionRequest
- type EventSubscriptionResponse
- type Execution
- type ExecutionLog
- type ExecutionRepository
- type ExecutionRequest
- type ExecutionResult
- type Function
- type FunctionRepository
- type GasBankAccount
- type GasBankRepository
- type GasBankService
- type GasBankTransaction
- type GasBankTransactionStatus
- type GasBankTransactionType
- type InvokeScriptData
- type JsonMap
- type NotificationStatus
- type NotificationType
- type Oracle
- type OracleAuthType
- type OracleDataSource
- type OracleDataSourceType
- type OracleRepository
- type OracleRequest
- type OracleRequestStatus
- type OracleService
- type OracleUpdate
- type PriceData
- type PriceFeed
- type PriceFeedRepository
- type PriceFeedService
- type PriceSource
- type PriceTriggerConfig
- type PriceUpdate
- type RandomRepository
- type RandomRequest
- type RandomRequestStatus
- type ScriptSigner
- type ScriptWitness
- type Secret
- type SecretMetadata
- type SecretRepository
- type SubscriptionStatus
- type Transaction
- type TransactionEvent
- type TransactionListResponse
- type TransactionStatus
- type TransactionType
- type TransferData
- type Trigger
- type TriggerEvent
- type TriggerRepository
- type TriggerType
- type User
- type UserRepository
- type WalletAccount
- type WithdrawalRequest
Constants ¶
This section is empty.
Variables ¶
var ( ErrGasBankAccountNotFound = errors.New("gas bank account not found") ErrInsufficientFunds = errors.New("insufficient funds for withdrawal") ErrMaximumWithdrawalExceeded = errors.New("maximum withdrawal amount exceeded") ErrDailyWithdrawalLimitReached = errors.New("daily withdrawal limit reached") ErrInvalidWithdrawalAmount = errors.New("invalid withdrawal amount") ErrInvalidDepositAmount = errors.New("invalid deposit amount") ErrDuplicateTransaction = errors.New("duplicate transaction detected") ErrTransactionNotFound = errors.New("transaction not found") )
Gas Bank error constants
var ( ErrDataSourceNotFound = errors.New("data source not found") ErrInvalidDataSourceName = errors.New("invalid data source name") ErrInvalidDataSourceURL = errors.New("invalid data source URL") ErrInvalidContractScript = errors.New("invalid contract script hash") ErrInvalidUpdateInterval = errors.New("invalid update interval") ErrMaxDataSourcesReached = errors.New("maximum number of data sources reached") )
Common errors for Oracle operations
var ( ErrPriceFeedNotFound = errors.New("price feed not found") ErrInvalidPriceFeedSymbol = errors.New("invalid price feed symbol") ErrInvalidContractAddress = errors.New("invalid contract address") ErrPriceFeedUpdateInterval = errors.New("invalid price feed update interval") ErrInsufficientValidSources = errors.New("insufficient valid price sources") ErrMaxPriceFeedsReached = errors.New("maximum number of price feeds reached") )
Common errors for price feed operations
Functions ¶
func InitializeTransactionData ¶
func InitializeTransactionData(req CreateTransactionRequest) ([]byte, error)
InitializeTransactionData converts the transaction request to the appropriate data structure
Types ¶
type BlockProcessing ¶
type BlockProcessing struct {
ID int `json:"id" db:"id"`
Network string `json:"network" db:"network"`
LastProcessedBlock int `json:"lastProcessedBlock" db:"last_processed_block"`
IsProcessing bool `json:"isProcessing" db:"is_processing"`
LastProcessedAt time.Time `json:"lastProcessedAt" db:"last_processed_at"`
CreatedAt time.Time `json:"createdAt" db:"created_at"`
UpdatedAt time.Time `json:"updatedAt" db:"updated_at"`
}
BlockProcessing represents the block processing state for a network
type BlockchainEvent ¶
type BlockchainEvent struct {
ID uuid.UUID `json:"id" db:"id"`
ContractAddress string `json:"contractAddress" db:"contract_address"`
EventName string `json:"eventName" db:"event_name"`
Parameters json.RawMessage `json:"parameters" db:"parameters"`
TransactionHash string `json:"transactionHash" db:"transaction_hash"`
BlockNumber int `json:"blockNumber" db:"block_number"`
BlockHash string `json:"blockHash" db:"block_hash"`
Timestamp time.Time `json:"timestamp" db:"timestamp"`
CreatedAt time.Time `json:"createdAt" db:"created_at"`
}
BlockchainEvent represents an event from the blockchain
func NewBlockchainEvent ¶
func NewBlockchainEvent( contractAddress string, eventName string, parameters json.RawMessage, transactionHash string, blockNumber int, blockHash string, timestamp time.Time, ) *BlockchainEvent
NewBlockchainEvent creates a new blockchain event
func (*BlockchainEvent) ToResponse ¶
func (e *BlockchainEvent) ToResponse() *BlockchainEventResponse
ToResponse converts a blockchain event to a blockchain event response
type BlockchainEventResponse ¶
type BlockchainEventResponse struct {
ID string `json:"id"`
ContractAddress string `json:"contractAddress"`
EventName string `json:"eventName"`
Parameters interface{} `json:"parameters"`
TransactionHash string `json:"transactionHash"`
BlockNumber int `json:"blockNumber"`
BlockHash string `json:"blockHash"`
Timestamp time.Time `json:"timestamp"`
}
BlockchainEventResponse represents a response for a blockchain event
type BlockchainTriggerConfig ¶
type BlockchainTriggerConfig struct {
ContractHash string `json:"contract_hash"`
EventName string `json:"event_name"`
}
BlockchainTriggerConfig represents configuration for a blockchain event trigger
type Contract ¶
type Contract struct {
ID uuid.UUID `json:"id" db:"id"`
Name string `json:"name" db:"name"`
Description string `json:"description" db:"description"`
Source string `json:"source,omitempty" db:"source"`
Bytecode []byte `json:"bytecode,omitempty" db:"bytecode"`
Manifest []byte `json:"manifest,omitempty" db:"manifest"`
Address string `json:"address" db:"address"`
Network string `json:"network" db:"network"`
CreatedAt time.Time `json:"createdAt" db:"created_at"`
UpdatedAt time.Time `json:"updatedAt" db:"updated_at"`
UserID int `json:"userId" db:"user_id"`
Status ContractStatus `json:"status" db:"status"`
TxHash string `json:"txHash" db:"tx_hash"`
}
Contract represents a smart contract in the system
func NewContract ¶
NewContract creates a new contract
func (*Contract) ToDeployResponse ¶
func (c *Contract) ToDeployResponse() *ContractDeployResponse
ToDeployResponse converts a contract to a contract deploy response
func (*Contract) ToResponse ¶
func (c *Contract) ToResponse() *ContractResponse
ToResponse converts a contract to a contract response
type ContractDeployRequest ¶
type ContractDeployRequest struct {
Name string `json:"name" validate:"required"`
Description string `json:"description"`
Source string `json:"source" validate:"required"`
Compiler string `json:"compiler" validate:"required"`
Parameters map[string]interface{} `json:"parameters"`
Wallet string `json:"wallet" validate:"required"`
Network string `json:"network" validate:"required,oneof=mainnet testnet"`
}
ContractDeployRequest represents a request to deploy a contract
type ContractDeployResponse ¶
type ContractDeployResponse struct {
ContractID string `json:"contractId"`
TxHash string `json:"txHash"`
Status ContractStatus `json:"status"`
Address string `json:"address,omitempty"`
}
ContractDeployResponse represents a contract deployment response
type ContractResponse ¶
type ContractResponse struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Address string `json:"address"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
Status ContractStatus `json:"status"`
TxHash string `json:"txHash"`
Network string `json:"network"`
}
ContractResponse represents a contract response
type ContractStatus ¶
type ContractStatus string
ContractStatus represents the status of a contract deployment
const ( ContractStatusPending ContractStatus = "pending" ContractStatusDeploying ContractStatus = "deploying" ContractStatusDeployed ContractStatus = "deployed" ContractStatusFailed ContractStatus = "failed" )
Contract statuses
type ContractVerification ¶
type ContractVerification struct {
ID uuid.UUID `json:"id" db:"id"`
ContractID uuid.UUID `json:"contractId" db:"contract_id"`
Verified bool `json:"verified" db:"verified"`
Message string `json:"message" db:"message"`
Details []byte `json:"details" db:"details"`
CreatedAt time.Time `json:"createdAt" db:"created_at"`
UserID int `json:"userId" db:"user_id"`
}
ContractVerification represents a contract verification
func NewContractVerification ¶
func NewContractVerification(contractID uuid.UUID, verified bool, message string, details []byte, userID int) *ContractVerification
NewContractVerification creates a new contract verification
type ContractVerifyRequest ¶
type ContractVerifyRequest struct {
ContractID string `json:"contractId" validate:"required,uuid"`
Source string `json:"source" validate:"required"`
Compiler string `json:"compiler" validate:"required"`
Parameters map[string]interface{} `json:"parameters"`
}
ContractVerifyRequest represents a request to verify a contract
type ContractVerifyResponse ¶
type ContractVerifyResponse struct {
Verified bool `json:"verified"`
Message string `json:"message"`
Details map[string]interface{} `json:"details,omitempty"`
}
ContractVerifyResponse represents a contract verification response
type CreateTransactionRequest ¶
type CreateTransactionRequest struct {
Service string `json:"service" validate:"required"`
EntityID uuid.UUID `json:"entityId,omitempty"`
EntityType string `json:"entityType,omitempty"`
Type TransactionType `json:"type" validate:"required"`
Script string `json:"script,omitempty"`
Params []interface{} `json:"params,omitempty"`
Signers []ScriptSigner `json:"signers,omitempty"`
GasPrice int64 `json:"gasPrice" validate:"required"`
SystemFee int64 `json:"systemFee" validate:"required"`
NetworkFee int64 `json:"networkFee" validate:"required"`
Priority string `json:"priority,omitempty"`
}
CreateTransactionRequest represents a request to create a new transaction
type CreateWalletRequest ¶
type CreateWalletRequest struct {
Service string `json:"service" validate:"required"`
}
CreateWalletRequest represents a request to create a new wallet account
type CronTriggerConfig ¶
type CronTriggerConfig struct {
Schedule string `json:"schedule"`
Timezone string `json:"timezone"`
}
CronTriggerConfig represents configuration for a cron trigger
type DeploymentData ¶
type DeploymentData struct {
Name string `json:"name"`
Version string `json:"version"`
Author string `json:"author"`
Email string `json:"email"`
Description string `json:"description"`
NEF []byte `json:"nef"`
Manifest interface{} `json:"manifest"`
Signers []ScriptSigner `json:"signers,omitempty"`
Network string `json:"network"`
}
DeploymentData represents the data specific to a deployment transaction
type DepositTracker ¶
type DepositTracker struct {
ID string `json:"id" db:"id"`
BlockchainTxID string `json:"blockchain_tx_id" db:"blockchain_tx_id"`
FromAddress string `json:"from_address" db:"from_address"`
ToAddress string `json:"to_address" db:"to_address"`
Amount string `json:"amount" db:"amount"`
Status string `json:"status" db:"status"`
Processed bool `json:"processed" db:"processed"`
TransactionID string `json:"transaction_id" db:"transaction_id"`
BlockHeight uint32 `json:"block_height" db:"block_height"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}
DepositTracker represents a record of deposits tracked from the blockchain
type EntropySource ¶
type EntropySource struct {
ID int `json:"id" db:"id"`
Name string `json:"name" db:"name"`
Type string `json:"type" db:"type"`
Weight float64 `json:"weight" db:"weight"`
Active bool `json:"active" db:"active"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}
EntropySource represents a source of entropy
type EventNotification ¶
type EventNotification struct {
ID uuid.UUID `json:"id" db:"id"`
SubscriptionID uuid.UUID `json:"subscriptionId" db:"subscription_id"`
EventID uuid.UUID `json:"eventId" db:"event_id"`
Status NotificationStatus `json:"status" db:"status"`
DeliveryAttempts int `json:"deliveryAttempts" db:"delivery_attempts"`
LastAttemptAt *time.Time `json:"lastAttemptAt" db:"last_attempt_at"`
DeliveredAt *time.Time `json:"deliveredAt" db:"delivered_at"`
Response string `json:"response" db:"response"`
CreatedAt time.Time `json:"createdAt" db:"created_at"`
}
EventNotification represents a notification for a blockchain event
func NewEventNotification ¶
func NewEventNotification(subscriptionID, eventID uuid.UUID) *EventNotification
NewEventNotification creates a new event notification
type EventSubscription ¶
type EventSubscription struct {
ID uuid.UUID `json:"id" db:"id"`
UserID int `json:"userId" db:"user_id"`
Name string `json:"name" db:"name"`
Description string `json:"description" db:"description"`
ContractAddress string `json:"contractAddress" db:"contract_address"`
EventName string `json:"eventName" db:"event_name"`
Parameters json.RawMessage `json:"parameters" db:"parameters"`
StartBlock *int `json:"startBlock" db:"start_block"`
EndBlock *int `json:"endBlock" db:"end_block"`
CallbackURL string `json:"callbackUrl" db:"callback_url"`
NotificationType NotificationType `json:"notificationType" db:"notification_type"`
Status SubscriptionStatus `json:"status" db:"status"`
CreatedAt time.Time `json:"createdAt" db:"created_at"`
UpdatedAt time.Time `json:"updatedAt" db:"updated_at"`
LastTriggeredAt *time.Time `json:"lastTriggeredAt" db:"last_triggered_at"`
TriggerCount int `json:"triggerCount" db:"trigger_count"`
}
EventSubscription represents a subscription to blockchain events
func NewEventSubscription ¶
func NewEventSubscription( userID int, name string, description string, contractAddress string, eventName string, parameters json.RawMessage, startBlock *int, endBlock *int, callbackURL string, notificationType NotificationType, ) *EventSubscription
NewEventSubscription creates a new event subscription
func (*EventSubscription) ToResponse ¶
func (s *EventSubscription) ToResponse() *EventSubscriptionResponse
ToResponse converts an event subscription to an event subscription response
type EventSubscriptionRequest ¶
type EventSubscriptionRequest struct {
Name string `json:"name" validate:"required"`
Description string `json:"description"`
ContractAddress string `json:"contractAddress"`
EventName string `json:"eventName"`
Parameters map[string]interface{} `json:"parameters"`
StartBlock *int `json:"startBlock"`
EndBlock *int `json:"endBlock"`
CallbackURL string `json:"callbackUrl"`
NotificationType string `json:"notificationType" validate:"required,oneof=webhook email in-app automation"`
}
EventSubscriptionRequest represents a request to create or update an event subscription
type EventSubscriptionResponse ¶
type EventSubscriptionResponse struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
ContractAddress string `json:"contractAddress"`
EventName string `json:"eventName"`
Parameters interface{} `json:"parameters"`
StartBlock *int `json:"startBlock"`
EndBlock *int `json:"endBlock"`
CallbackURL string `json:"callbackUrl"`
NotificationType string `json:"notificationType"`
Status string `json:"status"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
LastTriggeredAt *time.Time `json:"lastTriggeredAt,omitempty"`
TriggerCount int `json:"triggerCount"`
}
EventSubscriptionResponse represents a response for an event subscription
type Execution ¶
type Execution struct {
ID int `json:"id" db:"id"`
FunctionID int `json:"function_id" db:"function_id"`
Status string `json:"status" db:"status"`
StartTime time.Time `json:"start_time" db:"start_time"`
EndTime time.Time `json:"end_time,omitempty" db:"end_time"`
Duration int `json:"duration,omitempty" db:"duration"`
Result json.RawMessage `json:"result,omitempty" db:"result"`
Error string `json:"error,omitempty" db:"error"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
Logs []ExecutionLog `json:"logs,omitempty" db:"-"`
}
Execution represents a function execution
type ExecutionLog ¶
type ExecutionLog struct {
ID int `json:"id" db:"id"`
ExecutionID int `json:"execution_id" db:"execution_id"`
Timestamp time.Time `json:"timestamp" db:"timestamp"`
Level string `json:"level" db:"level"`
Message string `json:"message" db:"message"`
}
ExecutionLog represents a log entry for a function execution
type ExecutionRepository ¶
type ExecutionRepository interface {
Create(execution *Execution) error
GetByID(id int) (*Execution, error)
ListByFunctionID(functionID int, offset, limit int) ([]*Execution, error)
Update(execution *Execution) error
Delete(id int) error
AddLog(log *ExecutionLog) error
GetLogs(executionID int, offset, limit int) ([]*ExecutionLog, error)
}
ExecutionRepository defines methods for working with executions
type ExecutionRequest ¶
type ExecutionRequest struct {
Params interface{} `json:"params"`
Async bool `json:"async"`
}
ExecutionRequest represents a request to execute a function
type ExecutionResult ¶
type ExecutionResult struct {
ExecutionID string `json:"execution_id"`
FunctionID int `json:"function_id"`
Status string `json:"status"`
StartTime time.Time `json:"start_time"`
EndTime time.Time `json:"end_time,omitempty"`
Duration int `json:"duration,omitempty"`
Result json.RawMessage `json:"result,omitempty"`
Error string `json:"error,omitempty"`
Logs []string `json:"logs,omitempty"`
}
ExecutionResult represents the result of a function execution
type Function ¶
type Function struct {
ID int `json:"id" db:"id"`
UserID int `json:"user_id" db:"user_id"`
Name string `json:"name" db:"name"`
Description string `json:"description" db:"description"`
SourceCode string `json:"source_code" db:"source_code"`
Version int `json:"version" db:"version"`
Status string `json:"status" db:"status"`
Timeout int `json:"timeout" db:"timeout"`
Memory int `json:"memory" db:"memory"`
ExecutionCount int `json:"execution_count" db:"execution_count"`
LastExecution time.Time `json:"last_execution,omitempty" db:"last_execution"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
Secrets []string `json:"secrets,omitempty" db:"-"`
}
Function represents a JavaScript function stored in the system
type FunctionRepository ¶
type FunctionRepository interface {
Create(function *Function) error
GetByID(id int) (*Function, error)
GetByUserIDAndName(userID int, name string) (*Function, error)
List(userID int, offset, limit int) ([]*Function, error)
Update(function *Function) error
Delete(id int) error
IncrementExecutionCount(id int) error
UpdateLastExecution(id int, lastExecution time.Time) error
GetSecrets(functionID int) ([]string, error)
SetSecrets(functionID int, secrets []string) error
}
FunctionRepository defines methods for working with functions
type GasBankAccount ¶
type GasBankAccount struct {
ID string `json:"id" db:"id"`
UserID string `json:"user_id" db:"user_id"`
WalletAddress string `json:"wallet_address" db:"wallet_address"`
Balance string `json:"balance" db:"balance"`
AvailableBalance string `json:"available_balance" db:"available_balance"`
PendingBalance string `json:"pending_balance" db:"pending_balance"`
DailyWithdrawal string `json:"daily_withdrawal" db:"daily_withdrawal"`
LastWithdrawalDay time.Time `json:"last_withdrawal_day" db:"last_withdrawal_day"`
Active bool `json:"active" db:"active"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}
GasBankAccount represents a user's account in the gas bank
type GasBankRepository ¶
type GasBankRepository interface {
// Account operations
CreateAccount(ctx interface{}, account *GasBankAccount) (*GasBankAccount, error)
GetAccount(ctx interface{}, id string) (*GasBankAccount, error)
GetAccountByUserID(ctx interface{}, userID string) (*GasBankAccount, error)
GetAccountByWalletAddress(ctx interface{}, address string) (*GasBankAccount, error)
UpdateAccount(ctx interface{}, account *GasBankAccount) (*GasBankAccount, error)
ListAccounts(ctx interface{}) ([]*GasBankAccount, error)
// Transaction operations
CreateTransaction(ctx interface{}, tx *GasBankTransaction) (*GasBankTransaction, error)
GetTransaction(ctx interface{}, id string) (*GasBankTransaction, error)
GetTransactionByBlockchainTxID(ctx interface{}, txID string) (*GasBankTransaction, error)
UpdateTransaction(ctx interface{}, tx *GasBankTransaction) (*GasBankTransaction, error)
ListTransactionsByUserID(ctx interface{}, userID string, limit int, offset int) ([]*GasBankTransaction, error)
ListTransactionsByAccountID(ctx interface{}, accountID string, limit int, offset int) ([]*GasBankTransaction, error)
// Withdrawal operations
CreateWithdrawalRequest(ctx interface{}, req *WithdrawalRequest) (*WithdrawalRequest, error)
GetWithdrawalRequest(ctx interface{}, id string) (*WithdrawalRequest, error)
UpdateWithdrawalRequest(ctx interface{}, req *WithdrawalRequest) (*WithdrawalRequest, error)
ListWithdrawalRequestsByUserID(ctx interface{}, userID string, limit int, offset int) ([]*WithdrawalRequest, error)
// Deposit tracking operations
CreateDepositTracker(ctx interface{}, deposit *DepositTracker) (*DepositTracker, error)
GetDepositTrackerByTxID(ctx interface{}, txID string) (*DepositTracker, error)
UpdateDepositTracker(ctx interface{}, deposit *DepositTracker) (*DepositTracker, error)
ListUnprocessedDeposits(ctx interface{}) ([]*DepositTracker, error)
// Balance operations
UpdateBalance(ctx interface{}, accountID string, newBalance string, newPendingBalance string, newAvailableBalance string) error
IncrementDailyWithdrawal(ctx interface{}, accountID string, amount string) error
ResetDailyWithdrawal(ctx interface{}, accountID string) error
}
GasBankRepository defines the interface for gas bank operations
type GasBankService ¶
type GasBankService interface {
// Account management
CreateAccount(ctx context.Context, userID string, walletAddress string) (*GasBankAccount, error)
GetAccount(ctx context.Context, id string) (*GasBankAccount, error)
GetAccountByUserID(ctx context.Context, userID string) (*GasBankAccount, error)
GetAccountByWalletAddress(ctx context.Context, walletAddress string) (*GasBankAccount, error)
ListAccounts(ctx context.Context) ([]*GasBankAccount, error)
// Balance operations
GetBalance(ctx context.Context, accountID string) (string, error)
GetAvailableBalance(ctx context.Context, accountID string) (string, error)
// Transaction operations
ProcessDeposit(ctx context.Context, fromAddress string, toAddress string, amount string, blockchainTxID string, blockHeight uint32) (*GasBankTransaction, error)
RequestWithdrawal(ctx context.Context, userID string, amount string, toAddress string) (*WithdrawalRequest, error)
ProcessWithdrawalRequest(ctx context.Context, requestID string) (*GasBankTransaction, error)
CancelWithdrawalRequest(ctx context.Context, requestID string) error
DeductFee(ctx context.Context, userID string, amount string, notes string) (*GasBankTransaction, error)
// Transaction history
GetTransaction(ctx context.Context, id string) (*GasBankTransaction, error)
ListTransactionsByUserID(ctx context.Context, userID string, limit int, offset int) ([]*GasBankTransaction, error)
ListTransactionsByAccountID(ctx context.Context, accountID string, limit int, offset int) ([]*GasBankTransaction, error)
// Withdrawal history
GetWithdrawalRequest(ctx context.Context, id string) (*WithdrawalRequest, error)
ListWithdrawalRequestsByUserID(ctx context.Context, userID string, limit int, offset int) ([]*WithdrawalRequest, error)
// Service lifecycle
Start(ctx context.Context) error
Stop(ctx context.Context) error
}
GasBankService defines the interface for the gas bank service
type GasBankTransaction ¶
type GasBankTransaction struct {
ID string `json:"id" db:"id"`
AccountID string `json:"account_id" db:"account_id"`
UserID string `json:"user_id" db:"user_id"`
Type GasBankTransactionType `json:"type" db:"type"`
Amount string `json:"amount" db:"amount"`
Fee string `json:"fee" db:"fee"`
NetAmount string `json:"net_amount" db:"net_amount"`
Status GasBankTransactionStatus `json:"status" db:"status"`
BlockchainTxID string `json:"blockchain_tx_id" db:"blockchain_tx_id"`
FromAddress string `json:"from_address" db:"from_address"`
ToAddress string `json:"to_address" db:"to_address"`
Notes string `json:"notes" db:"notes"`
ConfirmedAt *time.Time `json:"confirmed_at" db:"confirmed_at"`
BlockHeight uint32 `json:"block_height" db:"block_height"`
ErrorMessage string `json:"error_message" db:"error_message"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}
GasBankTransaction represents a gas bank transaction
type GasBankTransactionStatus ¶
type GasBankTransactionStatus string
GasBankTransactionStatus defines the status of a gas bank transaction
const ( TransactionPending GasBankTransactionStatus = "pending" TransactionConfirmed GasBankTransactionStatus = "confirmed" TransactionFailed GasBankTransactionStatus = "failed" TransactionCancelled GasBankTransactionStatus = "cancelled" )
Transaction status constants
type GasBankTransactionType ¶
type GasBankTransactionType string
GasBankTransactionType defines the type of gas bank transaction
const ( DepositTransaction GasBankTransactionType = "deposit" WithdrawalTransaction GasBankTransactionType = "withdrawal" FeeDeductionTransaction GasBankTransactionType = "fee_deduction" RefundTransaction GasBankTransactionType = "refund" SystemTransferTransaction GasBankTransactionType = "system_transfer" )
Transaction type constants
type InvokeScriptData ¶
type InvokeScriptData struct {
Script string `json:"script"`
Params []interface{} `json:"params,omitempty"`
Signers []ScriptSigner `json:"signers,omitempty"`
Network string `json:"network"`
Witness []ScriptWitness `json:"witness,omitempty"`
}
InvokeScriptData represents the data specific to an invoke transaction
type JsonMap ¶
type JsonMap map[string]interface{}
JsonMap is a custom type for JSON maps
type NotificationStatus ¶
type NotificationStatus string
NotificationStatus represents the status of an event notification
const ( NotificationStatusPending NotificationStatus = "pending" NotificationStatusDelivered NotificationStatus = "delivered" NotificationStatusFailed NotificationStatus = "failed" NotificationStatusRetrying NotificationStatus = "retrying" )
Notification statuses
type NotificationType ¶
type NotificationType string
NotificationType represents the type of notification for an event subscription
const ( NotificationTypeWebhook NotificationType = "webhook" NotificationTypeEmail NotificationType = "email" NotificationTypeInApp NotificationType = "in-app" NotificationTypeAutomation NotificationType = "automation" )
Notification types
type Oracle ¶
type Oracle struct {
ID int `json:"id" db:"id"`
Name string `json:"name" db:"name"`
Description string `json:"description" db:"description"`
Type OracleDataSourceType `json:"type" db:"type"`
URL string `json:"url" db:"url"`
Method string `json:"method" db:"method"`
Headers JsonMap `json:"headers" db:"headers"`
Body string `json:"body" db:"body"`
AuthType OracleAuthType `json:"auth_type" db:"auth_type"`
AuthParams JsonMap `json:"auth_params" db:"auth_params"`
Path string `json:"path" db:"path"`
Transform string `json:"transform" db:"transform"`
Schedule string `json:"schedule" db:"schedule"`
Active bool `json:"active" db:"active"`
UserID int `json:"user_id" db:"user_id"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}
Oracle represents an oracle data source configuration
type OracleAuthType ¶
type OracleAuthType string
OracleAuthType represents the type of authentication for an oracle data source
const ( // OracleAuthTypeNone represents no authentication OracleAuthTypeNone OracleAuthType = "none" // OracleAuthTypeAPIKey represents API key authentication OracleAuthTypeAPIKey OracleAuthType = "api_key" // OracleAuthTypeOAuth represents OAuth authentication OracleAuthTypeOAuth OracleAuthType = "oauth" // OracleAuthTypeJWT represents JWT authentication OracleAuthTypeJWT OracleAuthType = "jwt" // OracleAuthTypeBasic represents basic authentication OracleAuthTypeBasic OracleAuthType = "basic" // OracleAuthTypeCustom represents custom authentication OracleAuthTypeCustom OracleAuthType = "custom" )
type OracleDataSource ¶
type OracleDataSource struct {
ID string `json:"id" db:"id"`
Name string `json:"name" db:"name"`
URL string `json:"url" db:"url"`
Method string `json:"method" db:"method"`
Headers string `json:"headers" db:"headers"`
ContractScript string `json:"contract_script" db:"contract_script"`
DataPath string `json:"data_path" db:"data_path"`
TransformScript string `json:"transform_script" db:"transform_script"`
UpdateInterval int `json:"update_interval" db:"update_interval"`
Active bool `json:"active" db:"active"`
LastUpdated time.Time `json:"last_updated" db:"last_updated"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}
OracleDataSource represents an external data source for the Oracle service
type OracleDataSourceType ¶
type OracleDataSourceType string
OracleDataSourceType represents the type of oracle data source
const ( // OracleDataSourceTypeREST represents a REST API data source OracleDataSourceTypeREST OracleDataSourceType = "rest" // OracleDataSourceTypeWebSocket represents a WebSocket data source OracleDataSourceTypeWebSocket OracleDataSourceType = "websocket" // OracleDataSourceTypeFile represents a file data source OracleDataSourceTypeFile OracleDataSourceType = "file" // OracleDataSourceTypeIPFS represents an IPFS data source OracleDataSourceTypeIPFS OracleDataSourceType = "ipfs" // OracleDataSourceTypeDatabase represents a database data source OracleDataSourceTypeDatabase OracleDataSourceType = "database" // OracleDataSourceTypeCustom represents a custom data source OracleDataSourceTypeCustom OracleDataSourceType = "custom" )
type OracleRepository ¶
type OracleRepository interface {
// Data source operations
CreateDataSource(ctx interface{}, dataSource *OracleDataSource) (*OracleDataSource, error)
GetDataSource(ctx interface{}, id string) (*OracleDataSource, error)
UpdateDataSource(ctx interface{}, dataSource *OracleDataSource) (*OracleDataSource, error)
DeleteDataSource(ctx interface{}, id string) error
ListDataSources(ctx interface{}) ([]*OracleDataSource, error)
// Update operations
UpdateLastUpdated(ctx interface{}, id string) error
RecordUpdate(ctx interface{}, id string, data string, txID string) error
// Oracle management
CreateOracle(oracle *Oracle) (*Oracle, error)
UpdateOracle(oracle *Oracle) (*Oracle, error)
GetOracleByID(id int) (*Oracle, error)
GetOracleByName(name string) (*Oracle, error)
ListOracles(userID int, offset, limit int) ([]*Oracle, error)
DeleteOracle(id int) error
// Oracle request management
CreateOracleRequest(request *OracleRequest) (*OracleRequest, error)
UpdateOracleRequest(request *OracleRequest) (*OracleRequest, error)
GetOracleRequestByID(id int) (*OracleRequest, error)
ListOracleRequests(oracleID int, offset, limit int) ([]*OracleRequest, error)
ListPendingOracleRequests() ([]*OracleRequest, error)
GetOracleStatistics() (map[string]interface{}, error)
}
OracleRepository defines the interface for Oracle data storage operations
type OracleRequest ¶
type OracleRequest struct {
ID int `json:"id" db:"id"`
OracleID int `json:"oracle_id" db:"oracle_id"`
UserID int `json:"user_id" db:"user_id"`
Status OracleRequestStatus `json:"status" db:"status"`
URL string `json:"url" db:"url"`
Method string `json:"method" db:"method"`
Headers JsonMap `json:"headers" db:"headers"`
Body string `json:"body" db:"body"`
AuthType OracleAuthType `json:"auth_type" db:"auth_type"`
AuthParams JsonMap `json:"auth_params" db:"auth_params"`
Path string `json:"path" db:"path"`
Transform string `json:"transform" db:"transform"`
CallbackAddress string `json:"callback_address" db:"callback_address"`
CallbackMethod string `json:"callback_method" db:"callback_method"`
GasFee float64 `json:"gas_fee" db:"gas_fee"`
Result JsonMap `json:"result" db:"result"`
RawResult string `json:"raw_result" db:"raw_result"`
Error string `json:"error" db:"error"`
TxHash string `json:"tx_hash" db:"tx_hash"`
BlockHeight int64 `json:"block_height" db:"block_height"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
CompletedAt time.Time `json:"completed_at" db:"completed_at"`
}
OracleRequest represents a request for oracle data
type OracleRequestStatus ¶
type OracleRequestStatus string
OracleRequestStatus represents the status of an oracle request
const ( // OracleRequestStatusPending indicates the request is pending OracleRequestStatusPending OracleRequestStatus = "pending" // OracleRequestStatusProcessing indicates the request is being processed OracleRequestStatusProcessing OracleRequestStatus = "processing" // OracleRequestStatusCompleted indicates the request completed successfully OracleRequestStatusCompleted OracleRequestStatus = "completed" // OracleRequestStatusCallbackSent indicates the callback has been sent to the contract OracleRequestStatusCallbackSent OracleRequestStatus = "callback_sent" // OracleRequestStatusFailed indicates the request failed OracleRequestStatusFailed OracleRequestStatus = "failed" )
type OracleService ¶
type OracleService interface {
// Data source management
CreateDataSource(ctx context.Context, name string, url string, method string, headers string,
contractScript string, dataPath string, transformScript string, updateInterval int) (*OracleDataSource, error)
GetDataSource(ctx context.Context, id string) (*OracleDataSource, error)
UpdateDataSource(ctx context.Context, id string, url string, method string, headers string,
contractScript string, dataPath string, transformScript string, updateInterval int, active bool) (*OracleDataSource, error)
DeleteDataSource(ctx context.Context, id string) error
ListDataSources(ctx context.Context) ([]*OracleDataSource, error)
// Oracle operations
TriggerUpdate(ctx context.Context, dataSourceID string) error
GetLatestData(ctx context.Context, dataSourceID string) (string, error)
GetDataHistory(ctx context.Context, dataSourceID string, limit int) ([]*OracleUpdate, error)
// Oracle request management
CreateRequest(ctx context.Context, userID int, oracleID int, callbackAddress string, callbackMethod string) (*OracleRequest, error)
GetRequest(ctx context.Context, id int) (*OracleRequest, error)
CancelRequest(ctx context.Context, id int) error
ListRequests(ctx context.Context, userID int, offset int, limit int) ([]*OracleRequest, error)
// Oracle management
CreateOracle(ctx context.Context, name string, description string, oracleType OracleDataSourceType,
url string, method string, headers JsonMap, body string, authType OracleAuthType,
authParams JsonMap, path string, transform string, schedule string, userID int) (*Oracle, error)
UpdateOracle(ctx context.Context, id int, name string, description string, active bool) (*Oracle, error)
GetOracle(ctx context.Context, id int) (*Oracle, error)
ListOracles(ctx context.Context, userID int, offset int, limit int) ([]*Oracle, error)
DeleteOracle(ctx context.Context, id int) error
// Service lifecycle
Start(ctx context.Context) error
Stop(ctx context.Context) error
}
OracleService defines the interface for oracle service
type OracleUpdate ¶
type OracleUpdate struct {
ID string `json:"id" db:"id"`
DataSourceID string `json:"data_source_id" db:"data_source_id"`
Data string `json:"data" db:"data"`
TransactionID string `json:"transaction_id" db:"transaction_id"`
Success bool `json:"success" db:"success"`
Error string `json:"error" db:"error"`
BlockHeight uint32 `json:"block_height" db:"block_height"`
Timestamp time.Time `json:"timestamp" db:"timestamp"`
}
OracleUpdate represents a record of an Oracle data update
type PriceData ¶
type PriceData struct {
SourceID string `json:"source_id" db:"source_id"`
SourceName string `json:"source_name" db:"source_name"`
Price float64 `json:"price" db:"price"`
Timestamp time.Time `json:"timestamp" db:"timestamp"`
Success bool `json:"success" db:"success"`
Error string `json:"error" db:"error"`
}
PriceData represents a price data point from a source
type PriceFeed ¶
type PriceFeed struct {
ID string `json:"id" db:"id"`
Symbol string `json:"symbol" db:"symbol"`
ContractAddress string `json:"contract_address" db:"contract_address"`
DeviationThreshold float64 `json:"deviation_threshold" db:"deviation_threshold"`
UpdateInterval int `json:"update_interval" db:"update_interval"`
MinValidSources int `json:"min_valid_sources" db:"min_valid_sources"`
Timeout int `json:"timeout" db:"timeout"`
Sources []PriceSource `json:"sources" db:"sources"`
Active bool `json:"active" db:"active"`
LastUpdated time.Time `json:"last_updated" db:"last_updated"`
LastPrice float64 `json:"last_price" db:"last_price"`
LastTxHash string `json:"last_tx_hash" db:"last_tx_hash"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}
PriceFeed represents a price feed configuration
type PriceFeedRepository ¶
type PriceFeedRepository interface {
// Price feed operations
CreatePriceFeed(ctx interface{}, priceFeed *PriceFeed) (*PriceFeed, error)
GetPriceFeed(ctx interface{}, id string) (*PriceFeed, error)
UpdatePriceFeed(ctx interface{}, priceFeed *PriceFeed) (*PriceFeed, error)
DeletePriceFeed(ctx interface{}, id string) error
ListPriceFeeds(ctx interface{}) ([]*PriceFeed, error)
GetPriceFeedBySymbol(ctx interface{}, symbol string) (*PriceFeed, error)
// Price source operations
AddPriceSource(ctx interface{}, priceFeedID string, source *PriceSource) (*PriceSource, error)
RemovePriceSource(ctx interface{}, priceFeedID string, sourceID string) error
// Price update operations
UpdateLastPrice(ctx interface{}, id string, price float64, txHash string) error
RecordPriceUpdate(ctx interface{}, id string, price float64, txID string) error
GetPriceHistory(ctx interface{}, id string, limit int) ([]*PriceUpdate, error)
}
PriceFeedRepository defines the interface for price feed data storage
type PriceFeedService ¶
type PriceFeedService interface {
// Price feed management
CreatePriceFeed(ctx context.Context, symbol string, contractAddress string, interval int, threshold float64, minSources int) (*PriceFeed, error)
UpdatePriceFeed(ctx context.Context, id string, active bool, interval int, threshold float64, minSources int) (*PriceFeed, error)
DeletePriceFeed(ctx context.Context, id string) error
GetPriceFeed(ctx context.Context, id string) (*PriceFeed, error)
GetPriceFeedBySymbol(ctx context.Context, symbol string) (*PriceFeed, error)
ListPriceFeeds(ctx context.Context) ([]*PriceFeed, error)
// Price source management
AddPriceSource(ctx context.Context, priceFeedID string, name string, url string, path string, weight float64, timeout int) (*PriceSource, error)
UpdatePriceSource(ctx context.Context, priceFeedID string, sourceID string, active bool, weight float64, timeout int) (*PriceSource, error)
RemovePriceSource(ctx context.Context, priceFeedID string, sourceID string) error
// Price operations
TriggerPriceUpdate(ctx context.Context, priceFeedID string) error
FetchLatestPrice(ctx context.Context, symbol string) (float64, error)
GetPriceHistory(ctx context.Context, priceFeedID string, limit int) ([]*PriceUpdate, error)
// Service lifecycle
Start(ctx context.Context) error
Stop(ctx context.Context) error
}
PriceFeedService defines the interface for the price feed service
type PriceSource ¶
type PriceSource struct {
ID string `json:"id" db:"id"`
Name string `json:"name" db:"name"`
URL string `json:"url" db:"url"`
Path string `json:"path" db:"path"`
Weight float64 `json:"weight" db:"weight"`
Timeout int `json:"timeout" db:"timeout"`
Active bool `json:"active" db:"active"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}
PriceSource represents a data source for price information
type PriceTriggerConfig ¶
type PriceTriggerConfig struct {
AssetPair string `json:"asset_pair"`
Condition string `json:"condition"` // "above", "below", "between"
Threshold float64 `json:"threshold"`
Duration int `json:"duration"` // seconds the condition must be met
}
PriceTriggerConfig represents configuration for a price trigger
type PriceUpdate ¶
type PriceUpdate struct {
ID string `json:"id" db:"id"`
PriceFeedID string `json:"price_feed_id" db:"price_feed_id"`
Symbol string `json:"symbol" db:"symbol"`
Price float64 `json:"price" db:"price"`
TransactionID string `json:"transaction_id" db:"transaction_id"`
Success bool `json:"success" db:"success"`
Error string `json:"error" db:"error"`
BlockHeight uint32 `json:"block_height" db:"block_height"`
Timestamp time.Time `json:"timestamp" db:"timestamp"`
}
PriceUpdate represents a record of a price feed update
type RandomRepository ¶
type RandomRepository interface {
// Request management
CreateRequest(req *RandomRequest) (*RandomRequest, error)
UpdateRequest(req *RandomRequest) (*RandomRequest, error)
GetRequestByID(id int) (*RandomRequest, error)
ListRequests(userID int, offset, limit int) ([]*RandomRequest, error)
ListPendingRequests() ([]*RandomRequest, error)
ListCommittedRequests() ([]*RandomRequest, error)
GetRandomStatistics() (map[string]interface{}, error)
// Entropy source management
CreateEntropySource(source *EntropySource) (*EntropySource, error)
UpdateEntropySource(source *EntropySource) (*EntropySource, error)
GetEntropySourceByID(id int) (*EntropySource, error)
GetEntropySourceByName(name string) (*EntropySource, error)
ListEntropySources() ([]*EntropySource, error)
}
RandomRepository defines the interface for random number data access
type RandomRequest ¶
type RandomRequest struct {
ID int `json:"id" db:"id"`
UserID int `json:"user_id" db:"user_id"`
Status RandomRequestStatus `json:"status" db:"status"`
CallbackAddress string `json:"callback_address" db:"callback_address"`
CallbackMethod string `json:"callback_method" db:"callback_method"`
Seed []byte `json:"seed" db:"seed"`
BlockHeight int64 `json:"block_height" db:"block_height"`
NumBytes int `json:"num_bytes" db:"num_bytes"`
DelayBlocks int `json:"delay_blocks" db:"delay_blocks"`
GasFee float64 `json:"gas_fee" db:"gas_fee"`
CommitmentHash string `json:"commitment_hash" db:"commitment_hash"`
RandomNumber []byte `json:"random_number" db:"random_number"`
Proof []byte `json:"proof" db:"proof"`
CommitmentTxHash string `json:"commitment_tx_hash" db:"commitment_tx_hash"`
RevealTxHash string `json:"reveal_tx_hash" db:"reveal_tx_hash"`
CallbackTxHash string `json:"callback_tx_hash" db:"callback_tx_hash"`
Error string `json:"error" db:"error"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
RevealedAt time.Time `json:"revealed_at" db:"revealed_at"`
}
RandomRequest represents a request for a random number
type RandomRequestStatus ¶
type RandomRequestStatus string
RandomRequestStatus represents the status of a random number request
const ( // RandomRequestStatusPending indicates the request is pending RandomRequestStatusPending RandomRequestStatus = "pending" // RandomRequestStatusCommitted indicates the commitment has been made RandomRequestStatusCommitted RandomRequestStatus = "committed" // RandomRequestStatusRevealed indicates the random number has been revealed RandomRequestStatusRevealed RandomRequestStatus = "revealed" // RandomRequestStatusCallbackSent indicates the callback has been sent to the contract RandomRequestStatusCallbackSent RandomRequestStatus = "callback_sent" // RandomRequestStatusFailed indicates the request failed RandomRequestStatusFailed RandomRequestStatus = "failed" )
type ScriptSigner ¶
type ScriptSigner struct {
Account string `json:"account"`
Scopes string `json:"scopes"`
AllowedContracts []string `json:"allowedContracts,omitempty"`
AllowedGroups []string `json:"allowedGroups,omitempty"`
Rules []map[string]string `json:"rules,omitempty"`
}
ScriptSigner represents a signer for a Neo transaction
type ScriptWitness ¶
type ScriptWitness struct {
InvocationScript string `json:"invocationScript"`
VerificationScript string `json:"verificationScript"`
}
ScriptWitness represents a witness for a Neo transaction
type Secret ¶
type Secret struct {
ID int `json:"id" db:"id"`
UserID int `json:"user_id" db:"user_id"`
Name string `json:"name" db:"name"`
Value string `json:"-" db:"value"` // Value is never returned to clients
Version int `json:"version" db:"version"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}
Secret represents a user secret
func (*Secret) ToMetadata ¶
func (s *Secret) ToMetadata() *SecretMetadata
ToMetadata converts a Secret to SecretMetadata
type SecretMetadata ¶
type SecretMetadata struct {
ID int `json:"id"`
UserID int `json:"user_id"`
Name string `json:"name"`
Version int `json:"version"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
SecretMetadata represents public information about a secret
type SecretRepository ¶
type SecretRepository interface {
Create(secret *Secret) error
GetByID(id int) (*Secret, error)
GetByUserIDAndName(userID int, name string) (*Secret, error)
List(userID int) ([]*Secret, error)
Update(secret *Secret) error
Delete(id int) error
}
SecretRepository defines methods for working with secrets
type SubscriptionStatus ¶
type SubscriptionStatus string
SubscriptionStatus represents the status of an event subscription
const ( SubscriptionStatusActive SubscriptionStatus = "active" SubscriptionStatusPaused SubscriptionStatus = "paused" SubscriptionStatusDeleted SubscriptionStatus = "deleted" SubscriptionStatusError SubscriptionStatus = "error" )
Subscription statuses
type Transaction ¶
type Transaction struct {
ID uuid.UUID `json:"id" db:"id"`
Hash string `json:"hash" db:"hash"`
Service string `json:"service" db:"service"`
EntityID *uuid.UUID `json:"entityId" db:"entity_id"`
EntityType string `json:"entityType" db:"entity_type"`
Status TransactionStatus `json:"status" db:"status"`
Type TransactionType `json:"type" db:"type"`
Data json.RawMessage `json:"data" db:"data"`
GasConsumed *int64 `json:"gasConsumed,omitempty" db:"gas_consumed"`
GasPrice int64 `json:"gasPrice" db:"gas_price"`
SystemFee int64 `json:"systemFee" db:"system_fee"`
NetworkFee int64 `json:"networkFee" db:"network_fee"`
BlockHeight *int64 `json:"blockHeight,omitempty" db:"block_height"`
BlockTime *time.Time `json:"blockTime,omitempty" db:"block_time"`
Sender string `json:"sender" db:"sender"`
Error string `json:"error,omitempty" db:"error"`
Result json.RawMessage `json:"result,omitempty" db:"result"`
CreatedAt time.Time `json:"createdAt" db:"created_at"`
UpdatedAt time.Time `json:"updatedAt" db:"updated_at"`
DeletedAt *time.Time `json:"deletedAt,omitempty" db:"deleted_at"`
}
Transaction represents a blockchain transaction
type TransactionEvent ¶
type TransactionEvent struct {
ID uuid.UUID `json:"id" db:"id"`
TransactionID uuid.UUID `json:"transactionId" db:"transaction_id"`
Status TransactionStatus `json:"status" db:"status"`
Details json.RawMessage `json:"details,omitempty" db:"details"`
Timestamp time.Time `json:"timestamp" db:"timestamp"`
}
TransactionEvent represents an event in the lifecycle of a transaction
type TransactionListResponse ¶
type TransactionListResponse struct {
Total int `json:"total"`
Page int `json:"page"`
Limit int `json:"limit"`
Transactions []Transaction `json:"transactions"`
}
TransactionListResponse represents the response for listing transactions
type TransactionStatus ¶
type TransactionStatus string
TransactionStatus represents the status of a blockchain transaction
const ( // TransactionStatusCreated - Transaction has been created but not yet submitted TransactionStatusCreated TransactionStatus = "created" // TransactionStatusPending - Transaction has been submitted to the blockchain TransactionStatusPending TransactionStatus = "pending" // TransactionStatusConfirming - Transaction has been included in a block but waiting for confirmation blocks TransactionStatusConfirming TransactionStatus = "confirming" // TransactionStatusConfirmed - Transaction has been confirmed with the required number of blocks TransactionStatusConfirmed TransactionStatus = "confirmed" // TransactionStatusFailed - Transaction has failed due to execution error or rejection TransactionStatusFailed TransactionStatus = "failed" // TransactionStatusExpired - Transaction has not been included in a block within the timeout period TransactionStatusExpired TransactionStatus = "expired" // TransactionStatusCancelled - Transaction has been cancelled before confirmation TransactionStatusCancelled TransactionStatus = "cancelled" )
type TransactionType ¶
type TransactionType string
TransactionType represents the type of blockchain transaction
const ( // TransactionTypeInvoke - Smart contract invocation TransactionTypeInvoke TransactionType = "invoke" // TransactionTypeDeployment - Smart contract deployment TransactionTypeDeployment TransactionType = "deployment" // TransactionTypeTransfer - Asset transfer TransactionTypeTransfer TransactionType = "transfer" // TransactionTypeClaimGas - GAS claim transaction TransactionTypeClaimGas TransactionType = "claim_gas" )
type TransferData ¶
type TransferData struct {
Asset string `json:"asset"`
Amount string `json:"amount"`
Recipient string `json:"recipient"`
Signers []ScriptSigner `json:"signers,omitempty"`
Network string `json:"network"`
}
TransferData represents the data specific to a transfer transaction
type Trigger ¶
type Trigger struct {
ID int `json:"id" db:"id"`
UserID int `json:"user_id" db:"user_id"`
FunctionID int `json:"function_id" db:"function_id"`
Name string `json:"name" db:"name"`
Description string `json:"description" db:"description"`
TriggerType TriggerType `json:"trigger_type" db:"trigger_type"`
TriggerConfig json.RawMessage `json:"trigger_config" db:"trigger_config"`
Status string `json:"status" db:"status"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}
Trigger represents a contract automation trigger
type TriggerEvent ¶
type TriggerEvent struct {
ID int `json:"id" db:"id"`
TriggerID int `json:"trigger_id" db:"trigger_id"`
Timestamp time.Time `json:"timestamp" db:"timestamp"`
Status string `json:"status" db:"status"`
ExecutionID int `json:"execution_id,omitempty" db:"execution_id"`
}
TriggerEvent represents a trigger execution event
type TriggerRepository ¶
type TriggerRepository interface {
Create(trigger *Trigger) error
GetByID(id int) (*Trigger, error)
GetByUserIDAndName(userID int, name string) (*Trigger, error)
List(userID int, offset, limit int) ([]*Trigger, error)
ListActiveTriggers() ([]*Trigger, error)
Update(trigger *Trigger) error
UpdateStatus(id int, status string) error
Delete(id int) error
// Event related methods
CreateEvent(event *TriggerEvent) error
GetEventByID(id int) (*TriggerEvent, error)
ListEventsByTriggerID(triggerID int, offset, limit int) ([]*TriggerEvent, error)
}
TriggerRepository defines methods for working with triggers
type TriggerType ¶
type TriggerType string
TriggerType defines the type of trigger
const ( // TriggerTypeCron is a time-based trigger using cron syntax TriggerTypeCron TriggerType = "cron" // TriggerTypePrice is a price-based trigger TriggerTypePrice TriggerType = "price" // TriggerTypeBlockchain is a blockchain event trigger TriggerTypeBlockchain TriggerType = "blockchain" )
type User ¶
type User struct {
ID int `json:"id" db:"id"`
Username string `json:"username" db:"username"`
Email string `json:"email" db:"email"`
PasswordHash string `json:"-" db:"password_hash"`
APIKey string `json:"-" db:"api_key"`
IsActive bool `json:"is_active" db:"is_active"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}
User represents a user in the system
func (*User) CheckPassword ¶
CheckPassword checks if the provided password matches the user's password
func (*User) SetPassword ¶
SetPassword sets a new password for the user
type UserRepository ¶
type UserRepository interface {
Create(user *User) error
GetByID(id int) (*User, error)
GetByUsername(username string) (*User, error)
GetByEmail(email string) (*User, error)
GetByAPIKey(apiKey string) (*User, error)
Update(user *User) error
Delete(id int) error
}
UserRepository defines methods for working with users
type WalletAccount ¶
type WalletAccount struct {
ID uuid.UUID `json:"id" db:"id"`
Service string `json:"service" db:"service"`
Address string `json:"address" db:"address"`
EncryptedPrivateKey string `json:"encryptedPrivateKey" db:"encrypted_private_key"`
PublicKey string `json:"publicKey" db:"public_key"`
CreatedAt time.Time `json:"createdAt" db:"created_at"`
UpdatedAt time.Time `json:"updatedAt" db:"updated_at"`
DeletedAt *time.Time `json:"deletedAt,omitempty" db:"deleted_at"`
}
WalletAccount represents a wallet account for transaction signing
type WithdrawalRequest ¶
type WithdrawalRequest struct {
ID string `json:"id" db:"id"`
AccountID string `json:"account_id" db:"account_id"`
UserID string `json:"user_id" db:"user_id"`
Amount string `json:"amount" db:"amount"`
Fee string `json:"fee" db:"fee"`
NetAmount string `json:"net_amount" db:"net_amount"`
Status GasBankTransactionStatus `json:"status" db:"status"`
ToAddress string `json:"to_address" db:"to_address"`
TransactionID string `json:"transaction_id" db:"transaction_id"`
ErrorMessage string `json:"error_message" db:"error_message"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}
WithdrawalRequest represents a request to withdraw funds from the gas bank