types

package
v0.1.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 23, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrReportCooldown = errors.New("report cooldown active")
)
View Source
var FeeDefaultPolicy = &types.Policy{
	Rules: []*types.Rule{
		{
			Resource: "ethereum.send",
			Effect:   types.Effect_EFFECT_ALLOW,
			ParameterConstraints: []*types.ParameterConstraint{
				{
					ParameterName: "asset",
					Constraint: &types.Constraint{
						Type: types.ConstraintType_CONSTRAINT_TYPE_FIXED,
						Value: &types.Constraint_FixedValue{
							FixedValue: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
						},
						Required: false,
					},
				},
				{
					ParameterName: "from_address",
					Constraint: &types.Constraint{
						Type:     types.ConstraintType_CONSTRAINT_TYPE_ANY,
						Required: true,
					},
				},
				{
					ParameterName: "amount",
					Constraint: &types.Constraint{
						Type:     types.ConstraintType_CONSTRAINT_TYPE_ANY,
						Required: true,
					},
				},
				{
					ParameterName: "to_address",
					Constraint: &types.Constraint{
						Type: types.ConstraintType_CONSTRAINT_TYPE_MAGIC_CONSTANT,
						Value: &types.Constraint_MagicConstantValue{
							MagicConstantValue: types.MagicConstant_VULTISIG_TREASURY,
						},
						Required: true,
					},
				},
			},
		},
	},
}

TODO: Temporary solution for testing purposes. This will be replaced by integrating the fee policy into every relevant policy.

Functions

This section is empty.

Types

type APIKey

type APIKey struct {
	ID        string         `json:"id"`
	ApiKey    string         `json:"apiKey"`
	PluginID  types.PluginID `json:"pluginId"`
	Status    int64          `json:"status"`
	ExpiresAt *time.Time     `json:"expires_at"`
}

type CreditMetadata

type CreditMetadata struct {
	DebitFeeID      uint64 `json:"debit_fee_id"`     // ID of the debit transaction
	TransactionHash string `json:"transaction_hash"` // Transaction hash in blockchain
	Network         string `json:"network"`          // Blockchain network (e.g., "ethereum", "polygon")
}

type FAQItem

type FAQItem struct {
	Question string `json:"question" yaml:"question,omitempty"`
	Answer   string `json:"answer"  yaml:"answer,omitempty"`
}

type FeeHistoryPaginatedList added in v0.1.16

type FeeHistoryPaginatedList struct {
	History    []PluginFeeResponse `json:"history"`
	TotalCount uint32              `json:"total_count"`
}

type FeeWithStatus added in v0.1.16

type FeeWithStatus struct {
	vtypes.Fee
	Status vtypes.FeeStatus
}

FeeWithStatus extends Fee with derived status from batch

type PauseHistoryRecord added in v0.1.16

type PauseHistoryRecord struct {
	ID                uuid.UUID      `json:"id"`
	PluginID          types.PluginID `json:"plugin_id"`
	Action            string         `json:"action"`
	ReportCountWindow *int           `json:"report_count_window,omitempty"`
	ActiveUsers       *int           `json:"active_users,omitempty"`
	ThresholdRate     *float64       `json:"threshold_rate,omitempty"`
	Reason            *string        `json:"reason,omitempty"`
	TriggeredBy       *string        `json:"triggered_by,omitempty"`
	CreatedAt         time.Time      `json:"created_at"`
}

type Plugin

type Plugin struct {
	ID             types.PluginID  `json:"id" yaml:"id" validate:"required"`
	Title          string          `json:"title" yaml:"title" validate:"required"`
	Description    string          `json:"description" yaml:"description" validate:"required"`
	ServerEndpoint string          `json:"server_endpoint" yaml:"server_endpoint" validate:"required"`
	Category       PluginCategory  `json:"category_id" yaml:"category" validate:"required"`
	CreatedAt      time.Time       `json:"created_at" yaml:"-"`
	UpdatedAt      time.Time       `json:"updated_at" yaml:"-"`
	Pricing        []types.Pricing `json:"pricing,omitempty" yaml:"-"`                             // New field for multiple pricing options
	LogoURL        string          `json:"logo_url,omitempty" yaml:"logo_url,omitempty"`           // New field, should be validated once plugins have this data in db.
	ThumbnailURL   string          `json:"thumbnail_url,omitempty" yaml:"thumbnail_url,omitempty"` // New field, should be validated once plugins have this data in db.
	Images         []PluginImage   `json:"images,omitempty" yaml:"images,omitempty"`               // New field, should be validated once plugins have this data in db.
	FAQs           []FAQItem       `json:"faqs,omitempty" yaml:"faqs,omitempty"`
	Features       []string        `json:"features,omitempty" yaml:"features,omitempty"`
	Audited        bool            `json:"audited" yaml:"audited,omitempty"`
	RatesCount     int             `json:"rates_count" yaml:"-"`
	AvgRating      float64         `json:"avg_rating" yaml:"-"`
	Installations  int             `json:"installations" yaml:"-"`
}

