mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-04 10:21:40 +00:00
feat: add rudimentary DidController table
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
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) (uint64, types.ControllerI, error) {
|
||||
shares, err := mpc.GenerateKeyshares()
|
||||
if err != nil {
|
||||
return 0, nil, err
|
||||
}
|
||||
controller, err := types.NewController(shares)
|
||||
if err != nil {
|
||||
return 0, nil, err
|
||||
}
|
||||
entry, err := controller.GetTableEntry()
|
||||
if err != nil {
|
||||
return 0, nil, err
|
||||
}
|
||||
num, err := k.OrmDB.ControllerTable().InsertReturningNumber(ctx, entry)
|
||||
if err != nil {
|
||||
return 0, nil, err
|
||||
}
|
||||
return num, controller, nil
|
||||
}
|
||||
Reference in New Issue
Block a user