Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into tt_1511_load_abi_geth…
Browse files Browse the repository at this point in the history
…wrappers
  • Loading branch information
Tofel committed Aug 27, 2024
2 parents 5ff48d8 + 5e55de9 commit 070a96e
Show file tree
Hide file tree
Showing 17 changed files with 93 additions and 65 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/seth-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
if: steps.changes.outputs.src == 'true'
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Run tests
- name: Run lints
if: steps.changes.outputs.src == 'true'
run: |
nix develop -c make lint
1 change: 1 addition & 0 deletions .github/workflows/seth-test-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Run tests
if: steps.changes.outputs.src == 'true'
env:
SETH_NETWORK: ${{ matrix.network }}
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/seth-test-bumping.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Run tests
if: steps.changes.outputs.src == 'true'
env:
SETH_NETWORK: ${{ matrix.network }}
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/seth-test-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Run tests
if: steps.changes.outputs.src == 'true'
env:
SETH_NETWORK: ${{ matrix.network }}
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/seth-test-decode-testnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Run tests
if: steps.changes.outputs.src == 'true'
env:
SETH_NETWORK: ${{ matrix.network }}
SETH_ROOT_PRIVATE_KEY: ${{ secrets.TESTNET_COMMON_KEYS }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/seth-test-decode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Run tests
if: steps.changes.outputs.src == 'true'
env:
SETH_NETWORK: ${{ matrix.network }}
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/seth-test-others.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Run tests
if: steps.changes.outputs.src == 'true'
env:
SETH_NETWORK: ${{ matrix.network }}
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/seth-test-trace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Run tests
if: steps.changes.outputs.src == 'true'
env:
SETH_NETWORK: ${{ matrix.network }}
run: |
Expand Down
3 changes: 3 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,6 @@ issues:
- wasp/examples/*
- k8s
- seth/contracts/*
- seth/examples/*
- seth/examples_wasp/*

2 changes: 1 addition & 1 deletion config/testconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (

"github.com/joho/godotenv"
"github.com/pkg/errors"
"github.com/smartcontractkit/seth"

"github.com/smartcontractkit/chainlink-testing-framework/logging"
"github.com/smartcontractkit/chainlink-testing-framework/seth"
)

func (c *TestConfig) GetLoggingConfig() *LoggingConfig {
Expand Down
2 changes: 1 addition & 1 deletion config/types.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package config

import "github.com/smartcontractkit/seth"
import "github.com/smartcontractkit/chainlink-testing-framework/seth"

type SethConfig interface {
GetSethConfig() *seth.Config
Expand Down
18 changes: 9 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,17 @@ require (
github.com/prometheus/common v0.45.0
github.com/rs/zerolog v1.30.0
github.com/slack-go/slack v0.12.2
github.com/smartcontractkit/seth v1.1.1
github.com/smartcontractkit/wasp v0.4.1
github.com/spf13/cobra v1.7.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.9.0
github.com/testcontainers/testcontainers-go v0.28.0
go.uber.org/atomic v1.11.0
go.uber.org/zap v1.26.0
golang.org/x/net v0.18.0
golang.org/x/net v0.25.0
golang.org/x/oauth2 v0.13.0
golang.org/x/sync v0.5.0
golang.org/x/text v0.14.0
golang.org/x/sync v0.7.0
golang.org/x/text v0.16.0
k8s.io/api v0.28.2
k8s.io/apimachinery v0.28.2
k8s.io/cli-runtime v0.28.2
Expand Down Expand Up @@ -284,13 +283,13 @@ require (
go.uber.org/ratelimit v0.3.0 // indirect
go4.org/netipx v0.0.0-20230125063823-8449b0a6169f // indirect
golang.org/x/arch v0.4.0 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
golang.org/x/mod v0.19.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.15.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/term v0.22.0 // indirect
golang.org/x/time v0.6.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 // indirect
Expand Down Expand Up @@ -319,6 +318,7 @@ require (
require (
github.com/aws/aws-sdk-go-v2/config v1.27.28
github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.32.5
github.com/smartcontractkit/chainlink-testing-framework/seth v1.2.0
)

require (
Expand Down
36 changes: 18 additions & 18 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1047,8 +1047,8 @@ github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/slack-go/slack v0.12.2 h1:x3OppyMyGIbbiyFhsBmpf9pwkUzMhthJMRNmNlA4LaQ=
github.com/slack-go/slack v0.12.2/go.mod h1:hlGi5oXA+Gt+yWTPP0plCdRKmjsDxecdHxYQdlMQKOw=
github.com/smartcontractkit/seth v1.1.1 h1:6hvexjJD7ek8ht/CLlEwQcH21K2E/WEYwbSRdKInZmM=
github.com/smartcontractkit/seth v1.1.1/go.mod h1:cDfKHi/hJLpO9sRpVbrflrHCOV+MJPAMJHloExJnIXk=
github.com/smartcontractkit/chainlink-testing-framework/seth v1.2.0 h1:wEc6EKMOOK/9w6z/zv2/wPZsV/txctbYoVJ1sCxhXwI=
github.com/smartcontractkit/chainlink-testing-framework/seth v1.2.0/go.mod h1:upYGPS9lOBW2pJg6XD8TTNSD1GtRfayU2Ct5bcfvqFw=
github.com/smartcontractkit/wasp v0.4.1 h1:qgIx2s+eCwH0OaBKaHEAHUQ1Z47bAgDu+ICS9IOqvGQ=
github.com/smartcontractkit/wasp v0.4.1/go.mod h1:3qiofyI3pkbrc48a3CVshbMfgl74SiuPL/tm30d9Wb4=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
Expand Down Expand Up @@ -1232,8 +1232,8 @@ golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5y
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
Expand Down Expand Up @@ -1323,8 +1323,8 @@ golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg=
golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ=
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand All @@ -1346,8 +1346,8 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE=
golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down Expand Up @@ -1431,15 +1431,15 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.0.0-20220526004731-065cf7ba2467/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4=
golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0=
golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk=
golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand All @@ -1451,14 +1451,14 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U=
golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181221001348-537d06c36207/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
Expand Down Expand Up @@ -1512,8 +1512,8 @@ golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4f
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.15.0 h1:zdAyfUGbYmuVokhzVmghFl2ZJh5QhcfebBgmVPFYA+8=
golang.org/x/tools v0.15.0/go.mod h1:hpksKq4dtpQWS1uQ61JkdqWM3LscIS6Slf+VVkm+wQk=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
2 changes: 1 addition & 1 deletion seth/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ test_cover:

.PHONY: lint
lint:
golangci-lint --color=always run -v
golangci-lint --color=always run -v -c .golangci.yaml
81 changes: 49 additions & 32 deletions seth/contract_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func extractABIFromGethWrapperDir(filePath string) (string, *abi.ABI, error) {
// use package name as contract name
contractName := node.Name.Name

// Traverse the AST to find var declarations
TOP_LOOP:
for _, decl := range node.Decls {
genDecl, ok := decl.(*ast.GenDecl)
if !ok || genDecl.Tok != token.VAR {
Expand All @@ -195,37 +195,9 @@ func extractABIFromGethWrapperDir(filePath string) (string, *abi.ABI, error) {
continue
}

for i, name := range vspec.Names {
if strings.HasSuffix(name.Name, metaDataSuffix) {
// make sure that for given name index there's a value
if len(vspec.Values)-1 >= i {
// check for expected types until we find a field with bind.MetaData type
// this might need to be updated if the structure of the MetaData struct changes
// or if package name that stores MetaData changes
if unaryExpr, ok := vspec.Values[i].(*ast.UnaryExpr); ok {
if compLit, ok := unaryExpr.X.(*ast.CompositeLit); ok {
if expr, ok := compLit.Type.(*ast.SelectorExpr); ok {
if x, ok := expr.X.(*ast.Ident); ok {
if x.Name == "bind" && expr.Sel.Name == "MetaData" {
for _, elt := range compLit.Elts {
if kvExpr, ok := elt.(*ast.KeyValueExpr); ok {
// Now look for filed named "ABI"
// in a similar way we could extract bytecode from "BIN" field
if key, ok := kvExpr.Key.(*ast.Ident); ok && key.Name == "ABI" {
if abiValue, ok := kvExpr.Value.(*ast.BasicLit); ok && abiValue.Kind == token.STRING {
abiContent = abiValue.Value
break
}
}
}
}
}
}
}
}
}
}
}
abiContent = extractValueFromCompositeLiteralField(vspec, "bind", "MetaData", "ABI")
if abiContent != "" {
break TOP_LOOP
}
}
}
Expand All @@ -247,3 +219,48 @@ func extractABIFromGethWrapperDir(filePath string) (string, *abi.ABI, error) {

return contractName, &parsedAbi, nil
}

// extractValueFromCompositeLiteralField finds a composite literal in a given ValueSpec with given type (packageName.typeName)
// and extracts value of a field with a given name
func extractValueFromCompositeLiteralField(vspec *ast.ValueSpec, varPackageName, varType, fieldName string) string {
for i := range vspec.Names {
// defensive programming - make sure that for given name index there's a value
if len(vspec.Values)-1 >= i {
// check for expected types until we find a field with bind.MetaData type
// this might need to be updated if the structure of the MetaData struct changes
// or if package name that stores MetaData changes
if unaryExpr, ok := vspec.Values[i].(*ast.UnaryExpr); ok {
if compLit, ok := unaryExpr.X.(*ast.CompositeLit); ok {
if expr, ok := compLit.Type.(*ast.SelectorExpr); ok {
if x, ok := expr.X.(*ast.Ident); ok {
if x.Name == varPackageName && expr.Sel.Name == varType {
return extractStringKeyFromCompositeLiteral(compLit, fieldName)
}
}
}
}
}
}
}

return ""
}

// extractStringKeyFromCompositeLiteral returns value of a string field with a given name from a composite literal
func extractStringKeyFromCompositeLiteral(compositeLiteral *ast.CompositeLit, keyName string) string {
var abiContent string
for _, elt := range compositeLiteral.Elts {
if kvExpr, ok := elt.(*ast.KeyValueExpr); ok {
// Look for filed named "ABI"
// in a similar way we could extract bytecode from "BIN" field
if key, ok := kvExpr.Key.(*ast.Ident); ok && key.Name == keyName {
if abiValue, ok := kvExpr.Value.(*ast.BasicLit); ok && abiValue.Kind == token.STRING {
abiContent = abiValue.Value
break
}
}
}
}

return abiContent
}
2 changes: 1 addition & 1 deletion seth/examples_wasp/client_main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func NewDebugContractSetup() (
if err != nil {
return nil, nil, common.Address{}, common.Address{}, nil, err
}
cs, err := seth.NewContractStore(cfg.ABIDir, cfg.BINDir)
cs, err := seth.NewContractStore(cfg.ABIDir, cfg.BINDir, nil)
if err != nil {
return nil, nil, common.Address{}, common.Address{}, nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion utils/seth/seth.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (

"github.com/pkg/errors"
"github.com/rs/zerolog"
pkg_seth "github.com/smartcontractkit/seth"

"github.com/smartcontractkit/chainlink-testing-framework/blockchain"
"github.com/smartcontractkit/chainlink-testing-framework/config"
"github.com/smartcontractkit/chainlink-testing-framework/k8s/environment"
pkg_seth "github.com/smartcontractkit/chainlink-testing-framework/seth"
)

var ErrInsufficientEphemeralKeys = `
Expand Down

0 comments on commit 070a96e

Please sign in to comment.