Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouop0 committed Jan 7, 2025
1 parent 53cf9fd commit f4264fa
Show file tree
Hide file tree
Showing 15 changed files with 37 additions and 25 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.23.4
require (
github.com/caarlos0/env/v6 v6.10.1
github.com/ethereum/go-ethereum v1.14.12
github.com/gin-gonic/gin v1.10.0
github.com/go-gormigrate/gormigrate/v2 v2.1.3
github.com/pkg/errors v0.9.1
github.com/spf13/cast v1.7.1
Expand All @@ -31,7 +32,6 @@ require (
github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/gin-gonic/gin v1.10.0 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
Expand Down
10 changes: 6 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ github.com/go-gormigrate/gormigrate/v2 v2.1.3/go.mod h1:VJ9FIOBAur+NmQ8c4tDVwOui
github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
Expand All @@ -97,6 +99,8 @@ github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
Expand Down Expand Up @@ -219,8 +223,6 @@ go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc=
golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ=
Expand All @@ -237,15 +239,15 @@ golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
Expand Down
3 changes: 2 additions & 1 deletion handler/latestBlockNumber.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package handler

import (
"context"
"time"

"github.com/optimism-java/interopbackend/internal/schema"
"github.com/optimism-java/interopbackend/internal/svc"
"github.com/optimism-java/interopbackend/pkg/log"
"time"

"github.com/pkg/errors"
"github.com/spf13/cast"
Expand Down
5 changes: 3 additions & 2 deletions handler/logFilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package handler

import (
"context"
"math/big"
"strings"

"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
Expand All @@ -11,8 +14,6 @@ import (
"github.com/optimism-java/interopbackend/pkg/event"
"github.com/optimism-java/interopbackend/pkg/log"
"github.com/pkg/errors"
"math/big"
"strings"
)

func LogBatchFilter(ctx *svc.ServiceContext, startBlock, endBlock int64, addresses []common.Address, topics [][]common.Hash) ([]*schema.SyncEvent, error) {
Expand Down
5 changes: 3 additions & 2 deletions handler/syncBlock.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package handler

import (
"fmt"
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/optimism-java/interopbackend/internal/schema"
"github.com/optimism-java/interopbackend/internal/svc"
"github.com/optimism-java/interopbackend/pkg/log"
"github.com/optimism-java/interopbackend/pkg/rpc"
"github.com/pkg/errors"
"gorm.io/gorm"
"time"
)

func SyncBlock(ctx *svc.ServiceContext) {
Expand Down Expand Up @@ -37,7 +38,7 @@ func SyncBlock(ctx *svc.ServiceContext) {
continue
}

//block, err := ctx.L2RPC.BlockByNumber(context.Background(), big.NewInt(syncingBlockNumber))
// block, err := ctx.L2RPC.BlockByNumber(context.Background(), big.NewInt(syncingBlockNumber))
blockJSON, err := rpc.HTTPPostJSON("", ctx.Config.L2RPCUrl, "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBlockByNumber\",\"params\":[\""+fmt.Sprintf("0x%X", syncingBlockNumber)+"\", true],\"id\":1}")
if err != nil {
log.Errorf("[Handler.SyncBlock] Syncing block by number error: %s\n", errors.WithStack(err))
Expand Down
5 changes: 3 additions & 2 deletions handler/syncEvent.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package handler

import (
"sync"
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/optimism-java/interopbackend/internal/blockchain"
"github.com/optimism-java/interopbackend/internal/schema"
"github.com/optimism-java/interopbackend/internal/svc"
"github.com/optimism-java/interopbackend/pkg/log"
"github.com/pkg/errors"
"gorm.io/gorm"
"sync"
"time"
)

func SyncEvent(ctx *svc.ServiceContext) {
Expand Down
5 changes: 3 additions & 2 deletions internal/api/api.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package api

import (
"net/http"
"strconv"

"github.com/gin-gonic/gin"
"github.com/optimism-java/interopbackend/internal/schema"
config "github.com/optimism-java/interopbackend/internal/types"
"gorm.io/gorm"
"net/http"
"strconv"
)

type Api struct {

Check failure on line 13 in internal/api/api.go

View workflow job for this annotation

GitHub Actions / Run golangci-lint

var-naming: type Api should be API (revive)
Expand Down
1 change: 0 additions & 1 deletion internal/blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ func init() {
cfg := config.GetConfig()
AddContract(cfg.L2toL2CrossDomainMessenger)
AddContract(cfg.CrossL2Inbox)

}

func Register(event Event) {
Expand Down
10 changes: 5 additions & 5 deletions internal/blockchain/blockchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package blockchain
import (
"encoding/hex"
"fmt"
"math/big"
"testing"

"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/optimism-java/interopbackend/pkg/event"
"math/big"
"testing"
)

func TestRemoveContract(t *testing.T) {
Expand All @@ -21,7 +22,6 @@ func TestRemoveContract(t *testing.T) {
RemoveContract("BB")
RemoveContract("CC")
fmt.Println(GetContracts())

}

// 382409ac69001e11931a28435afef442cbfd20d9891907e8fa373ba7d351f320
Expand All @@ -37,7 +37,7 @@ func TestRemoveContract(t *testing.T) {
func TestHashL2toL2CrossDomainMessage(t *testing.T) {
logs := "382409ac69001e11931a28435afef442cbfd20d9891907e8fa373ba7d351f3200000000000000000000000000000000000000000000000000000000000000386000000000000000000000000420000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000000000000000000000000000004200000000000000000000000000000000000028000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000847cfd6dbc000000000000000000000000420beef000000000000000000000000000000001000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb9226600000000000000000000000000000000000000000000000000000000000003e800000000000000000000000000000000000000000000000000000000"
s := crypto.Keccak256(common.Hex2Bytes(logs))
//与ExecutingMessage事件的msgHash匹配
// 与ExecutingMessage事件的msgHash匹配
fmt.Println(hex.EncodeToString(s))

sendMessageEvent := &event.SendMessage{}
Expand Down Expand Up @@ -101,7 +101,7 @@ func TestHashCody(t *testing.T) {

packed, _ := arguments.Pack(destination, source, nonce, sender, target, message)
messageHash := crypto.Keccak256Hash(packed)
//与RelayedMessage事件的messageHash匹配
// 与RelayedMessage事件的messageHash匹配
fmt.Println(messageHash)
}

Expand Down
3 changes: 2 additions & 1 deletion internal/svc/svc.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package svc

import (
"context"
"github.com/optimism-java/interopbackend/internal/types"
"log"
"time"

"github.com/optimism-java/interopbackend/internal/types"

"gorm.io/driver/mysql"

"github.com/ethereum/go-ethereum/common"
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"

"github.com/gin-gonic/gin"
"github.com/optimism-java/interopbackend/handler"
"github.com/optimism-java/interopbackend/internal/api"
Expand Down
3 changes: 2 additions & 1 deletion migration/migrate/migration.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package migrate

import (
"log"

"github.com/go-gormigrate/gormigrate/v2"
version "github.com/optimism-java/interopbackend/migration"
v0 "github.com/optimism-java/interopbackend/migration/version/v0"
"log"

"gorm.io/gorm"
)
Expand Down
3 changes: 2 additions & 1 deletion pkg/event/ExecutingMessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package event

import (
"encoding/json"
"math/big"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"math/big"
)

var (
Expand Down
3 changes: 2 additions & 1 deletion pkg/event/RelayedMessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package event

import (
"encoding/json"
"math/big"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"math/big"
)

var (
Expand Down
3 changes: 2 additions & 1 deletion pkg/event/SendMessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package event

import (
"encoding/json"
"math/big"

"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"math/big"
)

var (
Expand Down

0 comments on commit f4264fa

Please sign in to comment.