2023-03-08 07:49:09 +01:00
|
|
|
package store
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
)
|
|
|
|
|
2023-04-11 12:14:49 +02:00
|
|
|
func (s *PgStore) ActivateAccount(
|
|
|
|
ctx context.Context,
|
|
|
|
publicAddress string,
|
|
|
|
) error {
|
|
|
|
if _, err := s.db.Exec(
|
|
|
|
ctx,
|
|
|
|
s.queries.ActivateAccount,
|
|
|
|
publicAddress,
|
|
|
|
); err != nil {
|
|
|
|
return err
|
2023-03-08 07:49:09 +01:00
|
|
|
}
|
|
|
|
|
2023-04-11 12:14:49 +02:00
|
|
|
return nil
|
2023-03-08 07:49:09 +01:00
|
|
|
}
|
|
|
|
|
2023-04-11 12:14:49 +02:00
|
|
|
func (s *PgStore) GetAccountStatus(
|
|
|
|
ctx context.Context,
|
|
|
|
publicAddress string,
|
2023-05-16 14:20:01 +02:00
|
|
|
) (bool, bool, error) {
|
2023-03-08 07:49:09 +01:00
|
|
|
var (
|
2023-04-11 12:14:49 +02:00
|
|
|
accountActive bool
|
2023-05-16 14:20:01 +02:00
|
|
|
gasLock bool
|
2023-03-08 07:49:09 +01:00
|
|
|
)
|
|
|
|
|
2023-04-11 12:14:49 +02:00
|
|
|
if err := s.db.QueryRow(
|
2023-03-08 07:49:09 +01:00
|
|
|
ctx,
|
2023-04-11 12:14:49 +02:00
|
|
|
s.queries.GetAccountStatus,
|
2023-03-08 07:49:09 +01:00
|
|
|
publicAddress,
|
2023-04-11 12:14:49 +02:00
|
|
|
).Scan(
|
|
|
|
&accountActive,
|
2023-05-16 14:20:01 +02:00
|
|
|
&gasLock,
|
2023-03-08 07:49:09 +01:00
|
|
|
); err != nil {
|
2023-05-16 14:20:01 +02:00
|
|
|
return false, false, err
|
2023-03-08 07:49:09 +01:00
|
|
|
}
|
|
|
|
|
2023-05-16 14:20:01 +02:00
|
|
|
return accountActive, gasLock, nil
|
2023-03-08 07:49:09 +01:00
|
|
|
}
|
|
|
|
|
2023-05-16 14:20:01 +02:00
|
|
|
func (s *PgStore) GasLock(
|
2023-04-11 12:14:49 +02:00
|
|
|
ctx context.Context,
|
|
|
|
publicAddress string,
|
|
|
|
) error {
|
2023-03-08 07:49:09 +01:00
|
|
|
if _, err := s.db.Exec(
|
|
|
|
ctx,
|
2023-05-16 14:20:01 +02:00
|
|
|
s.queries.GasLock,
|
2023-03-08 07:49:09 +01:00
|
|
|
publicAddress,
|
|
|
|
); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-05-16 14:20:01 +02:00
|
|
|
func (s *PgStore) GasUnlock(
|
2023-04-11 12:14:49 +02:00
|
|
|
ctx context.Context,
|
|
|
|
publicAddress string,
|
|
|
|
) error {
|
2023-03-08 07:49:09 +01:00
|
|
|
if _, err := s.db.Exec(
|
|
|
|
ctx,
|
2023-05-16 14:20:01 +02:00
|
|
|
s.queries.GasUnlock,
|
2023-03-08 07:49:09 +01:00
|
|
|
publicAddress,
|
|
|
|
); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|