Skip to content

Commit

Permalink
Consistent TokenType passing
Browse files Browse the repository at this point in the history
  • Loading branch information
latenssi committed Aug 17, 2021
1 parent 07a645a commit f5185ba
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion handlers/tokens_func.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (s *Tokens) MakeAccountTokensFunc(tType templates.TokenType) http.HandlerFu
vars := mux.Vars(r)
a := vars["address"]

res, err := s.service.AccountTokens(a, &tType)
res, err := s.service.AccountTokens(a, tType)
if err != nil {
handleError(rw, s.log, err)
return
Expand Down
2 changes: 1 addition & 1 deletion tokens/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (s *Service) Setup(ctx context.Context, sync bool, tokenName, address strin
return job, tx, err
}

func (s *Service) AccountTokens(address string, tType *templates.TokenType) ([]AccountToken, error) {
func (s *Service) AccountTokens(address string, tType templates.TokenType) ([]AccountToken, error) {
// Check if the input is a valid address
address, err := flow_helpers.ValidateAddress(address, s.cfg.ChainID)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion tokens/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "github.com/flow-hydraulics/flow-wallet-api/templates"
// Store manages data regarding tokens.
type Store interface {
// List an accounts enabled tokens
AccountTokens(address string, tokenType *templates.TokenType) ([]AccountToken, error)
AccountTokens(address string, tokenType templates.TokenType) ([]AccountToken, error)

// Enable a token for an account
InsertAccountToken(at *AccountToken) error
Expand Down
6 changes: 3 additions & 3 deletions tokens/store_gorm.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ func NewGormStore(db *gorm.DB) *GormStore {
return &GormStore{db}
}

func (s *GormStore) AccountTokens(address string, tokenType *templates.TokenType) (att []AccountToken, err error) {
func (s *GormStore) AccountTokens(address string, tokenType templates.TokenType) (att []AccountToken, err error) {
q := s.db
if tokenType != nil {
if tokenType != templates.NotSpecified {
// Filter by type
q = q.Where(&AccountToken{AccountAddress: address, TokenType: *tokenType})
q = q.Where(&AccountToken{AccountAddress: address, TokenType: tokenType})
} else {
// Find all
q = q.Where(&AccountToken{AccountAddress: address})
Expand Down

0 comments on commit f5185ba

Please sign in to comment.