-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add default user for old endpoints #1665
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -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" | ||||||||||||||
|
@@ -51,6 +53,17 @@ 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 key pair for default user", log.ErrKey, err) | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The use of |
||||||||||||||
} | ||||||||||||||
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) | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The error from - logger.Error("Unable to save default user to the database", log.ErrKey, err)
+ return fmt.Errorf("unable to save default user to the database: %w", err) Commitable suggestion
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @zkokelj Great, if the fix has been applied as suggested, it should now properly handle the error when saving the default user to the database. If there's anything else that needs attention, feel free to let me know!
|
||||||||||||||
os.Exit(1) | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
// get all users and their private keys from the database | ||||||||||||||
allUsers, err := databaseStorage.GetAllUsers() | ||||||||||||||
if err != nil { | ||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for all these error handlings in the constructor, I think the gateway should panic.
There is no point continuing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed