intents

package
v0.30.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 21 Imported by: 1

Documentation

Overview

sequence-waas-intents v0.1.0 4e0514d799b9cb7630838b4ff70717bbfb3ceebb -- Code generated by webrpc-gen@v0.15.5 with golang generator. DO NOT EDIT.

webrpc-gen -schema=intent.ridl -target=golang -pkg=intents -client -out=./intent.gen.go

Index

Constants

View Source
const (
	IntentNameOpenSession           = "openSession"
	IntentNameCloseSession          = "closeSession"
	IntentNameValidateSession       = "validateSession"
	IntentNameFinishValidateSession = "finishValidateSession"
	IntentNameListSessions          = "listSessions"
	IntentNameGetSession            = "getSession"
	IntentNameSessionAuthProof      = "sessionAuthProof"
	IntentNameSignMessage           = "signMessage"
	IntentNameFeeOptions            = "feeOptions"
	IntentNameSendTransaction       = "sendTransaction"
	IntentNameGetTransactionReceipt = "getTransactionReceipt"
)
View Source
const (
	IntentResponseCodeSessionOpened      = "sessionOpened"
	IntentResponseCodeValidationRequired = "validationRequired"
	IntentResponseCodeValidationStarted  = "validationStarted"
	IntentResponseCodeValidationFinished = "validationFinished"
	IntentResponseCodeSessionClosed      = "sessionClosed"
	IntentResponseCodeSessionsListed     = "sessionsListed"
	IntentResponseCodeSessionAuthProof   = "sessionAuthProof"
	IntentResponseCodeSignedMessage      = "signedMessage"
	IntentResponseCodeFeeOptions         = "feeOptions"
	IntentResponseCodeTransactionReceipt = "transactionReceipt"
	IntentResponseCodeTransactionFailed  = "transactionFailed"
	IntentResponseCodeGetSessionResponse = "getSessionResponse"
)
View Source
const IntentAllowedTimeDriftInSec = 5
View Source
const IntentValidTimeInSec = 60
View Source
const SendTransactionFailedCode = "transactionFailed"
View Source
const SendTransactionResponseCode = "transactionReceipt"

Variables

View Source
var (
	HTTPClientRequestHeadersCtxKey = &contextKey{"HTTPClientRequestHeaders"}
	HTTPRequestCtxKey              = &contextKey{"HTTPRequest"}

	ServiceNameCtxKey = &contextKey{"ServiceName"}

	MethodNameCtxKey = &contextKey{"MethodName"}
)
View Source
var (
	ErrWebrpcEndpoint           = WebRPCError{Code: 0, Name: "WebrpcEndpoint", Message: "endpoint error", HTTPStatus: 400}
	ErrWebrpcRequestFailed      = WebRPCError{Code: -1, Name: "WebrpcRequestFailed", Message: "request failed", HTTPStatus: 400}
	ErrWebrpcBadRoute           = WebRPCError{Code: -2, Name: "WebrpcBadRoute", Message: "bad route", HTTPStatus: 404}
	ErrWebrpcBadMethod          = WebRPCError{Code: -3, Name: "WebrpcBadMethod", Message: "bad method", HTTPStatus: 405}
	ErrWebrpcBadRequest         = WebRPCError{Code: -4, Name: "WebrpcBadRequest", Message: "bad request", HTTPStatus: 400}
	ErrWebrpcBadResponse        = WebRPCError{Code: -5, Name: "WebrpcBadResponse", Message: "bad response", HTTPStatus: 500}
	ErrWebrpcServerPanic        = WebRPCError{Code: -6, Name: "WebrpcServerPanic", Message: "server panic", HTTPStatus: 500}
	ErrWebrpcInternalError      = WebRPCError{Code: -7, Name: "WebrpcInternalError", Message: "internal error", HTTPStatus: 500}
	ErrWebrpcClientDisconnected = WebRPCError{Code: -8, Name: "WebrpcClientDisconnected", Message: "client disconnected", HTTPStatus: 400}
	ErrWebrpcStreamLost         = WebRPCError{Code: -9, Name: "WebrpcStreamLost", Message: "stream lost", HTTPStatus: 400}
	ErrWebrpcStreamFinished     = WebRPCError{Code: -10, Name: "WebrpcStreamFinished", Message: "stream finished", HTTPStatus: 200}
)

