Skip to content

Commit

Permalink
linter
Browse files Browse the repository at this point in the history
  • Loading branch information
volodymyr-basiuk committed Dec 6, 2024
1 parent 8795037 commit 4370c3b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pkg/document/did.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const (

DefaultDidDocContext = "https://www.w3.org/ns/did/v1"

BlockchainAccountIdContext = "https://w3id.org/security#blockchainAccountId"
BlockchainAccountIDContext = "https://w3id.org/security#blockchainAccountId"
EcdsaSecp256k1RecoveryMethod2020Context = "https://identity.foundation/EcdsaSecp256k1RecoverySignature2020#EcdsaSecp256k1RecoveryMethod2020"
TezosMethod2021Context = "https://w3id.org/security#TezosMethod2021"
)
Expand Down
26 changes: 13 additions & 13 deletions pkg/services/pkh/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ func (r *Resolver) Resolve(
didString := did.String()
parts := strings.Split(didString, ":")
namespace := parts[2]
vmId := didString + "#blockchainAccountId"
vmID := didString + "#blockchainAccountId"

didResolution := document.NewDidResolution()
authentication := verifiable.Authentication{}
authentication.ID = vmId
authentication.ID = vmID
authentication.Type = document.EcdsaSecp256k1RecoveryMethod2020Type
authentication.Controller = didString
blockchainAccountID, err := getBlockchainAccountID(didString)
Expand All @@ -49,20 +49,20 @@ func (r *Resolver) Resolve(
Context: []interface{}{
document.DefaultDidDocContext,
map[string]string{
"blockchainAccountId": document.BlockchainAccountIdContext,
"blockchainAccountId": document.BlockchainAccountIDContext,
document.EcdsaSecp256k1RecoveryMethod2020Type: document.EcdsaSecp256k1RecoveryMethod2020Context,
},
},
ID: didString,
VerificationMethod: []verifiable.CommonVerificationMethod{},
Authentication: []verifiable.Authentication{authentication},
AssertionMethod: []interface{}{vmId},
AssertionMethod: []interface{}{vmID},
}

didResolution.DidDocument.VerificationMethod = append(
didResolution.DidDocument.VerificationMethod,
verifiable.CommonVerificationMethod{
ID: vmId,
ID: vmID,
Type: document.EcdsaSecp256k1RecoveryMethod2020Type,
Controller: didString,
BlockchainAccountID: blockchainAccountID,
Expand All @@ -77,28 +77,28 @@ func (r *Resolver) Resolve(
didResolution.DidDocument.Context = []interface{}{
document.DefaultDidDocContext,
map[string]string{
"blockchainAccountId": document.BlockchainAccountIdContext,
"blockchainAccountId": document.BlockchainAccountIDContext,
document.EcdsaSecp256k1RecoveryMethod2020Type: document.EcdsaSecp256k1RecoveryMethod2020Context,
document.TezosMethod2021Type: document.TezosMethod2021Context,
},
}

tzId := fmt.Sprintf("%s#%s", didString, document.TezosMethod2021Type)
tzID := fmt.Sprintf("%s#%s", didString, document.TezosMethod2021Type)
didResolution.DidDocument.VerificationMethod = append(
didResolution.DidDocument.VerificationMethod,
verifiable.CommonVerificationMethod{
ID: tzId,
ID: tzID,
Type: document.TezosMethod2021Type,
Controller: didString,
BlockchainAccountID: blockchainAccountID,
},
)
tzAuthentication := verifiable.Authentication{}
tzAuthentication.ID = tzId
tzAuthentication.ID = tzID
tzAuthentication.Type = document.TezosMethod2021Type
tzAuthentication.Controller = didString
didResolution.DidDocument.Authentication = append(didResolution.DidDocument.Authentication, tzAuthentication)
didResolution.DidDocument.AssertionMethod = append(didResolution.DidDocument.AssertionMethod, tzId)
didResolution.DidDocument.AssertionMethod = append(didResolution.DidDocument.AssertionMethod, tzID)
default:
return nil, fmt.Errorf("chain namespace not supported: %s", namespace)
}
Expand All @@ -110,9 +110,9 @@ func getBlockchainAccountID(did string) (string, error) {
if !strings.HasPrefix(did, prefix) {
return "", errors.New("invalid DID format: must start with 'did:pkh:'")
}
blockchainAccountId := strings.TrimPrefix(did, prefix)
if blockchainAccountId == "" {
blockchainAccountID := strings.TrimPrefix(did, prefix)
if blockchainAccountID == "" {
return "", errors.New("invalid DID format: missing blockchainAccountId")
}
return blockchainAccountId, nil
return blockchainAccountID, nil
}

0 comments on commit 4370c3b

Please sign in to comment.