Documentation
¶
Overview ¶
Package supabase provides NeoRequests-specific database operations.
Index ¶
- func MarshalParams(params any) json.RawMessage
- type ChainTx
- type ContractEvent
- type MiniApp
- type MiniAppRegistryUpdate
- type Notification
- type ProcessedEvent
- type Repository
- func (r *Repository) BumpMiniAppUsage(ctx context.Context, userID, appID, chainID string, ...) error
- func (r *Repository) CreateChainTx(ctx context.Context, tx *ChainTx) error
- func (r *Repository) CreateContractEvent(ctx context.Context, event *ContractEvent) error
- func (r *Repository) CreateNotification(ctx context.Context, n *Notification) error
- func (r *Repository) CreateProcessedEvent(ctx context.Context, event *ProcessedEvent) error
- func (r *Repository) CreateServiceRequest(ctx context.Context, req *ServiceRequest) error
- func (r *Repository) GetMiniApp(ctx context.Context, appID string) (*MiniApp, error)
- func (r *Repository) GetMiniAppByContractAddress(ctx context.Context, chainID, contractAddress string) (*MiniApp, error)
- func (r *Repository) HasProcessedEvent(ctx context.Context, chainID, txHash string, logIndex int) (bool, error)
- func (r *Repository) LatestProcessedBlock(ctx context.Context, chainID string) (uint64, bool, error)
- func (r *Repository) LogMiniAppTx(ctx context.Context, appID, chainID, txHash, senderAddress string, ...) error
- func (r *Repository) MarkProcessedEvent(ctx context.Context, event *ProcessedEvent) (bool, error)
- func (r *Repository) RollupMiniAppStats(ctx context.Context, date time.Time) error
- func (r *Repository) UpdateChainTx(ctx context.Context, tx *ChainTx) error
- func (r *Repository) UpdateMiniAppRegistry(ctx context.Context, appID string, update *MiniAppRegistryUpdate) error
- func (r *Repository) UpdateServiceRequest(ctx context.Context, req *ServiceRequest) error
- type RepositoryInterface
- type ServiceRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalParams ¶
func MarshalParams(params any) json.RawMessage
MarshalParams marshals params to JSON.
Types ¶
type ChainTx ¶
type ChainTx struct {
ID int64 `json:"id,omitempty"`
TxHash string `json:"tx_hash,omitempty"`
ChainID string `json:"chain_id,omitempty"`
RequestID string `json:"request_id"`
FromService string `json:"from_service"`
TxType string `json:"tx_type"`
ContractAddress string `json:"contract_address"`
MethodName string `json:"method_name"`
Params json.RawMessage `json:"params"`
GasConsumed *int64 `json:"gas_consumed,omitempty"`
Status string `json:"status,omitempty"`
RetryCount int `json:"retry_count,omitempty"`
ErrorMessage string `json:"error_message,omitempty"`
RPCEndpoint string `json:"rpc_endpoint,omitempty"`
SubmittedAt *time.Time `json:"submitted_at,omitempty"`
ConfirmedAt *time.Time `json:"confirmed_at,omitempty"`
}
ChainTx represents a chain_txs row for callback auditing.
type ContractEvent ¶
type ContractEvent struct {
ID int64 `json:"id,omitempty"`
ChainID string `json:"chain_id,omitempty"`
TxHash string `json:"tx_hash"`
BlockIndex uint64 `json:"block_index"`
ContractAddress string `json:"contract_address"`
EventName string `json:"event_name"`
AppID *string `json:"app_id,omitempty"`
State json.RawMessage `json:"state,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
}
ContractEvent represents a contract_events row.
type MiniApp ¶
type MiniApp struct {
AppID string `json:"app_id"`
DeveloperUserID string `json:"developer_user_id"`
Manifest json.RawMessage `json:"manifest"`
Status string `json:"status"`
ManifestHash string `json:"manifest_hash"`
EntryURL string `json:"entry_url"`
SupportedChains []string `json:"supported_chains"`
Contracts json.RawMessage `json:"contracts"`
Name string `json:"name"`
Description string `json:"description"`
Icon string `json:"icon"`
Banner string `json:"banner"`
Category string `json:"category"`
}
MiniApp represents a minimal MiniApp registry row needed for on-chain requests.
type MiniAppRegistryUpdate ¶
type MiniAppRegistryUpdate struct {
ChainID string `json:"chain_id,omitempty"`
ManifestHash string `json:"manifest_hash,omitempty"`
EntryURL string `json:"entry_url,omitempty"`
DeveloperPubKey string `json:"developer_pubkey,omitempty"`
Status string `json:"status,omitempty"`
ContractAddress string `json:"contract_address,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Icon string `json:"icon,omitempty"`
Banner string `json:"banner,omitempty"`
Category string `json:"category,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
}
MiniAppRegistryUpdate represents a partial update from AppRegistry sync.
type Notification ¶
type Notification struct {
ID string `json:"id,omitempty"`
AppID string `json:"app_id"`
ChainID string `json:"chain_id,omitempty"`
Title string `json:"title"`
Content string `json:"content"`
NotificationType string `json:"notification_type"`
Source string `json:"source"`
TxHash string `json:"tx_hash,omitempty"`
BlockNumber int64 `json:"block_number,omitempty"`
Priority int `json:"priority"`
}
Notification represents a miniapp_notifications row.
type ProcessedEvent ¶
type ProcessedEvent struct {
ID int64 `json:"id,omitempty"`
ChainID string `json:"chain_id"`
TxHash string `json:"tx_hash"`
LogIndex int `json:"log_index"`
BlockHeight uint64 `json:"block_height"`
BlockHash string `json:"block_hash"`
ContractAddress string `json:"contract_address"`
EventName string `json:"event_name"`
Payload json.RawMessage `json:"payload"`
Confirmations int `json:"confirmations,omitempty"`
}
ProcessedEvent represents a processed_events row for idempotency.
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository provides NeoRequests-specific data access methods.
func NewRepository ¶
func NewRepository(base *database.Repository) *Repository
NewRepository creates a new NeoRequests repository.
func (*Repository) BumpMiniAppUsage ¶
func (r *Repository) BumpMiniAppUsage(ctx context.Context, userID, appID, chainID string, gasDelta, governanceDelta *big.Int) error
BumpMiniAppUsage increments per-user MiniApp usage in Supabase.
func (*Repository) CreateChainTx ¶
func (r *Repository) CreateChainTx(ctx context.Context, tx *ChainTx) error
CreateChainTx inserts a new chain_txs row.
func (*Repository) CreateContractEvent ¶
func (r *Repository) CreateContractEvent(ctx context.Context, event *ContractEvent) error
CreateContractEvent inserts a contract event row.
func (*Repository) CreateNotification ¶
func (r *Repository) CreateNotification(ctx context.Context, n *Notification) error
CreateNotification inserts a notification record.
func (*Repository) CreateProcessedEvent ¶
func (r *Repository) CreateProcessedEvent(ctx context.Context, event *ProcessedEvent) error
CreateProcessedEvent inserts a processed_events row.
func (*Repository) CreateServiceRequest ¶
func (r *Repository) CreateServiceRequest(ctx context.Context, req *ServiceRequest) error
CreateServiceRequest inserts a new service request.
func (*Repository) GetMiniApp ¶
GetMiniApp retrieves a MiniApp manifest row by app_id.
func (*Repository) GetMiniAppByContractAddress ¶
func (r *Repository) GetMiniAppByContractAddress(ctx context.Context, chainID, contractAddress string) (*MiniApp, error)
GetMiniAppByContractAddress retrieves a MiniApp manifest row by chain-specific contract address.
func (*Repository) HasProcessedEvent ¶
func (r *Repository) HasProcessedEvent(ctx context.Context, chainID, txHash string, logIndex int) (bool, error)
HasProcessedEvent checks if the event was already processed.
func (*Repository) LatestProcessedBlock ¶
func (r *Repository) LatestProcessedBlock(ctx context.Context, chainID string) (uint64, bool, error)
LatestProcessedBlock returns the highest processed block height for a chain.
func (*Repository) LogMiniAppTx ¶
func (r *Repository) LogMiniAppTx( ctx context.Context, appID, chainID, txHash, senderAddress string, blockTime time.Time, ) error
LogMiniAppTx records a MiniApp transaction for usage analytics.
func (*Repository) MarkProcessedEvent ¶
func (r *Repository) MarkProcessedEvent(ctx context.Context, event *ProcessedEvent) (bool, error)
MarkProcessedEvent attempts to insert a processed event and returns true if inserted. If the event already exists, it returns false.
func (*Repository) RollupMiniAppStats ¶
RollupMiniAppStats triggers the server-side stats rollup for the given date.
func (*Repository) UpdateChainTx ¶
func (r *Repository) UpdateChainTx(ctx context.Context, tx *ChainTx) error
UpdateChainTx updates an existing chain_txs row by id.
func (*Repository) UpdateMiniAppRegistry ¶
func (r *Repository) UpdateMiniAppRegistry(ctx context.Context, appID string, update *MiniAppRegistryUpdate) error
UpdateMiniAppRegistry updates a MiniApp record with AppRegistry data.
func (*Repository) UpdateServiceRequest ¶
func (r *Repository) UpdateServiceRequest(ctx context.Context, req *ServiceRequest) error
UpdateServiceRequest updates an existing service request by id.
type RepositoryInterface ¶
type RepositoryInterface interface {
GetMiniApp(ctx context.Context, appID string) (*MiniApp, error)
GetMiniAppByContractAddress(ctx context.Context, chainID, contractAddress string) (*MiniApp, error)
UpdateMiniAppRegistry(ctx context.Context, appID string, update *MiniAppRegistryUpdate) error
LogMiniAppTx(ctx context.Context, appID, chainID, txHash, senderAddress string, blockTime time.Time) error
RollupMiniAppStats(ctx context.Context, date time.Time) error
BumpMiniAppUsage(ctx context.Context, userID, appID, chainID string, gasDelta, governanceDelta *big.Int) error
CreateServiceRequest(ctx context.Context, req *ServiceRequest) error
UpdateServiceRequest(ctx context.Context, req *ServiceRequest) error
CreateChainTx(ctx context.Context, tx *ChainTx) error
UpdateChainTx(ctx context.Context, tx *ChainTx) error
CreateContractEvent(ctx context.Context, event *ContractEvent) error
HasProcessedEvent(ctx context.Context, chainID, txHash string, logIndex int) (bool, error)
CreateProcessedEvent(ctx context.Context, event *ProcessedEvent) error
MarkProcessedEvent(ctx context.Context, event *ProcessedEvent) (bool, error)
LatestProcessedBlock(ctx context.Context, chainID string) (uint64, bool, error)
CreateNotification(ctx context.Context, n *Notification) error
}
RepositoryInterface defines NeoRequests data access methods.
type ServiceRequest ¶
type ServiceRequest struct {
ID string `json:"id,omitempty"`
UserID string `json:"user_id"`
ChainID string `json:"chain_id,omitempty"`
ServiceType string `json:"service_type"`
Status string `json:"status"`
Payload json.RawMessage `json:"payload"`
Result json.RawMessage `json:"result,omitempty"`
Error string `json:"error,omitempty"`
GasUsed int64 `json:"gas_used,omitempty"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
ChainTxID *int64 `json:"chain_tx_id,omitempty"`
RetryCount int `json:"retry_count,omitempty"`
LastError string `json:"last_error,omitempty"`
Signature []byte `json:"signature,omitempty"`
SignerKeyID string `json:"signer_key_id,omitempty"`
}
ServiceRequest represents a service_requests row for audit tracking.