mirror of
https://github.com/grassrootseconomics/cic-custodial.git
synced 2024-11-10 01:06:46 +01:00
Mohamed Sohail
b9d3c219c8
NOTE: This needs the db to be nuked if you are running a test cluster * updated gas refilling logic to reflect EthFaucet contract * fully dependant on on-chain contract to refill and unlock gas * minor fixes to nonce bootstrapper Ideal Values: INITIAL GIFT = 0.015 THRESHOLD = 0.01 TIME = 12 * 60 * 60 # Sample for 30 txs EXTREME LOW = 0.00675 LOW GAS USAGE = 0.00694605 RISING = 0.0135 HIGH = 0.027
74 lines
1.0 KiB
Go
74 lines
1.0 KiB
Go
package store
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
func (s *PgStore) ActivateAccount(
|
|
ctx context.Context,
|
|
publicAddress string,
|
|
) error {
|
|
if _, err := s.db.Exec(
|
|
ctx,
|
|
s.queries.ActivateAccount,
|
|
publicAddress,
|
|
); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (s *PgStore) GetAccountStatus(
|
|
ctx context.Context,
|
|
publicAddress string,
|
|
) (bool, bool, error) {
|
|
var (
|
|
accountActive bool
|
|
gasLock bool
|
|
)
|
|
|
|
if err := s.db.QueryRow(
|
|
ctx,
|
|
s.queries.GetAccountStatus,
|
|
publicAddress,
|
|
).Scan(
|
|
&accountActive,
|
|
&gasLock,
|
|
); err != nil {
|
|
return false, false, err
|
|
}
|
|
|
|
return accountActive, gasLock, nil
|
|
}
|
|
|
|
func (s *PgStore) GasLock(
|
|
ctx context.Context,
|
|
publicAddress string,
|
|
) error {
|
|
if _, err := s.db.Exec(
|
|
ctx,
|
|
s.queries.GasLock,
|
|
publicAddress,
|
|
); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (s *PgStore) GasUnlock(
|
|
ctx context.Context,
|
|
publicAddress string,
|
|
) error {
|
|
if _, err := s.db.Exec(
|
|
ctx,
|
|
s.queries.GasUnlock,
|
|
publicAddress,
|
|
); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|