mirror of
https://github.com/forta-network/go-multicall.git
synced 2026-05-23 00:09:26 +00:00
Merge c1fc7ff69a into 9467c4ddaa
This commit is contained in:
commit
778cbd2fb0
6 changed files with 11 additions and 8 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
# go-multicall
|
# go-multicall
|
||||||

|

|
||||||

|

|
||||||
|
|
||||||
A thin Go client for making multiple function calls in single `eth_call` request
|
A thin Go client for making multiple function calls in single `eth_call` request
|
||||||
|
|
||||||
|
|
@ -12,7 +12,7 @@ _**Warning:** MakerDAO Multicall contracts are different than the [OpenZeppelin
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
```
|
```
|
||||||
go get github.com/forta-network/go-multicall
|
go get github.com/xiangxn/go-multicall
|
||||||
```
|
```
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
@ -27,7 +27,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/forta-network/go-multicall"
|
"github.com/xiangxn/go-multicall"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/ethclient"
|
"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).
|
// DefaultAddress is the same for all chains (Multicall3).
|
||||||
|
|
@ -69,6 +69,9 @@ func (caller *Caller) Call(opts *bind.CallOpts, calls ...*Call) ([]*Call, error)
|
||||||
for i, result := range results {
|
for i, result := range results {
|
||||||
call := calls[i] // index always matches
|
call := calls[i] // index always matches
|
||||||
call.Failed = !result.Success
|
call.Failed = !result.Success
|
||||||
|
if call.Failed {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if err := call.Unpack(result.ReturnData); err != nil {
|
if err := call.Unpack(result.ReturnData); err != nil {
|
||||||
return calls, fmt.Errorf("failed to unpack call outputs at index [%d]: %v", i, err)
|
return calls, fmt.Errorf("failed to unpack call outputs at index [%d]: %v", i, err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ import (
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/forta-network/go-multicall/contracts/contract_multicall"
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
"github.com/xiangxn/go-multicall/contracts/contract_multicall"
|
||||||
)
|
)
|
||||||
|
|
||||||
type testType struct {
|
type testType struct {
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/forta-network/go-multicall"
|
"github.com/xiangxn/go-multicall"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/forta-network/go-multicall"
|
"github.com/xiangxn/go-multicall"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
||||||
2
go.mod
2
go.mod
|
|
@ -1,4 +1,4 @@
|
||||||
module github.com/forta-network/go-multicall
|
module github.com/xiangxn/go-multicall
|
||||||
|
|
||||||
go 1.19
|
go 1.19
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue