2019-07-21 05:41:30 +00:00
|
|
|
package permissions
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
)
|
|
|
|
|
2019-07-25 05:35:09 +00:00
|
|
|
func NewAPI(db *Database) *API {
|
|
|
|
return &API{db}
|
2019-07-21 05:41:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// API is class with methods available over RPC.
|
|
|
|
type API struct {
|
2019-07-25 05:35:09 +00:00
|
|
|
db *Database
|
2019-07-21 05:41:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (api *API) AddDappPermissions(ctx context.Context, perms DappPermissions) error {
|
2019-07-25 05:35:09 +00:00
|
|
|
return api.db.AddPermissions(perms)
|
2019-07-21 05:41:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (api *API) GetDappPermissions(ctx context.Context) ([]DappPermissions, error) {
|
2019-07-25 05:35:09 +00:00
|
|
|
return api.db.GetPermissions()
|
2019-07-21 05:41:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (api *API) DeleteDappPermissions(ctx context.Context, name string) error {
|
2022-03-14 12:38:12 +00:00
|
|
|
return api.db.DeletePermission(name, "")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (api *API) DeleteDappPermissionsByNameAndAddress(ctx context.Context, name string, address string) error {
|
|
|
|
return api.db.DeletePermission(name, address)
|
2019-07-21 05:41:30 +00:00
|
|
|
}
|