-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1e1fd58
commit f9fbf12
Showing
21 changed files
with
1,907 additions
and
1,478 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
core/gethwrappers/ccip/generated/evm_2_evm_offramp/evm_2_evm_offramp.go
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
190 changes: 157 additions & 33 deletions
190
core/gethwrappers/keystone/generated/feeds_consumer/feeds_consumer.go
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
core/gethwrappers/keystone/generation/generated-wrapper-dependency-versions-do-not-edit.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
GETH_VERSION: 1.13.8 | ||
capabilities_registry: ../../../contracts/solc/v0.8.24/CapabilitiesRegistry/CapabilitiesRegistry.abi ../../../contracts/solc/v0.8.24/CapabilitiesRegistry/CapabilitiesRegistry.bin 7e95d72f24940f08ada0ee3b85d894d6bfccfd6c8a3e0ceeff65bae52c899d54 | ||
feeds_consumer: ../../../contracts/solc/v0.8.24/KeystoneFeedsConsumer/KeystoneFeedsConsumer.abi ../../../contracts/solc/v0.8.24/KeystoneFeedsConsumer/KeystoneFeedsConsumer.bin 8c3a2b18a80be41e7c40d2bc3a4c8d1b5e18d55c1fd20ad5af68cebb66109fc5 | ||
feeds_consumer: ../../../contracts/solc/v0.8.24/KeystoneFeedsConsumer/KeystoneFeedsConsumer.abi ../../../contracts/solc/v0.8.24/KeystoneFeedsConsumer/KeystoneFeedsConsumer.bin 6ac1c08335868eab4299d168d63d8f757597b9ef6e0a2dcca75c4b439a31e168 | ||
forwarder: ../../../contracts/solc/v0.8.24/KeystoneForwarder/KeystoneForwarder.abi ../../../contracts/solc/v0.8.24/KeystoneForwarder/KeystoneForwarder.bin 45d9b866c64b41c1349a90b6764aee42a6d078b454d38f369b5fe02b23b9d16e | ||
ocr3_capability: ../../../contracts/solc/v0.8.24/OCR3Capability/OCR3Capability.abi ../../../contracts/solc/v0.8.24/OCR3Capability/OCR3Capability.bin 8bf0f53f222efce7143dea6134552eb26ea1eef845407b4475a0d79b7d7ba9f8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package command | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"github.com/smartcontractkit/chainlink/core/scripts/ccip/revert-reason/config" | ||
"github.com/smartcontractkit/chainlink/core/scripts/ccip/revert-reason/handler" | ||
) | ||
|
||
// RevertReasonCmd takes in a failed tx hash and tries to give you the reason | ||
var RevertReasonCmd = &cobra.Command{ | ||
Use: "reason <tx hash or error string>", | ||
Short: "Revert reason for failed TX.", | ||
Long: `Given a failed TX tries to find the revert reason. args = tx hex address`, | ||
Args: cobra.ExactArgs(1), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
cfg := config.New() | ||
baseHandler := handler.NewBaseHandler(cfg) | ||
|
||
decodeFromError, err := cmd.Flags().GetBool("from-error") | ||
if err != nil { | ||
log.Fatal("failed to get withdraw flag: ", err) | ||
} | ||
|
||
if decodeFromError { | ||
result, err := baseHandler.RevertReasonFromErrorCodeString(args[0]) | ||
if err != nil { | ||
log.Fatal("failed to decode error code string: ", err) | ||
} | ||
fmt.Print(result) | ||
} else { | ||
result, err := baseHandler.RevertReasonFromTx(args[0]) | ||
if err != nil { | ||
log.Fatal("failed to decode error code string: ", err) | ||
} | ||
fmt.Print(result) | ||
} | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package command | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
var configFile string | ||
|
||
// RootCmd represents the base command when called without any subcommands | ||
var RootCmd = &cobra.Command{ | ||
Use: "ccip-revert-reason", | ||
Short: "ChainLink CLI tool to resolve CCIP revert reasons", | ||
Long: `ccip-revert-reason is a CLI for running the CCIP revert reason resolution commands.`, | ||
} | ||
|
||
// Execute adds all child commands to the root command and sets flags appropriately. | ||
// This is called by main.main(). It only needs to happen once to the RootCmd. | ||
func Execute() { | ||
if err := RootCmd.Execute(); err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
} | ||
|
||
func init() { | ||
RootCmd.PersistentFlags().StringVar(&configFile, "config", "", "config file (default is .env)") | ||
_ = viper.BindPFlag("config", RootCmd.PersistentFlags().Lookup("config")) | ||
|
||
RootCmd.AddCommand(RevertReasonCmd) | ||
RevertReasonCmd.Flags().Bool("from-error", false, "Whether to decode an error string instead of transaction hash") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package config | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/spf13/viper" | ||
) | ||
|
||
// Config represents configuration fields | ||
type Config struct { | ||
NodeURL string `mapstructure:"NODE_URL"` | ||
FromAddress string `mapstructure:"FROM_ADDRESS"` | ||
} | ||
|
||
// New creates a new config | ||
func New() *Config { | ||
var cfg Config | ||
configFile := viper.GetString("config") | ||
if configFile != "" { | ||
// Use config file from the flag. | ||
viper.SetConfigFile(configFile) | ||
} else { | ||
viper.SetConfigFile(".env") | ||
} | ||
viper.AutomaticEnv() | ||
if err := viper.ReadInConfig(); err != nil { | ||
log.Fatal("failed to read config: ", err) | ||
} | ||
if err := viper.Unmarshal(&cfg); err != nil { | ||
log.Fatal("failed to unmarshal config: ", err) | ||
} | ||
if err := cfg.Validate(); err != nil { | ||
log.Fatal("failed to validate config: ", err) | ||
} | ||
|
||
return &cfg | ||
} | ||
|
||
// Validate validates the given config | ||
func (c *Config) Validate() error { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package handler | ||
|
||
import ( | ||
"github.com/smartcontractkit/chainlink/core/scripts/ccip/revert-reason/config" | ||
) | ||
|
||
// BaseHandler is the common handler with a common logic | ||
type BaseHandler struct { | ||
cfg *config.Config | ||
} | ||
|
||
// NewBaseHandler is the constructor of baseHandler | ||
func NewBaseHandler(cfg *config.Config) *BaseHandler { | ||
return &BaseHandler{ | ||
cfg: cfg, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package handler | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/smartcontractkit/chainlink/core/scripts/ccip/revert-reason/config" | ||
) | ||
|
||
func Test_RevertReasonFromTx(t *testing.T) { | ||
type fields struct { | ||
cfg *config.Config | ||
} | ||
type args struct { | ||
txHash string | ||
} | ||
var tests []struct { | ||
name string | ||
fields fields | ||
args args | ||
expected string | ||
} // TODO: Add test cases. | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
h := &BaseHandler{ | ||
cfg: tt.fields.cfg, | ||
} | ||
got, err := h.RevertReasonFromTx(tt.args.txHash) | ||
require.NoError(t, err) | ||
require.Equal(t, tt.expected, got) | ||
}) | ||
} | ||
} | ||
|
||
func Test_RevertReasonFromErrorCodeString(t *testing.T) { | ||
type fields struct { | ||
cfg *config.Config | ||
} | ||
type args struct { | ||
errorCodeString string | ||
} | ||
tests := []struct { | ||
name string | ||
fields fields | ||
args args | ||
expected string | ||
}{ | ||
{ | ||
name: "decode error string", | ||
fields: fields{cfg: &config.Config{}}, | ||
args: args{ | ||
errorCodeString: "0x4e487b710000000000000000000000000000000000000000000000000000000000000032", | ||
}, | ||
expected: "If you access an array, bytesN or an array slice at an out-of-bounds or negative index (i.e. x[i] where i >= x.length or i < 0).", | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
h := &BaseHandler{ | ||
cfg: tt.fields.cfg, | ||
} | ||
got, err := h.RevertReasonFromErrorCodeString(tt.args.errorCodeString) | ||
require.NoError(t, err) | ||
require.Equal(t, tt.expected, got) | ||
}) | ||
} | ||
} |
Oops, something went wrong.