Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
zkokelj committed Mar 5, 2024
1 parent d9bc42e commit 371719d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
5 changes: 5 additions & 0 deletions tools/walletextension/api/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ func ethRequestHandler(walletExt *walletextension.WalletExtension, conn userconn
hexUserID = hex.EncodeToString([]byte(common.DefaultUser)) // todo (@ziga) - this can be removed once old WE endpoints are removed
}

if len(hexUserID) < 3 {
handleError(conn, walletExt.Logger(), fmt.Errorf("encryption token length is incorrect"))
return
}

// todo (@pedro) remove this conn dependency
response, err := walletExt.ProxyEthRequest(request, conn, hexUserID)
if err != nil {
Expand Down
9 changes: 7 additions & 2 deletions tools/walletextension/storage/database/mariadb/mariadb.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"database/sql"
"encoding/hex"
"fmt"
"github.com/ethereum/go-ethereum/crypto"
"path/filepath"
"runtime"

"github.com/ethereum/go-ethereum/crypto"

_ "github.com/go-sql-driver/mysql" // Importing MariaDB driver
"github.com/ten-protocol/go-ten/go/common/errutil"
"github.com/ten-protocol/go-ten/tools/walletextension/common"
Expand Down Expand Up @@ -153,9 +154,13 @@ func (m *MariaDB) StoreTransaction(rawTx string, userID []byte) error {
defer stmt.Close()

// Calculate tx hash
if len(rawTx) < 3 {
fmt.Println("Invalid rawTx: ", rawTx)
return nil
}
rawTxBytes, err := hex.DecodeString(rawTx[2:])
if err != nil {
panic(err)
fmt.Println("Error decoding rawTx: ", rawTx)
}
txHash := crypto.Keccak256Hash(rawTxBytes)

Expand Down
9 changes: 7 additions & 2 deletions tools/walletextension/storage/database/sqlite/sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"database/sql"
"encoding/hex"
"fmt"
"github.com/ethereum/go-ethereum/crypto"
"os"
"path/filepath"

"github.com/ethereum/go-ethereum/crypto"

_ "github.com/mattn/go-sqlite3" // sqlite driver for sql.Open()
obscurocommon "github.com/ten-protocol/go-ten/go/common"
"github.com/ten-protocol/go-ten/go/common/errutil"
Expand Down Expand Up @@ -211,9 +212,13 @@ func (s *Database) StoreTransaction(rawTx string, userID []byte) error {
defer stmt.Close()

// Calculate tx hash
if len(rawTx) < 3 {
fmt.Println("Invalid rawTx: ", rawTx)
return nil
}
rawTxBytes, err := hex.DecodeString(rawTx[2:])
if err != nil {
panic(err)
fmt.Println("Error decoding rawTx: ", rawTx)
}
txHash := crypto.Keccak256Hash(rawTxBytes)

Expand Down

0 comments on commit 371719d

Please sign in to comment.