This commit is contained in:
0g-wh 2024-09-25 15:31:20 +00:00
parent 0c02c27a9d
commit de22587a5b
51 changed files with 85 additions and 406 deletions

View File

@ -8,7 +8,7 @@ outpkg: "mocks"
filename: "Mock{{.InterfaceName}}.go" filename: "Mock{{.InterfaceName}}.go"
packages: packages:
github.com/kava-labs/kava/x/precisebank/types: github.com/0glabs/0g-chain/x/precisebank/types:
# package-specific config # package-specific config
config: config:
interfaces: interfaces:

View File

@ -20,7 +20,6 @@ import (
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
solomachine "github.com/cosmos/ibc-go/v7/modules/light-clients/06-solomachine" solomachine "github.com/cosmos/ibc-go/v7/modules/light-clients/06-solomachine"
ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
"github.com/ethereum/go-ethereum/precompile/modules"
evmtypes "github.com/evmos/ethermint/x/evm/types" evmtypes "github.com/evmos/ethermint/x/evm/types"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"

View File

@ -6,12 +6,12 @@ import (
"time" "time"
sdkmath "cosmossdk.io/math" sdkmath "cosmossdk.io/math"
"github.com/0glabs/0g-chain/app"
evmutiltypes "github.com/0glabs/0g-chain/x/evmutil/types"
precisebankkeeper "github.com/0glabs/0g-chain/x/precisebank/keeper"
precisebanktypes "github.com/0glabs/0g-chain/x/precisebank/types"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types" tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/app"
evmutiltypes "github.com/kava-labs/kava/x/evmutil/types"
precisebankkeeper "github.com/kava-labs/kava/x/precisebank/keeper"
precisebanktypes "github.com/kava-labs/kava/x/precisebank/types"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )

View File

@ -6,8 +6,8 @@ import (
"fmt" "fmt"
"net/url" "net/url"
"github.com/0glabs/0g-chain/app"
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
"github.com/kava-labs/kava/app"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/credentials" "google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/credentials/insecure"

View File

@ -28,8 +28,8 @@ import (
committeetypes "github.com/0glabs/0g-chain/x/committee/types" committeetypes "github.com/0glabs/0g-chain/x/committee/types"
evmutiltypes "github.com/0glabs/0g-chain/x/evmutil/types" evmutiltypes "github.com/0glabs/0g-chain/x/evmutil/types"
issuancetypes "github.com/0glabs/0g-chain/x/issuance/types" issuancetypes "github.com/0glabs/0g-chain/x/issuance/types"
precisebanktypes "github.com/0glabs/0g-chain/x/precisebank/types"
pricefeedtypes "github.com/0glabs/0g-chain/x/pricefeed/types" pricefeedtypes "github.com/0glabs/0g-chain/x/pricefeed/types"
precisebanktypes "github.com/kava-labs/kava/x/precisebank/types"
) )
// QueryClient is a wrapper with all Cosmos and Kava grpc query clients // QueryClient is a wrapper with all Cosmos and Kava grpc query clients

2
go.mod
View File

@ -244,7 +244,7 @@ replace (
github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2 github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2
// Tracking kava-labs/go-ethereum kava/release/v1.10 branch // Tracking kava-labs/go-ethereum kava/release/v1.10 branch
// TODO: Tag before release // TODO: Tag before release
github.com/ethereum/go-ethereum => github.com/Kava-Labs/go-ethereum v1.10.27-0.20240513233504-6e038346780b github.com/ethereum/go-ethereum => github.com/evmos/go-ethereum v1.10.26-evmos-rc2
// Use ethermint fork that respects min-gas-price with NoBaseFee true and london enabled, and includes eip712 support // Use ethermint fork that respects min-gas-price with NoBaseFee true and london enabled, and includes eip712 support
github.com/evmos/ethermint => github.com/0glabs/ethermint v0.21.0-0g.v3.1.0 github.com/evmos/ethermint => github.com/0glabs/ethermint v0.21.0-0g.v3.1.0
// See https://github.com/cosmos/cosmos-sdk/pull/10401, https://github.com/cosmos/cosmos-sdk/commit/0592ba6158cd0bf49d894be1cef4faeec59e8320 // See https://github.com/cosmos/cosmos-sdk/pull/10401, https://github.com/cosmos/cosmos-sdk/commit/0592ba6158cd0bf49d894be1cef4faeec59e8320

View File

@ -1,27 +0,0 @@
# Precompile
The `precompile` package defines stateful precompile contracts used for creating precompile contracts that enhance the EVM, enable interactions between cosmos state and EVM state, or are used soley for testing purposes.
This package is made of two subpackages:
- `contracts` - Defines stateful precompiles and their constructors.
- `registry` - Defines stateful precompile addresses and registers them with the global registry
defined at `github.com/kava-labs/go-ethereum/precompile/modules`.
This is architected to isolate the dependency on the global registry (`github.com/kava-labs/go-ethereum/precompile/modules` package) to as few places as possible, have one source of truth for address registration (see `./registry/registry.go`), and isolate registration testing to one package.
In order to use the precompile registry, it must be imported for it's init function to run and register the precompiles. For the kava app, this is done in the `app.go` file with the import `_ "github.com/kava-labs/kava/precompile/registry"`. This is done in the `app.go` since this is the main file used for app dependencies and so all modules using the app cause the registry to be loaded. This is important for any consumers of the app outside of the kava cmd, as well as test code using the app for integration and unit testing.
## Defining a new precompile
1) Add the expected 0x address to the expected list in `./registry/registry_test.go`.
2) Create a new sub-directory under `./contracts` with a `contract_test.go` and `contract.go` file.
3) Implement `NewContract` function with associated tests in contract and contract test files.
4) Add the contract registration to `./registry/registry.go`.
## Contracts
### Noop
This contract is used for testing purposes only and should not be used on public chains. The functions of this contract (once implemented), will be used to exercise and test the various aspects of the EVM such as gas usage, argument parsing, events, etc. The specific operations tested under this contract are still to be determined.

