feat: `GetAccountsByKeyUID` endpoint added
This commit is contained in:
parent
c8ef2c1a7f
commit
392d808af0
|
@ -48,12 +48,7 @@ func (api *API) SaveAccount(ctx context.Context, account *accounts.Account) erro
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api *API) GetAccounts(ctx context.Context) ([]*accounts.Account, error) {
|
func (api *API) checkDerivedFromField(accounts []*accounts.Account) ([]*accounts.Account, error) {
|
||||||
accounts, err := api.db.GetAccounts()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
for i := range accounts {
|
for i := range accounts {
|
||||||
account := accounts[i]
|
account := accounts[i]
|
||||||
if account.Wallet && account.DerivedFrom == "" {
|
if account.Wallet && account.DerivedFrom == "" {
|
||||||
|
@ -64,10 +59,27 @@ func (api *API) GetAccounts(ctx context.Context) ([]*accounts.Account, error) {
|
||||||
account.DerivedFrom = address.Hex()
|
account.DerivedFrom = address.Hex()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return accounts, nil
|
return accounts, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (api *API) GetAccounts(ctx context.Context) ([]*accounts.Account, error) {
|
||||||
|
accounts, err := api.db.GetAccounts()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return api.checkDerivedFromField(accounts)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (api *API) GetAccountsByKeyUID(ctx context.Context, keyUID string) ([]*accounts.Account, error) {
|
||||||
|
accounts, err := api.db.GetAccountsByKeyUID(keyUID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return api.checkDerivedFromField(accounts)
|
||||||
|
}
|
||||||
|
|
||||||
func (api *API) DeleteAccount(ctx context.Context, address types.Address, password string) error {
|
func (api *API) DeleteAccount(ctx context.Context, address types.Address, password string) error {
|
||||||
acc, err := api.db.GetAccountByAddress(address)
|
acc, err := api.db.GetAccountByAddress(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue