Skip to content

Commit

Permalink
Reorganize protos and pkg subpackages
Browse files Browse the repository at this point in the history
  • Loading branch information
skosito committed Mar 25, 2024
1 parent f0776c8 commit cf9fb0d
Show file tree
Hide file tree
Showing 245 changed files with 3,355 additions and 3,555 deletions.
27 changes: 14 additions & 13 deletions cmd/zetaclientd/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import (

"github.com/ethereum/go-ethereum/ethclient"
"github.com/onrik/ethrpc"
"github.com/zeta-chain/zetacore/pkg"
"github.com/zeta-chain/zetacore/pkg/chains"
"github.com/zeta-chain/zetacore/pkg/coin"
"github.com/zeta-chain/zetacore/zetaclient/bitcoin"
corecontext "github.com/zeta-chain/zetacore/zetaclient/core_context"
"github.com/zeta-chain/zetacore/zetaclient/evm"
Expand Down Expand Up @@ -90,12 +91,12 @@ func DebugCmd() *cobra.Command {
return err
}

chain := pkg.GetChainFromChainID(chainID)
chain := chains.GetChainFromChainID(chainID)
if chain == nil {
return fmt.Errorf("invalid chain id")
}

if pkg.IsEVMChain(chain.ChainId) {
if chains.IsEVMChain(chain.ChainId) {

ob := evm.ChainClient{
Mu: &sync.Mutex{},
Expand All @@ -104,7 +105,7 @@ func DebugCmd() *cobra.Command {
ob.WithLogger(chainLogger)
var ethRPC *ethrpc.EthRPC
var client *ethclient.Client
coinType := pkg.CoinType_Cmd
coinType := coin.CoinType_Cmd
for chain, evmConfig := range cfg.GetAllEVMConfigs() {
if chainID == chain {
ethRPC = ethrpc.NewEthRPC(evmConfig.Endpoint)
Expand All @@ -114,7 +115,7 @@ func DebugCmd() *cobra.Command {
}
ob.WithEvmClient(client)
ob.WithEvmJSONRPC(ethRPC)
ob.WithChain(*pkg.GetChainFromChainID(chainID))
ob.WithChain(*chains.GetChainFromChainID(chainID))
}
}
hash := ethcommon.HexToHash(txHash)
Expand Down Expand Up @@ -144,29 +145,29 @@ func DebugCmd() *cobra.Command {
}
evmChainParams.ZetaTokenContractAddress = chainParams.ZetaTokenContractAddress
if strings.EqualFold(tx.To, chainParams.ConnectorContractAddress) {
coinType = pkg.CoinType_Zeta
coinType = coin.CoinType_Zeta
} else if strings.EqualFold(tx.To, chainParams.Erc20CustodyContractAddress) {
coinType = pkg.CoinType_ERC20
coinType = coin.CoinType_ERC20
} else if strings.EqualFold(tx.To, tssEthAddress) {
coinType = pkg.CoinType_Gas
coinType = coin.CoinType_Gas
}
}
}

switch coinType {
case pkg.CoinType_Zeta:
case coin.CoinType_Zeta:
ballotIdentifier, err = ob.CheckAndVoteInboundTokenZeta(tx, receipt, false)
if err != nil {
return err
}

case pkg.CoinType_ERC20:
case coin.CoinType_ERC20:
ballotIdentifier, err = ob.CheckAndVoteInboundTokenERC20(tx, receipt, false)
if err != nil {
return err
}

case pkg.CoinType_Gas:
case coin.CoinType_Gas:
ballotIdentifier, err = ob.CheckAndVoteInboundTokenGas(tx, receipt, false)
if err != nil {
return err
Expand All @@ -175,13 +176,13 @@ func DebugCmd() *cobra.Command {
fmt.Println("CoinType not detected")
}
fmt.Println("CoinType : ", coinType)
} else if pkg.IsBitcoinChain(chain.ChainId) {
} else if chains.IsBitcoinChain(chain.ChainId) {
obBtc := bitcoin.BTCChainClient{
Mu: &sync.Mutex{},
}
obBtc.WithZetaClient(bridge)
obBtc.WithLogger(chainLogger)
obBtc.WithChain(*pkg.GetChainFromChainID(chainID))
obBtc.WithChain(*chains.GetChainFromChainID(chainID))
connCfg := &rpcclient.ConnConfig{
Host: cfg.BitcoinConfig.RPCHost,
User: cfg.BitcoinConfig.RPCUsername,
Expand Down
8 changes: 4 additions & 4 deletions cmd/zetaclientd/keygen_tss.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
tsscommon "github.com/zeta-chain/go-tss/common"
"github.com/zeta-chain/go-tss/keygen"
"github.com/zeta-chain/go-tss/p2p"
"github.com/zeta-chain/zetacore/pkg"
"github.com/zeta-chain/zetacore/pkg/chains"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
"github.com/zeta-chain/zetacore/zetaclient/metrics"
)
Expand All @@ -37,7 +37,7 @@ func GenerateTss(
// Bitcoin chain ID is currently used for using the correct signature format
// TODO: remove this once we have a better way to determine the signature format
// https://github.com/zeta-chain/node/issues/1397
bitcoinChainID := pkg.BtcRegtestChain().ChainId
bitcoinChainID := chains.BtcRegtestChain().ChainId
btcChain, _, btcEnabled := appContext.GetBTCChainAndConfig()
if btcEnabled {
bitcoinChainID = btcChain.ChainId
Expand Down Expand Up @@ -109,7 +109,7 @@ func GenerateTss(
err = keygenTss(keyGen, tss, keygenLogger)
if err != nil {
keygenLogger.Error().Err(err).Msg("keygenTss error")
tssFailedVoteHash, err := zetaBridge.SetTSS("", keyGen.BlockNumber, pkg.ReceiveStatus_Failed)
tssFailedVoteHash, err := zetaBridge.SetTSS("", keyGen.BlockNumber, chains.ReceiveStatus_Failed)
if err != nil {
keygenLogger.Error().Err(err).Msg("Failed to broadcast Failed TSS Vote to zetacore")
return nil, err
Expand All @@ -127,7 +127,7 @@ func GenerateTss(
}

// If TSS is successful , broadcast the vote to zetacore and set Pubkey
tssSuccessVoteHash, err := zetaBridge.SetTSS(newTss.CurrentPubkey, keyGen.BlockNumber, pkg.ReceiveStatus_Success)
tssSuccessVoteHash, err := zetaBridge.SetTSS(newTss.CurrentPubkey, keyGen.BlockNumber, chains.ReceiveStatus_Success)
if err != nil {
keygenLogger.Error().Err(err).Msg("TSS successful but unable to broadcast vote to zeta-core")
return nil, err
Expand Down
3 changes: 2 additions & 1 deletion cmd/zetaclientd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/tendermint/tendermint/crypto/secp256k1"
"github.com/zeta-chain/go-tss/p2p"
"github.com/zeta-chain/zetacore/pkg"
"github.com/zeta-chain/zetacore/pkg/authz"
observerTypes "github.com/zeta-chain/zetacore/x/observer/types"
mc "github.com/zeta-chain/zetacore/zetaclient"
appcontext "github.com/zeta-chain/zetacore/zetaclient/app_context"
Expand Down Expand Up @@ -99,7 +100,7 @@ func start(_ *cobra.Command, _ []string) error {
}
zetaBridge.WaitForCoreToCreateBlocks()
startLogger.Info().Msgf("ZetaBridge is ready")
zetaBridge.SetAccountNumber(pkg.ZetaClientGranteeKey)
zetaBridge.SetAccountNumber(authz.ZetaClientGranteeKey)

// cross-check chainid
res, err := zetaBridge.GetNodeInfo()
Expand Down
8 changes: 4 additions & 4 deletions cmd/zetacored/get_pubkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/crypto"
"github.com/spf13/cobra"
"github.com/zeta-chain/zetacore/pkg"
"github.com/zeta-chain/zetacore/pkg/cosmos"
zetacrypto "github.com/zeta-chain/zetacore/pkg/crypto"
)

func GetPubKeyCmd() *cobra.Command {
Expand All @@ -33,8 +33,8 @@ func GetPubKeyCmd() *cobra.Command {
return cmd
}

func GetPubKeySet(clientctx client.Context, tssAccountName, password string) (pkg.PubKeySet, error) {
pubkeySet := pkg.PubKeySet{
func GetPubKeySet(clientctx client.Context, tssAccountName, password string) (zetacrypto.PubKeySet, error) {
pubkeySet := zetacrypto.PubKeySet{
Secp256k1: "",
Ed25519: "",
}
Expand All @@ -52,7 +52,7 @@ func GetPubKeySet(clientctx client.Context, tssAccountName, password string) (pk
if err != nil {
return pubkeySet, err
}
pubkey, err := pkg.NewPubKey(s)
pubkey, err := zetacrypto.NewPubKey(s)
if err != nil {
return pubkeySet, err
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/zetacored/observer_accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/spf13/cobra"
"github.com/zeta-chain/zetacore/app"
"github.com/zeta-chain/zetacore/cmd/zetacored/config"
"github.com/zeta-chain/zetacore/pkg"
"github.com/zeta-chain/zetacore/pkg/crypto"
crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types"
"github.com/zeta-chain/zetacore/x/observer/types"
)
Expand Down Expand Up @@ -115,11 +115,11 @@ func AddObserverAccountsCmd() *cobra.Command {

observerSet.ObserverList = append(observerSet.ObserverList, info.ObserverAddress)
if info.ZetaClientGranteePubKey != "" {
pubkey, err := pkg.NewPubKey(info.ZetaClientGranteePubKey)
pubkey, err := crypto.NewPubKey(info.ZetaClientGranteePubKey)
if err != nil {
panic(err)
}
pubkeySet := pkg.PubKeySet{
pubkeySet := crypto.PubKeySet{
Secp256k1: pubkey,
Ed25519: "",
}
Expand Down
100 changes: 0 additions & 100 deletions common/bitcoin/proof_test.go

This file was deleted.

Loading

0 comments on commit cf9fb0d

Please sign in to comment.