Skip to content

Commit

Permalink
keep prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Jun 3, 2024
1 parent 1bcc36f commit 3cf11a2
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions x/e2ee/keyring/keyring.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package keyring

import (
"fmt"
"io"
"path/filepath"
"reflect"

Check notice

Code scanning / CodeQL

Sensitive package import Note

Certain system packages contain functions which may be a possible source of non-determinism
"unsafe"

Check notice

Code scanning / CodeQL

Sensitive package import Note

Certain system packages contain functions which may be a possible source of non-determinism

"github.com/99designs/keyring"

sdkkeyring "github.com/cosmos/cosmos-sdk/crypto/keyring"
)

const keyringDirPrefix = "e2ee-keyring-%s"

type Keyring interface {
Get(string) ([]byte, error)
Set(string, []byte) error
Expand All @@ -26,6 +32,20 @@ func New(
return nil, err

Check warning on line 32 in x/e2ee/keyring/keyring.go

View check run for this annotation

Codecov / codecov/patch

x/e2ee/keyring/keyring.go#L32

Added line #L32 was not covered by tests
}
db = kr.DB()
switch backend {
case sdkkeyring.BackendTest, sdkkeyring.BackendFile:
fileDir := filepath.Join(rootDir, fmt.Sprintf(keyringDirPrefix, backend))
el := reflect.ValueOf(db).Elem()
if f := el.FieldByName("dir"); f.IsValid() {
reflect.NewAt(f.Type(), unsafe.Pointer(f.UnsafeAddr())).Elem().SetString(fileDir)
}
case sdkkeyring.BackendPass:
prefix := fmt.Sprintf(keyringDirPrefix, serviceName)
el := reflect.ValueOf(db).Elem()
if f := el.FieldByName("prefix"); f.IsValid() {
reflect.NewAt(f.Type(), unsafe.Pointer(f.UnsafeAddr())).Elem().SetString(prefix)

Check warning on line 46 in x/e2ee/keyring/keyring.go

View check run for this annotation

Codecov / codecov/patch

x/e2ee/keyring/keyring.go#L42-L46

Added lines #L42 - L46 were not covered by tests
}
}
}
return newKeystore(db, backend), nil
}
Expand Down

0 comments on commit 3cf11a2

Please sign in to comment.