add: (feat) balances query api

- add address utils
- return uint64 for balances instead of float
This commit is contained in:
2022-05-19 09:52:34 +03:00
parent 7d431f1c8f
commit f0690d62be
11 changed files with 170 additions and 98 deletions

View File

@@ -2,34 +2,36 @@ package syncer
import (
"context"
"math/big"
"strconv"
"github.com/georgysavva/scany/pgxscan"
"github.com/hibiken/asynq"
"github.com/jackc/pgx/v4"
"github.com/lmittmann/w3"
"github.com/rs/zerolog/log"
"math/big"
"strconv"
)
type tokenCursor struct {
cursorPos string `db:"cursor_pos"`
CursorPos string `db:"cursor_pos"`
}
func (s *Syncer) TokenSyncer(ctx context.Context, t *asynq.Task) error {
var lastCursor tokenCursor
if err := pgxscan.Get(ctx, s.db, &lastCursor, s.queries["cursor-pos"], 3); err != nil {
log.Err(err).Msg("pgxscan: token syncer task failed")
return err
}
latestChainIdx, err := s.cicnetClient.EntryCount(ctx)
if err != nil {
log.Err(err).Msg("token syncer task failed")
log.Err(err).Msg("cicnet: token syncer task failed")
return err
}
lastCursorPos, err := strconv.ParseInt(lastCursor.cursorPos, 10, 64)
lastCursorPos, err := strconv.ParseInt(lastCursor.CursorPos, 10, 64)
if err != nil {
log.Err(err).Msg("token syncer task failed")
log.Err(err).Msg("parse: token syncer task failed")
return err
}