mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-23 03:41:34 +00:00
rpcbinding: properly add imports for simple types of event parameters
There are two ways of doing this: first one is to emit all notifications parameter data into rpcbindings configuration on compile time (event if the parameter has a simple type), and the second one is to fetch parameter type from the manifest on rpcbinding file generation if needed (we always have manifest at this stage, thus it's not a problem to retrieve necessary information). The latter case is chosen to reduce the bindings configuration file size. Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
This commit is contained in:
parent
19cc6c6369
commit
37af2031bb
4 changed files with 4 additions and 3 deletions
|
@ -13,6 +13,7 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||
"math/big"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
// Hash contains contract hash.
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||
"math/big"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
// Hash contains contract hash.
|
||||
|
|
|
@ -347,8 +347,6 @@ func CompileAndSave(src string, o *Options) ([]byte, error) {
|
|||
eStructName := rpcbinding.ToEventBindingName(e.Name)
|
||||
for _, p := range e.Parameters {
|
||||
pStructName := rpcbinding.ToParameterBindingName(p.Name)
|
||||
// TODO: proper imports handling during bindings generation (see utf8 example).
|
||||
// Probably, we should always add p type to the list of types.
|
||||
if p.ExtendedType != nil {
|
||||
pName := eStructName + "." + pStructName
|
||||
cfg.Types[pName] = *p.ExtendedType
|
||||
|
|
|
@ -693,8 +693,9 @@ func scTemplateToRPC(cfg binding.Config, ctr ContractTmpl, imports map[string]st
|
|||
)
|
||||
if extType, ok = cfg.Types[fullPName]; !ok {
|
||||
extType = binding.ExtendedType{
|
||||
Base: abiEvent.Parameters[i].Type, // TODO: properly handle imports for this case (see utf8 example)
|
||||
Base: abiEvent.Parameters[i].Type,
|
||||
}
|
||||
addETImports(extType, ctr.NamedTypes, imports)
|
||||
}
|
||||
eTmp.Parameters = append(eTmp.Parameters, EventParamTmpl{
|
||||
ParamTmpl: binding.ParamTmpl{
|
||||
|
|
Loading…
Reference in a new issue