Skip to content

Commit

Permalink
Fixing dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
asoliman92 committed Aug 27, 2024
1 parent 1e1fd58 commit f9fbf12
Show file tree
Hide file tree
Showing 21 changed files with 1,907 additions and 1,478 deletions.
390 changes: 368 additions & 22 deletions contracts/pnpm-lock.yaml

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ccip_reader_tester: ../../../contracts/solc/v0.8.24/CCIPReaderTester/CCIPReaderT
commit_store: ../../../contracts/solc/v0.8.24/CommitStore/CommitStore.abi ../../../contracts/solc/v0.8.24/CommitStore/CommitStore.bin 274d87db70b643e00ab0a7e7845bb4b791f3b613bfc87708d33fc5a8369e2a41
commit_store_helper: ../../../contracts/solc/v0.8.24/CommitStoreHelper/CommitStoreHelper.abi ../../../contracts/solc/v0.8.24/CommitStoreHelper/CommitStoreHelper.bin f7128dcc2ee6dbcbc976288abcc16970ffb19b59412c5202ef6b259d2007f801
ether_sender_receiver: ../../../contracts/solc/v0.8.24/EtherSenderReceiver/EtherSenderReceiver.abi ../../../contracts/solc/v0.8.24/EtherSenderReceiver/EtherSenderReceiver.bin 09510a3f773f108a3c231e8d202835c845ded862d071ec54c4f89c12d868b8de
evm_2_evm_offramp: ../../../contracts/solc/v0.8.24/EVM2EVMOffRamp/EVM2EVMOffRamp.abi ../../../contracts/solc/v0.8.24/EVM2EVMOffRamp/EVM2EVMOffRamp.bin b0d77babbe635cd6ba04c2af049badc9e9d28a4b6ed6bb75f830ad902a618beb
evm_2_evm_offramp: ../../../contracts/solc/v0.8.24/EVM2EVMOffRamp/EVM2EVMOffRamp.abi ../../../contracts/solc/v0.8.24/EVM2EVMOffRamp/EVM2EVMOffRamp.bin b862579d2e9300d24e63255ad2bce193b951c892661c22aa1be076aae0b8815a
evm_2_evm_onramp: ../../../contracts/solc/v0.8.24/EVM2EVMOnRamp/EVM2EVMOnRamp.abi ../../../contracts/solc/v0.8.24/EVM2EVMOnRamp/EVM2EVMOnRamp.bin 5c02c2b167946b3467636ff2bb58594cb4652fc63d8bdfee2488ed562e2a3e50
lock_release_token_pool: ../../../contracts/solc/v0.8.24/LockReleaseTokenPool/LockReleaseTokenPool.abi ../../../contracts/solc/v0.8.24/LockReleaseTokenPool/LockReleaseTokenPool.bin e6a8ec9e8faccb1da7d90e0f702ed72975964f97dc3222b54cfcca0a0ba3fea2
lock_release_token_pool_and_proxy: ../../../contracts/solc/v0.8.24/LockReleaseTokenPoolAndProxy/LockReleaseTokenPoolAndProxy.abi ../../../contracts/solc/v0.8.24/LockReleaseTokenPoolAndProxy/LockReleaseTokenPoolAndProxy.bin e632b08be0fbd1d013e8b3a9d75293d0d532b83071c531ff2be1deec1fa48ec1
Expand Down
190 changes: 157 additions & 33 deletions core/gethwrappers/keystone/generated/feeds_consumer/feeds_consumer.go

Large diffs are not rendered by default.

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
42 changes: 42 additions & 0 deletions core/scripts/ccip/revert-reason/command/revert_reason.go
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)
}
},
}
35 changes: 35 additions & 0 deletions core/scripts/ccip/revert-reason/command/root.go
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")
}
42 changes: 42 additions & 0 deletions core/scripts/ccip/revert-reason/config/config.go
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
}
17 changes: 17 additions & 0 deletions core/scripts/ccip/revert-reason/handler/handler.go
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,
}
}
4 changes: 2 additions & 2 deletions core/scripts/ccip/revert-reason/handler/reason.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/token_admin_registry"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/usdc_token_pool"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/usdc_token_pool_1_4_0"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/burn_mint_erc677"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/erc20"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/shared/generated/burn_mint_erc677"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/shared/generated/erc20"
)

// RevertReasonFromErrorCodeString attempts to decode an error code string
Expand Down
68 changes: 68 additions & 0 deletions core/scripts/ccip/revert-reason/handler/reason_test.go
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)
})
}
}
Loading

0 comments on commit f9fbf12

Please sign in to comment.