fix: pin added did documents to local ipfs node

This commit is contained in:
Prad Nukala
2024-09-06 11:10:21 -04:00
parent fac81d90a3
commit 93ebc9eea1
8 changed files with 297 additions and 166 deletions
+12 -1
View File
@@ -10,6 +10,7 @@ import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
stakkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
"github.com/ipfs/kubo/client/rpc"
apiv1 "github.com/onsonr/sonr/api/did/v1"
"github.com/onsonr/sonr/x/did/types"
@@ -29,7 +30,8 @@ type Keeper struct {
AccountKeeper authkeeper.AccountKeeper
StakingKeeper *stakkeeper.Keeper
authority string
authority string
ipfsClient *rpc.HttpApi
}
// NewKeeper creates a new poa Keeper instance
@@ -47,7 +49,11 @@ func NewKeeper(cdc codec.BinaryCodec, storeService storetypes.KVStoreService, ac
if err != nil {
panic(err)
}
// Initialize IPFS client
ipfsClient, _ := rpc.NewLocalApi()
k := Keeper{
ipfsClient: ipfsClient,
cdc: cdc,
logger: logger,
Params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)),
@@ -64,3 +70,8 @@ func NewKeeper(cdc codec.BinaryCodec, storeService storetypes.KVStoreService, ac
k.Schema = schema
return k
}
// HasIPFSConnection returns true if the IPFS client is initialized
func (k *Keeper) HasIPFSConnection() bool {
return k.ipfsClient != nil
}