Skip to content

Commit 0d5774f

Browse files
committed
programmatic verification
1 parent dffaf51 commit 0d5774f

File tree

11 files changed

+355
-30
lines changed

11 files changed

+355
-30
lines changed

framework/cmd/observability/blockscout/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ services:
3030
ETHEREUM_JSONRPC_VARIANT: 'geth'
3131
ETHEREUM_JSONRPC_HTTP_URL: ${BLOCKSCOUT_RPC_URL}
3232
ETHEREUM_JSONRPC_TRACE_URL: ${BLOCKSCOUT_RPC_URL}
33+
CHAIN_ID: ${BLOCKSCOUT_CHAIN_ID:-1337}
3334

3435
visualizer:
3536
extends:
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package blockchain
2+
3+
import (
4+
"fmt"
5+
"github.com/smartcontractkit/chainlink-testing-framework/framework"
6+
)
7+
8+
// VerifyContract wraps the forge verify-contract command.
9+
func VerifyContract(out *Output, address, foundryDir, contractFile, contractName string) error {
10+
args := []string{
11+
"verify-contract",
12+
"--rpc-url", out.Nodes[0].HostHTTPUrl,
13+
"--chain-id",
14+
out.ChainID,
15+
"--compiler-version=0.8.24",
16+
address,
17+
fmt.Sprintf("%s:%s", contractFile, contractName),
18+
"--verifier", "blockscout",
19+
"--verifier-url", "http://localhost/api/",
20+
}
21+
return framework.RunCommandDir(foundryDir, "forge", args...)
22+
}

framework/docker.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,17 @@ func runCommand(name string, args ...string) error {
7777
return cmd.Run()
7878
}
7979

80+
// RunCommandDir executes a command in some directory and prints the output
81+
func RunCommandDir(dir, name string, args ...string) error {
82+
cmd := exec.Command(name, args...)
83+
cmd.Stdout = os.Stdout
84+
cmd.Stderr = os.Stderr
85+
if dir != "" {
86+
cmd.Dir = dir
87+
}
88+
return cmd.Run()
89+
}
90+
8091
// DockerClient wraps a Docker API client and provides convenience methods
8192
type DockerClient struct {
8293
cli *client.Client
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package onchain
2+
3+
import (
4+
"github.com/ethereum/go-ethereum/common"
5+
"github.com/smartcontractkit/chainlink-testing-framework/framework/examples/example_components/onchain/gethwrappers"
6+
"github.com/smartcontractkit/chainlink-testing-framework/seth"
7+
)
8+
9+
func NewCounterDeployment(c *seth.Client, in *Input) (*Output, error) {
10+
if in.Out != nil && in.Out.UseCache {
11+
return in.Out, nil
12+
}
13+
counterABI, err := gethwrappers.GethwrappersMetaData.GetAbi()
14+
if err != nil {
15+
return nil, err
16+
}
17+
dd, err := c.DeployContract(c.NewTXOpts(),
18+
"TestCounter",
19+
*counterABI,
20+
common.FromHex(gethwrappers.GethwrappersMetaData.Bin),
21+
)
22+
if err != nil {
23+
return nil, err
24+
}
25+
out := &Output{
26+
UseCache: true,
27+
// save all the addresses to output, so it can be cached
28+
Addresses: []common.Address{dd.Address},
29+
}
30+
in.Out = out
31+
return out, nil
32+
}

framework/examples/myproject/example_components/onchain/foundry.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[profile.default]
2+
chain_id = "1337"
23
src = "src"
34
out = "out"
45
libs = ["lib"]

framework/examples/myproject/example_components/onchain/gethwrappers/counter.go

Lines changed: 276 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 1eea5bae12ae557d589f9f0f0edae2faa47cb262

framework/examples/myproject/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ replace (
1010
require (
1111
github.com/ethereum/go-ethereum v1.14.11
1212
github.com/go-resty/resty/v2 v2.15.3
13-
github.com/smartcontractkit/chainlink-testing-framework/framework v0.2.13
13+
github.com/smartcontractkit/chainlink-testing-framework/framework v0.3.0
1414
github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.9
1515
github.com/smartcontractkit/chainlink-testing-framework/wasp v1.50.2
1616
github.com/stretchr/testify v1.9.0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[contracts_src]
22
[blockchain_a]
33
type = "anvil"
4-
docker_cmd_params = ["-b", "3"]
4+
docker_cmd_params = ["-b", "1"]

0 commit comments

Comments
 (0)