mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-03 01:41:44 +00:00
feature/did swt ante (#22)
* feat: add support for vault allocation * feat(dwn): Add IPFS client * refactor: move GetDefaultBypassFeeMessages to ibc/module.go * refactor(did): clean up genesis state definition * feat: remove global integrity proof requirement * feat: remove gas consumption for tx size * feat: add registration route * refactor: centralize response handling in the package * feat(types): add account and pubkey types * refactor: simplify dockerfile process-compose.yaml copy
This commit is contained in:
@@ -2,7 +2,6 @@ package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"cosmossdk.io/log"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
@@ -1,106 +0,0 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/ipfs/boxo/files"
|
||||
"github.com/ipfs/boxo/path"
|
||||
"github.com/ipfs/kubo/client/rpc"
|
||||
"github.com/ipfs/kubo/core/coreiface/options"
|
||||
"github.com/onsonr/sonr/internal/vfs"
|
||||
)
|
||||
|
||||
// assembleInitialVault assembles the initial vault
|
||||
func (k Keeper) assembleInitialVault(ctx sdk.Context) (string, int64, error) {
|
||||
cid, err := k.ipfsClient.Unixfs().Add(context.Background(), vfs.AssembleDirectory())
|
||||
if err != nil {
|
||||
return "", 0, err
|
||||
}
|
||||
return cid.String(), k.GetExpirationBlockHeight(ctx, time.Second*15), nil
|
||||
}
|
||||
|
||||
// pinInitialVault pins the initial vault to the local IPFS node
|
||||
func (k Keeper) pinInitialVault(_ sdk.Context, cid string, address string) (bool, error) {
|
||||
// Resolve the path
|
||||
path, err := path.NewPath(cid)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
// 1. Initialize vault.db sqlite database in local IPFS with Mount
|
||||
|
||||
// 2. Insert the InitialWalletAccounts
|
||||
|
||||
// 3. Publish the path to the IPNS
|
||||
_, err = k.ipfsClient.Name().Publish(context.Background(), path, options.Name.Key(address))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
// 4. Insert the accounts into x/auth
|
||||
|
||||
// 5. Insert the controller into state
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// GetFromIPFS gets a file from the local IPFS node
|
||||
func (k Keeper) GetFromIPFS(ctx sdk.Context, cid string) (files.Directory, error) {
|
||||
path, err := path.NewPath(cid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
node, err := k.ipfsClient.Unixfs().Get(ctx, path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dir, ok := node.(files.Directory)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("retrieved node is not a directory")
|
||||
}
|
||||
return dir, nil
|
||||
}
|
||||
|
||||
// HasIPFSConnection returns true if the IPFS client is initialized
|
||||
func (k *Keeper) HasIPFSConnection() bool {
|
||||
if k.ipfsClient == nil {
|
||||
ipfsClient, err := rpc.NewLocalApi()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
k.ipfsClient = ipfsClient
|
||||
}
|
||||
return k.ipfsClient != nil
|
||||
}
|
||||
|
||||
// HasPathInIPFS checks if a file is in the local IPFS node
|
||||
func (k Keeper) HasPathInIPFS(ctx sdk.Context, cid string) (bool, error) {
|
||||
path, err := path.NewPath(cid)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
v, err := k.ipfsClient.Unixfs().Get(ctx, path)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
if v == nil {
|
||||
return false, nil
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// PinToIPFS pins a file to the local IPFS node
|
||||
func (k Keeper) PinToIPFS(ctx sdk.Context, cid string, name string) error {
|
||||
path, err := path.NewPath(cid)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = k.ipfsClient.Pin().Add(ctx, path, options.Pin.Name(name))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"cosmossdk.io/errors"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
@@ -107,3 +106,10 @@ func (ms msgServer) UpdateParams(
|
||||
}
|
||||
return nil, ms.k.Params.Set(ctx, msg.Params)
|
||||
}
|
||||
|
||||
// ExecuteTx implements types.MsgServer.
|
||||
func (ms msgServer) ExecuteTx(ctx context.Context, msg *types.MsgExecuteTx) (*types.MsgExecuteTxResponse, error) {
|
||||
// ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
panic("ExecuteTx is unimplemented")
|
||||
return &types.MsgExecuteTxResponse{}, nil
|
||||
}
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
"github.com/onsonr/sonr/x/did/builder"
|
||||
"github.com/onsonr/sonr/x/did/types"
|
||||
)
|
||||
|
||||
// insertService inserts a service record into the database
|
||||
func (k Keeper) insertService(
|
||||
ctx sdk.Context,
|
||||
svc *types.Service,
|
||||
) (*types.MsgRegisterServiceResponse, error) {
|
||||
record := builder.APIFormatServiceRecord(svc)
|
||||
err := k.OrmDB.ServiceRecordTable().Insert(ctx, record)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &types.MsgRegisterServiceResponse{
|
||||
Success: true,
|
||||
Did: record.Id,
|
||||
}, nil
|
||||
func (k Keeper) insertAliasFromDisplayName() {
|
||||
}
|
||||
|
||||
func (k Keeper) insertAssertionFromIdentity() {
|
||||
}
|
||||
|
||||
func (k Keeper) insertAuthenticationFromCredential() {
|
||||
}
|
||||
|
||||
func (k Keeper) insertControllerFromMotrVault() {
|
||||
}
|
||||
|
||||
func (k Keeper) insertDelegationFromAccount() {
|
||||
}
|
||||
Reference in New Issue
Block a user