mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-02 17:31:39 +00:00
Squash merge develop into master
This commit is contained in:
+2
-2
@@ -3,7 +3,7 @@ package module
|
||||
import (
|
||||
autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
|
||||
|
||||
modulev1 "github.com/onsonr/hway/api/did/v1"
|
||||
modulev1 "github.com/onsonr/sonr/api/did/v1"
|
||||
)
|
||||
|
||||
// AutoCLIOptions implements the autocli.HasAutoCLIConfig interface.
|
||||
@@ -24,7 +24,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
|
||||
RpcCommandOptions: []*autocliv1.RpcCommandOptions{
|
||||
{
|
||||
RpcMethod: "UpdateParams",
|
||||
Skip: false, // set to true if authority gated
|
||||
Skip: true, // set to true if authority gated
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -0,0 +1,251 @@
|
||||
package builder
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
|
||||
"github.com/go-webauthn/webauthn/protocol"
|
||||
|
||||
"github.com/go-webauthn/webauthn/protocol/webauthncose"
|
||||
didv1 "github.com/onsonr/sonr/api/did/v1"
|
||||
"github.com/onsonr/sonr/x/did/types"
|
||||
)
|
||||
|
||||
func APIFormatDIDNamespace(namespace types.DIDNamespace) didv1.DIDNamespace {
|
||||
return didv1.DIDNamespace(namespace)
|
||||
}
|
||||
|
||||
func APIFormatDIDNamespaces(namespaces []types.DIDNamespace) []didv1.DIDNamespace {
|
||||
var s []didv1.DIDNamespace
|
||||
for _, namespace := range namespaces {
|
||||
s = append(s, APIFormatDIDNamespace(namespace))
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
func APIFormatKeyRole(role types.KeyRole) didv1.KeyRole {
|
||||
return didv1.KeyRole(role)
|
||||
}
|
||||
|
||||
func APIFormatKeyAlgorithm(algorithm types.KeyAlgorithm) didv1.KeyAlgorithm {
|
||||
return didv1.KeyAlgorithm(algorithm)
|
||||
}
|
||||
|
||||
func APIFormatKeyEncoding(encoding types.KeyEncoding) didv1.KeyEncoding {
|
||||
return didv1.KeyEncoding(encoding)
|
||||
}
|
||||
|
||||
func APIFormatKeyCurve(curve types.KeyCurve) didv1.KeyCurve {
|
||||
return didv1.KeyCurve(curve)
|
||||
}
|
||||
|
||||
func APIFormatKeyType(keyType types.KeyType) didv1.KeyType {
|
||||
return didv1.KeyType(keyType)
|
||||
}
|
||||
|
||||
func APIFormatPermissions(permissions *types.Permissions) *didv1.Permissions {
|
||||
if permissions == nil {
|
||||
return nil
|
||||
}
|
||||
p := didv1.Permissions{
|
||||
Grants: APIFormatDIDNamespaces(permissions.Grants),
|
||||
Scopes: APIFormatPermissionScopes(permissions.Scopes),
|
||||
}
|
||||
return &p
|
||||
}
|
||||
|
||||
func APIFormatPermissionScope(scope types.PermissionScope) didv1.PermissionScope {
|
||||
return didv1.PermissionScope(scope)
|
||||
}
|
||||
|
||||
func APIFormatPermissionScopes(scopes []types.PermissionScope) []didv1.PermissionScope {
|
||||
var s []didv1.PermissionScope
|
||||
for _, scope := range scopes {
|
||||
s = append(s, APIFormatPermissionScope(scope))
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
func APIFormatServiceRecord(service *types.Service) *didv1.ServiceRecord {
|
||||
return &didv1.ServiceRecord{
|
||||
Id: service.Id,
|
||||
ServiceType: service.ServiceType,
|
||||
Authority: service.Authority,
|
||||
Origin: service.Origin,
|
||||
Description: service.Description,
|
||||
ServiceEndpoints: service.ServiceEndpoints,
|
||||
Permissions: APIFormatPermissions(service.Permissions),
|
||||
}
|
||||
}
|
||||
|
||||
func APIFormatPubKeyJWK(jwk *types.PubKey_JWK) *didv1.PubKey_JWK {
|
||||
return &didv1.PubKey_JWK{
|
||||
Kty: jwk.Kty,
|
||||
Crv: jwk.Crv,
|
||||
X: jwk.X,
|
||||
Y: jwk.Y,
|
||||
N: jwk.N,
|
||||
E: jwk.E,
|
||||
}
|
||||
}
|
||||
|
||||
func APIFormatPubKey(key *types.PubKey) *didv1.PubKey {
|
||||
return &didv1.PubKey{
|
||||
Role: APIFormatKeyRole(key.GetRole()),
|
||||
Algorithm: APIFormatKeyAlgorithm(key.GetAlgorithm()),
|
||||
Encoding: APIFormatKeyEncoding(key.GetEncoding()),
|
||||
Curve: APIFormatKeyCurve(key.GetCurve()),
|
||||
KeyType: APIFormatKeyType(key.GetKeyType()),
|
||||
Raw: key.GetRaw(),
|
||||
}
|
||||
}
|
||||
|
||||
func FormatEC2PublicKey(key *webauthncose.EC2PublicKeyData) (*types.PubKey_JWK, error) {
|
||||
curve, err := GetCOSECurveName(key.Curve)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
jwkMap := map[string]interface{}{
|
||||
"kty": "EC",
|
||||
"crv": curve,
|
||||
"x": base64.RawURLEncoding.EncodeToString(key.XCoord),
|
||||
"y": base64.RawURLEncoding.EncodeToString(key.YCoord),
|
||||
}
|
||||
|
||||
return MapToJWK(jwkMap)
|
||||
}
|
||||
|
||||
func FormatRSAPublicKey(key *webauthncose.RSAPublicKeyData) (*types.PubKey_JWK, error) {
|
||||
jwkMap := map[string]interface{}{
|
||||
"kty": "RSA",
|
||||
"n": base64.RawURLEncoding.EncodeToString(key.Modulus),
|
||||
"e": base64.RawURLEncoding.EncodeToString(key.Exponent),
|
||||
}
|
||||
|
||||
return MapToJWK(jwkMap)
|
||||
}
|
||||
|
||||
func FormatOKPPublicKey(key *webauthncose.OKPPublicKeyData) (*types.PubKey_JWK, error) {
|
||||
curve, err := GetOKPCurveName(key.Curve)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
jwkMap := map[string]interface{}{
|
||||
"kty": "OKP",
|
||||
"crv": curve,
|
||||
"x": base64.RawURLEncoding.EncodeToString(key.XCoord),
|
||||
}
|
||||
|
||||
return MapToJWK(jwkMap)
|
||||
}
|
||||
|
||||
func MapToJWK(m map[string]interface{}) (*types.PubKey_JWK, error) {
|
||||
jwk := &types.PubKey_JWK{}
|
||||
for k, v := range m {
|
||||
switch k {
|
||||
case "kty":
|
||||
jwk.Kty = v.(string)
|
||||
case "crv":
|
||||
jwk.Crv = v.(string)
|
||||
case "x":
|
||||
jwk.X = v.(string)
|
||||
case "y":
|
||||
jwk.Y = v.(string)
|
||||
case "n":
|
||||
jwk.N = v.(string)
|
||||
case "e":
|
||||
jwk.E = v.(string)
|
||||
}
|
||||
}
|
||||
return jwk, nil
|
||||
}
|
||||
|
||||
func GetCOSECurveName(curveID int64) (string, error) {
|
||||
switch curveID {
|
||||
case int64(webauthncose.P256):
|
||||
return "P-256", nil
|
||||
case int64(webauthncose.P384):
|
||||
return "P-384", nil
|
||||
case int64(webauthncose.P521):
|
||||
return "P-521", nil
|
||||
default:
|
||||
return "", fmt.Errorf("unknown curve ID: %d", curveID)
|
||||
}
|
||||
}
|
||||
|
||||
func GetOKPCurveName(curveID int64) (string, error) {
|
||||
switch curveID {
|
||||
case int64(webauthncose.Ed25519):
|
||||
return "Ed25519", nil
|
||||
default:
|
||||
return "", fmt.Errorf("unknown OKP curve ID: %d", curveID)
|
||||
}
|
||||
}
|
||||
|
||||
// NormalizeTransports returns the transports as strings
|
||||
func NormalizeTransports(transports []protocol.AuthenticatorTransport) []string {
|
||||
tss := make([]string, len(transports))
|
||||
for i, t := range transports {
|
||||
tss[i] = string(t)
|
||||
}
|
||||
return tss
|
||||
}
|
||||
|
||||
// GetTransports returns the protocol.AuthenticatorTransport
|
||||
func ModuleTransportsToProtocol(transport []string) []protocol.AuthenticatorTransport {
|
||||
tss := make([]protocol.AuthenticatorTransport, len(transport))
|
||||
for i, t := range transport {
|
||||
tss[i] = protocol.AuthenticatorTransport(t)
|
||||
}
|
||||
return tss
|
||||
}
|
||||
|
||||
// ModuleFormatAPIServiceRecord formats a service record for the module
|
||||
func ModuleFormatAPIServiceRecord(service *didv1.ServiceRecord) *types.Service {
|
||||
return &types.Service{
|
||||
Id: service.Id,
|
||||
ServiceType: service.ServiceType,
|
||||
Authority: service.Authority,
|
||||
Origin: service.Origin,
|
||||
Description: service.Description,
|
||||
ServiceEndpoints: service.ServiceEndpoints,
|
||||
Permissions: ModuleFormatAPIPermissions(service.Permissions),
|
||||
}
|
||||
}
|
||||
|
||||
func ModuleFormatAPIPermissions(permissions *didv1.Permissions) *types.Permissions {
|
||||
if permissions == nil {
|
||||
return nil
|
||||
}
|
||||
p := types.Permissions{
|
||||
Grants: ModuleFormatAPIDIDNamespaces(permissions.Grants),
|
||||
Scopes: ModuleFormatAPIPermissionScopes(permissions.Scopes),
|
||||
}
|
||||
return &p
|
||||
}
|
||||
|
||||
func ModuleFormatAPIPermissionScope(scope didv1.PermissionScope) types.PermissionScope {
|
||||
return types.PermissionScope(scope)
|
||||
}
|
||||
|
||||
func ModuleFormatAPIPermissionScopes(scopes []didv1.PermissionScope) []types.PermissionScope {
|
||||
var s []types.PermissionScope
|
||||
for _, scope := range scopes {
|
||||
s = append(s, ModuleFormatAPIPermissionScope(scope))
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
func ModuleFormatAPIDIDNamespace(namespace didv1.DIDNamespace) types.DIDNamespace {
|
||||
return types.DIDNamespace(namespace)
|
||||
}
|
||||
|
||||
func ModuleFormatAPIDIDNamespaces(namespaces []didv1.DIDNamespace) []types.DIDNamespace {
|
||||
var s []types.DIDNamespace
|
||||
for _, namespace := range namespaces {
|
||||
s = append(s, ModuleFormatAPIDIDNamespace(namespace))
|
||||
}
|
||||
return s
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package types
|
||||
package builder
|
||||
|
||||
import (
|
||||
"crypto/hmac"
|
||||
@@ -8,17 +8,18 @@ import (
|
||||
"math/big"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/onsonr/sonr/x/did/types"
|
||||
)
|
||||
|
||||
// ComputePublicKey computes the public key of a child key given the extended public key, chain code, and index.
|
||||
func ComputePublicKey(extPubKey []byte, chainCode uint32, index int) ([]byte, error) {
|
||||
// ComputeAccountPublicKey computes the public key of a child key given the extended public key, chain code, and index.
|
||||
func computeBip32AccountPublicKey(extPubKey PublicKey, chainCode types.ChainCode, index int) (*types.PubKey, error) {
|
||||
// Check if the index is a hardened child key
|
||||
if chainCode&0x80000000 != 0 && index < 0 {
|
||||
return nil, errors.New("invalid index")
|
||||
}
|
||||
|
||||
// Serialize the public key
|
||||
pubKey, err := btcec.ParsePubKey(extPubKey)
|
||||
pubKey, err := btcec.ParsePubKey(extPubKey.GetRaw())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -54,8 +55,11 @@ func ComputePublicKey(extPubKey []byte, chainCode uint32, index int) ([]byte, er
|
||||
|
||||
// Create the child public key
|
||||
childPubKey := btcec.NewPublicKey(lx, ly)
|
||||
childPubKeyBytes := childPubKey.SerializeCompressed()
|
||||
return childPubKeyBytes, nil
|
||||
pk, err := types.NewPublicKey(childPubKey.SerializeCompressed(), types.ChainCodeKeyInfos[chainCode])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return pk, nil
|
||||
}
|
||||
|
||||
// newBigIntFieldVal creates a new field value from a big integer.
|
||||
@@ -0,0 +1,334 @@
|
||||
package builder
|
||||
|
||||
import (
|
||||
"github.com/onsonr/sonr/x/did/types"
|
||||
)
|
||||
|
||||
type (
|
||||
AuthenticatorAttachment string
|
||||
AuthenticatorTransport string
|
||||
)
|
||||
|
||||
const (
|
||||
// Platform represents a platform authenticator is attached using a client device-specific transport, called
|
||||
// platform attachment, and is usually not removable from the client device. A public key credential bound to a
|
||||
// platform authenticator is called a platform credential.
|
||||
Platform AuthenticatorAttachment = "platform"
|
||||
|
||||
// CrossPlatform represents a roaming authenticator is attached using cross-platform transports, called
|
||||
// cross-platform attachment. Authenticators of this class are removable from, and can "roam" among, client devices.
|
||||
// A public key credential bound to a roaming authenticator is called a roaming credential.
|
||||
CrossPlatform AuthenticatorAttachment = "cross-platform"
|
||||
)
|
||||
|
||||
func ParseAuthenticatorAttachment(s string) AuthenticatorAttachment {
|
||||
switch s {
|
||||
case "platform":
|
||||
return Platform
|
||||
default:
|
||||
return CrossPlatform
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
// USB indicates the respective authenticator can be contacted over removable USB.
|
||||
USB AuthenticatorTransport = "usb"
|
||||
|
||||
// NFC indicates the respective authenticator can be contacted over Near Field Communication (NFC).
|
||||
NFC AuthenticatorTransport = "nfc"
|
||||
|
||||
// BLE indicates the respective authenticator can be contacted over Bluetooth Smart (Bluetooth Low Energy / BLE).
|
||||
BLE AuthenticatorTransport = "ble"
|
||||
|
||||
// SmartCard indicates the respective authenticator can be contacted over ISO/IEC 7816 smart card with contacts.
|
||||
//
|
||||
// WebAuthn Level 3.
|
||||
SmartCard AuthenticatorTransport = "smart-card"
|
||||
|
||||
// Hybrid indicates the respective authenticator can be contacted using a combination of (often separate)
|
||||
// data-transport and proximity mechanisms. This supports, for example, authentication on a desktop computer using
|
||||
// a smartphone.
|
||||
//
|
||||
// WebAuthn Level 3.
|
||||
Hybrid AuthenticatorTransport = "hybrid"
|
||||
|
||||
// Internal indicates the respective authenticator is contacted using a client device-specific transport, i.e., it
|
||||
// is a platform authenticator. These authenticators are not removable from the client device.
|
||||
Internal AuthenticatorTransport = "internal"
|
||||
)
|
||||
|
||||
func ParseAuthenticatorTransport(s string) AuthenticatorTransport {
|
||||
switch s {
|
||||
case "usb":
|
||||
return USB
|
||||
case "nfc":
|
||||
return NFC
|
||||
case "ble":
|
||||
return BLE
|
||||
case "smart-card":
|
||||
return SmartCard
|
||||
case "hybrid":
|
||||
return Hybrid
|
||||
default:
|
||||
return Internal
|
||||
}
|
||||
}
|
||||
|
||||
type AuthenticatorFlags byte
|
||||
|
||||
const (
|
||||
// FlagUserPresent Bit 00000001 in the byte sequence. Tells us if user is present. Also referred to as the UP flag.
|
||||
FlagUserPresent AuthenticatorFlags = 1 << iota // Referred to as UP
|
||||
|
||||
// FlagRFU1 is a reserved for future use flag.
|
||||
FlagRFU1
|
||||
|
||||
// FlagUserVerified Bit 00000100 in the byte sequence. Tells us if user is verified
|
||||
// by the authenticator using a biometric or PIN. Also referred to as the UV flag.
|
||||
FlagUserVerified
|
||||
|
||||
// FlagBackupEligible Bit 00001000 in the byte sequence. Tells us if a backup is eligible for device. Also referred
|
||||
// to as the BE flag.
|
||||
FlagBackupEligible // Referred to as BE
|
||||
|
||||
// FlagBackupState Bit 00010000 in the byte sequence. Tells us if a backup state for device. Also referred to as the
|
||||
// BS flag.
|
||||
FlagBackupState
|
||||
|
||||
// FlagRFU2 is a reserved for future use flag.
|
||||
FlagRFU2
|
||||
|
||||
// FlagAttestedCredentialData Bit 01000000 in the byte sequence. Indicates whether
|
||||
// the authenticator added attested credential data. Also referred to as the AT flag.
|
||||
FlagAttestedCredentialData
|
||||
|
||||
// FlagHasExtensions Bit 10000000 in the byte sequence. Indicates if the authenticator data has extensions. Also
|
||||
// referred to as the ED flag.
|
||||
FlagHasExtensions
|
||||
)
|
||||
|
||||
type AttestationFormat string
|
||||
|
||||
const (
|
||||
// AttestationFormatPacked is the "packed" attestation statement format is a WebAuthn-optimized format for
|
||||
// attestation. It uses a very compact but still extensible encoding method. This format is implementable by
|
||||
// authenticators with limited resources (e.g., secure elements).
|
||||
AttestationFormatPacked AttestationFormat = "packed"
|
||||
|
||||
// AttestationFormatTPM is the TPM attestation statement format returns an attestation statement in the same format
|
||||
// as the packed attestation statement format, although the rawData and signature fields are computed differently.
|
||||
AttestationFormatTPM AttestationFormat = "tpm"
|
||||
|
||||
// AttestationFormatAndroidKey is the attestation statement format for platform authenticators on versions "N", and
|
||||
// later, which may provide this proprietary "hardware attestation" statement.
|
||||
AttestationFormatAndroidKey AttestationFormat = "android-key"
|
||||
|
||||
// AttestationFormatAndroidSafetyNet is the attestation statement format that Android-based platform authenticators
|
||||
// MAY produce an attestation statement based on the Android SafetyNet API.
|
||||
AttestationFormatAndroidSafetyNet AttestationFormat = "android-safetynet"
|
||||
|
||||
// AttestationFormatFIDOUniversalSecondFactor is the attestation statement format that is used with FIDO U2F
|
||||
// authenticators.
|
||||
AttestationFormatFIDOUniversalSecondFactor AttestationFormat = "fido-u2f"
|
||||
|
||||
// AttestationFormatApple is the attestation statement format that is used with Apple devices' platform
|
||||
// authenticators.
|
||||
AttestationFormatApple AttestationFormat = "apple"
|
||||
|
||||
// AttestationFormatNone is the attestation statement format that is used to replace any authenticator-provided
|
||||
// attestation statement when a WebAuthn Relying Party indicates it does not wish to receive attestation information.
|
||||
AttestationFormatNone AttestationFormat = "none"
|
||||
)
|
||||
|
||||
func ExtractAttestationFormats(p *types.Params) []AttestationFormat {
|
||||
var formats []AttestationFormat
|
||||
for _, v := range p.AttestationFormats {
|
||||
formats = append(formats, parseAttestationFormat(v))
|
||||
}
|
||||
return formats
|
||||
}
|
||||
|
||||
func parseAttestationFormat(s string) AttestationFormat {
|
||||
switch s {
|
||||
case "packed":
|
||||
return AttestationFormatPacked
|
||||
case "tpm":
|
||||
return AttestationFormatTPM
|
||||
case "android-key":
|
||||
return AttestationFormatAndroidKey
|
||||
case "android-safetynet":
|
||||
return AttestationFormatAndroidSafetyNet
|
||||
case "fido-u2f":
|
||||
return AttestationFormatFIDOUniversalSecondFactor
|
||||
case "apple":
|
||||
return AttestationFormatApple
|
||||
case "none":
|
||||
return AttestationFormatNone
|
||||
default:
|
||||
return AttestationFormatPacked
|
||||
}
|
||||
}
|
||||
|
||||
type CredentialType string
|
||||
|
||||
const (
|
||||
CredentialTypePublicKeyCredential CredentialType = "public-key"
|
||||
)
|
||||
|
||||
type ConveyancePreference string
|
||||
|
||||
const (
|
||||
// PreferNoAttestation is a ConveyancePreference value.
|
||||
//
|
||||
// This value indicates that the Relying Party is not interested in authenticator attestation. For example, in order
|
||||
// to potentially avoid having to obtain user consent to relay identifying information to the Relying Party, or to
|
||||
// save a round trip to an Attestation CA or Anonymization CA.
|
||||
//
|
||||
// This is the default value.
|
||||
//
|
||||
// Specification: §5.4.7. Attestation Conveyance Preference Enumeration (https://www.w3.org/TR/webauthn/#dom-attestationconveyancepreference-none)
|
||||
PreferNoAttestation ConveyancePreference = "none"
|
||||
|
||||
// PreferIndirectAttestation is a ConveyancePreference value.
|
||||
//
|
||||
// This value indicates that the Relying Party prefers an attestation conveyance yielding verifiable attestation
|
||||
// statements, but allows the client to decide how to obtain such attestation statements. The client MAY replace the
|
||||
// authenticator-generated attestation statements with attestation statements generated by an Anonymization CA, in
|
||||
// order to protect the user’s privacy, or to assist Relying Parties with attestation verification in a
|
||||
// heterogeneous ecosystem.
|
||||
//
|
||||
// Note: There is no guarantee that the Relying Party will obtain a verifiable attestation statement in this case.
|
||||
// For example, in the case that the authenticator employs self attestation.
|
||||
//
|
||||
// Specification: §5.4.7. Attestation Conveyance Preference Enumeration (https://www.w3.org/TR/webauthn/#dom-attestationconveyancepreference-indirect)
|
||||
PreferIndirectAttestation ConveyancePreference = "indirect"
|
||||
|
||||
// PreferDirectAttestation is a ConveyancePreference value.
|
||||
//
|
||||
// This value indicates that the Relying Party wants to receive the attestation statement as generated by the
|
||||
// authenticator.
|
||||
//
|
||||
// Specification: §5.4.7. Attestation Conveyance Preference Enumeration (https://www.w3.org/TR/webauthn/#dom-attestationconveyancepreference-direct)
|
||||
PreferDirectAttestation ConveyancePreference = "direct"
|
||||
|
||||
// PreferEnterpriseAttestation is a ConveyancePreference value.
|
||||
//
|
||||
// This value indicates that the Relying Party wants to receive an attestation statement that may include uniquely
|
||||
// identifying information. This is intended for controlled deployments within an enterprise where the organization
|
||||
// wishes to tie registrations to specific authenticators. User agents MUST NOT provide such an attestation unless
|
||||
// the user agent or authenticator configuration permits it for the requested RP ID.
|
||||
//
|
||||
// If permitted, the user agent SHOULD signal to the authenticator (at invocation time) that enterprise
|
||||
// attestation is requested, and convey the resulting AAGUID and attestation statement, unaltered, to the Relying
|
||||
// Party.
|
||||
//
|
||||
// Specification: §5.4.7. Attestation Conveyance Preference Enumeration (https://www.w3.org/TR/webauthn/#dom-attestationconveyancepreference-enterprise)
|
||||
PreferEnterpriseAttestation ConveyancePreference = "enterprise"
|
||||
)
|
||||
|
||||
func ExtractConveyancePreference(p *types.Params) ConveyancePreference {
|
||||
switch p.ConveyancePreference {
|
||||
case "none":
|
||||
return PreferNoAttestation
|
||||
case "indirect":
|
||||
return PreferIndirectAttestation
|
||||
case "direct":
|
||||
return PreferDirectAttestation
|
||||
case "enterprise":
|
||||
return PreferEnterpriseAttestation
|
||||
default:
|
||||
return PreferNoAttestation
|
||||
}
|
||||
}
|
||||
|
||||
type PublicKeyCredentialHints string
|
||||
|
||||
const (
|
||||
// PublicKeyCredentialHintSecurityKey is a PublicKeyCredentialHint that indicates that the Relying Party believes
|
||||
// that users will satisfy this request with a physical security key. For example, an enterprise Relying Party may
|
||||
// set this hint if they have issued security keys to their employees and will only accept those authenticators for
|
||||
// registration and authentication.
|
||||
//
|
||||
// For compatibility with older user agents, when this hint is used in PublicKeyCredentialCreationOptions, the
|
||||
// authenticatorAttachment SHOULD be set to cross-platform.
|
||||
PublicKeyCredentialHintSecurityKey PublicKeyCredentialHints = "security-key"
|
||||
|
||||
// PublicKeyCredentialHintClientDevice is a PublicKeyCredentialHint that indicates that the Relying Party believes
|
||||
// that users will satisfy this request with a platform authenticator attached to the client device.
|
||||
//
|
||||
// For compatibility with older user agents, when this hint is used in PublicKeyCredentialCreationOptions, the
|
||||
// authenticatorAttachment SHOULD be set to platform.
|
||||
PublicKeyCredentialHintClientDevice PublicKeyCredentialHints = "client-device"
|
||||
|
||||
// PublicKeyCredentialHintHybrid is a PublicKeyCredentialHint that indicates that the Relying Party believes that
|
||||
// users will satisfy this request with general-purpose authenticators such as smartphones. For example, a consumer
|
||||
// Relying Party may believe that only a small fraction of their customers possesses dedicated security keys. This
|
||||
// option also implies that the local platform authenticator should not be promoted in the UI.
|
||||
//
|
||||
// For compatibility with older user agents, when this hint is used in PublicKeyCredentialCreationOptions, the
|
||||
// authenticatorAttachment SHOULD be set to cross-platform.
|
||||
PublicKeyCredentialHintHybrid PublicKeyCredentialHints = "hybrid"
|
||||
)
|
||||
|
||||
func ParsePublicKeyCredentialHints(s string) PublicKeyCredentialHints {
|
||||
switch s {
|
||||
case "security-key":
|
||||
return PublicKeyCredentialHintSecurityKey
|
||||
case "client-device":
|
||||
return PublicKeyCredentialHintClientDevice
|
||||
case "hybrid":
|
||||
return PublicKeyCredentialHintHybrid
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
type AttestedCredentialData struct {
|
||||
AAGUID []byte `json:"aaguid"`
|
||||
CredentialID []byte `json:"credential_id"`
|
||||
|
||||
// The raw credential public key bytes received from the attestation data.
|
||||
CredentialPublicKey []byte `json:"public_key"`
|
||||
}
|
||||
|
||||
type ResidentKeyRequirement string
|
||||
|
||||
const (
|
||||
// ResidentKeyRequirementDiscouraged indicates the Relying Party prefers creating a server-side credential, but will
|
||||
// accept a client-side discoverable credential. This is the default.
|
||||
ResidentKeyRequirementDiscouraged ResidentKeyRequirement = "discouraged"
|
||||
|
||||
// ResidentKeyRequirementPreferred indicates to the client we would prefer a discoverable credential.
|
||||
ResidentKeyRequirementPreferred ResidentKeyRequirement = "preferred"
|
||||
|
||||
// ResidentKeyRequirementRequired indicates the Relying Party requires a client-side discoverable credential, and is
|
||||
// prepared to receive an error if a client-side discoverable credential cannot be created.
|
||||
ResidentKeyRequirementRequired ResidentKeyRequirement = "required"
|
||||
)
|
||||
|
||||
func ParseResidentKeyRequirement(s string) ResidentKeyRequirement {
|
||||
switch s {
|
||||
case "discouraged":
|
||||
return ResidentKeyRequirementDiscouraged
|
||||
case "preferred":
|
||||
return ResidentKeyRequirementPreferred
|
||||
default:
|
||||
return ResidentKeyRequirementRequired
|
||||
}
|
||||
}
|
||||
|
||||
type (
|
||||
AuthenticationExtensions map[string]any
|
||||
UserVerificationRequirement string
|
||||
)
|
||||
|
||||
const (
|
||||
// VerificationRequired User verification is required to create/release a credential
|
||||
VerificationRequired UserVerificationRequirement = "required"
|
||||
|
||||
// VerificationPreferred User verification is preferred to create/release a credential
|
||||
VerificationPreferred UserVerificationRequirement = "preferred" // This is the default
|
||||
|
||||
// VerificationDiscouraged The authenticator should not verify the user for the credential
|
||||
VerificationDiscouraged UserVerificationRequirement = "discouraged"
|
||||
)
|
||||
@@ -0,0 +1,48 @@
|
||||
package builder
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
"gopkg.in/macaroon.v2"
|
||||
|
||||
"gopkg.in/macaroon-bakery.v2/bakery/checkers"
|
||||
)
|
||||
|
||||
var PermissionNamespace *checkers.Namespace
|
||||
|
||||
func ValidateMacaroonMiddleware(secretKey []byte, location string) echo.MiddlewareFunc {
|
||||
return func(next echo.HandlerFunc) echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
// Extract the macaroon from the Authorization header
|
||||
auth := c.Request().Header.Get("Authorization")
|
||||
if auth == "" {
|
||||
return c.JSON(http.StatusUnauthorized, map[string]string{"error": "Missing Authorization header"})
|
||||
}
|
||||
|
||||
// Decode the macaroon
|
||||
mac, err := macaroon.Base64Decode([]byte(auth))
|
||||
if err != nil {
|
||||
return c.JSON(http.StatusBadRequest, map[string]string{"error": "Invalid macaroon encoding"})
|
||||
}
|
||||
|
||||
token, err := macaroon.New(secretKey, mac, location, macaroon.LatestVersion)
|
||||
if err != nil {
|
||||
return c.JSON(http.StatusBadRequest, map[string]string{"error": "Invalid macaroon"})
|
||||
}
|
||||
|
||||
// Verify the macaroon
|
||||
err = token.Verify(secretKey, func(caveat string) error {
|
||||
// Implement your caveat verification logic here
|
||||
// For example, you might check if the caveat is still valid (e.g., not expired)
|
||||
return nil // Return nil if the caveat is valid
|
||||
}, nil)
|
||||
if err != nil {
|
||||
return c.JSON(http.StatusUnauthorized, map[string]string{"error": "Invalid macaroon"})
|
||||
}
|
||||
|
||||
// Macaroon is valid, proceed to the next handler
|
||||
return next(c)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package builder
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/onsonr/sonr/x/did/types/oidc"
|
||||
)
|
||||
|
||||
func GetDiscovery(origin string) *oidc.DiscoveryDocument {
|
||||
baseURL := "https://" + origin // Ensure this is the correct base URL for your service
|
||||
discoveryDoc := &oidc.DiscoveryDocument{
|
||||
Issuer: baseURL,
|
||||
AuthorizationEndpoint: fmt.Sprintf("%s/auth", baseURL),
|
||||
TokenEndpoint: fmt.Sprintf("%s/token", baseURL),
|
||||
UserinfoEndpoint: fmt.Sprintf("%s/userinfo", baseURL),
|
||||
JwksUri: fmt.Sprintf("%s/jwks", baseURL),
|
||||
RegistrationEndpoint: fmt.Sprintf("%s/register", baseURL),
|
||||
ScopesSupported: []string{"openid", "profile", "email", "web3", "sonr"},
|
||||
ResponseTypesSupported: []string{"code"},
|
||||
ResponseModesSupported: []string{"query", "form_post"},
|
||||
GrantTypesSupported: []string{"authorization_code", "refresh_token"},
|
||||
AcrValuesSupported: []string{"passkey"},
|
||||
SubjectTypesSupported: []string{"public"},
|
||||
ClaimsSupported: []string{"sub", "iss", "name", "email"},
|
||||
}
|
||||
return discoveryDoc
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package builder
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/onsonr/sonr/x/did/types"
|
||||
)
|
||||
|
||||
type AuthenticatorResponse struct {
|
||||
// From the spec https://www.w3.org/TR/webauthn/#dom-authenticatorresponse-clientdatajson
|
||||
// This attribute contains a JSON serialization of the client data passed to the authenticator
|
||||
// by the client in its call to either create() or get().
|
||||
ClientDataJSON URLEncodedBase64 `json:"clientDataJSON"`
|
||||
}
|
||||
|
||||
type AuthenticatorAttestationResponse struct {
|
||||
// The byte slice of clientDataJSON, which becomes CollectedClientData
|
||||
AuthenticatorResponse
|
||||
|
||||
Transports []string `json:"transports,omitempty"`
|
||||
|
||||
AuthenticatorData URLEncodedBase64 `json:"authenticatorData"`
|
||||
|
||||
PublicKey URLEncodedBase64 `json:"publicKey"`
|
||||
|
||||
PublicKeyAlgorithm int64 `json:"publicKeyAlgorithm"`
|
||||
|
||||
// AttestationObject is the byte slice version of attestationObject.
|
||||
// This attribute contains an attestation object, which is opaque to, and
|
||||
// cryptographically protected against tampering by, the client. The
|
||||
// attestation object contains both authenticator data and an attestation
|
||||
// statement. The former contains the AAGUID, a unique credential ID, and
|
||||
// the credential public key. The contents of the attestation statement are
|
||||
// determined by the attestation statement format used by the authenticator.
|
||||
// It also contains any additional information that the Relying Party's server
|
||||
// requires to validate the attestation statement, as well as to decode and
|
||||
// validate the authenticator data along with the JSON-serialized client data.
|
||||
AttestationObject URLEncodedBase64 `json:"attestationObject"`
|
||||
}
|
||||
|
||||
type PublicKeyCredentialCreationOptions struct {
|
||||
RelyingParty RelyingPartyEntity `json:"rp"`
|
||||
User UserEntity `json:"user"`
|
||||
Challenge URLEncodedBase64 `json:"challenge"`
|
||||
Parameters []CredentialParameter `json:"pubKeyCredParams,omitempty"`
|
||||
Timeout int `json:"timeout,omitempty"`
|
||||
CredentialExcludeList []CredentialDescriptor `json:"excludeCredentials,omitempty"`
|
||||
AuthenticatorSelection AuthenticatorSelection `json:"authenticatorSelection,omitempty"`
|
||||
Hints []PublicKeyCredentialHints `json:"hints,omitempty"`
|
||||
Attestation ConveyancePreference `json:"attestation,omitempty"`
|
||||
AttestationFormats []AttestationFormat `json:"attestationFormats,omitempty"`
|
||||
Extensions AuthenticationExtensions `json:"extensions,omitempty"`
|
||||
}
|
||||
|
||||
func GetPublicKeyCredentialCreationOptions(origin string, subject string, vaultCID string, params *types.Params) (*PublicKeyCredentialCreationOptions, error) {
|
||||
chal, err := CreateChallenge()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &PublicKeyCredentialCreationOptions{
|
||||
RelyingParty: NewRelayingParty(origin, subject),
|
||||
User: NewUserEntity(subject, subject, vaultCID),
|
||||
Parameters: ExtractCredentialParameters(params),
|
||||
Timeout: 20,
|
||||
CredentialExcludeList: nil,
|
||||
Challenge: chal,
|
||||
AuthenticatorSelection: AuthenticatorSelection{},
|
||||
Hints: nil,
|
||||
Attestation: ExtractConveyancePreference(params),
|
||||
AttestationFormats: ExtractAttestationFormats(params),
|
||||
Extensions: nil,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func UnmarshalAuthenticatorResponse(data []byte) (*AuthenticatorResponse, error) {
|
||||
var ar AuthenticatorResponse
|
||||
err := json.Unmarshal(data, &ar)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &ar, nil
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package builder
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
didv1 "github.com/onsonr/sonr/api/did/v1"
|
||||
"github.com/onsonr/sonr/x/did/types"
|
||||
|
||||
"github.com/go-webauthn/webauthn/protocol/webauthncose"
|
||||
)
|
||||
|
||||
// PublicKey is an interface for a public key
|
||||
type PublicKey interface {
|
||||
cryptotypes.PubKey
|
||||
Clone() cryptotypes.PubKey
|
||||
GetRaw() []byte
|
||||
GetRole() types.KeyRole
|
||||
GetAlgorithm() types.KeyAlgorithm
|
||||
GetEncoding() types.KeyEncoding
|
||||
GetCurve() types.KeyCurve
|
||||
GetKeyType() types.KeyType
|
||||
}
|
||||
|
||||
// CreateAuthnVerification creates a new verification method for an authn method
|
||||
func CreateAuthnVerification(namespace types.DIDNamespace, issuer string, controller string, pubkey *types.PubKey, identifier string) *types.VerificationMethod {
|
||||
return &types.VerificationMethod{
|
||||
Method: namespace,
|
||||
Controller: controller,
|
||||
PublicKey: pubkey,
|
||||
Id: identifier,
|
||||
Issuer: issuer,
|
||||
}
|
||||
}
|
||||
|
||||
// CreateWalletVerification creates a new verification method for a wallet
|
||||
func CreateWalletVerification(namespace types.DIDNamespace, controller string, pubkey *types.PubKey, identifier string) *didv1.VerificationMethod {
|
||||
return &didv1.VerificationMethod{
|
||||
Method: APIFormatDIDNamespace(namespace),
|
||||
Controller: controller,
|
||||
PublicKey: APIFormatPubKey(pubkey),
|
||||
Id: identifier,
|
||||
}
|
||||
}
|
||||
|
||||
// ExtractWebAuthnPublicKey parses the raw public key bytes and returns a JWK representation
|
||||
func ExtractWebAuthnPublicKey(keyBytes []byte) (*types.PubKey_JWK, error) {
|
||||
key, err := webauthncose.ParsePublicKey(keyBytes)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to parse public key: %w", err)
|
||||
}
|
||||
|
||||
switch k := key.(type) {
|
||||
case *webauthncose.EC2PublicKeyData:
|
||||
return FormatEC2PublicKey(k)
|
||||
case *webauthncose.RSAPublicKeyData:
|
||||
return FormatRSAPublicKey(k)
|
||||
case *webauthncose.OKPPublicKeyData:
|
||||
return FormatOKPPublicKey(k)
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported key type")
|
||||
}
|
||||
}
|
||||
|
||||
// NewInitialWalletAccounts creates a new set of verification methods for a wallet
|
||||
func NewInitialWalletAccounts(controller string, pubkey *types.PubKey) ([]*didv1.VerificationMethod, error) {
|
||||
var verificationMethods []*didv1.VerificationMethod
|
||||
for method, chain := range types.InitialChainCodes {
|
||||
nk, err := computeBip32AccountPublicKey(pubkey, chain, 0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
addr, err := chain.FormatAddress(nk)
|
||||
if err != nil {
|
||||
return nil, nil
|
||||
}
|
||||
verificationMethods = append(verificationMethods, CreateWalletVerification(method, controller, nk, method.FormatDID(addr)))
|
||||
}
|
||||
return verificationMethods, nil
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package builder
|
||||
|
||||
import (
|
||||
"github.com/onsonr/sonr/x/did/types"
|
||||
"gopkg.in/macaroon-bakery.v2/bakery/checkers"
|
||||
)
|
||||
|
||||
var (
|
||||
GenericPermissionScopeStrings = [...]string{
|
||||
"profile.name",
|
||||
"identifiers.email",
|
||||
"identifiers.phone",
|
||||
"transactions.read",
|
||||
"transactions.write",
|
||||
"wallets.read",
|
||||
"wallets.create",
|
||||
"wallets.subscribe",
|
||||
"wallets.update",
|
||||
"transactions.verify",
|
||||
"transactions.broadcast",
|
||||
"admin.user",
|
||||
"admin.validator",
|
||||
}
|
||||
|
||||
StringToModulePermissionScope = map[string]types.PermissionScope{
|
||||
"PERMISSION_SCOPE_UNSPECIFIED": types.PermissionScope_PERMISSION_SCOPE_UNSPECIFIED,
|
||||
"PERMISSION_SCOPE_BASIC_INFO": types.PermissionScope_PERMISSION_SCOPE_BASIC_INFO,
|
||||
"PERMISSION_SCOPE_IDENTIFIERS_EMAIL": types.PermissionScope_PERMISSION_SCOPE_PERMISSIONS_READ,
|
||||
"PERMISSION_SCOPE_IDENTIFIERS_PHONE": types.PermissionScope_PERMISSION_SCOPE_PERMISSIONS_WRITE,
|
||||
"PERMISSION_SCOPE_TRANSACTIONS_READ": types.PermissionScope_PERMISSION_SCOPE_TRANSACTIONS_READ,
|
||||
"PERMISSION_SCOPE_TRANSACTIONS_WRITE": types.PermissionScope_PERMISSION_SCOPE_TRANSACTIONS_WRITE,
|
||||
"PERMISSION_SCOPE_WALLETS_READ": types.PermissionScope_PERMISSION_SCOPE_WALLETS_READ,
|
||||
"PERMISSION_SCOPE_WALLETS_CREATE": types.PermissionScope_PERMISSION_SCOPE_WALLETS_CREATE,
|
||||
"PERMISSION_SCOPE_WALLETS_SUBSCRIBE": types.PermissionScope_PERMISSION_SCOPE_WALLETS_SUBSCRIBE,
|
||||
"PERMISSION_SCOPE_WALLETS_UPDATE": types.PermissionScope_PERMISSION_SCOPE_WALLETS_UPDATE,
|
||||
"PERMISSION_SCOPE_TRANSACTIONS_VERIFY": types.PermissionScope_PERMISSION_SCOPE_TRANSACTIONS_VERIFY,
|
||||
"PERMISSION_SCOPE_TRANSACTIONS_BROADCAST": types.PermissionScope_PERMISSION_SCOPE_TRANSACTIONS_BROADCAST,
|
||||
"PERMISSION_SCOPE_ADMIN_USER": types.PermissionScope_PERMISSION_SCOPE_ADMIN_USER,
|
||||
"PERMISSION_SCOPE_ADMIN_VALIDATOR": types.PermissionScope_PERMISSION_SCOPE_ADMIN_VALIDATOR,
|
||||
}
|
||||
)
|
||||
|
||||
func ResolvePermissionScope(scope string) (types.PermissionScope, bool) {
|
||||
uriToPrefix := make(map[string]string)
|
||||
for _, scope := range GenericPermissionScopeStrings {
|
||||
uriToPrefix["https://example.com/auth/"+scope] = scope
|
||||
}
|
||||
PermissionNamespace := checkers.NewNamespace(uriToPrefix)
|
||||
|
||||
prefix, ok := PermissionNamespace.Resolve("https://example.com/auth/" + scope)
|
||||
if !ok {
|
||||
return 0, false
|
||||
}
|
||||
permScope, ok := StringToModulePermissionScope[prefix]
|
||||
return permScope, ok
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package builder
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"strings"
|
||||
|
||||
"github.com/onsonr/sonr/x/did/types"
|
||||
)
|
||||
|
||||
// ChallengeLength - Length of bytes to generate for a challenge.
|
||||
const ChallengeLength = 32
|
||||
|
||||
// CreateChallenge creates a new challenge that should be signed and returned by the authenticator. The spec recommends
|
||||
// using at least 16 bytes with 100 bits of entropy. We use 32 bytes.
|
||||
func CreateChallenge() (challenge URLEncodedBase64, err error) {
|
||||
challenge = make([]byte, ChallengeLength)
|
||||
|
||||
if _, err = rand.Read(challenge); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return challenge, nil
|
||||
}
|
||||
|
||||
type CredentialEntity struct {
|
||||
// A human-palatable name for the entity. Its function depends on what the PublicKeyCredentialEntity represents:
|
||||
//
|
||||
// When inherited by PublicKeyCredentialRpEntity it is a human-palatable identifier for the Relying Party,
|
||||
// intended only for display. For example, "ACME Corporation", "Wonderful Widgets, Inc." or "ОАО Примертех".
|
||||
//
|
||||
// When inherited by PublicKeyCredentialUserEntity, it is a human-palatable identifier for a user account. It is
|
||||
// intended only for display, i.e., aiding the user in determining the difference between user accounts with similar
|
||||
// displayNames. For example, "alexm", "alex.p.mueller@example.com" or "+14255551234".
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func NewCredentialEntity(name string) CredentialEntity {
|
||||
return CredentialEntity{
|
||||
Name: name,
|
||||
}
|
||||
}
|
||||
|
||||
type CredentialParameter struct {
|
||||
Type CredentialType `json:"type"`
|
||||
Algorithm types.COSEAlgorithmIdentifier `json:"alg"`
|
||||
}
|
||||
|
||||
func NewCredentialParameter(ki *types.KeyInfo) CredentialParameter {
|
||||
return CredentialParameter{
|
||||
Type: CredentialTypePublicKeyCredential,
|
||||
Algorithm: ki.Algorithm.CoseIdentifier(),
|
||||
}
|
||||
}
|
||||
|
||||
func ExtractCredentialParameters(p *types.Params) []CredentialParameter {
|
||||
var keys []*types.KeyInfo
|
||||
for k, v := range p.AllowedPublicKeys {
|
||||
if strings.Contains(k, "webauthn") {
|
||||
keys = append(keys, v)
|
||||
}
|
||||
}
|
||||
var cparams []CredentialParameter
|
||||
for _, ki := range keys {
|
||||
cparams = append(cparams, NewCredentialParameter(ki))
|
||||
}
|
||||
return cparams
|
||||
}
|
||||
|
||||
type RelyingPartyEntity struct {
|
||||
CredentialEntity
|
||||
|
||||
// A unique identifier for the Relying Party entity, which sets the RP ID.
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
func NewRelayingParty(name string, origin string) RelyingPartyEntity {
|
||||
return RelyingPartyEntity{
|
||||
CredentialEntity: NewCredentialEntity(origin),
|
||||
ID: origin,
|
||||
}
|
||||
}
|
||||
|
||||
type UserEntity struct {
|
||||
CredentialEntity
|
||||
// A human-palatable name for the user account, intended only for display.
|
||||
// For example, "Alex P. Müller" or "田中 倫". The Relying Party SHOULD let
|
||||
// the user choose this, and SHOULD NOT restrict the choice more than necessary.
|
||||
DisplayName string `json:"displayName"`
|
||||
|
||||
// ID is the user handle of the user account entity. To ensure secure operation,
|
||||
// authentication and authorization decisions MUST be made on the basis of this id
|
||||
// member, not the displayName nor name members. See Section 6.1 of
|
||||
// [RFC8266](https://www.w3.org/TR/webauthn/#biblio-rfc8266).
|
||||
ID any `json:"id"`
|
||||
}
|
||||
|
||||
func NewUserEntity(name string, subject string, cid string) UserEntity {
|
||||
return UserEntity{
|
||||
CredentialEntity: NewCredentialEntity(name),
|
||||
DisplayName: subject,
|
||||
ID: cid,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package builder
|
||||
|
||||
import (
|
||||
"github.com/onsonr/crypto"
|
||||
"github.com/onsonr/sonr/x/did/types"
|
||||
)
|
||||
|
||||
type Signer interface {
|
||||
Sign(msg []byte) ([]byte, error)
|
||||
Verify(msg []byte, sig []byte) error
|
||||
PublicKey() []byte
|
||||
}
|
||||
|
||||
type signer struct {
|
||||
user *types.Keyshare
|
||||
val *types.Keyshare
|
||||
}
|
||||
|
||||
func (k signer) Sign(msg []byte) ([]byte, error) {
|
||||
valSignFunc, err := crypto.GetSignFunc(k.val, msg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
usrSignFunc, err := crypto.GetSignFunc(k.user, msg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
sig, err := crypto.RunMPCSign(valSignFunc, usrSignFunc)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return crypto.SerializeMPCSignature(sig)
|
||||
}
|
||||
|
||||
func (k signer) Verify(msg []byte, sig []byte) error {
|
||||
sigMpc, err := crypto.DeserializeMPCSignature(sig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
pk, err := crypto.GetECDSAPublicKey(k.val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ok := crypto.VerifyMPCSignature(sigMpc, msg, pk)
|
||||
if !ok {
|
||||
return types.ErrInvalidSignature
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (k signer) PublicKey() []byte {
|
||||
if k.user != nil {
|
||||
return k.user.PublicKey
|
||||
}
|
||||
if k.val != nil {
|
||||
return k.val.PublicKey
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
package builder
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"reflect"
|
||||
|
||||
"github.com/go-webauthn/webauthn/protocol"
|
||||
)
|
||||
|
||||
// Credential contains all needed information about a WebAuthn credential for storage.
|
||||
type Credential struct {
|
||||
Subject string `json:"handle"`
|
||||
AttestationType string `json:"attestationType"`
|
||||
Origin string `json:"origin"`
|
||||
CredentialID []byte `json:"id"`
|
||||
PublicKey []byte `json:"publicKey"`
|
||||
Transport []string `json:"transport"`
|
||||
SignCount uint32 `json:"signCount"`
|
||||
UserPresent bool `json:"userPresent"`
|
||||
UserVerified bool `json:"userVerified"`
|
||||
BackupEligible bool `json:"backupEligible"`
|
||||
BackupState bool `json:"backupState"`
|
||||
CloneWarning bool `json:"cloneWarning"`
|
||||
}
|
||||
|
||||
// NewCredential will return a credential pointer on successful validation of a registration response.
|
||||
func NewCredential(c *protocol.ParsedCredentialCreationData, origin, handle string) *Credential {
|
||||
return &Credential{
|
||||
Subject: handle,
|
||||
Origin: origin,
|
||||
AttestationType: c.Response.AttestationObject.Format,
|
||||
CredentialID: c.Response.AttestationObject.AuthData.AttData.CredentialID,
|
||||
PublicKey: c.Response.AttestationObject.AuthData.AttData.CredentialPublicKey,
|
||||
Transport: NormalizeTransports(c.Response.Transports),
|
||||
SignCount: c.Response.AttestationObject.AuthData.Counter,
|
||||
UserPresent: c.Response.AttestationObject.AuthData.Flags.HasUserPresent(),
|
||||
UserVerified: c.Response.AttestationObject.AuthData.Flags.HasUserVerified(),
|
||||
BackupEligible: c.Response.AttestationObject.AuthData.Flags.HasBackupEligible(),
|
||||
BackupState: c.Response.AttestationObject.AuthData.Flags.HasAttestedCredentialData(),
|
||||
}
|
||||
}
|
||||
|
||||
// Descriptor converts a Credential into a protocol.CredentialDescriptor.
|
||||
func (c *Credential) Descriptor() protocol.CredentialDescriptor {
|
||||
return protocol.CredentialDescriptor{
|
||||
Type: protocol.PublicKeyCredentialType,
|
||||
CredentialID: c.CredentialID,
|
||||
Transport: ModuleTransportsToProtocol(c.Transport),
|
||||
AttestationType: c.AttestationType,
|
||||
}
|
||||
}
|
||||
|
||||
// This is a signal that the authenticator may be cloned, see CloneWarning above for more information.
|
||||
func (a *Credential) UpdateCounter(authDataCount uint32) {
|
||||
if authDataCount <= a.SignCount && (authDataCount != 0 || a.SignCount != 0) {
|
||||
a.CloneWarning = true
|
||||
return
|
||||
}
|
||||
|
||||
a.SignCount = authDataCount
|
||||
}
|
||||
|
||||
type CredentialDescriptor struct {
|
||||
// The valid credential types.
|
||||
Type CredentialType `json:"type"`
|
||||
|
||||
// CredentialID The ID of a credential to allow/disallow.
|
||||
CredentialID URLEncodedBase64 `json:"id"`
|
||||
|
||||
// The authenticator transports that can be used.
|
||||
Transport []AuthenticatorTransport `json:"transports,omitempty"`
|
||||
|
||||
// The AttestationType from the Credential. Used internally only.
|
||||
AttestationType string `json:"-"`
|
||||
}
|
||||
|
||||
func NewCredentialDescriptor(credentialID string, transports []AuthenticatorTransport, attestationType string) *CredentialDescriptor {
|
||||
return &CredentialDescriptor{
|
||||
CredentialID: URLEncodedBase64(credentialID),
|
||||
Transport: transports,
|
||||
AttestationType: attestationType,
|
||||
Type: CredentialTypePublicKeyCredential,
|
||||
}
|
||||
}
|
||||
|
||||
type AuthenticatorSelection struct {
|
||||
// AuthenticatorAttachment If this member is present, eligible authenticators are filtered to only
|
||||
// authenticators attached with the specified AuthenticatorAttachment enum.
|
||||
AuthenticatorAttachment AuthenticatorAttachment `json:"authenticatorAttachment,omitempty"`
|
||||
|
||||
// RequireResidentKey this member describes the Relying Party's requirements regarding resident
|
||||
// credentials. If the parameter is set to true, the authenticator MUST create a client-side-resident
|
||||
// public key credential source when creating a public key credential.
|
||||
RequireResidentKey *bool `json:"requireResidentKey,omitempty"`
|
||||
|
||||
// ResidentKey this member describes the Relying Party's requirements regarding resident
|
||||
// credentials per Webauthn Level 2.
|
||||
ResidentKey ResidentKeyRequirement `json:"residentKey,omitempty"`
|
||||
|
||||
// UserVerification This member describes the Relying Party's requirements regarding user verification for
|
||||
// the create() operation. Eligible authenticators are filtered to only those capable of satisfying this
|
||||
// requirement.
|
||||
UserVerification UserVerificationRequirement `json:"userVerification,omitempty"`
|
||||
}
|
||||
|
||||
type AuthenticatorData struct {
|
||||
RPIDHash []byte `json:"rpid"`
|
||||
Flags AuthenticatorFlags `json:"flags"`
|
||||
Counter uint32 `json:"sign_count"`
|
||||
AttData AttestedCredentialData `json:"att_data"`
|
||||
ExtData []byte `json:"ext_data"`
|
||||
}
|
||||
|
||||
type AttestationObject struct {
|
||||
// The authenticator data, including the newly created public key. See AuthenticatorData for more info
|
||||
AuthData AuthenticatorData
|
||||
|
||||
// The byteform version of the authenticator data, used in part for signature validation
|
||||
RawAuthData []byte `json:"authData"`
|
||||
|
||||
// The format of the Attestation data.
|
||||
Format string `json:"fmt"`
|
||||
|
||||
// The attestation statement data sent back if attestation is requested.
|
||||
AttStatement map[string]any `json:"attStmt,omitempty"`
|
||||
}
|
||||
|
||||
type URLEncodedBase64 []byte
|
||||
|
||||
func (e URLEncodedBase64) String() string {
|
||||
return base64.RawURLEncoding.EncodeToString(e)
|
||||
}
|
||||
|
||||
// UnmarshalJSON base64 decodes a URL-encoded value, storing the result in the
|
||||
// provided byte slice.
|
||||
func (e *URLEncodedBase64) UnmarshalJSON(data []byte) error {
|
||||
if bytes.Equal(data, []byte("null")) {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Trim the leading spaces.
|
||||
data = bytes.Trim(data, "\"")
|
||||
|
||||
// Trim the trailing equal characters.
|
||||
data = bytes.TrimRight(data, "=")
|
||||
|
||||
out := make([]byte, base64.RawURLEncoding.DecodedLen(len(data)))
|
||||
|
||||
n, err := base64.RawURLEncoding.Decode(out, data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
v := reflect.ValueOf(e).Elem()
|
||||
v.SetBytes(out[:n])
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON base64 encodes a non URL-encoded value, storing the result in the
|
||||
// provided byte slice.
|
||||
func (e URLEncodedBase64) MarshalJSON() ([]byte, error) {
|
||||
if e == nil {
|
||||
return []byte("null"), nil
|
||||
}
|
||||
|
||||
return []byte(`"` + base64.RawURLEncoding.EncodeToString(e) + `"`), nil
|
||||
}
|
||||
+13
-12
@@ -3,22 +3,22 @@ package module
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
|
||||
|
||||
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
|
||||
|
||||
"cosmossdk.io/core/address"
|
||||
"cosmossdk.io/core/appmodule"
|
||||
"cosmossdk.io/core/store"
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
nftkeeper "cosmossdk.io/x/nft/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
|
||||
modulev1 "github.com/onsonr/hway/api/did/module/v1"
|
||||
"github.com/onsonr/hway/x/did/keeper"
|
||||
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
|
||||
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
|
||||
|
||||
modulev1 "github.com/onsonr/sonr/api/did/module/v1"
|
||||
"github.com/onsonr/sonr/x/did/keeper"
|
||||
)
|
||||
|
||||
var _ appmodule.AppModule = AppModule{}
|
||||
@@ -44,6 +44,7 @@ type ModuleInputs struct {
|
||||
AddressCodec address.Codec
|
||||
|
||||
AccountKeeper authkeeper.AccountKeeper
|
||||
NFTKeeper nftkeeper.Keeper
|
||||
StakingKeeper stakingkeeper.Keeper
|
||||
SlashingKeeper slashingkeeper.Keeper
|
||||
}
|
||||
@@ -58,8 +59,8 @@ type ModuleOutputs struct {
|
||||
func ProvideModule(in ModuleInputs) ModuleOutputs {
|
||||
govAddr := authtypes.NewModuleAddress(govtypes.ModuleName).String()
|
||||
|
||||
k := keeper.NewKeeper(in.Cdc, in.StoreService, in.AccountKeeper, log.NewLogger(os.Stderr), govAddr)
|
||||
m := NewAppModule(in.Cdc, k)
|
||||
k := keeper.NewKeeper(in.Cdc, in.StoreService, in.AccountKeeper, in.NFTKeeper, &in.StakingKeeper, log.NewLogger(os.Stderr), govAddr)
|
||||
m := NewAppModule(in.Cdc, k, in.NFTKeeper)
|
||||
|
||||
return ModuleOutputs{Module: m, Keeper: k, Out: depinject.Out{}}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/onsonr/sonr/x/did/builder"
|
||||
"github.com/onsonr/sonr/x/did/types"
|
||||
"google.golang.org/grpc/peer"
|
||||
)
|
||||
|
||||
type Context struct {
|
||||
SDKCtx sdk.Context
|
||||
Keeper Keeper
|
||||
Peer *peer.Peer
|
||||
}
|
||||
|
||||
func (k Keeper) CurrentCtx(goCtx context.Context) Context {
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
peer, _ := peer.FromContext(goCtx)
|
||||
return Context{SDKCtx: ctx, Peer: peer, Keeper: k}
|
||||
}
|
||||
|
||||
func (c Context) Params() *types.Params {
|
||||
return c.Keeper.GetParams(c.SDK())
|
||||
}
|
||||
|
||||
func (c Context) SDK() sdk.Context {
|
||||
return c.SDKCtx
|
||||
}
|
||||
|
||||
func (c Context) IsAnonymous() bool {
|
||||
if c.Peer == nil {
|
||||
return true
|
||||
}
|
||||
return c.Peer.Addr == nil
|
||||
}
|
||||
|
||||
func (c Context) PeerID() string {
|
||||
if c.Peer == nil {
|
||||
return ""
|
||||
}
|
||||
return c.Peer.Addr.String()
|
||||
}
|
||||
|
||||
func (c Context) GetService(origin string) (*types.Service, error) {
|
||||
rec, err := c.Keeper.OrmDB.ServiceRecordTable().GetByOrigin(c.SDK(), origin)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return builder.ModuleFormatAPIServiceRecord(rec), nil
|
||||
}
|
||||
|
||||
func (c Context) GetServiceInfo(origin string) *types.ServiceInfo {
|
||||
rec, _ := c.GetService(origin)
|
||||
if rec == nil {
|
||||
return &types.ServiceInfo{Exists: false, Origin: origin, Fingerprint: types.ComputeOriginTXTRecord(origin)}
|
||||
}
|
||||
return &types.ServiceInfo{Exists: true, Origin: origin, Fingerprint: types.ComputeOriginTXTRecord(origin), Service: rec}
|
||||
}
|
||||
+40
-1
@@ -2,9 +2,12 @@ package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"cosmossdk.io/log"
|
||||
"github.com/onsonr/hway/x/did/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
"github.com/onsonr/sonr/x/did/types"
|
||||
)
|
||||
|
||||
// Logger returns the logger
|
||||
@@ -35,3 +38,39 @@ func (k *Keeper) ExportGenesis(ctx context.Context) *types.GenesisState {
|
||||
Params: params,
|
||||
}
|
||||
}
|
||||
|
||||
// CheckValidatorExists checks if a validator exists
|
||||
func (k Keeper) CheckValidatorExists(ctx sdk.Context, addr string) bool {
|
||||
address, err := sdk.ValAddressFromBech32(addr)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
ok, err := k.StakingKeeper.Validator(ctx, address)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
if ok != nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// GetAverageBlockTime returns the average block time in seconds
|
||||
func (k Keeper) GetAverageBlockTime(ctx sdk.Context) float64 {
|
||||
return float64(ctx.BlockTime().Sub(ctx.BlockTime()).Seconds())
|
||||
}
|
||||
|
||||
// GetParams returns the module parameters.
|
||||
func (k Keeper) GetParams(ctx sdk.Context) *types.Params {
|
||||
p, err := k.Params.Get(ctx)
|
||||
if err != nil {
|
||||
p = types.DefaultParams()
|
||||
}
|
||||
params := p.ActiveParams(k.HasIPFSConnection())
|
||||
return ¶ms
|
||||
}
|
||||
|
||||
// GetExpirationBlockHeight returns the block height at which the given duration will have passed
|
||||
func (k Keeper) GetExpirationBlockHeight(ctx sdk.Context, duration time.Duration) int64 {
|
||||
return ctx.BlockHeight() + int64(duration.Seconds()/k.GetAverageBlockTime(ctx))
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/onsonr/hway/x/did/types"
|
||||
"github.com/onsonr/sonr/x/did/types"
|
||||
)
|
||||
|
||||
func TestGenesis(t *testing.T) {
|
||||
@@ -20,7 +20,6 @@ func TestGenesis(t *testing.T) {
|
||||
err := f.k.InitGenesis(f.ctx, genesisState)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
||||
got := f.k.ExportGenesis(f.ctx)
|
||||
require.NotNil(t, got)
|
||||
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/ipfs/boxo/files"
|
||||
"github.com/ipfs/boxo/path"
|
||||
"github.com/ipfs/kubo/client/rpc"
|
||||
"github.com/ipfs/kubo/core/coreiface/options"
|
||||
"github.com/onsonr/sonr/internal/vfs"
|
||||
)
|
||||
|
||||
// assembleInitialVault assembles the initial vault
|
||||
func (k Keeper) assembleInitialVault(ctx sdk.Context) (string, int64, error) {
|
||||
cid, err := k.ipfsClient.Unixfs().Add(context.Background(), vfs.AssembleDirectory())
|
||||
if err != nil {
|
||||
return "", 0, err
|
||||
}
|
||||
return cid.String(), k.GetExpirationBlockHeight(ctx, time.Second*15), nil
|
||||
}
|
||||
|
||||
// pinInitialVault pins the initial vault to the local IPFS node
|
||||
func (k Keeper) pinInitialVault(_ sdk.Context, cid string, address string) (bool, error) {
|
||||
// Resolve the path
|
||||
path, err := path.NewPath(cid)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
// 1. Initialize vault.db sqlite database in local IPFS with Mount
|
||||
|
||||
// 2. Insert the InitialWalletAccounts
|
||||
|
||||
// 3. Publish the path to the IPNS
|
||||
_, err = k.ipfsClient.Name().Publish(context.Background(), path, options.Name.Key(address))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
// 4. Insert the accounts into x/auth
|
||||
|
||||
// 5. Insert the controller into state
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// GetFromIPFS gets a file from the local IPFS node
|
||||
func (k Keeper) GetFromIPFS(ctx sdk.Context, cid string) (files.Directory, error) {
|
||||
path, err := path.NewPath(cid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
node, err := k.ipfsClient.Unixfs().Get(ctx, path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dir, ok := node.(files.Directory)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("retrieved node is not a directory")
|
||||
}
|
||||
return dir, nil
|
||||
}
|
||||
|
||||
// HasIPFSConnection returns true if the IPFS client is initialized
|
||||
func (k *Keeper) HasIPFSConnection() bool {
|
||||
if k.ipfsClient == nil {
|
||||
ipfsClient, err := rpc.NewLocalApi()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
k.ipfsClient = ipfsClient
|
||||
}
|
||||
return k.ipfsClient != nil
|
||||
}
|
||||
|
||||
// HasPathInIPFS checks if a file is in the local IPFS node
|
||||
func (k Keeper) HasPathInIPFS(ctx sdk.Context, cid string) (bool, error) {
|
||||
path, err := path.NewPath(cid)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
v, err := k.ipfsClient.Unixfs().Get(ctx, path)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
if v == nil {
|
||||
return false, nil
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// PinToIPFS pins a file to the local IPFS node
|
||||
func (k Keeper) PinToIPFS(ctx sdk.Context, cid string, name string) error {
|
||||
path, err := path.NewPath(cid)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = k.ipfsClient.Pin().Add(ctx, path, options.Pin.Name(name))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
+87
-9
@@ -5,13 +5,18 @@ import (
|
||||
storetypes "cosmossdk.io/core/store"
|
||||
"cosmossdk.io/log"
|
||||
"cosmossdk.io/orm/model/ormdb"
|
||||
nftkeeper "cosmossdk.io/x/nft/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
|
||||
apiv1 "github.com/onsonr/hway/api/did/v1"
|
||||
"github.com/onsonr/hway/x/did/types"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
stakkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
|
||||
"github.com/ipfs/kubo/client/rpc"
|
||||
|
||||
apiv1 "github.com/onsonr/sonr/api/did/v1"
|
||||
"github.com/onsonr/sonr/x/did/types"
|
||||
)
|
||||
|
||||
// Keeper defines the middleware keeper.
|
||||
@@ -26,18 +31,32 @@ type Keeper struct {
|
||||
Schema collections.Schema
|
||||
|
||||
AccountKeeper authkeeper.AccountKeeper
|
||||
NftKeeper nftkeeper.Keeper
|
||||
StakingKeeper *stakkeeper.Keeper
|
||||
|
||||
authority string
|
||||
authority string
|
||||
ipfsClient *rpc.HttpApi
|
||||
}
|
||||
|
||||
// NewKeeper creates a new poa Keeper instance
|
||||
func NewKeeper(cdc codec.BinaryCodec, storeService storetypes.KVStoreService, accKeeper authkeeper.AccountKeeper, logger log.Logger, authority string) Keeper {
|
||||
func NewKeeper(
|
||||
cdc codec.BinaryCodec,
|
||||
storeService storetypes.KVStoreService,
|
||||
accKeeper authkeeper.AccountKeeper,
|
||||
nftKeeper nftkeeper.Keeper,
|
||||
stkKeeper *stakkeeper.Keeper,
|
||||
logger log.Logger,
|
||||
authority string,
|
||||
) Keeper {
|
||||
logger = logger.With(log.ModuleKey, "x/"+types.ModuleName)
|
||||
sb := collections.NewSchemaBuilder(storeService)
|
||||
if authority == "" {
|
||||
authority = authtypes.NewModuleAddress(govtypes.ModuleName).String()
|
||||
}
|
||||
db, err := ormdb.NewModuleDB(&types.ORMModuleSchema, ormdb.ModuleDBOptions{KVStoreService: storeService})
|
||||
db, err := ormdb.NewModuleDB(
|
||||
&types.ORMModuleSchema,
|
||||
ormdb.ModuleDBOptions{KVStoreService: storeService},
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -45,13 +64,24 @@ func NewKeeper(cdc codec.BinaryCodec, storeService storetypes.KVStoreService, ac
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// Initialize IPFS client
|
||||
ipfsClient, _ := rpc.NewLocalApi()
|
||||
k := Keeper{
|
||||
cdc: cdc,
|
||||
logger: logger,
|
||||
Params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)),
|
||||
ipfsClient: ipfsClient,
|
||||
cdc: cdc,
|
||||
logger: logger,
|
||||
Params: collections.NewItem(
|
||||
sb,
|
||||
types.ParamsKey,
|
||||
"params",
|
||||
codec.CollValue[types.Params](cdc),
|
||||
),
|
||||
authority: authority,
|
||||
OrmDB: store,
|
||||
AccountKeeper: accKeeper,
|
||||
NftKeeper: nftKeeper,
|
||||
StakingKeeper: stkKeeper,
|
||||
}
|
||||
schema, err := sb.Build()
|
||||
if err != nil {
|
||||
@@ -61,3 +91,51 @@ func NewKeeper(cdc codec.BinaryCodec, storeService storetypes.KVStoreService, ac
|
||||
k.Schema = schema
|
||||
return k
|
||||
}
|
||||
|
||||
// IsClaimedServiceOrigin checks if a service origin is unclaimed
|
||||
func (k Keeper) IsUnclaimedServiceOrigin(ctx sdk.Context, origin string) bool {
|
||||
rec, _ := k.OrmDB.ServiceRecordTable().GetByOrigin(ctx, origin)
|
||||
return rec == nil
|
||||
}
|
||||
|
||||
// IsValidServiceOrigin checks if a service origin is valid
|
||||
func (k Keeper) IsValidServiceOrigin(ctx sdk.Context, origin string) bool {
|
||||
rec, err := k.OrmDB.ServiceRecordTable().GetByOrigin(ctx, origin)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
if rec == nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// VerifyMinimumStake checks if a validator has a minimum stake
|
||||
func (k Keeper) VerifyMinimumStake(ctx sdk.Context, addr string) bool {
|
||||
address, err := sdk.AccAddressFromBech32(addr)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
addval, err := sdk.ValAddressFromBech32(addr)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
del, err := k.StakingKeeper.GetDelegation(ctx, address, addval)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
if del.Shares.IsZero() {
|
||||
return false
|
||||
}
|
||||
return del.Shares.IsPositive()
|
||||
}
|
||||
|
||||
// VerifyServicePermissions checks if a service has permission
|
||||
func (k Keeper) VerifyServicePermissions(
|
||||
ctx sdk.Context,
|
||||
addr string,
|
||||
service string,
|
||||
permissions string,
|
||||
) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
+11
-12
@@ -3,12 +3,10 @@ package keeper_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"cosmossdk.io/core/store"
|
||||
"cosmossdk.io/log"
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
|
||||
nftkeeper "cosmossdk.io/x/nft/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/runtime"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
@@ -23,13 +21,13 @@ import (
|
||||
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
|
||||
"cosmossdk.io/core/store"
|
||||
|
||||
module "github.com/onsonr/hway/x/did"
|
||||
"github.com/onsonr/hway/x/did/keeper"
|
||||
"github.com/onsonr/hway/x/did/types"
|
||||
"github.com/strangelove-ventures/poa"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
module "github.com/onsonr/sonr/x/did"
|
||||
"github.com/onsonr/sonr/x/did/keeper"
|
||||
"github.com/onsonr/sonr/x/did/types"
|
||||
)
|
||||
|
||||
var maccPerms = map[string][]string{
|
||||
@@ -51,6 +49,7 @@ type testFixture struct {
|
||||
|
||||
accountkeeper authkeeper.AccountKeeper
|
||||
bankkeeper bankkeeper.BaseKeeper
|
||||
nftKeeper nftkeeper.Keeper
|
||||
stakingKeeper *stakingkeeper.Keeper
|
||||
mintkeeper mintkeeper.Keeper
|
||||
|
||||
@@ -80,10 +79,10 @@ func SetupTest(t *testing.T) *testFixture {
|
||||
registerBaseSDKModules(f, encCfg, storeService, logger, require)
|
||||
|
||||
// Setup POA Keeper.
|
||||
f.k = keeper.NewKeeper(encCfg.Codec, storeService, f.accountkeeper, logger, f.govModAddr)
|
||||
f.k = keeper.NewKeeper(encCfg.Codec, storeService, f.accountkeeper, f.nftKeeper, f.stakingKeeper, logger, f.govModAddr)
|
||||
f.msgServer = keeper.NewMsgServerImpl(f.k)
|
||||
f.queryServer = keeper.NewQuerier(f.k)
|
||||
f.appModule = module.NewAppModule(encCfg.Codec, f.k)
|
||||
f.appModule = module.NewAppModule(encCfg.Codec, f.k, f.nftKeeper)
|
||||
|
||||
return f
|
||||
}
|
||||
|
||||
+58
-13
@@ -3,10 +3,7 @@ package keeper
|
||||
import (
|
||||
"context"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
// "github.com/onsonr/hway/internal/local"
|
||||
"github.com/onsonr/hway/x/did/types"
|
||||
"github.com/onsonr/sonr/x/did/types"
|
||||
)
|
||||
|
||||
var _ types.QueryServer = Querier{}
|
||||
@@ -20,17 +17,65 @@ func NewQuerier(keeper Keeper) Querier {
|
||||
}
|
||||
|
||||
// Params returns the total set of did parameters.
|
||||
func (k Querier) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
|
||||
p, err := k.Keeper.Params.Get(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.QueryParamsResponse{Params: &p}, nil
|
||||
func (k Querier) Params(
|
||||
goCtx context.Context,
|
||||
req *types.QueryRequest,
|
||||
) (*types.QueryParamsResponse, error) {
|
||||
ctx := k.CurrentCtx(goCtx)
|
||||
return &types.QueryParamsResponse{Params: k.GetParams(ctx.SDK())}, nil
|
||||
}
|
||||
|
||||
// Resolve implements types.QueryServer.
|
||||
func (k Querier) Resolve(
|
||||
goCtx context.Context,
|
||||
req *types.QueryRequest,
|
||||
) (*types.QueryResponse, error) {
|
||||
ctx := k.CurrentCtx(goCtx)
|
||||
return &types.QueryResponse{Params: k.GetParams(ctx.SDK())}, nil
|
||||
}
|
||||
|
||||
// Service implements types.QueryServer.
|
||||
func (k Querier) Service(
|
||||
goCtx context.Context,
|
||||
req *types.QueryRequest,
|
||||
) (*types.QueryResponse, error) {
|
||||
ctx := k.CurrentCtx(goCtx)
|
||||
return &types.QueryResponse{Service: ctx.GetServiceInfo(req.GetOrigin()), Params: ctx.Params()}, nil
|
||||
}
|
||||
|
||||
// ParamsAssets implements types.QueryServer.
|
||||
func (k Querier) ParamsAssets(goCtx context.Context, req *types.QueryRequest) (*types.QueryResponse, error) {
|
||||
// ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
panic("ParamsAssets is unimplemented")
|
||||
return &types.QueryResponse{}, nil
|
||||
}
|
||||
|
||||
// ParamsByAsset implements types.QueryServer.
|
||||
func (k Querier) ParamsByAsset(goCtx context.Context, req *types.QueryRequest) (*types.QueryResponse, error) {
|
||||
// ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
panic("ParamsByAsset is unimplemented")
|
||||
return &types.QueryResponse{}, nil
|
||||
}
|
||||
|
||||
// ParamsKeys implements types.QueryServer.
|
||||
func (k Querier) ParamsKeys(goCtx context.Context, req *types.QueryRequest) (*types.QueryResponse, error) {
|
||||
// ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
panic("ParamsKeys is unimplemented")
|
||||
return &types.QueryResponse{}, nil
|
||||
}
|
||||
|
||||
// ParamsByKey implements types.QueryServer.
|
||||
func (k Querier) ParamsByKey(goCtx context.Context, req *types.QueryRequest) (*types.QueryResponse, error) {
|
||||
// ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
panic("ParamsByKey is unimplemented")
|
||||
return &types.QueryResponse{}, nil
|
||||
}
|
||||
|
||||
// RegistrationOptionsByKey implements types.QueryServer.
|
||||
func (k Querier) RegistrationOptionsByKey(goCtx context.Context, req *types.QueryRequest) (*types.QueryResponse, error) {
|
||||
// ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
panic("RegistrationOptionsByKey is unimplemented")
|
||||
return &types.QueryResponse{}, nil
|
||||
// Accounts implements types.QueryServer.
|
||||
func (k Querier) Accounts(goCtx context.Context, req *types.QueryAccountsRequest) (*types.QueryAccountsResponse, error) {
|
||||
// ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
|
||||
+107
-4
@@ -2,6 +2,14 @@ package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"cosmossdk.io/errors"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
|
||||
"github.com/onsonr/sonr/x/did/builder"
|
||||
"github.com/onsonr/sonr/x/did/types"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
@@ -22,12 +30,107 @@ func NewMsgServerImpl(keeper Keeper) types.MsgServer {
|
||||
return &msgServer{k: keeper}
|
||||
}
|
||||
|
||||
// UpdateParams updates the x/did module parameters.
|
||||
func (ms msgServer) UpdateParams(ctx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) {
|
||||
if ms.k.authority != msg.Authority {
|
||||
return nil, errors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", ms.k.authority, msg.Authority)
|
||||
// # AuthorizeService
|
||||
//
|
||||
// AuthorizeService implements types.MsgServer.
|
||||
func (ms msgServer) AuthorizeService(goCtx context.Context, msg *types.MsgAuthorizeService) (*types.MsgAuthorizeServiceResponse, error) {
|
||||
if ms.k.authority != msg.Controller {
|
||||
return nil, errors.Wrapf(
|
||||
govtypes.ErrInvalidSigner,
|
||||
"invalid authority; expected %s, got %s",
|
||||
ms.k.authority,
|
||||
msg.Controller,
|
||||
)
|
||||
}
|
||||
return &types.MsgAuthorizeServiceResponse{}, nil
|
||||
}
|
||||
|
||||
// # AllocateVault
|
||||
//
|
||||
// AllocateVault implements types.MsgServer.
|
||||
func (ms msgServer) AllocateVault(
|
||||
goCtx context.Context,
|
||||
msg *types.MsgAllocateVault,
|
||||
) (*types.MsgAllocateVaultResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
// 1.Check if the service origin is valid
|
||||
if ms.k.IsValidServiceOrigin(ctx, msg.Origin) {
|
||||
return nil, types.ErrInvalidServiceOrigin
|
||||
}
|
||||
|
||||
cid, expiryBlock, err := ms.k.assembleInitialVault(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
regOpts, err := builder.GetPublicKeyCredentialCreationOptions(msg.Origin, msg.Subject, cid, ms.k.GetParams(ctx))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Convert to string
|
||||
regOptsJSON, err := json.Marshal(regOpts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.MsgAllocateVaultResponse{
|
||||
ExpiryBlock: expiryBlock,
|
||||
Cid: cid,
|
||||
RegistrationOptions: string(regOptsJSON),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// # RegisterController
|
||||
//
|
||||
// RegisterController implements types.MsgServer.
|
||||
func (ms msgServer) RegisterController(
|
||||
goCtx context.Context,
|
||||
msg *types.MsgRegisterController,
|
||||
) (*types.MsgRegisterControllerResponse, error) {
|
||||
_ = sdk.UnwrapSDKContext(goCtx)
|
||||
return &types.MsgRegisterControllerResponse{}, nil
|
||||
}
|
||||
|
||||
// # RegisterService
|
||||
//
|
||||
// RegisterService implements types.MsgServer.
|
||||
func (ms msgServer) RegisterService(
|
||||
goCtx context.Context,
|
||||
msg *types.MsgRegisterService,
|
||||
) (*types.MsgRegisterServiceResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
|
||||
// 1.Check if the service origin is valid
|
||||
if !ms.k.IsValidServiceOrigin(ctx, msg.Service.Origin) {
|
||||
return nil, types.ErrInvalidServiceOrigin
|
||||
}
|
||||
return ms.k.insertService(ctx, msg.Service)
|
||||
}
|
||||
|
||||
// # SyncController
|
||||
//
|
||||
// SyncController implements types.MsgServer.
|
||||
func (ms msgServer) SyncController(ctx context.Context, msg *types.MsgSyncController) (*types.MsgSyncControllerResponse, error) {
|
||||
// ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
return &types.MsgSyncControllerResponse{}, nil
|
||||
}
|
||||
|
||||
// # UpdateParams
|
||||
//
|
||||
// UpdateParams updates the x/did module parameters.
|
||||
func (ms msgServer) UpdateParams(
|
||||
ctx context.Context,
|
||||
msg *types.MsgUpdateParams,
|
||||
) (*types.MsgUpdateParamsResponse, error) {
|
||||
if ms.k.authority != msg.Authority {
|
||||
return nil, errors.Wrapf(
|
||||
govtypes.ErrInvalidSigner,
|
||||
"invalid authority; expected %s, got %s",
|
||||
ms.k.authority,
|
||||
msg.Authority,
|
||||
)
|
||||
}
|
||||
return nil, ms.k.Params.Set(ctx, msg.Params)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
package keeper_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/onsonr/hway/x/did/types"
|
||||
)
|
||||
|
||||
func TestParams(t *testing.T) {
|
||||
f := SetupTest(t)
|
||||
require := require.New(t)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
request *types.MsgUpdateParams
|
||||
err bool
|
||||
}{
|
||||
{
|
||||
name: "fail; invalid authority",
|
||||
request: &types.MsgUpdateParams{
|
||||
Authority: f.addrs[0].String(),
|
||||
Params: types.DefaultParams(),
|
||||
},
|
||||
err: true,
|
||||
},
|
||||
{
|
||||
name: "success",
|
||||
request: &types.MsgUpdateParams{
|
||||
Authority: f.govModAddr,
|
||||
Params: types.DefaultParams(),
|
||||
},
|
||||
err: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
_, err := f.msgServer.UpdateParams(f.ctx, tc.request)
|
||||
|
||||
if tc.err {
|
||||
require.Error(err)
|
||||
} else {
|
||||
require.NoError(err)
|
||||
|
||||
r, err := f.queryServer.Params(f.ctx, &types.QueryParamsRequest{})
|
||||
require.NoError(err)
|
||||
|
||||
require.EqualValues(&tc.request.Params, r.Params)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,26 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
"github.com/onsonr/sonr/x/did/builder"
|
||||
"github.com/onsonr/sonr/x/did/types"
|
||||
)
|
||||
|
||||
// insertService inserts a service record into the database
|
||||
func (k Keeper) insertService(
|
||||
ctx sdk.Context,
|
||||
svc *types.Service,
|
||||
) (*types.MsgRegisterServiceResponse, error) {
|
||||
record := builder.APIFormatServiceRecord(svc)
|
||||
err := k.OrmDB.ServiceRecordTable().Insert(ctx, record)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &types.MsgRegisterServiceResponse{
|
||||
Success: true,
|
||||
Did: record.Id,
|
||||
}, nil
|
||||
func (k Keeper) insertAliasFromDisplayName() {
|
||||
}
|
||||
|
||||
|
||||
+20
-28
@@ -4,13 +4,14 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
|
||||
"cosmossdk.io/client/v2/autocli"
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
"cosmossdk.io/x/nft"
|
||||
nftkeeper "cosmossdk.io/x/nft/keeper"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
@@ -18,23 +19,21 @@ import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
|
||||
"github.com/onsonr/hway/x/did/keeper"
|
||||
"github.com/onsonr/hway/x/did/types"
|
||||
"github.com/onsonr/sonr/x/did/keeper"
|
||||
"github.com/onsonr/sonr/x/did/types"
|
||||
// this line is used by starport scaffolding # 1
|
||||
)
|
||||
|
||||
const (
|
||||
// ConsensusVersion defines the current x/did module consensus version.
|
||||
ConsensusVersion = 1
|
||||
|
||||
// this line is used by starport scaffolding # simapp/module/const
|
||||
)
|
||||
|
||||
var (
|
||||
_ module.AppModuleBasic = AppModuleBasic{}
|
||||
_ module.AppModuleGenesis = AppModule{}
|
||||
_ module.AppModule = AppModule{}
|
||||
|
||||
_ module.AppModuleBasic = AppModuleBasic{}
|
||||
_ module.AppModuleGenesis = AppModule{}
|
||||
_ module.AppModule = AppModule{}
|
||||
_ autocli.HasAutoCLIConfig = AppModule{}
|
||||
)
|
||||
|
||||
@@ -46,17 +45,20 @@ type AppModuleBasic struct {
|
||||
type AppModule struct {
|
||||
AppModuleBasic
|
||||
|
||||
keeper keeper.Keeper
|
||||
keeper keeper.Keeper
|
||||
nftKeeper nftkeeper.Keeper
|
||||
}
|
||||
|
||||
// NewAppModule constructor
|
||||
func NewAppModule(
|
||||
cdc codec.Codec,
|
||||
keeper keeper.Keeper,
|
||||
nftKeeper nftkeeper.Keeper,
|
||||
) *AppModule {
|
||||
return &AppModule{
|
||||
AppModuleBasic: AppModuleBasic{cdc: cdc},
|
||||
keeper: keeper,
|
||||
nftKeeper: nftKeeper,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +68,8 @@ func (a AppModuleBasic) Name() string {
|
||||
|
||||
func (a AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
|
||||
return cdc.MustMarshalJSON(&types.GenesisState{
|
||||
Params: types.DefaultParams(),
|
||||
GlobalIntegrity: types.DefaultGlobalIntegrity(),
|
||||
Params: types.DefaultParams(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -82,28 +85,13 @@ func (a AppModuleBasic) ValidateGenesis(marshaler codec.JSONCodec, _ client.TxEn
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {
|
||||
}
|
||||
|
||||
func (a AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
|
||||
err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx))
|
||||
if err != nil {
|
||||
// same behavior as in cosmos-sdk
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Disable in favor of autocli.go. If you wish to use these, it will override AutoCLI methods.
|
||||
/*
|
||||
func (a AppModuleBasic) GetTxCmd() *cobra.Command {
|
||||
return cli.NewTxCmd()
|
||||
}
|
||||
|
||||
func (a AppModuleBasic) GetQueryCmd() *cobra.Command {
|
||||
return cli.GetQueryCmd()
|
||||
}
|
||||
*/
|
||||
|
||||
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
|
||||
types.RegisterLegacyAminoCodec(cdc)
|
||||
}
|
||||
@@ -113,11 +101,15 @@ func (a AppModuleBasic) RegisterInterfaces(r codectypes.InterfaceRegistry) {
|
||||
}
|
||||
|
||||
func (a AppModule) InitGenesis(ctx sdk.Context, marshaler codec.JSONCodec, message json.RawMessage) []abci.ValidatorUpdate {
|
||||
genesisState := types.DefaultGenesis()
|
||||
if err := a.keeper.Params.Set(ctx, genesisState.Params); err != nil {
|
||||
didGenesisState := types.DefaultGenesis()
|
||||
if err := a.keeper.Params.Set(ctx, didGenesisState.Params); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
nftGenesisState := nft.DefaultGenesisState()
|
||||
if err := types.DefaultNFTClasses(nftGenesisState); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
a.nftKeeper.InitGenesis(ctx, nftGenesisState)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,9 @@ package types
|
||||
import (
|
||||
fmt "fmt"
|
||||
proto "github.com/cosmos/gogoproto/proto"
|
||||
io "io"
|
||||
math "math"
|
||||
math_bits "math/bits"
|
||||
math "math"
|
||||
)
|
||||
|
||||
@@ -20,6 +23,602 @@ var _ = math.Inf
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
type BtcAccount struct {
|
||||
}
|
||||
|
||||
func (m *BtcAccount) Reset() { *m = BtcAccount{} }
|
||||
func (m *BtcAccount) String() string { return proto.CompactTextString(m) }
|
||||
func (*BtcAccount) ProtoMessage() {}
|
||||
func (*BtcAccount) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_2125a09fb14c3bc3, []int{0}
|
||||
}
|
||||
func (m *BtcAccount) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *BtcAccount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_BtcAccount.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *BtcAccount) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_BtcAccount.Merge(m, src)
|
||||
}
|
||||
func (m *BtcAccount) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *BtcAccount) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_BtcAccount.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_BtcAccount proto.InternalMessageInfo
|
||||
|
||||
type EthAccount struct {
|
||||
}
|
||||
|
||||
func (m *EthAccount) Reset() { *m = EthAccount{} }
|
||||
func (m *EthAccount) String() string { return proto.CompactTextString(m) }
|
||||
func (*EthAccount) ProtoMessage() {}
|
||||
func (*EthAccount) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_2125a09fb14c3bc3, []int{1}
|
||||
}
|
||||
func (m *EthAccount) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *EthAccount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_EthAccount.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *EthAccount) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_EthAccount.Merge(m, src)
|
||||
}
|
||||
func (m *EthAccount) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *EthAccount) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_EthAccount.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_EthAccount proto.InternalMessageInfo
|
||||
|
||||
type IBCAccount struct {
|
||||
}
|
||||
|
||||
func (m *IBCAccount) Reset() { *m = IBCAccount{} }
|
||||
func (m *IBCAccount) String() string { return proto.CompactTextString(m) }
|
||||
func (*IBCAccount) ProtoMessage() {}
|
||||
func (*IBCAccount) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_2125a09fb14c3bc3, []int{2}
|
||||
}
|
||||
func (m *IBCAccount) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *IBCAccount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_IBCAccount.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *IBCAccount) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_IBCAccount.Merge(m, src)
|
||||
}
|
||||
func (m *IBCAccount) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *IBCAccount) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_IBCAccount.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_IBCAccount proto.InternalMessageInfo
|
||||
|
||||
type SnrAccount struct {
|
||||
}
|
||||
|
||||
func (m *SnrAccount) Reset() { *m = SnrAccount{} }
|
||||
func (m *SnrAccount) String() string { return proto.CompactTextString(m) }
|
||||
func (*SnrAccount) ProtoMessage() {}
|
||||
func (*SnrAccount) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_2125a09fb14c3bc3, []int{3}
|
||||
}
|
||||
func (m *SnrAccount) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *SnrAccount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_SnrAccount.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *SnrAccount) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_SnrAccount.Merge(m, src)
|
||||
}
|
||||
func (m *SnrAccount) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *SnrAccount) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_SnrAccount.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_SnrAccount proto.InternalMessageInfo
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*BtcAccount)(nil), "did.v1.BtcAccount")
|
||||
proto.RegisterType((*EthAccount)(nil), "did.v1.EthAccount")
|
||||
proto.RegisterType((*IBCAccount)(nil), "did.v1.IBCAccount")
|
||||
proto.RegisterType((*SnrAccount)(nil), "did.v1.SnrAccount")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("did/v1/accounts.proto", fileDescriptor_2125a09fb14c3bc3) }
|
||||
|
||||
var fileDescriptor_2125a09fb14c3bc3 = []byte{
|
||||
// 145 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4d, 0xc9, 0x4c, 0xd1,
|
||||
0x2f, 0x33, 0xd4, 0x4f, 0x4c, 0x4e, 0xce, 0x2f, 0xcd, 0x2b, 0x29, 0xd6, 0x2b, 0x28, 0xca, 0x2f,
|
||||
0xc9, 0x17, 0x62, 0x4b, 0xc9, 0x4c, 0xd1, 0x2b, 0x33, 0x54, 0xe2, 0xe1, 0xe2, 0x72, 0x2a, 0x49,
|
||||
0x76, 0x84, 0x48, 0x82, 0x78, 0xae, 0x25, 0x19, 0x48, 0x3c, 0x4f, 0x27, 0x67, 0x24, 0x5e, 0x70,
|
||||
0x5e, 0x11, 0x94, 0xe7, 0x64, 0x73, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e,
|
||||
0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51,
|
||||
0x4a, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0xf9, 0x79, 0xc5, 0xf9,
|
||||
0x79, 0x45, 0xfa, 0x60, 0xa2, 0x42, 0x1f, 0xe4, 0x92, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36,
|
||||
0xb0, 0x23, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x82, 0x7e, 0x89, 0x0a, 0x9d, 0x00, 0x00,
|
||||
0x00,
|
||||
}
|
||||
|
||||
func (m *BtcAccount) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *BtcAccount) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *BtcAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *EthAccount) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *EthAccount) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *EthAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *IBCAccount) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *IBCAccount) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *IBCAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *SnrAccount) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *SnrAccount) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *SnrAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func encodeVarintAccounts(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovAccounts(v)
|
||||
base := offset
|
||||
for v >= 1<<7 {
|
||||
dAtA[offset] = uint8(v&0x7f | 0x80)
|
||||
v >>= 7
|
||||
offset++
|
||||
}
|
||||
dAtA[offset] = uint8(v)
|
||||
return base
|
||||
}
|
||||
func (m *BtcAccount) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *EthAccount) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *IBCAccount) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *SnrAccount) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
return n
|
||||
}
|
||||
|
||||
func sovAccounts(x uint64) (n int) {
|
||||
return (math_bits.Len64(x|1) + 6) / 7
|
||||
}
|
||||
func sozAccounts(x uint64) (n int) {
|
||||
return sovAccounts(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
||||
}
|
||||
func (m *BtcAccount) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowAccounts
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: BtcAccount: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: BtcAccount: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipAccounts(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthAccounts
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *EthAccount) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowAccounts
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: EthAccount: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: EthAccount: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipAccounts(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthAccounts
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *IBCAccount) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowAccounts
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: IBCAccount: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: IBCAccount: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipAccounts(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthAccounts
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *SnrAccount) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowAccounts
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: SnrAccount: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: SnrAccount: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipAccounts(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthAccounts
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func skipAccounts(dAtA []byte) (n int, err error) {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
depth := 0
|
||||
for iNdEx < l {
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowAccounts
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= (uint64(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
wireType := int(wire & 0x7)
|
||||
switch wireType {
|
||||
case 0:
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowAccounts
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx++
|
||||
if dAtA[iNdEx-1] < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 1:
|
||||
iNdEx += 8
|
||||
case 2:
|
||||
var length int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowAccounts
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
length |= (int(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if length < 0 {
|
||||
return 0, ErrInvalidLengthAccounts
|
||||
}
|
||||
iNdEx += length
|
||||
case 3:
|
||||
depth++
|
||||
case 4:
|
||||
if depth == 0 {
|
||||
return 0, ErrUnexpectedEndOfGroupAccounts
|
||||
}
|
||||
depth--
|
||||
case 5:
|
||||
iNdEx += 4
|
||||
default:
|
||||
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
|
||||
}
|
||||
if iNdEx < 0 {
|
||||
return 0, ErrInvalidLengthAccounts
|
||||
}
|
||||
if depth == 0 {
|
||||
return iNdEx, nil
|
||||
}
|
||||
}
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
|
||||
var (
|
||||
ErrInvalidLengthAccounts = fmt.Errorf("proto: negative length found during unmarshaling")
|
||||
ErrIntOverflowAccounts = fmt.Errorf("proto: integer overflow")
|
||||
ErrUnexpectedEndOfGroupAccounts = fmt.Errorf("proto: unexpected end of group")
|
||||
)
|
||||
func init() { proto.RegisterFile("did/v1/accounts.proto", fileDescriptor_2125a09fb14c3bc3) }
|
||||
|
||||
var fileDescriptor_2125a09fb14c3bc3 = []byte{
|
||||
|
||||
+200
-4
@@ -1,11 +1,25 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"crypto/ecdsa"
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"strings"
|
||||
|
||||
fmt "fmt"
|
||||
|
||||
ethcrypto "github.com/ethereum/go-ethereum/crypto"
|
||||
"golang.org/x/crypto/sha3"
|
||||
|
||||
"github.com/cosmos/btcutil/bech32"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/codec/types"
|
||||
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/msgservice"
|
||||
"github.com/mr-tron/base58/base58"
|
||||
"github.com/onsonr/crypto"
|
||||
// this line is used by starport scaffolding # 1
|
||||
)
|
||||
|
||||
@@ -26,16 +40,198 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
|
||||
}
|
||||
|
||||
func RegisterInterfaces(registry types.InterfaceRegistry) {
|
||||
//registry.RegisterImplementations(
|
||||
//(*cryptotypes.PubKey)(nil),
|
||||
// &PublicKey{},
|
||||
//)
|
||||
registry.RegisterImplementations(
|
||||
(*cryptotypes.PubKey)(nil),
|
||||
&PubKey{},
|
||||
)
|
||||
|
||||
registry.RegisterImplementations(
|
||||
(*sdk.Msg)(nil),
|
||||
&MsgUpdateParams{},
|
||||
&MsgRegisterController{},
|
||||
&MsgRegisterService{},
|
||||
&MsgAllocateVault{},
|
||||
)
|
||||
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
|
||||
}
|
||||
|
||||
type ChainCode uint32
|
||||
|
||||
const (
|
||||
ChainCodeBTC ChainCode = 0
|
||||
ChainCodeETH ChainCode = 60
|
||||
ChainCodeIBC ChainCode = 118
|
||||
ChainCodeSNR ChainCode = 703
|
||||
)
|
||||
|
||||
var InitialChainCodes = map[DIDNamespace]ChainCode{
|
||||
DIDNamespace_DID_NAMESPACE_BITCOIN: ChainCodeBTC,
|
||||
DIDNamespace_DID_NAMESPACE_IBC: ChainCodeIBC,
|
||||
DIDNamespace_DID_NAMESPACE_ETHEREUM: ChainCodeETH,
|
||||
DIDNamespace_DID_NAMESPACE_SONR: ChainCodeSNR,
|
||||
}
|
||||
|
||||
func (c ChainCode) FormatAddress(pubKey *PubKey) (string, error) {
|
||||
switch c {
|
||||
case ChainCodeBTC:
|
||||
return bech32.Encode("bc", pubKey.Bytes())
|
||||
|
||||
case ChainCodeETH:
|
||||
epk, err := pubKey.ECDSA()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return ComputeEthAddress(*epk), nil
|
||||
|
||||
case ChainCodeSNR:
|
||||
return bech32.Encode("idx", pubKey.Bytes())
|
||||
|
||||
case ChainCodeIBC:
|
||||
return bech32.Encode("cosmos", pubKey.Bytes())
|
||||
|
||||
}
|
||||
return "", ErrUnsopportedChainCode
|
||||
}
|
||||
|
||||
func (n DIDNamespace) ChainCode() (uint32, error) {
|
||||
switch n {
|
||||
case DIDNamespace_DID_NAMESPACE_BITCOIN:
|
||||
return 0, nil
|
||||
case DIDNamespace_DID_NAMESPACE_ETHEREUM:
|
||||
return 64, nil
|
||||
case DIDNamespace_DID_NAMESPACE_IBC:
|
||||
return 118, nil
|
||||
case DIDNamespace_DID_NAMESPACE_SONR:
|
||||
return 703, nil
|
||||
default:
|
||||
return 0, fmt.Errorf("unsupported chain")
|
||||
}
|
||||
}
|
||||
|
||||
func (n DIDNamespace) DIDMethod() string {
|
||||
switch n {
|
||||
case DIDNamespace_DID_NAMESPACE_IPFS:
|
||||
return "ipfs"
|
||||
case DIDNamespace_DID_NAMESPACE_SONR:
|
||||
return "sonr"
|
||||
case DIDNamespace_DID_NAMESPACE_BITCOIN:
|
||||
return "btcr"
|
||||
case DIDNamespace_DID_NAMESPACE_ETHEREUM:
|
||||
return "ethr"
|
||||
case DIDNamespace_DID_NAMESPACE_IBC:
|
||||
return "ibcr"
|
||||
case DIDNamespace_DID_NAMESPACE_WEBAUTHN:
|
||||
return "webauthn"
|
||||
case DIDNamespace_DID_NAMESPACE_DWN:
|
||||
return "motr"
|
||||
case DIDNamespace_DID_NAMESPACE_SERVICE:
|
||||
return "web"
|
||||
default:
|
||||
return "n/a"
|
||||
}
|
||||
}
|
||||
|
||||
func (n DIDNamespace) FormatDID(subject string) string {
|
||||
return fmt.Sprintf("%s:%s", n.DIDMethod(), subject)
|
||||
}
|
||||
|
||||
type EncodedKey []byte
|
||||
|
||||
func (e KeyEncoding) EncodeRaw(data []byte) (EncodedKey, error) {
|
||||
switch e {
|
||||
case KeyEncoding_KEY_ENCODING_RAW:
|
||||
return data, nil
|
||||
case KeyEncoding_KEY_ENCODING_HEX:
|
||||
return []byte(hex.EncodeToString(data)), nil
|
||||
case KeyEncoding_KEY_ENCODING_MULTIBASE:
|
||||
return []byte(base58.Encode(data)), nil
|
||||
default:
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (e KeyEncoding) DecodeRaw(data EncodedKey) ([]byte, error) {
|
||||
switch e {
|
||||
case KeyEncoding_KEY_ENCODING_RAW:
|
||||
return data, nil
|
||||
case KeyEncoding_KEY_ENCODING_HEX:
|
||||
return hex.DecodeString(string(data))
|
||||
case KeyEncoding_KEY_ENCODING_MULTIBASE:
|
||||
return base58.Decode(string(data))
|
||||
default:
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
|
||||
type COSEAlgorithmIdentifier int
|
||||
|
||||
func (k KeyAlgorithm) CoseIdentifier() COSEAlgorithmIdentifier {
|
||||
switch k {
|
||||
case KeyAlgorithm_KEY_ALGORITHM_ES256:
|
||||
return COSEAlgorithmIdentifier(-7)
|
||||
case KeyAlgorithm_KEY_ALGORITHM_ES384:
|
||||
return COSEAlgorithmIdentifier(-35)
|
||||
case KeyAlgorithm_KEY_ALGORITHM_ES512:
|
||||
return COSEAlgorithmIdentifier(-36)
|
||||
case KeyAlgorithm_KEY_ALGORITHM_EDDSA:
|
||||
return COSEAlgorithmIdentifier(-8)
|
||||
case KeyAlgorithm_KEY_ALGORITHM_ES256K:
|
||||
return COSEAlgorithmIdentifier(-10)
|
||||
default:
|
||||
return COSEAlgorithmIdentifier(0)
|
||||
}
|
||||
}
|
||||
|
||||
func (k KeyCurve) ComputePublicKey(data []byte) (*PubKey, error) {
|
||||
return nil, ErrUnsupportedKeyCurve
|
||||
}
|
||||
|
||||
func (k *Keyshare) Equals(o crypto.MPCShare) bool {
|
||||
opk := o.GetPublicKey()
|
||||
if opk != nil && k.PublicKey == nil {
|
||||
return false
|
||||
}
|
||||
return k.GetRole() == o.GetRole()
|
||||
}
|
||||
|
||||
func (k *Keyshare) IsUser() bool {
|
||||
return k.Role == 2
|
||||
}
|
||||
|
||||
func (k *Keyshare) IsValidator() bool {
|
||||
return k.Role == 1
|
||||
}
|
||||
|
||||
// ComputeOriginTXTRecord generates a fingerprint for a given origin
|
||||
func ComputeOriginTXTRecord(origin string) string {
|
||||
h := sha256.New()
|
||||
h.Write([]byte(origin))
|
||||
return fmt.Sprintf("v=sonr,o=%s,p=%x", origin, h.Sum(nil))
|
||||
}
|
||||
|
||||
func ComputeEthAddress(pk ecdsa.PublicKey) string {
|
||||
// Generate Ethereum address
|
||||
address := ethcrypto.PubkeyToAddress(pk)
|
||||
|
||||
// Apply ERC-55 checksum encoding
|
||||
addr := address.Hex()
|
||||
addr = strings.ToLower(addr)
|
||||
addr = strings.TrimPrefix(addr, "0x")
|
||||
hash := sha3.NewLegacyKeccak256()
|
||||
hash.Write([]byte(addr))
|
||||
hashBytes := hash.Sum(nil)
|
||||
|
||||
result := "0x"
|
||||
for i, c := range addr {
|
||||
if c >= '0' && c <= '9' {
|
||||
result += string(c)
|
||||
} else {
|
||||
if hashBytes[i/2]>>(4-i%2*4)&0xf >= 8 {
|
||||
result += strings.ToUpper(string(c))
|
||||
} else {
|
||||
result += string(c)
|
||||
}
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package types
|
||||
|
||||
// Coin represents a cryptocurrency
|
||||
type Coin interface {
|
||||
// FormatAddress formats a public key into an address
|
||||
FormatAddress(pubKey []byte) (string, error)
|
||||
|
||||
// GetIndex returns the coin type index
|
||||
GetIndex() int64
|
||||
|
||||
// GetPath returns the coin component path
|
||||
GetPath() uint32
|
||||
|
||||
// GetSymbol returns the coin symbol
|
||||
GetSymbol() string
|
||||
|
||||
// GetMethod returns the coin DID method
|
||||
GetMethod() string
|
||||
|
||||
// GetName returns the coin name
|
||||
GetName() string
|
||||
}
|
||||
|
||||
// CoinBTCType is the coin type for BTC
|
||||
const CoinBTCType = int64(0)
|
||||
|
||||
// CoinETHType is the coin type for ETH
|
||||
const CoinETHType = int64(60)
|
||||
|
||||
// CoinSNRType is the coin type for SNR
|
||||
const CoinSNRType = int64(703)
|
||||
@@ -7,9 +7,11 @@ var (
|
||||
ErrInvalidETHAddressFormat = sdkerrors.Register(ModuleName, 200, "invalid ETH address format")
|
||||
ErrInvalidBTCAddressFormat = sdkerrors.Register(ModuleName, 201, "invalid BTC address format")
|
||||
ErrInvalidIDXAddressFormat = sdkerrors.Register(ModuleName, 202, "invalid IDX address format")
|
||||
ErrInvalidEmailFormat = sdkerrors.Register(ModuleName, 203, "invalid email format")
|
||||
ErrInvalidPhoneFormat = sdkerrors.Register(ModuleName, 204, "invalid phone format")
|
||||
ErrMinimumAssertions = sdkerrors.Register(ModuleName, 300, "at least one assertion is required for account initialization")
|
||||
ErrInvalidControllers = sdkerrors.Register(ModuleName, 301, "no more than one controller can be used for account initialization")
|
||||
ErrMaximumAuthenticators = sdkerrors.Register(ModuleName, 302, "more authenticators provided than the total accepted count")
|
||||
ErrInvalidOriginFormat = sdkerrors.Register(ModuleName, 203, "invalid origin format")
|
||||
ErrInvalidServiceOrigin = sdkerrors.Register(ModuleName, 300, "invalid service origin")
|
||||
ErrUnrecognizedService = sdkerrors.Register(ModuleName, 301, "unrecognized service")
|
||||
ErrUnsupportedKeyEncoding = sdkerrors.Register(ModuleName, 400, "unsupported key encoding")
|
||||
ErrUnsopportedChainCode = sdkerrors.Register(ModuleName, 401, "unsupported chain code")
|
||||
ErrUnsupportedKeyCurve = sdkerrors.Register(ModuleName, 402, "unsupported key curve")
|
||||
ErrInvalidSignature = sdkerrors.Register(ModuleName, 403, "invalid signature")
|
||||
)
|
||||
|
||||
+196
-4
@@ -1,6 +1,31 @@
|
||||
package types
|
||||
|
||||
import "encoding/json"
|
||||
import (
|
||||
"encoding/json"
|
||||
fmt "fmt"
|
||||
|
||||
ormv1alpha1 "cosmossdk.io/api/cosmos/orm/v1alpha1"
|
||||
"cosmossdk.io/collections"
|
||||
"cosmossdk.io/x/nft"
|
||||
)
|
||||
|
||||
// ParamsKey saves the current module params.
|
||||
var ParamsKey = collections.NewPrefix(0)
|
||||
|
||||
const (
|
||||
ModuleName = "did"
|
||||
|
||||
StoreKey = ModuleName
|
||||
|
||||
QuerierRoute = ModuleName
|
||||
)
|
||||
|
||||
var ORMModuleSchema = ormv1alpha1.ModuleSchemaDescriptor{
|
||||
SchemaFile: []*ormv1alpha1.ModuleSchemaDescriptor_FileEntry{
|
||||
{Id: 1, ProtoFileName: "did/v1/state.proto"},
|
||||
},
|
||||
Prefix: []byte{0},
|
||||
}
|
||||
|
||||
// this line is used by starport scaffolding # genesis/types/import
|
||||
|
||||
@@ -11,7 +36,8 @@ const DefaultIndex uint64 = 1
|
||||
func DefaultGenesis() *GenesisState {
|
||||
return &GenesisState{
|
||||
// this line is used by starport scaffolding # genesis/types/default
|
||||
Params: DefaultParams(),
|
||||
GlobalIntegrity: DefaultGlobalIntegrity(),
|
||||
Params: DefaultParams(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,13 +45,151 @@ func DefaultGenesis() *GenesisState {
|
||||
// failure.
|
||||
func (gs GenesisState) Validate() error {
|
||||
// this line is used by starport scaffolding # genesis/types/validate
|
||||
|
||||
if gs.GlobalIntegrity == nil {
|
||||
return fmt.Errorf("global integrity proof is nil")
|
||||
}
|
||||
return gs.Params.Validate()
|
||||
}
|
||||
|
||||
// DefaultNFTClasses configures the Initial DIDNamespace NFT classes
|
||||
func DefaultNFTClasses(nftGenesis *nft.GenesisState) error {
|
||||
for _, n := range DIDNamespace_value {
|
||||
nftGenesis.Classes = append(nftGenesis.Classes, DIDNamespace(n).GetNFTClass())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DefaultParams returns default module parameters.
|
||||
func DefaultParams() Params {
|
||||
return Params{}
|
||||
return Params{
|
||||
WhitelistedAssets: DefaultAssets(),
|
||||
AllowedPublicKeys: DefaultKeyInfos(),
|
||||
LocalhostRegistrationEnabled: true,
|
||||
ConveyancePreference: "direct",
|
||||
AttestationFormats: []string{"packed", "android-key", "fido-u2f", "apple"},
|
||||
}
|
||||
}
|
||||
|
||||
// DefaultGlobalIntegrity returns the default global integrity proof
|
||||
func DefaultGlobalIntegrity() *GlobalIntegrity {
|
||||
return &GlobalIntegrity{
|
||||
Controller: "did:sonr:0x0",
|
||||
Seed: DefaultSeedMessage(),
|
||||
Accumulator: []byte{},
|
||||
Count: 0,
|
||||
}
|
||||
}
|
||||
|
||||
// DefaultSeedMessage returns the default seed message
|
||||
func DefaultSeedMessage() string {
|
||||
l1 := "The Sonr Network shall make no protocol that respects the establishment of centralized authority,"
|
||||
l2 := "or prohibits the free exercise of decentralized identity; or abridges the freedom of data sovereignty,"
|
||||
l3 := "or of encrypted communication; or the right of the users to peaceally interact and transact,"
|
||||
l4 := "and to petition the Network for the redress of vulnerabilities."
|
||||
return fmt.Sprintf("%s %s %s %s", l1, l2, l3, l4)
|
||||
}
|
||||
|
||||
// DefaultAssets returns the default asset infos: BTC, ETH, SNR, and USDC
|
||||
func DefaultAssets() []*AssetInfo {
|
||||
return []*AssetInfo{
|
||||
{
|
||||
Name: "Bitcoin",
|
||||
Symbol: "BTC",
|
||||
Hrp: "bc",
|
||||
Index: 0,
|
||||
AssetType: AssetType_ASSET_TYPE_NATIVE,
|
||||
IconUrl: "https://cdn.sonr.land/BTC.svg",
|
||||
},
|
||||
{
|
||||
Name: "Ethereum",
|
||||
Symbol: "ETH",
|
||||
Hrp: "eth",
|
||||
Index: 64,
|
||||
AssetType: AssetType_ASSET_TYPE_NATIVE,
|
||||
IconUrl: "https://cdn.sonr.land/ETH.svg",
|
||||
},
|
||||
{
|
||||
Name: "Sonr",
|
||||
Symbol: "SNR",
|
||||
Hrp: "idx",
|
||||
Index: 703,
|
||||
AssetType: AssetType_ASSET_TYPE_NATIVE,
|
||||
IconUrl: "https://cdn.sonr.land/SNR.svg",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// DefaultKeyInfos returns the default key infos: secp256k1, ed25519, keccak256, and bls12381.
|
||||
func DefaultKeyInfos() map[string]*KeyInfo {
|
||||
return map[string]*KeyInfo{
|
||||
// Identity Key Info
|
||||
// Sonr Controller Key Info - From MPC
|
||||
"auth.dwn": {
|
||||
Role: KeyRole_KEY_ROLE_INVOCATION,
|
||||
Curve: KeyCurve_KEY_CURVE_P256,
|
||||
Algorithm: KeyAlgorithm_KEY_ALGORITHM_ECDSA,
|
||||
Encoding: KeyEncoding_KEY_ENCODING_HEX,
|
||||
Type: KeyType_KEY_TYPE_MPC,
|
||||
},
|
||||
|
||||
// Sonr Vault Shared Key Info - From Registration
|
||||
"auth.zk": {
|
||||
Role: KeyRole_KEY_ROLE_ASSERTION,
|
||||
Curve: KeyCurve_KEY_CURVE_BLS12381,
|
||||
Algorithm: KeyAlgorithm_KEY_ALGORITHM_UNSPECIFIED,
|
||||
Encoding: KeyEncoding_KEY_ENCODING_MULTIBASE,
|
||||
Type: KeyType_KEY_TYPE_ZK,
|
||||
},
|
||||
|
||||
// Blockchain Key Info
|
||||
// Ethereum Key Info
|
||||
"auth.ethereum": {
|
||||
Role: KeyRole_KEY_ROLE_DELEGATION,
|
||||
Curve: KeyCurve_KEY_CURVE_KECCAK256,
|
||||
Algorithm: KeyAlgorithm_KEY_ALGORITHM_ECDSA,
|
||||
Encoding: KeyEncoding_KEY_ENCODING_HEX,
|
||||
Type: KeyType_KEY_TYPE_BIP32,
|
||||
},
|
||||
// Bitcoin/IBC Key Info
|
||||
"auth.bitcoin": {
|
||||
Role: KeyRole_KEY_ROLE_DELEGATION,
|
||||
Curve: KeyCurve_KEY_CURVE_SECP256K1,
|
||||
Algorithm: KeyAlgorithm_KEY_ALGORITHM_ECDSA,
|
||||
Encoding: KeyEncoding_KEY_ENCODING_HEX,
|
||||
Type: KeyType_KEY_TYPE_BIP32,
|
||||
},
|
||||
|
||||
// Authentication Key Info
|
||||
// Browser based WebAuthn
|
||||
"webauthn.browser": {
|
||||
Role: KeyRole_KEY_ROLE_AUTHENTICATION,
|
||||
Curve: KeyCurve_KEY_CURVE_P256,
|
||||
Algorithm: KeyAlgorithm_KEY_ALGORITHM_ES256,
|
||||
Encoding: KeyEncoding_KEY_ENCODING_RAW,
|
||||
Type: KeyType_KEY_TYPE_WEBAUTHN,
|
||||
},
|
||||
// FIDO U2F
|
||||
"webauthn.fido": {
|
||||
Role: KeyRole_KEY_ROLE_AUTHENTICATION,
|
||||
Curve: KeyCurve_KEY_CURVE_P256,
|
||||
Algorithm: KeyAlgorithm_KEY_ALGORITHM_ES256,
|
||||
Encoding: KeyEncoding_KEY_ENCODING_RAW,
|
||||
Type: KeyType_KEY_TYPE_WEBAUTHN,
|
||||
},
|
||||
// Cross-Platform Passkeys
|
||||
"webauthn.passkey": {
|
||||
Role: KeyRole_KEY_ROLE_AUTHENTICATION,
|
||||
Curve: KeyCurve_KEY_CURVE_ED25519,
|
||||
Algorithm: KeyAlgorithm_KEY_ALGORITHM_EDDSA,
|
||||
Encoding: KeyEncoding_KEY_ENCODING_RAW,
|
||||
Type: KeyType_KEY_TYPE_WEBAUTHN,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (p Params) ActiveParams(ipfsActive bool) Params {
|
||||
p.IpfsActive = ipfsActive
|
||||
return p
|
||||
}
|
||||
|
||||
// Stringer method for Params.
|
||||
@@ -43,3 +207,31 @@ func (p Params) Validate() error {
|
||||
// TODO:
|
||||
return nil
|
||||
}
|
||||
|
||||
//
|
||||
// # Genesis Structures
|
||||
//
|
||||
|
||||
// Equal returns true if two asset infos are equal
|
||||
func (a *AssetInfo) Equal(b *AssetInfo) bool {
|
||||
if a == nil && b == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Equal returns true if two key infos are equal
|
||||
func (k *KeyInfo) Equal(b *KeyInfo) bool {
|
||||
if k == nil && b == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Equal returns true if two validator infos are equal
|
||||
func (v *ValidatorInfo) Equal(b *ValidatorInfo) bool {
|
||||
if v == nil && b == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
+3388
-17
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@ package types_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/onsonr/hway/x/did/types"
|
||||
"github.com/onsonr/sonr/x/did/types"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
@@ -19,14 +19,6 @@ func TestGenesisState_Validate(t *testing.T) {
|
||||
genState: types.DefaultGenesis(),
|
||||
valid: true,
|
||||
},
|
||||
{
|
||||
desc: "valid genesis state",
|
||||
genState: &types.GenesisState{
|
||||
|
||||
// this line is used by starport scaffolding # types/genesis/validField
|
||||
},
|
||||
valid: true,
|
||||
},
|
||||
// this line is used by starport scaffolding # types/genesis/testcase
|
||||
}
|
||||
for _, tc := range tests {
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package types
|
||||
|
||||
import "lukechampine.com/blake3"
|
||||
|
||||
func (g *GlobalIntegrity) Update(address string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (g *GlobalIntegrity) getProof() (*Proof, error) {
|
||||
if g.Accumulator == nil {
|
||||
return NewProof(g.Controller, g.proofProperty(), g.seedKdf())
|
||||
}
|
||||
return &Proof{
|
||||
Issuer: g.Controller,
|
||||
Property: g.proofProperty(),
|
||||
Accumulator: g.Accumulator,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (g *GlobalIntegrity) proofProperty() string {
|
||||
return "did:sonr:integrity"
|
||||
}
|
||||
|
||||
func (g *GlobalIntegrity) seedKdf() []byte {
|
||||
res := blake3.Sum256([]byte(g.Seed))
|
||||
return res[:]
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
"math/big"
|
||||
|
||||
"cosmossdk.io/collections"
|
||||
"github.com/onsonr/crypto/core/curves"
|
||||
"github.com/onsonr/crypto/signatures/ecdsa"
|
||||
"golang.org/x/crypto/sha3"
|
||||
|
||||
ormv1alpha1 "cosmossdk.io/api/cosmos/orm/v1alpha1"
|
||||
)
|
||||
|
||||
// ParamsKey saves the current module params.
|
||||
var ParamsKey = collections.NewPrefix(0)
|
||||
|
||||
const (
|
||||
ModuleName = "did"
|
||||
|
||||
StoreKey = ModuleName
|
||||
|
||||
QuerierRoute = ModuleName
|
||||
)
|
||||
|
||||
var ORMModuleSchema = ormv1alpha1.ModuleSchemaDescriptor{
|
||||
SchemaFile: []*ormv1alpha1.ModuleSchemaDescriptor_FileEntry{
|
||||
{Id: 1, ProtoFileName: "did/v1/state.proto"},
|
||||
},
|
||||
Prefix: []byte{0},
|
||||
}
|
||||
|
||||
// VerifySignature verifies the signature of a message
|
||||
func VerifySignature(key []byte, msg []byte, sig []byte) bool {
|
||||
pp, err := BuildEcPoint(key)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
sigEd, err := ecdsa.DeserializeSecp256k1Signature(sig)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
hash := sha3.New256()
|
||||
_, err = hash.Write(msg)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
digest := hash.Sum(nil)
|
||||
return curves.VerifyEcdsa(pp, digest[:], sigEd)
|
||||
}
|
||||
|
||||
// BuildEcPoint builds an elliptic curve point from a compressed byte slice
|
||||
func BuildEcPoint(pubKey []byte) (*curves.EcPoint, error) {
|
||||
crv := curves.K256()
|
||||
x := new(big.Int).SetBytes(pubKey[1:33])
|
||||
y := new(big.Int).SetBytes(pubKey[33:])
|
||||
ecCurve, err := crv.ToEllipticCurve()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error converting curve: %v", err)
|
||||
}
|
||||
return &curves.EcPoint{X: x, Y: y, Curve: ecCurve}, nil
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
+86
-1
@@ -48,6 +48,91 @@ func (msg *MsgUpdateParams) Validate() error {
|
||||
return msg.Params.Validate()
|
||||
}
|
||||
|
||||
//
|
||||
// [RegisterService]
|
||||
//
|
||||
|
||||
// NewMsgRegisterController creates a new instance of MsgRegisterController
|
||||
func NewMsgRegisterService(
|
||||
sender sdk.Address,
|
||||
) (*MsgRegisterService, error) {
|
||||
return &MsgRegisterService{
|
||||
Controller: sender.String(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Route returns the name of the module
|
||||
func (msg MsgRegisterService) Route() string { return ModuleName }
|
||||
|
||||
// Type returns the the action
|
||||
func (msg MsgRegisterService) Type() string { return "register_service" }
|
||||
|
||||
// GetSignBytes implements the LegacyMsg interface.
|
||||
func (msg MsgRegisterService) GetSignBytes() []byte {
|
||||
return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(&msg))
|
||||
}
|
||||
|
||||
// GetSigners returns the expected signers for a MsgUpdateParams message.
|
||||
func (msg *MsgRegisterService) GetSigners() []sdk.AccAddress {
|
||||
addr, _ := sdk.AccAddressFromBech32(msg.Controller)
|
||||
return []sdk.AccAddress{addr}
|
||||
}
|
||||
|
||||
// ValidateBasic does a sanity check on the provided data.
|
||||
func (msg *MsgRegisterService) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
//
|
||||
// [AllocateVault]
|
||||
//
|
||||
|
||||
// NewMsgAllocateVault creates a new instance of MsgAllocateVault
|
||||
func NewMsgAllocateVault(
|
||||
sender sdk.Address,
|
||||
) (*MsgAllocateVault, error) {
|
||||
return &MsgAllocateVault{
|
||||
// [RegisterController]
|
||||
//
|
||||
|
||||
// NewMsgRegisterController creates a new instance of MsgRegisterController
|
||||
func NewMsgRegisterController(
|
||||
sender sdk.Address,
|
||||
) (*MsgRegisterController, error) {
|
||||
return &MsgRegisterController{
|
||||
Authority: sender.String(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Route returns the name of the module
|
||||
func (msg MsgAllocateVault) Route() string { return ModuleName }
|
||||
|
||||
// Type returns the the action
|
||||
func (msg MsgAllocateVault) Type() string { return "allocate_vault" }
|
||||
|
||||
// GetSignBytes implements the LegacyMsg interface.
|
||||
func (msg MsgAllocateVault) GetSignBytes() []byte {
|
||||
func (msg MsgRegisterController) Route() string { return ModuleName }
|
||||
|
||||
// Type returns the the action
|
||||
func (msg MsgRegisterController) Type() string { return "initialize_controller" }
|
||||
|
||||
// GetSignBytes implements the LegacyMsg interface.
|
||||
func (msg MsgRegisterController) GetSignBytes() []byte {
|
||||
return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(&msg))
|
||||
}
|
||||
|
||||
// GetSigners returns the expected signers for a MsgUpdateParams message.
|
||||
func (msg *MsgAllocateVault) GetSigners() []sdk.AccAddress {
|
||||
addr, _ := sdk.AccAddressFromBech32(msg.Authority)
|
||||
return []sdk.AccAddress{addr}
|
||||
}
|
||||
|
||||
// Vaalidate does a sanity check on the provided data.
|
||||
func (msg *MsgAllocateVault) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
//
|
||||
// [RegisterController]
|
||||
//
|
||||
@@ -65,7 +150,7 @@ func NewMsgRegisterController(
|
||||
func (msg MsgRegisterController) Route() string { return ModuleName }
|
||||
|
||||
// Type returns the the action
|
||||
func (msg MsgRegisterController) Type() string { return "initialize_controller" }
|
||||
func (msg MsgRegisterController) Type() string { return "register_controller" }
|
||||
|
||||
// GetSignBytes implements the LegacyMsg interface.
|
||||
func (msg MsgRegisterController) GetSignBytes() []byte {
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"cosmossdk.io/x/nft"
|
||||
)
|
||||
|
||||
func (n DIDNamespace) ID() string {
|
||||
switch n {
|
||||
case DIDNamespace_DID_NAMESPACE_DWN:
|
||||
return "did:dwn:0"
|
||||
case DIDNamespace_DID_NAMESPACE_SONR:
|
||||
return "did:sonr:0"
|
||||
case DIDNamespace_DID_NAMESPACE_BITCOIN:
|
||||
return "did:btc:0"
|
||||
case DIDNamespace_DID_NAMESPACE_ETHEREUM:
|
||||
return "did:eth:0"
|
||||
case DIDNamespace_DID_NAMESPACE_IBC:
|
||||
return "did:ibc:0"
|
||||
case DIDNamespace_DID_NAMESPACE_WEBAUTHN:
|
||||
return "did:authn:0"
|
||||
case DIDNamespace_DID_NAMESPACE_SERVICE:
|
||||
return "did:web:0"
|
||||
case DIDNamespace_DID_NAMESPACE_IPFS:
|
||||
return "did:ipfs:0"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (n DIDNamespace) Name() string {
|
||||
switch n {
|
||||
case DIDNamespace_DID_NAMESPACE_DWN:
|
||||
return "DecentralizedWebNode"
|
||||
case DIDNamespace_DID_NAMESPACE_SONR:
|
||||
return "SonrNetwork"
|
||||
case DIDNamespace_DID_NAMESPACE_BITCOIN:
|
||||
return "BitcoinNetwork"
|
||||
case DIDNamespace_DID_NAMESPACE_ETHEREUM:
|
||||
return "EthereumNetwork"
|
||||
case DIDNamespace_DID_NAMESPACE_IBC:
|
||||
return "IBCNetwork"
|
||||
case DIDNamespace_DID_NAMESPACE_WEBAUTHN:
|
||||
return "WebAuthentication"
|
||||
case DIDNamespace_DID_NAMESPACE_SERVICE:
|
||||
return "DecentrlizedService"
|
||||
case DIDNamespace_DID_NAMESPACE_IPFS:
|
||||
return "IPFSStorage"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (n DIDNamespace) Symbol() string {
|
||||
switch n {
|
||||
case DIDNamespace_DID_NAMESPACE_DWN:
|
||||
return "DWN"
|
||||
case DIDNamespace_DID_NAMESPACE_SONR:
|
||||
return "SONR"
|
||||
case DIDNamespace_DID_NAMESPACE_BITCOIN:
|
||||
return "BTC"
|
||||
case DIDNamespace_DID_NAMESPACE_ETHEREUM:
|
||||
return "ETH"
|
||||
case DIDNamespace_DID_NAMESPACE_IBC:
|
||||
return "IBC"
|
||||
case DIDNamespace_DID_NAMESPACE_WEBAUTHN:
|
||||
return "WEBAUTHN"
|
||||
case DIDNamespace_DID_NAMESPACE_SERVICE:
|
||||
return "SERVICE"
|
||||
case DIDNamespace_DID_NAMESPACE_IPFS:
|
||||
return "IPFS"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (n DIDNamespace) Description() string {
|
||||
switch n {
|
||||
case DIDNamespace_DID_NAMESPACE_DWN:
|
||||
return "DWN Service Provider"
|
||||
case DIDNamespace_DID_NAMESPACE_SONR:
|
||||
return "Sonr Network Gateway"
|
||||
case DIDNamespace_DID_NAMESPACE_BITCOIN:
|
||||
return "Bitcoin Network Gateway"
|
||||
case DIDNamespace_DID_NAMESPACE_ETHEREUM:
|
||||
return "Ethereum Network Gateway"
|
||||
case DIDNamespace_DID_NAMESPACE_IBC:
|
||||
return "IBC Network Gateway"
|
||||
case DIDNamespace_DID_NAMESPACE_WEBAUTHN:
|
||||
return "Web Authentication Key"
|
||||
case DIDNamespace_DID_NAMESPACE_SERVICE:
|
||||
return "Decentrlized Service"
|
||||
case DIDNamespace_DID_NAMESPACE_IPFS:
|
||||
return "Data Storage on IPFS"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (n DIDNamespace) GetNFTClass() *nft.Class {
|
||||
return &nft.Class{
|
||||
Id: n.ID(),
|
||||
Name: n.Name(),
|
||||
Symbol: n.Symbol(),
|
||||
Description: n.Description(),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Code generated from Pkl module `oidc`. DO NOT EDIT.
|
||||
package oidc
|
||||
|
||||
type DiscoveryDocument struct {
|
||||
Issuer string `pkl:"issuer" json:"issuer,omitempty" param:"issuer"`
|
||||
|
||||
AuthorizationEndpoint string `pkl:"authorization_endpoint" json:"authorization_endpoint,omitempty" param:"authorization_endpoint"`
|
||||
|
||||
TokenEndpoint string `pkl:"token_endpoint" json:"token_endpoint,omitempty" param:"token_endpoint"`
|
||||
|
||||
UserinfoEndpoint string `pkl:"userinfo_endpoint" json:"userinfo_endpoint,omitempty" param:"userinfo_endpoint"`
|
||||
|
||||
JwksUri string `pkl:"jwks_uri" json:"jwks_uri,omitempty" param:"jwks_uri"`
|
||||
|
||||
RegistrationEndpoint string `pkl:"registration_endpoint" json:"registration_endpoint,omitempty" param:"registration_endpoint"`
|
||||
|
||||
ScopesSupported []string `pkl:"scopes_supported" json:"scopes_supported,omitempty" param:"scopes_supported"`
|
||||
|
||||
ResponseTypesSupported []string `pkl:"response_types_supported" json:"response_types_supported,omitempty" param:"response_types_supported"`
|
||||
|
||||
ResponseModesSupported []string `pkl:"response_modes_supported" json:"response_modes_supported,omitempty" param:"response_modes_supported"`
|
||||
|
||||
SubjectTypesSupported []string `pkl:"subject_types_supported" json:"subject_types_supported,omitempty" param:"subject_types_supported"`
|
||||
|
||||
IdTokenSigningAlgValuesSupported []string `pkl:"id_token_signing_alg_values_supported" json:"id_token_signing_alg_values_supported,omitempty" param:"id_token_signing_alg_values_supported"`
|
||||
|
||||
ClaimsSupported []string `pkl:"claims_supported" json:"claims_supported,omitempty" param:"claims_supported"`
|
||||
|
||||
GrantTypesSupported []string `pkl:"grant_types_supported" json:"grant_types_supported,omitempty" param:"grant_types_supported"`
|
||||
|
||||
AcrValuesSupported []string `pkl:"acr_values_supported" json:"acr_values_supported,omitempty" param:"acr_values_supported"`
|
||||
|
||||
TokenEndpointAuthMethodsSupported []string `pkl:"token_endpoint_auth_methods_supported" json:"token_endpoint_auth_methods_supported,omitempty" param:"token_endpoint_auth_methods_supported"`
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// Code generated from Pkl module `oidc`. DO NOT EDIT.
|
||||
package oidc
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/apple/pkl-go/pkl"
|
||||
)
|
||||
|
||||
type Oidc struct {
|
||||
}
|
||||
|
||||
// LoadFromPath loads the pkl module at the given path and evaluates it into a Oidc
|
||||
func LoadFromPath(ctx context.Context, path string) (ret *Oidc, err error) {
|
||||
evaluator, err := pkl.NewEvaluator(ctx, pkl.PreconfiguredOptions)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer func() {
|
||||
cerr := evaluator.Close()
|
||||
if err == nil {
|
||||
err = cerr
|
||||
}
|
||||
}()
|
||||
ret, err = Load(ctx, evaluator, pkl.FileSource(path))
|
||||
return ret, err
|
||||
}
|
||||
|
||||
// Load loads the pkl module at the given source and evaluates it with the given evaluator into a Oidc
|
||||
func Load(ctx context.Context, evaluator pkl.Evaluator, source *pkl.ModuleSource) (*Oidc, error) {
|
||||
var ret Oidc
|
||||
if err := evaluator.EvaluateModule(ctx, source, &ret); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &ret, nil
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// Code generated from Pkl module `oidc`. DO NOT EDIT.
|
||||
package oidc
|
||||
|
||||
import "github.com/apple/pkl-go/pkl"
|
||||
|
||||
func init() {
|
||||
pkl.RegisterMapping("oidc", Oidc{})
|
||||
pkl.RegisterMapping("oidc#DiscoveryDocument", DiscoveryDocument{})
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"crypto/ecdsa"
|
||||
"encoding/hex"
|
||||
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
"github.com/mr-tron/base58/base58"
|
||||
"github.com/onsonr/crypto"
|
||||
"github.com/onsonr/crypto/macaroon"
|
||||
)
|
||||
|
||||
var WalletKeyInfo = &KeyInfo{
|
||||
Role: KeyRole_KEY_ROLE_DELEGATION,
|
||||
Curve: KeyCurve_KEY_CURVE_SECP256K1,
|
||||
Algorithm: KeyAlgorithm_KEY_ALGORITHM_ECDSA,
|
||||
Encoding: KeyEncoding_KEY_ENCODING_HEX,
|
||||
Type: KeyType_KEY_TYPE_BIP32,
|
||||
}
|
||||
|
||||
var EthKeyInfo = &KeyInfo{
|
||||
Role: KeyRole_KEY_ROLE_DELEGATION,
|
||||
Curve: KeyCurve_KEY_CURVE_KECCAK256,
|
||||
Algorithm: KeyAlgorithm_KEY_ALGORITHM_ECDSA,
|
||||
Encoding: KeyEncoding_KEY_ENCODING_HEX,
|
||||
Type: KeyType_KEY_TYPE_BIP32,
|
||||
}
|
||||
|
||||
var SonrKeyInfo = &KeyInfo{
|
||||
Role: KeyRole_KEY_ROLE_INVOCATION,
|
||||
Curve: KeyCurve_KEY_CURVE_P256,
|
||||
Algorithm: KeyAlgorithm_KEY_ALGORITHM_ECDSA,
|
||||
Encoding: KeyEncoding_KEY_ENCODING_HEX,
|
||||
Type: KeyType_KEY_TYPE_MPC,
|
||||
}
|
||||
|
||||
var ChainCodeKeyInfos = map[ChainCode]*KeyInfo{
|
||||
ChainCodeBTC: WalletKeyInfo,
|
||||
ChainCodeETH: EthKeyInfo,
|
||||
ChainCodeSNR: SonrKeyInfo,
|
||||
ChainCodeIBC: WalletKeyInfo,
|
||||
}
|
||||
|
||||
// NewEthPublicKey returns a new ethereum public key
|
||||
func NewPublicKey(data []byte, keyInfo *KeyInfo) (*PubKey, error) {
|
||||
encKey, err := keyInfo.Encoding.EncodeRaw(data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &PubKey{
|
||||
Raw: encKey,
|
||||
Role: keyInfo.Role,
|
||||
Encoding: keyInfo.Encoding,
|
||||
Algorithm: keyInfo.Algorithm,
|
||||
Curve: keyInfo.Curve,
|
||||
KeyType: keyInfo.Type,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Address returns the address of the public key
|
||||
func (k *PubKey) Address() cryptotypes.Address {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Bytes returns the raw bytes of the public key
|
||||
func (k *PubKey) Bytes() []byte {
|
||||
bz, _ := k.GetEncoding().DecodeRaw(k.GetRaw())
|
||||
return bz
|
||||
}
|
||||
|
||||
// Clone returns a copy of the public key
|
||||
func (k *PubKey) Clone() cryptotypes.PubKey {
|
||||
return &PubKey{
|
||||
Raw: k.GetRaw(),
|
||||
Role: k.GetRole(),
|
||||
Encoding: k.GetEncoding(),
|
||||
Algorithm: k.GetAlgorithm(),
|
||||
Curve: k.GetCurve(),
|
||||
KeyType: k.GetKeyType(),
|
||||
}
|
||||
}
|
||||
|
||||
// IssueMacaroon returns a macaroon for the public key with the given id and location
|
||||
func (pk *PubKey) IssueMacaroon(subject string, origin string) (*macaroon.Macaroon, error) {
|
||||
return macaroon.New(pk.Bytes(), []byte(subject), origin, macaroon.LatestVersion)
|
||||
}
|
||||
|
||||
// ECDSA returns the ECDSA public key
|
||||
func (k *PubKey) ECDSA() (*ecdsa.PublicKey, error) {
|
||||
return crypto.ComputeEcdsaPublicKey(k.Bytes())
|
||||
}
|
||||
|
||||
// VerifySignature verifies a signature over the given message
|
||||
func (k *PubKey) VerifySignature(msg []byte, sig []byte) bool {
|
||||
pk, err := crypto.ComputeEcdsaPublicKey(k.Bytes())
|
||||
sigMpc, err := crypto.DeserializeMPCSignature(sig)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return crypto.VerifyMPCSignature(sigMpc, msg, pk)
|
||||
}
|
||||
|
||||
// Equals returns true if two public keys are equal
|
||||
func (k *PubKey) Equals(k2 cryptotypes.PubKey) bool {
|
||||
if k == nil && k2 == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Type returns the type of the public key
|
||||
func (k *PubKey) Type() string {
|
||||
return k.KeyType.String()
|
||||
}
|
||||
|
||||
// DecodePublicKey extracts the public key from the given data
|
||||
func (k *KeyInfo) DecodePublicKey(data interface{}) ([]byte, error) {
|
||||
var bz []byte
|
||||
switch v := data.(type) {
|
||||
case string:
|
||||
bz = []byte(v)
|
||||
case []byte:
|
||||
bz = v
|
||||
default:
|
||||
return nil, ErrUnsupportedKeyEncoding
|
||||
}
|
||||
|
||||
if k.Encoding == KeyEncoding_KEY_ENCODING_RAW {
|
||||
return bz, nil
|
||||
}
|
||||
if k.Encoding == KeyEncoding_KEY_ENCODING_HEX {
|
||||
return hex.DecodeString(string(bz))
|
||||
}
|
||||
if k.Encoding == KeyEncoding_KEY_ENCODING_MULTIBASE {
|
||||
return base58.Decode(string(bz))
|
||||
}
|
||||
return nil, ErrUnsupportedKeyEncoding
|
||||
}
|
||||
|
||||
// EncodePublicKey encodes the public key according to the KeyInfo's encoding
|
||||
func (k *KeyInfo) EncodePublicKey(data []byte) (string, error) {
|
||||
if k.Encoding == KeyEncoding_KEY_ENCODING_RAW {
|
||||
return string(data), nil
|
||||
}
|
||||
if k.Encoding == KeyEncoding_KEY_ENCODING_HEX {
|
||||
return hex.EncodeToString(data), nil
|
||||
}
|
||||
if k.Encoding == KeyEncoding_KEY_ENCODING_MULTIBASE {
|
||||
return base58.Encode(data), nil
|
||||
}
|
||||
return "", ErrUnsupportedKeyEncoding
|
||||
}
|
||||
+1401
-162
File diff suppressed because it is too large
Load Diff
+557
-4
@@ -33,24 +33,58 @@ var _ = utilities.NewDoubleArray
|
||||
var _ = descriptor.ForMessage
|
||||
var _ = metadata.Join
|
||||
|
||||
var (
|
||||
filter_Query_Params_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
||||
)
|
||||
|
||||
func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryParamsRequest
|
||||
var protoReq QueryRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Params_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryParamsRequest
|
||||
var protoReq QueryRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Params_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := server.Params(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
var (
|
||||
filter_Query_ParamsAssets_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
||||
)
|
||||
|
||||
func request_Query_ParamsAssets_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ParamsAssets_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.ParamsAssets(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
func request_Query_Accounts_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryAccountsRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
@@ -262,6 +296,18 @@ func request_Query_Resolve_0(ctx context.Context, marshaler runtime.Marshaler, c
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_ParamsAssets_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ParamsAssets_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := server.ParamsAssets(ctx, &protoReq)
|
||||
func local_request_Query_Resolve_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryResolveRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
@@ -289,6 +335,12 @@ func local_request_Query_Resolve_0(ctx context.Context, marshaler runtime.Marsha
|
||||
|
||||
}
|
||||
|
||||
var (
|
||||
filter_Query_ParamsByAsset_0 = &utilities.DoubleArray{Encoding: map[string]int{"asset": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}}
|
||||
)
|
||||
|
||||
func request_Query_ParamsByAsset_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryRequest
|
||||
func request_Query_Service_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryServiceRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
@@ -300,6 +352,344 @@ func request_Query_Service_0(ctx context.Context, marshaler runtime.Marshaler, c
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["asset"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "asset")
|
||||
}
|
||||
|
||||
protoReq.Asset, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "asset", err)
|
||||
}
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ParamsByAsset_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.ParamsByAsset(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
val, ok = pathParams["origin"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "origin")
|
||||
}
|
||||
|
||||
protoReq.Origin, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "origin", err)
|
||||
}
|
||||
|
||||
msg, err := client.Service(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_ParamsByAsset_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryRequest
|
||||
func local_request_Query_Service_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryServiceRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["asset"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "asset")
|
||||
}
|
||||
|
||||
protoReq.Asset, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "asset", err)
|
||||
}
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ParamsByAsset_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := server.ParamsByAsset(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
var (
|
||||
filter_Query_ParamsKeys_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
||||
)
|
||||
|
||||
func request_Query_ParamsKeys_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ParamsKeys_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.ParamsKeys(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_ParamsKeys_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ParamsKeys_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := server.ParamsKeys(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
var (
|
||||
filter_Query_ParamsByKey_0 = &utilities.DoubleArray{Encoding: map[string]int{"key": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}}
|
||||
)
|
||||
|
||||
func request_Query_ParamsByKey_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["key"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key")
|
||||
}
|
||||
|
||||
protoReq.Key, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err)
|
||||
}
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ParamsByKey_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.ParamsByKey(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_ParamsByKey_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["key"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key")
|
||||
}
|
||||
|
||||
protoReq.Key, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err)
|
||||
}
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ParamsByKey_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := server.ParamsByKey(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
var (
|
||||
filter_Query_RegistrationOptionsByKey_0 = &utilities.DoubleArray{Encoding: map[string]int{"key": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}}
|
||||
)
|
||||
|
||||
func request_Query_RegistrationOptionsByKey_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["key"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key")
|
||||
}
|
||||
|
||||
protoReq.Key, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err)
|
||||
}
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_RegistrationOptionsByKey_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.RegistrationOptionsByKey(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_RegistrationOptionsByKey_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["key"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key")
|
||||
}
|
||||
|
||||
protoReq.Key, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err)
|
||||
}
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_RegistrationOptionsByKey_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := server.RegistrationOptionsByKey(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
var (
|
||||
filter_Query_Resolve_0 = &utilities.DoubleArray{Encoding: map[string]int{"did": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}}
|
||||
)
|
||||
|
||||
func request_Query_Resolve_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["did"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "did")
|
||||
}
|
||||
|
||||
protoReq.Did, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "did", err)
|
||||
}
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Resolve_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.Resolve(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_Resolve_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["did"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "did")
|
||||
}
|
||||
|
||||
protoReq.Did, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "did", err)
|
||||
}
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Resolve_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := server.Resolve(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
var (
|
||||
filter_Query_Service_0 = &utilities.DoubleArray{Encoding: map[string]int{"origin": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}}
|
||||
)
|
||||
|
||||
func request_Query_Service_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["origin"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "origin")
|
||||
@@ -311,13 +701,20 @@ func request_Query_Service_0(ctx context.Context, marshaler runtime.Marshaler, c
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "origin", err)
|
||||
}
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Service_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.Service(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_Service_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryServiceRequest
|
||||
var protoReq QueryRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
@@ -338,6 +735,24 @@ func local_request_Query_Service_0(ctx context.Context, marshaler runtime.Marsha
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "origin", err)
|
||||
}
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Service_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
val, ok = pathParams["origin"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "origin")
|
||||
}
|
||||
|
||||
protoReq.Origin, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "origin", err)
|
||||
}
|
||||
|
||||
msg, err := server.Service(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
@@ -372,6 +787,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_ParamsAssets_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
mux.Handle("GET", pattern_Query_Accounts_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
@@ -383,6 +799,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Query_ParamsAssets_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
resp, md, err := local_request_Query_Accounts_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
@@ -391,6 +808,11 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_ParamsAssets_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_ParamsByAsset_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
forward_Query_Accounts_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
@@ -406,6 +828,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Query_ParamsByAsset_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
resp, md, err := local_request_Query_Credentials_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
@@ -414,6 +837,11 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_ParamsByAsset_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_ParamsKeys_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
forward_Query_Credentials_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
@@ -429,6 +857,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Query_ParamsKeys_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
resp, md, err := local_request_Query_Identities_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
@@ -437,6 +866,53 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_ParamsKeys_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_ParamsByKey_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Query_ParamsByKey_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_ParamsByKey_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_RegistrationOptionsByKey_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Query_RegistrationOptionsByKey_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_RegistrationOptionsByKey_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
forward_Query_Identities_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
@@ -548,6 +1024,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_ParamsAssets_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
mux.Handle("GET", pattern_Query_Accounts_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
@@ -557,6 +1034,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Query_ParamsAssets_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
resp, md, err := request_Query_Accounts_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
@@ -564,6 +1042,11 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_ParamsAssets_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_ParamsByAsset_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
forward_Query_Accounts_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
@@ -577,6 +1060,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Query_ParamsByAsset_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
resp, md, err := request_Query_Credentials_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
@@ -584,6 +1068,11 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_ParamsByAsset_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_ParamsKeys_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
forward_Query_Credentials_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
@@ -597,6 +1086,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Query_ParamsKeys_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
resp, md, err := request_Query_Identities_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
@@ -604,6 +1094,47 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_ParamsKeys_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_ParamsByKey_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Query_ParamsByKey_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_ParamsByKey_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_RegistrationOptionsByKey_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Query_RegistrationOptionsByKey_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_RegistrationOptionsByKey_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
forward_Query_Identities_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
@@ -652,8 +1183,21 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
|
||||
}
|
||||
|
||||
var (
|
||||
pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"did", "params"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"params"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Query_ParamsAssets_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"params", "assets"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Query_ParamsByAsset_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"params", "assets", "asset"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Query_ParamsKeys_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"params", "keys"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Query_ParamsByKey_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"params", "keys", "key"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Query_RegistrationOptionsByKey_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3}, []string{"params", "keys", "key", "registration"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Query_Resolve_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 0}, []string{"did"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Query_Service_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"service", "origin"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
pattern_Query_Accounts_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 0, 2, 1}, []string{"did", "accounts"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Query_Credentials_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 0, 1, 0, 4, 1, 5, 1, 2, 2}, []string{"did", "origin", "credentials"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
@@ -668,6 +1212,15 @@ var (
|
||||
var (
|
||||
forward_Query_Params_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Query_ParamsAssets_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Query_ParamsByAsset_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Query_ParamsKeys_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Query_ParamsByKey_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Query_RegistrationOptionsByKey_0 = runtime.ForwardResponseMessage
|
||||
forward_Query_Accounts_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Query_Credentials_0 = runtime.ForwardResponseMessage
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package types
|
||||
|
||||
import "gopkg.in/macaroon-bakery.v2/bakery/checkers"
|
||||
|
||||
var (
|
||||
PermissionScopeStrings = [...]string{
|
||||
"profile.name",
|
||||
"identifiers.email",
|
||||
"identifiers.phone",
|
||||
"transactions.read",
|
||||
"transactions.write",
|
||||
"wallets.read",
|
||||
"wallets.create",
|
||||
"wallets.subscribe",
|
||||
"wallets.update",
|
||||
"transactions.verify",
|
||||
"transactions.broadcast",
|
||||
"admin.user",
|
||||
"admin.validator",
|
||||
}
|
||||
|
||||
StringToPermissionScope = map[string]PermissionScope{
|
||||
"PERMISSION_SCOPE_UNSPECIFIED": PermissionScope_PERMISSION_SCOPE_UNSPECIFIED,
|
||||
"PERMISSION_SCOPE_BASIC_INFO": PermissionScope_PERMISSION_SCOPE_BASIC_INFO,
|
||||
"PERMISSION_SCOPE_IDENTIFIERS_EMAIL": PermissionScope_PERMISSION_SCOPE_PERMISSIONS_READ,
|
||||
"PERMISSION_SCOPE_IDENTIFIERS_PHONE": PermissionScope_PERMISSION_SCOPE_PERMISSIONS_WRITE,
|
||||
"PERMISSION_SCOPE_TRANSACTIONS_READ": PermissionScope_PERMISSION_SCOPE_TRANSACTIONS_READ,
|
||||
"PERMISSION_SCOPE_TRANSACTIONS_WRITE": PermissionScope_PERMISSION_SCOPE_TRANSACTIONS_WRITE,
|
||||
"PERMISSION_SCOPE_WALLETS_READ": PermissionScope_PERMISSION_SCOPE_WALLETS_READ,
|
||||
"PERMISSION_SCOPE_WALLETS_CREATE": PermissionScope_PERMISSION_SCOPE_WALLETS_CREATE,
|
||||
"PERMISSION_SCOPE_WALLETS_SUBSCRIBE": PermissionScope_PERMISSION_SCOPE_WALLETS_SUBSCRIBE,
|
||||
"PERMISSION_SCOPE_WALLETS_UPDATE": PermissionScope_PERMISSION_SCOPE_WALLETS_UPDATE,
|
||||
"PERMISSION_SCOPE_TRANSACTIONS_VERIFY": PermissionScope_PERMISSION_SCOPE_TRANSACTIONS_VERIFY,
|
||||
"PERMISSION_SCOPE_TRANSACTIONS_BROADCAST": PermissionScope_PERMISSION_SCOPE_TRANSACTIONS_BROADCAST,
|
||||
"PERMISSION_SCOPE_ADMIN_USER": PermissionScope_PERMISSION_SCOPE_ADMIN_USER,
|
||||
"PERMISSION_SCOPE_ADMIN_VALIDATOR": PermissionScope_PERMISSION_SCOPE_ADMIN_VALIDATOR,
|
||||
}
|
||||
)
|
||||
|
||||
func ResolvePermissionScope(scope string) (PermissionScope, bool) {
|
||||
uriToPrefix := make(map[string]string)
|
||||
for _, scope := range PermissionScopeStrings {
|
||||
uriToPrefix["https://example.com/auth/"+scope] = scope
|
||||
}
|
||||
PermissionNamespace := checkers.NewNamespace(uriToPrefix)
|
||||
|
||||
prefix, ok := PermissionNamespace.Resolve("https://example.com/auth/" + scope)
|
||||
if !ok {
|
||||
return 0, false
|
||||
}
|
||||
permScope, ok := StringToPermissionScope[prefix]
|
||||
return permScope, ok
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package types
|
||||
|
||||
// ByteArray is a list of byte arrays
|
||||
type ByteArray = [][]byte
|
||||
+1106
-978
File diff suppressed because it is too large
Load Diff
+2805
-2
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,6 @@
|
||||
// Code generated from Pkl module `txns`. DO NOT EDIT.
|
||||
package txns
|
||||
|
||||
type Msg interface {
|
||||
GetTypeUrl() string
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// Code generated from Pkl module `txns`. DO NOT EDIT.
|
||||
package txns
|
||||
|
||||
import "github.com/apple/pkl-go/pkl"
|
||||
|
||||
type MsgDidAllocateVault interface {
|
||||
Msg
|
||||
|
||||
GetAuthority() string
|
||||
|
||||
GetSubject() string
|
||||
|
||||
GetToken() *pkl.Object
|
||||
}
|
||||
|
||||
var _ MsgDidAllocateVault = (*MsgDidAllocateVaultImpl)(nil)
|
||||
|
||||
type MsgDidAllocateVaultImpl struct {
|
||||
// The type URL for the message
|
||||
TypeUrl string `pkl:"typeUrl"`
|
||||
|
||||
Authority string `pkl:"authority"`
|
||||
|
||||
Subject string `pkl:"subject"`
|
||||
|
||||
Token *pkl.Object `pkl:"token"`
|
||||
}
|
||||
|
||||
// The type URL for the message
|
||||
func (rcv *MsgDidAllocateVaultImpl) GetTypeUrl() string {
|
||||
return rcv.TypeUrl
|
||||
}
|
||||
|
||||
func (rcv *MsgDidAllocateVaultImpl) GetAuthority() string {
|
||||
return rcv.Authority
|
||||
}
|
||||
|
||||
func (rcv *MsgDidAllocateVaultImpl) GetSubject() string {
|
||||
return rcv.Subject
|
||||
}
|
||||
|
||||
func (rcv *MsgDidAllocateVaultImpl) GetToken() *pkl.Object {
|
||||
return rcv.Token
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
// Code generated from Pkl module `txns`. DO NOT EDIT.
|
||||
package txns
|
||||
|
||||
import "github.com/apple/pkl-go/pkl"
|
||||
|
||||
type MsgDidAuthorize interface {
|
||||
Msg
|
||||
|
||||
GetAuthority() string
|
||||
|
||||
GetController() string
|
||||
|
||||
GetAddress() string
|
||||
|
||||
GetOrigin() string
|
||||
|
||||
GetToken() *pkl.Object
|
||||
}
|
||||
|
||||
var _ MsgDidAuthorize = (*MsgDidAuthorizeImpl)(nil)
|
||||
|
||||
type MsgDidAuthorizeImpl struct {
|
||||
// The type URL for the message
|
||||
TypeUrl string `pkl:"typeUrl"`
|
||||
|
||||
Authority string `pkl:"authority"`
|
||||
|
||||
Controller string `pkl:"controller"`
|
||||
|
||||
Address string `pkl:"address"`
|
||||
|
||||
Origin string `pkl:"origin"`
|
||||
|
||||
Token *pkl.Object `pkl:"token"`
|
||||
}
|
||||
|
||||
// The type URL for the message
|
||||
func (rcv *MsgDidAuthorizeImpl) GetTypeUrl() string {
|
||||
return rcv.TypeUrl
|
||||
}
|
||||
|
||||
func (rcv *MsgDidAuthorizeImpl) GetAuthority() string {
|
||||
return rcv.Authority
|
||||
}
|
||||
|
||||
func (rcv *MsgDidAuthorizeImpl) GetController() string {
|
||||
return rcv.Controller
|
||||
}
|
||||
|
||||
func (rcv *MsgDidAuthorizeImpl) GetAddress() string {
|
||||
return rcv.Address
|
||||
}
|
||||
|
||||
func (rcv *MsgDidAuthorizeImpl) GetOrigin() string {
|
||||
return rcv.Origin
|
||||
}
|
||||
|
||||
func (rcv *MsgDidAuthorizeImpl) GetToken() *pkl.Object {
|
||||
return rcv.Token
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
// Code generated from Pkl module `txns`. DO NOT EDIT.
|
||||
package txns
|
||||
|
||||
import "github.com/apple/pkl-go/pkl"
|
||||
|
||||
type MsgDidProveWitness interface {
|
||||
Msg
|
||||
|
||||
GetAuthority() string
|
||||
|
||||
GetProperty() string
|
||||
|
||||
GetWitness() []int
|
||||
|
||||
GetToken() *pkl.Object
|
||||
}
|
||||
|
||||
var _ MsgDidProveWitness = (*MsgDidProveWitnessImpl)(nil)
|
||||
|
||||
type MsgDidProveWitnessImpl struct {
|
||||
// The type URL for the message
|
||||
TypeUrl string `pkl:"typeUrl"`
|
||||
|
||||
Authority string `pkl:"authority"`
|
||||
|
||||
Property string `pkl:"property"`
|
||||
|
||||
Witness []int `pkl:"witness"`
|
||||
|
||||
Token *pkl.Object `pkl:"token"`
|
||||
}
|
||||
|
||||
// The type URL for the message
|
||||
func (rcv *MsgDidProveWitnessImpl) GetTypeUrl() string {
|
||||
return rcv.TypeUrl
|
||||
}
|
||||
|
||||
func (rcv *MsgDidProveWitnessImpl) GetAuthority() string {
|
||||
return rcv.Authority
|
||||
}
|
||||
|
||||
func (rcv *MsgDidProveWitnessImpl) GetProperty() string {
|
||||
return rcv.Property
|
||||
}
|
||||
|
||||
func (rcv *MsgDidProveWitnessImpl) GetWitness() []int {
|
||||
return rcv.Witness
|
||||
}
|
||||
|
||||
func (rcv *MsgDidProveWitnessImpl) GetToken() *pkl.Object {
|
||||
return rcv.Token
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
// Code generated from Pkl module `txns`. DO NOT EDIT.
|
||||
package txns
|
||||
|
||||
import "github.com/apple/pkl-go/pkl"
|
||||
|
||||
type MsgDidRegisterController interface {
|
||||
Msg
|
||||
|
||||
GetAuthority() string
|
||||
|
||||
GetCid() string
|
||||
|
||||
GetOrigin() string
|
||||
|
||||
GetAuthentication() []*pkl.Object
|
||||
|
||||
GetToken() *pkl.Object
|
||||
}
|
||||
|
||||
var _ MsgDidRegisterController = (*MsgDidRegisterControllerImpl)(nil)
|
||||
|
||||
type MsgDidRegisterControllerImpl struct {
|
||||
// The type URL for the message
|
||||
TypeUrl string `pkl:"typeUrl"`
|
||||
|
||||
Authority string `pkl:"authority"`
|
||||
|
||||
Cid string `pkl:"cid"`
|
||||
|
||||
Origin string `pkl:"origin"`
|
||||
|
||||
Authentication []*pkl.Object `pkl:"authentication"`
|
||||
|
||||
Token *pkl.Object `pkl:"token"`
|
||||
}
|
||||
|
||||
// The type URL for the message
|
||||
func (rcv *MsgDidRegisterControllerImpl) GetTypeUrl() string {
|
||||
return rcv.TypeUrl
|
||||
}
|
||||
|
||||
func (rcv *MsgDidRegisterControllerImpl) GetAuthority() string {
|
||||
return rcv.Authority
|
||||
}
|
||||
|
||||
func (rcv *MsgDidRegisterControllerImpl) GetCid() string {
|
||||
return rcv.Cid
|
||||
}
|
||||
|
||||
func (rcv *MsgDidRegisterControllerImpl) GetOrigin() string {
|
||||
return rcv.Origin
|
||||
}
|
||||
|
||||
func (rcv *MsgDidRegisterControllerImpl) GetAuthentication() []*pkl.Object {
|
||||
return rcv.Authentication
|
||||
}
|
||||
|
||||
func (rcv *MsgDidRegisterControllerImpl) GetToken() *pkl.Object {
|
||||
return rcv.Token
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
// Code generated from Pkl module `txns`. DO NOT EDIT.
|
||||
package txns
|
||||
|
||||
import "github.com/apple/pkl-go/pkl"
|
||||
|
||||
type MsgDidRegisterService interface {
|
||||
Msg
|
||||
|
||||
GetController() string
|
||||
|
||||
GetOriginUri() string
|
||||
|
||||
GetScopes() *pkl.Object
|
||||
|
||||
GetDescription() string
|
||||
|
||||
GetServiceEndpoints() map[string]string
|
||||
|
||||
GetMetadata() *pkl.Object
|
||||
|
||||
GetToken() *pkl.Object
|
||||
}
|
||||
|
||||
var _ MsgDidRegisterService = (*MsgDidRegisterServiceImpl)(nil)
|
||||
|
||||
type MsgDidRegisterServiceImpl struct {
|
||||
// The type URL for the message
|
||||
TypeUrl string `pkl:"typeUrl"`
|
||||
|
||||
Controller string `pkl:"controller"`
|
||||
|
||||
OriginUri string `pkl:"originUri"`
|
||||
|
||||
Scopes *pkl.Object `pkl:"scopes"`
|
||||
|
||||
Description string `pkl:"description"`
|
||||
|
||||
ServiceEndpoints map[string]string `pkl:"serviceEndpoints"`
|
||||
|
||||
Metadata *pkl.Object `pkl:"metadata"`
|
||||
|
||||
Token *pkl.Object `pkl:"token"`
|
||||
}
|
||||
|
||||
// The type URL for the message
|
||||
func (rcv *MsgDidRegisterServiceImpl) GetTypeUrl() string {
|
||||
return rcv.TypeUrl
|
||||
}
|
||||
|
||||
func (rcv *MsgDidRegisterServiceImpl) GetController() string {
|
||||
return rcv.Controller
|
||||
}
|
||||
|
||||
func (rcv *MsgDidRegisterServiceImpl) GetOriginUri() string {
|
||||
return rcv.OriginUri
|
||||
}
|
||||
|
||||
func (rcv *MsgDidRegisterServiceImpl) GetScopes() *pkl.Object {
|
||||
return rcv.Scopes
|
||||
}
|
||||
|
||||
func (rcv *MsgDidRegisterServiceImpl) GetDescription() string {
|
||||
return rcv.Description
|
||||
}
|
||||
|
||||
func (rcv *MsgDidRegisterServiceImpl) GetServiceEndpoints() map[string]string {
|
||||
return rcv.ServiceEndpoints
|
||||
}
|
||||
|
||||
func (rcv *MsgDidRegisterServiceImpl) GetMetadata() *pkl.Object {
|
||||
return rcv.Metadata
|
||||
}
|
||||
|
||||
func (rcv *MsgDidRegisterServiceImpl) GetToken() *pkl.Object {
|
||||
return rcv.Token
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// Code generated from Pkl module `txns`. DO NOT EDIT.
|
||||
package txns
|
||||
|
||||
import "github.com/apple/pkl-go/pkl"
|
||||
|
||||
type MsgDidSyncVault interface {
|
||||
Msg
|
||||
|
||||
GetController() string
|
||||
|
||||
GetToken() *pkl.Object
|
||||
}
|
||||
|
||||
var _ MsgDidSyncVault = (*MsgDidSyncVaultImpl)(nil)
|
||||
|
||||
type MsgDidSyncVaultImpl struct {
|
||||
// The type URL for the message
|
||||
TypeUrl string `pkl:"typeUrl"`
|
||||
|
||||
Controller string `pkl:"controller"`
|
||||
|
||||
Token *pkl.Object `pkl:"token"`
|
||||
}
|
||||
|
||||
// The type URL for the message
|
||||
func (rcv *MsgDidSyncVaultImpl) GetTypeUrl() string {
|
||||
return rcv.TypeUrl
|
||||
}
|
||||
|
||||
func (rcv *MsgDidSyncVaultImpl) GetController() string {
|
||||
return rcv.Controller
|
||||
}
|
||||
|
||||
func (rcv *MsgDidSyncVaultImpl) GetToken() *pkl.Object {
|
||||
return rcv.Token
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// Code generated from Pkl module `txns`. DO NOT EDIT.
|
||||
package txns
|
||||
|
||||
import "github.com/apple/pkl-go/pkl"
|
||||
|
||||
type MsgDidUpdateParams interface {
|
||||
Msg
|
||||
|
||||
GetAuthority() string
|
||||
|
||||
GetParams() *pkl.Object
|
||||
|
||||
GetToken() *pkl.Object
|
||||
}
|
||||
|
||||
var _ MsgDidUpdateParams = (*MsgDidUpdateParamsImpl)(nil)
|
||||
|
||||
type MsgDidUpdateParamsImpl struct {
|
||||
// The type URL for the message
|
||||
TypeUrl string `pkl:"typeUrl"`
|
||||
|
||||
Authority string `pkl:"authority"`
|
||||
|
||||
Params *pkl.Object `pkl:"params"`
|
||||
|
||||
Token *pkl.Object `pkl:"token"`
|
||||
}
|
||||
|
||||
// The type URL for the message
|
||||
func (rcv *MsgDidUpdateParamsImpl) GetTypeUrl() string {
|
||||
return rcv.TypeUrl
|
||||
}
|
||||
|
||||
func (rcv *MsgDidUpdateParamsImpl) GetAuthority() string {
|
||||
return rcv.Authority
|
||||
}
|
||||
|
||||
func (rcv *MsgDidUpdateParamsImpl) GetParams() *pkl.Object {
|
||||
return rcv.Params
|
||||
}
|
||||
|
||||
func (rcv *MsgDidUpdateParamsImpl) GetToken() *pkl.Object {
|
||||
return rcv.Token
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// Code generated from Pkl module `txns`. DO NOT EDIT.
|
||||
package txns
|
||||
|
||||
import "github.com/apple/pkl-go/pkl"
|
||||
|
||||
type MsgGovDeposit interface {
|
||||
Msg
|
||||
|
||||
GetProposalId() int
|
||||
|
||||
GetDepositor() string
|
||||
|
||||
GetAmount() []*pkl.Object
|
||||
}
|
||||
|
||||
var _ MsgGovDeposit = (*MsgGovDepositImpl)(nil)
|
||||
|
||||
type MsgGovDepositImpl struct {
|
||||
// The type URL for the message
|
||||
TypeUrl string `pkl:"typeUrl"`
|
||||
|
||||
ProposalId int `pkl:"proposalId"`
|
||||
|
||||
Depositor string `pkl:"depositor"`
|
||||
|
||||
Amount []*pkl.Object `pkl:"amount"`
|
||||
}
|
||||
|
||||
// The type URL for the message
|
||||
func (rcv *MsgGovDepositImpl) GetTypeUrl() string {
|
||||
return rcv.TypeUrl
|
||||
}
|
||||
|
||||
func (rcv *MsgGovDepositImpl) GetProposalId() int {
|
||||
return rcv.ProposalId
|
||||
}
|
||||
|
||||
func (rcv *MsgGovDepositImpl) GetDepositor() string {
|
||||
return rcv.Depositor
|
||||
}
|
||||
|
||||
func (rcv *MsgGovDepositImpl) GetAmount() []*pkl.Object {
|
||||
return rcv.Amount
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// Code generated from Pkl module `txns`. DO NOT EDIT.
|
||||
package txns
|
||||
|
||||
import "github.com/apple/pkl-go/pkl"
|
||||
|
||||
type MsgGovSubmitProposal interface {
|
||||
Msg
|
||||
|
||||
GetContent() *Proposal
|
||||
|
||||
GetInitialDeposit() []*pkl.Object
|
||||
|
||||
GetProposer() string
|
||||
}
|
||||
|
||||
var _ MsgGovSubmitProposal = (*MsgGovSubmitProposalImpl)(nil)
|
||||
|
||||
// Gov module messages
|
||||
type MsgGovSubmitProposalImpl struct {
|
||||
// The type URL for the message
|
||||
TypeUrl string `pkl:"typeUrl"`
|
||||
|
||||
Content *Proposal `pkl:"content"`
|
||||
|
||||
InitialDeposit []*pkl.Object `pkl:"initialDeposit"`
|
||||
|
||||
Proposer string `pkl:"proposer"`
|
||||
}
|
||||
|
||||
// The type URL for the message
|
||||
func (rcv *MsgGovSubmitProposalImpl) GetTypeUrl() string {
|
||||
return rcv.TypeUrl
|
||||
}
|
||||
|
||||
func (rcv *MsgGovSubmitProposalImpl) GetContent() *Proposal {
|
||||
return rcv.Content
|
||||
}
|
||||
|
||||
func (rcv *MsgGovSubmitProposalImpl) GetInitialDeposit() []*pkl.Object {
|
||||
return rcv.InitialDeposit
|
||||
}
|
||||
|
||||
func (rcv *MsgGovSubmitProposalImpl) GetProposer() string {
|
||||
return rcv.Proposer
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
// Code generated from Pkl module `txns`. DO NOT EDIT.
|
||||
package txns
|
||||
|
||||
type MsgGovVote interface {
|
||||
Msg
|
||||
|
||||
GetProposalId() int
|
||||
|
||||
GetVoter() string
|
||||
|
||||
GetOption() int
|
||||
}
|
||||
|
||||
var _ MsgGovVote = (*MsgGovVoteImpl)(nil)
|
||||
|
||||
type MsgGovVoteImpl struct {
|
||||
// The type URL for the message
|
||||
TypeUrl string `pkl:"typeUrl"`
|
||||
|
||||
ProposalId int `pkl:"proposalId"`
|
||||
|
||||
Voter string `pkl:"voter"`
|
||||
|
||||
Option int `pkl:"option"`
|
||||
}
|
||||
|
||||
// The type URL for the message
|
||||
func (rcv *MsgGovVoteImpl) GetTypeUrl() string {
|
||||
return rcv.TypeUrl
|
||||
}
|
||||
|
||||
func (rcv *MsgGovVoteImpl) GetProposalId() int {
|
||||
return rcv.ProposalId
|
||||
}
|
||||
|
||||
func (rcv *MsgGovVoteImpl) GetVoter() string {
|
||||
return rcv.Voter
|
||||
}
|
||||
|
||||
func (rcv *MsgGovVoteImpl) GetOption() int {
|
||||
return rcv.Option
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// Code generated from Pkl module `txns`. DO NOT EDIT.
|
||||
package txns
|
||||
|
||||
import "github.com/apple/pkl-go/pkl"
|
||||
|
||||
type MsgGroupCreateGroup interface {
|
||||
Msg
|
||||
|
||||
GetAdmin() string
|
||||
|
||||
GetMembers() []*pkl.Object
|
||||
|
||||
GetMetadata() string
|
||||
}
|
||||
|
||||
var _ MsgGroupCreateGroup = (*MsgGroupCreateGroupImpl)(nil)
|
||||
|
||||
// Group module messages
|
||||
type MsgGroupCreateGroupImpl struct {
|
||||
// The type URL for the message
|
||||
TypeUrl string `pkl:"typeUrl"`
|
||||
|
||||
Admin string `pkl:"admin"`
|
||||
|
||||
Members []*pkl.Object `pkl:"members"`
|
||||
|
||||
Metadata string `pkl:"metadata"`
|
||||
}
|
||||
|
||||
// The type URL for the message
|
||||
func (rcv *MsgGroupCreateGroupImpl) GetTypeUrl() string {
|
||||
return rcv.TypeUrl
|
||||
}
|
||||
|
||||
func (rcv *MsgGroupCreateGroupImpl) GetAdmin() string {
|
||||
return rcv.Admin
|
||||
}
|
||||
|
||||
func (rcv *MsgGroupCreateGroupImpl) GetMembers() []*pkl.Object {
|
||||
return rcv.Members
|
||||
}
|
||||
|
||||
func (rcv *MsgGroupCreateGroupImpl) GetMetadata() string {
|
||||
return rcv.Metadata
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
// Code generated from Pkl module `txns`. DO NOT EDIT.
|
||||
package txns
|
||||
|
||||
import "github.com/apple/pkl-go/pkl"
|
||||
|
||||
type MsgGroupSubmitProposal interface {
|
||||
Msg
|
||||
|
||||
GetGroupPolicyAddress() string
|
||||
|
||||
GetProposers() []string
|
||||
|
||||
GetMetadata() string
|
||||
|
||||
GetMessages() []*pkl.Object
|
||||
|
||||
GetExec() int
|
||||
}
|
||||
|
||||
var _ MsgGroupSubmitProposal = (*MsgGroupSubmitProposalImpl)(nil)
|
||||
|
||||
type MsgGroupSubmitProposalImpl struct {
|
||||
// The type URL for the message
|
||||
TypeUrl string `pkl:"typeUrl"`
|
||||
|
||||
GroupPolicyAddress string `pkl:"groupPolicyAddress"`
|
||||
|
||||
Proposers []string `pkl:"proposers"`
|
||||
|
||||
Metadata string `pkl:"metadata"`
|
||||
|
||||
Messages []*pkl.Object `pkl:"messages"`
|
||||
|
||||
Exec int `pkl:"exec"`
|
||||
}
|
||||
|
||||
// The type URL for the message
|
||||
func (rcv *MsgGroupSubmitProposalImpl) GetTypeUrl() string {
|
||||
return rcv.TypeUrl
|
||||
}
|
||||
|
||||
func (rcv *MsgGroupSubmitProposalImpl) GetGroupPolicyAddress() string {
|
||||
return rcv.GroupPolicyAddress
|
||||
}
|
||||
|
||||
func (rcv *MsgGroupSubmitProposalImpl) GetProposers() []string {
|
||||
return rcv.Proposers
|
||||
}
|
||||
|
||||
func (rcv *MsgGroupSubmitProposalImpl) GetMetadata() string {
|
||||
return rcv.Metadata
|
||||
}
|
||||
|
||||
func (rcv *MsgGroupSubmitProposalImpl) GetMessages() []*pkl.Object {
|
||||
return rcv.Messages
|
||||
}
|
||||
|
||||
func (rcv *MsgGroupSubmitProposalImpl) GetExec() int {
|
||||
return rcv.Exec
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
// Code generated from Pkl module `txns`. DO NOT EDIT.
|
||||
package txns
|
||||
|
||||
type MsgGroupVote interface {
|
||||
Msg
|
||||
|
||||
GetProposalId() int
|
||||
|
||||
GetVoter() string
|
||||
|
||||
GetOption() int
|
||||
|
||||
GetMetadata() string
|
||||
|
||||
GetExec() int
|
||||
}
|
||||
|
||||
var _ MsgGroupVote = (*MsgGroupVoteImpl)(nil)
|
||||
|
||||
type MsgGroupVoteImpl struct {
|
||||
// The type URL for the message
|
||||
TypeUrl string `pkl:"typeUrl"`
|
||||
|
||||
ProposalId int `pkl:"proposalId"`
|
||||
|
||||
Voter string `pkl:"voter"`
|
||||
|
||||
Option int `pkl:"option"`
|
||||
|
||||
Metadata string `pkl:"metadata"`
|
||||
|
||||
Exec int `pkl:"exec"`
|
||||
}
|
||||
|
||||
// The type URL for the message
|
||||
func (rcv *MsgGroupVoteImpl) GetTypeUrl() string {
|
||||
return rcv.TypeUrl
|
||||
}
|
||||
|
||||
func (rcv *MsgGroupVoteImpl) GetProposalId() int {
|
||||
return rcv.ProposalId
|
||||
}
|
||||
|
||||
func (rcv *MsgGroupVoteImpl) GetVoter() string {
|
||||
return rcv.Voter
|
||||
}
|
||||
|
||||
func (rcv *MsgGroupVoteImpl) GetOption() int {
|
||||
return rcv.Option
|
||||
}
|
||||
|
||||
func (rcv *MsgGroupVoteImpl) GetMetadata() string {
|
||||
return rcv.Metadata
|
||||
}
|
||||
|
||||
func (rcv *MsgGroupVoteImpl) GetExec() int {
|
||||
return rcv.Exec
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
// Code generated from Pkl module `txns`. DO NOT EDIT.
|
||||
package txns
|
||||
|
||||
import "github.com/apple/pkl-go/pkl"
|
||||
|
||||
type MsgStakingBeginRedelegate interface {
|
||||
Msg
|
||||
|
||||
GetDelegatorAddress() string
|
||||
|
||||
GetValidatorSrcAddress() string
|
||||
|
||||
GetValidatorDstAddress() string
|
||||
|
||||
GetAmount() *pkl.Object
|
||||
}
|
||||
|
||||
var _ MsgStakingBeginRedelegate = (*MsgStakingBeginRedelegateImpl)(nil)
|
||||
|
||||
type MsgStakingBeginRedelegateImpl struct {
|
||||
// The type URL for the message
|
||||
TypeUrl string `pkl:"typeUrl"`
|
||||
|
||||
DelegatorAddress string `pkl:"delegatorAddress"`
|
||||
|
||||
ValidatorSrcAddress string `pkl:"validatorSrcAddress"`
|
||||
|
||||
ValidatorDstAddress string `pkl:"validatorDstAddress"`
|
||||
|
||||
Amount *pkl.Object `pkl:"amount"`
|
||||
}
|
||||
|
||||
// The type URL for the message
|
||||
func (rcv *MsgStakingBeginRedelegateImpl) GetTypeUrl() string {
|
||||
return rcv.TypeUrl
|
||||
}
|
||||
|
||||
func (rcv *MsgStakingBeginRedelegateImpl) GetDelegatorAddress() string {
|
||||
return rcv.DelegatorAddress
|
||||
}
|
||||
|
||||
func (rcv *MsgStakingBeginRedelegateImpl) GetValidatorSrcAddress() string {
|
||||
return rcv.ValidatorSrcAddress
|
||||
}
|
||||
|
||||
func (rcv *MsgStakingBeginRedelegateImpl) GetValidatorDstAddress() string {
|
||||
return rcv.ValidatorDstAddress
|
||||
}
|
||||
|
||||
func (rcv *MsgStakingBeginRedelegateImpl) GetAmount() *pkl.Object {
|
||||
return rcv.Amount
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
// Code generated from Pkl module `txns`. DO NOT EDIT.
|
||||
package txns
|
||||
|
||||
import "github.com/apple/pkl-go/pkl"
|
||||
|
||||
type MsgStakingCreateValidator interface {
|
||||
Msg
|
||||
|
||||
GetDescription() *pkl.Object
|
||||
|
||||
GetCommission() *pkl.Object
|
||||
|
||||
GetMinSelfDelegation() string
|
||||
|
||||
GetDelegatorAddress() string
|
||||
|
||||
GetValidatorAddress() string
|
||||
|
||||
GetPubkey() *pkl.Object
|
||||
|
||||
GetValue() *pkl.Object
|
||||
}
|
||||
|
||||
var _ MsgStakingCreateValidator = (*MsgStakingCreateValidatorImpl)(nil)
|
||||
|
||||
// Staking module messages
|
||||
type MsgStakingCreateValidatorImpl struct {
|
||||
// The type URL for the message
|
||||
TypeUrl string `pkl:"typeUrl"`
|
||||
|
||||
Description *pkl.Object `pkl:"description"`
|
||||
|
||||
Commission *pkl.Object `pkl:"commission"`
|
||||
|
||||
MinSelfDelegation string `pkl:"minSelfDelegation"`
|
||||
|
||||
DelegatorAddress string `pkl:"delegatorAddress"`
|
||||
|
||||
ValidatorAddress string `pkl:"validatorAddress"`
|
||||
|
||||
Pubkey *pkl.Object `pkl:"pubkey"`
|
||||
|
||||
Value *pkl.Object `pkl:"value"`
|
||||
}
|
||||
|
||||
// The type URL for the message
|
||||
func (rcv *MsgStakingCreateValidatorImpl) GetTypeUrl() string {
|
||||
return rcv.TypeUrl
|
||||
}
|
||||
|
||||
func (rcv *MsgStakingCreateValidatorImpl) GetDescription() *pkl.Object {
|
||||
return rcv.Description
|
||||
}
|
||||
|
||||
func (rcv *MsgStakingCreateValidatorImpl) GetCommission() *pkl.Object {
|
||||
return rcv.Commission
|
||||
}
|
||||
|
||||
func (rcv *MsgStakingCreateValidatorImpl) GetMinSelfDelegation() string {
|
||||
return rcv.MinSelfDelegation
|
||||
}
|
||||
|
||||
func (rcv *MsgStakingCreateValidatorImpl) GetDelegatorAddress() string {
|
||||
return rcv.DelegatorAddress
|
||||
}
|
||||
|
||||
func (rcv *MsgStakingCreateValidatorImpl) GetValidatorAddress() string {
|
||||
return rcv.ValidatorAddress
|
||||
}
|
||||
|
||||
func (rcv *MsgStakingCreateValidatorImpl) GetPubkey() *pkl.Object {
|
||||
return rcv.Pubkey
|
||||
}
|
||||
|
||||
func (rcv *MsgStakingCreateValidatorImpl) GetValue() *pkl.Object {
|
||||
return rcv.Value
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// Code generated from Pkl module `txns`. DO NOT EDIT.
|
||||
package txns
|
||||
|
||||
import "github.com/apple/pkl-go/pkl"
|
||||
|
||||
type MsgStakingDelegate interface {
|
||||
Msg
|
||||
|
||||
GetDelegatorAddress() string
|
||||
|
||||
GetValidatorAddress() string
|
||||
|
||||
GetAmount() *pkl.Object
|
||||
}
|
||||
|
||||
var _ MsgStakingDelegate = (*MsgStakingDelegateImpl)(nil)
|
||||
|
||||
type MsgStakingDelegateImpl struct {
|
||||
// The type URL for the message
|
||||
TypeUrl string `pkl:"typeUrl"`
|
||||
|
||||
DelegatorAddress string `pkl:"delegatorAddress"`
|
||||
|
||||
ValidatorAddress string `pkl:"validatorAddress"`
|
||||
|
||||
Amount *pkl.Object `pkl:"amount"`
|
||||
}
|
||||
|
||||
// The type URL for the message
|
||||
func (rcv *MsgStakingDelegateImpl) GetTypeUrl() string {
|
||||
return rcv.TypeUrl
|
||||
}
|
||||
|
||||
func (rcv *MsgStakingDelegateImpl) GetDelegatorAddress() string {
|
||||
return rcv.DelegatorAddress
|
||||
}
|
||||
|
||||
func (rcv *MsgStakingDelegateImpl) GetValidatorAddress() string {
|
||||
return rcv.ValidatorAddress
|
||||
}
|
||||
|
||||
func (rcv *MsgStakingDelegateImpl) GetAmount() *pkl.Object {
|
||||
return rcv.Amount
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// Code generated from Pkl module `txns`. DO NOT EDIT.
|
||||
package txns
|
||||
|
||||
import "github.com/apple/pkl-go/pkl"
|
||||
|
||||
type MsgStakingUndelegate interface {
|
||||
Msg
|
||||
|
||||
GetDelegatorAddress() string
|
||||
|
||||
GetValidatorAddress() string
|
||||
|
||||
GetAmount() *pkl.Object
|
||||
}
|
||||
|
||||
var _ MsgStakingUndelegate = (*MsgStakingUndelegateImpl)(nil)
|
||||
|
||||
type MsgStakingUndelegateImpl struct {
|
||||
// The type URL for the message
|
||||
TypeUrl string `pkl:"typeUrl"`
|
||||
|
||||
DelegatorAddress string `pkl:"delegatorAddress"`
|
||||
|
||||
ValidatorAddress string `pkl:"validatorAddress"`
|
||||
|
||||
Amount *pkl.Object `pkl:"amount"`
|
||||
}
|
||||
|
||||
// The type URL for the message
|
||||
func (rcv *MsgStakingUndelegateImpl) GetTypeUrl() string {
|
||||
return rcv.TypeUrl
|
||||
}
|
||||
|
||||
func (rcv *MsgStakingUndelegateImpl) GetDelegatorAddress() string {
|
||||
return rcv.DelegatorAddress
|
||||
}
|
||||
|
||||
func (rcv *MsgStakingUndelegateImpl) GetValidatorAddress() string {
|
||||
return rcv.ValidatorAddress
|
||||
}
|
||||
|
||||
func (rcv *MsgStakingUndelegateImpl) GetAmount() *pkl.Object {
|
||||
return rcv.Amount
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Code generated from Pkl module `txns`. DO NOT EDIT.
|
||||
package txns
|
||||
|
||||
// Base class for all proposals
|
||||
type Proposal struct {
|
||||
// The title of the proposal
|
||||
Title string `pkl:"title"`
|
||||
|
||||
// The description of the proposal
|
||||
Description string `pkl:"description"`
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// Code generated from Pkl module `txns`. DO NOT EDIT.
|
||||
package txns
|
||||
|
||||
import "github.com/apple/pkl-go/pkl"
|
||||
|
||||
// Represents a transaction body
|
||||
type TxBody struct {
|
||||
Messages []Msg `pkl:"messages"`
|
||||
|
||||
Memo *string `pkl:"memo"`
|
||||
|
||||
TimeoutHeight *int `pkl:"timeoutHeight"`
|
||||
|
||||
ExtensionOptions *[]*pkl.Object `pkl:"extensionOptions"`
|
||||
|
||||
NonCriticalExtensionOptions *[]*pkl.Object `pkl:"nonCriticalExtensionOptions"`
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// Code generated from Pkl module `txns`. DO NOT EDIT.
|
||||
package txns
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/apple/pkl-go/pkl"
|
||||
)
|
||||
|
||||
type Txns struct {
|
||||
}
|
||||
|
||||
// LoadFromPath loads the pkl module at the given path and evaluates it into a Txns
|
||||
func LoadFromPath(ctx context.Context, path string) (ret *Txns, err error) {
|
||||
evaluator, err := pkl.NewEvaluator(ctx, pkl.PreconfiguredOptions)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer func() {
|
||||
cerr := evaluator.Close()
|
||||
if err == nil {
|
||||
err = cerr
|
||||
}
|
||||
}()
|
||||
ret, err = Load(ctx, evaluator, pkl.FileSource(path))
|
||||
return ret, err
|
||||
}
|
||||
|
||||
// Load loads the pkl module at the given source and evaluates it with the given evaluator into a Txns
|
||||
func Load(ctx context.Context, evaluator pkl.Evaluator, source *pkl.ModuleSource) (*Txns, error) {
|
||||
var ret Txns
|
||||
if err := evaluator.EvaluateModule(ctx, source, &ret); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &ret, nil
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Code generated from Pkl module `txns`. DO NOT EDIT.
|
||||
package txns
|
||||
|
||||
import "github.com/apple/pkl-go/pkl"
|
||||
|
||||
func init() {
|
||||
pkl.RegisterMapping("txns", Txns{})
|
||||
pkl.RegisterMapping("txns#Proposal", Proposal{})
|
||||
pkl.RegisterMapping("txns#MsgGovSubmitProposal", MsgGovSubmitProposalImpl{})
|
||||
pkl.RegisterMapping("txns#MsgGovVote", MsgGovVoteImpl{})
|
||||
pkl.RegisterMapping("txns#MsgGovDeposit", MsgGovDepositImpl{})
|
||||
pkl.RegisterMapping("txns#MsgGroupCreateGroup", MsgGroupCreateGroupImpl{})
|
||||
pkl.RegisterMapping("txns#MsgGroupSubmitProposal", MsgGroupSubmitProposalImpl{})
|
||||
pkl.RegisterMapping("txns#MsgGroupVote", MsgGroupVoteImpl{})
|
||||
pkl.RegisterMapping("txns#MsgStakingCreateValidator", MsgStakingCreateValidatorImpl{})
|
||||
pkl.RegisterMapping("txns#MsgStakingDelegate", MsgStakingDelegateImpl{})
|
||||
pkl.RegisterMapping("txns#MsgStakingUndelegate", MsgStakingUndelegateImpl{})
|
||||
pkl.RegisterMapping("txns#MsgStakingBeginRedelegate", MsgStakingBeginRedelegateImpl{})
|
||||
pkl.RegisterMapping("txns#MsgDidUpdateParams", MsgDidUpdateParamsImpl{})
|
||||
pkl.RegisterMapping("txns#MsgDidAllocateVault", MsgDidAllocateVaultImpl{})
|
||||
pkl.RegisterMapping("txns#MsgDidProveWitness", MsgDidProveWitnessImpl{})
|
||||
pkl.RegisterMapping("txns#MsgDidSyncVault", MsgDidSyncVaultImpl{})
|
||||
pkl.RegisterMapping("txns#MsgDidRegisterController", MsgDidRegisterControllerImpl{})
|
||||
pkl.RegisterMapping("txns#MsgDidAuthorize", MsgDidAuthorizeImpl{})
|
||||
pkl.RegisterMapping("txns#MsgDidRegisterService", MsgDidRegisterServiceImpl{})
|
||||
pkl.RegisterMapping("txns#TxBody", TxBody{})
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/onsonr/crypto/accumulator"
|
||||
"github.com/onsonr/crypto/core/curves"
|
||||
)
|
||||
|
||||
// Accumulator is the accumulator for the ZKP
|
||||
type Accumulator []byte
|
||||
|
||||
// Element is the element for the BLS scheme
|
||||
type Element = accumulator.Element
|
||||
|
||||
// Witness is the witness for the ZKP
|
||||
type Witness []byte
|
||||
|
||||
// NewProof creates a new Proof which is used for ZKP
|
||||
func NewProof(issuer, property string, pubKey []byte) (*Proof, error) {
|
||||
input := append(pubKey, []byte(property)...)
|
||||
hash := []byte(input)
|
||||
|
||||
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||
key, err := new(accumulator.SecretKey).New(curve, hash[:])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create secret key: %w", err)
|
||||
}
|
||||
|
||||
keyBytes, err := key.MarshalBinary()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to marshal secret key: %w", err)
|
||||
}
|
||||
|
||||
return &Proof{
|
||||
Issuer: issuer,
|
||||
Property: property,
|
||||
Accumulator: keyBytes,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// CreateAccumulator creates a new accumulator for a Proof
|
||||
func CreateAccumulator(proof *Proof, values ...string) error {
|
||||
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||
acc, err := new(accumulator.Accumulator).New(curve)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
secretKey := new(accumulator.SecretKey)
|
||||
if err := secretKey.UnmarshalBinary(proof.Accumulator); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fin, _, err := acc.Update(secretKey, ConvertValuesToZeroKnowledgeElements(values), nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
accBytes, err := fin.MarshalBinary()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to marshal accumulator: %w", err)
|
||||
}
|
||||
|
||||
proof.Accumulator = accBytes
|
||||
return nil
|
||||
}
|
||||
|
||||
// CreateWitness creates a witness for the accumulator in a Proof for a given value
|
||||
func CreateWitness(proof *Proof, value string) ([]byte, error) {
|
||||
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||
element := curve.Scalar.Hash([]byte(value))
|
||||
|
||||
secretKey := new(accumulator.SecretKey)
|
||||
if err := secretKey.UnmarshalBinary(proof.Accumulator); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
accObj := new(accumulator.Accumulator)
|
||||
if err := accObj.UnmarshalBinary(proof.Accumulator); err != nil {
|
||||
return nil, fmt.Errorf("failed to unmarshal accumulator: %w", err)
|
||||
}
|
||||
|
||||
mw, err := new(accumulator.MembershipWitness).New(element, accObj, secretKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
witnessBytes, err := mw.MarshalBinary()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to marshal witness: %w", err)
|
||||
}
|
||||
return witnessBytes, nil
|
||||
}
|
||||
|
||||
// VerifyWitness proves that a value is a member of the accumulator
|
||||
func VerifyWitness(proof *Proof, acc Accumulator, witness Witness) error {
|
||||
secretKey := new(accumulator.SecretKey)
|
||||
if err := secretKey.UnmarshalBinary([]byte(proof.Id)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||
publicKey, err := secretKey.GetPublicKey(curve)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
accObj := new(accumulator.Accumulator)
|
||||
if err := accObj.UnmarshalBinary(proof.Accumulator); err != nil {
|
||||
return fmt.Errorf("failed to unmarshal accumulator: %w", err)
|
||||
}
|
||||
|
||||
witnessObj := new(accumulator.MembershipWitness)
|
||||
if err := witnessObj.UnmarshalBinary(witness); err != nil {
|
||||
return fmt.Errorf("failed to unmarshal witness: %w", err)
|
||||
}
|
||||
return witnessObj.Verify(publicKey, accObj)
|
||||
}
|
||||
|
||||
// UpdateAccumulator updates the accumulator in a Proof with new values
|
||||
func UpdateAccumulator(proof *Proof, addValues []string, removeValues []string) error {
|
||||
secretKey := new(accumulator.SecretKey)
|
||||
if err := secretKey.UnmarshalBinary(proof.Accumulator); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
accObj := new(accumulator.Accumulator)
|
||||
if err := accObj.UnmarshalBinary(proof.Accumulator); err != nil {
|
||||
return fmt.Errorf("failed to unmarshal accumulator: %w", err)
|
||||
}
|
||||
|
||||
updatedAcc, _, err := accObj.Update(secretKey, ConvertValuesToZeroKnowledgeElements(addValues), ConvertValuesToZeroKnowledgeElements(removeValues))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
updatedAccBytes, err := updatedAcc.MarshalBinary()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to marshal updated accumulator: %w", err)
|
||||
}
|
||||
|
||||
proof.Accumulator = updatedAccBytes
|
||||
return nil
|
||||
}
|
||||
|
||||
// ConvertValuesToZeroKnowledgeElements converts a slice of strings to a slice of accumulator elements
|
||||
func ConvertValuesToZeroKnowledgeElements(values []string) []Element {
|
||||
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||
elements := make([]accumulator.Element, len(values))
|
||||
for i, value := range values {
|
||||
elements[i] = curve.Scalar.Hash([]byte(value))
|
||||
}
|
||||
return elements
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
# `x/oracle`
|
||||
|
||||
Our `oracle` module serves as a ICS-20 Compliant middleware which leverages InterChain Accounts and the Transfer module to associate derived wallets with Oracles and facilitate the transfer of tokens between them.
|
||||
|
||||
## Concepts
|
||||
|
||||
Describe specialized concepts and definitions used throughout the spec.
|
||||
|
||||
## State
|
||||
|
||||
Specify and describe structures expected to marshalled into the store, and their keys
|
||||
|
||||
## State Transitions
|
||||
|
||||
Standard state transition operations triggered by hooks, messages, etc.
|
||||
|
||||
## Messages
|
||||
|
||||
Specify message structure(s) and expected state machine behaviour(s). https://api.coingecko.com/api/v3/coins/list
|
||||
|
||||
## Begin Block
|
||||
|
||||
Specify any begin-block operations.
|
||||
|
||||
## End Block
|
||||
|
||||
Specify any end-block operations.
|
||||
|
||||
## Hooks
|
||||
|
||||
Describe available hooks to be called by/from this module.
|
||||
|
||||
## Events
|
||||
|
||||
List and describe event tags used.
|
||||
|
||||
## Client
|
||||
|
||||
List and describe CLI commands and gRPC and REST endpoints.
|
||||
|
||||
## Params
|
||||
|
||||
List all module parameters, their types (in JSON) and services.
|
||||
|
||||
## Future Improvements
|
||||
|
||||
Describe future improvements of this module.
|
||||
|
||||
## Tests
|
||||
|
||||
Acceptance tests.
|
||||
|
||||
## Appendix
|
||||
|
||||
Supplementary details referenced elsewhere within the spec.
|
||||
@@ -1,168 +0,0 @@
|
||||
package oracle
|
||||
|
||||
import (
|
||||
"github.com/onsonr/hway/x/oracle/keeper"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"
|
||||
|
||||
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
|
||||
channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
|
||||
porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types"
|
||||
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
|
||||
)
|
||||
|
||||
var _ porttypes.Middleware = &IBCMiddleware{}
|
||||
|
||||
// IBCMiddleware implements the ICS26 callbacks for the middleware given the
|
||||
// keeper and the underlying application.
|
||||
type IBCMiddleware struct {
|
||||
app porttypes.IBCModule
|
||||
keeper keeper.Keeper
|
||||
}
|
||||
|
||||
// NewIBCMiddleware creates a new IBCMiddleware given the keeper and underlying application.
|
||||
func NewIBCMiddleware(app porttypes.IBCModule, k keeper.Keeper) IBCMiddleware {
|
||||
return IBCMiddleware{
|
||||
app: app,
|
||||
keeper: k,
|
||||
}
|
||||
}
|
||||
|
||||
// OnChanOpenInit implements the IBCMiddleware interface.
|
||||
func (im IBCMiddleware) OnChanOpenInit(
|
||||
ctx sdk.Context,
|
||||
order channeltypes.Order,
|
||||
connectionHops []string,
|
||||
portID string,
|
||||
channelID string,
|
||||
chanCap *capabilitytypes.Capability,
|
||||
counterparty channeltypes.Counterparty,
|
||||
version string,
|
||||
) (string, error) {
|
||||
return im.app.OnChanOpenInit(
|
||||
ctx,
|
||||
order,
|
||||
connectionHops,
|
||||
portID,
|
||||
channelID,
|
||||
chanCap,
|
||||
counterparty,
|
||||
version,
|
||||
)
|
||||
}
|
||||
|
||||
// OnChanOpenTry implements the IBCMiddleware interface.
|
||||
func (im IBCMiddleware) OnChanOpenTry(
|
||||
ctx sdk.Context,
|
||||
order channeltypes.Order,
|
||||
connectionHops []string,
|
||||
portID, channelID string,
|
||||
chanCap *capabilitytypes.Capability,
|
||||
counterparty channeltypes.Counterparty,
|
||||
counterpartyVersion string,
|
||||
) (version string, err error) {
|
||||
return im.app.OnChanOpenTry(
|
||||
ctx,
|
||||
order,
|
||||
connectionHops,
|
||||
portID,
|
||||
channelID,
|
||||
chanCap,
|
||||
counterparty,
|
||||
counterpartyVersion,
|
||||
)
|
||||
}
|
||||
|
||||
// OnChanOpenAck implements the IBCMiddleware interface.
|
||||
func (im IBCMiddleware) OnChanOpenAck(
|
||||
ctx sdk.Context,
|
||||
portID, channelID string,
|
||||
counterpartyChannelID string,
|
||||
counterpartyVersion string,
|
||||
) error {
|
||||
return im.app.OnChanOpenAck(ctx, portID, channelID, counterpartyChannelID, counterpartyVersion)
|
||||
}
|
||||
|
||||
// OnChanOpenConfirm implements the IBCMiddleware interface.
|
||||
func (im IBCMiddleware) OnChanOpenConfirm(ctx sdk.Context, portID, channelID string) error {
|
||||
return im.app.OnChanOpenConfirm(ctx, portID, channelID)
|
||||
}
|
||||
|
||||
// OnChanCloseInit implements the IBCMiddleware interface.
|
||||
func (im IBCMiddleware) OnChanCloseInit(ctx sdk.Context, portID, channelID string) error {
|
||||
return im.app.OnChanCloseInit(ctx, portID, channelID)
|
||||
}
|
||||
|
||||
// OnChanCloseConfirm implements the IBCMiddleware interface.
|
||||
func (im IBCMiddleware) OnChanCloseConfirm(ctx sdk.Context, portID, channelID string) error {
|
||||
return im.app.OnChanCloseConfirm(ctx, portID, channelID)
|
||||
}
|
||||
|
||||
// OnRecvPacket implements the IBCMiddleware interface.
|
||||
func (im IBCMiddleware) OnRecvPacket(
|
||||
ctx sdk.Context,
|
||||
packet channeltypes.Packet,
|
||||
relayer sdk.AccAddress,
|
||||
) ibcexported.Acknowledgement {
|
||||
return im.app.OnRecvPacket(ctx, packet, relayer)
|
||||
}
|
||||
|
||||
// OnAcknowledgementPacket implements the IBCMiddleware interface.
|
||||
func (im IBCMiddleware) OnAcknowledgementPacket(
|
||||
ctx sdk.Context,
|
||||
packet channeltypes.Packet,
|
||||
acknowledgement []byte,
|
||||
relayer sdk.AccAddress,
|
||||
) error {
|
||||
return im.app.OnAcknowledgementPacket(ctx, packet, acknowledgement, relayer)
|
||||
}
|
||||
|
||||
// OnTimeoutPacket implements the IBCMiddleware interface.
|
||||
func (im IBCMiddleware) OnTimeoutPacket(
|
||||
ctx sdk.Context,
|
||||
packet channeltypes.Packet,
|
||||
relayer sdk.AccAddress,
|
||||
) error {
|
||||
return im.app.OnTimeoutPacket(ctx, packet, relayer)
|
||||
}
|
||||
|
||||
// SendPacket implements the ICS4 Wrapper interface.
|
||||
func (im IBCMiddleware) SendPacket(
|
||||
ctx sdk.Context,
|
||||
chanCap *capabilitytypes.Capability,
|
||||
sourcePort string,
|
||||
sourceChannel string,
|
||||
timeoutHeight clienttypes.Height,
|
||||
timeoutTimestamp uint64,
|
||||
data []byte,
|
||||
) (sequence uint64, err error) {
|
||||
return im.keeper.SendPacket(
|
||||
ctx,
|
||||
chanCap,
|
||||
sourceChannel,
|
||||
sourceChannel,
|
||||
timeoutHeight,
|
||||
timeoutTimestamp,
|
||||
data,
|
||||
)
|
||||
}
|
||||
|
||||
// WriteAcknowledgement implements the ICS4 Wrapper interface.
|
||||
func (im IBCMiddleware) WriteAcknowledgement(
|
||||
ctx sdk.Context,
|
||||
chanCap *capabilitytypes.Capability,
|
||||
packet ibcexported.PacketI,
|
||||
ack ibcexported.Acknowledgement,
|
||||
) error {
|
||||
return im.keeper.WriteAcknowledgement(ctx, chanCap, packet, ack)
|
||||
}
|
||||
|
||||
// GetAppVersion implements the ICS4 Wrapper interface.
|
||||
func (im IBCMiddleware) GetAppVersion(
|
||||
ctx sdk.Context,
|
||||
portID string,
|
||||
channelID string,
|
||||
) (string, bool) {
|
||||
return im.keeper.GetAppVersion(ctx, portID, channelID)
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"github.com/onsonr/hway/x/oracle/types"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
// InitGenesis initializes the middlewares state from a specified GenesisState.
|
||||
func (k Keeper) InitGenesis(ctx sdk.Context, state types.GenesisState) {
|
||||
}
|
||||
|
||||
// ExportGenesis exports the middlewares state.
|
||||
func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
|
||||
return &types.GenesisState{}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"github.com/onsonr/hway/x/oracle/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"
|
||||
|
||||
"cosmossdk.io/log"
|
||||
|
||||
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
|
||||
porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types"
|
||||
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
|
||||
)
|
||||
|
||||
// Keeper defines the middleware keeper.
|
||||
type Keeper struct {
|
||||
cdc codec.BinaryCodec
|
||||
msgServiceRouter *baseapp.MsgServiceRouter
|
||||
|
||||
ics4Wrapper porttypes.ICS4Wrapper
|
||||
}
|
||||
|
||||
// NewKeeper creates a new swap Keeper instance.
|
||||
func NewKeeper(
|
||||
cdc codec.BinaryCodec,
|
||||
msgServiceRouter *baseapp.MsgServiceRouter,
|
||||
ics4Wrapper porttypes.ICS4Wrapper,
|
||||
) Keeper {
|
||||
return Keeper{
|
||||
cdc: cdc,
|
||||
msgServiceRouter: msgServiceRouter,
|
||||
ics4Wrapper: ics4Wrapper,
|
||||
}
|
||||
}
|
||||
|
||||
// Logger returns a module-specific logger.
|
||||
func (k Keeper) Logger(ctx sdk.Context) log.Logger {
|
||||
return ctx.Logger().With("module", "x/"+ibcexported.ModuleName+"-"+types.ModuleName)
|
||||
}
|
||||
|
||||
// SendPacket wraps IBC ChannelKeeper's SendPacket function.
|
||||
func (k Keeper) SendPacket(
|
||||
ctx sdk.Context,
|
||||
chanCap *capabilitytypes.Capability,
|
||||
sourcePort string,
|
||||
sourceChannel string,
|
||||
timeoutHeight clienttypes.Height,
|
||||
timeoutTimestamp uint64,
|
||||
data []byte,
|
||||
) (sequence uint64, err error) {
|
||||
return k.ics4Wrapper.SendPacket(
|
||||
ctx,
|
||||
chanCap,
|
||||
sourcePort,
|
||||
sourceChannel,
|
||||
timeoutHeight,
|
||||
timeoutTimestamp,
|
||||
data,
|
||||
)
|
||||
}
|
||||
|
||||
// WriteAcknowledgement wraps IBC ChannelKeeper's WriteAcknowledgement function.
|
||||
func (k Keeper) WriteAcknowledgement(
|
||||
ctx sdk.Context,
|
||||
chanCap *capabilitytypes.Capability,
|
||||
packet ibcexported.PacketI,
|
||||
acknowledgement ibcexported.Acknowledgement,
|
||||
) error {
|
||||
return k.ics4Wrapper.WriteAcknowledgement(ctx, chanCap, packet, acknowledgement)
|
||||
}
|
||||
|
||||
// GetAppVersion wraps IBC ChannelKeeper's GetAppVersion function.
|
||||
func (k Keeper) GetAppVersion(ctx sdk.Context, portID string, channelID string) (string, bool) {
|
||||
return k.ics4Wrapper.GetAppVersion(ctx, portID, channelID)
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
package oracle
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
"github.com/onsonr/hway/x/oracle/keeper"
|
||||
"github.com/onsonr/hway/x/oracle/types"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
)
|
||||
|
||||
var (
|
||||
_ module.AppModuleBasic = AppModuleBasic{}
|
||||
_ module.AppModule = AppModule{}
|
||||
_ module.AppModuleSimulation = AppModule{}
|
||||
)
|
||||
|
||||
// AppModuleBasic is the middleware AppModuleBasic.
|
||||
type AppModuleBasic struct{}
|
||||
|
||||
// Name implements AppModuleBasic interface.
|
||||
func (AppModuleBasic) Name() string {
|
||||
return types.ModuleName
|
||||
}
|
||||
|
||||
// RegisterLegacyAminoCodec implements AppModuleBasic interface.
|
||||
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {}
|
||||
|
||||
// RegisterInterfaces registers module concrete types into protobuf Any.
|
||||
func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) {}
|
||||
|
||||
// DefaultGenesis returns default genesis state as raw bytes for the swap module.
|
||||
func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ValidateGenesis performs genesis state validation for the swap module.
|
||||
func (AppModuleBasic) ValidateGenesis(
|
||||
cdc codec.JSONCodec,
|
||||
config client.TxEncodingConfig,
|
||||
bz json.RawMessage,
|
||||
) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the swap module.
|
||||
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {}
|
||||
|
||||
// GetTxCmd implements AppModuleBasic interface.
|
||||
func (AppModuleBasic) GetTxCmd() *cobra.Command {
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetQueryCmd implements AppModuleBasic interface.
|
||||
func (AppModuleBasic) GetQueryCmd() *cobra.Command {
|
||||
return nil
|
||||
}
|
||||
|
||||
// AppModule is the middleware AppModule.
|
||||
type AppModule struct {
|
||||
AppModuleBasic
|
||||
keeper keeper.Keeper
|
||||
}
|
||||
|
||||
// IsAppModule implements module.AppModule.
|
||||
func (AppModule) IsAppModule() {
|
||||
}
|
||||
|
||||
// IsOnePerModuleType implements module.AppModule.
|
||||
func (AppModule) IsOnePerModuleType() {
|
||||
}
|
||||
|
||||
// NewAppModule initializes a new AppModule for the middleware.
|
||||
func NewAppModule(keeper keeper.Keeper) *AppModule {
|
||||
return &AppModule{
|
||||
keeper: keeper,
|
||||
}
|
||||
}
|
||||
|
||||
// RegisterInvariants implements the AppModule interface.
|
||||
func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {}
|
||||
|
||||
// RegisterServices registers module services.
|
||||
func (am AppModule) RegisterServices(cfg module.Configurator) {}
|
||||
|
||||
// InitGenesis performs genesis initialization for the ibc-router module. It returns
|
||||
// no validator updates.
|
||||
func (am AppModule) InitGenesis(
|
||||
ctx sdk.Context,
|
||||
cdc codec.JSONCodec,
|
||||
data json.RawMessage,
|
||||
) []abci.ValidatorUpdate {
|
||||
return []abci.ValidatorUpdate{}
|
||||
}
|
||||
|
||||
// ExportGenesis returns the exported genesis state as raw bytes for the swap module.
|
||||
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ConsensusVersion returns the consensus state breaking version for the swap module.
|
||||
func (am AppModule) ConsensusVersion() uint64 { return 1 }
|
||||
|
||||
// GenerateGenesisState implements the AppModuleSimulation interface.
|
||||
func (am AppModule) GenerateGenesisState(simState *module.SimulationState) {}
|
||||
|
||||
// ProposalContents implements the AppModuleSimulation interface.
|
||||
func (am AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent {
|
||||
return nil
|
||||
}
|
||||
|
||||
// RegisterStoreDecoder implements the AppModuleSimulation interface.
|
||||
func (am AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) {}
|
||||
|
||||
// WeightedOperations implements the AppModuleSimulation interface.
|
||||
func (am AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation {
|
||||
return nil
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package types
|
||||
|
||||
import sdkerrors "cosmossdk.io/errors"
|
||||
|
||||
var (
|
||||
ErrInvalidGenesisState = sdkerrors.Register(ModuleName, 1, "invalid genesis state")
|
||||
)
|
||||
@@ -1,3 +0,0 @@
|
||||
package types
|
||||
|
||||
// Define the expected interfaces that the middleware needs in order to properly function here.
|
||||
@@ -1,16 +0,0 @@
|
||||
package types
|
||||
|
||||
// DefaultGenesisState returns the default middleware GenesisState.
|
||||
func DefaultGenesisState() *GenesisState {
|
||||
return &GenesisState{}
|
||||
}
|
||||
|
||||
// NewGenesisState initializes and returns a new GenesisState.
|
||||
func NewGenesisState() *GenesisState {
|
||||
return &GenesisState{}
|
||||
}
|
||||
|
||||
// Validate performs basic validation of the GenesisState.
|
||||
func (gs *GenesisState) Validate() error {
|
||||
return nil
|
||||
}
|
||||
@@ -1,265 +0,0 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: oracle/v1/genesis.proto
|
||||
|
||||
package types
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
_ "github.com/cosmos/gogoproto/gogoproto"
|
||||
proto "github.com/cosmos/gogoproto/proto"
|
||||
io "io"
|
||||
math "math"
|
||||
math_bits "math/bits"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
// GenesisState defines the middlewares genesis state.
|
||||
type GenesisState struct {
|
||||
}
|
||||
|
||||
func (m *GenesisState) Reset() { *m = GenesisState{} }
|
||||
func (m *GenesisState) String() string { return proto.CompactTextString(m) }
|
||||
func (*GenesisState) ProtoMessage() {}
|
||||
func (*GenesisState) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_14b982a0a6345d1d, []int{0}
|
||||
}
|
||||
func (m *GenesisState) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *GenesisState) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_GenesisState.Merge(m, src)
|
||||
}
|
||||
func (m *GenesisState) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *GenesisState) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_GenesisState.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_GenesisState proto.InternalMessageInfo
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*GenesisState)(nil), "oracle.v1.GenesisState")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("oracle/v1/genesis.proto", fileDescriptor_14b982a0a6345d1d) }
|
||||
|
||||
var fileDescriptor_14b982a0a6345d1d = []byte{
|
||||
// 147 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xcf, 0x2f, 0x4a, 0x4c,
|
||||
0xce, 0x49, 0xd5, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28,
|
||||
0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x84, 0x48, 0xe8, 0x95, 0x19, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7,
|
||||
0x83, 0x45, 0xf5, 0x41, 0x2c, 0x88, 0x02, 0x25, 0x3e, 0x2e, 0x1e, 0x77, 0x88, 0x8e, 0xe0, 0x92,
|
||||
0xc4, 0x92, 0x54, 0x27, 0xfb, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48,
|
||||
0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x52,
|
||||
0x4d, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0xcf, 0xcf, 0x2b, 0xce, 0xcf,
|
||||
0x2b, 0xd2, 0xcf, 0x28, 0x4f, 0xac, 0xd4, 0xaf, 0xd0, 0x87, 0x5a, 0x5e, 0x52, 0x59, 0x90, 0x5a,
|
||||
0x9c, 0xc4, 0x06, 0x36, 0xd7, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x25, 0x38, 0x48, 0xfb, 0x93,
|
||||
0x00, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *GenesisState) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovGenesis(v)
|
||||
base := offset
|
||||
for v >= 1<<7 {
|
||||
dAtA[offset] = uint8(v&0x7f | 0x80)
|
||||
v >>= 7
|
||||
offset++
|
||||
}
|
||||
dAtA[offset] = uint8(v)
|
||||
return base
|
||||
}
|
||||
func (m *GenesisState) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
return n
|
||||
}
|
||||
|
||||
func sovGenesis(x uint64) (n int) {
|
||||
return (math_bits.Len64(x|1) + 6) / 7
|
||||
}
|
||||
func sozGenesis(x uint64) (n int) {
|
||||
return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
||||
}
|
||||
func (m *GenesisState) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowGenesis
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: GenesisState: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipGenesis(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthGenesis
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func skipGenesis(dAtA []byte) (n int, err error) {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
depth := 0
|
||||
for iNdEx < l {
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowGenesis
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= (uint64(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
wireType := int(wire & 0x7)
|
||||
switch wireType {
|
||||
case 0:
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowGenesis
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx++
|
||||
if dAtA[iNdEx-1] < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 1:
|
||||
iNdEx += 8
|
||||
case 2:
|
||||
var length int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowGenesis
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
length |= (int(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if length < 0 {
|
||||
return 0, ErrInvalidLengthGenesis
|
||||
}
|
||||
iNdEx += length
|
||||
case 3:
|
||||
depth++
|
||||
case 4:
|
||||
if depth == 0 {
|
||||
return 0, ErrUnexpectedEndOfGroupGenesis
|
||||
}
|
||||
depth--
|
||||
case 5:
|
||||
iNdEx += 4
|
||||
default:
|
||||
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
|
||||
}
|
||||
if iNdEx < 0 {
|
||||
return 0, ErrInvalidLengthGenesis
|
||||
}
|
||||
if depth == 0 {
|
||||
return iNdEx, nil
|
||||
}
|
||||
}
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
|
||||
var (
|
||||
ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling")
|
||||
ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow")
|
||||
ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group")
|
||||
)
|
||||
@@ -1,15 +0,0 @@
|
||||
package types
|
||||
|
||||
const (
|
||||
// ModuleName defines the name of the middleware.
|
||||
ModuleName = "oracle"
|
||||
|
||||
// StoreKey is the store key string for the middleware.
|
||||
StoreKey = ModuleName
|
||||
|
||||
// RouterKey is the message route for the middleware.
|
||||
RouterKey = ModuleName
|
||||
|
||||
// QuerierRoute is the querier route for the middleware.
|
||||
QuerierRoute = ModuleName
|
||||
)
|
||||
@@ -1,37 +0,0 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: oracle/v1/query.proto
|
||||
|
||||
package types
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
_ "github.com/cosmos/gogoproto/gogoproto"
|
||||
proto "github.com/cosmos/gogoproto/proto"
|
||||
math "math"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
func init() { proto.RegisterFile("oracle/v1/query.proto", fileDescriptor_34238c8dfdfcd7ec) }
|
||||
|
||||
var fileDescriptor_34238c8dfdfcd7ec = []byte{
|
||||
// 133 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xcd, 0x2f, 0x4a, 0x4c,
|
||||
0xce, 0x49, 0xd5, 0x2f, 0x33, 0xd4, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f,
|
||||
0xc9, 0x17, 0xe2, 0x84, 0x08, 0xeb, 0x95, 0x19, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x45,
|
||||
0xf5, 0x41, 0x2c, 0x88, 0x02, 0x27, 0xfb, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c,
|
||||
0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63,
|
||||
0x88, 0x52, 0x4d, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0xcf, 0xcf, 0x2b,
|
||||
0xce, 0xcf, 0x2b, 0xd2, 0xcf, 0x28, 0x4f, 0xac, 0xd4, 0xaf, 0xd0, 0x87, 0x5a, 0x55, 0x52, 0x59,
|
||||
0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x36, 0xc7, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x1c, 0x7f, 0x61,
|
||||
0xbe, 0x81, 0x00, 0x00, 0x00,
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: oracle/v1/tx.proto
|
||||
|
||||
package types
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
_ "github.com/cosmos/gogoproto/gogoproto"
|
||||
proto "github.com/cosmos/gogoproto/proto"
|
||||
math "math"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
func init() { proto.RegisterFile("oracle/v1/tx.proto", fileDescriptor_31571edce0094a5d) }
|
||||
|
||||
var fileDescriptor_31571edce0094a5d = []byte{
|
||||
// 130 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xca, 0x2f, 0x4a, 0x4c,
|
||||
0xce, 0x49, 0xd5, 0x2f, 0x33, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2,
|
||||
0x84, 0x88, 0xe9, 0x95, 0x19, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x45, 0xf5, 0x41, 0x2c,
|
||||
0x88, 0x02, 0x27, 0xfb, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e,
|
||||
0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x52, 0x4d,
|
||||
0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0xcf, 0xcf, 0x2b, 0xce, 0xcf, 0x2b,
|
||||
0xd2, 0xcf, 0x28, 0x4f, 0xac, 0xd4, 0xaf, 0xd0, 0x87, 0xda, 0x53, 0x52, 0x59, 0x90, 0x5a, 0x9c,
|
||||
0xc4, 0x06, 0x36, 0xc7, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x39, 0x40, 0x7c, 0x7a, 0x7e, 0x00,
|
||||
0x00, 0x00,
|
||||
}
|
||||
Reference in New Issue
Block a user