Webrpc errors

View Source
var FeeTokenType_name = map[uint32]string{
	0: "unknown",
	1: "erc20Token",
	2: "erc1155Token",
}
View Source
var FeeTokenType_value = map[string]uint32{
	"unknown":      0,
	"erc20Token":   1,
	"erc1155Token": 2,
}
View Source
var WebRPCServices = map[string][]string{}

Functions

func EncodeDelayedABI

func EncodeDelayedABI(data *delayedEncodeType) (string, error)

func IntentDataTypeToName

func IntentDataTypeToName[T any](t *T) string

func IntentResponseTypeToCode added in v0.29.4

func IntentResponseTypeToCode[T any](t *T) string

func IsValidSessionSignature

func IsValidSessionSignature(sessionId string, signature string, intent *Intent) error

func IsValidSessionSignatureP256K1

func IsValidSessionSignatureP256K1(sessionId string, signature string, intent *Intent) error

IsValidSessionSignatureP256K1 checks if the signature is valid for the given secp256k1 session

func IsValidSessionSignatureP256R1

func IsValidSessionSignatureP256R1(sessionId string, signature string, intent *Intent) error

IsValidSessionSignatureP256R1 checks if the signature is valid for the given secp256r1 session

func MethodNameFromContext

func MethodNameFromContext(ctx context.Context) string

func RequestFromContext

func RequestFromContext(ctx context.Context) *http.Request

func ServiceNameFromContext

func ServiceNameFromContext(ctx context.Context) string

func SessionAuthProofMessage added in v0.29.4

func SessionAuthProofMessage(sessionId string, wallet string, nonce *string) string

func SignIntentP256K1

func SignIntentP256K1(wallet *ethwallet.Wallet, intent *Intent) error

func SignIntentP256R1

func SignIntentP256R1(privateKey *ecdsa.PrivateKey, intent *Intent) error

func SignIntentWithWalletLegacy

func SignIntentWithWalletLegacy(wallet *ethwallet.Wallet, intent *Intent) error

func WebRPCSchemaHash

func WebRPCSchemaHash() string

Schema hash generated from your RIDL schema

func WebRPCSchemaVersion

func WebRPCSchemaVersion() string

Schema version of your RIDL schema

func WebRPCVersion

func WebRPCVersion() string

WebRPC description and code-gen version

Types

type ExpectedValuesForTransaction

type ExpectedValuesForTransaction struct {
	To    *common.Address
	Value *big.Int
	Data  []byte
}

type FeeOption added in v0.29.1

type FeeOption struct {
	Token    *FeeToken `json:"token"`
	To       string    `json:"to"`
	Value    string    `json:"value"`
	GasLimit uint      `json:"gasLimit"`
}

type FeeToken added in v0.29.1

type FeeToken struct {
	ChainId         uint64       `json:"chainId"`
	Name            string       `json:"name"`
	Symbol          string       `json:"symbol"`
	Type            FeeTokenType `json:"type"`
	Decimals        *uint32      `json:"decimals"`
	LogoURL         string       `json:"logoURL"`
	ContractAddress *string      `json:"contractAddress"`
	TokenID         *string      `json:"tokenID"`
}

type FeeTokenType added in v0.29.1

type FeeTokenType uint32
const (
	FeeTokenType_unknown      FeeTokenType = 0
	FeeTokenType_erc20Token   FeeTokenType = 1
	FeeTokenType_erc1155Token FeeTokenType = 2
)

func (*FeeTokenType) Is added in v0.29.1

func (x *FeeTokenType) Is(values ...FeeTokenType) bool

func (FeeTokenType) MarshalText added in v0.29.1

func (x FeeTokenType) MarshalText() ([]byte, error)