View File

@ -1,23 +0,0 @@
package noop
import (
"fmt"
"github.com/ethereum/go-ethereum/precompile/contract"
)
// NewContract returns a new noop stateful precompiled contract.
//
// This contract is used for testing purposes only and should not be used on public chains.
// The functions of this contract (once implemented), will be used to exercise and test the various aspects of
// the EVM such as gas usage, argument parsing, events, etc. The specific operations tested under this contract are
// still to be determined.
func NewContract() (contract.StatefulPrecompiledContract, error) {
precompile, err := contract.NewStatefulPrecompileContract([]*contract.StatefulPrecompileFunction{})
if err != nil {
return nil, fmt.Errorf("failed to instantiate noop precompile: %w", err)
}
return precompile, nil
}

View File

@ -1,18 +0,0 @@
package noop_test
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/kava-labs/kava/precompile/contracts/noop"
)
// TestContractConstructor ensures we have a valid constructor. This will fail
// if we attempt to define invalid or duplicate function selectors.
func TestContractConstructor(t *testing.T) {
precompile, err := noop.NewContract()
require.NoError(t, err, "expected precompile not error when created")
assert.NotNil(t, precompile, "expected precompile contract to be defined")
}

View File

@ -1,46 +0,0 @@
package registry
import (
"fmt"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/precompile/contract"
"github.com/ethereum/go-ethereum/precompile/modules"
"github.com/kava-labs/kava/precompile/contracts/noop"
)
const (
// NoopContractAddress the primary noop contract address for testing
NoopContractAddress = "0x9000000000000000000000000000000000000001"
// NoopContractAddress2 the secondary noop contract address for testing
NoopContractAddress2 = "0x9000000000000000000000000000000000000002"
)
// init registers stateful precompile contracts with the global precompile registry
// defined in kava-labs/go-ethereum/precompile/modules
func init() {
register(NoopContractAddress, noop.NewContract)
register(NoopContractAddress2, noop.NewContract)
}
// register accepts a 0x address string and a stateful precompile contract constructor, instantiates the
// precompile contract via the constructor, and registers it with the precompile module registry.
//
// This panics if the contract can not be created or the module can not be registered
func register(address string, newContract func() (contract.StatefulPrecompiledContract, error)) {
contract, err := newContract()
if err != nil {
panic(fmt.Errorf("error creating contract for address %s: %w", address, err))
}
module := modules.Module{
Address: common.HexToAddress(address),
Contract: contract,
}
err = modules.RegisterModule(module)
if err != nil {
panic(fmt.Errorf("error registering contract module for address %s: %w", address, err))
}
}

View File

@ -1,33 +0,0 @@
package registry_test
import (
"testing"
"github.com/ethereum/go-ethereum/precompile/modules"
"github.com/stretchr/testify/assert"
)
// TestRegisteredPrecompiles asserts precompiles are registered
//
// In addition, this serves as an integration test to
// 1. Ensure modules.RegisteredModules() is returning addresses in the correct ascending order
// 2. Ensure that that the address defined in the module is correct. Since we use common.HexToAddress and
// then back to 0x encoded string, we can be certain that the string defined in the module is the
// expected length, not missing 0's, etc.
func TestRegisteredPrecompilesAddresses(t *testing.T) {
// build list of 0x addresses that are registered
registeredModules := modules.RegisteredModules()
registeredPrecompiles := make([]string, 0, len(registeredModules))
for _, rp := range registeredModules {
registeredPrecompiles = append(registeredPrecompiles, rp.Address.String())
}
expectedPrecompiles := []string{
// 0x9 address space used for e2e & integration tests
"0x9000000000000000000000000000000000000001", // noop
"0x9000000000000000000000000000000000000002", // noop (duplicated for testing)
}
assert.Equal(t, expectedPrecompiles, registeredPrecompiles,
"expected registered precompile address list to match to match expected")
}

View File

@ -4,7 +4,7 @@ package kava.precisebank.v1;
import "cosmos_proto/cosmos.proto"; import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto"; import "gogoproto/gogo.proto";
option go_package = "github.com/kava-labs/kava/x/precisebank/types"; option go_package = "github.com/0glabs/0g-chain/x/precisebank/types";
// GenesisState defines the precisebank module's genesis state. // GenesisState defines the precisebank module's genesis state.
message GenesisState { message GenesisState {

View File

@ -5,7 +5,7 @@ import "cosmos/base/v1beta1/coin.proto";
import "gogoproto/gogo.proto"; import "gogoproto/gogo.proto";
import "google/api/annotations.proto"; import "google/api/annotations.proto";
option go_package = "github.com/kava-labs/kava/x/precisebank/types"; option go_package = "github.com/0glabs/0g-chain/x/precisebank/types";
option (gogoproto.goproto_getters_all) = false; option (gogoproto.goproto_getters_all) = false;
// Query defines the gRPC querier service for precisebank module // Query defines the gRPC querier service for precisebank module

View File

@ -26,13 +26,13 @@ import (
"github.com/strangelove-ventures/interchaintest/v7/ibc" "github.com/strangelove-ventures/interchaintest/v7/ibc"
"github.com/strangelove-ventures/interchaintest/v7/testreporter" "github.com/strangelove-ventures/interchaintest/v7/testreporter"
"github.com/kava-labs/kava/app" "github.com/0glabs/0g-chain/app"
"github.com/kava-labs/kava/client/erc20" "github.com/0glabs/0g-chain/client/erc20"
"github.com/kava-labs/kava/tests/e2e/runner" "github.com/0glabs/0g-chain/tests/e2e/runner"
"github.com/kava-labs/kava/tests/e2e/testutil" "github.com/0glabs/0g-chain/tests/e2e/testutil"
kavainterchain "github.com/kava-labs/kava/tests/interchain" kavainterchain "github.com/0glabs/0g-chain/tests/interchain"
"github.com/kava-labs/kava/tests/util" "github.com/0glabs/0g-chain/tests/util"
evmutiltypes "github.com/kava-labs/kava/x/evmutil/types" evmutiltypes "github.com/0glabs/0g-chain/x/evmutil/types"
) )
// This test does the following: // This test does the following:

View File

@ -1,173 +0,0 @@
package e2e_test
import (
"context"
"math/big"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
ethermint "github.com/evmos/ethermint/types"
evmtypes "github.com/evmos/ethermint/x/evm/types"
"github.com/kava-labs/kava/precompile/registry"
)
// TestPrecompileGenesis tests that the the following is true for enabled precompiles:
//
// - An enabled precompile has an EthAccount with matching code hash,
// sequence of 1, and no public key
// - An enabled precompile has code equal to 0x01
// - An enabled precompile has a nonce of 1
//
// This is important to ensure the genesis setup for precompiles is correct.
func (suite *IntegrationTestSuite) TestPrecompileGenesis() {
type fixture struct {
address string
expectIsEnabled bool
expectIsEthAccount bool
expectCode []byte
expectNonce uint64
}
// enabled represnets the expected state for a registered precompile
// that is enabled at genesis
enabled := func(address string) func() fixture {
return func() fixture {
return fixture{
address: address,
expectIsEnabled: true,
expectIsEthAccount: true,
expectCode: []byte{0x01},
expectNonce: uint64(1),
}
}
}
// disabled represents the expected state for a registered precompile
// that is not enabled at genesis
disabled := func(address string) func() fixture {
return func() fixture {
return fixture{
address: address,
expectIsEnabled: false,
expectIsEthAccount: false,
expectCode: []byte{},
expectNonce: uint64(0),
}
}
}
testCases := []struct {
name string
genFixture func() fixture
}{
{
name: "noop contract address is enabled and initialized",
genFixture: enabled(registry.NoopContractAddress),
},
{
name: "noop contract address second address is disabled and not initialized",
genFixture: disabled(registry.NoopContractAddress2),
},
}
for _, tc := range testCases {
suite.Run(tc.name, func() {
tf := tc.genFixture()
//
// Addresses
//
evmAddress := common.HexToAddress(tf.address)
sdkAddress := sdk.AccAddress(evmAddress.Bytes())
//
// Heights
//
// We ensure all queries happen at block 1 after genesis
// and help ensure determisitc behavior
genesisHeight := big.NewInt(1)
grpcGenesisContext := suite.Kava.Grpc.CtxAtHeight(genesisHeight.Int64())
//
// Queries
//
evmParamsResp, err := suite.Kava.Grpc.Query.Evm.Params(grpcGenesisContext, &evmtypes.QueryParamsRequest{})
suite.Require().NoError(err)
// accountErr is checked during in the assertions below if tf.expectIsEthAccount is true
// This is due to the service returning a not found error for address that are not enabled,
// which can be ignored when we do not expect an eth account to exist.
accountResponse, accountErr := suite.Kava.Grpc.Query.Auth.Account(
grpcGenesisContext, &authtypes.QueryAccountRequest{Address: sdkAddress.String()})
var account authtypes.AccountI
if accountErr == nil {
err = suite.Kava.EncodingConfig.Marshaler.UnpackAny(accountResponse.Account, &account)
suite.Require().NoError(err)
}
// We ensure both the evm json rpc and x/evm grpc code endpoints return the same value
// in the assertions below
grpcCodeResponse, err := suite.Kava.Grpc.Query.Evm.Code(grpcGenesisContext,
&evmtypes.QueryCodeRequest{Address: evmAddress.String()})
suite.Require().NoError(err)
rpcCode, err := suite.Kava.EvmClient.CodeAt(context.Background(), evmAddress, genesisHeight)
suite.Require().NoError(err)
nonce, err := suite.Kava.EvmClient.NonceAt(context.Background(), evmAddress, genesisHeight)
suite.Require().NoError(err)
//
// Assertions
//
if tf.expectIsEnabled {
suite.Containsf(evmParamsResp.Params.EnabledPrecompiles, tf.address,
"expected %s to be enabled in evm params", tf.address)
} else {
suite.NotContainsf(evmParamsResp.Params.EnabledPrecompiles, tf.address,
"expected %s to not be enabled in evm params", tf.address)
}
// Fail if fixuture configuration is invalid
if tf.expectIsEthAccount && len(tf.expectCode) == 0 {
suite.Failf("an eth account must have expected code for address %s", tf.address)
}
// Run addition EthAccount assertions
if tf.expectIsEthAccount {
suite.Require().NoErrorf(accountErr, "expected account query to not error for address %s", tf.address)
// All contracts including precompiles must be EthAccount's
ethAccount, isEthAccount := account.(*ethermint.EthAccount)
suite.Require().Truef(isEthAccount, "expected account at address %s to be an eth account", tf.address)
// Code hash must always match the EthAccount
codeHash := ethAccount.GetCodeHash()
suite.Equalf(crypto.Keccak256Hash(tf.expectCode), codeHash,
"expected codehash for account %s to match expected code", tf.address)
// A precompile (and contract) should never have a public key set
suite.Nilf(ethAccount.PubKey, "expected account %s to have no public key", tf.address)
// Assert the account sequence matches the expected nonce
// This a duplicate of the nonce assertion below, but also helps ensure these
// two sources agree
suite.Equal(tf.expectNonce, ethAccount.GetSequence())
}
// We assert both methods of code retrieval report the same value
suite.Equalf(tf.expectCode, rpcCode, "expected code for address %s to match expected", tf.address)
// The GRPC endpoint returns []byte(nil) when the code is not in state, which is different from
// the rpc endpoint that returns []byte{}.
grpcExpectedCode := tf.expectCode
if len(grpcExpectedCode) == 0 {
grpcExpectedCode = []byte(nil)
}
suite.Equalf(grpcExpectedCode, grpcCodeResponse.Code, "expected code for address %s to match expected", tf.address)
// We assert this outside of the account context since the evm rpc always returns a nonce
suite.Equalf(tf.expectNonce, nonce, "expected nonce for address %s to match expected", tf.address)
})
}
}

View File

@ -1,8 +1,8 @@
package e2e_test package e2e_test
import ( import (
precisebanktypes "github.com/0glabs/0g-chain/x/precisebank/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
precisebanktypes "github.com/kava-labs/kava/x/precisebank/types"
) )
func (suite *IntegrationTestSuite) TestUpgrade_PreciseBankReserveTransfer() { func (suite *IntegrationTestSuite) TestUpgrade_PreciseBankReserveTransfer() {

View File

@ -6,8 +6,8 @@ import (
sdkmath "cosmossdk.io/math" sdkmath "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/precisebank/keeper" "github.com/0glabs/0g-chain/x/precisebank/keeper"
"github.com/kava-labs/kava/x/precisebank/types" "github.com/0glabs/0g-chain/x/precisebank/types"
) )
// InitGenesis initializes the store state from a genesis state. // InitGenesis initializes the store state from a genesis state.

View File

@ -6,10 +6,10 @@ import (
sdkmath "cosmossdk.io/math" sdkmath "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/precisebank" "github.com/0glabs/0g-chain/x/precisebank"
"github.com/kava-labs/kava/x/precisebank/keeper" "github.com/0glabs/0g-chain/x/precisebank/keeper"
"github.com/kava-labs/kava/x/precisebank/testutil" "github.com/0glabs/0g-chain/x/precisebank/testutil"
"github.com/kava-labs/kava/x/precisebank/types" "github.com/0glabs/0g-chain/x/precisebank/types"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
) )

View File

@ -5,11 +5,11 @@ import (
errorsmod "cosmossdk.io/errors" errorsmod "cosmossdk.io/errors"
sdkmath "cosmossdk.io/math" sdkmath "cosmossdk.io/math"
"github.com/0glabs/0g-chain/x/precisebank/types"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/kava-labs/kava/x/precisebank/types"
) )
// BurnCoins burns coins deletes coins from the balance of the module account. // BurnCoins burns coins deletes coins from the balance of the module account.

View File

@ -5,13 +5,13 @@ import (
"testing" "testing"
sdkmath "cosmossdk.io/math" sdkmath "cosmossdk.io/math"
"github.com/0glabs/0g-chain/x/precisebank/keeper"
"github.com/0glabs/0g-chain/x/precisebank/testutil"
"github.com/0glabs/0g-chain/x/precisebank/types"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
"github.com/kava-labs/kava/x/precisebank/keeper"
"github.com/kava-labs/kava/x/precisebank/testutil"
"github.com/kava-labs/kava/x/precisebank/types"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
) )

View File

@ -4,9 +4,9 @@ import (
"fmt" "fmt"
"testing" "testing"
"github.com/0glabs/0g-chain/x/precisebank/types"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/kava-labs/kava/x/precisebank/types"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )

View File

@ -8,7 +8,7 @@ import (
"github.com/cosmos/cosmos-sdk/store/prefix" "github.com/cosmos/cosmos-sdk/store/prefix"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/precisebank/types" "github.com/0glabs/0g-chain/x/precisebank/types"
) )
// GetFractionalBalance returns the fractional balance for an address. // GetFractionalBalance returns the fractional balance for an address.

View File

@ -8,7 +8,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/kava-labs/kava/x/precisebank/types" "github.com/0glabs/0g-chain/x/precisebank/types"
) )
func TestSetGetFractionalBalance(t *testing.T) { func TestSetGetFractionalBalance(t *testing.T) {

View File

@ -5,7 +5,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/precisebank/types" "github.com/0glabs/0g-chain/x/precisebank/types"
) )
type queryServer struct { type queryServer struct {

View File

@ -11,9 +11,9 @@ import (
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"github.com/kava-labs/kava/x/precisebank/keeper" "github.com/0glabs/0g-chain/x/precisebank/keeper"
"github.com/kava-labs/kava/x/precisebank/testutil" "github.com/0glabs/0g-chain/x/precisebank/testutil"
"github.com/kava-labs/kava/x/precisebank/types" "github.com/0glabs/0g-chain/x/precisebank/types"
) )
type grpcQueryTestSuite struct { type grpcQueryTestSuite struct {

View File

@ -4,8 +4,8 @@ import (
"fmt" "fmt"
sdkmath "cosmossdk.io/math" sdkmath "cosmossdk.io/math"
"github.com/0glabs/0g-chain/x/precisebank/types"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/precisebank/types"
) )
// RegisterInvariants registers the x/precisebank module invariants // RegisterInvariants registers the x/precisebank module invariants

View File

@ -4,10 +4,10 @@ import (
"testing" "testing"
sdkmath "cosmossdk.io/math" sdkmath "cosmossdk.io/math"
"github.com/0glabs/0g-chain/x/precisebank/keeper"
"github.com/0glabs/0g-chain/x/precisebank/testutil"
"github.com/0glabs/0g-chain/x/precisebank/types"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/precisebank/keeper"
"github.com/kava-labs/kava/x/precisebank/testutil"
"github.com/kava-labs/kava/x/precisebank/types"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
) )

View File

@ -8,9 +8,9 @@ import (
storetypes "github.com/cosmos/cosmos-sdk/store/types" storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/precisebank/keeper" "github.com/0glabs/0g-chain/x/precisebank/keeper"
"github.com/kava-labs/kava/x/precisebank/types" "github.com/0glabs/0g-chain/x/precisebank/types"
"github.com/kava-labs/kava/x/precisebank/types/mocks" "github.com/0glabs/0g-chain/x/precisebank/types/mocks"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )

View File

@ -6,7 +6,7 @@ import (
evmtypes "github.com/evmos/ethermint/x/evm/types" evmtypes "github.com/evmos/ethermint/x/evm/types"
"github.com/kava-labs/kava/x/precisebank/types" "github.com/0glabs/0g-chain/x/precisebank/types"
) )
// Enforce that Keeper implements the expected keeper interfaces // Enforce that Keeper implements the expected keeper interfaces

