Feature/update dockerfile (#6)
* chore: remove unused new.Dockerfile
* feat: add DID model definitions
* fix: Fix EncodePublicKey method in KeyInfo struct
* feat: Update `EncodePublicKey` to be the inverse of `DecodePublicKey`
* refactor: update AssetInfo protobuf definition
* fix: update default assets with correct asset types
* fix: Initialize IPFS client and check for mounted directories
* feat: Improve IPFS client initialization and mount checking
* feat: Add local filesystem check for IPFS and IPNS
* fix: Use Unixfs().Get() instead of Cat() for IPFS and IPNS content retrieval
* feat: Update GetCID and GetIPNS functions to read data from IPFS node
* fix: Ensure IPFS client is initialized before pinning CID
* feat: Add AddFile and AddFolder methods
* feat: add IPFS file system abstraction
* feat: Implement IPFS file, location, and filesystem abstractions
* refactor: remove unused functions and types
* refactor: remove unused FileSystem interface
* feat: add initial wasm entrypoint
* feat: add basic vault command operations
* docs: add vault module features
* test: remove test for MsgUpdateParams
* refactor: Replace PrimaryKey with Property struct in zkprop.go
* feat: Update the `CreateWitness` and `CreateAccumulator` and `VerifyWitness` and `UpdateAccumulator` to Use the new `Accumulator` and `Witness` types. Then Clean up the code in the file and refactor the marshalling methods
* <no value>
* feat: add KeyCurve and KeyType to KeyInfo in genesis
* feat: add WASM build step to devbox.json
* feat: Add zkgate.go file
* feat: Uncomment and modify zkgate code to work with Property struct
* feat: Merge zkgate.go and zkprop.go logic
* feat: implement API endpoints for profile management
* refactor: remove unused template file
* feat(orm): remove unused ORM models
* feat: add persistent SQLite database support in WASM
* fix: Update module names in protobuf files
* feat: Add method to initialize SQLite database
* fix: update go-sqlite3 dependency to version 1.14.23
* feat: introduce database layer
* feat: Implement database layer for Vault node
* feature/update-dockerfile
* feat: Add keyshares table
* fix: Reorder the SQL statements in the tables.go file
* feat: Update the `createCredentialsTable` method to match the proper Credential struct
* feat: Update createProfilesTable and add createPropertiesTable
* feat: Add constant SQL queries to queries.go and use prepared statements in db.go
* feat: Add createKeysharesTable to internal/db/db.go
* feat: Update `createPermissionsTable` to match Permissions struct
* feat: Add database enum types
* feat: Add DIDNamespace and PermissionScope enums
* feat: Add DBConfig and DBOption types
* feat: Update the db implementation to use the provided go library
* fix: update db implementation to use go-sqlite3 v0.18.2
* fix: Refactor database connection and statement handling
* feat: Simplify db.go implementation
* feat: Convert constant SQL queries to functions in queries.go and update db.go to use prepared statements
* feat: Add models.go file with database table structs
* fix: Remove unused statement map and prepare statements
diff --git a/internal/db/db.go b/internal/db/db.go
index 201d09b..d4d4d4e 100644
--- a/internal/db/db.go
+++ b/internal/db/db.go
@@ -32,11 +32,6 @@ func Open(config *DBConfig) (*DB, error) {
Conn: conn,
}
- if err := createTables(db); err != nil {
- conn.Close()
- return nil, fmt.Errorf("failed to create tables: %w", err)
- }
-
return db, nil
}
@@ -61,114 +56,3 @@ func createTables(db *DB) error {
return nil
}
-// AddAccount adds a new account to the database
-func (db *DB) AddAccount(name, address string) error {
- return db.Exec(insertAccountQuery(name, address))
-}
-
-// AddAsset adds a new asset to the database
-func (db *DB) AddAsset(name, symbol string, decimals int, chainID int64) error {
- return db.Exec(insertAssetQuery(name, symbol, decimals, chainID))
-}
-
-// AddChain adds a new chain to the database
-func (db *DB) AddChain(name, networkID string) error {
- return db.Exec(insertChainQuery(name, networkID))
-}
-
-// AddCredential adds a new credential to the database
-func (db *DB) AddCredential(
- handle, controller, attestationType, origin string,
- credentialID, publicKey []byte,
- transport string,
- signCount uint32,
- userPresent, userVerified, backupEligible, backupState, cloneWarning bool,
-) error {
- return db.Exec(insertCredentialQuery(
- handle,
- controller,
- attestationType,
- origin,
- credentialID,
- publicKey,
- transport,
- signCount,
- userPresent,
- userVerified,
- backupEligible,
- backupState,
- cloneWarning,
- ))
-}
-
-// AddProfile adds a new profile to the database
-func (db *DB) AddProfile(
- id, subject, controller, originURI, publicMetadata, privateMetadata string,
-) error {
- return db.statements["insertProfile"].Exec(
- id, subject, controller, originURI, publicMetadata, privateMetadata,
- )
-}
-
-// AddProperty adds a new property to the database
-func (db *DB) AddProperty(
- profileID, key, accumulator, propertyKey string,
-) error {
- return db.statements["insertProperty"].Exec(
- profileID, key, accumulator, propertyKey,
- )
-}
-
-// AddPermission adds a new permission to the database
-func (db *DB) AddPermission(
- serviceID string,
- grants []DIDNamespace,
- scopes []PermissionScope,
-) error {
- grantsJSON, err := json.Marshal(grants)
- if err != nil {
- return fmt.Errorf("failed to marshal grants: %w", err)
- }
-
- scopesJSON, err := json.Marshal(scopes)
- if err != nil {
- return fmt.Errorf("failed to marshal scopes: %w", err)
- }
-
- return db.statements["insertPermission"].Exec(
- serviceID, string(grantsJSON), string(scopesJSON),
- )
-}
-
-// GetPermission retrieves the permission for the given service ID
-func (db *DB) GetPermission(serviceID string) ([]DIDNamespace, []PermissionScope, error) {
- row := db.statements["getPermission"].QueryRow(serviceID)
-
- var grantsJSON, scopesJSON string
- if err := row.Scan(&grantsJSON, &scopesJSON); err != nil {
- return nil, nil, fmt.Errorf("failed to get permission: %w", err)
- }
-
- var grants []DIDNamespace
- if err := json.Unmarshal([]byte(grantsJSON), &grants); err != nil {
- return nil, nil, fmt.Errorf("failed to unmarshal grants: %w", err)
- }
-
- var scopes []PermissionScope
- if err := json.Unmarshal([]byte(scopesJSON), &scopes); err != nil {
- return nil, nil, fmt.Errorf("failed to unmarshal scopes: %w", err)
- }
-
- return grants, scopes, nil
-}
-
-// Close closes the database connection and finalizes all prepared statements
-func (db *DB) Close() error {
- for _, stmt := range db.statements {
- stmt.Finalize()
- }
- return db.Conn.Close()
-}
diff --git a/internal/db/queries.go b/internal/db/queries.go
index 807d701..e69de29 100644
--- a/internal/db/queries.go
+++ b/internal/db/queries.go
@@ -1,79 +0,0 @@
-package db
-
-import "fmt"
-
-// Account queries
-func insertAccountQuery(name, address string) string {
- return fmt.Sprintf(`INSERT INTO accounts (name, address) VALUES (%s, %s)`, name, address)
-}
-
-// Asset queries
-func insertAssetQuery(name, symbol string, decimals int, chainID int64) string {
- return fmt.Sprintf(
- `INSERT INTO assets (name, symbol, decimals, chain_id) VALUES (%s, %s, %d, %d)`,
- name,
- symbol,
- decimals,
- chainID,
- )
-}
-
-// Chain queries
-func insertChainQuery(name string, networkID string) string {
- return fmt.Sprintf(`INSERT INTO chains (name, network_id) VALUES (%s, %d)`, name, networkID)
-}
-
-// Credential queries
-func insertCredentialQuery(
- handle, controller, attestationType, origin string,
- credentialID, publicKey []byte,
- transport string,
- signCount uint32,
- userPresent, userVerified, backupEligible, backupState, cloneWarning bool,
-) string {
- return fmt.Sprintf(`INSERT INTO credentials (
- handle, controller, attestation_type, origin,
- credential_id, public_key, transport, sign_count,
- user_present, user_verified, backup_eligible,
- backup_state, clone_warning
- ) VALUES (%s, %s, %s, %s, %s, %s, %s, %d, %t, %t, %t, %t, %t)`,
- handle, controller, attestationType, origin,
- credentialID, publicKey, transport, signCount,
- userPresent, userVerified, backupEligible,
- backupState, cloneWarning)
-}
-
-// Profile queries
-func insertProfileQuery(
- id, subject, controller, originURI, publicMetadata, privateMetadata string,
-) string {
- return fmt.Sprintf(`INSERT INTO profiles (
- id, subject, controller, origin_uri,
- public_metadata, private_metadata
- ) VALUES (%s, %s, %s, %s, %s, %s)`,
- id, subject, controller, originURI,
- publicMetadata, privateMetadata)
-}
-
-// Property queries
-func insertPropertyQuery(profileID, key, accumulator, propertyKey string) string {
- return fmt.Sprintf(`INSERT INTO properties (
- profile_id, key, accumulator, property_key
- ) VALUES (%s, %s, %s, %s)`,
- profileID, key, accumulator, propertyKey)
-}
-
-// Permission queries
-func insertPermissionQuery(serviceID, grants, scopes string) string {
- return fmt.Sprintf(
- `INSERT INTO permissions (service_id, grants, scopes) VALUES (%s, %s, %s)`,
- serviceID,
- grants,
- scopes,
- )
-}
-
-// GetPermission query
-func getPermissionQuery(serviceID string) string {
- return fmt.Sprintf(`SELECT grants, scopes FROM permissions WHERE service_id = %s`, serviceID)
-}
* fix: update Makefile to use sonrd instead of wasmd
* feat: Add targets for templ and vault in Makefile and use only make in devbox.json
* feat: add SQLite database support
* bump: version 0.6.0 → 0.7.0
* refactor: upgrade actions to latest versions
2024-09-05 01:24:57 -04:00
|
|
|
module github.com/onsonr/sonr
|
2024-07-05 22:20:13 -04:00
|
|
|
|
Feature/update dockerfile (#6)
* chore: remove unused new.Dockerfile
* feat: add DID model definitions
* fix: Fix EncodePublicKey method in KeyInfo struct
* feat: Update `EncodePublicKey` to be the inverse of `DecodePublicKey`
* refactor: update AssetInfo protobuf definition
* fix: update default assets with correct asset types
* fix: Initialize IPFS client and check for mounted directories
* feat: Improve IPFS client initialization and mount checking
* feat: Add local filesystem check for IPFS and IPNS
* fix: Use Unixfs().Get() instead of Cat() for IPFS and IPNS content retrieval
* feat: Update GetCID and GetIPNS functions to read data from IPFS node
* fix: Ensure IPFS client is initialized before pinning CID
* feat: Add AddFile and AddFolder methods
* feat: add IPFS file system abstraction
* feat: Implement IPFS file, location, and filesystem abstractions
* refactor: remove unused functions and types
* refactor: remove unused FileSystem interface
* feat: add initial wasm entrypoint
* feat: add basic vault command operations
* docs: add vault module features
* test: remove test for MsgUpdateParams
* refactor: Replace PrimaryKey with Property struct in zkprop.go
* feat: Update the `CreateWitness` and `CreateAccumulator` and `VerifyWitness` and `UpdateAccumulator` to Use the new `Accumulator` and `Witness` types. Then Clean up the code in the file and refactor the marshalling methods
* <no value>
* feat: add KeyCurve and KeyType to KeyInfo in genesis
* feat: add WASM build step to devbox.json
* feat: Add zkgate.go file
* feat: Uncomment and modify zkgate code to work with Property struct
* feat: Merge zkgate.go and zkprop.go logic
* feat: implement API endpoints for profile management
* refactor: remove unused template file
* feat(orm): remove unused ORM models
* feat: add persistent SQLite database support in WASM
* fix: Update module names in protobuf files
* feat: Add method to initialize SQLite database
* fix: update go-sqlite3 dependency to version 1.14.23
* feat: introduce database layer
* feat: Implement database layer for Vault node
* feature/update-dockerfile
* feat: Add keyshares table
* fix: Reorder the SQL statements in the tables.go file
* feat: Update the `createCredentialsTable` method to match the proper Credential struct
* feat: Update createProfilesTable and add createPropertiesTable
* feat: Add constant SQL queries to queries.go and use prepared statements in db.go
* feat: Add createKeysharesTable to internal/db/db.go
* feat: Update `createPermissionsTable` to match Permissions struct
* feat: Add database enum types
* feat: Add DIDNamespace and PermissionScope enums
* feat: Add DBConfig and DBOption types
* feat: Update the db implementation to use the provided go library
* fix: update db implementation to use go-sqlite3 v0.18.2
* fix: Refactor database connection and statement handling
* feat: Simplify db.go implementation
* feat: Convert constant SQL queries to functions in queries.go and update db.go to use prepared statements
* feat: Add models.go file with database table structs
* fix: Remove unused statement map and prepare statements
diff --git a/internal/db/db.go b/internal/db/db.go
index 201d09b..d4d4d4e 100644
--- a/internal/db/db.go
+++ b/internal/db/db.go
@@ -32,11 +32,6 @@ func Open(config *DBConfig) (*DB, error) {
Conn: conn,
}
- if err := createTables(db); err != nil {
- conn.Close()
- return nil, fmt.Errorf("failed to create tables: %w", err)
- }
-
return db, nil
}
@@ -61,114 +56,3 @@ func createTables(db *DB) error {
return nil
}
-// AddAccount adds a new account to the database
-func (db *DB) AddAccount(name, address string) error {
- return db.Exec(insertAccountQuery(name, address))
-}
-
-// AddAsset adds a new asset to the database
-func (db *DB) AddAsset(name, symbol string, decimals int, chainID int64) error {
- return db.Exec(insertAssetQuery(name, symbol, decimals, chainID))
-}
-
-// AddChain adds a new chain to the database
-func (db *DB) AddChain(name, networkID string) error {
- return db.Exec(insertChainQuery(name, networkID))
-}
-
-// AddCredential adds a new credential to the database
-func (db *DB) AddCredential(
- handle, controller, attestationType, origin string,
- credentialID, publicKey []byte,
- transport string,
- signCount uint32,
- userPresent, userVerified, backupEligible, backupState, cloneWarning bool,
-) error {
- return db.Exec(insertCredentialQuery(
- handle,
- controller,
- attestationType,
- origin,
- credentialID,
- publicKey,
- transport,
- signCount,
- userPresent,
- userVerified,
- backupEligible,
- backupState,
- cloneWarning,
- ))
-}
-
-// AddProfile adds a new profile to the database
-func (db *DB) AddProfile(
- id, subject, controller, originURI, publicMetadata, privateMetadata string,
-) error {
- return db.statements["insertProfile"].Exec(
- id, subject, controller, originURI, publicMetadata, privateMetadata,
- )
-}
-
-// AddProperty adds a new property to the database
-func (db *DB) AddProperty(
- profileID, key, accumulator, propertyKey string,
-) error {
- return db.statements["insertProperty"].Exec(
- profileID, key, accumulator, propertyKey,
- )
-}
-
-// AddPermission adds a new permission to the database
-func (db *DB) AddPermission(
- serviceID string,
- grants []DIDNamespace,
- scopes []PermissionScope,
-) error {
- grantsJSON, err := json.Marshal(grants)
- if err != nil {
- return fmt.Errorf("failed to marshal grants: %w", err)
- }
-
- scopesJSON, err := json.Marshal(scopes)
- if err != nil {
- return fmt.Errorf("failed to marshal scopes: %w", err)
- }
-
- return db.statements["insertPermission"].Exec(
- serviceID, string(grantsJSON), string(scopesJSON),
- )
-}
-
-// GetPermission retrieves the permission for the given service ID
-func (db *DB) GetPermission(serviceID string) ([]DIDNamespace, []PermissionScope, error) {
- row := db.statements["getPermission"].QueryRow(serviceID)
-
- var grantsJSON, scopesJSON string
- if err := row.Scan(&grantsJSON, &scopesJSON); err != nil {
- return nil, nil, fmt.Errorf("failed to get permission: %w", err)
- }
-
- var grants []DIDNamespace
- if err := json.Unmarshal([]byte(grantsJSON), &grants); err != nil {
- return nil, nil, fmt.Errorf("failed to unmarshal grants: %w", err)
- }
-
- var scopes []PermissionScope
- if err := json.Unmarshal([]byte(scopesJSON), &scopes); err != nil {
- return nil, nil, fmt.Errorf("failed to unmarshal scopes: %w", err)
- }
-
- return grants, scopes, nil
-}
-
-// Close closes the database connection and finalizes all prepared statements
-func (db *DB) Close() error {
- for _, stmt := range db.statements {
- stmt.Finalize()
- }
- return db.Conn.Close()
-}
diff --git a/internal/db/queries.go b/internal/db/queries.go
index 807d701..e69de29 100644
--- a/internal/db/queries.go
+++ b/internal/db/queries.go
@@ -1,79 +0,0 @@
-package db
-
-import "fmt"
-
-// Account queries
-func insertAccountQuery(name, address string) string {
- return fmt.Sprintf(`INSERT INTO accounts (name, address) VALUES (%s, %s)`, name, address)
-}
-
-// Asset queries
-func insertAssetQuery(name, symbol string, decimals int, chainID int64) string {
- return fmt.Sprintf(
- `INSERT INTO assets (name, symbol, decimals, chain_id) VALUES (%s, %s, %d, %d)`,
- name,
- symbol,
- decimals,
- chainID,
- )
-}
-
-// Chain queries
-func insertChainQuery(name string, networkID string) string {
- return fmt.Sprintf(`INSERT INTO chains (name, network_id) VALUES (%s, %d)`, name, networkID)
-}
-
-// Credential queries
-func insertCredentialQuery(
- handle, controller, attestationType, origin string,
- credentialID, publicKey []byte,
- transport string,
- signCount uint32,
- userPresent, userVerified, backupEligible, backupState, cloneWarning bool,
-) string {
- return fmt.Sprintf(`INSERT INTO credentials (
- handle, controller, attestation_type, origin,
- credential_id, public_key, transport, sign_count,
- user_present, user_verified, backup_eligible,
- backup_state, clone_warning
- ) VALUES (%s, %s, %s, %s, %s, %s, %s, %d, %t, %t, %t, %t, %t)`,
- handle, controller, attestationType, origin,
- credentialID, publicKey, transport, signCount,
- userPresent, userVerified, backupEligible,
- backupState, cloneWarning)
-}
-
-// Profile queries
-func insertProfileQuery(
- id, subject, controller, originURI, publicMetadata, privateMetadata string,
-) string {
- return fmt.Sprintf(`INSERT INTO profiles (
- id, subject, controller, origin_uri,
- public_metadata, private_metadata
- ) VALUES (%s, %s, %s, %s, %s, %s)`,
- id, subject, controller, originURI,
- publicMetadata, privateMetadata)
-}
-
-// Property queries
-func insertPropertyQuery(profileID, key, accumulator, propertyKey string) string {
- return fmt.Sprintf(`INSERT INTO properties (
- profile_id, key, accumulator, property_key
- ) VALUES (%s, %s, %s, %s)`,
- profileID, key, accumulator, propertyKey)
-}
-
-// Permission queries
-func insertPermissionQuery(serviceID, grants, scopes string) string {
- return fmt.Sprintf(
- `INSERT INTO permissions (service_id, grants, scopes) VALUES (%s, %s, %s)`,
- serviceID,
- grants,
- scopes,
- )
-}
-
-// GetPermission query
-func getPermissionQuery(serviceID string) string {
- return fmt.Sprintf(`SELECT grants, scopes FROM permissions WHERE service_id = %s`, serviceID)
-}
* fix: update Makefile to use sonrd instead of wasmd
* feat: Add targets for templ and vault in Makefile and use only make in devbox.json
* feat: add SQLite database support
* bump: version 0.6.0 → 0.7.0
* refactor: upgrade actions to latest versions
2024-09-05 01:24:57 -04:00
|
|
|
go 1.22.5
|
|
|
|
|
2024-07-05 22:20:13 -04:00
|
|
|
// overrides
|
|
|
|
replace (
|
|
|
|
cosmossdk.io/core => cosmossdk.io/core v0.11.0
|
Feature/update dockerfile (#6)
* chore: remove unused new.Dockerfile
* feat: add DID model definitions
* fix: Fix EncodePublicKey method in KeyInfo struct
* feat: Update `EncodePublicKey` to be the inverse of `DecodePublicKey`
* refactor: update AssetInfo protobuf definition
* fix: update default assets with correct asset types
* fix: Initialize IPFS client and check for mounted directories
* feat: Improve IPFS client initialization and mount checking
* feat: Add local filesystem check for IPFS and IPNS
* fix: Use Unixfs().Get() instead of Cat() for IPFS and IPNS content retrieval
* feat: Update GetCID and GetIPNS functions to read data from IPFS node
* fix: Ensure IPFS client is initialized before pinning CID
* feat: Add AddFile and AddFolder methods
* feat: add IPFS file system abstraction
* feat: Implement IPFS file, location, and filesystem abstractions
* refactor: remove unused functions and types
* refactor: remove unused FileSystem interface
* feat: add initial wasm entrypoint
* feat: add basic vault command operations
* docs: add vault module features
* test: remove test for MsgUpdateParams
* refactor: Replace PrimaryKey with Property struct in zkprop.go
* feat: Update the `CreateWitness` and `CreateAccumulator` and `VerifyWitness` and `UpdateAccumulator` to Use the new `Accumulator` and `Witness` types. Then Clean up the code in the file and refactor the marshalling methods
* <no value>
* feat: add KeyCurve and KeyType to KeyInfo in genesis
* feat: add WASM build step to devbox.json
* feat: Add zkgate.go file
* feat: Uncomment and modify zkgate code to work with Property struct
* feat: Merge zkgate.go and zkprop.go logic
* feat: implement API endpoints for profile management
* refactor: remove unused template file
* feat(orm): remove unused ORM models
* feat: add persistent SQLite database support in WASM
* fix: Update module names in protobuf files
* feat: Add method to initialize SQLite database
* fix: update go-sqlite3 dependency to version 1.14.23
* feat: introduce database layer
* feat: Implement database layer for Vault node
* feature/update-dockerfile
* feat: Add keyshares table
* fix: Reorder the SQL statements in the tables.go file
* feat: Update the `createCredentialsTable` method to match the proper Credential struct
* feat: Update createProfilesTable and add createPropertiesTable
* feat: Add constant SQL queries to queries.go and use prepared statements in db.go
* feat: Add createKeysharesTable to internal/db/db.go
* feat: Update `createPermissionsTable` to match Permissions struct
* feat: Add database enum types
* feat: Add DIDNamespace and PermissionScope enums
* feat: Add DBConfig and DBOption types
* feat: Update the db implementation to use the provided go library
* fix: update db implementation to use go-sqlite3 v0.18.2
* fix: Refactor database connection and statement handling
* feat: Simplify db.go implementation
* feat: Convert constant SQL queries to functions in queries.go and update db.go to use prepared statements
* feat: Add models.go file with database table structs
* fix: Remove unused statement map and prepare statements
diff --git a/internal/db/db.go b/internal/db/db.go
index 201d09b..d4d4d4e 100644
--- a/internal/db/db.go
+++ b/internal/db/db.go
@@ -32,11 +32,6 @@ func Open(config *DBConfig) (*DB, error) {
Conn: conn,
}
- if err := createTables(db); err != nil {
- conn.Close()
- return nil, fmt.Errorf("failed to create tables: %w", err)
- }
-
return db, nil
}
@@ -61,114 +56,3 @@ func createTables(db *DB) error {
return nil
}
-// AddAccount adds a new account to the database
-func (db *DB) AddAccount(name, address string) error {
- return db.Exec(insertAccountQuery(name, address))
-}
-
-// AddAsset adds a new asset to the database
-func (db *DB) AddAsset(name, symbol string, decimals int, chainID int64) error {
- return db.Exec(insertAssetQuery(name, symbol, decimals, chainID))
-}
-
-// AddChain adds a new chain to the database
-func (db *DB) AddChain(name, networkID string) error {
- return db.Exec(insertChainQuery(name, networkID))
-}
-
-// AddCredential adds a new credential to the database
-func (db *DB) AddCredential(
- handle, controller, attestationType, origin string,
- credentialID, publicKey []byte,
- transport string,
- signCount uint32,
- userPresent, userVerified, backupEligible, backupState, cloneWarning bool,
-) error {
- return db.Exec(insertCredentialQuery(
- handle,
- controller,
- attestationType,
- origin,
- credentialID,
- publicKey,
- transport,
- signCount,
- userPresent,
- userVerified,
- backupEligible,
- backupState,
- cloneWarning,
- ))
-}
-
-// AddProfile adds a new profile to the database
-func (db *DB) AddProfile(
- id, subject, controller, originURI, publicMetadata, privateMetadata string,
-) error {
- return db.statements["insertProfile"].Exec(
- id, subject, controller, originURI, publicMetadata, privateMetadata,
- )
-}
-
-// AddProperty adds a new property to the database
-func (db *DB) AddProperty(
- profileID, key, accumulator, propertyKey string,
-) error {
- return db.statements["insertProperty"].Exec(
- profileID, key, accumulator, propertyKey,
- )
-}
-
-// AddPermission adds a new permission to the database
-func (db *DB) AddPermission(
- serviceID string,
- grants []DIDNamespace,
- scopes []PermissionScope,
-) error {
- grantsJSON, err := json.Marshal(grants)
- if err != nil {
- return fmt.Errorf("failed to marshal grants: %w", err)
- }
-
- scopesJSON, err := json.Marshal(scopes)
- if err != nil {
- return fmt.Errorf("failed to marshal scopes: %w", err)
- }
-
- return db.statements["insertPermission"].Exec(
- serviceID, string(grantsJSON), string(scopesJSON),
- )
-}
-
-// GetPermission retrieves the permission for the given service ID
-func (db *DB) GetPermission(serviceID string) ([]DIDNamespace, []PermissionScope, error) {
- row := db.statements["getPermission"].QueryRow(serviceID)
-
- var grantsJSON, scopesJSON string
- if err := row.Scan(&grantsJSON, &scopesJSON); err != nil {
- return nil, nil, fmt.Errorf("failed to get permission: %w", err)
- }
-
- var grants []DIDNamespace
- if err := json.Unmarshal([]byte(grantsJSON), &grants); err != nil {
- return nil, nil, fmt.Errorf("failed to unmarshal grants: %w", err)
- }
-
- var scopes []PermissionScope
- if err := json.Unmarshal([]byte(scopesJSON), &scopes); err != nil {
- return nil, nil, fmt.Errorf("failed to unmarshal scopes: %w", err)
- }
-
- return grants, scopes, nil
-}
-
-// Close closes the database connection and finalizes all prepared statements
-func (db *DB) Close() error {
- for _, stmt := range db.statements {
- stmt.Finalize()
- }
- return db.Conn.Close()
-}
diff --git a/internal/db/queries.go b/internal/db/queries.go
index 807d701..e69de29 100644
--- a/internal/db/queries.go
+++ b/internal/db/queries.go
@@ -1,79 +0,0 @@
-package db
-
-import "fmt"
-
-// Account queries
-func insertAccountQuery(name, address string) string {
- return fmt.Sprintf(`INSERT INTO accounts (name, address) VALUES (%s, %s)`, name, address)
-}
-
-// Asset queries
-func insertAssetQuery(name, symbol string, decimals int, chainID int64) string {
- return fmt.Sprintf(
- `INSERT INTO assets (name, symbol, decimals, chain_id) VALUES (%s, %s, %d, %d)`,
- name,
- symbol,
- decimals,
- chainID,
- )
-}
-
-// Chain queries
-func insertChainQuery(name string, networkID string) string {
- return fmt.Sprintf(`INSERT INTO chains (name, network_id) VALUES (%s, %d)`, name, networkID)
-}
-
-// Credential queries
-func insertCredentialQuery(
- handle, controller, attestationType, origin string,
- credentialID, publicKey []byte,
- transport string,
- signCount uint32,
- userPresent, userVerified, backupEligible, backupState, cloneWarning bool,
-) string {
- return fmt.Sprintf(`INSERT INTO credentials (
- handle, controller, attestation_type, origin,
- credential_id, public_key, transport, sign_count,
- user_present, user_verified, backup_eligible,
- backup_state, clone_warning
- ) VALUES (%s, %s, %s, %s, %s, %s, %s, %d, %t, %t, %t, %t, %t)`,
- handle, controller, attestationType, origin,
- credentialID, publicKey, transport, signCount,
- userPresent, userVerified, backupEligible,
- backupState, cloneWarning)
-}
-
-// Profile queries
-func insertProfileQuery(
- id, subject, controller, originURI, publicMetadata, privateMetadata string,
-) string {
- return fmt.Sprintf(`INSERT INTO profiles (
- id, subject, controller, origin_uri,
- public_metadata, private_metadata
- ) VALUES (%s, %s, %s, %s, %s, %s)`,
- id, subject, controller, originURI,
- publicMetadata, privateMetadata)
-}
-
-// Property queries
-func insertPropertyQuery(profileID, key, accumulator, propertyKey string) string {
- return fmt.Sprintf(`INSERT INTO properties (
- profile_id, key, accumulator, property_key
- ) VALUES (%s, %s, %s, %s)`,
- profileID, key, accumulator, propertyKey)
-}
-
-// Permission queries
-func insertPermissionQuery(serviceID, grants, scopes string) string {
- return fmt.Sprintf(
- `INSERT INTO permissions (service_id, grants, scopes) VALUES (%s, %s, %s)`,
- serviceID,
- grants,
- scopes,
- )
-}
-
-// GetPermission query
-func getPermissionQuery(serviceID string) string {
- return fmt.Sprintf(`SELECT grants, scopes FROM permissions WHERE service_id = %s`, serviceID)
-}
* fix: update Makefile to use sonrd instead of wasmd
* feat: Add targets for templ and vault in Makefile and use only make in devbox.json
* feat: add SQLite database support
* bump: version 0.6.0 → 0.7.0
* refactor: upgrade actions to latest versions
2024-09-05 01:24:57 -04:00
|
|
|
github.com/ChainSafe/go-schnorrkel => github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d
|
|
|
|
github.com/ChainSafe/go-schnorrkel/1 => github.com/ChainSafe/go-schnorrkel v1.0.0
|
|
|
|
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/prometheus/client_golang => github.com/prometheus/client_golang v1.18.0
|
|
|
|
github.com/prometheus/common => github.com/prometheus/common v0.47.0
|
|
|
|
github.com/spf13/viper => github.com/spf13/viper v1.17.0 // v1.18+ breaks app overrides
|
Feature/update dockerfile (#6)
* chore: remove unused new.Dockerfile
* feat: add DID model definitions
* fix: Fix EncodePublicKey method in KeyInfo struct
* feat: Update `EncodePublicKey` to be the inverse of `DecodePublicKey`
* refactor: update AssetInfo protobuf definition
* fix: update default assets with correct asset types
* fix: Initialize IPFS client and check for mounted directories
* feat: Improve IPFS client initialization and mount checking
* feat: Add local filesystem check for IPFS and IPNS
* fix: Use Unixfs().Get() instead of Cat() for IPFS and IPNS content retrieval
* feat: Update GetCID and GetIPNS functions to read data from IPFS node
* fix: Ensure IPFS client is initialized before pinning CID
* feat: Add AddFile and AddFolder methods
* feat: add IPFS file system abstraction
* feat: Implement IPFS file, location, and filesystem abstractions
* refactor: remove unused functions and types
* refactor: remove unused FileSystem interface
* feat: add initial wasm entrypoint
* feat: add basic vault command operations
* docs: add vault module features
* test: remove test for MsgUpdateParams
* refactor: Replace PrimaryKey with Property struct in zkprop.go
* feat: Update the `CreateWitness` and `CreateAccumulator` and `VerifyWitness` and `UpdateAccumulator` to Use the new `Accumulator` and `Witness` types. Then Clean up the code in the file and refactor the marshalling methods
* <no value>
* feat: add KeyCurve and KeyType to KeyInfo in genesis
* feat: add WASM build step to devbox.json
* feat: Add zkgate.go file
* feat: Uncomment and modify zkgate code to work with Property struct
* feat: Merge zkgate.go and zkprop.go logic
* feat: implement API endpoints for profile management
* refactor: remove unused template file
* feat(orm): remove unused ORM models
* feat: add persistent SQLite database support in WASM
* fix: Update module names in protobuf files
* feat: Add method to initialize SQLite database
* fix: update go-sqlite3 dependency to version 1.14.23
* feat: introduce database layer
* feat: Implement database layer for Vault node
* feature/update-dockerfile
* feat: Add keyshares table
* fix: Reorder the SQL statements in the tables.go file
* feat: Update the `createCredentialsTable` method to match the proper Credential struct
* feat: Update createProfilesTable and add createPropertiesTable
* feat: Add constant SQL queries to queries.go and use prepared statements in db.go
* feat: Add createKeysharesTable to internal/db/db.go
* feat: Update `createPermissionsTable` to match Permissions struct
* feat: Add database enum types
* feat: Add DIDNamespace and PermissionScope enums
* feat: Add DBConfig and DBOption types
* feat: Update the db implementation to use the provided go library
* fix: update db implementation to use go-sqlite3 v0.18.2
* fix: Refactor database connection and statement handling
* feat: Simplify db.go implementation
* feat: Convert constant SQL queries to functions in queries.go and update db.go to use prepared statements
* feat: Add models.go file with database table structs
* fix: Remove unused statement map and prepare statements
diff --git a/internal/db/db.go b/internal/db/db.go
index 201d09b..d4d4d4e 100644
--- a/internal/db/db.go
+++ b/internal/db/db.go
@@ -32,11 +32,6 @@ func Open(config *DBConfig) (*DB, error) {
Conn: conn,
}
- if err := createTables(db); err != nil {
- conn.Close()
- return nil, fmt.Errorf("failed to create tables: %w", err)
- }
-
return db, nil
}
@@ -61,114 +56,3 @@ func createTables(db *DB) error {
return nil
}
-// AddAccount adds a new account to the database
-func (db *DB) AddAccount(name, address string) error {
- return db.Exec(insertAccountQuery(name, address))
-}
-
-// AddAsset adds a new asset to the database
-func (db *DB) AddAsset(name, symbol string, decimals int, chainID int64) error {
- return db.Exec(insertAssetQuery(name, symbol, decimals, chainID))
-}
-
-// AddChain adds a new chain to the database
-func (db *DB) AddChain(name, networkID string) error {
- return db.Exec(insertChainQuery(name, networkID))
-}
-
-// AddCredential adds a new credential to the database
-func (db *DB) AddCredential(
- handle, controller, attestationType, origin string,
- credentialID, publicKey []byte,
- transport string,
- signCount uint32,
- userPresent, userVerified, backupEligible, backupState, cloneWarning bool,
-) error {
- return db.Exec(insertCredentialQuery(
- handle,
- controller,
- attestationType,
- origin,
- credentialID,
- publicKey,
- transport,
- signCount,
- userPresent,
- userVerified,
- backupEligible,
- backupState,
- cloneWarning,
- ))
-}
-
-// AddProfile adds a new profile to the database
-func (db *DB) AddProfile(
- id, subject, controller, originURI, publicMetadata, privateMetadata string,
-) error {
- return db.statements["insertProfile"].Exec(
- id, subject, controller, originURI, publicMetadata, privateMetadata,
- )
-}
-
-// AddProperty adds a new property to the database
-func (db *DB) AddProperty(
- profileID, key, accumulator, propertyKey string,
-) error {
- return db.statements["insertProperty"].Exec(
- profileID, key, accumulator, propertyKey,
- )
-}
-
-// AddPermission adds a new permission to the database
-func (db *DB) AddPermission(
- serviceID string,
- grants []DIDNamespace,
- scopes []PermissionScope,
-) error {
- grantsJSON, err := json.Marshal(grants)
- if err != nil {
- return fmt.Errorf("failed to marshal grants: %w", err)
- }
-
- scopesJSON, err := json.Marshal(scopes)
- if err != nil {
- return fmt.Errorf("failed to marshal scopes: %w", err)
- }
-
- return db.statements["insertPermission"].Exec(
- serviceID, string(grantsJSON), string(scopesJSON),
- )
-}
-
-// GetPermission retrieves the permission for the given service ID
-func (db *DB) GetPermission(serviceID string) ([]DIDNamespace, []PermissionScope, error) {
- row := db.statements["getPermission"].QueryRow(serviceID)
-
- var grantsJSON, scopesJSON string
- if err := row.Scan(&grantsJSON, &scopesJSON); err != nil {
- return nil, nil, fmt.Errorf("failed to get permission: %w", err)
- }
-
- var grants []DIDNamespace
- if err := json.Unmarshal([]byte(grantsJSON), &grants); err != nil {
- return nil, nil, fmt.Errorf("failed to unmarshal grants: %w", err)
- }
-
- var scopes []PermissionScope
- if err := json.Unmarshal([]byte(scopesJSON), &scopes); err != nil {
- return nil, nil, fmt.Errorf("failed to unmarshal scopes: %w", err)
- }
-
- return grants, scopes, nil
-}
-
-// Close closes the database connection and finalizes all prepared statements
-func (db *DB) Close() error {
- for _, stmt := range db.statements {
- stmt.Finalize()
- }
- return db.Conn.Close()
-}
diff --git a/internal/db/queries.go b/internal/db/queries.go
index 807d701..e69de29 100644
--- a/internal/db/queries.go
+++ b/internal/db/queries.go
@@ -1,79 +0,0 @@
-package db
-
-import "fmt"
-
-// Account queries
-func insertAccountQuery(name, address string) string {
- return fmt.Sprintf(`INSERT INTO accounts (name, address) VALUES (%s, %s)`, name, address)
-}
-
-// Asset queries
-func insertAssetQuery(name, symbol string, decimals int, chainID int64) string {
- return fmt.Sprintf(
- `INSERT INTO assets (name, symbol, decimals, chain_id) VALUES (%s, %s, %d, %d)`,
- name,
- symbol,
- decimals,
- chainID,
- )
-}
-
-// Chain queries
-func insertChainQuery(name string, networkID string) string {
- return fmt.Sprintf(`INSERT INTO chains (name, network_id) VALUES (%s, %d)`, name, networkID)
-}
-
-// Credential queries
-func insertCredentialQuery(
- handle, controller, attestationType, origin string,
- credentialID, publicKey []byte,
- transport string,
- signCount uint32,
- userPresent, userVerified, backupEligible, backupState, cloneWarning bool,
-) string {
- return fmt.Sprintf(`INSERT INTO credentials (
- handle, controller, attestation_type, origin,
- credential_id, public_key, transport, sign_count,
- user_present, user_verified, backup_eligible,
- backup_state, clone_warning
- ) VALUES (%s, %s, %s, %s, %s, %s, %s, %d, %t, %t, %t, %t, %t)`,
- handle, controller, attestationType, origin,
- credentialID, publicKey, transport, signCount,
- userPresent, userVerified, backupEligible,
- backupState, cloneWarning)
-}
-
-// Profile queries
-func insertProfileQuery(
- id, subject, controller, originURI, publicMetadata, privateMetadata string,
-) string {
- return fmt.Sprintf(`INSERT INTO profiles (
- id, subject, controller, origin_uri,
- public_metadata, private_metadata
- ) VALUES (%s, %s, %s, %s, %s, %s)`,
- id, subject, controller, originURI,
- publicMetadata, privateMetadata)
-}
-
-// Property queries
-func insertPropertyQuery(profileID, key, accumulator, propertyKey string) string {
- return fmt.Sprintf(`INSERT INTO properties (
- profile_id, key, accumulator, property_key
- ) VALUES (%s, %s, %s, %s)`,
- profileID, key, accumulator, propertyKey)
-}
-
-// Permission queries
-func insertPermissionQuery(serviceID, grants, scopes string) string {
- return fmt.Sprintf(
- `INSERT INTO permissions (service_id, grants, scopes) VALUES (%s, %s, %s)`,
- serviceID,
- grants,
- scopes,
- )
-}
-
-// GetPermission query
-func getPermissionQuery(serviceID string) string {
- return fmt.Sprintf(`SELECT grants, scopes FROM permissions WHERE service_id = %s`, serviceID)
-}
* fix: update Makefile to use sonrd instead of wasmd
* feat: Add targets for templ and vault in Makefile and use only make in devbox.json
* feat: add SQLite database support
* bump: version 0.6.0 → 0.7.0
* refactor: upgrade actions to latest versions
2024-09-05 01:24:57 -04:00
|
|
|
github.com/vedhavyas/go-subkey => github.com/strangelove-ventures/go-subkey v1.0.7
|
2024-07-05 22:20:13 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
replace (
|
|
|
|
github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0
|
|
|
|
|
|
|
|
// dgrijalva/jwt-go is deprecated and doesn't receive security updates.
|
|
|
|
// See: https://github.com/cosmos/cosmos-sdk/issues/13134
|
|
|
|
github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2
|
|
|
|
// Fix upstream GHSA-h395-qcrw-5vmq vulnerability.
|
|
|
|
// See: https://github.com/cosmos/cosmos-sdk/issues/10409
|
|
|
|
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.8.1
|
|
|
|
|
|
|
|
// pin version! 126854af5e6d has issues with the store so that queries fail
|
|
|
|
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
|
|
|
|
)
|
|
|
|
|
|
|
|
require (
|
2024-07-06 00:34:41 -04:00
|
|
|
cosmossdk.io/api v0.7.5
|
2024-07-05 22:20:13 -04:00
|
|
|
cosmossdk.io/client/v2 v2.0.0-beta.1
|
|
|
|
cosmossdk.io/collections v0.4.0
|
|
|
|
cosmossdk.io/core v0.12.0
|
|
|
|
cosmossdk.io/depinject v1.0.0-alpha.4
|
|
|
|
cosmossdk.io/errors v1.0.1
|
|
|
|
cosmossdk.io/log v1.3.1
|
|
|
|
cosmossdk.io/math v1.3.0
|
|
|
|
cosmossdk.io/orm v1.0.0-beta.3
|
2024-07-06 00:34:41 -04:00
|
|
|
cosmossdk.io/store v1.1.0
|
2024-07-05 22:20:13 -04:00
|
|
|
cosmossdk.io/tools/confix v0.1.1
|
|
|
|
cosmossdk.io/x/circuit v0.1.0
|
|
|
|
cosmossdk.io/x/evidence v0.1.0
|
|
|
|
cosmossdk.io/x/feegrant v0.1.0
|
|
|
|
cosmossdk.io/x/nft v0.1.0
|
2024-07-06 00:34:41 -04:00
|
|
|
cosmossdk.io/x/tx v0.13.3
|
2024-07-05 22:20:13 -04:00
|
|
|
cosmossdk.io/x/upgrade v0.1.1
|
2024-09-21 21:42:51 -04:00
|
|
|
github.com/a-h/templ v0.2.778
|
2024-09-05 18:37:38 -04:00
|
|
|
github.com/apple/pkl-go v0.8.0
|
2024-07-26 12:14:20 -04:00
|
|
|
github.com/btcsuite/btcd/btcec/v2 v2.3.3
|
2024-09-05 18:37:38 -04:00
|
|
|
github.com/charmbracelet/bubbles v0.19.0
|
2024-09-05 16:38:44 -04:00
|
|
|
github.com/charmbracelet/bubbletea v1.1.0
|
|
|
|
github.com/charmbracelet/huh v0.5.3
|
2024-09-05 18:37:38 -04:00
|
|
|
github.com/charmbracelet/lipgloss v0.13.0
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/cometbft/cometbft v0.38.8
|
2024-09-23 12:39:59 -04:00
|
|
|
github.com/cosmos/btcutil v1.0.5
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/cosmos/cosmos-db v1.0.2
|
2024-07-06 00:34:41 -04:00
|
|
|
github.com/cosmos/cosmos-proto v1.0.0-beta.5
|
2024-07-24 02:42:05 -04:00
|
|
|
github.com/cosmos/cosmos-sdk v0.50.5
|
2024-07-06 00:34:41 -04:00
|
|
|
github.com/cosmos/gogoproto v1.4.12
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8 v8.0.2-0.20240228211029-91e486ec4dbb
|
|
|
|
github.com/cosmos/ibc-go/modules/capability v1.0.0
|
|
|
|
github.com/cosmos/ibc-go/v8 v8.2.0
|
2024-09-11 15:10:54 -04:00
|
|
|
github.com/donseba/go-htmx v1.10.0
|
2024-09-14 12:47:25 -04:00
|
|
|
github.com/ethereum/go-ethereum v1.14.6
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/go-webauthn/webauthn v0.10.2
|
|
|
|
github.com/golang/protobuf v1.5.4
|
|
|
|
github.com/grpc-ecosystem/grpc-gateway v1.16.0
|
Feature/update dockerfile (#6)
* chore: remove unused new.Dockerfile
* feat: add DID model definitions
* fix: Fix EncodePublicKey method in KeyInfo struct
* feat: Update `EncodePublicKey` to be the inverse of `DecodePublicKey`
* refactor: update AssetInfo protobuf definition
* fix: update default assets with correct asset types
* fix: Initialize IPFS client and check for mounted directories
* feat: Improve IPFS client initialization and mount checking
* feat: Add local filesystem check for IPFS and IPNS
* fix: Use Unixfs().Get() instead of Cat() for IPFS and IPNS content retrieval
* feat: Update GetCID and GetIPNS functions to read data from IPFS node
* fix: Ensure IPFS client is initialized before pinning CID
* feat: Add AddFile and AddFolder methods
* feat: add IPFS file system abstraction
* feat: Implement IPFS file, location, and filesystem abstractions
* refactor: remove unused functions and types
* refactor: remove unused FileSystem interface
* feat: add initial wasm entrypoint
* feat: add basic vault command operations
* docs: add vault module features
* test: remove test for MsgUpdateParams
* refactor: Replace PrimaryKey with Property struct in zkprop.go
* feat: Update the `CreateWitness` and `CreateAccumulator` and `VerifyWitness` and `UpdateAccumulator` to Use the new `Accumulator` and `Witness` types. Then Clean up the code in the file and refactor the marshalling methods
* <no value>
* feat: add KeyCurve and KeyType to KeyInfo in genesis
* feat: add WASM build step to devbox.json
* feat: Add zkgate.go file
* feat: Uncomment and modify zkgate code to work with Property struct
* feat: Merge zkgate.go and zkprop.go logic
* feat: implement API endpoints for profile management
* refactor: remove unused template file
* feat(orm): remove unused ORM models
* feat: add persistent SQLite database support in WASM
* fix: Update module names in protobuf files
* feat: Add method to initialize SQLite database
* fix: update go-sqlite3 dependency to version 1.14.23
* feat: introduce database layer
* feat: Implement database layer for Vault node
* feature/update-dockerfile
* feat: Add keyshares table
* fix: Reorder the SQL statements in the tables.go file
* feat: Update the `createCredentialsTable` method to match the proper Credential struct
* feat: Update createProfilesTable and add createPropertiesTable
* feat: Add constant SQL queries to queries.go and use prepared statements in db.go
* feat: Add createKeysharesTable to internal/db/db.go
* feat: Update `createPermissionsTable` to match Permissions struct
* feat: Add database enum types
* feat: Add DIDNamespace and PermissionScope enums
* feat: Add DBConfig and DBOption types
* feat: Update the db implementation to use the provided go library
* fix: update db implementation to use go-sqlite3 v0.18.2
* fix: Refactor database connection and statement handling
* feat: Simplify db.go implementation
* feat: Convert constant SQL queries to functions in queries.go and update db.go to use prepared statements
* feat: Add models.go file with database table structs
* fix: Remove unused statement map and prepare statements
diff --git a/internal/db/db.go b/internal/db/db.go
index 201d09b..d4d4d4e 100644
--- a/internal/db/db.go
+++ b/internal/db/db.go
@@ -32,11 +32,6 @@ func Open(config *DBConfig) (*DB, error) {
Conn: conn,
}
- if err := createTables(db); err != nil {
- conn.Close()
- return nil, fmt.Errorf("failed to create tables: %w", err)
- }
-
return db, nil
}
@@ -61,114 +56,3 @@ func createTables(db *DB) error {
return nil
}
-// AddAccount adds a new account to the database
-func (db *DB) AddAccount(name, address string) error {
- return db.Exec(insertAccountQuery(name, address))
-}
-
-// AddAsset adds a new asset to the database
-func (db *DB) AddAsset(name, symbol string, decimals int, chainID int64) error {
- return db.Exec(insertAssetQuery(name, symbol, decimals, chainID))
-}
-
-// AddChain adds a new chain to the database
-func (db *DB) AddChain(name, networkID string) error {
- return db.Exec(insertChainQuery(name, networkID))
-}
-
-// AddCredential adds a new credential to the database
-func (db *DB) AddCredential(
- handle, controller, attestationType, origin string,
- credentialID, publicKey []byte,
- transport string,
- signCount uint32,
- userPresent, userVerified, backupEligible, backupState, cloneWarning bool,
-) error {
- return db.Exec(insertCredentialQuery(
- handle,
- controller,
- attestationType,
- origin,
- credentialID,
- publicKey,
- transport,
- signCount,
- userPresent,
- userVerified,
- backupEligible,
- backupState,
- cloneWarning,
- ))
-}
-
-// AddProfile adds a new profile to the database
-func (db *DB) AddProfile(
- id, subject, controller, originURI, publicMetadata, privateMetadata string,
-) error {
- return db.statements["insertProfile"].Exec(
- id, subject, controller, originURI, publicMetadata, privateMetadata,
- )
-}
-
-// AddProperty adds a new property to the database
-func (db *DB) AddProperty(
- profileID, key, accumulator, propertyKey string,
-) error {
- return db.statements["insertProperty"].Exec(
- profileID, key, accumulator, propertyKey,
- )
-}
-
-// AddPermission adds a new permission to the database
-func (db *DB) AddPermission(
- serviceID string,
- grants []DIDNamespace,
- scopes []PermissionScope,
-) error {
- grantsJSON, err := json.Marshal(grants)
- if err != nil {
- return fmt.Errorf("failed to marshal grants: %w", err)
- }
-
- scopesJSON, err := json.Marshal(scopes)
- if err != nil {
- return fmt.Errorf("failed to marshal scopes: %w", err)
- }
-
- return db.statements["insertPermission"].Exec(
- serviceID, string(grantsJSON), string(scopesJSON),
- )
-}
-
-// GetPermission retrieves the permission for the given service ID
-func (db *DB) GetPermission(serviceID string) ([]DIDNamespace, []PermissionScope, error) {
- row := db.statements["getPermission"].QueryRow(serviceID)
-
- var grantsJSON, scopesJSON string
- if err := row.Scan(&grantsJSON, &scopesJSON); err != nil {
- return nil, nil, fmt.Errorf("failed to get permission: %w", err)
- }
-
- var grants []DIDNamespace
- if err := json.Unmarshal([]byte(grantsJSON), &grants); err != nil {
- return nil, nil, fmt.Errorf("failed to unmarshal grants: %w", err)
- }
-
- var scopes []PermissionScope
- if err := json.Unmarshal([]byte(scopesJSON), &scopes); err != nil {
- return nil, nil, fmt.Errorf("failed to unmarshal scopes: %w", err)
- }
-
- return grants, scopes, nil
-}
-
-// Close closes the database connection and finalizes all prepared statements
-func (db *DB) Close() error {
- for _, stmt := range db.statements {
- stmt.Finalize()
- }
- return db.Conn.Close()
-}
diff --git a/internal/db/queries.go b/internal/db/queries.go
index 807d701..e69de29 100644
--- a/internal/db/queries.go
+++ b/internal/db/queries.go
@@ -1,79 +0,0 @@
-package db
-
-import "fmt"
-
-// Account queries
-func insertAccountQuery(name, address string) string {
- return fmt.Sprintf(`INSERT INTO accounts (name, address) VALUES (%s, %s)`, name, address)
-}
-
-// Asset queries
-func insertAssetQuery(name, symbol string, decimals int, chainID int64) string {
- return fmt.Sprintf(
- `INSERT INTO assets (name, symbol, decimals, chain_id) VALUES (%s, %s, %d, %d)`,
- name,
- symbol,
- decimals,
- chainID,
- )
-}
-
-// Chain queries
-func insertChainQuery(name string, networkID string) string {
- return fmt.Sprintf(`INSERT INTO chains (name, network_id) VALUES (%s, %d)`, name, networkID)
-}
-
-// Credential queries
-func insertCredentialQuery(
- handle, controller, attestationType, origin string,
- credentialID, publicKey []byte,
- transport string,
- signCount uint32,
- userPresent, userVerified, backupEligible, backupState, cloneWarning bool,
-) string {
- return fmt.Sprintf(`INSERT INTO credentials (
- handle, controller, attestation_type, origin,
- credential_id, public_key, transport, sign_count,
- user_present, user_verified, backup_eligible,
- backup_state, clone_warning
- ) VALUES (%s, %s, %s, %s, %s, %s, %s, %d, %t, %t, %t, %t, %t)`,
- handle, controller, attestationType, origin,
- credentialID, publicKey, transport, signCount,
- userPresent, userVerified, backupEligible,
- backupState, cloneWarning)
-}
-
-// Profile queries
-func insertProfileQuery(
- id, subject, controller, originURI, publicMetadata, privateMetadata string,
-) string {
- return fmt.Sprintf(`INSERT INTO profiles (
- id, subject, controller, origin_uri,
- public_metadata, private_metadata
- ) VALUES (%s, %s, %s, %s, %s, %s)`,
- id, subject, controller, originURI,
- publicMetadata, privateMetadata)
-}
-
-// Property queries
-func insertPropertyQuery(profileID, key, accumulator, propertyKey string) string {
- return fmt.Sprintf(`INSERT INTO properties (
- profile_id, key, accumulator, property_key
- ) VALUES (%s, %s, %s, %s)`,
- profileID, key, accumulator, propertyKey)
-}
-
-// Permission queries
-func insertPermissionQuery(serviceID, grants, scopes string) string {
- return fmt.Sprintf(
- `INSERT INTO permissions (service_id, grants, scopes) VALUES (%s, %s, %s)`,
- serviceID,
- grants,
- scopes,
- )
-}
-
-// GetPermission query
-func getPermissionQuery(serviceID string) string {
- return fmt.Sprintf(`SELECT grants, scopes FROM permissions WHERE service_id = %s`, serviceID)
-}
* fix: update Makefile to use sonrd instead of wasmd
* feat: Add targets for templ and vault in Makefile and use only make in devbox.json
* feat: add SQLite database support
* bump: version 0.6.0 → 0.7.0
* refactor: upgrade actions to latest versions
2024-09-05 01:24:57 -04:00
|
|
|
github.com/ipfs/boxo v0.21.0
|
2024-07-08 22:57:53 -04:00
|
|
|
github.com/ipfs/kubo v0.29.0
|
2024-07-23 17:04:00 -04:00
|
|
|
github.com/joho/godotenv v1.5.1
|
2024-09-11 15:10:54 -04:00
|
|
|
github.com/labstack/echo/v4 v4.10.2
|
|
|
|
github.com/nlepage/go-js-promise v1.0.0
|
2024-09-19 02:04:22 -04:00
|
|
|
github.com/onsonr/crypto v1.32.0
|
2024-09-11 15:10:54 -04:00
|
|
|
github.com/segmentio/ksuid v1.0.4
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/spf13/cast v1.6.0
|
|
|
|
github.com/spf13/cobra v1.8.0
|
|
|
|
github.com/spf13/pflag v1.0.5
|
|
|
|
github.com/spf13/viper v1.18.2
|
|
|
|
github.com/strangelove-ventures/globalfee v0.50.0
|
|
|
|
github.com/strangelove-ventures/poa v0.50.0
|
|
|
|
github.com/strangelove-ventures/tokenfactory v0.50.0
|
|
|
|
github.com/stretchr/testify v1.9.0
|
2024-09-11 15:10:54 -04:00
|
|
|
github.com/syumai/workers v0.26.3
|
Feature/update dockerfile (#6)
* chore: remove unused new.Dockerfile
* feat: add DID model definitions
* fix: Fix EncodePublicKey method in KeyInfo struct
* feat: Update `EncodePublicKey` to be the inverse of `DecodePublicKey`
* refactor: update AssetInfo protobuf definition
* fix: update default assets with correct asset types
* fix: Initialize IPFS client and check for mounted directories
* feat: Improve IPFS client initialization and mount checking
* feat: Add local filesystem check for IPFS and IPNS
* fix: Use Unixfs().Get() instead of Cat() for IPFS and IPNS content retrieval
* feat: Update GetCID and GetIPNS functions to read data from IPFS node
* fix: Ensure IPFS client is initialized before pinning CID
* feat: Add AddFile and AddFolder methods
* feat: add IPFS file system abstraction
* feat: Implement IPFS file, location, and filesystem abstractions
* refactor: remove unused functions and types
* refactor: remove unused FileSystem interface
* feat: add initial wasm entrypoint
* feat: add basic vault command operations
* docs: add vault module features
* test: remove test for MsgUpdateParams
* refactor: Replace PrimaryKey with Property struct in zkprop.go
* feat: Update the `CreateWitness` and `CreateAccumulator` and `VerifyWitness` and `UpdateAccumulator` to Use the new `Accumulator` and `Witness` types. Then Clean up the code in the file and refactor the marshalling methods
* <no value>
* feat: add KeyCurve and KeyType to KeyInfo in genesis
* feat: add WASM build step to devbox.json
* feat: Add zkgate.go file
* feat: Uncomment and modify zkgate code to work with Property struct
* feat: Merge zkgate.go and zkprop.go logic
* feat: implement API endpoints for profile management
* refactor: remove unused template file
* feat(orm): remove unused ORM models
* feat: add persistent SQLite database support in WASM
* fix: Update module names in protobuf files
* feat: Add method to initialize SQLite database
* fix: update go-sqlite3 dependency to version 1.14.23
* feat: introduce database layer
* feat: Implement database layer for Vault node
* feature/update-dockerfile
* feat: Add keyshares table
* fix: Reorder the SQL statements in the tables.go file
* feat: Update the `createCredentialsTable` method to match the proper Credential struct
* feat: Update createProfilesTable and add createPropertiesTable
* feat: Add constant SQL queries to queries.go and use prepared statements in db.go
* feat: Add createKeysharesTable to internal/db/db.go
* feat: Update `createPermissionsTable` to match Permissions struct
* feat: Add database enum types
* feat: Add DIDNamespace and PermissionScope enums
* feat: Add DBConfig and DBOption types
* feat: Update the db implementation to use the provided go library
* fix: update db implementation to use go-sqlite3 v0.18.2
* fix: Refactor database connection and statement handling
* feat: Simplify db.go implementation
* feat: Convert constant SQL queries to functions in queries.go and update db.go to use prepared statements
* feat: Add models.go file with database table structs
* fix: Remove unused statement map and prepare statements
diff --git a/internal/db/db.go b/internal/db/db.go
index 201d09b..d4d4d4e 100644
--- a/internal/db/db.go
+++ b/internal/db/db.go
@@ -32,11 +32,6 @@ func Open(config *DBConfig) (*DB, error) {
Conn: conn,
}
- if err := createTables(db); err != nil {
- conn.Close()
- return nil, fmt.Errorf("failed to create tables: %w", err)
- }
-
return db, nil
}
@@ -61,114 +56,3 @@ func createTables(db *DB) error {
return nil
}
-// AddAccount adds a new account to the database
-func (db *DB) AddAccount(name, address string) error {
- return db.Exec(insertAccountQuery(name, address))
-}
-
-// AddAsset adds a new asset to the database
-func (db *DB) AddAsset(name, symbol string, decimals int, chainID int64) error {
- return db.Exec(insertAssetQuery(name, symbol, decimals, chainID))
-}
-
-// AddChain adds a new chain to the database
-func (db *DB) AddChain(name, networkID string) error {
- return db.Exec(insertChainQuery(name, networkID))
-}
-
-// AddCredential adds a new credential to the database
-func (db *DB) AddCredential(
- handle, controller, attestationType, origin string,
- credentialID, publicKey []byte,
- transport string,
- signCount uint32,
- userPresent, userVerified, backupEligible, backupState, cloneWarning bool,
-) error {
- return db.Exec(insertCredentialQuery(
- handle,
- controller,
- attestationType,
- origin,
- credentialID,
- publicKey,
- transport,
- signCount,
- userPresent,
- userVerified,
- backupEligible,
- backupState,
- cloneWarning,
- ))
-}
-
-// AddProfile adds a new profile to the database
-func (db *DB) AddProfile(
- id, subject, controller, originURI, publicMetadata, privateMetadata string,
-) error {
- return db.statements["insertProfile"].Exec(
- id, subject, controller, originURI, publicMetadata, privateMetadata,
- )
-}
-
-// AddProperty adds a new property to the database
-func (db *DB) AddProperty(
- profileID, key, accumulator, propertyKey string,
-) error {
- return db.statements["insertProperty"].Exec(
- profileID, key, accumulator, propertyKey,
- )
-}
-
-// AddPermission adds a new permission to the database
-func (db *DB) AddPermission(
- serviceID string,
- grants []DIDNamespace,
- scopes []PermissionScope,
-) error {
- grantsJSON, err := json.Marshal(grants)
- if err != nil {
- return fmt.Errorf("failed to marshal grants: %w", err)
- }
-
- scopesJSON, err := json.Marshal(scopes)
- if err != nil {
- return fmt.Errorf("failed to marshal scopes: %w", err)
- }
-
- return db.statements["insertPermission"].Exec(
- serviceID, string(grantsJSON), string(scopesJSON),
- )
-}
-
-// GetPermission retrieves the permission for the given service ID
-func (db *DB) GetPermission(serviceID string) ([]DIDNamespace, []PermissionScope, error) {
- row := db.statements["getPermission"].QueryRow(serviceID)
-
- var grantsJSON, scopesJSON string
- if err := row.Scan(&grantsJSON, &scopesJSON); err != nil {
- return nil, nil, fmt.Errorf("failed to get permission: %w", err)
- }
-
- var grants []DIDNamespace
- if err := json.Unmarshal([]byte(grantsJSON), &grants); err != nil {
- return nil, nil, fmt.Errorf("failed to unmarshal grants: %w", err)
- }
-
- var scopes []PermissionScope
- if err := json.Unmarshal([]byte(scopesJSON), &scopes); err != nil {
- return nil, nil, fmt.Errorf("failed to unmarshal scopes: %w", err)
- }
-
- return grants, scopes, nil
-}
-
-// Close closes the database connection and finalizes all prepared statements
-func (db *DB) Close() error {
- for _, stmt := range db.statements {
- stmt.Finalize()
- }
- return db.Conn.Close()
-}
diff --git a/internal/db/queries.go b/internal/db/queries.go
index 807d701..e69de29 100644
--- a/internal/db/queries.go
+++ b/internal/db/queries.go
@@ -1,79 +0,0 @@
-package db
-
-import "fmt"
-
-// Account queries
-func insertAccountQuery(name, address string) string {
- return fmt.Sprintf(`INSERT INTO accounts (name, address) VALUES (%s, %s)`, name, address)
-}
-
-// Asset queries
-func insertAssetQuery(name, symbol string, decimals int, chainID int64) string {
- return fmt.Sprintf(
- `INSERT INTO assets (name, symbol, decimals, chain_id) VALUES (%s, %s, %d, %d)`,
- name,
- symbol,
- decimals,
- chainID,
- )
-}
-
-// Chain queries
-func insertChainQuery(name string, networkID string) string {
- return fmt.Sprintf(`INSERT INTO chains (name, network_id) VALUES (%s, %d)`, name, networkID)
-}
-
-// Credential queries
-func insertCredentialQuery(
- handle, controller, attestationType, origin string,
- credentialID, publicKey []byte,
- transport string,
- signCount uint32,
- userPresent, userVerified, backupEligible, backupState, cloneWarning bool,
-) string {
- return fmt.Sprintf(`INSERT INTO credentials (
- handle, controller, attestation_type, origin,
- credential_id, public_key, transport, sign_count,
- user_present, user_verified, backup_eligible,
- backup_state, clone_warning
- ) VALUES (%s, %s, %s, %s, %s, %s, %s, %d, %t, %t, %t, %t, %t)`,
- handle, controller, attestationType, origin,
- credentialID, publicKey, transport, signCount,
- userPresent, userVerified, backupEligible,
- backupState, cloneWarning)
-}
-
-// Profile queries
-func insertProfileQuery(
- id, subject, controller, originURI, publicMetadata, privateMetadata string,
-) string {
- return fmt.Sprintf(`INSERT INTO profiles (
- id, subject, controller, origin_uri,
- public_metadata, private_metadata
- ) VALUES (%s, %s, %s, %s, %s, %s)`,
- id, subject, controller, originURI,
- publicMetadata, privateMetadata)
-}
-
-// Property queries
-func insertPropertyQuery(profileID, key, accumulator, propertyKey string) string {
- return fmt.Sprintf(`INSERT INTO properties (
- profile_id, key, accumulator, property_key
- ) VALUES (%s, %s, %s, %s)`,
- profileID, key, accumulator, propertyKey)
-}
-
-// Permission queries
-func insertPermissionQuery(serviceID, grants, scopes string) string {
- return fmt.Sprintf(
- `INSERT INTO permissions (service_id, grants, scopes) VALUES (%s, %s, %s)`,
- serviceID,
- grants,
- scopes,
- )
-}
-
-// GetPermission query
-func getPermissionQuery(serviceID string) string {
- return fmt.Sprintf(`SELECT grants, scopes FROM permissions WHERE service_id = %s`, serviceID)
-}
* fix: update Makefile to use sonrd instead of wasmd
* feat: Add targets for templ and vault in Makefile and use only make in devbox.json
* feat: add SQLite database support
* bump: version 0.6.0 → 0.7.0
* refactor: upgrade actions to latest versions
2024-09-05 01:24:57 -04:00
|
|
|
golang.org/x/crypto v0.26.0
|
2024-07-08 22:57:53 -04:00
|
|
|
google.golang.org/genproto/googleapis/api v0.0.0-20240617180043-68d350f18fd4
|
|
|
|
google.golang.org/grpc v1.64.0
|
|
|
|
google.golang.org/protobuf v1.34.2
|
2024-09-11 15:10:54 -04:00
|
|
|
gopkg.in/macaroon.v2 v2.1.0
|
2024-07-05 22:20:13 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
require (
|
2024-07-08 22:57:53 -04:00
|
|
|
cloud.google.com/go v0.112.1 // indirect
|
|
|
|
cloud.google.com/go/compute/metadata v0.3.0 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
cloud.google.com/go/iam v1.1.6 // indirect
|
2024-07-08 22:57:53 -04:00
|
|
|
cloud.google.com/go/storage v1.38.0 // indirect
|
2024-07-06 00:34:41 -04:00
|
|
|
filippo.io/edwards25519 v1.1.0 // indirect
|
2024-09-23 12:39:59 -04:00
|
|
|
git.sr.ht/~sircmpwn/go-bare v0.0.0-20210406120253-ab86bc2846d9 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
|
|
|
|
github.com/99designs/keyring v1.2.1 // indirect
|
|
|
|
github.com/DataDog/datadog-go v3.2.0+incompatible // indirect
|
|
|
|
github.com/DataDog/zstd v1.5.5 // indirect
|
|
|
|
github.com/alecthomas/units v0.0.0-20231202071711-9a357b53e9c9 // indirect
|
2024-09-05 16:38:44 -04:00
|
|
|
github.com/atotto/clipboard v0.1.4 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/aws/aws-sdk-go v1.44.224 // indirect
|
2024-09-05 16:38:44 -04:00
|
|
|
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/beorn7/perks v1.0.1 // indirect
|
|
|
|
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
|
|
|
|
github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect
|
|
|
|
github.com/bits-and-blooms/bitset v1.13.0 // indirect
|
|
|
|
github.com/blang/semver/v4 v4.0.0 // indirect
|
|
|
|
github.com/btcsuite/btcd/btcutil v1.1.5 // indirect
|
|
|
|
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect
|
2024-07-26 12:14:20 -04:00
|
|
|
github.com/bwesterb/go-ristretto v1.2.3 // indirect
|
2024-09-05 16:38:44 -04:00
|
|
|
github.com/catppuccin/go v0.2.0 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
|
|
|
|
github.com/cespare/xxhash v1.1.0 // indirect
|
|
|
|
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
2024-09-05 16:38:44 -04:00
|
|
|
github.com/charmbracelet/x/ansi v0.2.3 // indirect
|
|
|
|
github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 // indirect
|
|
|
|
github.com/charmbracelet/x/term v0.2.0 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/chzyer/readline v1.5.1 // indirect
|
|
|
|
github.com/cockroachdb/apd/v2 v2.0.2 // indirect
|
2024-07-06 00:34:41 -04:00
|
|
|
github.com/cockroachdb/errors v1.11.3 // indirect
|
|
|
|
github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
|
2024-07-06 00:34:41 -04:00
|
|
|
github.com/cockroachdb/pebble v1.1.1 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/cockroachdb/redact v1.1.5 // indirect
|
|
|
|
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
|
|
|
|
github.com/cometbft/cometbft-db v0.9.1 // indirect
|
2024-07-26 12:14:20 -04:00
|
|
|
github.com/consensys/bavard v0.1.13 // indirect
|
|
|
|
github.com/consensys/gnark-crypto v0.12.1 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/cosmos/go-bip39 v1.0.0 // indirect
|
|
|
|
github.com/cosmos/gogogateway v1.2.0 // indirect
|
2024-07-06 00:34:41 -04:00
|
|
|
github.com/cosmos/iavl v1.1.2 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/cosmos/ics23/go v0.10.0 // indirect
|
|
|
|
github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect
|
|
|
|
github.com/crackcomm/go-gitignore v0.0.0-20231225121904-e25f5bc08668 // indirect
|
|
|
|
github.com/creachadair/atomicfile v0.3.1 // indirect
|
|
|
|
github.com/creachadair/tomledit v0.0.24 // indirect
|
|
|
|
github.com/danieljoos/wincred v1.1.2 // indirect
|
|
|
|
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
|
|
|
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
|
|
|
|
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
|
|
|
|
github.com/dgraph-io/badger/v2 v2.2007.4 // indirect
|
|
|
|
github.com/dgraph-io/ristretto v0.1.1 // indirect
|
|
|
|
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect
|
|
|
|
github.com/dustin/go-humanize v1.0.1 // indirect
|
Feature/update dockerfile (#6)
* chore: remove unused new.Dockerfile
* feat: add DID model definitions
* fix: Fix EncodePublicKey method in KeyInfo struct
* feat: Update `EncodePublicKey` to be the inverse of `DecodePublicKey`
* refactor: update AssetInfo protobuf definition
* fix: update default assets with correct asset types
* fix: Initialize IPFS client and check for mounted directories
* feat: Improve IPFS client initialization and mount checking
* feat: Add local filesystem check for IPFS and IPNS
* fix: Use Unixfs().Get() instead of Cat() for IPFS and IPNS content retrieval
* feat: Update GetCID and GetIPNS functions to read data from IPFS node
* fix: Ensure IPFS client is initialized before pinning CID
* feat: Add AddFile and AddFolder methods
* feat: add IPFS file system abstraction
* feat: Implement IPFS file, location, and filesystem abstractions
* refactor: remove unused functions and types
* refactor: remove unused FileSystem interface
* feat: add initial wasm entrypoint
* feat: add basic vault command operations
* docs: add vault module features
* test: remove test for MsgUpdateParams
* refactor: Replace PrimaryKey with Property struct in zkprop.go
* feat: Update the `CreateWitness` and `CreateAccumulator` and `VerifyWitness` and `UpdateAccumulator` to Use the new `Accumulator` and `Witness` types. Then Clean up the code in the file and refactor the marshalling methods
* <no value>
* feat: add KeyCurve and KeyType to KeyInfo in genesis
* feat: add WASM build step to devbox.json
* feat: Add zkgate.go file
* feat: Uncomment and modify zkgate code to work with Property struct
* feat: Merge zkgate.go and zkprop.go logic
* feat: implement API endpoints for profile management
* refactor: remove unused template file
* feat(orm): remove unused ORM models
* feat: add persistent SQLite database support in WASM
* fix: Update module names in protobuf files
* feat: Add method to initialize SQLite database
* fix: update go-sqlite3 dependency to version 1.14.23
* feat: introduce database layer
* feat: Implement database layer for Vault node
* feature/update-dockerfile
* feat: Add keyshares table
* fix: Reorder the SQL statements in the tables.go file
* feat: Update the `createCredentialsTable` method to match the proper Credential struct
* feat: Update createProfilesTable and add createPropertiesTable
* feat: Add constant SQL queries to queries.go and use prepared statements in db.go
* feat: Add createKeysharesTable to internal/db/db.go
* feat: Update `createPermissionsTable` to match Permissions struct
* feat: Add database enum types
* feat: Add DIDNamespace and PermissionScope enums
* feat: Add DBConfig and DBOption types
* feat: Update the db implementation to use the provided go library
* fix: update db implementation to use go-sqlite3 v0.18.2
* fix: Refactor database connection and statement handling
* feat: Simplify db.go implementation
* feat: Convert constant SQL queries to functions in queries.go and update db.go to use prepared statements
* feat: Add models.go file with database table structs
* fix: Remove unused statement map and prepare statements
diff --git a/internal/db/db.go b/internal/db/db.go
index 201d09b..d4d4d4e 100644
--- a/internal/db/db.go
+++ b/internal/db/db.go
@@ -32,11 +32,6 @@ func Open(config *DBConfig) (*DB, error) {
Conn: conn,
}
- if err := createTables(db); err != nil {
- conn.Close()
- return nil, fmt.Errorf("failed to create tables: %w", err)
- }
-
return db, nil
}
@@ -61,114 +56,3 @@ func createTables(db *DB) error {
return nil
}
-// AddAccount adds a new account to the database
-func (db *DB) AddAccount(name, address string) error {
- return db.Exec(insertAccountQuery(name, address))
-}
-
-// AddAsset adds a new asset to the database
-func (db *DB) AddAsset(name, symbol string, decimals int, chainID int64) error {
- return db.Exec(insertAssetQuery(name, symbol, decimals, chainID))
-}
-
-// AddChain adds a new chain to the database
-func (db *DB) AddChain(name, networkID string) error {
- return db.Exec(insertChainQuery(name, networkID))
-}
-
-// AddCredential adds a new credential to the database
-func (db *DB) AddCredential(
- handle, controller, attestationType, origin string,
- credentialID, publicKey []byte,
- transport string,
- signCount uint32,
- userPresent, userVerified, backupEligible, backupState, cloneWarning bool,
-) error {
- return db.Exec(insertCredentialQuery(
- handle,
- controller,
- attestationType,
- origin,
- credentialID,
- publicKey,
- transport,
- signCount,
- userPresent,
- userVerified,
- backupEligible,
- backupState,
- cloneWarning,
- ))
-}
-
-// AddProfile adds a new profile to the database
-func (db *DB) AddProfile(
- id, subject, controller, originURI, publicMetadata, privateMetadata string,
-) error {
- return db.statements["insertProfile"].Exec(
- id, subject, controller, originURI, publicMetadata, privateMetadata,
- )
-}
-
-// AddProperty adds a new property to the database
-func (db *DB) AddProperty(
- profileID, key, accumulator, propertyKey string,
-) error {
- return db.statements["insertProperty"].Exec(
- profileID, key, accumulator, propertyKey,
- )
-}
-
-// AddPermission adds a new permission to the database
-func (db *DB) AddPermission(
- serviceID string,
- grants []DIDNamespace,
- scopes []PermissionScope,
-) error {
- grantsJSON, err := json.Marshal(grants)
- if err != nil {
- return fmt.Errorf("failed to marshal grants: %w", err)
- }
-
- scopesJSON, err := json.Marshal(scopes)
- if err != nil {
- return fmt.Errorf("failed to marshal scopes: %w", err)
- }
-
- return db.statements["insertPermission"].Exec(
- serviceID, string(grantsJSON), string(scopesJSON),
- )
-}
-
-// GetPermission retrieves the permission for the given service ID
-func (db *DB) GetPermission(serviceID string) ([]DIDNamespace, []PermissionScope, error) {
- row := db.statements["getPermission"].QueryRow(serviceID)
-
- var grantsJSON, scopesJSON string
- if err := row.Scan(&grantsJSON, &scopesJSON); err != nil {
- return nil, nil, fmt.Errorf("failed to get permission: %w", err)
- }
-
- var grants []DIDNamespace
- if err := json.Unmarshal([]byte(grantsJSON), &grants); err != nil {
- return nil, nil, fmt.Errorf("failed to unmarshal grants: %w", err)
- }
-
- var scopes []PermissionScope
- if err := json.Unmarshal([]byte(scopesJSON), &scopes); err != nil {
- return nil, nil, fmt.Errorf("failed to unmarshal scopes: %w", err)
- }
-
- return grants, scopes, nil
-}
-
-// Close closes the database connection and finalizes all prepared statements
-func (db *DB) Close() error {
- for _, stmt := range db.statements {
- stmt.Finalize()
- }
- return db.Conn.Close()
-}
diff --git a/internal/db/queries.go b/internal/db/queries.go
index 807d701..e69de29 100644
--- a/internal/db/queries.go
+++ b/internal/db/queries.go
@@ -1,79 +0,0 @@
-package db
-
-import "fmt"
-
-// Account queries
-func insertAccountQuery(name, address string) string {
- return fmt.Sprintf(`INSERT INTO accounts (name, address) VALUES (%s, %s)`, name, address)
-}
-
-// Asset queries
-func insertAssetQuery(name, symbol string, decimals int, chainID int64) string {
- return fmt.Sprintf(
- `INSERT INTO assets (name, symbol, decimals, chain_id) VALUES (%s, %s, %d, %d)`,
- name,
- symbol,
- decimals,
- chainID,
- )
-}
-
-// Chain queries
-func insertChainQuery(name string, networkID string) string {
- return fmt.Sprintf(`INSERT INTO chains (name, network_id) VALUES (%s, %d)`, name, networkID)
-}
-
-// Credential queries
-func insertCredentialQuery(
- handle, controller, attestationType, origin string,
- credentialID, publicKey []byte,
- transport string,
- signCount uint32,
- userPresent, userVerified, backupEligible, backupState, cloneWarning bool,
-) string {
- return fmt.Sprintf(`INSERT INTO credentials (
- handle, controller, attestation_type, origin,
- credential_id, public_key, transport, sign_count,
- user_present, user_verified, backup_eligible,
- backup_state, clone_warning
- ) VALUES (%s, %s, %s, %s, %s, %s, %s, %d, %t, %t, %t, %t, %t)`,
- handle, controller, attestationType, origin,
- credentialID, publicKey, transport, signCount,
- userPresent, userVerified, backupEligible,
- backupState, cloneWarning)
-}
-
-// Profile queries
-func insertProfileQuery(
- id, subject, controller, originURI, publicMetadata, privateMetadata string,
-) string {
- return fmt.Sprintf(`INSERT INTO profiles (
- id, subject, controller, origin_uri,
- public_metadata, private_metadata
- ) VALUES (%s, %s, %s, %s, %s, %s)`,
- id, subject, controller, originURI,
- publicMetadata, privateMetadata)
-}
-
-// Property queries
-func insertPropertyQuery(profileID, key, accumulator, propertyKey string) string {
- return fmt.Sprintf(`INSERT INTO properties (
- profile_id, key, accumulator, property_key
- ) VALUES (%s, %s, %s, %s)`,
- profileID, key, accumulator, propertyKey)
-}
-
-// Permission queries
-func insertPermissionQuery(serviceID, grants, scopes string) string {
- return fmt.Sprintf(
- `INSERT INTO permissions (service_id, grants, scopes) VALUES (%s, %s, %s)`,
- serviceID,
- grants,
- scopes,
- )
-}
-
-// GetPermission query
-func getPermissionQuery(serviceID string) string {
- return fmt.Sprintf(`SELECT grants, scopes FROM permissions WHERE service_id = %s`, serviceID)
-}
* fix: update Makefile to use sonrd instead of wasmd
* feat: Add targets for templ and vault in Makefile and use only make in devbox.json
* feat: add SQLite database support
* bump: version 0.6.0 → 0.7.0
* refactor: upgrade actions to latest versions
2024-09-05 01:24:57 -04:00
|
|
|
github.com/dustinxie/ecc v0.0.0-20210511000915-959544187564 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/dvsekhvalnov/jose2go v1.6.0 // indirect
|
|
|
|
github.com/emicklei/dot v1.6.1 // indirect
|
2024-09-05 16:38:44 -04:00
|
|
|
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/facebookgo/atomicfile v0.0.0-20151019160806-2de1f203e7d5 // indirect
|
|
|
|
github.com/fatih/color v1.16.0 // indirect
|
|
|
|
github.com/felixge/httpsnoop v1.0.4 // indirect
|
|
|
|
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
|
|
|
github.com/fxamacker/cbor/v2 v2.6.0 // indirect
|
|
|
|
github.com/getsentry/sentry-go v0.27.0 // indirect
|
|
|
|
github.com/go-kit/kit v0.12.0 // indirect
|
|
|
|
github.com/go-kit/log v0.2.1 // indirect
|
|
|
|
github.com/go-logfmt/logfmt v0.6.0 // indirect
|
2024-07-08 22:57:53 -04:00
|
|
|
github.com/go-logr/logr v1.4.2 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/go-logr/stdr v1.2.2 // indirect
|
|
|
|
github.com/go-webauthn/x v0.1.9 // indirect
|
|
|
|
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
|
|
|
|
github.com/gogo/googleapis v1.4.1 // indirect
|
|
|
|
github.com/gogo/protobuf v1.3.2 // indirect
|
|
|
|
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
|
|
|
|
github.com/golang/glog v1.2.0 // indirect
|
|
|
|
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
|
|
|
github.com/golang/mock v1.6.0 // indirect
|
|
|
|
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
|
|
|
|
github.com/google/btree v1.1.2 // indirect
|
|
|
|
github.com/google/go-cmp v0.6.0 // indirect
|
|
|
|
github.com/google/go-tpm v0.9.0 // indirect
|
|
|
|
github.com/google/gopacket v1.1.19 // indirect
|
|
|
|
github.com/google/orderedcode v0.0.1 // indirect
|
|
|
|
github.com/google/s2a-go v0.1.7 // indirect
|
|
|
|
github.com/google/uuid v1.6.0 // indirect
|
|
|
|
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
|
2024-07-08 22:57:53 -04:00
|
|
|
github.com/googleapis/gax-go/v2 v2.12.2 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/gorilla/handlers v1.5.2 // indirect
|
2024-09-14 12:47:25 -04:00
|
|
|
github.com/gorilla/mux v1.8.1 // indirect
|
2024-07-08 22:57:53 -04:00
|
|
|
github.com/gorilla/websocket v1.5.3 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
|
|
|
|
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
|
2024-09-11 15:10:54 -04:00
|
|
|
github.com/gtank/merlin v0.1.1 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/hashicorp/errwrap v1.1.0 // indirect
|
|
|
|
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
|
|
|
|
github.com/hashicorp/go-getter v1.7.5 // indirect
|
|
|
|
github.com/hashicorp/go-hclog v1.5.0 // indirect
|
|
|
|
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
|
2024-07-06 00:34:41 -04:00
|
|
|
github.com/hashicorp/go-metrics v0.5.3 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
|
|
|
github.com/hashicorp/go-plugin v1.5.2 // indirect
|
|
|
|
github.com/hashicorp/go-safetemp v1.0.0 // indirect
|
|
|
|
github.com/hashicorp/go-version v1.6.0 // indirect
|
|
|
|
github.com/hashicorp/golang-lru v1.0.2 // indirect
|
|
|
|
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
|
|
|
|
github.com/hashicorp/hcl v1.0.0 // indirect
|
|
|
|
github.com/hashicorp/yamux v0.1.1 // indirect
|
|
|
|
github.com/hdevalence/ed25519consensus v0.1.0 // indirect
|
2024-09-14 12:47:25 -04:00
|
|
|
github.com/holiman/uint256 v1.2.4 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/huandu/skiplist v1.2.0 // indirect
|
|
|
|
github.com/iancoleman/orderedmap v0.3.0 // indirect
|
|
|
|
github.com/iancoleman/strcase v0.3.0 // indirect
|
|
|
|
github.com/improbable-eng/grpc-web v0.15.0 // indirect
|
|
|
|
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
|
|
|
github.com/ipfs/bbloom v0.0.4 // indirect
|
|
|
|
github.com/ipfs/go-bitfield v1.1.0 // indirect
|
|
|
|
github.com/ipfs/go-block-format v0.2.0 // indirect
|
2024-07-06 00:34:41 -04:00
|
|
|
github.com/ipfs/go-cid v0.4.1 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/ipfs/go-datastore v0.6.0 // indirect
|
|
|
|
github.com/ipfs/go-ds-measure v0.2.0 // indirect
|
|
|
|
github.com/ipfs/go-fs-lock v0.0.7 // indirect
|
2024-07-08 22:57:53 -04:00
|
|
|
github.com/ipfs/go-ipfs-cmds v0.11.0 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/ipfs/go-ipfs-util v0.0.3 // indirect
|
|
|
|
github.com/ipfs/go-ipld-cbor v0.1.0 // indirect
|
|
|
|
github.com/ipfs/go-ipld-format v0.6.0 // indirect
|
|
|
|
github.com/ipfs/go-ipld-legacy v0.2.1 // indirect
|
|
|
|
github.com/ipfs/go-log v1.0.5 // indirect
|
|
|
|
github.com/ipfs/go-log/v2 v2.5.1 // indirect
|
|
|
|
github.com/ipfs/go-metrics-interface v0.0.1 // indirect
|
|
|
|
github.com/ipfs/go-unixfsnode v1.9.0 // indirect
|
|
|
|
github.com/ipld/go-car/v2 v2.13.1 // indirect
|
|
|
|
github.com/ipld/go-codec-dagpb v1.6.0 // indirect
|
|
|
|
github.com/ipld/go-ipld-prime v0.21.0 // indirect
|
|
|
|
github.com/jbenet/goprocess v0.1.4 // indirect
|
2024-09-23 12:39:59 -04:00
|
|
|
github.com/jinzhu/inflection v1.0.0 // indirect
|
|
|
|
github.com/jinzhu/now v1.1.5 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
|
|
|
github.com/jmhodges/levigo v1.0.0 // indirect
|
2024-07-08 22:57:53 -04:00
|
|
|
github.com/klauspost/compress v1.17.9 // indirect
|
|
|
|
github.com/klauspost/cpuid/v2 v2.2.8 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/kr/pretty v0.3.1 // indirect
|
|
|
|
github.com/kr/text v0.2.0 // indirect
|
2024-09-07 18:12:58 -04:00
|
|
|
github.com/labstack/gommon v0.4.0 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/lib/pq v1.10.7 // indirect
|
|
|
|
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
|
|
|
|
github.com/libp2p/go-cidranger v1.1.0 // indirect
|
2024-07-08 22:57:53 -04:00
|
|
|
github.com/libp2p/go-libp2p v0.35.1 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/libp2p/go-libp2p-asn-util v0.4.1 // indirect
|
|
|
|
github.com/libp2p/go-libp2p-kad-dht v0.25.2 // indirect
|
|
|
|
github.com/libp2p/go-libp2p-kbucket v0.6.3 // indirect
|
|
|
|
github.com/libp2p/go-libp2p-record v0.2.0 // indirect
|
|
|
|
github.com/libp2p/go-libp2p-routing-helpers v0.7.3 // indirect
|
|
|
|
github.com/libp2p/go-msgio v0.3.0 // indirect
|
|
|
|
github.com/libp2p/go-netroute v0.2.1 // indirect
|
2024-07-06 00:34:41 -04:00
|
|
|
github.com/linxGnu/grocksdb v1.8.14 // indirect
|
2024-09-05 16:38:44 -04:00
|
|
|
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/magiconair/properties v1.8.7 // indirect
|
|
|
|
github.com/manifoldco/promptui v0.9.0 // indirect
|
|
|
|
github.com/mattn/go-colorable v0.1.13 // indirect
|
|
|
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
2024-09-05 16:38:44 -04:00
|
|
|
github.com/mattn/go-localereader v0.0.1 // indirect
|
|
|
|
github.com/mattn/go-runewidth v0.0.16 // indirect
|
2024-07-08 22:57:53 -04:00
|
|
|
github.com/miekg/dns v1.1.61 // indirect
|
2024-09-11 15:10:54 -04:00
|
|
|
github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/minio/highwayhash v1.0.2 // indirect
|
|
|
|
github.com/minio/sha256-simd v1.0.1 // indirect
|
|
|
|
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
|
|
|
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
|
2024-09-05 16:38:44 -04:00
|
|
|
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
2024-07-26 12:14:20 -04:00
|
|
|
github.com/mmcloughlin/addchain v0.4.0 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/mtibben/percent v0.2.1 // indirect
|
2024-09-05 16:38:44 -04:00
|
|
|
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
|
|
|
|
github.com/muesli/cancelreader v0.2.2 // indirect
|
|
|
|
github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/multiformats/go-base32 v0.1.0 // indirect
|
|
|
|
github.com/multiformats/go-base36 v0.2.0 // indirect
|
2024-07-08 22:57:53 -04:00
|
|
|
github.com/multiformats/go-multiaddr v0.12.4 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/multiformats/go-multiaddr-dns v0.3.1 // indirect
|
|
|
|
github.com/multiformats/go-multibase v0.2.0 // indirect
|
|
|
|
github.com/multiformats/go-multicodec v0.9.0 // indirect
|
|
|
|
github.com/multiformats/go-multihash v0.2.3 // indirect
|
|
|
|
github.com/multiformats/go-multistream v0.5.0 // indirect
|
|
|
|
github.com/multiformats/go-varint v0.0.7 // indirect
|
2024-09-23 12:39:59 -04:00
|
|
|
github.com/ncruces/julianday v1.0.0 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect
|
|
|
|
github.com/oklog/run v1.1.0 // indirect
|
2024-07-08 22:57:53 -04:00
|
|
|
github.com/onsi/ginkgo v1.16.5 // indirect
|
|
|
|
github.com/onsi/gomega v1.33.1 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/opentracing/opentracing-go v1.2.0 // indirect
|
|
|
|
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
|
|
|
|
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
|
|
|
|
github.com/petar/GoLLRB v0.0.0-20210522233825-ae3b015fd3e9 // indirect
|
2024-07-06 00:34:41 -04:00
|
|
|
github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect
|
|
|
|
github.com/pkg/errors v0.9.1 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
|
|
|
github.com/polydawn/refmt v0.89.0 // indirect
|
2024-07-08 22:57:53 -04:00
|
|
|
github.com/prometheus/client_golang v1.19.1 // indirect
|
2024-07-06 00:34:41 -04:00
|
|
|
github.com/prometheus/client_model v0.6.1 // indirect
|
2024-07-08 22:57:53 -04:00
|
|
|
github.com/prometheus/common v0.54.0 // indirect
|
|
|
|
github.com/prometheus/procfs v0.15.1 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
|
2024-09-05 16:38:44 -04:00
|
|
|
github.com/rivo/uniseg v0.4.7 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/rogpeppe/go-internal v1.12.0 // indirect
|
|
|
|
github.com/rs/cors v1.11.0 // indirect
|
|
|
|
github.com/rs/zerolog v1.32.0 // indirect
|
|
|
|
github.com/sagikazarmark/locafero v0.4.0 // indirect
|
|
|
|
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
|
|
|
|
github.com/samber/lo v1.39.0 // indirect
|
|
|
|
github.com/sasha-s/go-deadlock v0.3.1 // indirect
|
|
|
|
github.com/sourcegraph/conc v0.3.0 // indirect
|
|
|
|
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
|
|
|
github.com/spf13/afero v1.11.0 // indirect
|
|
|
|
github.com/subosito/gotenv v1.6.0 // indirect
|
|
|
|
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
|
|
|
|
github.com/tendermint/go-amino v0.16.0 // indirect
|
2024-09-23 12:39:59 -04:00
|
|
|
github.com/tetratelabs/wazero v1.8.0 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/tidwall/btree v1.7.0 // indirect
|
|
|
|
github.com/ulikunitz/xz v0.5.11 // indirect
|
2024-09-07 18:12:58 -04:00
|
|
|
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
|
|
|
github.com/valyala/fasttemplate v1.2.2 // indirect
|
2024-09-05 18:37:38 -04:00
|
|
|
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
|
|
|
|
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/whyrusleeping/base32 v0.0.0-20170828182744-c30ac30633cc // indirect
|
|
|
|
github.com/whyrusleeping/cbor v0.0.0-20171005072247-63513f603b11 // indirect
|
2024-07-08 22:57:53 -04:00
|
|
|
github.com/whyrusleeping/cbor-gen v0.1.2 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 // indirect
|
|
|
|
github.com/x448/float16 v0.8.4 // indirect
|
|
|
|
github.com/zondax/hid v0.9.2 // indirect
|
|
|
|
github.com/zondax/ledger-go v0.14.3 // indirect
|
|
|
|
go.etcd.io/bbolt v1.3.8 // indirect
|
|
|
|
go.opencensus.io v0.24.0 // indirect
|
2024-07-08 22:57:53 -04:00
|
|
|
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect
|
|
|
|
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.52.0 // indirect
|
|
|
|
go.opentelemetry.io/otel v1.27.0 // indirect
|
|
|
|
go.opentelemetry.io/otel/metric v1.27.0 // indirect
|
|
|
|
go.opentelemetry.io/otel/trace v1.27.0 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
go.uber.org/multierr v1.11.0 // indirect
|
|
|
|
go.uber.org/zap v1.27.0 // indirect
|
|
|
|
go4.org v0.0.0-20230225012048-214862532bf5 // indirect
|
2024-07-08 22:57:53 -04:00
|
|
|
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect
|
Feature/update dockerfile (#6)
* chore: remove unused new.Dockerfile
* feat: add DID model definitions
* fix: Fix EncodePublicKey method in KeyInfo struct
* feat: Update `EncodePublicKey` to be the inverse of `DecodePublicKey`
* refactor: update AssetInfo protobuf definition
* fix: update default assets with correct asset types
* fix: Initialize IPFS client and check for mounted directories
* feat: Improve IPFS client initialization and mount checking
* feat: Add local filesystem check for IPFS and IPNS
* fix: Use Unixfs().Get() instead of Cat() for IPFS and IPNS content retrieval
* feat: Update GetCID and GetIPNS functions to read data from IPFS node
* fix: Ensure IPFS client is initialized before pinning CID
* feat: Add AddFile and AddFolder methods
* feat: add IPFS file system abstraction
* feat: Implement IPFS file, location, and filesystem abstractions
* refactor: remove unused functions and types
* refactor: remove unused FileSystem interface
* feat: add initial wasm entrypoint
* feat: add basic vault command operations
* docs: add vault module features
* test: remove test for MsgUpdateParams
* refactor: Replace PrimaryKey with Property struct in zkprop.go
* feat: Update the `CreateWitness` and `CreateAccumulator` and `VerifyWitness` and `UpdateAccumulator` to Use the new `Accumulator` and `Witness` types. Then Clean up the code in the file and refactor the marshalling methods
* <no value>
* feat: add KeyCurve and KeyType to KeyInfo in genesis
* feat: add WASM build step to devbox.json
* feat: Add zkgate.go file
* feat: Uncomment and modify zkgate code to work with Property struct
* feat: Merge zkgate.go and zkprop.go logic
* feat: implement API endpoints for profile management
* refactor: remove unused template file
* feat(orm): remove unused ORM models
* feat: add persistent SQLite database support in WASM
* fix: Update module names in protobuf files
* feat: Add method to initialize SQLite database
* fix: update go-sqlite3 dependency to version 1.14.23
* feat: introduce database layer
* feat: Implement database layer for Vault node
* feature/update-dockerfile
* feat: Add keyshares table
* fix: Reorder the SQL statements in the tables.go file
* feat: Update the `createCredentialsTable` method to match the proper Credential struct
* feat: Update createProfilesTable and add createPropertiesTable
* feat: Add constant SQL queries to queries.go and use prepared statements in db.go
* feat: Add createKeysharesTable to internal/db/db.go
* feat: Update `createPermissionsTable` to match Permissions struct
* feat: Add database enum types
* feat: Add DIDNamespace and PermissionScope enums
* feat: Add DBConfig and DBOption types
* feat: Update the db implementation to use the provided go library
* fix: update db implementation to use go-sqlite3 v0.18.2
* fix: Refactor database connection and statement handling
* feat: Simplify db.go implementation
* feat: Convert constant SQL queries to functions in queries.go and update db.go to use prepared statements
* feat: Add models.go file with database table structs
* fix: Remove unused statement map and prepare statements
diff --git a/internal/db/db.go b/internal/db/db.go
index 201d09b..d4d4d4e 100644
--- a/internal/db/db.go
+++ b/internal/db/db.go
@@ -32,11 +32,6 @@ func Open(config *DBConfig) (*DB, error) {
Conn: conn,
}
- if err := createTables(db); err != nil {
- conn.Close()
- return nil, fmt.Errorf("failed to create tables: %w", err)
- }
-
return db, nil
}
@@ -61,114 +56,3 @@ func createTables(db *DB) error {
return nil
}
-// AddAccount adds a new account to the database
-func (db *DB) AddAccount(name, address string) error {
- return db.Exec(insertAccountQuery(name, address))
-}
-
-// AddAsset adds a new asset to the database
-func (db *DB) AddAsset(name, symbol string, decimals int, chainID int64) error {
- return db.Exec(insertAssetQuery(name, symbol, decimals, chainID))
-}
-
-// AddChain adds a new chain to the database
-func (db *DB) AddChain(name, networkID string) error {
- return db.Exec(insertChainQuery(name, networkID))
-}
-
-// AddCredential adds a new credential to the database
-func (db *DB) AddCredential(
- handle, controller, attestationType, origin string,
- credentialID, publicKey []byte,
- transport string,
- signCount uint32,
- userPresent, userVerified, backupEligible, backupState, cloneWarning bool,
-) error {
- return db.Exec(insertCredentialQuery(
- handle,
- controller,
- attestationType,
- origin,
- credentialID,
- publicKey,
- transport,
- signCount,
- userPresent,
- userVerified,
- backupEligible,
- backupState,
- cloneWarning,
- ))
-}
-
-// AddProfile adds a new profile to the database
-func (db *DB) AddProfile(
- id, subject, controller, originURI, publicMetadata, privateMetadata string,
-) error {
- return db.statements["insertProfile"].Exec(
- id, subject, controller, originURI, publicMetadata, privateMetadata,
- )
-}
-
-// AddProperty adds a new property to the database
-func (db *DB) AddProperty(
- profileID, key, accumulator, propertyKey string,
-) error {
- return db.statements["insertProperty"].Exec(
- profileID, key, accumulator, propertyKey,
- )
-}
-
-// AddPermission adds a new permission to the database
-func (db *DB) AddPermission(
- serviceID string,
- grants []DIDNamespace,
- scopes []PermissionScope,
-) error {
- grantsJSON, err := json.Marshal(grants)
- if err != nil {
- return fmt.Errorf("failed to marshal grants: %w", err)
- }
-
- scopesJSON, err := json.Marshal(scopes)
- if err != nil {
- return fmt.Errorf("failed to marshal scopes: %w", err)
- }
-
- return db.statements["insertPermission"].Exec(
- serviceID, string(grantsJSON), string(scopesJSON),
- )
-}
-
-// GetPermission retrieves the permission for the given service ID
-func (db *DB) GetPermission(serviceID string) ([]DIDNamespace, []PermissionScope, error) {
- row := db.statements["getPermission"].QueryRow(serviceID)
-
- var grantsJSON, scopesJSON string
- if err := row.Scan(&grantsJSON, &scopesJSON); err != nil {
- return nil, nil, fmt.Errorf("failed to get permission: %w", err)
- }
-
- var grants []DIDNamespace
- if err := json.Unmarshal([]byte(grantsJSON), &grants); err != nil {
- return nil, nil, fmt.Errorf("failed to unmarshal grants: %w", err)
- }
-
- var scopes []PermissionScope
- if err := json.Unmarshal([]byte(scopesJSON), &scopes); err != nil {
- return nil, nil, fmt.Errorf("failed to unmarshal scopes: %w", err)
- }
-
- return grants, scopes, nil
-}
-
-// Close closes the database connection and finalizes all prepared statements
-func (db *DB) Close() error {
- for _, stmt := range db.statements {
- stmt.Finalize()
- }
- return db.Conn.Close()
-}
diff --git a/internal/db/queries.go b/internal/db/queries.go
index 807d701..e69de29 100644
--- a/internal/db/queries.go
+++ b/internal/db/queries.go
@@ -1,79 +0,0 @@
-package db
-
-import "fmt"
-
-// Account queries
-func insertAccountQuery(name, address string) string {
- return fmt.Sprintf(`INSERT INTO accounts (name, address) VALUES (%s, %s)`, name, address)
-}
-
-// Asset queries
-func insertAssetQuery(name, symbol string, decimals int, chainID int64) string {
- return fmt.Sprintf(
- `INSERT INTO assets (name, symbol, decimals, chain_id) VALUES (%s, %s, %d, %d)`,
- name,
- symbol,
- decimals,
- chainID,
- )
-}
-
-// Chain queries
-func insertChainQuery(name string, networkID string) string {
- return fmt.Sprintf(`INSERT INTO chains (name, network_id) VALUES (%s, %d)`, name, networkID)
-}
-
-// Credential queries
-func insertCredentialQuery(
- handle, controller, attestationType, origin string,
- credentialID, publicKey []byte,
- transport string,
- signCount uint32,
- userPresent, userVerified, backupEligible, backupState, cloneWarning bool,
-) string {
- return fmt.Sprintf(`INSERT INTO credentials (
- handle, controller, attestation_type, origin,
- credential_id, public_key, transport, sign_count,
- user_present, user_verified, backup_eligible,
- backup_state, clone_warning
- ) VALUES (%s, %s, %s, %s, %s, %s, %s, %d, %t, %t, %t, %t, %t)`,
- handle, controller, attestationType, origin,
- credentialID, publicKey, transport, signCount,
- userPresent, userVerified, backupEligible,
- backupState, cloneWarning)
-}
-
-// Profile queries
-func insertProfileQuery(
- id, subject, controller, originURI, publicMetadata, privateMetadata string,
-) string {
- return fmt.Sprintf(`INSERT INTO profiles (
- id, subject, controller, origin_uri,
- public_metadata, private_metadata
- ) VALUES (%s, %s, %s, %s, %s, %s)`,
- id, subject, controller, originURI,
- publicMetadata, privateMetadata)
-}
-
-// Property queries
-func insertPropertyQuery(profileID, key, accumulator, propertyKey string) string {
- return fmt.Sprintf(`INSERT INTO properties (
- profile_id, key, accumulator, property_key
- ) VALUES (%s, %s, %s, %s)`,
- profileID, key, accumulator, propertyKey)
-}
-
-// Permission queries
-func insertPermissionQuery(serviceID, grants, scopes string) string {
- return fmt.Sprintf(
- `INSERT INTO permissions (service_id, grants, scopes) VALUES (%s, %s, %s)`,
- serviceID,
- grants,
- scopes,
- )
-}
-
-// GetPermission query
-func getPermissionQuery(serviceID string) string {
- return fmt.Sprintf(`SELECT grants, scopes FROM permissions WHERE service_id = %s`, serviceID)
-}
* fix: update Makefile to use sonrd instead of wasmd
* feat: Add targets for templ and vault in Makefile and use only make in devbox.json
* feat: add SQLite database support
* bump: version 0.6.0 → 0.7.0
* refactor: upgrade actions to latest versions
2024-09-05 01:24:57 -04:00
|
|
|
golang.org/x/mod v0.20.0 // indirect
|
|
|
|
golang.org/x/net v0.28.0 // indirect
|
2024-07-08 22:57:53 -04:00
|
|
|
golang.org/x/oauth2 v0.21.0 // indirect
|
Feature/update dockerfile (#6)
* chore: remove unused new.Dockerfile
* feat: add DID model definitions
* fix: Fix EncodePublicKey method in KeyInfo struct
* feat: Update `EncodePublicKey` to be the inverse of `DecodePublicKey`
* refactor: update AssetInfo protobuf definition
* fix: update default assets with correct asset types
* fix: Initialize IPFS client and check for mounted directories
* feat: Improve IPFS client initialization and mount checking
* feat: Add local filesystem check for IPFS and IPNS
* fix: Use Unixfs().Get() instead of Cat() for IPFS and IPNS content retrieval
* feat: Update GetCID and GetIPNS functions to read data from IPFS node
* fix: Ensure IPFS client is initialized before pinning CID
* feat: Add AddFile and AddFolder methods
* feat: add IPFS file system abstraction
* feat: Implement IPFS file, location, and filesystem abstractions
* refactor: remove unused functions and types
* refactor: remove unused FileSystem interface
* feat: add initial wasm entrypoint
* feat: add basic vault command operations
* docs: add vault module features
* test: remove test for MsgUpdateParams
* refactor: Replace PrimaryKey with Property struct in zkprop.go
* feat: Update the `CreateWitness` and `CreateAccumulator` and `VerifyWitness` and `UpdateAccumulator` to Use the new `Accumulator` and `Witness` types. Then Clean up the code in the file and refactor the marshalling methods
* <no value>
* feat: add KeyCurve and KeyType to KeyInfo in genesis
* feat: add WASM build step to devbox.json
* feat: Add zkgate.go file
* feat: Uncomment and modify zkgate code to work with Property struct
* feat: Merge zkgate.go and zkprop.go logic
* feat: implement API endpoints for profile management
* refactor: remove unused template file
* feat(orm): remove unused ORM models
* feat: add persistent SQLite database support in WASM
* fix: Update module names in protobuf files
* feat: Add method to initialize SQLite database
* fix: update go-sqlite3 dependency to version 1.14.23
* feat: introduce database layer
* feat: Implement database layer for Vault node
* feature/update-dockerfile
* feat: Add keyshares table
* fix: Reorder the SQL statements in the tables.go file
* feat: Update the `createCredentialsTable` method to match the proper Credential struct
* feat: Update createProfilesTable and add createPropertiesTable
* feat: Add constant SQL queries to queries.go and use prepared statements in db.go
* feat: Add createKeysharesTable to internal/db/db.go
* feat: Update `createPermissionsTable` to match Permissions struct
* feat: Add database enum types
* feat: Add DIDNamespace and PermissionScope enums
* feat: Add DBConfig and DBOption types
* feat: Update the db implementation to use the provided go library
* fix: update db implementation to use go-sqlite3 v0.18.2
* fix: Refactor database connection and statement handling
* feat: Simplify db.go implementation
* feat: Convert constant SQL queries to functions in queries.go and update db.go to use prepared statements
* feat: Add models.go file with database table structs
* fix: Remove unused statement map and prepare statements
diff --git a/internal/db/db.go b/internal/db/db.go
index 201d09b..d4d4d4e 100644
--- a/internal/db/db.go
+++ b/internal/db/db.go
@@ -32,11 +32,6 @@ func Open(config *DBConfig) (*DB, error) {
Conn: conn,
}
- if err := createTables(db); err != nil {
- conn.Close()
- return nil, fmt.Errorf("failed to create tables: %w", err)
- }
-
return db, nil
}
@@ -61,114 +56,3 @@ func createTables(db *DB) error {
return nil
}
-// AddAccount adds a new account to the database
-func (db *DB) AddAccount(name, address string) error {
- return db.Exec(insertAccountQuery(name, address))
-}
-
-// AddAsset adds a new asset to the database
-func (db *DB) AddAsset(name, symbol string, decimals int, chainID int64) error {
- return db.Exec(insertAssetQuery(name, symbol, decimals, chainID))
-}
-
-// AddChain adds a new chain to the database
-func (db *DB) AddChain(name, networkID string) error {
- return db.Exec(insertChainQuery(name, networkID))
-}
-
-// AddCredential adds a new credential to the database
-func (db *DB) AddCredential(
- handle, controller, attestationType, origin string,
- credentialID, publicKey []byte,
- transport string,
- signCount uint32,
- userPresent, userVerified, backupEligible, backupState, cloneWarning bool,
-) error {
- return db.Exec(insertCredentialQuery(
- handle,
- controller,
- attestationType,
- origin,
- credentialID,
- publicKey,
- transport,
- signCount,
- userPresent,
- userVerified,
- backupEligible,
- backupState,
- cloneWarning,
- ))
-}
-
-// AddProfile adds a new profile to the database
-func (db *DB) AddProfile(
- id, subject, controller, originURI, publicMetadata, privateMetadata string,
-) error {
- return db.statements["insertProfile"].Exec(
- id, subject, controller, originURI, publicMetadata, privateMetadata,
- )
-}
-
-// AddProperty adds a new property to the database
-func (db *DB) AddProperty(
- profileID, key, accumulator, propertyKey string,
-) error {
- return db.statements["insertProperty"].Exec(
- profileID, key, accumulator, propertyKey,
- )
-}
-
-// AddPermission adds a new permission to the database
-func (db *DB) AddPermission(
- serviceID string,
- grants []DIDNamespace,
- scopes []PermissionScope,
-) error {
- grantsJSON, err := json.Marshal(grants)
- if err != nil {
- return fmt.Errorf("failed to marshal grants: %w", err)
- }
-
- scopesJSON, err := json.Marshal(scopes)
- if err != nil {
- return fmt.Errorf("failed to marshal scopes: %w", err)
- }
-
- return db.statements["insertPermission"].Exec(
- serviceID, string(grantsJSON), string(scopesJSON),
- )
-}
-
-// GetPermission retrieves the permission for the given service ID
-func (db *DB) GetPermission(serviceID string) ([]DIDNamespace, []PermissionScope, error) {
- row := db.statements["getPermission"].QueryRow(serviceID)
-
- var grantsJSON, scopesJSON string
- if err := row.Scan(&grantsJSON, &scopesJSON); err != nil {
- return nil, nil, fmt.Errorf("failed to get permission: %w", err)
- }
-
- var grants []DIDNamespace
- if err := json.Unmarshal([]byte(grantsJSON), &grants); err != nil {
- return nil, nil, fmt.Errorf("failed to unmarshal grants: %w", err)
- }
-
- var scopes []PermissionScope
- if err := json.Unmarshal([]byte(scopesJSON), &scopes); err != nil {
- return nil, nil, fmt.Errorf("failed to unmarshal scopes: %w", err)
- }
-
- return grants, scopes, nil
-}
-
-// Close closes the database connection and finalizes all prepared statements
-func (db *DB) Close() error {
- for _, stmt := range db.statements {
- stmt.Finalize()
- }
- return db.Conn.Close()
-}
diff --git a/internal/db/queries.go b/internal/db/queries.go
index 807d701..e69de29 100644
--- a/internal/db/queries.go
+++ b/internal/db/queries.go
@@ -1,79 +0,0 @@
-package db
-
-import "fmt"
-
-// Account queries
-func insertAccountQuery(name, address string) string {
- return fmt.Sprintf(`INSERT INTO accounts (name, address) VALUES (%s, %s)`, name, address)
-}
-
-// Asset queries
-func insertAssetQuery(name, symbol string, decimals int, chainID int64) string {
- return fmt.Sprintf(
- `INSERT INTO assets (name, symbol, decimals, chain_id) VALUES (%s, %s, %d, %d)`,
- name,
- symbol,
- decimals,
- chainID,
- )
-}
-
-// Chain queries
-func insertChainQuery(name string, networkID string) string {
- return fmt.Sprintf(`INSERT INTO chains (name, network_id) VALUES (%s, %d)`, name, networkID)
-}
-
-// Credential queries
-func insertCredentialQuery(
- handle, controller, attestationType, origin string,
- credentialID, publicKey []byte,
- transport string,
- signCount uint32,
- userPresent, userVerified, backupEligible, backupState, cloneWarning bool,
-) string {
- return fmt.Sprintf(`INSERT INTO credentials (
- handle, controller, attestation_type, origin,
- credential_id, public_key, transport, sign_count,
- user_present, user_verified, backup_eligible,
- backup_state, clone_warning
- ) VALUES (%s, %s, %s, %s, %s, %s, %s, %d, %t, %t, %t, %t, %t)`,
- handle, controller, attestationType, origin,
- credentialID, publicKey, transport, signCount,
- userPresent, userVerified, backupEligible,
- backupState, cloneWarning)
-}
-
-// Profile queries
-func insertProfileQuery(
- id, subject, controller, originURI, publicMetadata, privateMetadata string,
-) string {
- return fmt.Sprintf(`INSERT INTO profiles (
- id, subject, controller, origin_uri,
- public_metadata, private_metadata
- ) VALUES (%s, %s, %s, %s, %s, %s)`,
- id, subject, controller, originURI,
- publicMetadata, privateMetadata)
-}
-
-// Property queries
-func insertPropertyQuery(profileID, key, accumulator, propertyKey string) string {
- return fmt.Sprintf(`INSERT INTO properties (
- profile_id, key, accumulator, property_key
- ) VALUES (%s, %s, %s, %s)`,
- profileID, key, accumulator, propertyKey)
-}
-
-// Permission queries
-func insertPermissionQuery(serviceID, grants, scopes string) string {
- return fmt.Sprintf(
- `INSERT INTO permissions (service_id, grants, scopes) VALUES (%s, %s, %s)`,
- serviceID,
- grants,
- scopes,
- )
-}
-
-// GetPermission query
-func getPermissionQuery(serviceID string) string {
- return fmt.Sprintf(`SELECT grants, scopes FROM permissions WHERE service_id = %s`, serviceID)
-}
* fix: update Makefile to use sonrd instead of wasmd
* feat: Add targets for templ and vault in Makefile and use only make in devbox.json
* feat: add SQLite database support
* bump: version 0.6.0 → 0.7.0
* refactor: upgrade actions to latest versions
2024-09-05 01:24:57 -04:00
|
|
|
golang.org/x/sync v0.8.0 // indirect
|
|
|
|
golang.org/x/sys v0.25.0 // indirect
|
|
|
|
golang.org/x/term v0.23.0 // indirect
|
|
|
|
golang.org/x/text v0.18.0 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
golang.org/x/time v0.5.0 // indirect
|
Feature/update dockerfile (#6)
* chore: remove unused new.Dockerfile
* feat: add DID model definitions
* fix: Fix EncodePublicKey method in KeyInfo struct
* feat: Update `EncodePublicKey` to be the inverse of `DecodePublicKey`
* refactor: update AssetInfo protobuf definition
* fix: update default assets with correct asset types
* fix: Initialize IPFS client and check for mounted directories
* feat: Improve IPFS client initialization and mount checking
* feat: Add local filesystem check for IPFS and IPNS
* fix: Use Unixfs().Get() instead of Cat() for IPFS and IPNS content retrieval
* feat: Update GetCID and GetIPNS functions to read data from IPFS node
* fix: Ensure IPFS client is initialized before pinning CID
* feat: Add AddFile and AddFolder methods
* feat: add IPFS file system abstraction
* feat: Implement IPFS file, location, and filesystem abstractions
* refactor: remove unused functions and types
* refactor: remove unused FileSystem interface
* feat: add initial wasm entrypoint
* feat: add basic vault command operations
* docs: add vault module features
* test: remove test for MsgUpdateParams
* refactor: Replace PrimaryKey with Property struct in zkprop.go
* feat: Update the `CreateWitness` and `CreateAccumulator` and `VerifyWitness` and `UpdateAccumulator` to Use the new `Accumulator` and `Witness` types. Then Clean up the code in the file and refactor the marshalling methods
* <no value>
* feat: add KeyCurve and KeyType to KeyInfo in genesis
* feat: add WASM build step to devbox.json
* feat: Add zkgate.go file
* feat: Uncomment and modify zkgate code to work with Property struct
* feat: Merge zkgate.go and zkprop.go logic
* feat: implement API endpoints for profile management
* refactor: remove unused template file
* feat(orm): remove unused ORM models
* feat: add persistent SQLite database support in WASM
* fix: Update module names in protobuf files
* feat: Add method to initialize SQLite database
* fix: update go-sqlite3 dependency to version 1.14.23
* feat: introduce database layer
* feat: Implement database layer for Vault node
* feature/update-dockerfile
* feat: Add keyshares table
* fix: Reorder the SQL statements in the tables.go file
* feat: Update the `createCredentialsTable` method to match the proper Credential struct
* feat: Update createProfilesTable and add createPropertiesTable
* feat: Add constant SQL queries to queries.go and use prepared statements in db.go
* feat: Add createKeysharesTable to internal/db/db.go
* feat: Update `createPermissionsTable` to match Permissions struct
* feat: Add database enum types
* feat: Add DIDNamespace and PermissionScope enums
* feat: Add DBConfig and DBOption types
* feat: Update the db implementation to use the provided go library
* fix: update db implementation to use go-sqlite3 v0.18.2
* fix: Refactor database connection and statement handling
* feat: Simplify db.go implementation
* feat: Convert constant SQL queries to functions in queries.go and update db.go to use prepared statements
* feat: Add models.go file with database table structs
* fix: Remove unused statement map and prepare statements
diff --git a/internal/db/db.go b/internal/db/db.go
index 201d09b..d4d4d4e 100644
--- a/internal/db/db.go
+++ b/internal/db/db.go
@@ -32,11 +32,6 @@ func Open(config *DBConfig) (*DB, error) {
Conn: conn,
}
- if err := createTables(db); err != nil {
- conn.Close()
- return nil, fmt.Errorf("failed to create tables: %w", err)
- }
-
return db, nil
}
@@ -61,114 +56,3 @@ func createTables(db *DB) error {
return nil
}
-// AddAccount adds a new account to the database
-func (db *DB) AddAccount(name, address string) error {
- return db.Exec(insertAccountQuery(name, address))
-}
-
-// AddAsset adds a new asset to the database
-func (db *DB) AddAsset(name, symbol string, decimals int, chainID int64) error {
- return db.Exec(insertAssetQuery(name, symbol, decimals, chainID))
-}
-
-// AddChain adds a new chain to the database
-func (db *DB) AddChain(name, networkID string) error {
- return db.Exec(insertChainQuery(name, networkID))
-}
-
-// AddCredential adds a new credential to the database
-func (db *DB) AddCredential(
- handle, controller, attestationType, origin string,
- credentialID, publicKey []byte,
- transport string,
- signCount uint32,
- userPresent, userVerified, backupEligible, backupState, cloneWarning bool,
-) error {
- return db.Exec(insertCredentialQuery(
- handle,
- controller,
- attestationType,
- origin,
- credentialID,
- publicKey,
- transport,
- signCount,
- userPresent,
- userVerified,
- backupEligible,
- backupState,
- cloneWarning,
- ))
-}
-
-// AddProfile adds a new profile to the database
-func (db *DB) AddProfile(
- id, subject, controller, originURI, publicMetadata, privateMetadata string,
-) error {
- return db.statements["insertProfile"].Exec(
- id, subject, controller, originURI, publicMetadata, privateMetadata,
- )
-}
-
-// AddProperty adds a new property to the database
-func (db *DB) AddProperty(
- profileID, key, accumulator, propertyKey string,
-) error {
- return db.statements["insertProperty"].Exec(
- profileID, key, accumulator, propertyKey,
- )
-}
-
-// AddPermission adds a new permission to the database
-func (db *DB) AddPermission(
- serviceID string,
- grants []DIDNamespace,
- scopes []PermissionScope,
-) error {
- grantsJSON, err := json.Marshal(grants)
- if err != nil {
- return fmt.Errorf("failed to marshal grants: %w", err)
- }
-
- scopesJSON, err := json.Marshal(scopes)
- if err != nil {
- return fmt.Errorf("failed to marshal scopes: %w", err)
- }
-
- return db.statements["insertPermission"].Exec(
- serviceID, string(grantsJSON), string(scopesJSON),
- )
-}
-
-// GetPermission retrieves the permission for the given service ID
-func (db *DB) GetPermission(serviceID string) ([]DIDNamespace, []PermissionScope, error) {
- row := db.statements["getPermission"].QueryRow(serviceID)
-
- var grantsJSON, scopesJSON string
- if err := row.Scan(&grantsJSON, &scopesJSON); err != nil {
- return nil, nil, fmt.Errorf("failed to get permission: %w", err)
- }
-
- var grants []DIDNamespace
- if err := json.Unmarshal([]byte(grantsJSON), &grants); err != nil {
- return nil, nil, fmt.Errorf("failed to unmarshal grants: %w", err)
- }
-
- var scopes []PermissionScope
- if err := json.Unmarshal([]byte(scopesJSON), &scopes); err != nil {
- return nil, nil, fmt.Errorf("failed to unmarshal scopes: %w", err)
- }
-
- return grants, scopes, nil
-}
-
-// Close closes the database connection and finalizes all prepared statements
-func (db *DB) Close() error {
- for _, stmt := range db.statements {
- stmt.Finalize()
- }
- return db.Conn.Close()
-}
diff --git a/internal/db/queries.go b/internal/db/queries.go
index 807d701..e69de29 100644
--- a/internal/db/queries.go
+++ b/internal/db/queries.go
@@ -1,79 +0,0 @@
-package db
-
-import "fmt"
-
-// Account queries
-func insertAccountQuery(name, address string) string {
- return fmt.Sprintf(`INSERT INTO accounts (name, address) VALUES (%s, %s)`, name, address)
-}
-
-// Asset queries
-func insertAssetQuery(name, symbol string, decimals int, chainID int64) string {
- return fmt.Sprintf(
- `INSERT INTO assets (name, symbol, decimals, chain_id) VALUES (%s, %s, %d, %d)`,
- name,
- symbol,
- decimals,
- chainID,
- )
-}
-
-// Chain queries
-func insertChainQuery(name string, networkID string) string {
- return fmt.Sprintf(`INSERT INTO chains (name, network_id) VALUES (%s, %d)`, name, networkID)
-}
-
-// Credential queries
-func insertCredentialQuery(
- handle, controller, attestationType, origin string,
- credentialID, publicKey []byte,
- transport string,
- signCount uint32,
- userPresent, userVerified, backupEligible, backupState, cloneWarning bool,
-) string {
- return fmt.Sprintf(`INSERT INTO credentials (
- handle, controller, attestation_type, origin,
- credential_id, public_key, transport, sign_count,
- user_present, user_verified, backup_eligible,
- backup_state, clone_warning
- ) VALUES (%s, %s, %s, %s, %s, %s, %s, %d, %t, %t, %t, %t, %t)`,
- handle, controller, attestationType, origin,
- credentialID, publicKey, transport, signCount,
- userPresent, userVerified, backupEligible,
- backupState, cloneWarning)
-}
-
-// Profile queries
-func insertProfileQuery(
- id, subject, controller, originURI, publicMetadata, privateMetadata string,
-) string {
- return fmt.Sprintf(`INSERT INTO profiles (
- id, subject, controller, origin_uri,
- public_metadata, private_metadata
- ) VALUES (%s, %s, %s, %s, %s, %s)`,
- id, subject, controller, originURI,
- publicMetadata, privateMetadata)
-}
-
-// Property queries
-func insertPropertyQuery(profileID, key, accumulator, propertyKey string) string {
- return fmt.Sprintf(`INSERT INTO properties (
- profile_id, key, accumulator, property_key
- ) VALUES (%s, %s, %s, %s)`,
- profileID, key, accumulator, propertyKey)
-}
-
-// Permission queries
-func insertPermissionQuery(serviceID, grants, scopes string) string {
- return fmt.Sprintf(
- `INSERT INTO permissions (service_id, grants, scopes) VALUES (%s, %s, %s)`,
- serviceID,
- grants,
- scopes,
- )
-}
-
-// GetPermission query
-func getPermissionQuery(serviceID string) string {
- return fmt.Sprintf(`SELECT grants, scopes FROM permissions WHERE service_id = %s`, serviceID)
-}
* fix: update Makefile to use sonrd instead of wasmd
* feat: Add targets for templ and vault in Makefile and use only make in devbox.json
* feat: add SQLite database support
* bump: version 0.6.0 → 0.7.0
* refactor: upgrade actions to latest versions
2024-09-05 01:24:57 -04:00
|
|
|
golang.org/x/tools v0.24.0 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
|
2024-07-08 22:57:53 -04:00
|
|
|
gonum.org/v1/gonum v0.15.0 // indirect
|
|
|
|
google.golang.org/api v0.169.0 // indirect
|
2024-07-06 00:34:41 -04:00
|
|
|
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
|
2024-07-08 22:57:53 -04:00
|
|
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240617180043-68d350f18fd4 // indirect
|
2024-09-23 12:39:59 -04:00
|
|
|
gopkg.in/errgo.v1 v1.0.1 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
gopkg.in/ini.v1 v1.67.0 // indirect
|
|
|
|
gopkg.in/yaml.v2 v2.4.0 // indirect
|
|
|
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
|
|
|
gotest.tools/v3 v3.5.1 // indirect
|
|
|
|
nhooyr.io/websocket v1.8.10 // indirect
|
|
|
|
pgregory.net/rapid v1.1.0 // indirect
|
2024-07-26 12:14:20 -04:00
|
|
|
rsc.io/tmplfunc v0.0.3 // indirect
|
2024-07-05 22:20:13 -04:00
|
|
|
sigs.k8s.io/yaml v1.4.0 // indirect
|
|
|
|
)
|