app

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AppIDV1Regex = regexp.MustCompile(`^[a-z0-9][-a-z0-9]{0,65}$`)

Functions

func GenerateAppSessionIDV1

func GenerateAppSessionIDV1(definition AppDefinitionV1) (string, error)

GenerateAppSessionIDV1 generates a deterministic app session ID from the definition using ABI encoding.

func GenerateRebalanceBatchIDV1

func GenerateRebalanceBatchIDV1(sessionVersions []AppSessionVersionV1) (string, error)

GenerateRebalanceBatchIDV1 creates a deterministic batch ID from session versions using ABI encoding. The batch ID is generated by hashing the list of (sessionID, version) pairs.

func GenerateRebalanceTransactionIDV1

func GenerateRebalanceTransactionIDV1(batchID, sessionID, asset string) (string, error)

GenerateRebalanceTransactionIDV1 creates a deterministic transaction ID for a rebalance transaction using ABI encoding.

func GenerateSessionKeyStateIDV1

func GenerateSessionKeyStateIDV1(userAddress, sessionKey string, version uint64) (string, error)

GenerateSessionKeyStateIDV1 generates a deterministic ID from user_address, session_key, and version.

func PackAppSessionKeyStateV1

func PackAppSessionKeyStateV1(state AppSessionKeyStateV1) ([]byte, error)

PackAppSessionKeyStateV1 packs the session key state for signing using ABI encoding. This is used to generate a deterministic hash that the user signs when registering/updating a session key. The user_sig field is excluded from packing since it is the signature itself.

func PackAppStateUpdateV1

func PackAppStateUpdateV1(stateUpdate AppStateUpdateV1) ([]byte, error)

PackAppStateUpdateV1 packs the AppStateUpdate for signing using ABI encoding. This is used to generate a deterministic hash that participants sign when updating an app session state.

func PackAppV1

func PackAppV1(app AppV1) ([]byte, error)

PackAppV1 packs the AppV1 for signing using ABI encoding.

func PackCreateAppSessionRequestV1

func PackCreateAppSessionRequestV1(definition AppDefinitionV1, sessionData string) ([]byte, error)

PackCreateAppSessionRequestV1 packs the Definition and SessionData for signing using ABI encoding. This is used to generate a deterministic hash that participants sign when creating an app session.

Types

type AppAllocationV1

type AppAllocationV1 struct {
	Participant string
	Asset       string
	Amount      decimal.Decimal
}

AppAllocationV1 represents the allocation of assets to a participant in an app session.

type AppDefinitionV1

type AppDefinitionV1 struct {
	ApplicationID string
	Participants  []AppParticipantV1
	Quorum        uint8
	Nonce         uint64
}

AppDefinitionV1 represents the definition for an app session.

type AppInfoV1

type AppInfoV1 struct {
	App       AppV1
	CreatedAt time.Time
	UpdatedAt time.Time
}

AppInfoV1 represents full application info including timestamps.

type AppParticipantV1

type AppParticipantV1 struct {
	WalletAddress   string
	SignatureWeight uint8
}

AppParticipantV1 represents the definition for an app participant.

type AppSessionInfoV1

type AppSessionInfoV1 struct {
	AppSessionID  string
	AppDefinition AppDefinitionV1
	IsClosed      bool
	SessionData   string
	Version       uint64
	Allocations   []AppAllocationV1
}

AppSessionInfoV1 represents information about an application session.

type AppSessionKeyStateV1

type AppSessionKeyStateV1 struct {
	// ID Hash(user_address + session_key + version)
	// UserAddress is the user wallet address
	UserAddress string
	// SessionKey is the session key address for delegation
	SessionKey string
	// Version is the version of the session key format
	Version uint64
	// ApplicationID is the application IDs associated with this session key
	ApplicationIDs []string
	// AppSessionID is the application session IDs associated with this session key
	AppSessionIDs []string
	// ExpiresAt is Unix timestamp in seconds indicating when the session key expires
	ExpiresAt time.Time
	// UserSig is the user's signature over the session key metadata to authorize the registration/update of the session key
	UserSig string
}

AppSessionKeyStateV1 represents the state of a session key.

type AppSessionKeyValidatorV1

type AppSessionKeyValidatorV1 struct {
	// contains filtered or unexported fields
}

func NewAppSessionKeySigValidatorV1

func NewAppSessionKeySigValidatorV1(ownerGetter GetAppSessionKeyOwnerFuncV1) *AppSessionKeyValidatorV1

func (*AppSessionKeyValidatorV1) Recover

func (s *AppSessionKeyValidatorV1) Recover(data, sig []byte) (string, error)

func (*AppSessionKeyValidatorV1) Verify

func (s *AppSessionKeyValidatorV1) Verify(wallet string, data, sig []byte) error

type AppSessionSignerTypeV1

type AppSessionSignerTypeV1 uint8
const (
	AppSessionSignerTypeV1_Wallet     AppSessionSignerTypeV1 = 0xA1
	AppSessionSignerTypeV1_SessionKey AppSessionSignerTypeV1 = 0xA2
)

func (AppSessionSignerTypeV1) String

func (t AppSessionSignerTypeV1) String() string

type AppSessionSignerV1

type AppSessionSignerV1 struct {
	sign.Signer
	// contains filtered or unexported fields
}

func NewAppSessionKeySignerV1

func NewAppSessionKeySignerV1(signer sign.Signer) (*AppSessionSignerV1, error)

func NewAppSessionWalletSignerV1

func NewAppSessionWalletSignerV1(signer sign.Signer) (*AppSessionSignerV1, error)

func (*AppSessionSignerV1) Sign

func (s *AppSessionSignerV1) Sign(data []byte) (sign.Signature, error)

type AppSessionStatus

type AppSessionStatus uint8
const (
	AppSessionStatusVoid AppSessionStatus = iota
	AppSessionStatusOpen
	AppSessionStatusClosed
)

func (*AppSessionStatus) Scan

func (s *AppSessionStatus) Scan(src any) error

func (AppSessionStatus) String

func (status AppSessionStatus) String() string

type AppSessionV1

type AppSessionV1 struct {
	SessionID     string
	ApplicationID string
	Participants  []AppParticipantV1
	Quorum        uint8
	Nonce         uint64
	Status        AppSessionStatus
	Version       uint64
	SessionData   string
	CreatedAt     time.Time
	UpdatedAt     time.Time
}

AppSessionV1 represents an application session in the V1 API.

type AppSessionVersionV1

type AppSessionVersionV1 struct {
	SessionID string
	Version   uint64
}

AppSessionVersionV1 represents a session ID and version pair for rebalancing operations.

type AppStateUpdateIntent

type AppStateUpdateIntent uint8
const (
	AppStateUpdateIntentOperate AppStateUpdateIntent = iota
	AppStateUpdateIntentDeposit
	AppStateUpdateIntentWithdraw
	AppStateUpdateIntentClose
	AppStateUpdateIntentRebalance
)

func (AppStateUpdateIntent) GatedAction

func (intent AppStateUpdateIntent) GatedAction() core.GatedAction

func (AppStateUpdateIntent) String

func (intent AppStateUpdateIntent) String() string

type AppStateUpdateV1

type AppStateUpdateV1 struct {
	AppSessionID string
	Intent       AppStateUpdateIntent
	Version      uint64
	Allocations  []AppAllocationV1
	SessionData  string
}

AppStateUpdateV1 represents the current state of an application session.

type AppV1

type AppV1 struct {
	ID                          string
	OwnerWallet                 string
	Metadata                    string
	Version                     uint64
	CreationApprovalNotRequired bool
}

AppV1 represents an application registry entry.

type AssetAllowanceV1

type AssetAllowanceV1 struct {
	Asset     string
	Allowance decimal.Decimal
	Used      decimal.Decimal
}

AssetAllowanceV1 represents an asset allowance with usage tracking.

type GetAppSessionKeyOwnerFuncV1

type GetAppSessionKeyOwnerFuncV1 func(sessionKeyAddr string) (string, error)

type SessionKeyV1

type SessionKeyV1 struct {
	ID          uint
	SessionKey  string
	Application string
	Allowances  []AssetAllowanceV1
	Scope       *string
	ExpiresAt   time.Time
	CreatedAt   time.Time
}

SessionKeyV1 represents a session key with spending allowances.

type SignedAppStateUpdateV1

type SignedAppStateUpdateV1 struct {
	AppStateUpdate AppStateUpdateV1
	QuorumSigs     []string
}

SignedAppStateUpdateV1 represents a signed application session state update.

Jump to

Keyboard shortcuts

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