View File

@ -8,10 +8,10 @@ import (
"github.com/cosmos/cosmos-sdk/testutil" "github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/app" "github.com/0glabs/0g-chain/app"
"github.com/kava-labs/kava/x/precisebank/keeper" "github.com/0glabs/0g-chain/x/precisebank/keeper"
"github.com/kava-labs/kava/x/precisebank/types" "github.com/0glabs/0g-chain/x/precisebank/types"
"github.com/kava-labs/kava/x/precisebank/types/mocks" "github.com/0glabs/0g-chain/x/precisebank/types/mocks"
) )
// testData defines necessary fields for testing keeper store methods and mocks // testData defines necessary fields for testing keeper store methods and mocks

View File

@ -10,7 +10,7 @@ import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/kava-labs/kava/x/precisebank/types" "github.com/0glabs/0g-chain/x/precisebank/types"
) )
// MintCoins creates new coins from thin air and adds it to the module account. // MintCoins creates new coins from thin air and adds it to the module account.

View File

@ -11,9 +11,9 @@ import (
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
"github.com/kava-labs/kava/x/precisebank/keeper" "github.com/0glabs/0g-chain/x/precisebank/keeper"
"github.com/kava-labs/kava/x/precisebank/testutil" "github.com/0glabs/0g-chain/x/precisebank/testutil"
"github.com/kava-labs/kava/x/precisebank/types" "github.com/0glabs/0g-chain/x/precisebank/types"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
) )

