status-go/services/connector/commands/revoke_permissions.go
Mikhail Rogachev d5a78e784a
feat_: connector revoke permissions and accounts (#5646)
* feat(connector)_: add `wallet_revokePermissions` endpoint

* feat_: same behavior for `eth_accounts` and `eth_requestAccounts`
2024-08-06 12:28:55 -07:00

42 lines
779 B
Go

package commands
import (
"database/sql"
persistence "github.com/status-im/status-go/services/connector/database"
"github.com/status-im/status-go/signal"
)
type RevokePermissionsCommand struct {
Db *sql.DB
}
func (c *RevokePermissionsCommand) Execute(request RPCRequest) (interface{}, error) {
err := request.Validate()
if err != nil {
return "", err
}
dApp, err := persistence.SelectDAppByUrl(c.Db, request.URL)
if err != nil {
return "", err
}
if dApp == nil {
return "", ErrDAppIsNotPermittedByUser
}
err = persistence.DeleteDApp(c.Db, dApp.URL)
if err != nil {
return "", err
}
signal.SendConnectorDAppPermissionRevoked(signal.ConnectorDApp{
URL: request.URL,
Name: request.Name,
IconURL: request.IconURL,
})
return nil, nil
}