wormchain: Fix formatting and add to lint.sh

This commit is contained in:
Chirantan Ekbote 2022-09-02 17:56:09 +09:00 committed by Chirantan Ekbote
parent 7f4b0d1a09
commit d577b931a4
30 changed files with 81 additions and 55 deletions

View File

@ -43,7 +43,7 @@ format(){
fi
# Use -exec because of pitfall #1 in http://mywiki.wooledge.org/BashPitfalls
GOFMT_OUTPUT="$(find "./sdk" "./node" "./event_database" -type f -name '*.go' -not -path './node/pkg/proto/*' -print0 | xargs -r -0 goimports $GOIMPORTS_ARGS 2>&1)"
GOFMT_OUTPUT="$(find "./sdk" "./node" "./event_database" "./wormhole_chain" -type f -name '*.go' -not -path './node/pkg/proto/*' -print0 | xargs -r -0 goimports $GOIMPORTS_ARGS 2>&1)"
if [ -n "$GOFMT_OUTPUT" ]; then
if [ "$GITHUB_ACTION" == "true" ]; then
@ -107,7 +107,7 @@ done
shift $((OPTIND - 1))
if [ "$#" -ne "1" ]; then
echo "Need to specify COMMAND." >&2
echo "Need to specify COMMAND." >&2
print_help
exit 1
fi
@ -115,15 +115,15 @@ fi
COMMAND="$1"
if [[ ! " ${VALID_COMMANDS[*]} " == *" $COMMAND "* ]]; then
echo "Invalid command $COMMAND." >&2
echo "Invalid command $COMMAND." >&2
print_help
exit 1
fi
# run this script recursively inside docker, if requested
if [ "$DOCKER" == "true" ]; then
# The easy thing to do here would be to use a bind mount to share the code with the container.
# But this doesn't work in scenarios where we are in a container already.
# The easy thing to do here would be to use a bind mount to share the code with the container.
# But this doesn't work in scenarios where we are in a container already.
# But it's easy so we just won't support that case for now.
# If we wanted to support it, my idea would be to `docker run`, `docker cp`, `docker exec`, `docker rm`.

View File

@ -50,7 +50,8 @@ func (app *App) ExportAppStateAndValidators(
// prepare for fresh start at zero height
// NOTE zero height genesis is a temporary feature which will be deprecated
// in favour of export at a block height
//
// in favour of export at a block height
func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) {
applyAllowedAddrs := false

View File

@ -1,5 +1,7 @@
{
"height": "0",
"height": "7",
"round": 0,
"step": 0
"step": 3,
"signature": "t5IKJ4vt040h9AYTDotLzOIWPIcPyJGttV6F17UDKnZwgqAtQRZpI1KdihUiK/ETx/TuGcjQbRZfUY5RTky5Aw==",
"signbytes": "71080211070000000000000022480A207FCFF07D9D1F96B2D2BF33205CFDA6F5F23E4CE6EB8F083241B17702DCAB725D122408011220EEE1DC12493E08AF12B7EC70E55641D2E60FF2EAF14EFE1D57BF6BDCF870997A2A0B089289C7980610FDF6CA52320D776F726D686F6C65636861696E"
}

View File

@ -75,15 +75,14 @@ func IsWORMToken(tokenChain uint16, tokenAddress [32]byte) bool {
//
// For most tokens, this looks something like
//
// "wh/00001/165809739240a0ac03b98440fe8985548e3aa683cd0d4d9df5b5659669faa300"
// "wh/00001/165809739240a0ac03b98440fe8985548e3aa683cd0d4d9df5b5659669faa300"
//
// where the string "wh" is followed by the token chain (fixed 5 characters)
// in decimal, followed by the token address in hex (fixed 64 character).
//
// For the special case of the wormhole token it returns
//
// "uworm"
//
// "uworm"
func GetWrappedCoinIdentifier(tokenChain uint16, tokenAddress [32]byte) string {
if IsWORMToken(tokenChain, tokenAddress) {
return "uworm"

View File

@ -5,10 +5,11 @@ package types
import (
fmt "fmt"
proto "github.com/gogo/protobuf/proto"
io "io"
math "math"
math_bits "math/bits"
proto "github.com/gogo/protobuf/proto"
)
// Reference imports to suppress errors if they are not otherwise used.

View File

@ -5,10 +5,11 @@ package types
import (
fmt "fmt"
proto "github.com/gogo/protobuf/proto"
io "io"
math "math"
math_bits "math/bits"
proto "github.com/gogo/protobuf/proto"
)
// Reference imports to suppress errors if they are not otherwise used.

View File

@ -5,11 +5,12 @@ package types
import (
fmt "fmt"
_ "github.com/gogo/protobuf/gogoproto"
proto "github.com/gogo/protobuf/proto"
io "io"
math "math"
math_bits "math/bits"
_ "github.com/gogo/protobuf/gogoproto"
proto "github.com/gogo/protobuf/proto"
)
// Reference imports to suppress errors if they are not otherwise used.

View File

@ -5,10 +5,11 @@ package types
import (
fmt "fmt"
proto "github.com/gogo/protobuf/proto"
io "io"
math "math"
math_bits "math/bits"
proto "github.com/gogo/protobuf/proto"
)
// Reference imports to suppress errors if they are not otherwise used.

View File

@ -5,11 +5,12 @@ package types
import (
fmt "fmt"
_ "github.com/gogo/protobuf/gogoproto"
proto "github.com/gogo/protobuf/proto"
io "io"
math "math"
math_bits "math/bits"
_ "github.com/gogo/protobuf/gogoproto"
proto "github.com/gogo/protobuf/proto"
)
// Reference imports to suppress errors if they are not otherwise used.

View File

@ -6,6 +6,10 @@ package types
import (
context "context"
fmt "fmt"
io "io"
math "math"
math_bits "math/bits"
query "github.com/cosmos/cosmos-sdk/types/query"
_ "github.com/gogo/protobuf/gogoproto"
grpc1 "github.com/gogo/protobuf/grpc"
@ -14,9 +18,6 @@ import (
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
io "io"
math "math"
math_bits "math/bits"
)
// Reference imports to suppress errors if they are not otherwise used.

View File

@ -5,10 +5,11 @@ package types
import (
fmt "fmt"
proto "github.com/gogo/protobuf/proto"
io "io"
math "math"
math_bits "math/bits"
proto "github.com/gogo/protobuf/proto"
)
// Reference imports to suppress errors if they are not otherwise used.

View File

@ -6,6 +6,10 @@ package types
import (
context "context"
fmt "fmt"
io "io"
math "math"
math_bits "math/bits"
types "github.com/cosmos/cosmos-sdk/types"
_ "github.com/gogo/protobuf/gogoproto"
grpc1 "github.com/gogo/protobuf/grpc"
@ -13,9 +17,6 @@ import (
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
io "io"
math "math"
math_bits "math/bits"
)
// Reference imports to suppress errors if they are not otherwise used.

View File

@ -4,6 +4,7 @@ import (
"context"
"encoding/hex"
"github.com/certusone/wormhole-chain/x/wormhole/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"

View File

@ -2,6 +2,7 @@ package cli
import (
"encoding/hex"
"github.com/certusone/wormhole-chain/x/wormhole/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/tx"

View File

@ -28,9 +28,9 @@ func (k Keeper) UpdateGuardianSet(ctx sdk.Context, newGuardianSet types.Guardian
return types.ErrGuardianSetNotSequential
}
if newGuardianSet.ExpirationTime != 0 {
if newGuardianSet.ExpirationTime != 0 {
return types.ErrNewGuardianSetHasExpiry
}
}
// Create new set
_, err := k.AppendGuardianSet(ctx, newGuardianSet)

View File

@ -4,14 +4,15 @@ import (
"crypto/ecdsa"
"crypto/rand"
"fmt"
"testing"
"time"
keepertest "github.com/certusone/wormhole-chain/testutil/keeper"
"github.com/certusone/wormhole-chain/x/wormhole/keeper"
"github.com/certusone/wormhole-chain/x/wormhole/types"
"github.com/certusone/wormhole/node/pkg/vaa"
"github.com/ethereum/go-ethereum/crypto"
"github.com/stretchr/testify/assert"
"testing"
"time"
)
func TestCalculateQuorum(t *testing.T) {

View File

@ -5,11 +5,12 @@ package types
import (
fmt "fmt"
_ "github.com/gogo/protobuf/gogoproto"
proto "github.com/gogo/protobuf/proto"
io "io"
math "math"
math_bits "math/bits"
_ "github.com/gogo/protobuf/gogoproto"
proto "github.com/gogo/protobuf/proto"
)
// Reference imports to suppress errors if they are not otherwise used.

View File

@ -5,10 +5,11 @@ package types
import (
fmt "fmt"
proto "github.com/gogo/protobuf/proto"
io "io"
math "math"
math_bits "math/bits"
proto "github.com/gogo/protobuf/proto"
)
// Reference imports to suppress errors if they are not otherwise used.

View File

@ -5,10 +5,11 @@ package types
import (
fmt "fmt"
proto "github.com/gogo/protobuf/proto"
io "io"
math "math"
math_bits "math/bits"
proto "github.com/gogo/protobuf/proto"
)
// Reference imports to suppress errors if they are not otherwise used.

View File

@ -10,14 +10,14 @@ const DefaultIndex uint64 = 1
// DefaultGenesis returns the default Capability genesis state
func DefaultGenesis() *GenesisState {
return &GenesisState{
GuardianSetList: []GuardianSet{},
Config: nil,
ReplayProtectionList: []ReplayProtection{},
SequenceCounterList: []SequenceCounter{},
GuardianSetList: []GuardianSet{},
Config: nil,
ReplayProtectionList: []ReplayProtection{},
SequenceCounterList: []SequenceCounter{},
ConsensusGuardianSetIndex: &ConsensusGuardianSetIndex{
Index: 0,
},
GuardianValidatorList: []GuardianValidator{},
GuardianValidatorList: []GuardianValidator{},
// this line is used by starport scaffolding # genesis/types/default
}
}

View File

@ -5,11 +5,12 @@ package types
import (
fmt "fmt"
_ "github.com/gogo/protobuf/gogoproto"
proto "github.com/gogo/protobuf/proto"
io "io"
math "math"
math_bits "math/bits"
_ "github.com/gogo/protobuf/gogoproto"
proto "github.com/gogo/protobuf/proto"
)
// Reference imports to suppress errors if they are not otherwise used.

View File

@ -6,11 +6,12 @@ package types
import (
bytes "bytes"
fmt "fmt"
_ "github.com/gogo/protobuf/gogoproto"
proto "github.com/gogo/protobuf/proto"
io "io"
math "math"
math_bits "math/bits"
_ "github.com/gogo/protobuf/gogoproto"
proto "github.com/gogo/protobuf/proto"
)
// Reference imports to suppress errors if they are not otherwise used.

View File

@ -5,10 +5,11 @@ package types
import (
fmt "fmt"
proto "github.com/gogo/protobuf/proto"
io "io"
math "math"
math_bits "math/bits"
proto "github.com/gogo/protobuf/proto"
)
// Reference imports to suppress errors if they are not otherwise used.

View File

@ -6,11 +6,12 @@ package types
import (
bytes "bytes"
fmt "fmt"
_ "github.com/gogo/protobuf/gogoproto"
proto "github.com/gogo/protobuf/proto"
io "io"
math "math"
math_bits "math/bits"
_ "github.com/gogo/protobuf/gogoproto"
proto "github.com/gogo/protobuf/proto"
)
// Reference imports to suppress errors if they are not otherwise used.

View File

@ -3,10 +3,11 @@ package types
import (
"crypto/ecdsa"
"crypto/rand"
"testing"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/stretchr/testify/assert"
"testing"
)
func TestKeysAsAddresses(t *testing.T) {

View File

@ -5,10 +5,11 @@ package types
import (
fmt "fmt"
proto "github.com/gogo/protobuf/proto"
io "io"
math "math"
math_bits "math/bits"
proto "github.com/gogo/protobuf/proto"
)
// Reference imports to suppress errors if they are not otherwise used.

View File

@ -6,6 +6,10 @@ package types
import (
context "context"
fmt "fmt"
io "io"
math "math"
math_bits "math/bits"
query "github.com/cosmos/cosmos-sdk/types/query"
_ "github.com/gogo/protobuf/gogoproto"
grpc1 "github.com/gogo/protobuf/grpc"
@ -14,9 +18,6 @@ import (
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
io "io"
math "math"
math_bits "math/bits"
)
// Reference imports to suppress errors if they are not otherwise used.

View File

@ -5,10 +5,11 @@ package types
import (
fmt "fmt"
proto "github.com/gogo/protobuf/proto"
io "io"
math "math"
math_bits "math/bits"
proto "github.com/gogo/protobuf/proto"
)
// Reference imports to suppress errors if they are not otherwise used.

View File

@ -5,10 +5,11 @@ package types
import (
fmt "fmt"
proto "github.com/gogo/protobuf/proto"
io "io"
math "math"
math_bits "math/bits"
proto "github.com/gogo/protobuf/proto"
)
// Reference imports to suppress errors if they are not otherwise used.

View File

@ -6,14 +6,15 @@ package types
import (
context "context"
fmt "fmt"
io "io"
math "math"
math_bits "math/bits"
grpc1 "github.com/gogo/protobuf/grpc"
proto "github.com/gogo/protobuf/proto"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
io "io"
math "math"
math_bits "math/bits"
)
// Reference imports to suppress errors if they are not otherwise used.