View File

@ -10,7 +10,7 @@ import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
"github.com/kava-labs/kava/x/precisebank/types" "github.com/0glabs/0g-chain/x/precisebank/types"
) )
func TestMintCoins_PanicValidations(t *testing.T) { func TestMintCoins_PanicValidations(t *testing.T) {

View File

@ -6,7 +6,7 @@ import (
sdkmath "cosmossdk.io/math" sdkmath "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/precisebank/types" "github.com/0glabs/0g-chain/x/precisebank/types"
) )
// GetRemainderAmount returns the internal remainder amount. // GetRemainderAmount returns the internal remainder amount.

View File

@ -4,7 +4,7 @@ import (
"testing" "testing"
sdkmath "cosmossdk.io/math" sdkmath "cosmossdk.io/math"
"github.com/kava-labs/kava/x/precisebank/types" "github.com/0glabs/0g-chain/x/precisebank/types"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )

View File

@ -6,10 +6,10 @@ import (
errorsmod "cosmossdk.io/errors" errorsmod "cosmossdk.io/errors"
sdkmath "cosmossdk.io/math" sdkmath "cosmossdk.io/math"
"github.com/0glabs/0g-chain/x/precisebank/types"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/kava-labs/kava/x/precisebank/types"
) )
// IsSendEnabledCoins uses the parent x/bank keeper to check the coins provided // IsSendEnabledCoins uses the parent x/bank keeper to check the coins provided