func (FeeTokenType) String added in v0.29.1

func (x FeeTokenType) String() string

func (*FeeTokenType) UnmarshalText added in v0.29.1

func (x *FeeTokenType) UnmarshalText(b []byte) error

type Intent

type Intent struct {
	Version    string       `json:"version"`
	Name       string       `json:"name"`
	ExpiresAt  uint64       `json:"expiresAt"`
	IssuedAt   uint64       `json:"issuedAt"`
	Data       interface{}  `json:"data"`
	Signatures []*Signature `json:"signatures,omitempty"`
}

func (*Intent) Hash

func (intent *Intent) Hash() ([]byte, error)

func (*Intent) IsValid

func (intent *Intent) IsValid() error

func (*Intent) Signers

func (intent *Intent) Signers() []string

type IntentDataCloseSession

type IntentDataCloseSession struct {
	SessionID string `json:"sessionId"`
}

type IntentDataFeeOptions added in v0.29.1

type IntentDataFeeOptions struct {
	Network string `json:"network"`
	Wallet  string `json:"wallet"`
	// is used to generate nonce space
	Identifier   string            `json:"identifier"`
	Transactions []json.RawMessage `json:"transactions"`
}

type IntentDataFinishValidateSession

type IntentDataFinishValidateSession struct {
	SessionID string `json:"sessionId"`
	Wallet    string `json:"wallet"`
	Salt      string `json:"salt"`
	Challenge string `json:"challenge"`
}

type IntentDataGetSession

type IntentDataGetSession struct {
	SessionID string `json:"sessionId"`
	Wallet    string `json:"wallet"`
}

type IntentDataGetTransactionReceipt added in v0.29.2

type IntentDataGetTransactionReceipt struct {
	Network    string `json:"network"`
	Wallet     string `json:"wallet"`
	MetaTxHash string `json:"metaTxHash"`
}

type IntentDataListSessions

type IntentDataListSessions struct {
	Wallet string `json:"wallet"`
}

type IntentDataOpenSession

type IntentDataOpenSession struct {
	SessionID string  `json:"sessionId"`
	Email     *string `json:"email,omitempty"`
	IdToken   *string `json:"idToken,omitempty"`
}

no way to generate string enums enum IntentName : string - openSession - closeSession - validateSession - finishValidateSession - listSessions - getSession - sessionAuthProof - signMessage - sendTransaction - getTransactionReceipt

func (*IntentDataOpenSession) IsValid

func (id *IntentDataOpenSession) IsValid() error

type IntentDataSendTransaction

type IntentDataSendTransaction struct {
	Network string `json:"network"`
	Wallet  string `json:"wallet"`
	// is used to generate nonce space
	Identifier           string            `json:"identifier"`
	Transactions         []json.RawMessage `json:"transactions"`
	TransactionsFeeQuote *string           `json:"transactionsFeeQuote,omitempty"`
}

func (*IntentDataSendTransaction) ExpectedValuesFor

func (*IntentDataSendTransaction) IsValidInterpretation

func (p *IntentDataSendTransaction) IsValidInterpretation(subdigest common.Hash, txns sequence.Transactions, nonce *big.Int) bool

func (*IntentDataSendTransaction) Nonce

func (p *IntentDataSendTransaction) Nonce() (*big.Int, error)

type IntentDataSessionAuthProof added in v0.29.4

type IntentDataSessionAuthProof struct {
	Network string  `json:"network"`
	Wallet  string  `json:"wallet"`
	Nonce   *string `json:"nonce"`
}

func (*IntentDataSessionAuthProof) IsValidInterpretation added in v0.29.4

func (id *IntentDataSessionAuthProof) IsValidInterpretation(sessionID string, message string) error

type IntentDataSignMessage

type IntentDataSignMessage struct {
	Network string `json:"network"`
	Wallet  string `json:"wallet"`
	Message string `json:"message"`
}

func (*IntentDataSignMessage) IsValidInterpretation

func (p *IntentDataSignMessage) IsValidInterpretation(subdigest common.Hash) bool

