feature/did accounts (#23)

* feat: add support for DID number as primary key for Controllers

* refactor: rename pkg/proxy to app/proxy

* feat: add vault module keeper tests

* feat(vault): add DID keeper to vault module

* refactor: move vault client code to its own package

* refactor(vault): extract schema definition

* refactor: use vaulttypes for MsgAllocateVault

* refactor: update vault assembly logic to use new methods

* feat: add dwn-proxy command

* refactor: remove unused context.go file

* refactor: remove unused web-related code

* feat: add DWN proxy server

* feat: add BuildTx RPC to vault module

* fix: Implement BuildTx endpoint

* feat: add devbox integration to project
This commit is contained in:
Prad Nukala
2024-09-25 19:45:28 -04:00
committed by GitHub
parent 97b3f9836a
commit 60c48d2409
216 changed files with 18162 additions and 9232 deletions
+13
View File
@@ -0,0 +1,13 @@
syntax = "proto3";
package vault.module.v1;
import "cosmos/app/v1alpha1/module.proto";
// Module is the app config object of the module.
// Learn more: https://docs.cosmos.network/main/building-modules/depinject
message Module {
option (cosmos.app.v1alpha1.module) = {
go_import : "github.com/onsonr/sonr"
};
}
+37
View File
@@ -0,0 +1,37 @@
syntax = "proto3";
package vault.v1;
import "amino/amino.proto";
import "gogoproto/gogo.proto";
option go_package = "github.com/onsonr/sonr/x/vault/types";
// GenesisState defines the module genesis state
message GenesisState {
// Params defines all the parameters of the module.
Params params = 1 [(gogoproto.nullable) = false];
}
// Params defines the set of module parameters.
message Params {
option (amino.name) = "vault/params";
option (gogoproto.equal) = true;
option (gogoproto.goproto_stringer) = false;
bool ipfs_active = 1;
bool local_registration_enabled = 2;
Schema schema = 3;
}
message Schema {
int32 version = 1;
string account = 2;
string asset = 3;
string chain = 4;
string credential = 5;
string jwk = 6;
string grant = 7;
string keyshare = 8;
string publicKey = 9;
string profile = 10;
}
+66
View File
@@ -0,0 +1,66 @@
syntax = "proto3";
package vault.v1;
import "google/api/annotations.proto";
import "vault/v1/genesis.proto";
option go_package = "github.com/onsonr/sonr/x/vault/types";
// Query provides defines the gRPC querier service.
service Query {
// Params queries all parameters of the module.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/vault/v1/params";
}
// BuildTx builds an unsigned transaction message for the given PKL.
rpc BuildTx(BuildTxRequest) returns (BuildTxResponse) {
option (google.api.http).post = "/vault/v1/buildtx";
}
// Sync queries the DID document by its id. And returns the required PKL
// information
rpc Sync(SyncRequest) returns (SyncResponse) {
option (google.api.http).post = "/vault/v1/sync";
}
}
// QueryParamsRequest is the request type for the Query/Params RPC method.
message QueryParamsRequest {}
// QueryParamsResponse is the response type for the Query/Params RPC method.
message QueryParamsResponse {
// params defines the parameters of the module.
Params params = 1;
}
// QueryIPFSRequest is the request type for the Query/IPFS RPC method.
message QueryIPFSRequest {}
// QueryIPFSResponse is the response type for the Query/IPFS RPC method.
message QueryIPFSResponse {
// IPFS is the IPFS client status.
bool ipfs = 1;
}
// SyncRequest is the request type for the Sync RPC method.
message SyncRequest {
string did = 1;
}
// SyncResponse is the response type for the Sync RPC method.
message SyncResponse {
bool success = 1;
}
// BuildTxRequest is the request type for the BuildTx RPC method.
message BuildTxRequest {
string did = 1;
string pkl = 2;
}
// BuildTxResponse is the response type for the BuildTx RPC method.
message BuildTxResponse {
bool success = 1;
string tx = 2;
}
+22
View File
@@ -0,0 +1,22 @@
syntax = "proto3";
package vault.v1;
import "cosmos/orm/v1/orm.proto";
option go_package = "github.com/onsonr/sonr/x/vault/types";
// https://github.com/cosmos/cosmos-sdk/blob/main/orm/README.md
message DWN {
option (cosmos.orm.v1.table) = {
id: 1
primary_key: {fields: "account"}
index: {
id: 1
fields: "amount"
}
};
bytes account = 1;
uint64 amount = 2;
}
+74
View File
@@ -0,0 +1,74 @@
syntax = "proto3";
package vault.v1;
import "cosmos/msg/v1/msg.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "vault/v1/genesis.proto";
option go_package = "github.com/onsonr/sonr/x/vault/types";
// Msg defines the Msg service.
service Msg {
option (cosmos.msg.v1.service) = true;
// AllocateVault assembles a sqlite3 database in a local directory and returns
// the CID of the database. this operation is called by services initiating a
// controller registration.
rpc AllocateVault(MsgAllocateVault) returns (MsgAllocateVaultResponse);
// UpdateParams defines a governance operation for updating the parameters.
//
// Since: cosmos-sdk 0.47
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
}
// MsgUpdateParams is the Msg/UpdateParams request type.
//
// Since: cosmos-sdk 0.47
message MsgUpdateParams {
option (cosmos.msg.v1.signer) = "authority";
// authority is the address of the governance account.
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// params defines the parameters to update.
//
// NOTE: All parameters must be supplied.
Params params = 2 [(gogoproto.nullable) = false];
}
// MsgUpdateParamsResponse defines the response structure for executing a
// MsgUpdateParams message.
//
// Since: cosmos-sdk 0.47
message MsgUpdateParamsResponse {}
// MsgAllocateVault is the message type for the AllocateVault RPC.
message MsgAllocateVault {
option (cosmos.msg.v1.signer) = "authority";
// authority is the address of the service account.
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// subject is a unique human-defined identifier to associate with the vault.
string subject = 2;
// origin is the origin of the request in wildcard form.
string origin = 3;
}
// MsgAllocateVaultResponse is the response type for the AllocateVault RPC.
message MsgAllocateVaultResponse {
// CID is the content identifier of the vault.
string cid = 1;
// ExpiryBlock is the block number at which the vault will expire.
int64 expiry_block = 2;
// RegistrationOptions is a json string of the
// PublicKeyCredentialCreationOptions for WebAuthn
string token = 3;
// IsLocalhost is a flag to indicate if the vault is localhost
bool localhost = 4;
}