View File

@ -4,14 +4,14 @@ import (
"fmt" "fmt"
"testing" "testing"
"github.com/0glabs/0g-chain/app"
"github.com/0glabs/0g-chain/x/precisebank/keeper"
"github.com/0glabs/0g-chain/x/precisebank/testutil"
"github.com/0glabs/0g-chain/x/precisebank/types"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
"github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/precisebank/keeper"
"github.com/kava-labs/kava/x/precisebank/testutil"
"github.com/kava-labs/kava/x/precisebank/types"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
) )

View File

@ -3,9 +3,9 @@ package keeper_test
import ( import (
"testing" "testing"
"github.com/0glabs/0g-chain/x/precisebank/types"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/kava-labs/kava/x/precisebank/types"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )

View File

@ -2,8 +2,8 @@ package keeper
import ( import (
sdkmath "cosmossdk.io/math" sdkmath "cosmossdk.io/math"
"github.com/0glabs/0g-chain/x/precisebank/types"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/precisebank/types"
) )
// GetBalance returns the balance of a specific denom for an address. This will // GetBalance returns the balance of a specific denom for an address. This will

View File

@ -8,8 +8,8 @@ import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
"github.com/kava-labs/kava/x/precisebank/testutil" "github.com/0glabs/0g-chain/x/precisebank/testutil"
"github.com/kava-labs/kava/x/precisebank/types" "github.com/0glabs/0g-chain/x/precisebank/types"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
) )

View File

