Skip to content

Commit

Permalink
add default user for old endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
zkokelj committed Nov 24, 2023
1 parent 378aec6 commit 79e7e90
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tools/walletextension/container/walletextension_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"net/http"
"os"

"github.com/ethereum/go-ethereum/crypto"

"github.com/ten-protocol/go-ten/go/common/log"
"github.com/ten-protocol/go-ten/go/common/stopcontrol"
"github.com/ten-protocol/go-ten/go/rpc"
Expand Down Expand Up @@ -51,6 +53,16 @@ func NewWalletExtensionContainerFromConfig(config config.Config, logger gethlog.
// add default user (when no UserID is provided in the query parameter - for WE endpoints)
userAccountManager.AddAndReturnAccountManager(hex.EncodeToString([]byte(wecommon.DefaultUser)))

// add default user to the database (temporary fix before removing wallet extension endpoints)
accountPrivateKey, err := crypto.GenerateKey()
if err != nil {
logger.Error("Unable to generate hey pair for default user", log.ErrKey, err)
}
err = databaseStorage.AddUser([]byte(wecommon.DefaultUser), crypto.FromECDSA(accountPrivateKey))
if err != nil {
logger.Error("Unable to save default user to the database", log.ErrKey, err)
}

// get all users and their private keys from the database
allUsers, err := databaseStorage.GetAllUsers()
if err != nil {
Expand Down

0 comments on commit 79e7e90

Please sign in to comment.