Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling return failures #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# go-multicall
![coverage](https://img.shields.io/badge/coverage-87.7%25-brightgreen)
![build](https://github.com/forta-network/go-multicall/actions/workflows/build.yml/badge.svg)
![build](https://github.com/xiangxn/go-multicall/actions/workflows/build.yml/badge.svg)

A thin Go client for making multiple function calls in single `eth_call` request

Expand All @@ -12,7 +12,7 @@ _**Warning:** MakerDAO Multicall contracts are different than the [OpenZeppelin
## Install

```
go get github.com/forta-network/go-multicall
go get github.com/xiangxn/go-multicall
```

## Example
Expand All @@ -27,7 +27,7 @@ import (
"fmt"
"math/big"

"github.com/forta-network/go-multicall"
"github.com/xiangxn/go-multicall"
"github.com/ethereum/go-ethereum/common"
)

Expand Down
5 changes: 4 additions & 1 deletion caller.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/forta-network/go-multicall/contracts/contract_multicall"
"github.com/xiangxn/go-multicall/contracts/contract_multicall"
)

// DefaultAddress is the same for all chains (Multicall3).
Expand Down Expand Up @@ -69,6 +69,9 @@ func (caller *Caller) Call(opts *bind.CallOpts, calls ...*Call) ([]*Call, error)
for i, result := range results {
call := calls[i] // index always matches
call.Failed = !result.Success
if call.Failed {
continue
}
if err := call.Unpack(result.ReturnData); err != nil {
return calls, fmt.Errorf("failed to unpack call outputs at index [%d]: %v", i, err)
}
Expand Down
2 changes: 1 addition & 1 deletion caller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/forta-network/go-multicall/contracts/contract_multicall"
"github.com/stretchr/testify/require"
"github.com/xiangxn/go-multicall/contracts/contract_multicall"
)

type testType struct {
Expand Down
2 changes: 1 addition & 1 deletion examples/agent_registry/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"math/big"

"github.com/ethereum/go-ethereum/common"
"github.com/forta-network/go-multicall"
"github.com/xiangxn/go-multicall"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion examples/balance/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"math/big"

"github.com/ethereum/go-ethereum/common"
"github.com/forta-network/go-multicall"
"github.com/xiangxn/go-multicall"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/forta-network/go-multicall
module github.com/xiangxn/go-multicall

go 1.19

Expand Down