mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-03 01:41:44 +00:00
feature/1110 abstract connected wallet operations (#1166)
- **refactor: refactor DID module types and move to controller package** - **refactor: move controller creation and resolution logic to keeper** - **refactor: update imports to reflect controller package move** - **refactor: update protobuf definitions for DID module** - **docs: update proto README to reflect changes** - **refactor: move hway to gateway, update node modules, and refactor pkl generation** - **build: update pkl-gen task to use new pkl file paths** - **refactor: refactor DWN WASM build and deployment process** - **refactor: refactor DID controller implementation to use account-based storage** - **refactor: move DID controller interface to base file and update implementation** - **chore: migrate to google protobuf** - **feat: Add v0.52.0 Interfaces for Acc Abstraction** - **refactor: replace public_key with public_key_hex in Assertion message** - **refactor: remove unused PubKey, JSONWebKey, and RawKey message types and related code**
This commit is contained in:
@@ -0,0 +1 @@
|
||||
# Core
|
||||
@@ -0,0 +1,30 @@
|
||||
package appmodule
|
||||
|
||||
import (
|
||||
"cosmossdk.io/core/event"
|
||||
"cosmossdk.io/core/gas"
|
||||
"cosmossdk.io/core/header"
|
||||
"cosmossdk.io/core/store"
|
||||
|
||||
"github.com/onsonr/sonr/pkg/core/branch"
|
||||
"github.com/onsonr/sonr/pkg/core/log"
|
||||
"github.com/onsonr/sonr/pkg/core/router"
|
||||
"github.com/onsonr/sonr/pkg/core/transaction"
|
||||
)
|
||||
|
||||
// Environment is used to get all services to their respective module.
|
||||
// Contract: All fields of environment are always populated by runtime.
|
||||
type Environment struct {
|
||||
Logger log.Logger
|
||||
|
||||
BranchService branch.Service
|
||||
EventService event.Service
|
||||
GasService gas.Service
|
||||
HeaderService header.Service
|
||||
QueryRouterService router.Service
|
||||
MsgRouterService router.Service
|
||||
TransactionService transaction.Service
|
||||
|
||||
KVStoreService store.KVStoreService
|
||||
MemStoreService store.MemoryStoreService
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Package branch contains the core branch service interface.
|
||||
package branch
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
)
|
||||
|
||||
// ErrGasLimitExceeded is returned when the gas limit is exceeded in a
|
||||
// Service.ExecuteWithGasLimit call.
|
||||
var ErrGasLimitExceeded = errors.New("branch: gas limit exceeded")
|
||||
|
||||
// Service is the branch service interface. It can be used to execute
|
||||
// code paths in an isolated execution context that can be reverted.
|
||||
// A revert typically means a rollback on events and state changes.
|
||||
type Service interface {
|
||||
// Execute executes the given function in an isolated context. If the
|
||||
// `f` function returns an error, the execution is considered failed,
|
||||
// and every change made affecting the execution context is rolled back.
|
||||
// If the function returns nil, the execution is considered successful, and
|
||||
// committed.
|
||||
// The context.Context passed to the `f` function is a child of the context
|
||||
// passed to the Execute function, and is what should be used with other
|
||||
// core services in order to ensure the execution remains isolated.
|
||||
Execute(ctx context.Context, f func(ctx context.Context) error) error
|
||||
// ExecuteWithGasLimit executes the given function `f` in an isolated context,
|
||||
// with the provided gas limit, this is advanced usage and is used to disallow
|
||||
// an execution path to consume an indefinite amount of gas.
|
||||
// If the execution fails or succeeds the gas limit is still applied to the
|
||||
// parent context, the function returns a gasUsed value which is the amount
|
||||
// of gas used by the execution path. If the execution path exceeds the gas
|
||||
// ErrGasLimitExceeded is returned.
|
||||
ExecuteWithGasLimit(ctx context.Context, gasLimit uint64, f func(ctx context.Context) error) (gasUsed uint64, err error)
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package log
|
||||
|
||||
const ModuleKey = "module"
|
||||
|
||||
// Logger defines basic logger functionality that all previous versions of the Logger interface should
|
||||
// support. Library users should prefer to use this interface when possible, then type case to Logger
|
||||
// to see if WithContext is supported.
|
||||
type Logger interface {
|
||||
// Info takes a message and a set of key/value pairs and logs with level INFO.
|
||||
// The key of the tuple must be a string.
|
||||
Info(msg string, keyVals ...any)
|
||||
|
||||
// Warn takes a message and a set of key/value pairs and logs with level WARN.
|
||||
// The key of the tuple must be a string.
|
||||
Warn(msg string, keyVals ...any)
|
||||
|
||||
// Error takes a message and a set of key/value pairs and logs with level ERR.
|
||||
// The key of the tuple must be a string.
|
||||
Error(msg string, keyVals ...any)
|
||||
|
||||
// Debug takes a message and a set of key/value pairs and logs with level DEBUG.
|
||||
// The key of the tuple must be a string.
|
||||
Debug(msg string, keyVals ...any)
|
||||
|
||||
// Impl returns the underlying logger implementation.
|
||||
// It is used to access the full functionalities of the underlying logger.
|
||||
// Advanced users can type cast the returned value to the actual logger.
|
||||
Impl() any
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/onsonr/sonr/pkg/core/transaction"
|
||||
)
|
||||
|
||||
// Service is the interface that wraps the basic methods for a router.
|
||||
// A router can be a query router or a message router.
|
||||
type Service interface {
|
||||
// CanInvoke returns an error if the given request cannot be invoked.
|
||||
CanInvoke(ctx context.Context, typeURL string) error
|
||||
// Invoke execute a message or query. The response should be type casted by the caller to the expected response.
|
||||
Invoke(ctx context.Context, req transaction.Msg) (res transaction.Msg, err error)
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package transaction
|
||||
|
||||
import "context"
|
||||
|
||||
// ExecMode defines the execution mode
|
||||
type ExecMode uint8
|
||||
|
||||
// All possible execution modes.
|
||||
// For backwards compatibility and easier casting, the exec mode values must be the same as in cosmos/cosmos-sdk/types package.
|
||||
const (
|
||||
ExecModeCheck ExecMode = iota
|
||||
ExecModeReCheck
|
||||
ExecModeSimulate
|
||||
_
|
||||
_
|
||||
_
|
||||
_
|
||||
ExecModeFinalize
|
||||
)
|
||||
|
||||
// Service creates a transaction service.
|
||||
type Service interface {
|
||||
// ExecMode returns the current execution mode.
|
||||
ExecMode(ctx context.Context) ExecMode
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package transaction
|
||||
|
||||
type (
|
||||
// Msg uses structural types to define the interface for a message.
|
||||
Msg = interface {
|
||||
Reset()
|
||||
String() string
|
||||
ProtoMessage()
|
||||
}
|
||||
Identity = []byte
|
||||
)
|
||||
|
||||
// GenericMsg defines a generic version of a Msg.
|
||||
// The GenericMsg refers to the non pointer version of Msg,
|
||||
// and is required to allow its instantiations in generic contexts.
|
||||
type GenericMsg[T any] interface {
|
||||
*T
|
||||
Msg
|
||||
}
|
||||
|
||||
// Codec defines the TX codec, which converts a TX from bytes to its concrete representation.
|
||||
type Codec[T Tx] interface {
|
||||
// Decode decodes the tx bytes into a DecodedTx, containing
|
||||
// both concrete and bytes representation of the tx.
|
||||
Decode([]byte) (T, error)
|
||||
// DecodeJSON decodes the tx JSON bytes into a DecodedTx
|
||||
DecodeJSON([]byte) (T, error)
|
||||
}
|
||||
|
||||
// Tx defines the interface for a transaction.
|
||||
// All custom transactions must implement this interface.
|
||||
type Tx interface {
|
||||
// Hash returns the unique identifier for the Tx.
|
||||
Hash() [32]byte
|
||||
// GetMessages returns the list of state transitions of the Tx.
|
||||
GetMessages() ([]Msg, error)
|
||||
// GetSenders returns the tx state transition sender.
|
||||
GetSenders() ([]Identity, error) // TODO reduce this to a single identity if accepted
|
||||
// GetGasLimit returns the gas limit of the tx. Must return math.MaxUint64 for infinite gas
|
||||
// txs.
|
||||
GetGasLimit() (uint64, error)
|
||||
// Bytes returns the encoded version of this tx. Note: this is ideally cached
|
||||
// from the first instance of the decoding of the tx.
|
||||
Bytes() []byte
|
||||
}
|
||||
Reference in New Issue
Block a user