Skip to content

Commit

Permalink
sync with develop branch
Browse files Browse the repository at this point in the history
  • Loading branch information
ws4charlie committed Oct 13, 2023
2 parents 6f04e8a + 8a308fc commit c4459ec
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 8 deletions.
30 changes: 28 additions & 2 deletions cmd/zetacored/main.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package main

import (
"fmt"
"os"
"strings"

"github.com/cosmos/cosmos-sdk/server"
cmdcfg "github.com/zeta-chain/zetacore/cmd/zetacored/config"

svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"
"github.com/zeta-chain/zetacore/app"
cmdcfg "github.com/zeta-chain/zetacore/cmd/zetacored/config"
)

func main() {
Expand All @@ -16,12 +17,37 @@ func main() {
rootCmd, _ := NewRootCmd()

if err := svrcmd.Execute(rootCmd, "", app.DefaultNodeHome); err != nil {

switch e := err.(type) {
case server.ErrorCode:
os.Exit(e.Code)

default:
processError(e)
os.Exit(1)
}
}
}

func processError(err error) {
// --ledger flag can't be used with Ethereum HD path
if strings.Contains(err.Error(), "cannot set custom bip32 path with ledger") {
printNotice([]string{
"note: --ledger flag can't be used with Ethereum HD path (used by default)",
"use --hd-path=\"\" in the command to use Cosmos HD path",
})
os.Exit(1)
}
}

func printNotice(messages []string) {
if len(messages) == 0 {
return
}
border := strings.Repeat("*", len(messages[0])+4) // 4 to account for padding
fmt.Println(border)
for _, message := range messages {
fmt.Printf("* %s \n", message)
}
fmt.Println(border)
}
3 changes: 1 addition & 2 deletions cmd/zetacored/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,12 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig appparams.EncodingConfig
ethermintclient.KeyCommands(app.DefaultNodeHome),
)

// replace the default hd-path for the key add command
// replace the default hd-path for the key add command with Ethereum HD Path
if err := SetEthereumHDPath(rootCmd); err != nil {
fmt.Printf("warning: unable to set default HD path: %v\n", err)
}

rootCmd.AddCommand(server.RosettaCommand(encodingConfig.InterfaceRegistry, encodingConfig.Codec))

}

func addModuleInitFlags(startCmd *cobra.Command) {
Expand Down
2 changes: 1 addition & 1 deletion docs/openapi/openapi.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27966,7 +27966,7 @@ paths:
- Query
/zeta-chain/zetacore/fungible/system_contract:
get:
summary: Queries a ZetaDepositAndCallContract by index.
summary: Queries SystemContract
operationId: Query_SystemContract
responses:
"200":
Expand Down
2 changes: 1 addition & 1 deletion proto/fungible/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ service Query {
option (google.api.http).get = "/zeta-chain/zetacore/fungible/foreign_coins";
}

// Queries a ZetaDepositAndCallContract by index.
// Queries SystemContract
rpc SystemContract(QueryGetSystemContractRequest) returns (QueryGetSystemContractResponse) {
option (google.api.http).get = "/zeta-chain/zetacore/fungible/system_contract";
}
Expand Down
1 change: 1 addition & 0 deletions x/fungible/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func GetQueryCmd(_ string) *cobra.Command {
CmdShowForeignCoins(),
CmdGasStabilityPoolAddress(),
CmdGasStabilityPoolBalance(),
CmdSystemContract(),
)

return cmd
Expand Down
32 changes: 32 additions & 0 deletions x/fungible/client/cli/query_system_contract.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package cli

import (
"context"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/spf13/cobra"
"github.com/zeta-chain/zetacore/x/fungible/types"
)

func CmdSystemContract() *cobra.Command {
cmd := &cobra.Command{
Use: "system-contract",
Short: "query system contract",
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)
queryClient := types.NewQueryClient(clientCtx)

res, err := queryClient.SystemContract(context.Background(), &types.QueryGetSystemContractRequest{})
if err != nil {
return err
}

return clientCtx.PrintProto(res)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}
4 changes: 2 additions & 2 deletions x/fungible/types/query.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions zetaclient/bitcoin_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,13 @@ func (ob *BitcoinChainClient) IsSendOutTxProcessed(sendHash string, nonce uint64
return false, false, err
}

// Get original cctx parameters
params, err = ob.GetPendingCctxParams(nonce)
if err != nil {
ob.logger.ObserveOutTx.Info().Msgf("IsSendOutTxProcessed: can't find pending cctx for nonce %d", nonce)
return false, false, err
}

if !included {
if !broadcasted {
return false, false, nil
Expand Down

0 comments on commit c4459ec

Please sign in to comment.