A SignMessagePacket (intent) *MUST* be mapped to a regular "SignMessage" Sequence action, this means that it must adhere to the following rules: - the subdigest must match `SubDigest(chainID, Wallet, Digest(Message))`

type IntentDataValidateSession

type IntentDataValidateSession struct {
	SessionID      string `json:"sessionId"`
	Wallet         string `json:"wallet"`
	DeviceMetadata string `json:"deviceMetadata"`
}

type IntentDataValidator

type IntentDataValidator interface {
	IsValid() error
}

type IntentResponse

type IntentResponse struct {
	Code string      `json:"code"`
	Data interface{} `json:"data"`
}

type IntentResponseFeeOptions added in v0.29.1

type IntentResponseFeeOptions struct {
	FeeOptions []*FeeOption `json:"feeOptions"`
	FeeQuote   *string      `json:"feeQuote,omitempty"`
}

type IntentResponseGetSession

type IntentResponseGetSession struct {
	SessionID string `json:"sessionId"`
	Wallet    string `json:"wallet"`
	Validated bool   `json:"validated"`
}

type IntentResponseListSessions

type IntentResponseListSessions struct {
	Sessions []string `json:"sessions"`
}

type IntentResponseSessionAuthProof added in v0.29.4

type IntentResponseSessionAuthProof struct {
	SessionID string `json:"sessionId"`
	Network   string `json:"network"`
	Wallet    string `json:"wallet"`
	// The message contents : “ OpenedSession < sessionId > < wallet > < nonce ? > ” hex encoded
	Message   string `json:"message"`
	Signature string `json:"signature"`
}

type IntentResponseSessionClosed

type IntentResponseSessionClosed struct {
}

type IntentResponseSessionOpened

type IntentResponseSessionOpened struct {
	SessionID string `json:"sessionId"`
	Wallet    string `json:"wallet"`
}

no way to generate string enums enum IntentResponseCode : string - sessionOpened - validationRequired - validationStarted - validationFinished - sessionAuthProof - signedMessage - transactionReceipt - transactionFailed - getSessionResponse

type IntentResponseSignedMessage

type IntentResponseSignedMessage struct {
	Signature string `json:"signature"`
	Message   string `json:"message"`
}

type IntentResponseTransactionFailed

type IntentResponseTransactionFailed struct {
	Error       string      `json:"error"`
	Request     interface{} `json:"request"`
	Simulations interface{} `json:"simulations"`
}

type IntentResponseTransactionReceipt

type IntentResponseTransactionReceipt struct {
	Request       interface{} `json:"request"`
	TxHash        string      `json:"txHash"`
	MetaTxHash    string      `json:"metaTxHash"`
	Receipt       interface{} `json:"receipt"`
	NativeReceipt interface{} `json:"nativeReceipt"`
	Simulations   interface{} `json:"simulations"`
}

type IntentResponseTyped added in v0.29.4

type IntentResponseTyped[T any] struct {
	IntentResponse
	Data T `json:"data"`
}

func NewIntentResponseTyped added in v0.29.4

func NewIntentResponseTyped[T any](data T) *IntentResponseTyped[T]

func NewIntentResponseTypedFromIntentResponse added in v0.29.4

func NewIntentResponseTypedFromIntentResponse[T any](res *IntentResponse) (*IntentResponseTyped[T], error)

type IntentResponseValidateSession

type IntentResponseValidateSession struct {
}

type IntentResponseValidationFinished

type IntentResponseValidationFinished struct {
	IsValid bool `json:"isValid"`
}

type IntentResponseValidationRequired

type IntentResponseValidationRequired struct {
	SessionID string `json:"sessionId"`
}

type IntentResponseValidationStarted

type IntentResponseValidationStarted struct {
	Salt string `json:"salt"`
}

type IntentTyped

type IntentTyped[T any] struct {
	Intent
	Data T `json:"data"`
}

func NewIntentTyped

func NewIntentTyped[T any](data T) *IntentTyped[T]

func NewIntentTypedFromIntent