@ -4,9 +4,9 @@ import (
"testing" "testing"
sdkmath "cosmossdk.io/math" sdkmath "cosmossdk.io/math"
"github.com/0glabs/0g-chain/x/precisebank/types"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/kava-labs/kava/x/precisebank/types"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )

View File

@ -15,8 +15,8 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/types/module"
"github.com/kava-labs/kava/x/precisebank/keeper" "github.com/0glabs/0g-chain/x/precisebank/keeper"
"github.com/kava-labs/kava/x/precisebank/types" "github.com/0glabs/0g-chain/x/precisebank/types"
) )
// ConsensusVersion defines the current module consensus version. // ConsensusVersion defines the current module consensus version.

View File

@ -6,9 +6,9 @@ import (
"testing" "testing"
sdkmath "cosmossdk.io/math" sdkmath "cosmossdk.io/math"
"github.com/0glabs/0g-chain/x/precisebank/types"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/address" "github.com/cosmos/cosmos-sdk/types/address"
"github.com/kava-labs/kava/x/precisebank/types"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )

View File

@ -16,9 +16,9 @@ import (
"github.com/evmos/ethermint/crypto/ethsecp256k1" "github.com/evmos/ethermint/crypto/ethsecp256k1"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"github.com/kava-labs/kava/app" "github.com/0glabs/0g-chain/app"
"github.com/kava-labs/kava/x/precisebank/keeper" "github.com/0glabs/0g-chain/x/precisebank/keeper"
"github.com/kava-labs/kava/x/precisebank/types" "github.com/0glabs/0g-chain/x/precisebank/types"
) )
type Suite struct { type Suite struct {

View File

@ -3,8 +3,8 @@ package types_test
import ( import (
"testing" "testing"
"github.com/0glabs/0g-chain/x/precisebank/types"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/precisebank/types"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )

View File

@ -5,8 +5,8 @@ import (
"testing" "testing"
sdkmath "cosmossdk.io/math" sdkmath "cosmossdk.io/math"
"github.com/kava-labs/kava/app" "github.com/0glabs/0g-chain/app"
"github.com/kava-labs/kava/x/precisebank/types" "github.com/0glabs/0g-chain/x/precisebank/types"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )

View File

@ -7,9 +7,9 @@ import (
"testing" "testing"
sdkmath "cosmossdk.io/math" sdkmath "cosmossdk.io/math"
"github.com/0glabs/0g-chain/app"
"github.com/0glabs/0g-chain/x/precisebank/types"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/precisebank/types"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )

View File

@ -4,10 +4,10 @@ import (
"testing" "testing"
sdkmath "cosmossdk.io/math" sdkmath "cosmossdk.io/math"
"github.com/0glabs/0g-chain/app"
"github.com/0glabs/0g-chain/x/precisebank/testutil"
"github.com/0glabs/0g-chain/x/precisebank/types"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/precisebank/testutil"
"github.com/kava-labs/kava/x/precisebank/types"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )

View File

@ -3,8 +3,8 @@ package types_test
import ( import (
"testing" "testing"
"github.com/0glabs/0g-chain/x/precisebank/types"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/precisebank/types"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )

View File

@ -3,10 +3,10 @@ package pricefeed_test
import ( import (
"testing" "testing"
"github.com/0glabs/0g-chain/x/pricefeed"
"github.com/0glabs/0g-chain/x/pricefeed/keeper"
"github.com/0glabs/0g-chain/x/pricefeed/testutil"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/pricefeed"
"github.com/kava-labs/kava/x/pricefeed/keeper"
"github.com/kava-labs/kava/x/pricefeed/testutil"
) )
func TestEndBlocker_UpdatesMultipleMarkets(t *testing.T) { func TestEndBlocker_UpdatesMultipleMarkets(t *testing.T) {

View File

@ -9,9 +9,9 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/kava-labs/kava/app" "github.com/0glabs/0g-chain/app"
"github.com/kava-labs/kava/x/pricefeed/keeper" "github.com/0glabs/0g-chain/x/pricefeed/keeper"
"github.com/kava-labs/kava/x/pricefeed/types" "github.com/0glabs/0g-chain/x/pricefeed/types"
) )
func SetCurrentPrices_PriceCalculations(t *testing.T, f func(ctx sdk.Context, keeper keeper.Keeper)) { func SetCurrentPrices_PriceCalculations(t *testing.T, f func(ctx sdk.Context, keeper keeper.Keeper)) {