mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-02 17:31:39 +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:
@@ -1,20 +1,20 @@
|
||||
package types
|
||||
package controller
|
||||
|
||||
import (
|
||||
"github.com/onsonr/crypto/mpc"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
didv1 "github.com/onsonr/sonr/api/did/v1"
|
||||
commonv1 "github.com/onsonr/sonr/pkg/common/types"
|
||||
"github.com/onsonr/sonr/x/did/types"
|
||||
)
|
||||
|
||||
type ControllerI interface {
|
||||
ChainID() string
|
||||
GetPubKey() *didv1.PubKey
|
||||
GetPubKey() *commonv1.PubKey
|
||||
SonrAddress() string
|
||||
RawPublicKey() []byte
|
||||
}
|
||||
|
||||
func NewController(shares []mpc.Share) (ControllerI, error) {
|
||||
func New(shares []mpc.Share) (ControllerI, error) {
|
||||
var (
|
||||
valKs = shares[0]
|
||||
userKs = shares[1]
|
||||
@@ -23,7 +23,7 @@ func NewController(shares []mpc.Share) (ControllerI, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
sonrAddr, err := ComputeSonrAddress(pb)
|
||||
sonrAddr, err := types.ComputeSonrAddr(pb)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -36,14 +36,6 @@ func NewController(shares []mpc.Share) (ControllerI, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func LoadControllerFromTableEntry(ctx sdk.Context, entry *didv1.Controller) (ControllerI, error) {
|
||||
return &controller{
|
||||
address: entry.Did,
|
||||
chainID: ctx.ChainID(),
|
||||
publicKey: entry.PublicKey.RawKey.Key,
|
||||
}, nil
|
||||
}
|
||||
|
||||
type controller struct {
|
||||
userKs mpc.Share
|
||||
valKs mpc.Share
|
||||
@@ -57,10 +49,10 @@ func (c *controller) ChainID() string {
|
||||
return c.chainID
|
||||
}
|
||||
|
||||
func (c *controller) GetPubKey() *didv1.PubKey {
|
||||
return &didv1.PubKey{
|
||||
func (c *controller) GetPubKey() *commonv1.PubKey {
|
||||
return &commonv1.PubKey{
|
||||
KeyType: "ecdsa",
|
||||
RawKey: &didv1.RawKey{
|
||||
RawKey: &commonv1.RawKey{
|
||||
Algorithm: "secp256k1",
|
||||
Key: c.publicKey,
|
||||
},
|
||||
@@ -0,0 +1 @@
|
||||
package signer
|
||||
@@ -0,0 +1 @@
|
||||
package signer
|
||||
@@ -1,4 +1,4 @@
|
||||
package mpc
|
||||
package signer
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -0,0 +1,20 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
|
||||
didv1 "github.com/onsonr/sonr/api/did/v1"
|
||||
)
|
||||
|
||||
func LoadFromTableEntry(ctx sdk.Context, entry *didv1.Controller) (ControllerI, error) {
|
||||
k, err := hexutil.Decode(entry.PublicKeyHex)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &controller{
|
||||
address: entry.Did,
|
||||
chainID: ctx.ChainID(),
|
||||
publicKey: k,
|
||||
}, nil
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package wallet
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
commonv1 "github.com/onsonr/sonr/pkg/common/types"
|
||||
)
|
||||
|
||||
type PubKeyI interface {
|
||||
GetRole() string
|
||||
GetKeyType() string
|
||||
GetRawKey() *commonv1.RawKey
|
||||
GetJwk() *commonv1.JSONWebKey
|
||||
}
|
||||
|
||||
// PubKey defines a generic pubkey.
|
||||
type PublicKey interface {
|
||||
VerifySignature(msg, sig []byte) bool
|
||||
}
|
||||
|
||||
type PubKeyG[T any] interface {
|
||||
*T
|
||||
PublicKey
|
||||
}
|
||||
|
||||
type pubKeyImpl struct {
|
||||
decode func(b []byte) (PublicKey, error)
|
||||
validate func(key PublicKey) error
|
||||
}
|
||||
|
||||
// func WithSecp256K1PubKey() Option {
|
||||
// return WithPubKeyWithValidationFunc(func(pt *secp256k1.PubKey) error {
|
||||
// _, err := dcrd_secp256k1.ParsePubKey(pt.Key)
|
||||
// return err
|
||||
// })
|
||||
// }
|
||||
//
|
||||
// func WithPubKey[T any, PT PubKeyG[T]]() Option {
|
||||
// return WithPubKeyWithValidationFunc[T, PT](func(_ PT) error {
|
||||
// return nil
|
||||
// })
|
||||
// }
|
||||
//
|
||||
// func WithPubKeyWithValidationFunc[T any, PT PubKeyG[T]](validateFn func(PT) error) Option {
|
||||
// pkImpl := pubKeyImpl{
|
||||
// decode: func(b []byte) (PublicKey, error) {
|
||||
// key := PT(new(T))
|
||||
// err := gogoproto.Unmarshal(b, key)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
// return key, nil
|
||||
// },
|
||||
// validate: func(k PublicKey) error {
|
||||
// concrete, ok := k.(PT)
|
||||
// if !ok {
|
||||
// return fmt.Errorf(
|
||||
// "invalid pubkey type passed for validation, wanted: %T, got: %T",
|
||||
// concrete,
|
||||
// k,
|
||||
// )
|
||||
// }
|
||||
// return validateFn(concrete)
|
||||
// },
|
||||
// }
|
||||
// return func(a *Account) {
|
||||
// a.supportedPubKeys[gogoproto.MessageName(PT(new(T)))] = pkImpl
|
||||
// }
|
||||
// }
|
||||
func nameFromTypeURL(url string) string {
|
||||
name := url
|
||||
if i := strings.LastIndexByte(url, '/'); i >= 0 {
|
||||
name = name[i+len("/"):]
|
||||
}
|
||||
return name
|
||||
}
|
||||
|
||||
// CustomPubKey represents a custom secp256k1 public key.
|
||||
type CustomPubKey struct {
|
||||
proto.Message
|
||||
|
||||
Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
|
||||
}
|
||||
|
||||
// NewCustomPubKeyFromRawBytes creates a new CustomPubKey from raw bytes.
|
||||
func NewCustomPubKeyFromRawBytes(key []byte) (*CustomPubKey, error) {
|
||||
// Validate the key length and format
|
||||
if len(key) != 33 {
|
||||
return nil, fmt.Errorf("invalid key length; expected 33 bytes, got %d", len(key))
|
||||
}
|
||||
if key[0] != 0x02 && key[0] != 0x03 {
|
||||
return nil, fmt.Errorf("invalid key format; expected 0x02 or 0x03 as the first byte, got 0x%02x", key[0])
|
||||
}
|
||||
|
||||
return &CustomPubKey{Key: key}, nil
|
||||
}
|
||||
|
||||
// Bytes returns the byte representation of the public key.
|
||||
func (pk *CustomPubKey) Bytes() []byte {
|
||||
return pk.Key
|
||||
}
|
||||
|
||||
// Equals checks if two public keys are equal.
|
||||
func (pk *CustomPubKey) Equals(other sdk.PubKey) bool {
|
||||
return bytes.EqualFold(pk.Bytes(), other.Bytes())
|
||||
}
|
||||
|
||||
// Type returns the type of the public key.
|
||||
func (pk *CustomPubKey) Type() string {
|
||||
return "custom-secp256k1"
|
||||
}
|
||||
|
||||
// Marshal implements the proto.Message interface.
|
||||
func (pk *CustomPubKey) Marshal() ([]byte, error) {
|
||||
return proto.Marshal(pk)
|
||||
}
|
||||
|
||||
// Unmarshal implements the proto.Message interface.
|
||||
func (pk *CustomPubKey) Unmarshal(data []byte) error {
|
||||
return proto.Unmarshal(data, pk)
|
||||
}
|
||||
|
||||
// Address returns the address derived from the public key.
|
||||
func (pk *CustomPubKey) Address() []byte {
|
||||
// Implement address derivation logic here
|
||||
// For simplicity, this example uses a placeholder
|
||||
return []byte("derived-address")
|
||||
}
|
||||
|
||||
// VerifySignature verifies a signature using the public key.
|
||||
func (pk *CustomPubKey) VerifySignature(msg []byte, sig []byte) bool {
|
||||
// Implement signature verification logic here
|
||||
// For simplicity, this example uses a placeholder
|
||||
return true
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
package wallet
|
||||
@@ -0,0 +1 @@
|
||||
package wallet
|
||||
@@ -1,31 +0,0 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/onsonr/crypto/mpc"
|
||||
"github.com/onsonr/sonr/x/did/types"
|
||||
)
|
||||
|
||||
func (k Keeper) NewController(ctx sdk.Context) (types.ControllerI, error) {
|
||||
shares, err := mpc.GenerateKeyshares()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
controller, err := types.NewController(shares)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return controller, nil
|
||||
}
|
||||
|
||||
func (k Keeper) ResolveController(ctx sdk.Context, did string) (types.ControllerI, error) {
|
||||
ct, err := k.OrmDB.ControllerTable().GetByDid(ctx, did)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
c, err := types.LoadControllerFromTableEntry(ctx, ct)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return c, nil
|
||||
}
|
||||
+27
-1
@@ -4,11 +4,37 @@ import (
|
||||
"context"
|
||||
|
||||
"cosmossdk.io/log"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/onsonr/crypto/mpc"
|
||||
|
||||
"github.com/onsonr/sonr/x/did/controller"
|
||||
"github.com/onsonr/sonr/x/did/types"
|
||||
)
|
||||
|
||||
func (k Keeper) NewController(ctx sdk.Context) (controller.ControllerI, error) {
|
||||
shares, err := mpc.GenerateKeyshares()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
controller, err := controller.New(shares)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return controller, nil
|
||||
}
|
||||
|
||||
func (k Keeper) ResolveController(ctx sdk.Context, did string) (controller.ControllerI, error) {
|
||||
ct, err := k.OrmDB.ControllerTable().GetByDid(ctx, did)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
c, err := controller.LoadFromTableEntry(ctx, ct)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return c, nil
|
||||
}
|
||||
|
||||
// Logger returns the logger
|
||||
func (k Keeper) Logger() log.Logger {
|
||||
return k.logger
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
didtypes "github.com/onsonr/sonr/x/did/types"
|
||||
"gopkg.in/macaroon.v2"
|
||||
)
|
||||
|
||||
var fourYears = time.Hour * 24 * 365 * 4
|
||||
|
||||
// IssueAdminMacaroon creates a macaroon with the specified parameters.
|
||||
func (k Keeper) IssueAdminMacaroon(sdkctx sdk.Context, controller didtypes.ControllerI) (*macaroon.Macaroon, error) {
|
||||
// Derive the root key by hashing the shared MPC public key
|
||||
rootKey := sha256.Sum256([]byte(controller.RawPublicKey()))
|
||||
// Create the macaroon
|
||||
m, err := macaroon.New(rootKey[:], []byte(controller.SonrAddress()), controller.ChainID(), macaroon.LatestVersion)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Add the block expiry caveat
|
||||
caveat := fmt.Sprintf("block-expiry=%d", calculateBlockExpiry(sdkctx, fourYears))
|
||||
err = m.AddFirstPartyCaveat([]byte(caveat))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// IssueServiceMacaroon creates a macaroon with the specified parameters.
|
||||
func (k Keeper) IssueServiceMacaroon(sdkctx sdk.Context, sharedMPCPubKey, location, id string, blockExpiry uint64) (*macaroon.Macaroon, error) {
|
||||
// Derive the root key by hashing the shared MPC public key
|
||||
rootKey := sha256.Sum256([]byte(sharedMPCPubKey))
|
||||
// Create the macaroon
|
||||
m, err := macaroon.New(rootKey[:], []byte(id), location, macaroon.LatestVersion)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Add the block expiry caveat
|
||||
caveat := fmt.Sprintf("block-expiry=%d", blockExpiry)
|
||||
err = m.AddFirstPartyCaveat([]byte(caveat))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func calculateBlockExpiry(sdkctx sdk.Context, duration time.Duration) uint64 {
|
||||
blockTime := sdkctx.BlockTime()
|
||||
avgBlockTime := float64(blockTime.Sub(blockTime).Seconds())
|
||||
return uint64(duration.Seconds() / avgBlockTime)
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package types
|
||||
|
||||
type SonrAccount struct {
|
||||
ID string
|
||||
Name string
|
||||
Address string
|
||||
PublicKey string
|
||||
ChainCode string
|
||||
Index string
|
||||
Controller string
|
||||
CreatedAt string
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
// Package accountstd exports the types and functions that are used by developers to implement smart accounts.
|
||||
package accstd
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/address"
|
||||
|
||||
"github.com/onsonr/sonr/pkg/core/transaction"
|
||||
"github.com/onsonr/sonr/x/did/types/accstd/internal/accounts"
|
||||
)
|
||||
|
||||
var (
|
||||
accountsModuleAddress = address.Module("accounts")
|
||||
ErrInvalidType = errors.New("invalid type")
|
||||
)
|
||||
|
||||
// Interface is the exported interface of an Account.
|
||||
type Interface = accounts.Account
|
||||
|
||||
// ExecuteBuilder is the exported type of ExecuteBuilder.
|
||||
type ExecuteBuilder = accounts.ExecuteBuilder
|
||||
|
||||
// QueryBuilder is the exported type of QueryBuilder.
|
||||
type QueryBuilder = accounts.QueryBuilder
|
||||
|
||||
// InitBuilder is the exported type of InitBuilder.
|
||||
type InitBuilder = accounts.InitBuilder
|
||||
|
||||
// AccountCreatorFunc is the exported type of AccountCreatorFunc.
|
||||
type AccountCreatorFunc = accounts.AccountCreatorFunc
|
||||
|
||||
func DIAccount[A Interface](name string, constructor func(deps Dependencies) (A, error)) DepinjectAccount {
|
||||
return DepinjectAccount{MakeAccount: AddAccount(name, constructor)}
|
||||
}
|
||||
|
||||
type DepinjectAccount struct {
|
||||
MakeAccount AccountCreatorFunc
|
||||
}
|
||||
|
||||
func (DepinjectAccount) IsManyPerContainerType() {}
|
||||
|
||||
// Dependencies is the exported type of Dependencies.
|
||||
type Dependencies = accounts.Dependencies
|
||||
|
||||
func RegisterExecuteHandler[
|
||||
Req any, ProtoReq accounts.ProtoMsgG[Req], Resp any, ProtoResp accounts.ProtoMsgG[Resp],
|
||||
](router *ExecuteBuilder, handler func(ctx context.Context, req ProtoReq) (ProtoResp, error),
|
||||
) {
|
||||
accounts.RegisterExecuteHandler(router, handler)
|
||||
}
|
||||
|
||||
// RegisterQueryHandler registers a query handler for a smart account that uses protobuf.
|
||||
func RegisterQueryHandler[
|
||||
Req any, ProtoReq accounts.ProtoMsgG[Req], Resp any, ProtoResp accounts.ProtoMsgG[Resp],
|
||||
](router *QueryBuilder, handler func(ctx context.Context, req ProtoReq) (ProtoResp, error),
|
||||
) {
|
||||
accounts.RegisterQueryHandler(router, handler)
|
||||
}
|
||||
|
||||
// RegisterInitHandler registers an initialisation handler for a smart account that uses protobuf.
|
||||
func RegisterInitHandler[
|
||||
Req any, ProtoReq accounts.ProtoMsgG[Req], Resp any, ProtoResp accounts.ProtoMsgG[Resp],
|
||||
](router *InitBuilder, handler func(ctx context.Context, req ProtoReq) (ProtoResp, error),
|
||||
) {
|
||||
accounts.RegisterInitHandler(router, handler)
|
||||
}
|
||||
|
||||
// AddAccount is a helper function to add a smart account to the list of smart accounts.
|
||||
func AddAccount[A Interface](name string, constructor func(deps Dependencies) (A, error)) AccountCreatorFunc {
|
||||
return func(deps accounts.Dependencies) (string, accounts.Account, error) {
|
||||
acc, err := constructor(deps)
|
||||
return name, acc, err
|
||||
}
|
||||
}
|
||||
|
||||
// Whoami returns the address of the account being invoked.
|
||||
func Whoami(ctx context.Context) []byte {
|
||||
return accounts.Whoami(ctx)
|
||||
}
|
||||
|
||||
// Sender returns the sender of the execution request.
|
||||
func Sender(ctx context.Context) []byte {
|
||||
return accounts.Sender(ctx)
|
||||
}
|
||||
|
||||
// HasSender checks if the execution context was sent from the provided sender
|
||||
func HasSender(ctx context.Context, wantSender []byte) bool {
|
||||
return bytes.Equal(Sender(ctx), wantSender)
|
||||
}
|
||||
|
||||
// SenderIsSelf checks if the sender of the request is the account itself.
|
||||
func SenderIsSelf(ctx context.Context) bool { return HasSender(ctx, Whoami(ctx)) }
|
||||
|
||||
// SenderIsAccountsModule returns true if the sender of the execution request is the accounts module.
|
||||
func SenderIsAccountsModule(ctx context.Context) bool {
|
||||
return bytes.Equal(Sender(ctx), accountsModuleAddress)
|
||||
}
|
||||
|
||||
// Funds returns if any funds were sent during the execute or init request. In queries this
|
||||
// returns nil.
|
||||
func Funds(ctx context.Context) sdk.Coins { return accounts.Funds(ctx) }
|
||||
|
||||
func ExecModule[MsgResp, Msg transaction.Msg](ctx context.Context, msg Msg) (resp MsgResp, err error) {
|
||||
untyped, err := accounts.ExecModule(ctx, msg)
|
||||
if err != nil {
|
||||
return resp, err
|
||||
}
|
||||
return assertOrErr[MsgResp](untyped)
|
||||
}
|
||||
|
||||
// QueryModule can be used by an account to execute a module query.
|
||||
func QueryModule[Resp, Req transaction.Msg](ctx context.Context, req Req) (resp Resp, err error) {
|
||||
untyped, err := accounts.QueryModule(ctx, req)
|
||||
if err != nil {
|
||||
return resp, err
|
||||
}
|
||||
return assertOrErr[Resp](untyped)
|
||||
}
|
||||
|
||||
// UnpackAny unpacks a protobuf Any message generically.
|
||||
func UnpackAny[Msg any, ProtoMsg accounts.ProtoMsgG[Msg]](any *accounts.Any) (*Msg, error) {
|
||||
return accounts.UnpackAny[Msg, ProtoMsg](any)
|
||||
}
|
||||
|
||||
// PackAny packs a protobuf Any message generically.
|
||||
func PackAny(msg transaction.Msg) (*accounts.Any, error) {
|
||||
return accounts.PackAny(msg)
|
||||
}
|
||||
|
||||
// ExecModuleAnys can be used to execute a list of messages towards a module
|
||||
// when those messages are packed in Any messages. The function returns a list
|
||||
// of responses packed in Any messages.
|
||||
func ExecModuleAnys(ctx context.Context, msgs []*accounts.Any) ([]*accounts.Any, error) {
|
||||
responses := make([]*accounts.Any, len(msgs))
|
||||
for i, msg := range msgs {
|
||||
concreteMessage, err := accounts.UnpackAnyRaw(msg)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error unpacking message %d: %w", i, err)
|
||||
}
|
||||
resp, err := accounts.ExecModule(ctx, concreteMessage)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error executing message %d: %w", i, err)
|
||||
}
|
||||
// pack again
|
||||
respAnyPB, err := accounts.PackAny(resp)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error packing response %d: %w", i, err)
|
||||
}
|
||||
responses[i] = respAnyPB
|
||||
}
|
||||
return responses, nil
|
||||
}
|
||||
|
||||
// asserts the given any to the provided generic, returns ErrInvalidType if it can't.
|
||||
func assertOrErr[T any](r any) (concrete T, err error) {
|
||||
concrete, ok := r.(T)
|
||||
if !ok {
|
||||
return concrete, ErrInvalidType
|
||||
}
|
||||
return concrete, nil
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package accounts
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/onsonr/sonr/pkg/core/transaction"
|
||||
)
|
||||
|
||||
var (
|
||||
errNoInitHandler = errors.New("no init handler")
|
||||
errNoExecuteHandler = errors.New("account does not accept messages")
|
||||
errInvalidMessage = errors.New("invalid message")
|
||||
)
|
||||
|
||||
// NewInitBuilder creates a new InitBuilder instance.
|
||||
func NewInitBuilder() *InitBuilder {
|
||||
return &InitBuilder{}
|
||||
}
|
||||
|
||||
// InitBuilder defines a smart account's initialisation handler builder.
|
||||
type InitBuilder struct {
|
||||
// handler is the handler function that will be called when the smart account is initialized.
|
||||
// Although the function here is defined to take an any, the smart account will work
|
||||
// with a typed version of it.
|
||||
handler func(ctx context.Context, initRequest transaction.Msg) (initResponse transaction.Msg, err error)
|
||||
|
||||
// schema is the schema of the message that will be passed to the handler function.
|
||||
schema HandlerSchema
|
||||
}
|
||||
|
||||
// makeHandler returns the handler function that will be called when the smart account is initialized.
|
||||
// It returns an error if no handler was registered.
|
||||
func (i *InitBuilder) makeHandler() (func(ctx context.Context, initRequest transaction.Msg) (initResponse transaction.Msg, err error), error) {
|
||||
if i.handler == nil {
|
||||
return nil, errNoInitHandler
|
||||
}
|
||||
return i.handler, nil
|
||||
}
|
||||
|
||||
// NewExecuteBuilder creates a new ExecuteBuilder instance.
|
||||
func NewExecuteBuilder() *ExecuteBuilder {
|
||||
return &ExecuteBuilder{
|
||||
handlers: make(map[string]func(ctx context.Context, executeRequest transaction.Msg) (executeResponse transaction.Msg, err error)),
|
||||
handlersSchema: make(map[string]HandlerSchema),
|
||||
}
|
||||
}
|
||||
|
||||
// ExecuteBuilder defines a smart account's execution router, it will be used to map an execution message
|
||||
// to a handler function for a specific account.
|
||||
type ExecuteBuilder struct {
|
||||
// handlers is a map of handler functions that will be called when the smart account is executed.
|
||||
handlers map[string]func(ctx context.Context, executeRequest transaction.Msg) (executeResponse transaction.Msg, err error)
|
||||
|
||||
// handlersSchema is a map of schemas for the messages that will be passed to the handler functions
|
||||
// and the messages that will be returned by the handler functions.
|
||||
handlersSchema map[string]HandlerSchema
|
||||
|
||||
// err is the error that occurred before building the handler function.
|
||||
err error
|
||||
}
|
||||
|
||||
func (r *ExecuteBuilder) makeHandler() (func(ctx context.Context, executeRequest transaction.Msg) (executeResponse transaction.Msg, err error), error) {
|
||||
// if no handler is registered it's fine, it means the account will not be accepting execution or query messages.
|
||||
if len(r.handlers) == 0 {
|
||||
return func(ctx context.Context, _ transaction.Msg) (_ transaction.Msg, err error) {
|
||||
return nil, errNoExecuteHandler
|
||||
}, nil
|
||||
}
|
||||
|
||||
if r.err != nil {
|
||||
return nil, r.err
|
||||
}
|
||||
|
||||
// build the real execution handler
|
||||
return func(ctx context.Context, executeRequest transaction.Msg) (executeResponse transaction.Msg, err error) {
|
||||
messageName := MessageName(executeRequest)
|
||||
handler, ok := r.handlers[messageName]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("%w: no handler for message %s", errInvalidMessage, messageName)
|
||||
}
|
||||
return handler(ctx, executeRequest)
|
||||
}, nil
|
||||
}
|
||||
|
||||
// NewQueryBuilder creates a new QueryBuilder instance.
|
||||
func NewQueryBuilder() *QueryBuilder {
|
||||
return &QueryBuilder{
|
||||
er: NewExecuteBuilder(),
|
||||
}
|
||||
}
|
||||
|
||||
// QueryBuilder defines a smart account's query router, it will be used to map a query message
|
||||
// to a handler function for a specific account.
|
||||
type QueryBuilder struct {
|
||||
// er is the ExecuteBuilder, since there's no difference between the execution and query handlers API.
|
||||
er *ExecuteBuilder
|
||||
}
|
||||
|
||||
func (r *QueryBuilder) makeHandler() (func(ctx context.Context, queryRequest transaction.Msg) (queryResponse transaction.Msg, err error), error) {
|
||||
return r.er.makeHandler()
|
||||
}
|
||||
|
||||
// IsRoutingError returns true if the error is a routing error,
|
||||
// which typically occurs when a message cannot be matched to a handler.
|
||||
func IsRoutingError(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
return errors.Is(err, errInvalidMessage)
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package accounts
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/binary"
|
||||
|
||||
"cosmossdk.io/collections"
|
||||
"cosmossdk.io/core/store"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
"github.com/onsonr/sonr/pkg/core/transaction"
|
||||
"github.com/onsonr/sonr/x/did/types/accstd/internal/prefixstore"
|
||||
)
|
||||
|
||||
var AccountStatePrefix = collections.NewPrefix(255)
|
||||
|
||||
type (
|
||||
ModuleExecFunc = func(ctx context.Context, sender []byte, msg transaction.Msg) (transaction.Msg, error)
|
||||
ModuleQueryFunc = func(ctx context.Context, queryReq transaction.Msg) (transaction.Msg, error)
|
||||
)
|
||||
|
||||
type contextKey struct{}
|
||||
|
||||
type contextValue struct {
|
||||
store store.KVStore // store is the prefixed store for the account.
|
||||
sender []byte // sender is the address of the entity invoking the account action.
|
||||
whoami []byte // whoami is the address of the account being invoked.
|
||||
funds sdk.Coins // funds reports the coins sent alongside the request.
|
||||
parentContext context.Context // parentContext that was used to build the account context.
|
||||
moduleExec ModuleExecFunc // moduleExec is a function that executes a module message, when the resp type is unknown.
|
||||
moduleQuery ModuleQueryFunc // moduleQuery is a function that queries a module.
|
||||
}
|
||||
|
||||
func addCtx(ctx context.Context, value contextValue) context.Context {
|
||||
return context.WithValue(ctx, contextKey{}, value)
|
||||
}
|
||||
|
||||
func getCtx(ctx context.Context) contextValue {
|
||||
return ctx.Value(contextKey{}).(contextValue)
|
||||
}
|
||||
|
||||
// MakeAccountContext creates a new account execution context given:
|
||||
// storeSvc: which fetches the x/accounts module store.
|
||||
// accountAddr: the address of the account being invoked, which is used to give the
|
||||
// account a prefixed storage.
|
||||
// sender: the address of entity invoking the account action.
|
||||
// moduleExec: a function that executes a module message.
|
||||
// moduleQuery: a function that queries a module.
|
||||
func MakeAccountContext(
|
||||
ctx context.Context,
|
||||
storeSvc store.KVStoreService,
|
||||
accNumber uint64,
|
||||
accountAddr []byte,
|
||||
sender []byte,
|
||||
funds sdk.Coins,
|
||||
moduleExec ModuleExecFunc,
|
||||
moduleQuery ModuleQueryFunc,
|
||||
) context.Context {
|
||||
return addCtx(ctx, contextValue{
|
||||
store: makeAccountStore(ctx, storeSvc, accNumber),
|
||||
sender: sender,
|
||||
whoami: accountAddr,
|
||||
funds: funds,
|
||||
parentContext: ctx,
|
||||
moduleExec: moduleExec,
|
||||
moduleQuery: moduleQuery,
|
||||
})
|
||||
}
|
||||
|
||||
func SetSender(ctx context.Context, sender []byte) context.Context {
|
||||
v := getCtx(ctx)
|
||||
v.sender = sender
|
||||
return addCtx(v.parentContext, v)
|
||||
}
|
||||
|
||||
// makeAccountStore creates the prefixed store for the account.
|
||||
// It uses the number of the account, this gives constant size
|
||||
// bytes prefixes for the account state.
|
||||
func makeAccountStore(ctx context.Context, storeSvc store.KVStoreService, accNum uint64) store.KVStore {
|
||||
prefix := make([]byte, 8)
|
||||
binary.BigEndian.PutUint64(prefix, accNum)
|
||||
return prefixstore.New(storeSvc.OpenKVStore(ctx), append(AccountStatePrefix, prefix...))
|
||||
}
|
||||
|
||||
// ExecModule can be used to execute a message towards a module, when the response type is unknown.
|
||||
func ExecModule(ctx context.Context, msg transaction.Msg) (transaction.Msg, error) {
|
||||
// get sender
|
||||
v := getCtx(ctx)
|
||||
|
||||
resp, err := v.moduleExec(v.parentContext, v.whoami, msg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// QueryModule can be used by an account to execute a module query.
|
||||
func QueryModule(ctx context.Context, req transaction.Msg) (transaction.Msg, error) {
|
||||
// we do not need to check the sender in a query because it is not a state transition.
|
||||
// we also unwrap the original context.
|
||||
v := getCtx(ctx)
|
||||
resp, err := v.moduleQuery(v.parentContext, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// openKVStore returns the prefixed store for the account given the context.
|
||||
func openKVStore(ctx context.Context) store.KVStore { return getCtx(ctx).store }
|
||||
|
||||
// Sender returns the address of the entity invoking the account action.
|
||||
func Sender(ctx context.Context) []byte {
|
||||
return getCtx(ctx).sender
|
||||
}
|
||||
|
||||
// Whoami returns the address of the account being invoked.
|
||||
func Whoami(ctx context.Context) []byte {
|
||||
return getCtx(ctx).whoami
|
||||
}
|
||||
|
||||
// Funds returns the funds associated with the execution context.
|
||||
func Funds(ctx context.Context) sdk.Coins { return getCtx(ctx).funds }
|
||||
@@ -0,0 +1,66 @@
|
||||
package accounts
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/gogoproto/proto"
|
||||
|
||||
"github.com/onsonr/sonr/pkg/core/transaction"
|
||||
)
|
||||
|
||||
// ProtoMsgG is a generic interface for protobuf messages.
|
||||
type ProtoMsgG[T any] interface {
|
||||
*T
|
||||
transaction.Msg
|
||||
}
|
||||
|
||||
type Any = codectypes.Any
|
||||
|
||||
func FindMessageByName(name string) (transaction.Msg, error) {
|
||||
typ := proto.MessageType(name)
|
||||
if typ == nil {
|
||||
return nil, fmt.Errorf("no message type found for %s", name)
|
||||
}
|
||||
return reflect.New(typ.Elem()).Interface().(transaction.Msg), nil
|
||||
}
|
||||
|
||||
func MessageName(msg transaction.Msg) string {
|
||||
return proto.MessageName(msg)
|
||||
}
|
||||
|
||||
// PackAny packs a proto message into an anypb.Any.
|
||||
func PackAny(msg transaction.Msg) (*Any, error) {
|
||||
return codectypes.NewAnyWithValue(msg)
|
||||
}
|
||||
|
||||
// UnpackAny unpacks an anypb.Any into a proto message.
|
||||
func UnpackAny[T any, PT ProtoMsgG[T]](anyPB *Any) (PT, error) {
|
||||
to := new(T)
|
||||
return to, UnpackAnyTo(anyPB, PT(to))
|
||||
}
|
||||
|
||||
func UnpackAnyTo(anyPB *Any, to transaction.Msg) error {
|
||||
return proto.Unmarshal(anyPB.Value, to)
|
||||
}
|
||||
|
||||
func UnpackAnyRaw(anyPB *Any) (proto.Message, error) {
|
||||
split := strings.Split(anyPB.TypeUrl, "/")
|
||||
name := split[len(split)-1]
|
||||
typ := proto.MessageType(name)
|
||||
if typ == nil {
|
||||
return nil, fmt.Errorf("no message type found for %s", name)
|
||||
}
|
||||
to := reflect.New(typ.Elem()).Interface().(proto.Message)
|
||||
return to, UnpackAnyTo(anyPB, to)
|
||||
}
|
||||
|
||||
func Merge(a, b transaction.Msg) {
|
||||
proto.Merge(a, b)
|
||||
}
|
||||
|
||||
func Equal(a, b transaction.Msg) bool {
|
||||
return proto.Equal(a, b)
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
package accounts
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"cosmossdk.io/collections"
|
||||
"cosmossdk.io/core/address"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
gogoproto "github.com/cosmos/gogoproto/proto"
|
||||
|
||||
"github.com/onsonr/sonr/pkg/core/appmodule"
|
||||
"github.com/onsonr/sonr/pkg/core/transaction"
|
||||
)
|
||||
|
||||
// Dependencies are passed to the constructor of a smart account.
|
||||
type Dependencies struct {
|
||||
SchemaBuilder *collections.SchemaBuilder
|
||||
AddressCodec address.Codec
|
||||
Environment appmodule.Environment
|
||||
LegacyStateCodec interface {
|
||||
Marshal(gogoproto.Message) ([]byte, error)
|
||||
Unmarshal([]byte, gogoproto.Message) error
|
||||
}
|
||||
}
|
||||
|
||||
// AccountCreatorFunc is a function that creates an account.
|
||||
type AccountCreatorFunc = func(deps Dependencies) (string, Account, error)
|
||||
|
||||
// MakeAccountsMap creates a map of account names to account implementations
|
||||
// from a list of account creator functions.
|
||||
func MakeAccountsMap(
|
||||
cdc codec.Codec,
|
||||
addressCodec address.Codec,
|
||||
env appmodule.Environment,
|
||||
accounts []AccountCreatorFunc,
|
||||
) (map[string]Implementation, error) {
|
||||
accountsMap := make(map[string]Implementation, len(accounts))
|
||||
for _, makeAccount := range accounts {
|
||||
stateSchemaBuilder := collections.NewSchemaBuilderFromAccessor(openKVStore)
|
||||
deps := Dependencies{
|
||||
SchemaBuilder: stateSchemaBuilder,
|
||||
AddressCodec: addressCodec,
|
||||
Environment: env,
|
||||
LegacyStateCodec: cdc,
|
||||
}
|
||||
name, accountInterface, err := makeAccount(deps)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create account %s: %w", name, err)
|
||||
}
|
||||
if _, ok := accountsMap[name]; ok {
|
||||
return nil, fmt.Errorf("account %s is already registered", name)
|
||||
}
|
||||
impl, err := newImplementation(stateSchemaBuilder, accountInterface)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create implementation for account %s: %w", name, err)
|
||||
}
|
||||
accountsMap[name] = impl
|
||||
}
|
||||
|
||||
return accountsMap, nil
|
||||
}
|
||||
|
||||
// newImplementation creates a new Implementation instance given an Account implementer.
|
||||
func newImplementation(schemaBuilder *collections.SchemaBuilder, account Account) (Implementation, error) {
|
||||
// make init handler
|
||||
ir := NewInitBuilder()
|
||||
account.RegisterInitHandler(ir)
|
||||
initHandler, err := ir.makeHandler()
|
||||
if err != nil {
|
||||
return Implementation{}, err
|
||||
}
|
||||
|
||||
// make execute handler
|
||||
er := NewExecuteBuilder()
|
||||
account.RegisterExecuteHandlers(er)
|
||||
executeHandler, err := er.makeHandler()
|
||||
if err != nil {
|
||||
return Implementation{}, err
|
||||
}
|
||||
|
||||
// make query handler
|
||||
qr := NewQueryBuilder()
|
||||
account.RegisterQueryHandlers(qr)
|
||||
queryHandler, err := qr.makeHandler()
|
||||
if err != nil {
|
||||
return Implementation{}, err
|
||||
}
|
||||
|
||||
// build schema
|
||||
schema, err := schemaBuilder.Build()
|
||||
if err != nil {
|
||||
return Implementation{}, err
|
||||
}
|
||||
return Implementation{
|
||||
Init: initHandler,
|
||||
Execute: executeHandler,
|
||||
Query: queryHandler,
|
||||
CollectionsSchema: schema,
|
||||
InitHandlerSchema: ir.schema,
|
||||
QueryHandlersSchema: qr.er.handlersSchema,
|
||||
ExecuteHandlersSchema: er.handlersSchema,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Implementation wraps an Account implementer in order to provide a concrete
|
||||
// and non-generic implementation usable by the x/accounts module.
|
||||
type Implementation struct {
|
||||
// Init defines the initialisation handler for the smart account.
|
||||
Init func(ctx context.Context, msg transaction.Msg) (resp transaction.Msg, err error)
|
||||
// Execute defines the execution handler for the smart account.
|
||||
Execute func(ctx context.Context, msg transaction.Msg) (resp transaction.Msg, err error)
|
||||
// Query defines the query handler for the smart account.
|
||||
Query func(ctx context.Context, msg transaction.Msg) (resp transaction.Msg, err error)
|
||||
// CollectionsSchema represents the state schema.
|
||||
CollectionsSchema collections.Schema
|
||||
// InitHandlerSchema represents the init handler schema.
|
||||
InitHandlerSchema HandlerSchema
|
||||
// QueryHandlersSchema is the schema of the query handlers.
|
||||
QueryHandlersSchema map[string]HandlerSchema
|
||||
// ExecuteHandlersSchema is the schema of the execute handlers.
|
||||
ExecuteHandlersSchema map[string]HandlerSchema
|
||||
}
|
||||
|
||||
// HasExec returns true if the account can execute the given msg.
|
||||
func (i Implementation) HasExec(m transaction.Msg) bool {
|
||||
_, ok := i.ExecuteHandlersSchema[MessageName(m)]
|
||||
return ok
|
||||
}
|
||||
|
||||
// HasQuery returns true if the account can execute the given request.
|
||||
func (i Implementation) HasQuery(m transaction.Msg) bool {
|
||||
_, ok := i.QueryHandlersSchema[MessageName(m)]
|
||||
return ok
|
||||
}
|
||||
|
||||
// HasInit returns true if the account uses the provided init message.
|
||||
func (i Implementation) HasInit(m transaction.Msg) bool {
|
||||
return i.InitHandlerSchema.RequestSchema.Name == MessageName(m)
|
||||
}
|
||||
|
||||
// MessageSchema defines the schema of a message.
|
||||
// A message can also define a state schema.
|
||||
type MessageSchema struct {
|
||||
// Name identifies the message name, this must be queryable from some reflection service.
|
||||
Name string
|
||||
// New is used to create a new message instance for the schema.
|
||||
New func() transaction.Msg
|
||||
}
|
||||
|
||||
// HandlerSchema defines the schema of a handler.
|
||||
type HandlerSchema struct {
|
||||
// RequestSchema defines the schema of the request.
|
||||
RequestSchema MessageSchema
|
||||
// ResponseSchema defines the schema of the response.
|
||||
ResponseSchema MessageSchema
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package accounts
|
||||
|
||||
// Account defines a smart account interface.
|
||||
type Account interface {
|
||||
// RegisterInitHandler allows the smart account to register an initialisation handler, using
|
||||
// the provided InitBuilder. The handler will be called when the smart account is initialized
|
||||
// (deployed).
|
||||
RegisterInitHandler(builder *InitBuilder)
|
||||
|
||||
// RegisterExecuteHandlers allows the smart account to register execution handlers.
|
||||
// The smart account might also decide to not register any execution handler.
|
||||
RegisterExecuteHandlers(builder *ExecuteBuilder)
|
||||
|
||||
// RegisterQueryHandlers allows the smart account to register query handlers. The smart account
|
||||
// might also decide to not register any query handler.
|
||||
RegisterQueryHandlers(builder *QueryBuilder)
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package accounts
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"github.com/onsonr/sonr/pkg/core/transaction"
|
||||
)
|
||||
|
||||
// RegisterInitHandler registers an initialisation handler for a smart account that uses protobuf.
|
||||
func RegisterInitHandler[
|
||||
Req any, ProtoReq ProtoMsgG[Req], Resp any, ProtoResp ProtoMsgG[Resp],
|
||||
](router *InitBuilder, handler func(ctx context.Context, req ProtoReq) (ProtoResp, error),
|
||||
) {
|
||||
reqName := MessageName(ProtoReq(new(Req)))
|
||||
|
||||
router.handler = func(ctx context.Context, initRequest transaction.Msg) (initResponse transaction.Msg, err error) {
|
||||
concrete, ok := initRequest.(ProtoReq)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("%w: wanted %s, got %T", errInvalidMessage, reqName, initRequest)
|
||||
}
|
||||
return handler(ctx, concrete)
|
||||
}
|
||||
|
||||
router.schema = HandlerSchema{
|
||||
RequestSchema: *NewProtoMessageSchema[Req, ProtoReq](),
|
||||
ResponseSchema: *NewProtoMessageSchema[Resp, ProtoResp](),
|
||||
}
|
||||
}
|
||||
|
||||
// RegisterExecuteHandler registers an execution handler for a smart account that uses protobuf.
|
||||
func RegisterExecuteHandler[
|
||||
Req any, ProtoReq ProtoMsgG[Req], Resp any, ProtoResp ProtoMsgG[Resp],
|
||||
](router *ExecuteBuilder, handler func(ctx context.Context, req ProtoReq) (ProtoResp, error),
|
||||
) {
|
||||
reqName := MessageName(ProtoReq(new(Req)))
|
||||
// check if not registered already
|
||||
if _, ok := router.handlers[reqName]; ok {
|
||||
router.err = fmt.Errorf("handler already registered for message %s", reqName)
|
||||
return
|
||||
}
|
||||
|
||||
router.handlers[reqName] = func(ctx context.Context, executeRequest transaction.Msg) (executeResponse transaction.Msg, err error) {
|
||||
concrete, ok := executeRequest.(ProtoReq)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("%w: wanted %s, got %T", errInvalidMessage, reqName, executeRequest)
|
||||
}
|
||||
return handler(ctx, concrete)
|
||||
}
|
||||
|
||||
router.handlersSchema[reqName] = HandlerSchema{
|
||||
RequestSchema: *NewProtoMessageSchema[Req, ProtoReq](),
|
||||
ResponseSchema: *NewProtoMessageSchema[Resp, ProtoResp](),
|
||||
}
|
||||
}
|
||||
|
||||
// RegisterQueryHandler registers a query handler for a smart account that uses protobuf.
|
||||
func RegisterQueryHandler[
|
||||
Req any, ProtoReq ProtoMsgG[Req], Resp any, ProtoResp ProtoMsgG[Resp],
|
||||
](router *QueryBuilder, handler func(ctx context.Context, req ProtoReq) (ProtoResp, error),
|
||||
) {
|
||||
RegisterExecuteHandler(router.er, handler)
|
||||
}
|
||||
|
||||
func NewProtoMessageSchema[T any, PT ProtoMsgG[T]]() *MessageSchema {
|
||||
msg := PT(new(T))
|
||||
if _, ok := (interface{}(msg)).(proto.Message); ok {
|
||||
panic("protov2 messages are not supported")
|
||||
}
|
||||
return &MessageSchema{
|
||||
Name: MessageName(msg),
|
||||
New: func() transaction.Msg {
|
||||
return PT(new(T))
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
// Package prefixstore provides a store that prefixes all keys with a given
|
||||
// prefix. It is used to isolate storage reads and writes for an account.
|
||||
// Implementation taken from cosmossdk.io/store/prefix, and adapted to
|
||||
// the cosmossdk.io/core/store.KVStore interface.
|
||||
package prefixstore
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
|
||||
"cosmossdk.io/core/store"
|
||||
)
|
||||
|
||||
// New creates a new prefix store using the provided bytes prefix.
|
||||
func New(store store.KVStore, prefix []byte) store.KVStore {
|
||||
return Store{
|
||||
parent: store,
|
||||
prefix: prefix,
|
||||
}
|
||||
}
|
||||
|
||||
var _ store.KVStore = Store{}
|
||||
|
||||
// Store is similar with cometbft/cometbft-db/blob/v1.0.1/prefixdb.go
|
||||
// both gives access only to the limited subset of the store
|
||||
// for convenience or safety
|
||||
type Store struct {
|
||||
parent store.KVStore
|
||||
prefix []byte
|
||||
}
|
||||
|
||||
func cloneAppend(bz, tail []byte) (res []byte) {
|
||||
res = make([]byte, len(bz)+len(tail))
|
||||
copy(res, bz)
|
||||
copy(res[len(bz):], tail)
|
||||
return
|
||||
}
|
||||
|
||||
func (s Store) key(key []byte) (res []byte) {
|
||||
if key == nil {
|
||||
panic("nil key on Store")
|
||||
}
|
||||
res = cloneAppend(s.prefix, key)
|
||||
return
|
||||
}
|
||||
|
||||
// Implements KVStore
|
||||
func (s Store) Get(key []byte) ([]byte, error) {
|
||||
return s.parent.Get(s.key(key))
|
||||
}
|
||||
|
||||
// Implements KVStore
|
||||
func (s Store) Has(key []byte) (bool, error) {
|
||||
return s.parent.Has(s.key(key))
|
||||
}
|
||||
|
||||
// Implements KVStore
|
||||
func (s Store) Set(key, value []byte) error {
|
||||
return s.parent.Set(s.key(key), value)
|
||||
}
|
||||
|
||||
// Implements KVStore
|
||||
func (s Store) Delete(key []byte) error { return s.parent.Delete(s.key(key)) }
|
||||
|
||||
// Implements KVStore
|
||||
// Check https://github.com/cometbft/cometbft-db/blob/v1.0.1/prefixdb.go#L109
|
||||
func (s Store) Iterator(start, end []byte) (store.Iterator, error) {
|
||||
newstart := cloneAppend(s.prefix, start)
|
||||
|
||||
var newend []byte
|
||||
if end == nil {
|
||||
newend = cpIncr(s.prefix)
|
||||
} else {
|
||||
newend = cloneAppend(s.prefix, end)
|
||||
}
|
||||
|
||||
iter, err := s.parent.Iterator(newstart, newend)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return newPrefixIterator(s.prefix, start, end, iter), nil
|
||||
}
|
||||
|
||||
// ReverseIterator implements KVStore
|
||||
// Check https://github.com/cometbft/cometbft-db/blob/v1.0.1/prefixdb.go#L132
|
||||
func (s Store) ReverseIterator(start, end []byte) (store.Iterator, error) {
|
||||
newstart := cloneAppend(s.prefix, start)
|
||||
|
||||
var newend []byte
|
||||
if end == nil {
|
||||
newend = cpIncr(s.prefix)
|
||||
} else {
|
||||
newend = cloneAppend(s.prefix, end)
|
||||
}
|
||||
|
||||
iter, err := s.parent.ReverseIterator(newstart, newend)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return newPrefixIterator(s.prefix, start, end, iter), nil
|
||||
}
|
||||
|
||||
var _ store.Iterator = (*prefixIterator)(nil)
|
||||
|
||||
type prefixIterator struct {
|
||||
prefix []byte
|
||||
start []byte
|
||||
end []byte
|
||||
iter store.Iterator
|
||||
valid bool
|
||||
}
|
||||
|
||||
func newPrefixIterator(prefix, start, end []byte, parent store.Iterator) *prefixIterator {
|
||||
return &prefixIterator{
|
||||
prefix: prefix,
|
||||
start: start,
|
||||
end: end,
|
||||
iter: parent,
|
||||
valid: parent.Valid() && bytes.HasPrefix(parent.Key(), prefix),
|
||||
}
|
||||
}
|
||||
|
||||
// Implements Iterator
|
||||
func (pi *prefixIterator) Domain() ([]byte, []byte) {
|
||||
return pi.start, pi.end
|
||||
}
|
||||
|
||||
// Implements Iterator
|
||||
func (pi *prefixIterator) Valid() bool {
|
||||
return pi.valid && pi.iter.Valid()
|
||||
}
|
||||
|
||||
// Implements Iterator
|
||||
func (pi *prefixIterator) Next() {
|
||||
if !pi.valid {
|
||||
panic("prefixIterator invalid, cannot call Next()")
|
||||
}
|
||||
|
||||
if pi.iter.Next(); !pi.iter.Valid() || !bytes.HasPrefix(pi.iter.Key(), pi.prefix) {
|
||||
// TODO: shouldn't pi be set to nil instead?
|
||||
pi.valid = false
|
||||
}
|
||||
}
|
||||
|
||||
// Implements Iterator
|
||||
func (pi *prefixIterator) Key() (key []byte) {
|
||||
if !pi.valid {
|
||||
panic("prefixIterator invalid, cannot call Key()")
|
||||
}
|
||||
|
||||
key = pi.iter.Key()
|
||||
key = stripPrefix(key, pi.prefix)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Implements Iterator
|
||||
func (pi *prefixIterator) Value() []byte {
|
||||
if !pi.valid {
|
||||
panic("prefixIterator invalid, cannot call Value()")
|
||||
}
|
||||
|
||||
return pi.iter.Value()
|
||||
}
|
||||
|
||||
// Implements Iterator
|
||||
func (pi *prefixIterator) Close() error {
|
||||
return pi.iter.Close()
|
||||
}
|
||||
|
||||
// Error returns an error if the prefixIterator is invalid defined by the Valid
|
||||
// method.
|
||||
func (pi *prefixIterator) Error() error {
|
||||
if !pi.Valid() {
|
||||
return errors.New("invalid prefixIterator")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// copied from github.com/cometbft/cometbft-db/blob/v1.0.1/prefixdb.go
|
||||
func stripPrefix(key, prefix []byte) []byte {
|
||||
if len(key) < len(prefix) || !bytes.Equal(key[:len(prefix)], prefix) {
|
||||
panic("should not happen")
|
||||
}
|
||||
|
||||
return key[len(prefix):]
|
||||
}
|
||||
|
||||
// wrapping types.PrefixEndBytes
|
||||
func cpIncr(bz []byte) []byte {
|
||||
return prefixEndBytes(bz)
|
||||
}
|
||||
|
||||
// prefixEndBytes returns the []byte that would end a
|
||||
// range query for all []byte with a certain prefix
|
||||
// Deals with last byte of prefix being FF without overflowing
|
||||
func prefixEndBytes(prefix []byte) []byte {
|
||||
if len(prefix) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
end := make([]byte, len(prefix))
|
||||
copy(end, prefix)
|
||||
|
||||
for {
|
||||
if end[len(end)-1] != byte(255) {
|
||||
end[len(end)-1]++
|
||||
break
|
||||
}
|
||||
|
||||
end = end[:len(end)-1]
|
||||
|
||||
if len(end) == 0 {
|
||||
end = nil
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return end
|
||||
}
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
"golang.org/x/crypto/sha3"
|
||||
)
|
||||
|
||||
// ComputeSonrAddress computes the Sonr address from a public key
|
||||
func ComputeSonrAddress(pk []byte) (string, error) {
|
||||
// ComputeSonrAddr computes the Sonr address from a public key
|
||||
func ComputeSonrAddr(pk []byte) (string, error) {
|
||||
sonrAddr, err := bech32.ConvertAndEncode("idx", pk)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -18,8 +18,8 @@ func ComputeSonrAddress(pk []byte) (string, error) {
|
||||
return sonrAddr, nil
|
||||
}
|
||||
|
||||
// ComputeBitcoinAddress computes the Bitcoin address from a public key
|
||||
func ComputeBitcoinAddress(pk []byte) (string, error) {
|
||||
// ComputeBitcoinAddr computes the Bitcoin address from a public key
|
||||
func ComputeBitcoinAddr(pk []byte) (string, error) {
|
||||
btcAddr, err := bech32.ConvertAndEncode("bc", pk)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -27,8 +27,8 @@ func ComputeBitcoinAddress(pk []byte) (string, error) {
|
||||
return btcAddr, nil
|
||||
}
|
||||
|
||||
// ComputeEthAddress computes the Ethereum address from a public key
|
||||
func ComputeEthAddress(pk *ecdsa.PublicKey) string {
|
||||
// ComputeEthereumAddr computes the Ethereum address from a public key
|
||||
func ComputeEthereumAddr(pk *ecdsa.PublicKey) string {
|
||||
// Generate Ethereum address
|
||||
address := ethcrypto.PubkeyToAddress(*pk)
|
||||
|
||||
+165
-1805
File diff suppressed because it is too large
Load Diff
@@ -1,68 +0,0 @@
|
||||
package mpc
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
"github.com/golang/protobuf/proto"
|
||||
)
|
||||
|
||||
// CustomPubKey represents a custom secp256k1 public key.
|
||||
type CustomPubKey struct {
|
||||
proto.Message
|
||||
|
||||
Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
|
||||
}
|
||||
|
||||
// NewCustomPubKeyFromRawBytes creates a new CustomPubKey from raw bytes.
|
||||
func NewCustomPubKeyFromRawBytes(key []byte) (*CustomPubKey, error) {
|
||||
// Validate the key length and format
|
||||
if len(key) != 33 {
|
||||
return nil, fmt.Errorf("invalid key length; expected 33 bytes, got %d", len(key))
|
||||
}
|
||||
if key[0] != 0x02 && key[0] != 0x03 {
|
||||
return nil, fmt.Errorf("invalid key format; expected 0x02 or 0x03 as the first byte, got 0x%02x", key[0])
|
||||
}
|
||||
|
||||
return &CustomPubKey{Key: key}, nil
|
||||
}
|
||||
|
||||
// Bytes returns the byte representation of the public key.
|
||||
func (pk *CustomPubKey) Bytes() []byte {
|
||||
return pk.Key
|
||||
}
|
||||
|
||||
// Equals checks if two public keys are equal.
|
||||
func (pk *CustomPubKey) Equals(other types.PubKey) bool {
|
||||
return bytes.EqualFold(pk.Bytes(), other.Bytes())
|
||||
}
|
||||
|
||||
// Type returns the type of the public key.
|
||||
func (pk *CustomPubKey) Type() string {
|
||||
return "custom-secp256k1"
|
||||
}
|
||||
|
||||
// Marshal implements the proto.Message interface.
|
||||
func (pk *CustomPubKey) Marshal() ([]byte, error) {
|
||||
return proto.Marshal(pk)
|
||||
}
|
||||
|
||||
// Unmarshal implements the proto.Message interface.
|
||||
func (pk *CustomPubKey) Unmarshal(data []byte) error {
|
||||
return proto.Unmarshal(data, pk)
|
||||
}
|
||||
|
||||
// Address returns the address derived from the public key.
|
||||
func (pk *CustomPubKey) Address() []byte {
|
||||
// Implement address derivation logic here
|
||||
// For simplicity, this example uses a placeholder
|
||||
return []byte("derived-address")
|
||||
}
|
||||
|
||||
// VerifySignature verifies a signature using the public key.
|
||||
func (pk *CustomPubKey) VerifySignature(msg []byte, sig []byte) bool {
|
||||
// Implement signature verification logic here
|
||||
// For simplicity, this example uses a placeholder
|
||||
return true
|
||||
}
|
||||
@@ -4,10 +4,10 @@ import (
|
||||
"encoding/json"
|
||||
fmt "fmt"
|
||||
|
||||
"github.com/onsonr/sonr/internal/orm/keyalgorithm"
|
||||
"github.com/onsonr/sonr/internal/orm/keycurve"
|
||||
"github.com/onsonr/sonr/internal/orm/keyencoding"
|
||||
"github.com/onsonr/sonr/internal/orm/keyrole"
|
||||
"github.com/onsonr/sonr/pkg/motr/types/orm/keyalgorithm"
|
||||
"github.com/onsonr/sonr/pkg/motr/types/orm/keycurve"
|
||||
"github.com/onsonr/sonr/pkg/motr/types/orm/keyencoding"
|
||||
"github.com/onsonr/sonr/pkg/motr/types/orm/keyrole"
|
||||
)
|
||||
|
||||
// DefaultParams returns default module parameters.
|
||||
|
||||
@@ -0,0 +1,931 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: did/v1/params.proto
|
||||
|
||||
package types
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
_ "github.com/cosmos/cosmos-sdk/types/tx/amino"
|
||||
_ "github.com/cosmos/gogoproto/gogoproto"
|
||||
proto "github.com/cosmos/gogoproto/proto"
|
||||
io "io"
|
||||
math "math"
|
||||
math_bits "math/bits"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
// Params defines the set of module parameters.
|
||||
type Params struct {
|
||||
// Whitelisted Key Types
|
||||
AllowedPublicKeys map[string]*KeyInfo `protobuf:"bytes,2,rep,name=allowed_public_keys,json=allowedPublicKeys,proto3" json:"allowed_public_keys,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||
// ConveyancePreference defines the conveyance preference
|
||||
ConveyancePreference string `protobuf:"bytes,3,opt,name=conveyance_preference,json=conveyancePreference,proto3" json:"conveyance_preference,omitempty"`
|
||||
// AttestationFormats defines the attestation formats
|
||||
AttestationFormats []string `protobuf:"bytes,4,rep,name=attestation_formats,json=attestationFormats,proto3" json:"attestation_formats,omitempty"`
|
||||
}
|
||||
|
||||
func (m *Params) Reset() { *m = Params{} }
|
||||
func (*Params) ProtoMessage() {}
|
||||
func (*Params) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_9d62d07335ae093e, []int{0}
|
||||
}
|
||||
func (m *Params) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_Params.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *Params) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Params.Merge(m, src)
|
||||
}
|
||||
func (m *Params) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *Params) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Params.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Params proto.InternalMessageInfo
|
||||
|
||||
func (m *Params) GetAllowedPublicKeys() map[string]*KeyInfo {
|
||||
if m != nil {
|
||||
return m.AllowedPublicKeys
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Params) GetConveyancePreference() string {
|
||||
if m != nil {
|
||||
return m.ConveyancePreference
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Params) GetAttestationFormats() []string {
|
||||
if m != nil {
|
||||
return m.AttestationFormats
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// KeyInfo defines information for accepted PubKey types
|
||||
type KeyInfo struct {
|
||||
Role string `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"`
|
||||
Algorithm string `protobuf:"bytes,2,opt,name=algorithm,proto3" json:"algorithm,omitempty"`
|
||||
Encoding string `protobuf:"bytes,3,opt,name=encoding,proto3" json:"encoding,omitempty"`
|
||||
Curve string `protobuf:"bytes,4,opt,name=curve,proto3" json:"curve,omitempty"`
|
||||
}
|
||||
|
||||
func (m *KeyInfo) Reset() { *m = KeyInfo{} }
|
||||
func (m *KeyInfo) String() string { return proto.CompactTextString(m) }
|
||||
func (*KeyInfo) ProtoMessage() {}
|
||||
func (*KeyInfo) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_9d62d07335ae093e, []int{1}
|
||||
}
|
||||
func (m *KeyInfo) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *KeyInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_KeyInfo.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *KeyInfo) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_KeyInfo.Merge(m, src)
|
||||
}
|
||||
func (m *KeyInfo) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *KeyInfo) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_KeyInfo.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_KeyInfo proto.InternalMessageInfo
|
||||
|
||||
func (m *KeyInfo) GetRole() string {
|
||||
if m != nil {
|
||||
return m.Role
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *KeyInfo) GetAlgorithm() string {
|
||||
if m != nil {
|
||||
return m.Algorithm
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *KeyInfo) GetEncoding() string {
|
||||
if m != nil {
|
||||
return m.Encoding
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *KeyInfo) GetCurve() string {
|
||||
if m != nil {
|
||||
return m.Curve
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*Params)(nil), "did.v1.Params")
|
||||
proto.RegisterMapType((map[string]*KeyInfo)(nil), "did.v1.Params.AllowedPublicKeysEntry")
|
||||
proto.RegisterType((*KeyInfo)(nil), "did.v1.KeyInfo")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("did/v1/params.proto", fileDescriptor_9d62d07335ae093e) }
|
||||
|
||||
var fileDescriptor_9d62d07335ae093e = []byte{
|
||||
// 412 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0x31, 0x6f, 0xd3, 0x40,
|
||||
0x14, 0xc7, 0x73, 0x49, 0x1a, 0xc8, 0x75, 0x80, 0x5e, 0x02, 0x58, 0x11, 0x72, 0xa3, 0x48, 0x95,
|
||||
0x2c, 0x06, 0x9f, 0xda, 0x2e, 0xa8, 0x62, 0x01, 0x09, 0x24, 0xd4, 0x25, 0xb2, 0xd4, 0x85, 0xc5,
|
||||
0xba, 0xd8, 0x2f, 0xee, 0xa9, 0xf6, 0x3d, 0xeb, 0x7c, 0x36, 0xf8, 0x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 0xa2, 0x88, 0x53, 0x33, 0x02, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (this *Params) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
}
|
||||
|
||||
that1, ok := that.(*Params)
|
||||
if !ok {
|
||||
that2, ok := that.(Params)
|
||||
if ok {
|
||||
that1 = &that2
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
if len(this.AllowedPublicKeys) != len(that1.AllowedPublicKeys) {
|
||||
return false
|
||||
}
|
||||
for i := range this.AllowedPublicKeys {
|
||||
if !this.AllowedPublicKeys[i].Equal(that1.AllowedPublicKeys[i]) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if this.ConveyancePreference != that1.ConveyancePreference {
|
||||
return false
|
||||
}
|
||||
if len(this.AttestationFormats) != len(that1.AttestationFormats) {
|
||||
return false
|
||||
}
|
||||
for i := range this.AttestationFormats {
|
||||
if this.AttestationFormats[i] != that1.AttestationFormats[i] {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
func (m *Params) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *Params) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.AttestationFormats) > 0 {
|
||||
for iNdEx := len(m.AttestationFormats) - 1; iNdEx >= 0; iNdEx-- {
|
||||
i -= len(m.AttestationFormats[iNdEx])
|
||||
copy(dAtA[i:], m.AttestationFormats[iNdEx])
|
||||
i = encodeVarintParams(dAtA, i, uint64(len(m.AttestationFormats[iNdEx])))
|
||||
i--
|
||||
dAtA[i] = 0x22
|
||||
}
|
||||
}
|
||||
if len(m.ConveyancePreference) > 0 {
|
||||
i -= len(m.ConveyancePreference)
|
||||
copy(dAtA[i:], m.ConveyancePreference)
|
||||
i = encodeVarintParams(dAtA, i, uint64(len(m.ConveyancePreference)))
|
||||
i--
|
||||
dAtA[i] = 0x1a
|
||||
}
|
||||
if len(m.AllowedPublicKeys) > 0 {
|
||||
for k := range m.AllowedPublicKeys {
|
||||
v := m.AllowedPublicKeys[k]
|
||||
baseI := i
|
||||
if v != nil {
|
||||
{
|
||||
size, err := v.MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintParams(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
i -= len(k)
|
||||
copy(dAtA[i:], k)
|
||||
i = encodeVarintParams(dAtA, i, uint64(len(k)))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
i = encodeVarintParams(dAtA, i, uint64(baseI-i))
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *KeyInfo) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *KeyInfo) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *KeyInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Curve) > 0 {
|
||||
i -= len(m.Curve)
|
||||
copy(dAtA[i:], m.Curve)
|
||||
i = encodeVarintParams(dAtA, i, uint64(len(m.Curve)))
|
||||
i--
|
||||
dAtA[i] = 0x22
|
||||
}
|
||||
if len(m.Encoding) > 0 {
|
||||
i -= len(m.Encoding)
|
||||
copy(dAtA[i:], m.Encoding)
|
||||
i = encodeVarintParams(dAtA, i, uint64(len(m.Encoding)))
|
||||
i--
|
||||
dAtA[i] = 0x1a
|
||||
}
|
||||
if len(m.Algorithm) > 0 {
|
||||
i -= len(m.Algorithm)
|
||||
copy(dAtA[i:], m.Algorithm)
|
||||
i = encodeVarintParams(dAtA, i, uint64(len(m.Algorithm)))
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
if len(m.Role) > 0 {
|
||||
i -= len(m.Role)
|
||||
copy(dAtA[i:], m.Role)
|
||||
i = encodeVarintParams(dAtA, i, uint64(len(m.Role)))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func encodeVarintParams(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovParams(v)
|
||||
base := offset
|
||||
for v >= 1<<7 {
|
||||
dAtA[offset] = uint8(v&0x7f | 0x80)
|
||||
v >>= 7
|
||||
offset++
|
||||
}
|
||||
dAtA[offset] = uint8(v)
|
||||
return base
|
||||
}
|
||||
func (m *Params) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.AllowedPublicKeys) > 0 {
|
||||
for k, v := range m.AllowedPublicKeys {
|
||||
_ = k
|
||||
_ = v
|
||||
l = 0
|
||||
if v != nil {
|
||||
l = v.Size()
|
||||
l += 1 + sovParams(uint64(l))
|
||||
}
|
||||
mapEntrySize := 1 + len(k) + sovParams(uint64(len(k))) + l
|
||||
n += mapEntrySize + 1 + sovParams(uint64(mapEntrySize))
|
||||
}
|
||||
}
|
||||
l = len(m.ConveyancePreference)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovParams(uint64(l))
|
||||
}
|
||||
if len(m.AttestationFormats) > 0 {
|
||||
for _, s := range m.AttestationFormats {
|
||||
l = len(s)
|
||||
n += 1 + l + sovParams(uint64(l))
|
||||
}
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *KeyInfo) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
l = len(m.Role)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovParams(uint64(l))
|
||||
}
|
||||
l = len(m.Algorithm)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovParams(uint64(l))
|
||||
}
|
||||
l = len(m.Encoding)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovParams(uint64(l))
|
||||
}
|
||||
l = len(m.Curve)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovParams(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func sovParams(x uint64) (n int) {
|
||||
return (math_bits.Len64(x|1) + 6) / 7
|
||||
}
|
||||
func sozParams(x uint64) (n int) {
|
||||
return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
||||
}
|
||||
func (m *Params) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowParams
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: Params: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field AllowedPublicKeys", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowParams
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthParams
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthParams
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if m.AllowedPublicKeys == nil {
|
||||
m.AllowedPublicKeys = make(map[string]*KeyInfo)
|
||||
}
|
||||
var mapkey string
|
||||
var mapvalue *KeyInfo
|
||||
for iNdEx < postIndex {
|
||||
entryPreIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowParams
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
if fieldNum == 1 {
|
||||
var stringLenmapkey uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowParams
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLenmapkey |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLenmapkey := int(stringLenmapkey)
|
||||
if intStringLenmapkey < 0 {
|
||||
return ErrInvalidLengthParams
|
||||
}
|
||||
postStringIndexmapkey := iNdEx + intStringLenmapkey
|
||||
if postStringIndexmapkey < 0 {
|
||||
return ErrInvalidLengthParams
|
||||
}
|
||||
if postStringIndexmapkey > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
mapkey = string(dAtA[iNdEx:postStringIndexmapkey])
|
||||
iNdEx = postStringIndexmapkey
|
||||
} else if fieldNum == 2 {
|
||||
var mapmsglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowParams
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
mapmsglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if mapmsglen < 0 {
|
||||
return ErrInvalidLengthParams
|
||||
}
|
||||
postmsgIndex := iNdEx + mapmsglen
|
||||
if postmsgIndex < 0 {
|
||||
return ErrInvalidLengthParams
|
||||
}
|
||||
if postmsgIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
mapvalue = &KeyInfo{}
|
||||
if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postmsgIndex
|
||||
} else {
|
||||
iNdEx = entryPreIndex
|
||||
skippy, err := skipParams(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthParams
|
||||
}
|
||||
if (iNdEx + skippy) > postIndex {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
m.AllowedPublicKeys[mapkey] = mapvalue
|
||||
iNdEx = postIndex
|
||||
case 3:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field ConveyancePreference", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowParams
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthParams
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthParams
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.ConveyancePreference = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 4:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field AttestationFormats", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowParams
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthParams
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthParams
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.AttestationFormats = append(m.AttestationFormats, string(dAtA[iNdEx:postIndex]))
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipParams(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthParams
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *KeyInfo) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowParams
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: KeyInfo: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: KeyInfo: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Role", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowParams
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthParams
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthParams
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Role = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Algorithm", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowParams
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthParams
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthParams
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Algorithm = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 3:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Encoding", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowParams
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthParams
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthParams
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Encoding = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 4:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Curve", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowParams
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthParams
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthParams
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Curve = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipParams(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthParams
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func skipParams(dAtA []byte) (n int, err error) {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
depth := 0
|
||||
for iNdEx < l {
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowParams
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= (uint64(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
wireType := int(wire & 0x7)
|
||||
switch wireType {
|
||||
case 0:
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowParams
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx++
|
||||
if dAtA[iNdEx-1] < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 1:
|
||||
iNdEx += 8
|
||||
case 2:
|
||||
var length int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowParams
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
length |= (int(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if length < 0 {
|
||||
return 0, ErrInvalidLengthParams
|
||||
}
|
||||
iNdEx += length
|
||||
case 3:
|
||||
depth++
|
||||
case 4:
|
||||
if depth == 0 {
|
||||
return 0, ErrUnexpectedEndOfGroupParams
|
||||
}
|
||||
depth--
|
||||
case 5:
|
||||
iNdEx += 4
|
||||
default:
|
||||
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
|
||||
}
|
||||
if iNdEx < 0 {
|
||||
return 0, ErrInvalidLengthParams
|
||||
}
|
||||
if depth == 0 {
|
||||
return iNdEx, nil
|
||||
}
|
||||
}
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
|
||||
var (
|
||||
ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling")
|
||||
ErrIntOverflowParams = fmt.Errorf("proto: integer overflow")
|
||||
ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group")
|
||||
)
|
||||
@@ -1,76 +0,0 @@
|
||||
package pubkey
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
didv1 "github.com/onsonr/sonr/api/did/v1"
|
||||
)
|
||||
|
||||
type PubKeyI interface {
|
||||
GetRole() string
|
||||
GetKeyType() string
|
||||
GetRawKey() *didv1.RawKey
|
||||
GetJwk() *didv1.JSONWebKey
|
||||
}
|
||||
|
||||
// PubKey defines a generic pubkey.
|
||||
type PublicKey interface {
|
||||
VerifySignature(msg, sig []byte) bool
|
||||
}
|
||||
|
||||
type PubKeyG[T any] interface {
|
||||
*T
|
||||
PublicKey
|
||||
}
|
||||
|
||||
type pubKeyImpl struct {
|
||||
decode func(b []byte) (PublicKey, error)
|
||||
validate func(key PublicKey) error
|
||||
}
|
||||
|
||||
// func WithSecp256K1PubKey() Option {
|
||||
// return WithPubKeyWithValidationFunc(func(pt *secp256k1.PubKey) error {
|
||||
// _, err := dcrd_secp256k1.ParsePubKey(pt.Key)
|
||||
// return err
|
||||
// })
|
||||
// }
|
||||
//
|
||||
// func WithPubKey[T any, PT PubKeyG[T]]() Option {
|
||||
// return WithPubKeyWithValidationFunc[T, PT](func(_ PT) error {
|
||||
// return nil
|
||||
// })
|
||||
// }
|
||||
//
|
||||
// func WithPubKeyWithValidationFunc[T any, PT PubKeyG[T]](validateFn func(PT) error) Option {
|
||||
// pkImpl := pubKeyImpl{
|
||||
// decode: func(b []byte) (PublicKey, error) {
|
||||
// key := PT(new(T))
|
||||
// err := gogoproto.Unmarshal(b, key)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
// return key, nil
|
||||
// },
|
||||
// validate: func(k PublicKey) error {
|
||||
// concrete, ok := k.(PT)
|
||||
// if !ok {
|
||||
// return fmt.Errorf(
|
||||
// "invalid pubkey type passed for validation, wanted: %T, got: %T",
|
||||
// concrete,
|
||||
// k,
|
||||
// )
|
||||
// }
|
||||
// return validateFn(concrete)
|
||||
// },
|
||||
// }
|
||||
// return func(a *Account) {
|
||||
// a.supportedPubKeys[gogoproto.MessageName(PT(new(T)))] = pkImpl
|
||||
// }
|
||||
// }
|
||||
func nameFromTypeURL(url string) string {
|
||||
name := url
|
||||
if i := strings.LastIndexByte(url, '/'); i >= 0 {
|
||||
name = name[i+len("/"):]
|
||||
}
|
||||
return name
|
||||
}
|
||||
+31
-576
@@ -443,99 +443,6 @@ func (m *QueryVerifyResponse) GetValid() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// Document defines a DID document
|
||||
type Document struct {
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
Controller string `protobuf:"bytes,2,opt,name=controller,proto3" json:"controller,omitempty"`
|
||||
Authentication []string `protobuf:"bytes,3,rep,name=authentication,proto3" json:"authentication,omitempty"`
|
||||
AssertionMethod []string `protobuf:"bytes,4,rep,name=assertion_method,json=assertionMethod,proto3" json:"assertion_method,omitempty"`
|
||||
CapabilityDelegation []string `protobuf:"bytes,5,rep,name=capability_delegation,json=capabilityDelegation,proto3" json:"capability_delegation,omitempty"`
|
||||
CapabilityInvocation []string `protobuf:"bytes,6,rep,name=capability_invocation,json=capabilityInvocation,proto3" json:"capability_invocation,omitempty"`
|
||||
Service []string `protobuf:"bytes,7,rep,name=service,proto3" json:"service,omitempty"`
|
||||
}
|
||||
|
||||
func (m *Document) Reset() { *m = Document{} }
|
||||
func (m *Document) String() string { return proto.CompactTextString(m) }
|
||||
func (*Document) ProtoMessage() {}
|
||||
func (*Document) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_ae1fa9bb626e2869, []int{7}
|
||||
}
|
||||
func (m *Document) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *Document) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_Document.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *Document) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Document.Merge(m, src)
|
||||
}
|
||||
func (m *Document) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *Document) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Document.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Document proto.InternalMessageInfo
|
||||
|
||||
func (m *Document) GetId() string {
|
||||
if m != nil {
|
||||
return m.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Document) GetController() string {
|
||||
if m != nil {
|
||||
return m.Controller
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Document) GetAuthentication() []string {
|
||||
if m != nil {
|
||||
return m.Authentication
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Document) GetAssertionMethod() []string {
|
||||
if m != nil {
|
||||
return m.AssertionMethod
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Document) GetCapabilityDelegation() []string {
|
||||
if m != nil {
|
||||
return m.CapabilityDelegation
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Document) GetCapabilityInvocation() []string {
|
||||
if m != nil {
|
||||
return m.CapabilityInvocation
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Document) GetService() []string {
|
||||
if m != nil {
|
||||
return m.Service
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*QueryRequest)(nil), "did.v1.QueryRequest")
|
||||
proto.RegisterType((*QueryParamsResponse)(nil), "did.v1.QueryParamsResponse")
|
||||
@@ -544,53 +451,42 @@ func init() {
|
||||
proto.RegisterType((*QuerySignResponse)(nil), "did.v1.QuerySignResponse")
|
||||
proto.RegisterType((*QueryVerifyRequest)(nil), "did.v1.QueryVerifyRequest")
|
||||
proto.RegisterType((*QueryVerifyResponse)(nil), "did.v1.QueryVerifyResponse")
|
||||
proto.RegisterType((*Document)(nil), "did.v1.Document")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("did/v1/query.proto", fileDescriptor_ae1fa9bb626e2869) }
|
||||
|
||||
var fileDescriptor_ae1fa9bb626e2869 = []byte{
|
||||
// 625 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x54, 0x41, 0x6f, 0xd3, 0x4c,
|
||||
0x10, 0x6d, 0x92, 0xc6, 0x6d, 0xe7, 0xfb, 0x48, 0xc3, 0xe2, 0x56, 0x26, 0x44, 0x56, 0xb5, 0x87,
|
||||
0xaa, 0x08, 0x14, 0xab, 0xed, 0x15, 0x2e, 0xa8, 0x17, 0x0e, 0x48, 0x90, 0x22, 0x90, 0xb8, 0x94,
|
||||
0x6d, 0x76, 0x70, 0x57, 0x75, 0x76, 0x53, 0xef, 0xc6, 0x22, 0x42, 0x70, 0xe0, 0x17, 0x80, 0xb8,
|
||||
0xf3, 0x7b, 0x38, 0x56, 0xe2, 0xc2, 0x11, 0xb5, 0x1c, 0xf9, 0x11, 0xc8, 0xeb, 0x75, 0x1a, 0x5b,
|
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96, 0xc7, 0xcc, 0x26, 0xa8, 0x8f, 0x3d,
|
||||
0xfb, 0xbd, 0xdc, 0xff, 0x15, 0x00, 0x00, 0xff, 0xff, 0xb9, 0xc1, 0x21, 0x0f, 0x81, 0x05, 0x00,
|
||||
0x00,
|
||||
// 478 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x53, 0xc1, 0x6e, 0xd3, 0x40,
|
||||
0x10, 0x8d, 0x53, 0xe2, 0xb6, 0x03, 0x94, 0xb0, 0x35, 0x91, 0x15, 0x22, 0x0b, 0xed, 0x01, 0x21,
|
||||
0x81, 0x6c, 0xa5, 0x5c, 0xe1, 0x82, 0xfa, 0x01, 0xe0, 0x22, 0x0e, 0x5c, 0xc0, 0xed, 0x0e, 0x66,
|
||||
0xd5, 0x64, 0xd7, 0xf5, 0xae, 0x2d, 0x2c, 0x04, 0x07, 0xbe, 0x00, 0xa9, 0x77, 0xbe, 0x87, 0x63,
|
||||
0x25, 0x2e, 0x1c, 0x51, 0xc2, 0x87, 0xa0, 0xac, 0xd7, 0x25, 0x1b, 0x89, 0x23, 0xea, 0xc5, 0xf2,
|
||||
0xbc, 0x79, 0xf3, 0xe6, 0x8d, 0x67, 0x0c, 0x84, 0x71, 0x96, 0xd4, 0xd3, 0xe4, 0xac, 0xc2, 0xb2,
|
||||
0x89, 0x8b, 0x52, 0x6a, 0x49, 0x7c, 0xc6, 0x59, 0x5c, 0x4f, 0xc7, 0x81, 0xcd, 0xe5, 0x28, 0x50,
|
||||
0x71, 0xd5, 0x66, 0xc7, 0xfb, 0x16, 0x2d, 0xb2, 0x32, 0x9b, 0x77, 0xe0, 0x24, 0x97, 0x32, 0x9f,
|
||||
0x61, 0x92, 0x15, 0x3c, 0xc9, 0x84, 0x90, 0x3a, 0xd3, 0x5c, 0x0a, 0x9b, 0xa5, 0x6f, 0xe1, 0xc6,
|
||||
0x8b, 0x95, 0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
||||
0x41, 0x9d, 0xcd, 0xac, 0xc5, 0x9d, 0xb4, 0x0d, 0x0e, 0xce, 0xfb, 0x30, 0x30, 0x6c, 0x72, 0x04,
|
||||
0x7e, 0xbb, 0x62, 0x12, 0x74, 0x0b, 0x5b, 0xbf, 0xc0, 0xf1, 0x5d, 0x07, 0x75, 0xaf, 0x86, 0x8e,
|
||||
0xbe, 0xfc, 0xf8, 0x7d, 0xde, 0x1f, 0x92, 0xbd, 0xc4, 0x39, 0x75, 0xf2, 0x12, 0xb6, 0xed, 0x81,
|
||||
0xfc, 0x43, 0x75, 0xb2, 0x81, 0x3a, 0xc7, 0x44, 0xef, 0x18, 0xd9, 0x5b, 0xe4, 0x66, 0x27, 0xfb,
|
||||
0x91, 0x71, 0xf6, 0x89, 0xbc, 0x01, 0xbf, 0x1d, 0x8e, 0x8c, 0x9d, 0x72, 0x67, 0x23, 0x1b, 0x86,
|
||||
0xdd, 0xaf, 0x41, 0x27, 0x46, 0x79, 0x44, 0x03, 0x47, 0x39, 0xa9, 0x0d, 0xeb, 0xd9, 0x93, 0xef,
|
||||
0x8b, 0xc8, 0xbb, 0x58, 0x44, 0xde, 0xaf, 0x45, 0xe4, 0x7d, 0x5d, 0x46, 0xbd, 0x8b, 0x65, 0xd4,
|
||||
0xfb, 0xb9, 0x8c, 0x7a, 0xaf, 0x69, 0xce, 0xf5, 0xfb, 0xea, 0x38, 0x3e, 0x91, 0xf3, 0x44, 0x0a,
|
||||
0x25, 0x45, 0x99, 0x98, 0xc7, 0x07, 0xa3, 0xa3, 0x9b, 0x02, 0xd5, 0xb1, 0x6f, 0x7e, 0xe1, 0xc7,
|
||||
0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x63, 0xf5, 0x0e, 0x9a, 0x29, 0x04, 0x00, 0x00,
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
@@ -609,8 +505,6 @@ type QueryClient interface {
|
||||
Params(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error)
|
||||
// Resolve queries the DID document by its id.
|
||||
Resolve(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryResolveResponse, error)
|
||||
// Sign signs a message with the DID document
|
||||
Sign(ctx context.Context, in *QuerySignRequest, opts ...grpc.CallOption) (*QuerySignResponse, error)
|
||||
// Verify verifies a message with the DID document
|
||||
Verify(ctx context.Context, in *QueryVerifyRequest, opts ...grpc.CallOption) (*QueryVerifyResponse, error)
|
||||
}
|
||||
@@ -641,15 +535,6 @@ func (c *queryClient) Resolve(ctx context.Context, in *QueryRequest, opts ...grp
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *queryClient) Sign(ctx context.Context, in *QuerySignRequest, opts ...grpc.CallOption) (*QuerySignResponse, error) {
|
||||
out := new(QuerySignResponse)
|
||||
err := c.cc.Invoke(ctx, "/did.v1.Query/Sign", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *queryClient) Verify(ctx context.Context, in *QueryVerifyRequest, opts ...grpc.CallOption) (*QueryVerifyResponse, error) {
|
||||
out := new(QueryVerifyResponse)
|
||||
err := c.cc.Invoke(ctx, "/did.v1.Query/Verify", in, out, opts...)
|
||||
@@ -665,8 +550,6 @@ type QueryServer interface {
|
||||
Params(context.Context, *QueryRequest) (*QueryParamsResponse, error)
|
||||
// Resolve queries the DID document by its id.
|
||||
Resolve(context.Context, *QueryRequest) (*QueryResolveResponse, error)
|
||||
// Sign signs a message with the DID document
|
||||
Sign(context.Context, *QuerySignRequest) (*QuerySignResponse, error)
|
||||
// Verify verifies a message with the DID document
|
||||
Verify(context.Context, *QueryVerifyRequest) (*QueryVerifyResponse, error)
|
||||
}
|
||||
@@ -681,9 +564,6 @@ func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryRequest)
|
||||
func (*UnimplementedQueryServer) Resolve(ctx context.Context, req *QueryRequest) (*QueryResolveResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Resolve not implemented")
|
||||
}
|
||||
func (*UnimplementedQueryServer) Sign(ctx context.Context, req *QuerySignRequest) (*QuerySignResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Sign not implemented")
|
||||
}
|
||||
func (*UnimplementedQueryServer) Verify(ctx context.Context, req *QueryVerifyRequest) (*QueryVerifyResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Verify not implemented")
|
||||
}
|
||||
@@ -728,24 +608,6 @@ func _Query_Resolve_Handler(srv interface{}, ctx context.Context, dec func(inter
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Query_Sign_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(QuerySignRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(QueryServer).Sign(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/did.v1.Query/Sign",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(QueryServer).Sign(ctx, req.(*QuerySignRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Query_Verify_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(QueryVerifyRequest)
|
||||
if err := dec(in); err != nil {
|
||||
@@ -777,10 +639,6 @@ var _Query_serviceDesc = grpc.ServiceDesc{
|
||||
MethodName: "Resolve",
|
||||
Handler: _Query_Resolve_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Sign",
|
||||
Handler: _Query_Sign_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Verify",
|
||||
Handler: _Query_Verify_Handler,
|
||||
@@ -1097,88 +955,6 @@ func (m *QueryVerifyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *Document) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *Document) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *Document) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Service) > 0 {
|
||||
for iNdEx := len(m.Service) - 1; iNdEx >= 0; iNdEx-- {
|
||||
i -= len(m.Service[iNdEx])
|
||||
copy(dAtA[i:], m.Service[iNdEx])
|
||||
i = encodeVarintQuery(dAtA, i, uint64(len(m.Service[iNdEx])))
|
||||
i--
|
||||
dAtA[i] = 0x3a
|
||||
}
|
||||
}
|
||||
if len(m.CapabilityInvocation) > 0 {
|
||||
for iNdEx := len(m.CapabilityInvocation) - 1; iNdEx >= 0; iNdEx-- {
|
||||
i -= len(m.CapabilityInvocation[iNdEx])
|
||||
copy(dAtA[i:], m.CapabilityInvocation[iNdEx])
|
||||
i = encodeVarintQuery(dAtA, i, uint64(len(m.CapabilityInvocation[iNdEx])))
|
||||
i--
|
||||
dAtA[i] = 0x32
|
||||
}
|
||||
}
|
||||
if len(m.CapabilityDelegation) > 0 {
|
||||
for iNdEx := len(m.CapabilityDelegation) - 1; iNdEx >= 0; iNdEx-- {
|
||||
i -= len(m.CapabilityDelegation[iNdEx])
|
||||
copy(dAtA[i:], m.CapabilityDelegation[iNdEx])
|
||||
i = encodeVarintQuery(dAtA, i, uint64(len(m.CapabilityDelegation[iNdEx])))
|
||||
i--
|
||||
dAtA[i] = 0x2a
|
||||
}
|
||||
}
|
||||
if len(m.AssertionMethod) > 0 {
|
||||
for iNdEx := len(m.AssertionMethod) - 1; iNdEx >= 0; iNdEx-- {
|
||||
i -= len(m.AssertionMethod[iNdEx])
|
||||
copy(dAtA[i:], m.AssertionMethod[iNdEx])
|
||||
i = encodeVarintQuery(dAtA, i, uint64(len(m.AssertionMethod[iNdEx])))
|
||||
i--
|
||||
dAtA[i] = 0x22
|
||||
}
|
||||
}
|
||||
if len(m.Authentication) > 0 {
|
||||
for iNdEx := len(m.Authentication) - 1; iNdEx >= 0; iNdEx-- {
|
||||
i -= len(m.Authentication[iNdEx])
|
||||
copy(dAtA[i:], m.Authentication[iNdEx])
|
||||
i = encodeVarintQuery(dAtA, i, uint64(len(m.Authentication[iNdEx])))
|
||||
i--
|
||||
dAtA[i] = 0x1a
|
||||
}
|
||||
}
|
||||
if len(m.Controller) > 0 {
|
||||
i -= len(m.Controller)
|
||||
copy(dAtA[i:], m.Controller)
|
||||
i = encodeVarintQuery(dAtA, i, uint64(len(m.Controller)))
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
if len(m.Id) > 0 {
|
||||
i -= len(m.Id)
|
||||
copy(dAtA[i:], m.Id)
|
||||
i = encodeVarintQuery(dAtA, i, uint64(len(m.Id)))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func encodeVarintQuery(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovQuery(v)
|
||||
base := offset
|
||||
@@ -1328,53 +1104,6 @@ func (m *QueryVerifyResponse) Size() (n int) {
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *Document) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
l = len(m.Id)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovQuery(uint64(l))
|
||||
}
|
||||
l = len(m.Controller)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovQuery(uint64(l))
|
||||
}
|
||||
if len(m.Authentication) > 0 {
|
||||
for _, s := range m.Authentication {
|
||||
l = len(s)
|
||||
n += 1 + l + sovQuery(uint64(l))
|
||||
}
|
||||
}
|
||||
if len(m.AssertionMethod) > 0 {
|
||||
for _, s := range m.AssertionMethod {
|
||||
l = len(s)
|
||||
n += 1 + l + sovQuery(uint64(l))
|
||||
}
|
||||
}
|
||||
if len(m.CapabilityDelegation) > 0 {
|
||||
for _, s := range m.CapabilityDelegation {
|
||||
l = len(s)
|
||||
n += 1 + l + sovQuery(uint64(l))
|
||||
}
|
||||
}
|
||||
if len(m.CapabilityInvocation) > 0 {
|
||||
for _, s := range m.CapabilityInvocation {
|
||||
l = len(s)
|
||||
n += 1 + l + sovQuery(uint64(l))
|
||||
}
|
||||
}
|
||||
if len(m.Service) > 0 {
|
||||
for _, s := range m.Service {
|
||||
l = len(s)
|
||||
n += 1 + l + sovQuery(uint64(l))
|
||||
}
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func sovQuery(x uint64) (n int) {
|
||||
return (math_bits.Len64(x|1) + 6) / 7
|
||||
}
|
||||
@@ -2335,280 +2064,6 @@ func (m *QueryVerifyResponse) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *Document) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowQuery
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: Document: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: Document: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowQuery
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthQuery
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthQuery
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Id = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Controller", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowQuery
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthQuery
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthQuery
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Controller = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 3:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Authentication", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowQuery
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthQuery
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthQuery
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Authentication = append(m.Authentication, string(dAtA[iNdEx:postIndex]))
|
||||
iNdEx = postIndex
|
||||
case 4:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field AssertionMethod", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowQuery
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthQuery
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthQuery
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.AssertionMethod = append(m.AssertionMethod, string(dAtA[iNdEx:postIndex]))
|
||||
iNdEx = postIndex
|
||||
case 5:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field CapabilityDelegation", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowQuery
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthQuery
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthQuery
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.CapabilityDelegation = append(m.CapabilityDelegation, string(dAtA[iNdEx:postIndex]))
|
||||
iNdEx = postIndex
|
||||
case 6:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field CapabilityInvocation", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowQuery
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthQuery
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthQuery
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.CapabilityInvocation = append(m.CapabilityInvocation, string(dAtA[iNdEx:postIndex]))
|
||||
iNdEx = postIndex
|
||||
case 7:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Service", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowQuery
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthQuery
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthQuery
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Service = append(m.Service, string(dAtA[iNdEx:postIndex]))
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipQuery(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthQuery
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func skipQuery(dAtA []byte) (n int, err error) {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
|
||||
@@ -141,78 +141,6 @@ func local_request_Query_Resolve_0(ctx context.Context, marshaler runtime.Marsha
|
||||
|
||||
}
|
||||
|
||||
var (
|
||||
filter_Query_Sign_0 = &utilities.DoubleArray{Encoding: map[string]int{"did": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}}
|
||||
)
|
||||
|
||||
func request_Query_Sign_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QuerySignRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["did"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "did")
|
||||
}
|
||||
|
||||
protoReq.Did, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "did", err)
|
||||
}
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Sign_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.Sign(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_Sign_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QuerySignRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["did"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "did")
|
||||
}
|
||||
|
||||
protoReq.Did, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "did", err)
|
||||
}
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Sign_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := server.Sign(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
var (
|
||||
filter_Query_Verify_0 = &utilities.DoubleArray{Encoding: map[string]int{"did": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}}
|
||||
)
|
||||
@@ -337,29 +265,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("POST", pattern_Query_Sign_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Query_Sign_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_Sign_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("POST", pattern_Query_Verify_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
@@ -464,26 +369,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("POST", pattern_Query_Sign_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Query_Sign_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_Sign_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("POST", pattern_Query_Verify_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
@@ -512,8 +397,6 @@ var (
|
||||
|
||||
pattern_Query_Resolve_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 0}, []string{"did", "v1"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Query_Sign_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 0, 2, 2}, []string{"did", "v1", "sign"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Query_Verify_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 0, 2, 2}, []string{"did", "v1", "verify"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
)
|
||||
|
||||
@@ -522,7 +405,5 @@ var (
|
||||
|
||||
forward_Query_Resolve_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Query_Sign_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Query_Verify_0 = runtime.ForwardResponseMessage
|
||||
)
|
||||
|
||||
+530
-911
File diff suppressed because it is too large
Load Diff
+50
-49
@@ -783,55 +783,56 @@ func init() {
|
||||
func init() { proto.RegisterFile("did/v1/tx.proto", fileDescriptor_d73284df019ff211) }
|
||||
|
||||
var fileDescriptor_d73284df019ff211 = []byte{
|
||||
// 767 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0xcd, 0x4e, 0xdb, 0x4c,
|
||||
0x14, 0xcd, 0x10, 0x08, 0xe4, 0x92, 0x10, 0xbe, 0x51, 0x3e, 0xc5, 0x58, 0x90, 0x44, 0x46, 0xa8,
|
||||
0x08, 0x95, 0x44, 0x50, 0xa9, 0x42, 0xb4, 0x6a, 0x05, 0x2a, 0x15, 0x88, 0x46, 0x6a, 0x5d, 0xba,
|
||||
0x61, 0x93, 0x1a, 0x7b, 0xe4, 0xb8, 0x24, 0x9e, 0xc8, 0x33, 0x41, 0xc9, 0xae, 0xea, 0x13, 0xf4,
|
||||
0x05, 0xfa, 0x04, 0xdd, 0xb0, 0xe8, 0xaa, 0xea, 0x03, 0xb0, 0x44, 0x5d, 0x75, 0x55, 0x55, 0x20,
|
||||
0x95, 0x27, 0xe8, 0xb2, 0x52, 0x35, 0x76, 0xe2, 0xd8, 0xf9, 0x29, 0x08, 0x50, 0x37, 0x91, 0xef,
|
||||
0x3d, 0xf7, 0x9e, 0x39, 0xf7, 0x78, 0x66, 0x62, 0x48, 0x19, 0x96, 0x51, 0x3c, 0x5a, 0x29, 0xf2,
|
||||
0x66, 0xa1, 0xee, 0x50, 0x4e, 0x71, 0xcc, 0xb0, 0x8c, 0xc2, 0xd1, 0x8a, 0x9c, 0xd1, 0x29, 0xab,
|
||||
0x51, 0x56, 0xac, 0x31, 0x53, 0xe0, 0x35, 0x66, 0x7a, 0x05, 0xf2, 0x8c, 0x07, 0x94, 0xdd, 0xa8,
|
||||
0xe8, 0x05, 0x6d, 0x28, 0xdd, 0x26, 0x33, 0x89, 0x4d, 0x98, 0xe5, 0x67, 0x4d, 0x6a, 0x52, 0xaf,
|
||||
0x5a, 0x3c, 0x79, 0x59, 0xe5, 0x27, 0x82, 0xff, 0x4b, 0xcc, 0x7c, 0x66, 0xd9, 0x87, 0x1b, 0x0d,
|
||||
0x5e, 0x21, 0x36, 0xb7, 0x74, 0x8d, 0x5b, 0xd4, 0xc6, 0x6b, 0x00, 0x3a, 0xb5, 0xb9, 0x43, 0xab,
|
||||
0x55, 0xe2, 0x48, 0x28, 0x8f, 0x16, 0xe3, 0x9b, 0xd2, 0xd7, 0x4f, 0xcb, 0xe9, 0xf6, 0x5a, 0x1b,
|
||||
0x86, 0xe1, 0x10, 0xc6, 0x5e, 0x72, 0xc7, 0xb2, 0x4d, 0x35, 0x50, 0x8b, 0x25, 0x18, 0x67, 0x8d,
|
||||
0x83, 0x37, 0x44, 0xe7, 0xd2, 0x88, 0x68, 0x53, 0x3b, 0x21, 0x9e, 0x85, 0xb8, 0xc6, 0x18, 0x71,
|
||||
0xc4, 0x02, 0x52, 0xd4, 0xc5, 0xba, 0x09, 0x3c, 0x0f, 0x49, 0xdd, 0x21, 0x86, 0xd0, 0xa0, 0x55,
|
||||
0xcb, 0x96, 0x21, 0x8d, 0xe6, 0xd1, 0x62, 0x42, 0x4d, 0x74, 0x93, 0x3b, 0x06, 0x5e, 0x80, 0xa9,
|
||||
0x9a, 0xa6, 0x6b, 0x0e, 0xa5, 0x76, 0x99, 0xd3, 0x43, 0x62, 0x4b, 0x63, 0x2e, 0x4f, 0xb2, 0x93,
|
||||
0xdd, 0x13, 0xc9, 0xf5, 0xd4, 0xbb, 0x8b, 0xe3, 0xa5, 0x80, 0x28, 0x65, 0x17, 0xe6, 0x06, 0xce,
|
||||
0xa9, 0x12, 0x56, 0xa7, 0x36, 0x23, 0x9e, 0x6a, 0x5d, 0x27, 0x8c, 0xb9, 0xc3, 0x4e, 0xa8, 0x9d,
|
||||
0x10, 0x4f, 0x43, 0xd4, 0xb0, 0x8c, 0xf6, 0x2c, 0xe2, 0x51, 0xf9, 0x82, 0x60, 0xba, 0xc3, 0xe6,
|
||||
0xcb, 0xff, 0xf7, 0x86, 0xf5, 0x7b, 0x31, 0x7a, 0x25, 0x2f, 0x9e, 0x82, 0xd4, 0xab, 0xfe, 0x5a,
|
||||
0x36, 0xfc, 0x46, 0x90, 0x28, 0x31, 0x73, 0xab, 0x49, 0xf4, 0x06, 0x27, 0x7b, 0xcd, 0x1b, 0x58,
|
||||
0xf0, 0x08, 0x26, 0x6a, 0x84, 0x31, 0xcd, 0x24, 0x4c, 0x1a, 0xc9, 0x47, 0x17, 0x27, 0x57, 0x95,
|
||||
0x82, 0x77, 0x04, 0x0a, 0xc1, 0x15, 0x0a, 0xa5, 0x76, 0xd1, 0x96, 0xcd, 0x9d, 0x96, 0xea, 0xf7,
|
||||
0x0c, 0xb0, 0x22, 0x3a, 0xc0, 0x0a, 0xf9, 0x01, 0x24, 0x43, 0x0c, 0x62, 0xa8, 0x43, 0xd2, 0xf2,
|
||||
0xa4, 0xaa, 0xe2, 0x11, 0xa7, 0x61, 0xec, 0x48, 0xab, 0x36, 0x88, 0x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, 0x1f, 0x43, 0xbc, 0x7b, 0x1b, 0xa4,
|
||||
0x07, 0x9d, 0x60, 0x79, 0x76, 0x50, 0xd6, 0xf7, 0x6b, 0x17, 0x92, 0xe1, 0x5b, 0x55, 0x0a, 0x94,
|
||||
0x87, 0x10, 0x39, 0x3f, 0x0c, 0xf1, 0xc9, 0xf6, 0x01, 0x0f, 0xf8, 0x63, 0x9b, 0xeb, 0xed, 0x0b,
|
||||
0xc1, 0xf2, 0xc2, 0x5f, 0x61, 0x9f, 0xfb, 0x05, 0xa4, 0x7a, 0x0f, 0xab, 0x1c, 0xe8, 0xec, 0xc1,
|
||||
0x64, 0x65, 0x38, 0xe6, 0x53, 0xbe, 0x86, 0xf4, 0xc0, 0x73, 0x90, 0xeb, 0xef, 0x0d, 0x4b, 0xbe,
|
||||
0x73, 0x49, 0x81, 0xbf, 0xc2, 0x36, 0x24, 0x42, 0xbb, 0x2b, 0x13, 0x6c, 0x0c, 0x00, 0x72, 0x6e,
|
||||
0x08, 0xd0, 0x61, 0x92, 0xc7, 0xde, 0x5e, 0x1c, 0x2f, 0xa1, 0xcd, 0x87, 0x27, 0x67, 0x59, 0x74,
|
||||
0x7a, 0x96, 0x45, 0x3f, 0xce, 0xb2, 0xe8, 0xfd, 0x79, 0x36, 0x72, 0x7a, 0x9e, 0x8d, 0x7c, 0x3b,
|
||||
0xcf, 0x46, 0xf6, 0x15, 0xd3, 0xe2, 0x95, 0xc6, 0x41, 0x41, 0xa7, 0xb5, 0x22, 0xb5, 0x19, 0xb5,
|
||||
0x9d, 0xa2, 0xfb, 0xd3, 0x2c, 0x8a, 0xaf, 0x13, 0xde, 0xaa, 0x13, 0x76, 0x10, 0x73, 0xbf, 0x41,
|
||||
0xee, 0xfd, 0x09, 0x00, 0x00, 0xff, 0xff, 0x93, 0x06, 0x64, 0x08, 0xfe, 0x08, 0x00, 0x00,
|
||||
// 775 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0xcd, 0x4e, 0xdb, 0x4a,
|
||||
0x14, 0x8e, 0x09, 0x04, 0x72, 0x48, 0x08, 0x77, 0x6e, 0xae, 0x62, 0x2c, 0x48, 0x22, 0x23, 0x74,
|
||||
0x11, 0x2a, 0x89, 0xa0, 0x52, 0x85, 0x68, 0xd5, 0x0a, 0x54, 0x2a, 0x10, 0x8d, 0xd4, 0xba, 0x74,
|
||||
0xc3, 0x26, 0x35, 0xf6, 0xc8, 0x71, 0x49, 0x3c, 0x91, 0x67, 0x82, 0x92, 0x5d, 0xd5, 0x27, 0xe8,
|
||||
0x0b, 0xf4, 0x09, 0xba, 0x61, 0xd1, 0x55, 0xd5, 0x07, 0x60, 0x89, 0xba, 0xea, 0xaa, 0xaa, 0x40,
|
||||
0x2a, 0x4f, 0xd0, 0x65, 0xa5, 0x6a, 0xfc, 0x17, 0x3b, 0x3f, 0x05, 0x01, 0xea, 0x26, 0xf2, 0x39,
|
||||
0xdf, 0x39, 0xdf, 0x7c, 0xe7, 0xf3, 0xcc, 0xc4, 0x90, 0xd1, 0x4d, 0xbd, 0x7c, 0xb4, 0x52, 0x66,
|
||||
0xed, 0x52, 0xd3, 0x26, 0x8c, 0xa0, 0x84, 0x6e, 0xea, 0xa5, 0xa3, 0x15, 0x29, 0xa7, 0x11, 0xda,
|
||||
0x20, 0xb4, 0xdc, 0xa0, 0x06, 0xc7, 0x1b, 0xd4, 0x70, 0x0b, 0xa4, 0x19, 0x17, 0xa8, 0x3a, 0x51,
|
||||
0xd9, 0x0d, 0x3c, 0x28, 0xeb, 0x91, 0x19, 0xd8, 0xc2, 0xd4, 0xf4, 0xb3, 0xff, 0x7a, 0xd9, 0xa6,
|
||||
0x6a, 0xab, 0x8d, 0xa0, 0xd4, 0x20, 0x06, 0x71, 0x29, 0xf8, 0x93, 0x9b, 0x95, 0x7f, 0x08, 0xf0,
|
||||
0x5f, 0x85, 0x1a, 0x4f, 0x4d, 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a, 0x43, 0xb4, 0x5f, 0xcb, 0x8b, 0xf7, 0x02, 0x64, 0x38, 0x5f, 0x53, 0x57, 0x19, 0x7e, 0xe6,
|
||||
0xdc, 0xdd, 0xe8, 0x1e, 0x24, 0xb9, 0x5e, 0x62, 0x9b, 0xac, 0x73, 0xa9, 0x05, 0xdd, 0x52, 0x74,
|
||||
0x07, 0x12, 0xee, 0xed, 0xef, 0x2c, 0x30, 0xb9, 0x3a, 0xe5, 0x9f, 0x26, 0x97, 0x77, 0x73, 0xf4,
|
||||
0xe4, 0x5b, 0x21, 0xa6, 0x78, 0x35, 0x7c, 0xcf, 0x87, 0xe7, 0x76, 0x83, 0xf5, 0x29, 0x3e, 0x6f,
|
||||
0x97, 0x53, 0x9e, 0x71, 0x5f, 0x55, 0x48, 0x9e, 0x3f, 0xe6, 0xea, 0xcf, 0x38, 0xc4, 0x2b, 0xd4,
|
||||
0x40, 0x8f, 0x20, 0xd9, 0xbd, 0x0d, 0xb2, 0x83, 0x4e, 0xb0, 0x34, 0x3b, 0x28, 0x1b, 0xf8, 0xb5,
|
||||
0x0b, 0xe9, 0xe8, 0xad, 0x2a, 0x86, 0xca, 0x23, 0x88, 0x54, 0x1c, 0x86, 0x04, 0x64, 0xfb, 0x80,
|
||||
0x06, 0xfc, 0xb1, 0xcd, 0xf5, 0xf6, 0x45, 0x60, 0x69, 0xe1, 0x8f, 0x70, 0xc0, 0xfd, 0x1c, 0x32,
|
||||
0xbd, 0x87, 0x55, 0x0a, 0x75, 0xf6, 0x60, 0x92, 0x3c, 0x1c, 0x0b, 0x28, 0x5f, 0x41, 0x76, 0xe0,
|
||||
0x39, 0x28, 0xf4, 0xf7, 0x46, 0x25, 0xff, 0x7f, 0x49, 0x41, 0xb0, 0xc2, 0x36, 0xa4, 0x22, 0xbb,
|
||||
0x2b, 0x17, 0x6e, 0x0c, 0x01, 0x52, 0x61, 0x08, 0xe0, 0x33, 0x49, 0x63, 0x6f, 0x2e, 0x8e, 0x97,
|
||||
0x84, 0xcd, 0x07, 0x27, 0x67, 0x79, 0xe1, 0xf4, 0x2c, 0x2f, 0x7c, 0x3f, 0xcb, 0x0b, 0xef, 0xce,
|
||||
0xf3, 0xb1, 0xd3, 0xf3, 0x7c, 0xec, 0xeb, 0x79, 0x3e, 0xb6, 0x2f, 0x1b, 0x26, 0xab, 0xb5, 0x0e,
|
||||
0x4a, 0x1a, 0x69, 0x94, 0x89, 0x45, 0x89, 0x65, 0x97, 0x9d, 0x9f, 0x76, 0x99, 0x7f, 0x9c, 0xb0,
|
||||
0x4e, 0x13, 0xd3, 0x83, 0x84, 0xf3, 0x0d, 0x72, 0xf7, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x35,
|
||||
0x86, 0x16, 0x4d, 0x13, 0x09, 0x00, 0x00,
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
|
||||
+38
-283
@@ -23,38 +23,13 @@ var _ = math.Inf
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
type URI_Protocol int32
|
||||
|
||||
const (
|
||||
URI_HTTPS URI_Protocol = 0
|
||||
URI_IPFS URI_Protocol = 1
|
||||
)
|
||||
|
||||
var URI_Protocol_name = map[int32]string{
|
||||
0: "HTTPS",
|
||||
1: "IPFS",
|
||||
}
|
||||
|
||||
var URI_Protocol_value = map[string]int32{
|
||||
"HTTPS": 0,
|
||||
"IPFS": 1,
|
||||
}
|
||||
|
||||
func (x URI_Protocol) String() string {
|
||||
return proto.EnumName(URI_Protocol_name, int32(x))
|
||||
}
|
||||
|
||||
func (URI_Protocol) EnumDescriptor() ([]byte, []int) {
|
||||
return fileDescriptor_ab6e3654a2974847, []int{2, 0}
|
||||
}
|
||||
|
||||
type Metadata struct {
|
||||
Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
Origin string `protobuf:"bytes,2,opt,name=origin,proto3" json:"origin,omitempty"`
|
||||
Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"`
|
||||
Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty"`
|
||||
Category string `protobuf:"bytes,5,opt,name=category,proto3" json:"category,omitempty"`
|
||||
Icon *URI `protobuf:"bytes,6,opt,name=icon,proto3" json:"icon,omitempty"`
|
||||
Icon string `protobuf:"bytes,6,opt,name=icon,proto3" json:"icon,omitempty"`
|
||||
Tags []string `protobuf:"bytes,7,rep,name=tags,proto3" json:"tags,omitempty"`
|
||||
}
|
||||
|
||||
@@ -126,11 +101,11 @@ func (m *Metadata) GetCategory() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Metadata) GetIcon() *URI {
|
||||
func (m *Metadata) GetIcon() string {
|
||||
if m != nil {
|
||||
return m.Icon
|
||||
}
|
||||
return nil
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Metadata) GetTags() []string {
|
||||
@@ -213,96 +188,37 @@ func (m *Profile) GetController() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
type URI struct {
|
||||
Protocol URI_Protocol `protobuf:"varint,1,opt,name=protocol,proto3,enum=service.v1.URI_Protocol" json:"protocol,omitempty"`
|
||||
Uri string `protobuf:"bytes,2,opt,name=uri,proto3" json:"uri,omitempty"`
|
||||
}
|
||||
|
||||
func (m *URI) Reset() { *m = URI{} }
|
||||
func (m *URI) String() string { return proto.CompactTextString(m) }
|
||||
func (*URI) ProtoMessage() {}
|
||||
func (*URI) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_ab6e3654a2974847, []int{2}
|
||||
}
|
||||
func (m *URI) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *URI) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_URI.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *URI) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_URI.Merge(m, src)
|
||||
}
|
||||
func (m *URI) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *URI) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_URI.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_URI proto.InternalMessageInfo
|
||||
|
||||
func (m *URI) GetProtocol() URI_Protocol {
|
||||
if m != nil {
|
||||
return m.Protocol
|
||||
}
|
||||
return URI_HTTPS
|
||||
}
|
||||
|
||||
func (m *URI) GetUri() string {
|
||||
if m != nil {
|
||||
return m.Uri
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterEnum("service.v1.URI_Protocol", URI_Protocol_name, URI_Protocol_value)
|
||||
proto.RegisterType((*Metadata)(nil), "service.v1.Metadata")
|
||||
proto.RegisterType((*Profile)(nil), "service.v1.Profile")
|
||||
proto.RegisterType((*URI)(nil), "service.v1.URI")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("service/v1/state.proto", fileDescriptor_ab6e3654a2974847) }
|
||||
|
||||
var fileDescriptor_ab6e3654a2974847 = []byte{
|
||||
// 422 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x52, 0xc1, 0x8e, 0xd3, 0x30,
|
||||
0x14, 0xac, 0x9b, 0x6c, 0x9b, 0xbe, 0x45, 0x25, 0xb2, 0xd0, 0x62, 0xed, 0xc1, 0x44, 0x05, 0xa1,
|
||||
0x1e, 0x50, 0xa2, 0x5d, 0x38, 0xed, 0x09, 0x71, 0x40, 0xf4, 0x80, 0x54, 0x65, 0x77, 0x2f, 0xdc,
|
||||
0x52, 0xd7, 0x14, 0xa3, 0xc4, 0xaf,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d, 0x5a, 0xda, 0xc5, 0xc0, 0xdb, 0x3f, 0xfd, 0x1d, 0x00, 0x00, 0xff, 0xff, 0xf1, 0xad,
|
||||
0x51, 0x19, 0x6b, 0x02, 0x00, 0x00,
|
||||
// 348 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x91, 0xc1, 0x6a, 0xe3, 0x30,
|
||||
0x10, 0x86, 0x23, 0xdb, 0xeb, 0x24, 0xb3, 0x4b, 0x08, 0x62, 0xc9, 0x8a, 0x1c, 0x84, 0x09, 0xcb,
|
||||
0x92, 0xc3, 0x12, 0x13, 0xf6, 0x96, 0xd3, 0xd2, 0x7b, 0xa1, 0xe4, 0xd8, 0x9b, 0x23, 0xab, 0xae,
|
||||
0x4a, 0xec, 0x09, 0x92, 0x12, 0x9a, 0x97, 0x28, 0xed, 0x0b, 0xf4, 0x79, 0x7a, 0xe8, 0x21, 0xd0,
|
||||
0x4b, 0x8f, 0x25, 0x79, 0x83, 0x3e, 0x41, 0x91, 0xe2, 0x14, 0xf7, 0x22, 0x66, 0xfe, 0x19, 0x7e,
|
||||
0xfd, 0x1f, 0x03, 0x03, 0x23, 0xf5, 0x46, 0x09, 0x99, 0x6e, 0xa6, 0xa9, 0xb1, 0x99, 0x95, 0x93,
|
||||
0x95, 0x46, 0x8b, 0x14, 0x6a, 0x7d, 0xb2, 0x99, 0x0e, 0x7f, 0x09, 0x34, 0x25, 0x9a, 0x14, 0x75,
|
||||
0xe9, 0xd6, 0x50, 0x97, 0xc7, 0xa5, 0xd1, 0x33, 0x81, 0xce, 0xb9, 0xb4, 0x59, 0x9e, 0xd9, 0x8c,
|
||||
0xf6, 0x20, 0x50, 0x39, 0x23, 0x09, 0x19, 0x47, 0xf3, 0x40, 0xe5, 0x74, 0x00, 0x31, 0x6a, 0x55,
|
||||
0xa8, 0x8a, 0x05, 0x09, 0x19, 0x77, 0xe7, 0x75, 0x47, 0x29, 0x44, 0x55, 0x56, 0x4a, 0x16, 0x7a,
|
||||
0xd5, 0xd7, 0x34, 0x81, 0xef, 0xb9, 0x34, 0x42, 0xab, 0x95, 0x55, 0x58, 0xb1, 0xc8, 0x8f, 0x9a,
|
||||
0x12, 0x1d, 0x42, 0x47, 0x64, 0x56, 0x16, 0xa8, 0xb7, 0xec, 0x9b, 0x1f, 0x7f, 0xf6, 0xce, 0x51,
|
||||
0x09, 0xac, 0x58, 0x7c, 0x74, 0x74, 0xb5, 0xd3, 0x6c, 0x56, 0x18, 0xd6, 0x4e, 0x42, 0xa7, 0xb9,
|
||||
0x7a, 0xc6, 0xdf, 0x1f, 0x5f, 0xee, 0x42, 0x06, 0xb1, 0x4b, 0xda, 0x27, 0xf4, 0xc7, 0x29, 0x61,
|
||||
0x9f, 0x30, 0xc2, 0xc8, 0xe8, 0x81, 0x40, 0xfb, 0x42, 0xe3, 0x95, 0x5a, 0xca, 0x06, 0x4d, 0xd7,
|
||||
0xd3, 0x30, 0x68, 0x9b, 0xf5, 0xe2, 0x46, 0x0a, 0x5b, 0xe3, 0x9c, 0xda, 0x06, 0x67, 0xf8, 0x85,
|
||||
0x93, 0x03, 0x08, 0xac, 0xac, 0xc6, 0xe5, 0x52, 0xea, 0x1a, 0xa9, 0xa1, 0xcc, 0x7e, 0xfb, 0x34,
|
||||
0x1c, 0x22, 0xf7, 0x13, 0xfd, 0x09, 0xbd, 0xda, 0xf0, 0x6f, 0x23, 0x53, 0x70, 0xf6, 0xff, 0x69,
|
||||
0xcf, 0xc9, 0x6e, 0xcf, 0xc9, 0xdb, 0x9e, 0x93, 0xfb, 0x03, 0x6f, 0xed, 0x0e, 0xbc, 0xf5, 0x7a,
|
||||
0xe0, 0xad, 0xcb, 0x3f, 0x85, 0xb2, 0xd7, 0xeb, 0xc5, 0x44, 0x60, 0x99, 0x62, 0x65, 0xb0, 0xd2,
|
||||
0xa9, 0x7f, 0x6e, 0xd3, 0xd3, 0x49, 0xed, 0x76, 0x25, 0xcd, 0x22, 0xf6, 0xb7, 0xfa, 0xf7, 0x11,
|
||||
0x00, 0x00, 0xff, 0xff, 0x81, 0xa0, 0xdf, 0xce, 0xea, 0x01, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *Metadata) Marshal() (dAtA []byte, err error) {
|
||||
@@ -334,15 +250,10 @@ func (m *Metadata) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
dAtA[i] = 0x3a
|
||||
}
|
||||
}
|
||||
if m.Icon != nil {
|
||||
{
|
||||
size, err := m.Icon.MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintState(dAtA, i, uint64(size))
|
||||
}
|
||||
if len(m.Icon) > 0 {
|
||||
i -= len(m.Icon)
|
||||
copy(dAtA[i:], m.Icon)
|
||||
i = encodeVarintState(dAtA, i, uint64(len(m.Icon)))
|
||||
i--
|
||||
dAtA[i] = 0x32
|
||||
}
|
||||
@@ -433,41 +344,6 @@ func (m *Profile) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *URI) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *URI) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *URI) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Uri) > 0 {
|
||||
i -= len(m.Uri)
|
||||
copy(dAtA[i:], m.Uri)
|
||||
i = encodeVarintState(dAtA, i, uint64(len(m.Uri)))
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
if m.Protocol != 0 {
|
||||
i = encodeVarintState(dAtA, i, uint64(m.Protocol))
|
||||
i--
|
||||
dAtA[i] = 0x8
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func encodeVarintState(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovState(v)
|
||||
base := offset
|
||||
@@ -504,8 +380,8 @@ func (m *Metadata) Size() (n int) {
|
||||
if l > 0 {
|
||||
n += 1 + l + sovState(uint64(l))
|
||||
}
|
||||
if m.Icon != nil {
|
||||
l = m.Icon.Size()
|
||||
l = len(m.Icon)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovState(uint64(l))
|
||||
}
|
||||
if len(m.Tags) > 0 {
|
||||
@@ -542,22 +418,6 @@ func (m *Profile) Size() (n int) {
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *URI) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
if m.Protocol != 0 {
|
||||
n += 1 + sovState(uint64(m.Protocol))
|
||||
}
|
||||
l = len(m.Uri)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovState(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func sovState(x uint64) (n int) {
|
||||
return (math_bits.Len64(x|1) + 6) / 7
|
||||
}
|
||||
@@ -744,7 +604,7 @@ func (m *Metadata) Unmarshal(dAtA []byte) error {
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Icon", wireType)
|
||||
}
|
||||
var msglen int
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowState
|
||||
@@ -754,27 +614,23 @@ func (m *Metadata) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthState
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthState
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if m.Icon == nil {
|
||||
m.Icon = &URI{}
|
||||
}
|
||||
if err := m.Icon.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
m.Icon = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 7:
|
||||
if wireType != 2 {
|
||||
@@ -1007,107 +863,6 @@ func (m *Profile) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *URI) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowState
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: URI: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: URI: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 0 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Protocol", wireType)
|
||||
}
|
||||
m.Protocol = 0
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowState
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
m.Protocol |= URI_Protocol(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Uri", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowState
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthState
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthState
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Uri = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipState(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthState
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func skipState(dAtA []byte) (n int, err error) {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
"github.com/ipfs/kubo/client/rpc"
|
||||
|
||||
apiv1 "github.com/onsonr/sonr/api/vault/v1"
|
||||
dwngen "github.com/onsonr/sonr/internal/dwn/gen"
|
||||
dwngen "github.com/onsonr/sonr/pkg/motr/config"
|
||||
didkeeper "github.com/onsonr/sonr/x/did/keeper"
|
||||
"github.com/onsonr/sonr/x/vault/types"
|
||||
)
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/onsonr/crypto/mpc"
|
||||
didtypes "github.com/onsonr/sonr/x/did/types"
|
||||
|
||||
"github.com/onsonr/sonr/x/did/controller"
|
||||
"github.com/onsonr/sonr/x/vault/types"
|
||||
)
|
||||
|
||||
@@ -72,7 +72,7 @@ func (k Querier) Allocate(goCtx context.Context, req *types.QueryAllocateRequest
|
||||
}
|
||||
|
||||
// 3. Create Controller from Keyshares
|
||||
con, err := didtypes.NewController(shares)
|
||||
con, err := controller.New(shares)
|
||||
if err != nil {
|
||||
ctx.Logger().Error(fmt.Sprintf("Error creating controller: %s", err.Error()))
|
||||
return nil, types.ErrControllerCreation.Wrap(err.Error())
|
||||
|
||||
@@ -3,7 +3,7 @@ package types
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/onsonr/sonr/internal/orm"
|
||||
"github.com/onsonr/sonr/pkg/motr/types/orm"
|
||||
)
|
||||
|
||||
// DefaultParams returns default module parameters.
|
||||
|
||||
@@ -3,16 +3,16 @@ package types
|
||||
import (
|
||||
"github.com/ipfs/boxo/files"
|
||||
|
||||
"github.com/onsonr/sonr/internal/dwn"
|
||||
dwngen "github.com/onsonr/sonr/internal/dwn/gen"
|
||||
"github.com/onsonr/sonr/pkg/motr"
|
||||
"github.com/onsonr/sonr/pkg/motr/config"
|
||||
)
|
||||
|
||||
type Vault struct {
|
||||
FS files.Node
|
||||
}
|
||||
|
||||
func NewVault(keyshareJSON string, adddress string, chainID string, schema *dwngen.Schema) (*Vault, error) {
|
||||
dwnCfg := &dwngen.Config{
|
||||
func NewVault(keyshareJSON string, adddress string, chainID string, schema *config.Schema) (*Vault, error) {
|
||||
dwnCfg := &config.Config{
|
||||
MotrKeyshare: keyshareJSON,
|
||||
MotrAddress: adddress,
|
||||
IpfsGatewayUrl: "https://ipfs.sonr.land",
|
||||
@@ -21,7 +21,7 @@ func NewVault(keyshareJSON string, adddress string, chainID string, schema *dwng
|
||||
SonrChainId: chainID,
|
||||
VaultSchema: schema,
|
||||
}
|
||||
fileMap, err := dwn.NewVaultDirectory(dwnCfg)
|
||||
fileMap, err := motr.NewVaultDirectory(dwnCfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user