From 3eb1f8ab7f184f215f498b05a5a48adea756ff12 Mon Sep 17 00:00:00 2001 From: Jared Wasinger Date: Mon, 3 Feb 2025 13:59:40 -0800 Subject: [PATCH] accounts/abi: rename MetaData field 'Id' to 'ID' --- accounts/abi/abigen/source2.go.tpl | 4 ++-- accounts/abi/bind/v2/base.go | 6 +++--- accounts/abi/bind/v2/dep_tree.go | 12 ++++++------ accounts/abi/bind/v2/dep_tree_test.go | 6 +++--- accounts/abi/bind/v2/lib_test.go | 18 +++++++++--------- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/accounts/abi/abigen/source2.go.tpl b/accounts/abi/abigen/source2.go.tpl index 6112144f0f..fc28aa9a46 100644 --- a/accounts/abi/abigen/source2.go.tpl +++ b/accounts/abi/abigen/source2.go.tpl @@ -37,9 +37,9 @@ var ( var {{.Type}}MetaData = bind.MetaData{ ABI: "{{.InputABI}}", {{if (index $.Libraries .Type) -}} - Id: "{{index $.Libraries .Type}}", + ID: "{{index $.Libraries .Type}}", {{ else -}} - Id: "{{.Type}}", + ID: "{{.Type}}", {{end -}} {{if .InputBin -}} Bin: "0x{{.InputBin}}", diff --git a/accounts/abi/bind/v2/base.go b/accounts/abi/bind/v2/base.go index 50dd808e9a..9d9a1e4aea 100644 --- a/accounts/abi/bind/v2/base.go +++ b/accounts/abi/bind/v2/base.go @@ -93,7 +93,7 @@ type MetaData struct { ABI string // the raw ABI definition (JSON) Deps []*MetaData // library dependencies of the contract - // For bindings that were compiled from combined-json Id is the Solidity library pattern: a 34 character prefix + // For bindings that were compiled from combined-json ID is the Solidity library pattern: a 34 character prefix // of the hex encoding of the keccak256 // hash of the fully qualified 'library name', i.e. the path of the source file. // @@ -101,10 +101,10 @@ type MetaData struct { // in the ABI definition or overridden via the --type flag). // // This is a unique identifier of a contract within a compilation unit. When used as part of a multi-contract - // deployment with library dependencies, the Id is used to link + // deployment with library dependencies, the ID is used to link // contracts during deployment using // [LinkAndDeploy]. - Id string + ID string mu sync.Mutex parsedABI *abi.ABI diff --git a/accounts/abi/bind/v2/dep_tree.go b/accounts/abi/bind/v2/dep_tree.go index 633ce63d74..bd34cabfeb 100644 --- a/accounts/abi/bind/v2/dep_tree.go +++ b/accounts/abi/bind/v2/dep_tree.go @@ -29,7 +29,7 @@ type DeploymentParams struct { func (d *DeploymentParams) validate() error { for _, meta := range d.Contracts { if meta.Bin == "" { - return fmt.Errorf("cannot deploy contract %s: deployer code missing from metadata", meta.Id) + return fmt.Errorf("cannot deploy contract %s: deployer code missing from metadata", meta.ID) } } return nil @@ -81,7 +81,7 @@ func newDepTreeDeployer(deployParams *DeploymentParams, deployFn DeployFn) *depT // The deployment result (deploy addresses/txs or an error) is stored in the depTreeDeployer object. func (d *depTreeDeployer) linkAndDeploy(metadata *MetaData) (common.Address, error) { // Don't deploy already deployed contracts - if addr, ok := d.deployedAddrs[metadata.Id]; ok { + if addr, ok := d.deployedAddrs[metadata.ID]; ok { return addr, nil } // if this contract/library depends on other libraries deploy them (and their dependencies) first @@ -92,19 +92,19 @@ func (d *depTreeDeployer) linkAndDeploy(metadata *MetaData) (common.Address, err return common.Address{}, err } // link their deployed addresses into the bytecode to produce - deployerCode = strings.ReplaceAll(deployerCode, "__$"+dep.Id+"$__", strings.ToLower(addr.String()[2:])) + deployerCode = strings.ReplaceAll(deployerCode, "__$"+dep.ID+"$__", strings.ToLower(addr.String()[2:])) } // Finally, deploy the contract. code, err := hex.DecodeString(deployerCode[2:]) if err != nil { panic(fmt.Sprintf("error decoding contract deployer hex %s:\n%v", deployerCode[2:], err)) } - addr, tx, err := d.deployFn(d.inputs[metadata.Id], code) + addr, tx, err := d.deployFn(d.inputs[metadata.ID], code) if err != nil { return common.Address{}, err } - d.deployedAddrs[metadata.Id] = addr - d.deployerTxs[metadata.Id] = tx + d.deployedAddrs[metadata.ID] = addr + d.deployerTxs[metadata.ID] = tx return addr, nil } diff --git a/accounts/abi/bind/v2/dep_tree_test.go b/accounts/abi/bind/v2/dep_tree_test.go index 5cc887f891..827ba25518 100644 --- a/accounts/abi/bind/v2/dep_tree_test.go +++ b/accounts/abi/bind/v2/dep_tree_test.go @@ -50,7 +50,7 @@ func copyMetaData(m *MetaData) *MetaData { Bin: m.Bin, ABI: m.ABI, Deps: deps, - Id: m.Id, + ID: m.ID, mu: sync.Mutex{}, parsedABI: m.parsedABI, } @@ -200,12 +200,12 @@ func testLinkCase(tcInput linkTestCaseInput) error { overrides := make(map[string]common.Address) for pattern, bin := range tc.contractCodes { - contracts[pattern] = &MetaData{Id: pattern, Bin: "0x" + bin} + contracts[pattern] = &MetaData{ID: pattern, Bin: "0x" + bin} } for pattern, bin := range tc.libCodes { contracts[pattern] = &MetaData{ Bin: "0x" + bin, - Id: pattern, + ID: pattern, } } diff --git a/accounts/abi/bind/v2/lib_test.go b/accounts/abi/bind/v2/lib_test.go index 8dcddab93f..72fe29954c 100644 --- a/accounts/abi/bind/v2/lib_test.go +++ b/accounts/abi/bind/v2/lib_test.go @@ -110,7 +110,7 @@ func TestDeploymentLibraries(t *testing.T) { constructorInput := c.PackConstructor(big.NewInt(42), big.NewInt(1)) deploymentParams := &bind.DeploymentParams{ Contracts: []*bind.MetaData{&nested_libraries.C1MetaData}, - Inputs: map[string][]byte{nested_libraries.C1MetaData.Id: constructorInput}, + Inputs: map[string][]byte{nested_libraries.C1MetaData.ID: constructorInput}, } res, err := bind.LinkAndDeploy(deploymentParams, makeTestDeployer(opts, bindBackend)) if err != nil { @@ -129,7 +129,7 @@ func TestDeploymentLibraries(t *testing.T) { } doInput := c.PackDo(big.NewInt(1)) - contractAddr := res.Addrs[nested_libraries.C1MetaData.Id] + contractAddr := res.Addrs[nested_libraries.C1MetaData.ID] callOpts := &bind.CallOpts{From: common.Address{}, Context: context.Background()} instance := c.Instance(bindBackend, contractAddr) internalCallCount, err := bind.Call(instance, callOpts, doInput, c.UnpackDo) @@ -177,7 +177,7 @@ func TestDeploymentWithOverrides(t *testing.T) { // deploy the contract deploymentParams = &bind.DeploymentParams{ Contracts: []*bind.MetaData{&nested_libraries.C1MetaData}, - Inputs: map[string][]byte{nested_libraries.C1MetaData.Id: constructorInput}, + Inputs: map[string][]byte{nested_libraries.C1MetaData.ID: constructorInput}, Overrides: overrides, } res, err = bind.LinkAndDeploy(deploymentParams, makeTestDeployer(opts, bindBackend)) @@ -198,7 +198,7 @@ func TestDeploymentWithOverrides(t *testing.T) { // call the deployed contract and make sure it returns the correct result doInput := c.PackDo(big.NewInt(1)) - instance := c.Instance(bindBackend, res.Addrs[nested_libraries.C1MetaData.Id]) + instance := c.Instance(bindBackend, res.Addrs[nested_libraries.C1MetaData.ID]) callOpts := new(bind.CallOpts) internalCallCount, err := bind.Call(instance, callOpts, doInput, c.UnpackDo) if err != nil { @@ -223,12 +223,12 @@ func TestEvents(t *testing.T) { } backend.Commit() - if _, err := bind.WaitDeployed(context.Background(), backend, res.Txs[events.CMetaData.Id].Hash()); err != nil { + if _, err := bind.WaitDeployed(context.Background(), backend, res.Txs[events.CMetaData.ID].Hash()); err != nil { t.Fatalf("WaitDeployed failed %v", err) } c := events.NewC() - instance := c.Instance(backend, res.Addrs[events.CMetaData.Id]) + instance := c.Instance(backend, res.Addrs[events.CMetaData.ID]) newCBasic1Ch := make(chan *events.CBasic1) newCBasic2Ch := make(chan *events.CBasic2) @@ -322,14 +322,14 @@ func TestErrors(t *testing.T) { } backend.Commit() - if _, err := bind.WaitDeployed(context.Background(), backend, res.Txs[solc_errors.CMetaData.Id].Hash()); err != nil { + if _, err := bind.WaitDeployed(context.Background(), backend, res.Txs[solc_errors.CMetaData.ID].Hash()); err != nil { t.Fatalf("WaitDeployed failed %v", err) } c := solc_errors.NewC() - instance := c.Instance(backend, res.Addrs[solc_errors.CMetaData.Id]) + instance := c.Instance(backend, res.Addrs[solc_errors.CMetaData.ID]) packedInput := c.PackFoo() - opts := &bind.CallOpts{From: res.Addrs[solc_errors.CMetaData.Id]} + opts := &bind.CallOpts{From: res.Addrs[solc_errors.CMetaData.ID]} _, err = bind.Call[struct{}](instance, opts, packedInput, nil) if err == nil { t.Fatalf("expected call to fail")