Merge pull request #3299 from nspcc-dev/autogeneration-linter

smartcontract: fix generation of nns wrapper for follow Go naming
This commit is contained in:
Anna Shaleva 2024-01-26 12:50:35 +03:00 committed by GitHub
commit 36b89215ab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 17 deletions

View file

@ -174,8 +174,8 @@ func Sum(first int, second int) int {
return neogointernal.CallWithToken(Hash, "sum", int(contract.All), first, second).(int) return neogointernal.CallWithToken(Hash, "sum", int(contract.All), first, second).(int)
} }
// Sum_3 invokes ` + "`sum`" + ` method of contract. // Sum2 invokes ` + "`sum`" + ` method of contract.
func Sum_3(first int, second int, third int) int { func Sum2(first int, second int, third int) int {
return neogointernal.CallWithToken(Hash, "sum", int(contract.All), first, second, third).(int) return neogointernal.CallWithToken(Hash, "sum", int(contract.All), first, second, third).(int)
} }

View file

@ -256,25 +256,25 @@ func (c *Contract) RenewUnsigned(name string) (*transaction.Transaction, error)
return c.actor.MakeUnsignedCall(c.hash, "renew", nil, name) return c.actor.MakeUnsignedCall(c.hash, "renew", nil, name)
} }
// Renew_2 creates a transaction invoking `renew` method of the contract. // Renew2 creates a transaction invoking `renew` method of the contract.
// This transaction is signed and immediately sent to the network. // This transaction is signed and immediately sent to the network.
// The values returned are its hash, ValidUntilBlock value and error if any. // The values returned are its hash, ValidUntilBlock value and error if any.
func (c *Contract) Renew_2(name string, years *big.Int) (util.Uint256, uint32, error) { func (c *Contract) Renew2(name string, years *big.Int) (util.Uint256, uint32, error) {
return c.actor.SendCall(c.hash, "renew", name, years) return c.actor.SendCall(c.hash, "renew", name, years)
} }
// Renew_2Transaction creates a transaction invoking `renew` method of the contract. // Renew2Transaction creates a transaction invoking `renew` method of the contract.
// This transaction is signed, but not sent to the network, instead it's // This transaction is signed, but not sent to the network, instead it's
// returned to the caller. // returned to the caller.
func (c *Contract) Renew_2Transaction(name string, years *big.Int) (*transaction.Transaction, error) { func (c *Contract) Renew2Transaction(name string, years *big.Int) (*transaction.Transaction, error) {
return c.actor.MakeCall(c.hash, "renew", name, years) return c.actor.MakeCall(c.hash, "renew", name, years)
} }
// Renew_2Unsigned creates a transaction invoking `renew` method of the contract. // Renew2Unsigned creates a transaction invoking `renew` method of the contract.
// This transaction is not signed, it's simply returned to the caller. // This transaction is not signed, it's simply returned to the caller.
// Any fields of it that do not affect fees can be changed (ValidUntilBlock, // Any fields of it that do not affect fees can be changed (ValidUntilBlock,
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well. // Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
func (c *Contract) Renew_2Unsigned(name string, years *big.Int) (*transaction.Transaction, error) { func (c *Contract) Renew2Unsigned(name string, years *big.Int) (*transaction.Transaction, error) {
return c.actor.MakeUnsignedCall(c.hash, "renew", nil, name, years) return c.actor.MakeUnsignedCall(c.hash, "renew", nil, name, years)
} }

View file

@ -234,16 +234,11 @@ func TemplateFromManifest(cfg Config, scTypeConverter func(string, smartcontract
// Consider `perform(a)` and `perform(a, b)` methods. // Consider `perform(a)` and `perform(a, b)` methods.
// First, try to export the second method with `Perform2` name. // First, try to export the second method with `Perform2` name.
// If `perform2` is already in the manifest, use `perform_2` with as many underscores // If `perform2` is already in the manifest, use `perform3` with uprising suffix as many times
// as needed to eliminate name conflicts. It will produce long names in certain circumstances, // as needed to eliminate name conflicts. If `perform3` is already in the manifest, use `perform4` etc.
// but if the manifest contains lots of similar names with trailing underscores, delicate naming
// was probably not the goal.
name := m.Name name := m.Name
if v, ok := seen[name]; !ok || v { for suffix := 2; seen[name]; suffix++ {
suffix := strconv.Itoa(len(m.Parameters)) name = m.Name + strconv.Itoa(suffix)
for ; seen[name]; name = m.Name + suffix {
suffix = "_" + suffix
}
} }
seen[name] = true seen[name] = true