func NewIntentTypedFromIntent[T any](intent *Intent) (*IntentTyped[T], error)

func (*IntentTyped[T]) IsValid

func (i *IntentTyped[T]) IsValid() error

func (*IntentTyped[T]) ToIntent

func (i *IntentTyped[T]) ToIntent() *Intent

type KeyType

type KeyType int
const (
	KeyTypeSECP256K1 KeyType = iota
	KeyTypeSECP256R1
	KeyTypeUnknown
)

func KeyTypeFromSessionId

func KeyTypeFromSessionId(sessionId string) KeyType

type SendTransactionFailed

type SendTransactionFailed struct {
	Code string `json:"code"`
	Data struct {
		Request     *IntentDataSendTransaction `json:"request"`
		Simulations []*proto.SimulateResult    `json:"simulations"`
	}
}

type SendTransactionResponse

type SendTransactionResponse struct {
	Code string `json:"code"`
	Data struct {
		Request       *IntentDataSendTransaction `json:"request"`
		TxHash        string                     `json:"txHash"`
		Receipt       *proto.MetaTxnReceipt      `json:"receipt"`
		NativeReceipt *types.Receipt             `json:"nativeReceipt"`
		Simulations   []*proto.SimulateResult    `json:"simulations"`
	}
}

type Session

type Session interface {
	SessionID() string
	Sign(intent *Intent) error
}

func NewSessionP256K1

func NewSessionP256K1(wallet *ethwallet.Wallet) Session

func NewSessionP256R1

func NewSessionP256R1(privateKey *ecdsa.PrivateKey) Session

type Signature

type Signature struct {
	SessionID string `json:"sessionId"`
	Signature string `json:"signature"`
}

type TransactionDelayedEncode

type TransactionDelayedEncode struct {
	Type  string          `json:"type"`
	To    string          `json:"to"`
	Value string          `json:"value"`
	Data  json.RawMessage `json:"data"`
}

type TransactionERC1155

type TransactionERC1155 struct {
	Type         string                     `json:"type"`
	TokenAddress string                     `json:"tokenAddress"`
	To           string                     `json:"to"`
	Vals         []*TransactionERC1155Value `json:"vals"`
	Data         *string                    `json:"data"`
}

type TransactionERC1155Value

type TransactionERC1155Value struct {
	ID     string `json:"id"`
	Amount string `json:"amount"`
}

type TransactionERC20

type TransactionERC20 struct {
	Type         string `json:"type"`
	TokenAddress string `json:"tokenAddress"`
	To           string `json:"to"`
	Value        string `json:"value"`
}

no way to generate string enums enum TransactionType : string - transaction - erc20send - erc721send - erc1155send - delayedEncode

type TransactionERC721

type TransactionERC721 struct {
	Type         string  `json:"type"`
	TokenAddress string  `json:"tokenAddress"`
	To           string  `json:"to"`
	Id           string  `json:"id"`
	Safe         *bool   `json:"safe"`
	Data         *string `json:"data"`
}

type TransactionRaw

type TransactionRaw struct {
	Type  string `json:"type"`
	To    string `json:"to"`
	Value string `json:"value"`
	Data  string `json:"data"`
}

type WebRPCError

type WebRPCError struct {
	Name       string `json:"error"`
	Code       int    `json:"code"`
	Message    string `json:"msg"`
	Cause      string `json:"cause,omitempty"`
	HTTPStatus int    `json:"status"`
	// contains filtered or unexported fields
}

func ErrorWithCause deprecated

func ErrorWithCause(rpcErr WebRPCError, cause error) WebRPCError

Deprecated: Use .WithCause() method on WebRPCError.

func (WebRPCError) Error

func (e WebRPCError) Error() string

func (WebRPCError) Is

func (e WebRPCError) Is(target error) bool

func (WebRPCError) Unwrap

func (e WebRPCError) Unwrap() error

func (WebRPCError) WithCause

func (e WebRPCError) WithCause(cause error) WebRPCError

Jump to

Keyboard shortcuts

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