feat: add vault module

This commit is contained in:
Prad Nukala
2024-09-25 19:49:16 -04:00
parent 94f1a7e581
commit 607af1e76d
354 changed files with 22222 additions and 20921 deletions
+4 -1
View File
@@ -10,9 +10,12 @@ lint:
- DEFAULT
- COMMENTS
- FILE_LOWER_SNAKE_CASE
except:
ignore:
- UNARY_RPC
- COMMENT_FIELD
- SERVICE_SUFFIX
- PACKAGE_VERSION_SUFFIX
- RPC_REQUEST_STANDARD_NAME
- FILE_OPTIONS_REQUIRE_GO_PACKAGE
- FILE_OPTIONS_REQUIRE_GO_PACKAGE
- PACKAGE_VERSION_SUFFIX
+4 -9
View File
@@ -35,17 +35,11 @@ message Params {
// Whitelisted Key Types
map<string, KeyInfo> allowed_public_keys = 2;
// IpfsActive is a flag to enable/disable ipfs
bool ipfs_active = 3;
// Localhost Registration Enabled
bool localhost_registration_enabled = 4;
// ConveyancePreference defines the conveyance preference
string conveyance_preference = 5;
string conveyance_preference = 3;
// AttestationFormats defines the attestation formats
repeated string attestation_formats = 6;
repeated string attestation_formats = 4;
}
// AssetInfo defines the asset info
@@ -85,7 +79,8 @@ message KeyInfo {
string role = 1;
string algorithm = 2; // e.g., "ES256", "EdDSA", "ES256K"
string encoding = 3; // e.g., "hex", "base64", "multibase"
string curve = 4; // e.g., "P256", "P384", "P521", "X25519", "X448", "Ed25519", "Ed448", "secp256k1"
string curve = 4; // e.g., "P256", "P384", "P521", "X25519", "X448",
// "Ed25519", "Ed448", "secp256k1"
string type = 5; // e.g., "Octet", "Elliptic", "RSA", "Symmetric", "HMAC"
}
-23
View File
@@ -17,11 +17,6 @@ service Query {
rpc Resolve(QueryRequest) returns (QueryResolveResponse) {
option (google.api.http).get = "/did/{did}";
}
// Sync queries the DID document by its id. And returns the required PKL information
rpc Sync(SyncRequest) returns (SyncResponse) {
option (google.api.http).post = "/sync";
}
}
// Queryequest is the request type for the Query/Params RPC method.
@@ -32,14 +27,6 @@ message QueryRequest {
string asset = 4;
}
// QueryResolveResponse is the response type for the Query/Resolve RPC method.
message QueryResponse {
bool success = 1;
string query = 2;
Document document = 3;
Params params = 5;
}
// QueryParamsResponse is the response type for the Query/Params RPC method.
message QueryParamsResponse {
// params defines the parameters of the module.
@@ -51,13 +38,3 @@ message QueryResolveResponse {
// document is the DID document
Document document = 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;
}
+20 -24
View File
@@ -33,7 +33,10 @@ message Alias {
message Controller {
option (cosmos.orm.v1.table) = {
id: 2
primary_key: {fields: "id"}
primary_key: {
fields: "number"
auto_increment: true
}
index: {
id: 1
fields: "sonr_address"
@@ -51,49 +54,41 @@ message Controller {
}
index: {
id: 4
fields: "vault_cid"
unique: true
}
index: {
id: 5
fields: "status,vault_cid"
fields: "did"
unique: true
}
};
// The unique identifier of the controller
string id = 1;
uint64 number = 1;
// The unique identifier of the controller
string did = 2;
// The DID of the controller
string sonr_address = 2;
string sonr_address = 3;
// The DID of the controller
string eth_address = 3;
string eth_address = 4;
// The DID of the controller
string btc_address = 4;
// Aliases of the controller
repeated string aliases = 5;
string btc_address = 5;
// PubKey is the verification method
PubKey public_key = 6;
bytes public_key = 6;
// The vault address or identifier
string vault_cid = 7;
// The Authentications of the controller
repeated string authentication = 8;
// Val Keyshare
string ks_val = 7;
// The Status of the claims for the controller
string status = 9;
bool claimed = 8;
}
// Verification reprsents a method of verifying membership in a DID
message Verification {
option (cosmos.orm.v1.table) = {
id: 4
primary_key: {fields: "id"}
primary_key: {fields: "did"}
index: {
id: 1
fields: "issuer,subject"
@@ -112,7 +107,7 @@ message Verification {
};
// The unique identifier of the verification
string id = 1;
string did = 1;
// The controller of the verification
string controller = 2;
@@ -129,6 +124,7 @@ message Verification {
// The public key of the verification
PubKey public_key = 6;
// The Verification Type (Authentication, Assertion, CapabilityDelegation, CapabilityInvocation)
// The Verification Type (Authentication, Assertion, CapabilityDelegation,
// CapabilityInvocation)
string verification_type = 7;
}
+41 -43
View File
@@ -12,52 +12,25 @@ option go_package = "github.com/onsonr/sonr/x/did/types";
// Msg defines the Msg service.
service Msg {
option (cosmos.msg.v1.service) = true;
// UpdateParams defines a governance operation for updating the parameters.
//
// Since: cosmos-sdk 0.47
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
// AuthorizeService asserts the given controller is the owner of the given address.
// AuthorizeService asserts the given controller is the owner of the given
// address.
rpc AuthorizeService(MsgAuthorizeService) returns (MsgAuthorizeServiceResponse);
// 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);
// ExecuteTx executes a transaction on the Sonr Blockchain. It leverages
// Macaroon for verification.
rpc ExecuteTx(MsgExecuteTx) returns (MsgExecuteTxResponse);
// RegisterController initializes a controller with the given authentication set, address, cid, publicKey, and user-defined alias.
// RegisterController initializes a controller with the given authentication
// set, address, cid, publicKey, and user-defined alias.
rpc RegisterController(MsgRegisterController) returns (MsgRegisterControllerResponse);
// RegisterService initializes a Service with a given permission scope and URI. The domain must have a valid TXT record containing the public key.
// RegisterService initializes a Service with a given permission scope and
// URI. The domain must have a valid TXT record containing the public key.
rpc RegisterService(MsgRegisterService) returns (MsgRegisterServiceResponse);
}
// 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;
// UpdateParams defines a governance operation for updating the parameters.
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
}
// MsgRegisterController is the message type for the InitializeController RPC.
@@ -73,13 +46,16 @@ message MsgRegisterController {
// Keyshares is the list of keyshares to initialize the controller with.
repeated bytes keyshares = 3;
// Verifications is the list of verifications to initialize the controller with.
// Verifications is the list of verifications to initialize the controller
// with.
repeated bytes verifications = 4;
}
// MsgRegisterControllerResponse is the response type for the InitializeController RPC.
// MsgRegisterControllerResponse is the response type for the
// InitializeController RPC.
message MsgRegisterControllerResponse {
// Success returns true if the specified cid is valid and not already encrypted.
// Success returns true if the specified cid is valid and not already
// encrypted.
bool success = 1;
// Controller is the address of the initialized controller.
@@ -89,6 +65,26 @@ message MsgRegisterControllerResponse {
map<string, string> accounts = 3;
}
// MsgExecuteTx is the message type for the ExecuteTx RPC.
message MsgExecuteTx {
option (cosmos.msg.v1.signer) = "controller";
// Controller is the address of the controller to authenticate.
string controller = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// Messages is the list of messages to execute.
map<string, bytes> messages = 2;
// MacaroonToken is the macaroon token to authenticate the operation.
string macaroon_token = 3;
}
// MsgExecuteTxResponse is the response type for the ExecuteTx RPC.
message MsgExecuteTxResponse {
bool success = 1;
string tx_hash = 2;
}
// MsgAuthorizeService is the message type for the AuthorizeService RPC.
message MsgAuthorizeService {
option (cosmos.msg.v1.signer) = "controller";
@@ -106,7 +102,8 @@ message MsgAuthorizeService {
string token = 4;
}
// MsgAuthorizeServiceResponse is the response type for the AuthorizeService RPC.
// MsgAuthorizeServiceResponse is the response type for the AuthorizeService
// RPC.
message MsgAuthorizeServiceResponse {
bool success = 1;
string token = 2;
@@ -119,7 +116,8 @@ message MsgRegisterService {
// authority is the address of the governance account.
string controller = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// origin is the origin of the request in wildcard form. Requires valid TXT record in DNS.
// origin is the origin of the request in wildcard form. Requires valid TXT
// record in DNS.
Service service = 2;
}
+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;
}