type PluginAvgRatingDto

type PluginAvgRatingDto struct {
	PluginID  string  `json:"plugin_id"`
	AvgRating float64 `json:"avg_rating"`
}

type PluginBillingSummary added in v0.1.16

type PluginBillingSummary struct {
	PluginID    vtypes.PluginID `json:"plugin_id"`
	AppName     string          `json:"app_name"`
	Pricing     string          `json:"pricing"` // Formatted: "0.50 USDC one-time + 0.01 USDC per transaction"
	StartDate   time.Time       `json:"start_date"`
	NextPayment *time.Time      `json:"next_payment"` // nil for non-recurring
	TotalFees   string          `json:"total_fees"`
}

PluginBillingSummary is the response DTO for plugin billing info

type PluginBillingSummaryList added in v0.1.16

type PluginBillingSummaryList struct {
	Plugins    []PluginBillingSummary `json:"plugins"`
	TotalCount uint32                 `json:"total_count"`
}

PluginBillingSummaryList is the response for the billing summary endpoint

type PluginBillingSummaryRow added in v0.1.16

type PluginBillingSummaryRow struct {
	PluginID  string
	StartDate time.Time
	TotalFees uint64
}

PluginBillingSummaryRow is the raw data from the database query

type PluginCategory

type PluginCategory string
const (
	PluginCategoryAIAgent PluginCategory = "ai-agent"
	PluginCategoryApp     PluginCategory = "app"
)

func (PluginCategory) IsValid

func (pc PluginCategory) IsValid() bool

IsValid checks if the plugin category is valid

func (PluginCategory) String

func (pc PluginCategory) String() string

String returns the string representation of the plugin category

type PluginCreateDto

type PluginCreateDto struct {
	Type           string                       `json:"type" validate:"required"`
	Title          string                       `json:"title" validate:"required"`
	Description    string                       `json:"description" validate:"required"`
	Metadata       json.RawMessage              `json:"metadata" validate:"required"`
	ServerEndpoint string                       `json:"server_endpoint" validate:"required"`
	LogoURL        string                       `json:"logo_url"`
	CategoryID     uuid.UUID                    `json:"category_id" validate:"required"`
	PricingData    []types.PricingCreateDataDto `json:"pricing_data" validate:"required"`
}

type PluginFeeResponse added in v0.1.16

type PluginFeeResponse struct {
	ID              uint64           `json:"id"`
	PluginID        vtypes.PluginID  `json:"plugin_id"`
	AppName         string           `json:"app_name"` // Plugin title for display
	PolicyID        uuid.UUID        `json:"policy_id"`
	PublicKey       string           `json:"public_key"`
	TransactionType string           `json:"transaction_type"` // fee type: installation_fee, subscription_fee, etc.
	Amount          string           `json:"amount"`           // String for consistency with plugin history
	Status          vtypes.FeeStatus `json:"status"`
	CreatedAt       time.Time        `json:"created_at"`
}

PluginFeeResponse is the response DTO for plugin fees. It matches the transaction history format for frontend consistency.

func FromFeesWithStatus added in v0.1.16

func FromFeesWithStatus(fees []FeeWithStatus, titleMap map[string]string) []PluginFeeResponse

FromFeesWithStatus converts a slice of FeeWithStatus to a slice of PluginFeeResponse titleMap maps plugin_id to app name/title

type PluginFilters

type PluginFilters struct {
	Term       *string    `json:"term"`
	TagID      *uuid.UUID `json:"tag_id"`
	CategoryID *string    `json:"category_id"`
}

type PluginImage

type PluginImage struct {
	URL       string `json:"url" yaml:"url"`
	Caption   string `json:"caption" yaml:"caption,omitempty"`
	AltText   string `json:"alt_text" yaml:"alt_text,omitempty"`
	SortOrder int    `json:"sort_order" yaml:"sort_order,omitempty"` // for carousels
	ZIndex    int    `json:"z_index" yaml:"z_index,omitempty"`       // for overlays
}

type PluginOwner added in v0.1.16

type PluginOwner struct {
	PluginID         vtypes.PluginID     `json:"plugin_id"`
	PublicKey        string              `json:"public_key"`
	Active           bool                `json:"active"`
	Role             PluginOwnerRole     `json:"role"`
	AddedVia         PluginOwnerAddedVia `json:"added_via"`
	AddedByPublicKey string              `json:"added_by_public_key,omitempty"`
	CreatedAt        time.Time           `json:"created_at"`
	UpdatedAt        time.Time           `json:"updated_at"`
}

