simplify generated code for list of library dependencies

This commit is contained in:
Jared Wasinger 2024-11-26 17:41:18 +07:00 committed by Felix Lange
parent 0bdf69cbc6
commit b612cab7f1
3 changed files with 20 additions and 29 deletions

View File

@ -38,10 +38,9 @@ var (
{{end}}
{{range $contract := .Contracts}}
// TODO: turn this into a list, now that the pattern is embedded in each MetaData object
var {{$contract.Type}}LibraryDeps = map[string]*bind.MetaData{
var {{$contract.Type}}LibraryDeps = []*bind.MetaData{
{{range $name, $pattern := .AllLibraries -}}
"{{$pattern}}": {{$name}}MetaData,
{{$name}}MetaData,
{{ end}}
}

View File

@ -23,12 +23,11 @@ var (
_ = abi.ConvertType
)
// TODO: turn this into a list, now that the pattern is embedded in each MetaData object
var C1LibraryDeps = map[string]*bind.MetaData{
"ffc1393672b8ed81d0c8093ffcb0e7fbe8": L1MetaData,
"2ce896a6dd38932d354f317286f90bc675": L2MetaData,
"d03b97f5e1a564374023a72ac7d1806773": L3MetaData,
"5f33a1fab8ea7d932b4bc8c5e7dcd90bc2": L4MetaData,
var C1LibraryDeps = []*bind.MetaData{
L1MetaData,
L2MetaData,
L3MetaData,
L4MetaData,
}
// TODO: convert this type to value type after everything works.
@ -80,11 +79,10 @@ func (_C1 *C1) UnpackDo(data []byte) (*big.Int, error) {
}
// TODO: turn this into a list, now that the pattern is embedded in each MetaData object
var C2LibraryDeps = map[string]*bind.MetaData{
"ffc1393672b8ed81d0c8093ffcb0e7fbe8": L1MetaData,
"fd1474cf57f7ed48491e8bfdfd0d172adf": L2bMetaData,
"6070639404c39b5667691bb1f9177e1eac": L4bMetaData,
var C2LibraryDeps = []*bind.MetaData{
L1MetaData,
L2bMetaData,
L4bMetaData,
}
// TODO: convert this type to value type after everything works.
@ -136,8 +134,7 @@ func (_C2 *C2) UnpackDo(data []byte) (*big.Int, error) {
}
// TODO: turn this into a list, now that the pattern is embedded in each MetaData object
var L1LibraryDeps = map[string]*bind.MetaData{}
var L1LibraryDeps = []*bind.MetaData{}
// TODO: convert this type to value type after everything works.
// L1MetaData contains all meta data concerning the L1 contract.
@ -188,8 +185,7 @@ func (_L1 *L1) UnpackDo(data []byte) (*big.Int, error) {
}
// TODO: turn this into a list, now that the pattern is embedded in each MetaData object
var L2LibraryDeps = map[string]*bind.MetaData{}
var L2LibraryDeps = []*bind.MetaData{}
// TODO: convert this type to value type after everything works.
// L2MetaData contains all meta data concerning the L2 contract.
@ -240,8 +236,7 @@ func (_L2 *L2) UnpackDo(data []byte) (*big.Int, error) {
}
// TODO: turn this into a list, now that the pattern is embedded in each MetaData object
var L2bLibraryDeps = map[string]*bind.MetaData{}
var L2bLibraryDeps = []*bind.MetaData{}
// TODO: convert this type to value type after everything works.
// L2bMetaData contains all meta data concerning the L2b contract.
@ -292,8 +287,7 @@ func (_L2b *L2b) UnpackDo(data []byte) (*big.Int, error) {
}
// TODO: turn this into a list, now that the pattern is embedded in each MetaData object
var L3LibraryDeps = map[string]*bind.MetaData{}
var L3LibraryDeps = []*bind.MetaData{}
// TODO: convert this type to value type after everything works.
// L3MetaData contains all meta data concerning the L3 contract.
@ -344,8 +338,7 @@ func (_L3 *L3) UnpackDo(data []byte) (*big.Int, error) {
}
// TODO: turn this into a list, now that the pattern is embedded in each MetaData object
var L4LibraryDeps = map[string]*bind.MetaData{}
var L4LibraryDeps = []*bind.MetaData{}
// TODO: convert this type to value type after everything works.
// L4MetaData contains all meta data concerning the L4 contract.
@ -396,8 +389,7 @@ func (_L4 *L4) UnpackDo(data []byte) (*big.Int, error) {
}
// TODO: turn this into a list, now that the pattern is embedded in each MetaData object
var L4bLibraryDeps = map[string]*bind.MetaData{}
var L4bLibraryDeps = []*bind.MetaData{}
// TODO: convert this type to value type after everything works.
// L4bMetaData contains all meta data concerning the L4b contract.

View File

@ -127,7 +127,7 @@ type DeploymentParams struct {
Contracts []ContractDeployParams
// Libraries is a map of pattern to metadata for library contracts that
// are to be deployed.
Libraries map[string]*bind.MetaData
Libraries []*bind.MetaData
// Overrides is an optional map of pattern to deployment address.
// Contracts/libraries that refer to dependencies in the override
// set are linked to the provided address (an already-deployed contract).
@ -156,8 +156,8 @@ func LinkAndDeploy(auth *bind.TransactOpts, backend bind.ContractBackend, deploy
// re-express libraries as a map of pattern -> pre-link binary
pending := make(map[string]string)
for pattern, meta := range libMetas {
pending[pattern] = meta.Bin
for _, meta := range libMetas {
pending[meta.Pattern] = meta.Bin
}
// initialize the set of already-deployed contracts with given override addresses