mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-04 18:31:41 +00:00
feature/did accounts (#23)
* feat: add support for DID number as primary key for Controllers * refactor: rename pkg/proxy to app/proxy * feat: add vault module keeper tests * feat(vault): add DID keeper to vault module * refactor: move vault client code to its own package * refactor(vault): extract schema definition * refactor: use vaulttypes for MsgAllocateVault * refactor: update vault assembly logic to use new methods * feat: add dwn-proxy command * refactor: remove unused context.go file * refactor: remove unused web-related code * feat: add DWN proxy server * feat: add BuildTx RPC to vault module * fix: Implement BuildTx endpoint * feat: add devbox integration to project
This commit is contained in:
@@ -1,61 +0,0 @@
|
||||
package vault
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/types/bech32"
|
||||
"github.com/ipfs/boxo/files"
|
||||
"github.com/onsonr/crypto/mpc"
|
||||
"github.com/onsonr/sonr/config/dwn"
|
||||
)
|
||||
|
||||
type SchemaVersion = int
|
||||
|
||||
var CurrentSchemaVersion SchemaVersion = 1
|
||||
|
||||
type Vault struct {
|
||||
FS files.Node
|
||||
ValKs mpc.Share
|
||||
}
|
||||
|
||||
func New(subject string, origin string, chainID string) (*Vault, error) {
|
||||
shares, err := mpc.GenerateKeyshares()
|
||||
var (
|
||||
valKs = shares[0]
|
||||
usrKs = shares[1]
|
||||
)
|
||||
usrKsJSON, err := usrKs.Marshal()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
sonrAddr, err := bech32.ConvertAndEncode("idx", valKs.GetPublicKey())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cnfg := NewConfig(usrKsJSON, sonrAddr, chainID, DefaultSchema())
|
||||
|
||||
fileMap, err := NewVaultDirectory(cnfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Vault{
|
||||
FS: fileMap,
|
||||
ValKs: valKs,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func DefaultSchema() *dwn.Schema {
|
||||
return &dwn.Schema{
|
||||
Version: CurrentSchemaVersion,
|
||||
Account: "++, id, name, address, publicKey, chainCode, index, controller, createdAt",
|
||||
Asset: "++, id, name, symbol, decimals, chainCode, createdAt",
|
||||
Chain: "++, id, name, networkId, chainCode, createdAt",
|
||||
Credential: "++, id, subject, controller, attestationType, origin, label, deviceId, credentialId, publicKey, transport, signCount, userPresent, userVerified, backupEligible, backupState, cloneWarning, createdAt, updatedAt",
|
||||
Jwk: "++, kty, crv, x, y, n, e",
|
||||
Grant: "++, subject, controller, origin, token, scopes, createdAt, updatedAt",
|
||||
Keyshare: "++, id, data, role, createdAt, lastRefreshed",
|
||||
PublicKey: "++, role, algorithm, encoding, curve, key_type, raw, jwk",
|
||||
Profile: "++, id, subject, controller, originUri, publicMetadata, privateMetadata, createdAt, updatedAt",
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user