type PluginOwnerAddedVia added in v0.1.16

type PluginOwnerAddedVia string
const (
	PluginOwnerAddedViaBootstrap PluginOwnerAddedVia = "bootstrap_plugin_key"
	PluginOwnerAddedViaOwnerAPI  PluginOwnerAddedVia = "owner_api"
	PluginOwnerAddedViaAdminCLI  PluginOwnerAddedVia = "admin_cli"
)

type PluginOwnerRole added in v0.1.16

type PluginOwnerRole string
const (
	PluginOwnerRoleAdmin PluginOwnerRole = "admin"
)

type PluginPolicyPaginatedList

type PluginPolicyPaginatedList struct {
	Policies   []types.PluginPolicy `json:"policies" validate:"required"`
	TotalCount int                  `json:"total_count" validate:"required"`
}

type PluginPolicySync

type PluginPolicySync struct {
	ID         uuid.UUID        `json:"id" validate:"required"`
	PolicyID   uuid.UUID        `json:"policy_id" validate:"required"`
	PluginID   ptypes.PluginID  `json:"plugin_id" validate:"required"`
	Signature  string           `json:"signature" validate:"required"`
	SyncType   PolicySyncType   `json:"sync_type" validate:"required"`
	Status     PolicySyncStatus `json:"status" validate:"required"`
	FailReason string           `json:"fail_reason"` // when synced is false, this field contains the reason for the failure
}

type PluginRating

type PluginRating struct {
	PluginID string `json:"plugin_id"`
	Rating   int    `json:"rating"`
	Count    int    `json:"count"`
}

type PluginRatingDto

type PluginRatingDto struct {
	Rating int `json:"rating"`
	Count  int `json:"count"`
}

type PluginReport added in v0.1.16

type PluginReport struct {
	PluginID       types.PluginID `json:"plugin_id"`
	ReporterPubKey string         `json:"reporter_public_key"`
	Reason         string         `json:"reason"`
	CreatedAt      time.Time      `json:"created_at"`
	LastReportedAt time.Time      `json:"last_reported_at"`
	ReportCount    int            `json:"report_count"`
}

type PluginTotalCount

type PluginTotalCount struct {
	ID         types.PluginID `json:"id" validate:"required"`
	TotalCount int            `json:"total_count" validate:"required"`
}

type PluginTransactionResponse added in v0.1.16

type PluginTransactionResponse struct {
	ID            uuid.UUID            `json:"id"`
	PluginID      vtypes.PluginID      `json:"plugin_id"`
	AppName       string               `json:"app_name"` // Plugin title for display
	PolicyID      uuid.UUID            `json:"policy_id"`
	PublicKey     string               `json:"public_key"` // Matches Fee format (was from_public_key)
	ToPublicKey   string               `json:"to_public_key"`
	Chain         common.Chain         `json:"chain"`
	TokenID       string               `json:"token_id"`
	Amount        *string              `json:"amount"` // Transaction amount in base units
	TxHash        *string              `json:"tx_hash"`
	Status        storage.TxStatus     `json:"status"`
	StatusOnChain *rpc.TxOnChainStatus `json:"status_onchain"`
	CreatedAt     time.Time            `json:"created_at"`
	UpdatedAt     time.Time            `json:"updated_at"`
	BroadcastedAt *time.Time           `json:"broadcasted_at"`
}

PluginTransactionResponse is the response DTO for plugin transactions. It matches the Fee format as closely as possible for frontend consistency.

func FromStorageTxs added in v0.1.16

func FromStorageTxs(txs []storage.Tx, titleMap map[string]string) []PluginTransactionResponse

FromStorageTxs converts a slice of storage.Tx to a slice of PluginTransactionResponse titleMap maps plugin_id to app name/title

type PluginUpdateDto

type PluginUpdateDto struct {
	Title          string                       `json:"title"`
	Description    string                       `json:"description"`
	Metadata       json.RawMessage              `json:"metadata"`
	ServerEndpoint string                       `json:"server_endpoint"`
	LogoURL        string                       `json:"logo_url"`
	PricingData    []types.PricingCreateDataDto `json:"pricing_data"`
	CategoryID     uuid.UUID                    `json:"category_id"`
}

using references on struct fields allows us to process partially field DTOs

type PluginWithRatings

type PluginWithRatings struct {
	Plugin
	Ratings []PluginRatingDto `json:"ratings,omitempty"`
}

