signer/core: solving the problem of unused variables

This commit is contained in:
Monkey 2024-06-11 11:05:20 +08:00
parent 2eb185c92b
commit 74d17abd01

View file

@ -55,6 +55,9 @@ func NewUIServerAPI(extapi *SignerAPI) *UIServerAPI {
func (s *UIServerAPI) ListAccounts(ctx context.Context) ([]accounts.Account, error) { func (s *UIServerAPI) ListAccounts(ctx context.Context) ([]accounts.Account, error) {
var accs []accounts.Account var accs []accounts.Account
for _, wallet := range s.am.Wallets() { for _, wallet := range s.am.Wallets() {
if err := ctx.Err(); err != nil {
return accs, err
}
accs = append(accs, wallet.Accounts()...) accs = append(accs, wallet.Accounts()...)
} }
return accs, nil return accs, nil
@ -127,7 +130,7 @@ func (s *UIServerAPI) ImportRawKey(privkey string, password string) (accounts.Ac
if err != nil { if err != nil {
return accounts.Account{}, err return accounts.Account{}, err
} }
if err := ValidatePasswordFormat(password); err != nil { if err = ValidatePasswordFormat(password); err != nil {
return accounts.Account{}, fmt.Errorf("password requirements not met: %v", err) return accounts.Account{}, fmt.Errorf("password requirements not met: %v", err)
} }
// No error // No error
@ -170,7 +173,7 @@ func (s *UIServerAPI) SetChainId(id math.HexOrDecimal64) math.HexOrDecimal64 {
// Export returns encrypted private key associated with the given address in web3 keystore format. // Export returns encrypted private key associated with the given address in web3 keystore format.
// Example // Example
// {"jsonrpc":"2.0","method":"clef_export","params":["0x19e7e376e7c213b7e7e7e46cc70a5dd086daff2a"], "id":4} // {"jsonrpc":"2.0","method":"clef_export","params":["0x19e7e376e7c213b7e7e7e46cc70a5dd086daff2a"], "id":4}
func (s *UIServerAPI) Export(ctx context.Context, addr common.Address) (json.RawMessage, error) { func (s *UIServerAPI) Export(_ context.Context, addr common.Address) (json.RawMessage, error) {
// Look up the wallet containing the requested signer // Look up the wallet containing the requested signer
wallet, err := s.am.Find(accounts.Account{Address: addr}) wallet, err := s.am.Find(accounts.Account{Address: addr})
if err != nil { if err != nil {
@ -187,8 +190,8 @@ func (s *UIServerAPI) Export(ctx context.Context, addr common.Address) (json.Raw
// decryption it will encrypt the key with the given newPassphrase and store it in the keystore. // decryption it will encrypt the key with the given newPassphrase and store it in the keystore.
// Example (the address in question has privkey `11...11`): // Example (the address in question has privkey `11...11`):
// {"jsonrpc":"2.0","method":"clef_import","params":[{"address":"19e7e376e7c213b7e7e7e46cc70a5dd086daff2a","crypto":{"cipher":"aes-128-ctr","ciphertext":"33e4cd3756091d037862bb7295e9552424a391a6e003272180a455ca2a9fb332","cipherparams":{"iv":"b54b263e8f89c42bb219b6279fba5cce"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"e4ca94644fd30569c1b1afbbc851729953c92637b7fe4bb9840bbb31ffbc64a5"},"mac":"f4092a445c2b21c0ef34f17c9cd0d873702b2869ec5df4439a0c2505823217e7"},"id":"216c7eac-e8c1-49af-a215-fa0036f29141","version":3},"test","yaddayadda"], "id":4} // {"jsonrpc":"2.0","method":"clef_import","params":[{"address":"19e7e376e7c213b7e7e7e46cc70a5dd086daff2a","crypto":{"cipher":"aes-128-ctr","ciphertext":"33e4cd3756091d037862bb7295e9552424a391a6e003272180a455ca2a9fb332","cipherparams":{"iv":"b54b263e8f89c42bb219b6279fba5cce"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"e4ca94644fd30569c1b1afbbc851729953c92637b7fe4bb9840bbb31ffbc64a5"},"mac":"f4092a445c2b21c0ef34f17c9cd0d873702b2869ec5df4439a0c2505823217e7"},"id":"216c7eac-e8c1-49af-a215-fa0036f29141","version":3},"test","yaddayadda"], "id":4}
func (api *UIServerAPI) Import(ctx context.Context, keyJSON json.RawMessage, oldPassphrase, newPassphrase string) (accounts.Account, error) { func (s *UIServerAPI) Import(_ context.Context, keyJSON json.RawMessage, oldPassphrase, newPassphrase string) (accounts.Account, error) {
be := api.am.Backends(keystore.KeyStoreType) be := s.am.Backends(keystore.KeyStoreType)
if len(be) == 0 { if len(be) == 0 {
return accounts.Account{}, errors.New("password based accounts not supported") return accounts.Account{}, errors.New("password based accounts not supported")
@ -205,8 +208,8 @@ func (api *UIServerAPI) Import(ctx context.Context, keyJSON json.RawMessage, old
// This method is the same as New on the external API, the difference being that // This method is the same as New on the external API, the difference being that
// this implementation does not ask for confirmation, since it's initiated by // this implementation does not ask for confirmation, since it's initiated by
// the user // the user
func (api *UIServerAPI) New(ctx context.Context) (common.Address, error) { func (s *UIServerAPI) New(_ context.Context) (common.Address, error) {
return api.extApi.newAccount() return s.extApi.newAccount()
} }
// Other methods to be added, not yet implemented are: // Other methods to be added, not yet implemented are: