commands

package
v0.184.48 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2024 License: MPL-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	WalletResponseMaxInterval = 20 * time.Minute

	ErrWalletResponseTimeout                  = fmt.Errorf("timeout waiting for wallet response")
	ErrEmptyAccountsShared                    = fmt.Errorf("empty accounts were shared by wallet")
	ErrRequestAccountsRejectedByUser          = fmt.Errorf("request accounts was rejected by user")
	ErrSendTransactionRejectedByUser          = fmt.Errorf("send transaction was rejected by user")
	ErrPersonalSignRejectedByUser             = fmt.Errorf("personal sign was rejected by user")
	ErrEmptyRequestID                         = fmt.Errorf("empty requestID")
	ErrAnotherConnectorOperationIsAwaitingFor = fmt.Errorf("another connector operation is awaiting for user input")
)
View Source
var (
	ErrAccountsRequestDeniedByUser = errors.New("accounts request denied by user")
	ErrNoAccountsAvailable         = errors.New("no accounts available")
)

errors

View Source
var (
	ErrNoRequestPermissionsParamsFound = errors.New("no request permission params found")
	ErrMultipleKeysFound               = errors.New("multiple methodNames found in request permissions params")
	ErrInvalidParamType                = errors.New("invalid parameter type")
)
View Source
var (
	ErrRequestMissingDAppData   = errors.New("request missing dApp data")
	ErrDAppIsNotPermittedByUser = errors.New("dApp is not permitted by user")
	ErrEmptyRPCParams           = errors.New("empty rpc params")
)

errors

View Source
var (
	ErrParamsFromAddressIsNotShared = errors.New("from parameter address is not dApp's shared account")
	ErrNoTransactionParamsFound     = errors.New("no transaction in params found")
)
View Source
var (
	ErrNoActiveNetworks     = errors.New("no active networks")
	ErrUnsupportedNetwork   = errors.New("unsupported network")
	ErrNoChainIDParamsFound = errors.New("no chain id in params found")
)

errors

View Source
var (
	ErrInvalidParamsStructure = errors.New("invalid params structure")
)

Functions

func FormatAccountAddressToResponse added in v0.182.41

func FormatAccountAddressToResponse(address types.Address) []string

func PersistDAppData

func PersistDAppData(db *sql.DB, dApp signal.ConnectorDApp, sharedAccount types.Address, chainID uint64) error

func SetupTestDB

func SetupTestDB(t *testing.T) (db *sql.DB, close func())

Types

type AccountsCommand

type AccountsCommand struct {
	Db *sql.DB
}

func (*AccountsCommand) Execute

func (c *AccountsCommand) Execute(request RPCRequest) (interface{}, error)

type ChainIDCommand

type ChainIDCommand struct {
	NetworkManager NetworkManagerInterface
	Db             *sql.DB
}

func (*ChainIDCommand) Execute

func (c *ChainIDCommand) Execute(request RPCRequest) (interface{}, error)

type ClientSideHandler

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

func NewClientSideHandler

func NewClientSideHandler() *ClientSideHandler

func (*ClientSideHandler) PersonalSignAccepted added in v0.183.43

func (c *ClientSideHandler) PersonalSignAccepted(args PersonalSignAcceptedArgs) error

func (*ClientSideHandler) PersonalSignRejected added in v0.183.43

func (c *ClientSideHandler) PersonalSignRejected(args RejectedArgs) error

func (*ClientSideHandler) RequestAccountsAccepted

func (c *ClientSideHandler) RequestAccountsAccepted(args RequestAccountsAcceptedArgs) error

func (*ClientSideHandler) RequestAccountsRejected

func (c *ClientSideHandler) RequestAccountsRejected(args RejectedArgs) error

func (*ClientSideHandler) RequestPersonalSign added in v0.183.43

func (c *ClientSideHandler) RequestPersonalSign(dApp signal.ConnectorDApp, challenge, address string) (string, error)

func (*ClientSideHandler) RequestSendTransaction

func (c *ClientSideHandler) RequestSendTransaction(dApp signal.ConnectorDApp, chainID uint64, txArgs *transactions.SendTxArgs) (types.Hash, error)

func (*ClientSideHandler) RequestShareAccountForDApp

func (c *ClientSideHandler) RequestShareAccountForDApp(dApp signal.ConnectorDApp) (types.Address, uint64, error)

func (*ClientSideHandler) SendTransactionAccepted

func (c *ClientSideHandler) SendTransactionAccepted(args SendTransactionAcceptedArgs) error

func (*ClientSideHandler) SendTransactionRejected

func (c *ClientSideHandler) SendTransactionRejected(args RejectedArgs) error

type ClientSideHandlerInterface

type ClientSideHandlerInterface interface {
	RequestShareAccountForDApp(dApp signal.ConnectorDApp) (types.Address, uint64, error)
	RequestAccountsAccepted(args RequestAccountsAcceptedArgs) error
	RequestAccountsRejected(args RejectedArgs) error

	RequestSendTransaction(dApp signal.ConnectorDApp, chainID uint64, txArgs *transactions.SendTxArgs) (types.Hash, error)
	SendTransactionAccepted(args SendTransactionAcceptedArgs) error
	SendTransactionRejected(args RejectedArgs) error

	RequestPersonalSign(dApp signal.ConnectorDApp, challenge, address string) (string, error)
	PersonalSignAccepted(args PersonalSignAcceptedArgs) error
	PersonalSignRejected(args RejectedArgs) error
}

type EventType

type EventType struct {
	Type  string          `json:"type"`
	Event json.RawMessage `json:"event"`
}

type Message

type Message struct {
	Type MessageType
	Data interface{}
}

type MessageType

type MessageType int
const (
	RequestAccountsAccepted MessageType = iota
	SendTransactionAccepted
	PersonalSignAccepted
	Rejected
)

type NetworkManagerInterface

type NetworkManagerInterface interface {
	GetActiveNetworks() ([]*params.Network, error)
}

type NetworkManagerMock

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

func (*NetworkManagerMock) GetActiveNetworks

func (nm *NetworkManagerMock) GetActiveNetworks() ([]*params.Network, error)

func (*NetworkManagerMock) SetNetworks

func (nm *NetworkManagerMock) SetNetworks(networks []*params.Network)

type Permission added in v0.182.39

type Permission struct {
	ParentCapability string `json:"parentCapability"`
	Date             string `json:"date"`
}

type PersonalSignAcceptedArgs added in v0.183.43

type PersonalSignAcceptedArgs struct {
	RequestID string `json:"requestId"`
	Signature string `json:"signature"`
}

type PersonalSignCommand added in v0.183.43

type PersonalSignCommand struct {
	Db            *sql.DB
	ClientHandler ClientSideHandlerInterface
}

func (*PersonalSignCommand) Execute added in v0.183.43

func (c *PersonalSignCommand) Execute(request RPCRequest) (interface{}, error)

type PersonalSignParams added in v0.183.43

type PersonalSignParams struct {
	Challenge string `json:"challenge"`
	Address   string `json:"address"`
}

type RPCClientInterface

type RPCClientInterface interface {
	CallRaw(body string) string
}

type RPCClientMock

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

func (*RPCClientMock) CallRaw

func (c *RPCClientMock) CallRaw(request string) string

func (*RPCClientMock) SetResponse

func (c *RPCClientMock) SetResponse(response string)

type RPCCommand

type RPCCommand interface {
	Execute(request RPCRequest) (interface{}, error)
}

type RPCRequest

type RPCRequest struct {
	JSONRPC string        `json:"jsonrpc"`
	ID      int           `json:"id"`
	Method  string        `json:"method"`
	Params  []interface{} `json:"params"`
	URL     string        `json:"url"`
	Name    string        `json:"name"`
	IconURL string        `json:"iconUrl"`
}

func ConstructRPCRequest

func ConstructRPCRequest(method string, params []interface{}, dApp *signal.ConnectorDApp) (RPCRequest, error)

func RPCRequestFromJSON

func RPCRequestFromJSON(inputJSON string) (RPCRequest, error)

func (*RPCRequest) Validate

func (r *RPCRequest) Validate() error

type RawAccountsResponse

type RawAccountsResponse struct {
	JSONRPC string             `json:"jsonrpc"`
	ID      int                `json:"id"`
	Result  []accounts.Account `json:"result"`
}

type RejectedArgs

type RejectedArgs struct {
	RequestID string `json:"requestId"`
}

type RequestAccountsAcceptedArgs

type RequestAccountsAcceptedArgs struct {
	RequestID string        `json:"requestId"`
	Account   types.Address `json:"account"`
	ChainID   uint64        `json:"chainId"`
}

type RequestAccountsCommand

type RequestAccountsCommand struct {
	ClientHandler ClientSideHandlerInterface
	Db            *sql.DB
}

func (*RequestAccountsCommand) Execute

func (c *RequestAccountsCommand) Execute(request RPCRequest) (interface{}, error)

type RequestPermissionsCommand added in v0.182.39

type RequestPermissionsCommand struct{}

func (*RequestPermissionsCommand) Execute added in v0.182.39

func (c *RequestPermissionsCommand) Execute(request RPCRequest) (interface{}, error)

type RevokePermissionsCommand added in v0.182.41

type RevokePermissionsCommand struct {
	Db *sql.DB
}

func (*RevokePermissionsCommand) Execute added in v0.182.41

func (c *RevokePermissionsCommand) Execute(request RPCRequest) (interface{}, error)

type SendTransactionAcceptedArgs

type SendTransactionAcceptedArgs struct {
	RequestID string     `json:"requestId"`
	Hash      types.Hash `json:"hash"`
}

type SendTransactionCommand

type SendTransactionCommand struct {
	Db            *sql.DB
	ClientHandler ClientSideHandlerInterface
}

func (*SendTransactionCommand) Execute

func (c *SendTransactionCommand) Execute(request RPCRequest) (interface{}, error)

type SwitchEthereumChainCommand

type SwitchEthereumChainCommand struct {
	NetworkManager NetworkManagerInterface
	Db             *sql.DB
}

func (*SwitchEthereumChainCommand) Execute

func (c *SwitchEthereumChainCommand) Execute(request RPCRequest) (interface{}, error)

Jump to

Keyboard shortcuts

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