PluginWithRatings is used for API responses that include rating statistics

type PluginsPaginatedList

type PluginsPaginatedList struct {
	Plugins    []Plugin `json:"plugins"`
	TotalCount int      `json:"total_count"`
}

type PolicySyncStatus

type PolicySyncStatus int
const (
	NotSynced PolicySyncStatus = iota
	Synced    PolicySyncStatus = iota + 1
	Failed    PolicySyncStatus = iota + 2
)

type PolicySyncType

type PolicySyncType int
const (
	AddPolicy PolicySyncType = iota
	UpdatePolicy
	RemovePolicy
)

type PricingInfo added in v0.1.16

type PricingInfo struct {
	Type      string  // once, recurring, per-tx
	Amount    uint64  // amount in smallest unit
	Asset     string  // usdc
	Frequency *string // daily, weekly, biweekly, monthly (nil for non-recurring)
}

PricingInfo represents a single pricing entry for a plugin

type RecipeFunctions

type RecipeFunctions struct {
	ID        string   `json:"id"`
	Functions []string `json:"functions"`
}

type ReportCreateRequest added in v0.1.16

type ReportCreateRequest struct {
	Reason string `json:"reason" validate:"required"`
}

type ReportSubmitResult added in v0.1.16

type ReportSubmitResult struct {
	Status       string `json:"status"`
	PluginPaused bool   `json:"plugin_paused"`
}

type Review

type Review struct {
	ID        string    `json:"id" validate:"required"`
	Address   string    `json:"address" validate:"required"`
	Rating    int       `json:"rating" validate:"required,min=1,max=5"`
	Comment   string    `json:"comment,omitempty"`
	CreatedAt time.Time `json:"created_at"`
	PluginId  string    `json:"plugin_id" validate:"required"`
}

type ReviewCreateDto

type ReviewCreateDto struct {
	Address string `json:"address" validate:"required"`
	Rating  int    `json:"rating" validate:"required"`
	Comment string `json:"comment,omitempty"`
}

type ReviewDto

type ReviewDto struct {
	ID        string            `json:"id" validate:"required"`
	Address   string            `json:"address" validate:"required"`
	Rating    int               `json:"rating" validate:"required"`
	Comment   string            `json:"comment,omitempty"`
	CreatedAt time.Time         `json:"created_at"`
	PluginId  string            `json:"plugin_id" validate:"required"`
	Ratings   []PluginRatingDto `json:"ratings,omitempty"`
}

type ReviewsDto

type ReviewsDto struct {
	Reviews    []Review `json:"reviews"`
	TotalCount int      `json:"total_count"`
}

type Tag

type Tag struct {
	ID        string    `json:"id" validate:"required"`
	Name      string    `json:"name" validate:"required,min=2,max=50"`
	CreatedAt time.Time `json:"created_at" validate:"required"`
}

Tag represents a plugin tag with unique identifier, name

type TimeTrigger

type TimeTrigger struct {
	PolicyID       string            `json:"policy_id"`
	CronExpression string            `json:"cron_expression"`
	StartTime      time.Time         `json:"start_time"`
	EndTime        *time.Time        `json:"end_time"`
	Frequency      string            `json:"frequency"`
	Interval       int               `json:"interval"`
	LastExecution  *time.Time        `json:"last_execution"`
	Status         TimeTriggerStatus `json:"status"`
}

type TimeTriggerStatus

type TimeTriggerStatus string
const (
	StatusTimeTriggerPending TimeTriggerStatus = "PENDING"
	StatusTimeTriggerRunning TimeTriggerStatus = "RUNNING"
)

type TransactionHistoryPaginatedList

type TransactionHistoryPaginatedList struct {
	History    []PluginTransactionResponse `json:"history"`
	TotalCount uint32                      `json:"total_count"`
}

type VaultToken

type VaultToken struct {
	ID         string     `json:"id"`
	TokenID    string     `json:"token_id"`
	PublicKey  string     `json:"public_key"`
	ExpiresAt  time.Time  `json:"expires_at"`
	CreatedAt  time.Time  `json:"created_at"`
	UpdatedAt  time.Time  `json:"updated_at"`
	LastUsedAt time.Time  `json:"last_used_at"`
	RevokedAt  *time.Time `json:"revoked_at"`
}

VaultToken represents a token stored in the database

func (*VaultToken) IsRevoked

func (t *VaultToken) IsRevoked() bool

type VaultTokenCreate

type VaultTokenCreate struct {
	PublicKey string    `json:"public_key"`
	TokenID   string    `json:"token_id"`
	ExpiresAt time.Time `json:"expires_at"`
}

VaultTokenCreate represents the data needed to create a new vault token

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL