accounts/abi: rename MetaData field 'Id' to 'ID'
This commit is contained in:
parent
7fc8c6d553
commit
3eb1f8ab7f
|
@ -37,9 +37,9 @@ var (
|
||||||
var {{.Type}}MetaData = bind.MetaData{
|
var {{.Type}}MetaData = bind.MetaData{
|
||||||
ABI: "{{.InputABI}}",
|
ABI: "{{.InputABI}}",
|
||||||
{{if (index $.Libraries .Type) -}}
|
{{if (index $.Libraries .Type) -}}
|
||||||
Id: "{{index $.Libraries .Type}}",
|
ID: "{{index $.Libraries .Type}}",
|
||||||
{{ else -}}
|
{{ else -}}
|
||||||
Id: "{{.Type}}",
|
ID: "{{.Type}}",
|
||||||
{{end -}}
|
{{end -}}
|
||||||
{{if .InputBin -}}
|
{{if .InputBin -}}
|
||||||
Bin: "0x{{.InputBin}}",
|
Bin: "0x{{.InputBin}}",
|
||||||
|
|
|
@ -93,7 +93,7 @@ type MetaData struct {
|
||||||
ABI string // the raw ABI definition (JSON)
|
ABI string // the raw ABI definition (JSON)
|
||||||
Deps []*MetaData // library dependencies of the contract
|
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
|
// of the hex encoding of the keccak256
|
||||||
// hash of the fully qualified 'library name', i.e. the path of the source file.
|
// 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).
|
// 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
|
// 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
|
// contracts during deployment using
|
||||||
// [LinkAndDeploy].
|
// [LinkAndDeploy].
|
||||||
Id string
|
ID string
|
||||||
|
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
parsedABI *abi.ABI
|
parsedABI *abi.ABI
|
||||||
|
|
|
@ -29,7 +29,7 @@ type DeploymentParams struct {
|
||||||
func (d *DeploymentParams) validate() error {
|
func (d *DeploymentParams) validate() error {
|
||||||
for _, meta := range d.Contracts {
|
for _, meta := range d.Contracts {
|
||||||
if meta.Bin == "" {
|
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
|
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.
|
// The deployment result (deploy addresses/txs or an error) is stored in the depTreeDeployer object.
|
||||||
func (d *depTreeDeployer) linkAndDeploy(metadata *MetaData) (common.Address, error) {
|
func (d *depTreeDeployer) linkAndDeploy(metadata *MetaData) (common.Address, error) {
|
||||||
// Don't deploy already deployed contracts
|
// 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
|
return addr, nil
|
||||||
}
|
}
|
||||||
// if this contract/library depends on other libraries deploy them (and their dependencies) first
|
// 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
|
return common.Address{}, err
|
||||||
}
|
}
|
||||||
// link their deployed addresses into the bytecode to produce
|
// 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.
|
// Finally, deploy the contract.
|
||||||
code, err := hex.DecodeString(deployerCode[2:])
|
code, err := hex.DecodeString(deployerCode[2:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Sprintf("error decoding contract deployer hex %s:\n%v", deployerCode[2:], err))
|
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 {
|
if err != nil {
|
||||||
return common.Address{}, err
|
return common.Address{}, err
|
||||||
}
|
}
|
||||||
d.deployedAddrs[metadata.Id] = addr
|
d.deployedAddrs[metadata.ID] = addr
|
||||||
d.deployerTxs[metadata.Id] = tx
|
d.deployerTxs[metadata.ID] = tx
|
||||||
return addr, nil
|
return addr, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ func copyMetaData(m *MetaData) *MetaData {
|
||||||
Bin: m.Bin,
|
Bin: m.Bin,
|
||||||
ABI: m.ABI,
|
ABI: m.ABI,
|
||||||
Deps: deps,
|
Deps: deps,
|
||||||
Id: m.Id,
|
ID: m.ID,
|
||||||
mu: sync.Mutex{},
|
mu: sync.Mutex{},
|
||||||
parsedABI: m.parsedABI,
|
parsedABI: m.parsedABI,
|
||||||
}
|
}
|
||||||
|
@ -200,12 +200,12 @@ func testLinkCase(tcInput linkTestCaseInput) error {
|
||||||
overrides := make(map[string]common.Address)
|
overrides := make(map[string]common.Address)
|
||||||
|
|
||||||
for pattern, bin := range tc.contractCodes {
|
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 {
|
for pattern, bin := range tc.libCodes {
|
||||||
contracts[pattern] = &MetaData{
|
contracts[pattern] = &MetaData{
|
||||||
Bin: "0x" + bin,
|
Bin: "0x" + bin,
|
||||||
Id: pattern,
|
ID: pattern,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,7 @@ func TestDeploymentLibraries(t *testing.T) {
|
||||||
constructorInput := c.PackConstructor(big.NewInt(42), big.NewInt(1))
|
constructorInput := c.PackConstructor(big.NewInt(42), big.NewInt(1))
|
||||||
deploymentParams := &bind.DeploymentParams{
|
deploymentParams := &bind.DeploymentParams{
|
||||||
Contracts: []*bind.MetaData{&nested_libraries.C1MetaData},
|
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))
|
res, err := bind.LinkAndDeploy(deploymentParams, makeTestDeployer(opts, bindBackend))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -129,7 +129,7 @@ func TestDeploymentLibraries(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
doInput := c.PackDo(big.NewInt(1))
|
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()}
|
callOpts := &bind.CallOpts{From: common.Address{}, Context: context.Background()}
|
||||||
instance := c.Instance(bindBackend, contractAddr)
|
instance := c.Instance(bindBackend, contractAddr)
|
||||||
internalCallCount, err := bind.Call(instance, callOpts, doInput, c.UnpackDo)
|
internalCallCount, err := bind.Call(instance, callOpts, doInput, c.UnpackDo)
|
||||||
|
@ -177,7 +177,7 @@ func TestDeploymentWithOverrides(t *testing.T) {
|
||||||
// deploy the contract
|
// deploy the contract
|
||||||
deploymentParams = &bind.DeploymentParams{
|
deploymentParams = &bind.DeploymentParams{
|
||||||
Contracts: []*bind.MetaData{&nested_libraries.C1MetaData},
|
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,
|
Overrides: overrides,
|
||||||
}
|
}
|
||||||
res, err = bind.LinkAndDeploy(deploymentParams, makeTestDeployer(opts, bindBackend))
|
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
|
// call the deployed contract and make sure it returns the correct result
|
||||||
doInput := c.PackDo(big.NewInt(1))
|
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)
|
callOpts := new(bind.CallOpts)
|
||||||
internalCallCount, err := bind.Call(instance, callOpts, doInput, c.UnpackDo)
|
internalCallCount, err := bind.Call(instance, callOpts, doInput, c.UnpackDo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -223,12 +223,12 @@ func TestEvents(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
backend.Commit()
|
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)
|
t.Fatalf("WaitDeployed failed %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
c := events.NewC()
|
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)
|
newCBasic1Ch := make(chan *events.CBasic1)
|
||||||
newCBasic2Ch := make(chan *events.CBasic2)
|
newCBasic2Ch := make(chan *events.CBasic2)
|
||||||
|
@ -322,14 +322,14 @@ func TestErrors(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
backend.Commit()
|
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)
|
t.Fatalf("WaitDeployed failed %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
c := solc_errors.NewC()
|
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()
|
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)
|
_, err = bind.Call[struct{}](instance, opts, packedInput, nil)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("expected call to fail")
|
t.Fatalf("expected call to fail")
|
||||||
|
|
Loading…
Reference in New Issue