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

Arbitrum SDK #1116

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f57b68b
nitro
trajan0x Jul 7, 2023
2f67189
rm nitro
trajan0x Jul 7, 2023
07e0c27
nitro-contracts
trajan0x Jul 7, 2023
4796cd9
Revert "nitro-contracts"
trajan0x Jul 7, 2023
9cd2969
Revert "Revert "nitro-contracts""
trajan0x Jul 7, 2023
42105ed
node interface first pass
trajan0x Jul 7, 2023
b51a1b1
another one
trajan0x Jul 7, 2023
1878483
more session
trajan0x Jul 7, 2023
22d292a
Revert "more session"
trajan0x Jul 7, 2023
81fbabe
more arbgas
trajan0x Jul 7, 2023
a7cac0e
Merge branch 'master' into feat/arb-sdk
trajan0x Jul 7, 2023
81f5504
lint fix
trajan0x Jul 7, 2023
adc439b
add some new checks for ci flake
trajan0x Jul 7, 2023
106e84e
backup
trajan0x Jul 7, 2023
76278d9
Merge branch 'master' into feat/arb-sdk
trajan0x Jul 26, 2023
1e07031
Merge branch 'master' into feat/arb-sdk
trajan0x Jul 29, 2023
a6f343b
Merge branch 'feat/arb-sdk' of https://github.com/synapsecns/sanguine…
trajan0x Jul 30, 2023
bb9e88c
Merge branch 'master' into feat/arb-sdk
trajan0x Jul 30, 2023
865179e
Merge branch 'master' into feat/arb-sdk
trajan0x Aug 7, 2023
53dae85
Merge branch 'master' into feat/arb-sdk
trajan0x Aug 22, 2023
f7d9992
Merge branch 'master' into feat/arb-sdk
dwasse Feb 7, 2024
f50c1a8
Fix: arbitrum sdk build
dwasse Feb 7, 2024
8eb138d
Cleanup: lint
dwasse Feb 7, 2024
dadf7aa
Cleanup: lint
dwasse Feb 7, 2024
3c147fd
Feat: only run anvil tests when CI is false
dwasse Feb 7, 2024
1452abf
Add CI=true to go workflow
dwasse Feb 8, 2024
a4e3fa2
Fix: check for testDone in explorer tests
dwasse Feb 8, 2024
75c7fc8
Merge branch 'master' into feat/arb-sdk
dwasse Feb 8, 2024
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
[submodule "services/cctp-relayer/external/synapse-contracts"]
path = services/cctp-relayer/external/synapse-contracts
url = https://github.com/synapsecns/synapse-contracts
[submodule "ethergo/internal/nitro-contracts"]
path = ethergo/internal/nitro-contracts
url = https://github.com/OffchainLabs/nitro-contracts
[submodule "packages/contracts-core/lib/create3-factory"]
path = packages/contracts-core/lib/create3-factory
url = https://github.com/zeframlou/create3-factory
Expand Down
5 changes: 5 additions & 0 deletions ethergo/chain/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Chain

The chain module contains deprecated implementations of many commom utilities for interacting with the chain. While this module will be excised in due course from internal libs, it should not be used in any new code.

Feel free to duplicate any functionality from this module on the assumption it will be deleted.
1 change: 1 addition & 0 deletions ethergo/internal/nitro-contracts
Submodule nitro-contracts added at 2ba206
16 changes: 16 additions & 0 deletions ethergo/parser/abiutil/selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package abiutil

import (
"fmt"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"strings"
Expand Down Expand Up @@ -59,3 +60,18 @@ func GetStringSelectorByName(name string, metadata *bind.MetaData) (string, erro
// extract the function selector bytes from the only matching testContract
return matchingSigs[0], nil
}

// MustGetMethodByName gets all the method metadata.
func MustGetMethodByName(name string, metadata *bind.MetaData) abi.Method {
cabi, err := metadata.GetAbi()
if err != nil {
panic(err)
}

method, ok := cabi.Methods[name]
if !ok {
panic(fmt.Errorf("no method with name %s", name))
}

return method
}
4 changes: 4 additions & 0 deletions ethergo/parser/abiutil/selector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ func (a *AbiSuite) getSelectorSuccesful(name string, metadata *bind.MetaData) [4
selector2 := abiutil.MustGetSelectorByName(name, metadata)
a.Require().Equal(selector, selector2)

realMethod := abiutil.MustGetMethodByName(name, metadata)
a.Require().NoError(err)
a.Require().Equal(realMethod.ID, selector2[:])

return selector
}

Expand Down
746 changes: 746 additions & 0 deletions ethergo/sdks/arbitrum/contracts/arbgasinfo/arbgasinfo.abigen.go

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions ethergo/sdks/arbitrum/contracts/arbgasinfo/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Package arbgasinfo contains the interface to the pre-compiled gas price contract for the Arbitrum chain.
//
// ArbGasInfo contains the interface for a pre-compile used by arbitrum for l2 gas estimation. Documentation is here: https://developer.arbitrum.io/devs-how-tos/how-to-estimate-gas#an-example-of-how-to-apply-this-formula-in-your-code
// therefore: this cannot be deployed w/ deployers, but merely mocked or called via rpc. For this same reason, we do not need to return Filterers. As this contract does not actually exist.
package arbgasinfo
6 changes: 6 additions & 0 deletions ethergo/sdks/arbitrum/contracts/arbgasinfo/generate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package arbgasinfo

//go:generate go run github.com/synapsecns/sanguine/tools/abigen generate --sol ../../../../internal/nitro-contracts/src/precompiles/ArbGasInfo.sol --pkg arbgasinfo --sol-version 0.8.17 --filename arbgasinfo
// here we generate some interfaces we use in for our mocks. TODO this should be automated in abigen for all contracts + be condensed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Address the TODO comment regarding the automation of interface generation in abigen. Consider implementing the automation or creating a tracking issue to address this in the future.

Would you like me to open a GitHub issue to track this task?

//go:generate go run github.com/vburenin/ifacemaker -f arbgasinfo.abigen.go -s ArbGasInfoCaller -i IArbGasInfoCaller -p arbgasinfo -o icaller_generated.go -c "autogenerated file"
//go:generate go run github.com/vektra/mockery/v2 --name IArbGasInfoCaller --output ./mocks --case=underscore
38 changes: 38 additions & 0 deletions ethergo/sdks/arbitrum/contracts/arbgasinfo/helpers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package arbgasinfo

import (
"fmt"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
)

// ArbGasInfoRef is a reference to a ArbGasInfo contract.
//
// nolint: golint
type ArbGasInfoRef struct {
*ArbGasInfo
address common.Address
}

// Address gets the address of the contract.
func (a ArbGasInfoRef) Address() common.Address {
return a.address
}

// NewArbGasInfoRef creates a new ArbGasInfoRef bound to a contract.
func NewArbGasInfoRef(address common.Address, backend bind.ContractBackend) (IArbGasInfo, error) {
gasInfo, err := NewArbGasInfo(address, backend)
if err != nil {
return nil, fmt.Errorf("failed to instantiate ArbGasInfo contract: %w", err)
}

return &ArbGasInfoRef{
ArbGasInfo: gasInfo,
address: address,
}, nil
}

// IArbGasInfo is a thin wrapper around ArbGasInfoCaller that allows interfacing with the contract.
type IArbGasInfo interface {
IArbGasInfoCaller
}
82 changes: 82 additions & 0 deletions ethergo/sdks/arbitrum/contracts/arbgasinfo/icaller_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading