Merge pull request #3164 from nspcc-dev/pretty-generator

Apply `gofmt` to autogenerated bindings
This commit is contained in:
Roman Khimov 2023-10-18 18:41:32 +03:00 committed by GitHub
commit ef2bc7ca04
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 784 additions and 757 deletions

View file

@ -386,7 +386,7 @@ func (e *SetAdminEvent) FromStackItem(item *stackitem.Array) error {
err error
)
index++
e.Name, err = func (item stackitem.Item) (string, error) {
e.Name, err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
@ -395,13 +395,13 @@ func (e *SetAdminEvent) FromStackItem(item *stackitem.Array) error {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Name: %w", err)
}
index++
e.OldAdmin, err = func (item stackitem.Item) (util.Uint160, error) {
e.OldAdmin, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -411,13 +411,13 @@ func (e *SetAdminEvent) FromStackItem(item *stackitem.Array) error {
return util.Uint160{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field OldAdmin: %w", err)
}
index++
e.NewAdmin, err = func (item stackitem.Item) (util.Uint160, error) {
e.NewAdmin, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -427,7 +427,7 @@ func (e *SetAdminEvent) FromStackItem(item *stackitem.Array) error {
return util.Uint160{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field NewAdmin: %w", err)
}
@ -479,7 +479,7 @@ func (e *RenewEvent) FromStackItem(item *stackitem.Array) error {
err error
)
index++
e.Name, err = func (item stackitem.Item) (string, error) {
e.Name, err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
@ -488,7 +488,7 @@ func (e *RenewEvent) FromStackItem(item *stackitem.Array) error {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Name: %w", err)
}

View file

@ -290,7 +290,7 @@ func (e *OnMintEvent) FromStackItem(item *stackitem.Array) error {
err error
)
index++
e.From, err = func (item stackitem.Item) (util.Uint160, error) {
e.From, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -300,13 +300,13 @@ func (e *OnMintEvent) FromStackItem(item *stackitem.Array) error {
return util.Uint160{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field From: %w", err)
}
index++
e.To, err = func (item stackitem.Item) (util.Uint160, error) {
e.To, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -316,7 +316,7 @@ func (e *OnMintEvent) FromStackItem(item *stackitem.Array) error {
return util.Uint160{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field To: %w", err)
}

View file

@ -260,7 +260,7 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error {
err error
)
index++
res.Hash, err = func (item stackitem.Item) (util.Uint256, error) {
res.Hash, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -270,7 +270,7 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Hash: %w", err)
}
@ -282,7 +282,7 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error {
}
index++
res.PrevHash, err = func (item stackitem.Item) (util.Uint256, error) {
res.PrevHash, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -292,13 +292,13 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field PrevHash: %w", err)
}
index++
res.MerkleRoot, err = func (item stackitem.Item) (util.Uint256, error) {
res.MerkleRoot, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -308,7 +308,7 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field MerkleRoot: %w", err)
}
@ -332,7 +332,7 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error {
}
index++
res.NextConsensus, err = func (item stackitem.Item) (util.Uint160, error) {
res.NextConsensus, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -342,7 +342,7 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error {
return util.Uint160{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field NextConsensus: %w", err)
}
@ -382,7 +382,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
err error
)
index++
res.Hash, err = func (item stackitem.Item) (util.Uint256, error) {
res.Hash, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -392,7 +392,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Hash: %w", err)
}
@ -404,7 +404,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
}
index++
res.PrevHash, err = func (item stackitem.Item) (util.Uint256, error) {
res.PrevHash, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -414,13 +414,13 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field PrevHash: %w", err)
}
index++
res.MerkleRoot, err = func (item stackitem.Item) (util.Uint256, error) {
res.MerkleRoot, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -430,7 +430,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field MerkleRoot: %w", err)
}
@ -454,7 +454,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
}
index++
res.NextConsensus, err = func (item stackitem.Item) (util.Uint160, error) {
res.NextConsensus, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -464,7 +464,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
return util.Uint160{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field NextConsensus: %w", err)
}
@ -476,7 +476,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
}
index++
res.PrevStateRoot, err = func (item stackitem.Item) (util.Uint256, error) {
res.PrevStateRoot, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -486,7 +486,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field PrevStateRoot: %w", err)
}
@ -520,7 +520,7 @@ func (res *LedgerTransaction) FromStackItem(item stackitem.Item) error {
err error
)
index++
res.Hash, err = func (item stackitem.Item) (util.Uint256, error) {
res.Hash, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -530,7 +530,7 @@ func (res *LedgerTransaction) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Hash: %w", err)
}
@ -548,7 +548,7 @@ func (res *LedgerTransaction) FromStackItem(item stackitem.Item) error {
}
index++
res.Sender, err = func (item stackitem.Item) (util.Uint160, error) {
res.Sender, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -558,7 +558,7 @@ func (res *LedgerTransaction) FromStackItem(item stackitem.Item) error {
return util.Uint160{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Sender: %w", err)
}
@ -616,7 +616,7 @@ func (res *LedgerTransactionSigner) FromStackItem(item stackitem.Item) error {
err error
)
index++
res.Account, err = func (item stackitem.Item) (util.Uint160, error) {
res.Account, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -626,7 +626,7 @@ func (res *LedgerTransactionSigner) FromStackItem(item stackitem.Item) error {
return util.Uint160{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Account: %w", err)
}
@ -638,14 +638,14 @@ func (res *LedgerTransactionSigner) FromStackItem(item stackitem.Item) error {
}
index++
res.AllowedContracts, err = func (item stackitem.Item) ([]util.Uint160, error) {
res.AllowedContracts, err = func(item stackitem.Item) ([]util.Uint160, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
}
res := make([]util.Uint160, len(arr))
for i := range res {
res[i], err = func (item stackitem.Item) (util.Uint160, error) {
res[i], err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -655,26 +655,26 @@ func (res *LedgerTransactionSigner) FromStackItem(item stackitem.Item) error {
return util.Uint160{}, err
}
return u, nil
} (arr[i])
}(arr[i])
if err != nil {
return nil, fmt.Errorf("item %d: %w", i, err)
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field AllowedContracts: %w", err)
}
index++
res.AllowedGroups, err = func (item stackitem.Item) (keys.PublicKeys, error) {
res.AllowedGroups, err = func(item stackitem.Item) (keys.PublicKeys, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
}
res := make(keys.PublicKeys, len(arr))
for i := range res {
res[i], err = func (item stackitem.Item) (*keys.PublicKey, error) {
res[i], err = func(item stackitem.Item) (*keys.PublicKey, error) {
b, err := item.TryBytes()
if err != nil {
return nil, err
@ -684,19 +684,19 @@ func (res *LedgerTransactionSigner) FromStackItem(item stackitem.Item) error {
return nil, err
}
return k, nil
} (arr[i])
}(arr[i])
if err != nil {
return nil, fmt.Errorf("item %d: %w", i, err)
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field AllowedGroups: %w", err)
}
index++
res.Rules, err = func (item stackitem.Item) ([]*LedgerWitnessRule, error) {
res.Rules, err = func(item stackitem.Item) ([]*LedgerWitnessRule, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
@ -709,7 +709,7 @@ func (res *LedgerTransactionSigner) FromStackItem(item stackitem.Item) error {
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Rules: %w", err)
}
@ -841,7 +841,7 @@ func (e *ComplicatedNameEvent) FromStackItem(item *stackitem.Array) error {
err error
)
index++
e.ComplicatedParam, err = func (item stackitem.Item) (string, error) {
e.ComplicatedParam, err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
@ -850,7 +850,7 @@ func (e *ComplicatedNameEvent) FromStackItem(item *stackitem.Array) error {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field ComplicatedParam: %w", err)
}
@ -902,7 +902,7 @@ func (e *SomeMapEvent) FromStackItem(item *stackitem.Array) error {
err error
)
index++
e.M, err = func (item stackitem.Item) (map[any]any, error) {
e.M, err = func(item stackitem.Item) (map[any]any, error) {
m, ok := item.Value().([]stackitem.MapElement)
if !ok {
return nil, fmt.Errorf("%s is not a map", item.Type().String())
@ -920,7 +920,7 @@ func (e *SomeMapEvent) FromStackItem(item *stackitem.Array) error {
res[k] = v
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field M: %w", err)
}
@ -972,7 +972,7 @@ func (e *SomeStructEvent) FromStackItem(item *stackitem.Array) error {
err error
)
index++
e.S, err = func (item stackitem.Item) ([]any, error) {
e.S, err = func(item stackitem.Item) ([]any, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
@ -985,7 +985,7 @@ func (e *SomeStructEvent) FromStackItem(item *stackitem.Array) error {
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field S: %w", err)
}
@ -1037,7 +1037,7 @@ func (e *SomeArrayEvent) FromStackItem(item *stackitem.Array) error {
err error
)
index++
e.A, err = func (item stackitem.Item) ([]any, error) {
e.A, err = func(item stackitem.Item) ([]any, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
@ -1050,7 +1050,7 @@ func (e *SomeArrayEvent) FromStackItem(item *stackitem.Array) error {
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field A: %w", err)
}
@ -1102,7 +1102,7 @@ func (e *SomeUnexportedFieldEvent) FromStackItem(item *stackitem.Array) error {
err error
)
index++
e.S, err = func (item stackitem.Item) ([]any, error) {
e.S, err = func(item stackitem.Item) ([]any, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
@ -1115,7 +1115,7 @@ func (e *SomeUnexportedFieldEvent) FromStackItem(item *stackitem.Array) error {
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field S: %w", err)
}

View file

@ -311,7 +311,7 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error {
err error
)
index++
res.Hash, err = func (item stackitem.Item) (util.Uint256, error) {
res.Hash, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -321,7 +321,7 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Hash: %w", err)
}
@ -333,7 +333,7 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error {
}
index++
res.PrevHash, err = func (item stackitem.Item) (util.Uint256, error) {
res.PrevHash, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -343,13 +343,13 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field PrevHash: %w", err)
}
index++
res.MerkleRoot, err = func (item stackitem.Item) (util.Uint256, error) {
res.MerkleRoot, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -359,7 +359,7 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field MerkleRoot: %w", err)
}
@ -383,7 +383,7 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error {
}
index++
res.NextConsensus, err = func (item stackitem.Item) (util.Uint160, error) {
res.NextConsensus, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -393,7 +393,7 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error {
return util.Uint160{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field NextConsensus: %w", err)
}
@ -433,7 +433,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
err error
)
index++
res.Hash, err = func (item stackitem.Item) (util.Uint256, error) {
res.Hash, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -443,7 +443,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Hash: %w", err)
}
@ -455,7 +455,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
}
index++
res.PrevHash, err = func (item stackitem.Item) (util.Uint256, error) {
res.PrevHash, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -465,13 +465,13 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field PrevHash: %w", err)
}
index++
res.MerkleRoot, err = func (item stackitem.Item) (util.Uint256, error) {
res.MerkleRoot, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -481,7 +481,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field MerkleRoot: %w", err)
}
@ -505,7 +505,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
}
index++
res.NextConsensus, err = func (item stackitem.Item) (util.Uint160, error) {
res.NextConsensus, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -515,7 +515,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
return util.Uint160{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field NextConsensus: %w", err)
}
@ -527,7 +527,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
}
index++
res.PrevStateRoot, err = func (item stackitem.Item) (util.Uint256, error) {
res.PrevStateRoot, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -537,7 +537,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field PrevStateRoot: %w", err)
}
@ -571,7 +571,7 @@ func (res *LedgerTransaction) FromStackItem(item stackitem.Item) error {
err error
)
index++
res.Hash, err = func (item stackitem.Item) (util.Uint256, error) {
res.Hash, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -581,7 +581,7 @@ func (res *LedgerTransaction) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Hash: %w", err)
}
@ -599,7 +599,7 @@ func (res *LedgerTransaction) FromStackItem(item stackitem.Item) error {
}
index++
res.Sender, err = func (item stackitem.Item) (util.Uint160, error) {
res.Sender, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -609,7 +609,7 @@ func (res *LedgerTransaction) FromStackItem(item stackitem.Item) error {
return util.Uint160{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Sender: %w", err)
}
@ -667,7 +667,7 @@ func (res *LedgerTransactionSigner) FromStackItem(item stackitem.Item) error {
err error
)
index++
res.Account, err = func (item stackitem.Item) (util.Uint160, error) {
res.Account, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -677,7 +677,7 @@ func (res *LedgerTransactionSigner) FromStackItem(item stackitem.Item) error {
return util.Uint160{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Account: %w", err)
}
@ -689,14 +689,14 @@ func (res *LedgerTransactionSigner) FromStackItem(item stackitem.Item) error {
}
index++
res.AllowedContracts, err = func (item stackitem.Item) ([]util.Uint160, error) {
res.AllowedContracts, err = func(item stackitem.Item) ([]util.Uint160, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
}
res := make([]util.Uint160, len(arr))
for i := range res {
res[i], err = func (item stackitem.Item) (util.Uint160, error) {
res[i], err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -706,26 +706,26 @@ func (res *LedgerTransactionSigner) FromStackItem(item stackitem.Item) error {
return util.Uint160{}, err
}
return u, nil
} (arr[i])
}(arr[i])
if err != nil {
return nil, fmt.Errorf("item %d: %w", i, err)
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field AllowedContracts: %w", err)
}
index++
res.AllowedGroups, err = func (item stackitem.Item) (keys.PublicKeys, error) {
res.AllowedGroups, err = func(item stackitem.Item) (keys.PublicKeys, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
}
res := make(keys.PublicKeys, len(arr))
for i := range res {
res[i], err = func (item stackitem.Item) (*keys.PublicKey, error) {
res[i], err = func(item stackitem.Item) (*keys.PublicKey, error) {
b, err := item.TryBytes()
if err != nil {
return nil, err
@ -735,19 +735,19 @@ func (res *LedgerTransactionSigner) FromStackItem(item stackitem.Item) error {
return nil, err
}
return k, nil
} (arr[i])
}(arr[i])
if err != nil {
return nil, fmt.Errorf("item %d: %w", i, err)
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field AllowedGroups: %w", err)
}
index++
res.Rules, err = func (item stackitem.Item) ([]*LedgerWitnessRule, error) {
res.Rules, err = func(item stackitem.Item) ([]*LedgerWitnessRule, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
@ -760,7 +760,7 @@ func (res *LedgerTransactionSigner) FromStackItem(item stackitem.Item) error {
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Rules: %w", err)
}
@ -926,7 +926,7 @@ func (e *ComplicatedNameEvent) FromStackItem(item *stackitem.Array) error {
err error
)
index++
e.ComplicatedParam, err = func (item stackitem.Item) (string, error) {
e.ComplicatedParam, err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
@ -935,7 +935,7 @@ func (e *ComplicatedNameEvent) FromStackItem(item *stackitem.Array) error {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field ComplicatedParam: %w", err)
}
@ -987,7 +987,7 @@ func (e *SomeMapEvent) FromStackItem(item *stackitem.Array) error {
err error
)
index++
e.M, err = func (item stackitem.Item) (map[*big.Int]map[string][]util.Uint160, error) {
e.M, err = func(item stackitem.Item) (map[*big.Int]map[string][]util.Uint160, error) {
m, ok := item.Value().([]stackitem.MapElement)
if !ok {
return nil, fmt.Errorf("%s is not a map", item.Type().String())
@ -998,14 +998,14 @@ func (e *SomeMapEvent) FromStackItem(item *stackitem.Array) error {
if err != nil {
return nil, fmt.Errorf("key %d: %w", i, err)
}
v, err := func (item stackitem.Item) (map[string][]util.Uint160, error) {
v, err := func(item stackitem.Item) (map[string][]util.Uint160, error) {
m, ok := item.Value().([]stackitem.MapElement)
if !ok {
return nil, fmt.Errorf("%s is not a map", item.Type().String())
}
res := make(map[string][]util.Uint160)
for i := range m {
k, err := func (item stackitem.Item) (string, error) {
k, err := func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
@ -1014,18 +1014,18 @@ func (e *SomeMapEvent) FromStackItem(item *stackitem.Array) error {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
} (m[i].Key)
}(m[i].Key)
if err != nil {
return nil, fmt.Errorf("key %d: %w", i, err)
}
v, err := func (item stackitem.Item) ([]util.Uint160, error) {
v, err := func(item stackitem.Item) ([]util.Uint160, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
}
res := make([]util.Uint160, len(arr))
for i := range res {
res[i], err = func (item stackitem.Item) (util.Uint160, error) {
res[i], err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -1035,27 +1035,27 @@ func (e *SomeMapEvent) FromStackItem(item *stackitem.Array) error {
return util.Uint160{}, err
}
return u, nil
} (arr[i])
}(arr[i])
if err != nil {
return nil, fmt.Errorf("item %d: %w", i, err)
}
}
return res, nil
} (m[i].Value)
}(m[i].Value)
if err != nil {
return nil, fmt.Errorf("value %d: %w", i, err)
}
res[k] = v
}
return res, nil
} (m[i].Value)
}(m[i].Value)
if err != nil {
return nil, fmt.Errorf("value %d: %w", i, err)
}
res[k] = v
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field M: %w", err)
}
@ -1159,14 +1159,14 @@ func (e *SomeArrayEvent) FromStackItem(item *stackitem.Array) error {
err error
)
index++
e.A, err = func (item stackitem.Item) ([][]*big.Int, error) {
e.A, err = func(item stackitem.Item) ([][]*big.Int, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
}
res := make([][]*big.Int, len(arr))
for i := range res {
res[i], err = func (item stackitem.Item) ([]*big.Int, error) {
res[i], err = func(item stackitem.Item) ([]*big.Int, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
@ -1179,13 +1179,13 @@ func (e *SomeArrayEvent) FromStackItem(item *stackitem.Array) error {
}
}
return res, nil
} (arr[i])
}(arr[i])
if err != nil {
return nil, fmt.Errorf("item %d: %w", i, err)
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field A: %w", err)
}

View file

@ -266,7 +266,7 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error {
err error
)
index++
res.Hash, err = func (item stackitem.Item) (util.Uint256, error) {
res.Hash, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -276,7 +276,7 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Hash: %w", err)
}
@ -288,7 +288,7 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error {
}
index++
res.PrevHash, err = func (item stackitem.Item) (util.Uint256, error) {
res.PrevHash, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -298,13 +298,13 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field PrevHash: %w", err)
}
index++
res.MerkleRoot, err = func (item stackitem.Item) (util.Uint256, error) {
res.MerkleRoot, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -314,7 +314,7 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field MerkleRoot: %w", err)
}
@ -338,7 +338,7 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error {
}
index++
res.NextConsensus, err = func (item stackitem.Item) (util.Uint160, error) {
res.NextConsensus, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -348,7 +348,7 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error {
return util.Uint160{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field NextConsensus: %w", err)
}
@ -388,7 +388,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
err error
)
index++
res.Hash, err = func (item stackitem.Item) (util.Uint256, error) {
res.Hash, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -398,7 +398,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Hash: %w", err)
}
@ -410,7 +410,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
}
index++
res.PrevHash, err = func (item stackitem.Item) (util.Uint256, error) {
res.PrevHash, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -420,13 +420,13 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field PrevHash: %w", err)
}
index++
res.MerkleRoot, err = func (item stackitem.Item) (util.Uint256, error) {
res.MerkleRoot, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -436,7 +436,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field MerkleRoot: %w", err)
}
@ -460,7 +460,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
}
index++
res.NextConsensus, err = func (item stackitem.Item) (util.Uint160, error) {
res.NextConsensus, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -470,7 +470,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
return util.Uint160{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field NextConsensus: %w", err)
}
@ -482,7 +482,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
}
index++
res.PrevStateRoot, err = func (item stackitem.Item) (util.Uint256, error) {
res.PrevStateRoot, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -492,7 +492,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field PrevStateRoot: %w", err)
}
@ -526,7 +526,7 @@ func (res *LedgerTransaction) FromStackItem(item stackitem.Item) error {
err error
)
index++
res.Hash, err = func (item stackitem.Item) (util.Uint256, error) {
res.Hash, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -536,7 +536,7 @@ func (res *LedgerTransaction) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Hash: %w", err)
}
@ -554,7 +554,7 @@ func (res *LedgerTransaction) FromStackItem(item stackitem.Item) error {
}
index++
res.Sender, err = func (item stackitem.Item) (util.Uint160, error) {
res.Sender, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -564,7 +564,7 @@ func (res *LedgerTransaction) FromStackItem(item stackitem.Item) error {
return util.Uint160{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Sender: %w", err)
}
@ -622,7 +622,7 @@ func (res *LedgerTransactionSigner) FromStackItem(item stackitem.Item) error {
err error
)
index++
res.Account, err = func (item stackitem.Item) (util.Uint160, error) {
res.Account, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -632,7 +632,7 @@ func (res *LedgerTransactionSigner) FromStackItem(item stackitem.Item) error {
return util.Uint160{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Account: %w", err)
}
@ -644,14 +644,14 @@ func (res *LedgerTransactionSigner) FromStackItem(item stackitem.Item) error {
}
index++
res.AllowedContracts, err = func (item stackitem.Item) ([]util.Uint160, error) {
res.AllowedContracts, err = func(item stackitem.Item) ([]util.Uint160, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
}
res := make([]util.Uint160, len(arr))
for i := range res {
res[i], err = func (item stackitem.Item) (util.Uint160, error) {
res[i], err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -661,26 +661,26 @@ func (res *LedgerTransactionSigner) FromStackItem(item stackitem.Item) error {
return util.Uint160{}, err
}
return u, nil
} (arr[i])
}(arr[i])
if err != nil {
return nil, fmt.Errorf("item %d: %w", i, err)
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field AllowedContracts: %w", err)
}
index++
res.AllowedGroups, err = func (item stackitem.Item) (keys.PublicKeys, error) {
res.AllowedGroups, err = func(item stackitem.Item) (keys.PublicKeys, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
}
res := make(keys.PublicKeys, len(arr))
for i := range res {
res[i], err = func (item stackitem.Item) (*keys.PublicKey, error) {
res[i], err = func(item stackitem.Item) (*keys.PublicKey, error) {
b, err := item.TryBytes()
if err != nil {
return nil, err
@ -690,19 +690,19 @@ func (res *LedgerTransactionSigner) FromStackItem(item stackitem.Item) error {
return nil, err
}
return k, nil
} (arr[i])
}(arr[i])
if err != nil {
return nil, fmt.Errorf("item %d: %w", i, err)
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field AllowedGroups: %w", err)
}
index++
res.Rules, err = func (item stackitem.Item) ([]*LedgerWitnessRule, error) {
res.Rules, err = func(item stackitem.Item) ([]*LedgerWitnessRule, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
@ -715,7 +715,7 @@ func (res *LedgerTransactionSigner) FromStackItem(item stackitem.Item) error {
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Rules: %w", err)
}
@ -887,7 +887,7 @@ func (e *ComplicatedNameEvent) FromStackItem(item *stackitem.Array) error {
err error
)
index++
e.ComplicatedParam, err = func (item stackitem.Item) (string, error) {
e.ComplicatedParam, err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
@ -896,7 +896,7 @@ func (e *ComplicatedNameEvent) FromStackItem(item *stackitem.Array) error {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field ComplicatedParam: %w", err)
}
@ -948,7 +948,7 @@ func (e *SomeMapEvent) FromStackItem(item *stackitem.Array) error {
err error
)
index++
e.M, err = func (item stackitem.Item) (map[*big.Int][]map[string][]util.Uint160, error) {
e.M, err = func(item stackitem.Item) (map[*big.Int][]map[string][]util.Uint160, error) {
m, ok := item.Value().([]stackitem.MapElement)
if !ok {
return nil, fmt.Errorf("%s is not a map", item.Type().String())
@ -959,21 +959,21 @@ func (e *SomeMapEvent) FromStackItem(item *stackitem.Array) error {
if err != nil {
return nil, fmt.Errorf("key %d: %w", i, err)
}
v, err := func (item stackitem.Item) ([]map[string][]util.Uint160, error) {
v, err := func(item stackitem.Item) ([]map[string][]util.Uint160, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
}
res := make([]map[string][]util.Uint160, len(arr))
for i := range res {
res[i], err = func (item stackitem.Item) (map[string][]util.Uint160, error) {
res[i], err = func(item stackitem.Item) (map[string][]util.Uint160, error) {
m, ok := item.Value().([]stackitem.MapElement)
if !ok {
return nil, fmt.Errorf("%s is not a map", item.Type().String())
}
res := make(map[string][]util.Uint160)
for i := range m {
k, err := func (item stackitem.Item) (string, error) {
k, err := func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
@ -982,18 +982,18 @@ func (e *SomeMapEvent) FromStackItem(item *stackitem.Array) error {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
} (m[i].Key)
}(m[i].Key)
if err != nil {
return nil, fmt.Errorf("key %d: %w", i, err)
}
v, err := func (item stackitem.Item) ([]util.Uint160, error) {
v, err := func(item stackitem.Item) ([]util.Uint160, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
}
res := make([]util.Uint160, len(arr))
for i := range res {
res[i], err = func (item stackitem.Item) (util.Uint160, error) {
res[i], err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -1003,33 +1003,33 @@ func (e *SomeMapEvent) FromStackItem(item *stackitem.Array) error {
return util.Uint160{}, err
}
return u, nil
} (arr[i])
}(arr[i])
if err != nil {
return nil, fmt.Errorf("item %d: %w", i, err)
}
}
return res, nil
} (m[i].Value)
}(m[i].Value)
if err != nil {
return nil, fmt.Errorf("value %d: %w", i, err)
}
res[k] = v
}
return res, nil
} (arr[i])
}(arr[i])
if err != nil {
return nil, fmt.Errorf("item %d: %w", i, err)
}
}
return res, nil
} (m[i].Value)
}(m[i].Value)
if err != nil {
return nil, fmt.Errorf("value %d: %w", i, err)
}
res[k] = v
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field M: %w", err)
}
@ -1133,14 +1133,14 @@ func (e *SomeArrayEvent) FromStackItem(item *stackitem.Array) error {
err error
)
index++
e.A, err = func (item stackitem.Item) ([][]*big.Int, error) {
e.A, err = func(item stackitem.Item) ([][]*big.Int, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
}
res := make([][]*big.Int, len(arr))
for i := range res {
res[i], err = func (item stackitem.Item) ([]*big.Int, error) {
res[i], err = func(item stackitem.Item) ([]*big.Int, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
@ -1153,13 +1153,13 @@ func (e *SomeArrayEvent) FromStackItem(item *stackitem.Array) error {
}
}
return res, nil
} (arr[i])
}(arr[i])
if err != nil {
return nil, fmt.Errorf("item %d: %w", i, err)
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field A: %w", err)
}

View file

@ -218,7 +218,7 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error {
err error
)
index++
res.Hash, err = func (item stackitem.Item) (util.Uint256, error) {
res.Hash, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -228,7 +228,7 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Hash: %w", err)
}
@ -240,7 +240,7 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error {
}
index++
res.PrevHash, err = func (item stackitem.Item) (util.Uint256, error) {
res.PrevHash, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -250,13 +250,13 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field PrevHash: %w", err)
}
index++
res.MerkleRoot, err = func (item stackitem.Item) (util.Uint256, error) {
res.MerkleRoot, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -266,7 +266,7 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field MerkleRoot: %w", err)
}
@ -290,7 +290,7 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error {
}
index++
res.NextConsensus, err = func (item stackitem.Item) (util.Uint160, error) {
res.NextConsensus, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -300,7 +300,7 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error {
return util.Uint160{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field NextConsensus: %w", err)
}
@ -340,7 +340,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
err error
)
index++
res.Hash, err = func (item stackitem.Item) (util.Uint256, error) {
res.Hash, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -350,7 +350,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Hash: %w", err)
}
@ -362,7 +362,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
}
index++
res.PrevHash, err = func (item stackitem.Item) (util.Uint256, error) {
res.PrevHash, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -372,13 +372,13 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field PrevHash: %w", err)
}
index++
res.MerkleRoot, err = func (item stackitem.Item) (util.Uint256, error) {
res.MerkleRoot, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -388,7 +388,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field MerkleRoot: %w", err)
}
@ -412,7 +412,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
}
index++
res.NextConsensus, err = func (item stackitem.Item) (util.Uint160, error) {
res.NextConsensus, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -422,7 +422,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
return util.Uint160{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field NextConsensus: %w", err)
}
@ -434,7 +434,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
}
index++
res.PrevStateRoot, err = func (item stackitem.Item) (util.Uint256, error) {
res.PrevStateRoot, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -444,7 +444,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field PrevStateRoot: %w", err)
}
@ -478,7 +478,7 @@ func (res *LedgerTransaction) FromStackItem(item stackitem.Item) error {
err error
)
index++
res.Hash, err = func (item stackitem.Item) (util.Uint256, error) {
res.Hash, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -488,7 +488,7 @@ func (res *LedgerTransaction) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Hash: %w", err)
}
@ -506,7 +506,7 @@ func (res *LedgerTransaction) FromStackItem(item stackitem.Item) error {
}
index++
res.Sender, err = func (item stackitem.Item) (util.Uint160, error) {
res.Sender, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -516,7 +516,7 @@ func (res *LedgerTransaction) FromStackItem(item stackitem.Item) error {
return util.Uint160{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Sender: %w", err)
}
@ -574,7 +574,7 @@ func (res *LedgerTransactionSigner) FromStackItem(item stackitem.Item) error {
err error
)
index++
res.Account, err = func (item stackitem.Item) (util.Uint160, error) {
res.Account, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -584,7 +584,7 @@ func (res *LedgerTransactionSigner) FromStackItem(item stackitem.Item) error {
return util.Uint160{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Account: %w", err)
}
@ -596,14 +596,14 @@ func (res *LedgerTransactionSigner) FromStackItem(item stackitem.Item) error {
}
index++
res.AllowedContracts, err = func (item stackitem.Item) ([]util.Uint160, error) {
res.AllowedContracts, err = func(item stackitem.Item) ([]util.Uint160, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
}
res := make([]util.Uint160, len(arr))
for i := range res {
res[i], err = func (item stackitem.Item) (util.Uint160, error) {
res[i], err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -613,26 +613,26 @@ func (res *LedgerTransactionSigner) FromStackItem(item stackitem.Item) error {
return util.Uint160{}, err
}
return u, nil
} (arr[i])
}(arr[i])
if err != nil {
return nil, fmt.Errorf("item %d: %w", i, err)
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field AllowedContracts: %w", err)
}
index++
res.AllowedGroups, err = func (item stackitem.Item) (keys.PublicKeys, error) {
res.AllowedGroups, err = func(item stackitem.Item) (keys.PublicKeys, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
}
res := make(keys.PublicKeys, len(arr))
for i := range res {
res[i], err = func (item stackitem.Item) (*keys.PublicKey, error) {
res[i], err = func(item stackitem.Item) (*keys.PublicKey, error) {
b, err := item.TryBytes()
if err != nil {
return nil, err
@ -642,19 +642,19 @@ func (res *LedgerTransactionSigner) FromStackItem(item stackitem.Item) error {
return nil, err
}
return k, nil
} (arr[i])
}(arr[i])
if err != nil {
return nil, fmt.Errorf("item %d: %w", i, err)
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field AllowedGroups: %w", err)
}
index++
res.Rules, err = func (item stackitem.Item) ([]*LedgerWitnessRule, error) {
res.Rules, err = func(item stackitem.Item) ([]*LedgerWitnessRule, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
@ -667,7 +667,7 @@ func (res *LedgerTransactionSigner) FromStackItem(item stackitem.Item) error {
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Rules: %w", err)
}
@ -781,7 +781,7 @@ func (res *ManagementABI) FromStackItem(item stackitem.Item) error {
err error
)
index++
res.Methods, err = func (item stackitem.Item) ([]*ManagementMethod, error) {
res.Methods, err = func(item stackitem.Item) ([]*ManagementMethod, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
@ -794,13 +794,13 @@ func (res *ManagementABI) FromStackItem(item stackitem.Item) error {
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Methods: %w", err)
}
index++
res.Events, err = func (item stackitem.Item) ([]*ManagementEvent, error) {
res.Events, err = func(item stackitem.Item) ([]*ManagementEvent, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
@ -813,7 +813,7 @@ func (res *ManagementABI) FromStackItem(item stackitem.Item) error {
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Events: %w", err)
}
@ -859,7 +859,7 @@ func (res *ManagementContract) FromStackItem(item stackitem.Item) error {
}
index++
res.Hash, err = func (item stackitem.Item) (util.Uint160, error) {
res.Hash, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -869,7 +869,7 @@ func (res *ManagementContract) FromStackItem(item stackitem.Item) error {
return util.Uint160{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Hash: %w", err)
}
@ -915,7 +915,7 @@ func (res *ManagementEvent) FromStackItem(item stackitem.Item) error {
err error
)
index++
res.Name, err = func (item stackitem.Item) (string, error) {
res.Name, err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
@ -924,13 +924,13 @@ func (res *ManagementEvent) FromStackItem(item stackitem.Item) error {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Name: %w", err)
}
index++
res.Params, err = func (item stackitem.Item) ([]*ManagementParameter, error) {
res.Params, err = func(item stackitem.Item) ([]*ManagementParameter, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
@ -943,7 +943,7 @@ func (res *ManagementEvent) FromStackItem(item stackitem.Item) error {
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Params: %w", err)
}
@ -977,7 +977,7 @@ func (res *ManagementGroup) FromStackItem(item stackitem.Item) error {
err error
)
index++
res.PublicKey, err = func (item stackitem.Item) (*keys.PublicKey, error) {
res.PublicKey, err = func(item stackitem.Item) (*keys.PublicKey, error) {
b, err := item.TryBytes()
if err != nil {
return nil, err
@ -987,7 +987,7 @@ func (res *ManagementGroup) FromStackItem(item stackitem.Item) error {
return nil, err
}
return k, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field PublicKey: %w", err)
}
@ -1027,7 +1027,7 @@ func (res *ManagementManifest) FromStackItem(item stackitem.Item) error {
err error
)
index++
res.Name, err = func (item stackitem.Item) (string, error) {
res.Name, err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
@ -1036,13 +1036,13 @@ func (res *ManagementManifest) FromStackItem(item stackitem.Item) error {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Name: %w", err)
}
index++
res.Groups, err = func (item stackitem.Item) ([]*ManagementGroup, error) {
res.Groups, err = func(item stackitem.Item) ([]*ManagementGroup, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
@ -1055,20 +1055,20 @@ func (res *ManagementManifest) FromStackItem(item stackitem.Item) error {
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Groups: %w", err)
}
index++
res.Features, err = func (item stackitem.Item) (map[string]string, error) {
res.Features, err = func(item stackitem.Item) (map[string]string, error) {
m, ok := item.Value().([]stackitem.MapElement)
if !ok {
return nil, fmt.Errorf("%s is not a map", item.Type().String())
}
res := make(map[string]string)
for i := range m {
k, err := func (item stackitem.Item) (string, error) {
k, err := func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
@ -1077,11 +1077,11 @@ func (res *ManagementManifest) FromStackItem(item stackitem.Item) error {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
} (m[i].Key)
}(m[i].Key)
if err != nil {
return nil, fmt.Errorf("key %d: %w", i, err)
}
v, err := func (item stackitem.Item) (string, error) {
v, err := func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
@ -1090,27 +1090,27 @@ func (res *ManagementManifest) FromStackItem(item stackitem.Item) error {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
} (m[i].Value)
}(m[i].Value)
if err != nil {
return nil, fmt.Errorf("value %d: %w", i, err)
}
res[k] = v
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Features: %w", err)
}
index++
res.SupportedStandards, err = func (item stackitem.Item) ([]string, error) {
res.SupportedStandards, err = func(item stackitem.Item) ([]string, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
}
res := make([]string, len(arr))
for i := range res {
res[i], err = func (item stackitem.Item) (string, error) {
res[i], err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
@ -1119,13 +1119,13 @@ func (res *ManagementManifest) FromStackItem(item stackitem.Item) error {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
} (arr[i])
}(arr[i])
if err != nil {
return nil, fmt.Errorf("item %d: %w", i, err)
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field SupportedStandards: %w", err)
}
@ -1137,7 +1137,7 @@ func (res *ManagementManifest) FromStackItem(item stackitem.Item) error {
}
index++
res.Permissions, err = func (item stackitem.Item) ([]*ManagementPermission, error) {
res.Permissions, err = func(item stackitem.Item) ([]*ManagementPermission, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
@ -1150,20 +1150,20 @@ func (res *ManagementManifest) FromStackItem(item stackitem.Item) error {
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Permissions: %w", err)
}
index++
res.Trusts, err = func (item stackitem.Item) ([]util.Uint160, error) {
res.Trusts, err = func(item stackitem.Item) ([]util.Uint160, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
}
res := make([]util.Uint160, len(arr))
for i := range res {
res[i], err = func (item stackitem.Item) (util.Uint160, error) {
res[i], err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -1173,13 +1173,13 @@ func (res *ManagementManifest) FromStackItem(item stackitem.Item) error {
return util.Uint160{}, err
}
return u, nil
} (arr[i])
}(arr[i])
if err != nil {
return nil, fmt.Errorf("item %d: %w", i, err)
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Trusts: %w", err)
}
@ -1219,7 +1219,7 @@ func (res *ManagementMethod) FromStackItem(item stackitem.Item) error {
err error
)
index++
res.Name, err = func (item stackitem.Item) (string, error) {
res.Name, err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
@ -1228,13 +1228,13 @@ func (res *ManagementMethod) FromStackItem(item stackitem.Item) error {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Name: %w", err)
}
index++
res.Params, err = func (item stackitem.Item) ([]*ManagementParameter, error) {
res.Params, err = func(item stackitem.Item) ([]*ManagementParameter, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
@ -1247,7 +1247,7 @@ func (res *ManagementMethod) FromStackItem(item stackitem.Item) error {
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Params: %w", err)
}
@ -1299,7 +1299,7 @@ func (res *ManagementParameter) FromStackItem(item stackitem.Item) error {
err error
)
index++
res.Name, err = func (item stackitem.Item) (string, error) {
res.Name, err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
@ -1308,7 +1308,7 @@ func (res *ManagementParameter) FromStackItem(item stackitem.Item) error {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Name: %w", err)
}
@ -1348,7 +1348,7 @@ func (res *ManagementPermission) FromStackItem(item stackitem.Item) error {
err error
)
index++
res.Contract, err = func (item stackitem.Item) (util.Uint160, error) {
res.Contract, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -1358,20 +1358,20 @@ func (res *ManagementPermission) FromStackItem(item stackitem.Item) error {
return util.Uint160{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Contract: %w", err)
}
index++
res.Methods, err = func (item stackitem.Item) ([]string, error) {
res.Methods, err = func(item stackitem.Item) ([]string, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
}
res := make([]string, len(arr))
for i := range res {
res[i], err = func (item stackitem.Item) (string, error) {
res[i], err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
@ -1380,13 +1380,13 @@ func (res *ManagementPermission) FromStackItem(item stackitem.Item) error {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
} (arr[i])
}(arr[i])
if err != nil {
return nil, fmt.Errorf("item %d: %w", i, err)
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Methods: %w", err)
}
@ -1438,7 +1438,7 @@ func (res *StructsInternal) FromStackItem(item stackitem.Item) error {
}
index++
res.String, err = func (item stackitem.Item) (string, error) {
res.String, err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
@ -1447,13 +1447,13 @@ func (res *StructsInternal) FromStackItem(item stackitem.Item) error {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field String: %w", err)
}
index++
res.H160, err = func (item stackitem.Item) (util.Uint160, error) {
res.H160, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -1463,13 +1463,13 @@ func (res *StructsInternal) FromStackItem(item stackitem.Item) error {
return util.Uint160{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field H160: %w", err)
}
index++
res.H256, err = func (item stackitem.Item) (util.Uint256, error) {
res.H256, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -1479,13 +1479,13 @@ func (res *StructsInternal) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field H256: %w", err)
}
index++
res.PK, err = func (item stackitem.Item) (*keys.PublicKey, error) {
res.PK, err = func(item stackitem.Item) (*keys.PublicKey, error) {
b, err := item.TryBytes()
if err != nil {
return nil, err
@ -1495,13 +1495,13 @@ func (res *StructsInternal) FromStackItem(item stackitem.Item) error {
return nil, err
}
return k, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field PK: %w", err)
}
index++
res.PubKey, err = func (item stackitem.Item) (*keys.PublicKey, error) {
res.PubKey, err = func(item stackitem.Item) (*keys.PublicKey, error) {
b, err := item.TryBytes()
if err != nil {
return nil, err
@ -1511,7 +1511,7 @@ func (res *StructsInternal) FromStackItem(item stackitem.Item) error {
return nil, err
}
return k, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field PubKey: %w", err)
}
@ -1523,7 +1523,7 @@ func (res *StructsInternal) FromStackItem(item stackitem.Item) error {
}
index++
res.ArrOfBytes, err = func (item stackitem.Item) ([][]byte, error) {
res.ArrOfBytes, err = func(item stackitem.Item) ([][]byte, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
@ -1536,20 +1536,20 @@ func (res *StructsInternal) FromStackItem(item stackitem.Item) error {
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field ArrOfBytes: %w", err)
}
index++
res.ArrOfH160, err = func (item stackitem.Item) ([]util.Uint160, error) {
res.ArrOfH160, err = func(item stackitem.Item) ([]util.Uint160, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
}
res := make([]util.Uint160, len(arr))
for i := range res {
res[i], err = func (item stackitem.Item) (util.Uint160, error) {
res[i], err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -1559,19 +1559,19 @@ func (res *StructsInternal) FromStackItem(item stackitem.Item) error {
return util.Uint160{}, err
}
return u, nil
} (arr[i])
}(arr[i])
if err != nil {
return nil, fmt.Errorf("item %d: %w", i, err)
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field ArrOfH160: %w", err)
}
index++
res.Map, err = func (item stackitem.Item) (map[*big.Int]keys.PublicKeys, error) {
res.Map, err = func(item stackitem.Item) (map[*big.Int]keys.PublicKeys, error) {
m, ok := item.Value().([]stackitem.MapElement)
if !ok {
return nil, fmt.Errorf("%s is not a map", item.Type().String())
@ -1582,14 +1582,14 @@ func (res *StructsInternal) FromStackItem(item stackitem.Item) error {
if err != nil {
return nil, fmt.Errorf("key %d: %w", i, err)
}
v, err := func (item stackitem.Item) (keys.PublicKeys, error) {
v, err := func(item stackitem.Item) (keys.PublicKeys, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
}
res := make(keys.PublicKeys, len(arr))
for i := range res {
res[i], err = func (item stackitem.Item) (*keys.PublicKey, error) {
res[i], err = func(item stackitem.Item) (*keys.PublicKey, error) {
b, err := item.TryBytes()
if err != nil {
return nil, err
@ -1599,20 +1599,20 @@ func (res *StructsInternal) FromStackItem(item stackitem.Item) error {
return nil, err
}
return k, nil
} (arr[i])
}(arr[i])
if err != nil {
return nil, fmt.Errorf("item %d: %w", i, err)
}
}
return res, nil
} (m[i].Value)
}(m[i].Value)
if err != nil {
return nil, fmt.Errorf("value %d: %w", i, err)
}
res[k] = v
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Map: %w", err)
}

View file

@ -214,7 +214,7 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error {
err error
)
index++
res.Hash, err = func (item stackitem.Item) (util.Uint256, error) {
res.Hash, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -224,7 +224,7 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Hash: %w", err)
}
@ -236,7 +236,7 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error {
}
index++
res.PrevHash, err = func (item stackitem.Item) (util.Uint256, error) {
res.PrevHash, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -246,13 +246,13 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field PrevHash: %w", err)
}
index++
res.MerkleRoot, err = func (item stackitem.Item) (util.Uint256, error) {
res.MerkleRoot, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -262,7 +262,7 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field MerkleRoot: %w", err)
}
@ -286,7 +286,7 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error {
}
index++
res.NextConsensus, err = func (item stackitem.Item) (util.Uint160, error) {
res.NextConsensus, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -296,7 +296,7 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error {
return util.Uint160{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field NextConsensus: %w", err)
}
@ -336,7 +336,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
err error
)
index++
res.Hash, err = func (item stackitem.Item) (util.Uint256, error) {
res.Hash, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -346,7 +346,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Hash: %w", err)
}
@ -358,7 +358,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
}
index++
res.PrevHash, err = func (item stackitem.Item) (util.Uint256, error) {
res.PrevHash, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -368,13 +368,13 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field PrevHash: %w", err)
}
index++
res.MerkleRoot, err = func (item stackitem.Item) (util.Uint256, error) {
res.MerkleRoot, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -384,7 +384,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field MerkleRoot: %w", err)
}
@ -408,7 +408,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
}
index++
res.NextConsensus, err = func (item stackitem.Item) (util.Uint160, error) {
res.NextConsensus, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -418,7 +418,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
return util.Uint160{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field NextConsensus: %w", err)
}
@ -430,7 +430,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
}
index++
res.PrevStateRoot, err = func (item stackitem.Item) (util.Uint256, error) {
res.PrevStateRoot, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -440,7 +440,7 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field PrevStateRoot: %w", err)
}
@ -474,7 +474,7 @@ func (res *LedgerTransaction) FromStackItem(item stackitem.Item) error {
err error
)
index++
res.Hash, err = func (item stackitem.Item) (util.Uint256, error) {
res.Hash, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -484,7 +484,7 @@ func (res *LedgerTransaction) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Hash: %w", err)
}
@ -502,7 +502,7 @@ func (res *LedgerTransaction) FromStackItem(item stackitem.Item) error {
}
index++
res.Sender, err = func (item stackitem.Item) (util.Uint160, error) {
res.Sender, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -512,7 +512,7 @@ func (res *LedgerTransaction) FromStackItem(item stackitem.Item) error {
return util.Uint160{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Sender: %w", err)
}
@ -570,7 +570,7 @@ func (res *LedgerTransactionSigner) FromStackItem(item stackitem.Item) error {
err error
)
index++
res.Account, err = func (item stackitem.Item) (util.Uint160, error) {
res.Account, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -580,7 +580,7 @@ func (res *LedgerTransactionSigner) FromStackItem(item stackitem.Item) error {
return util.Uint160{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Account: %w", err)
}
@ -592,14 +592,14 @@ func (res *LedgerTransactionSigner) FromStackItem(item stackitem.Item) error {
}
index++
res.AllowedContracts, err = func (item stackitem.Item) ([]util.Uint160, error) {
res.AllowedContracts, err = func(item stackitem.Item) ([]util.Uint160, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
}
res := make([]util.Uint160, len(arr))
for i := range res {
res[i], err = func (item stackitem.Item) (util.Uint160, error) {
res[i], err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -609,26 +609,26 @@ func (res *LedgerTransactionSigner) FromStackItem(item stackitem.Item) error {
return util.Uint160{}, err
}
return u, nil
} (arr[i])
}(arr[i])
if err != nil {
return nil, fmt.Errorf("item %d: %w", i, err)
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field AllowedContracts: %w", err)
}
index++
res.AllowedGroups, err = func (item stackitem.Item) (keys.PublicKeys, error) {
res.AllowedGroups, err = func(item stackitem.Item) (keys.PublicKeys, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
}
res := make(keys.PublicKeys, len(arr))
for i := range res {
res[i], err = func (item stackitem.Item) (*keys.PublicKey, error) {
res[i], err = func(item stackitem.Item) (*keys.PublicKey, error) {
b, err := item.TryBytes()
if err != nil {
return nil, err
@ -638,19 +638,19 @@ func (res *LedgerTransactionSigner) FromStackItem(item stackitem.Item) error {
return nil, err
}
return k, nil
} (arr[i])
}(arr[i])
if err != nil {
return nil, fmt.Errorf("item %d: %w", i, err)
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field AllowedGroups: %w", err)
}
index++
res.Rules, err = func (item stackitem.Item) ([]*LedgerWitnessRule, error) {
res.Rules, err = func(item stackitem.Item) ([]*LedgerWitnessRule, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
@ -663,7 +663,7 @@ func (res *LedgerTransactionSigner) FromStackItem(item stackitem.Item) error {
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Rules: %w", err)
}
@ -777,7 +777,7 @@ func (res *ManagementABI) FromStackItem(item stackitem.Item) error {
err error
)
index++
res.Methods, err = func (item stackitem.Item) ([]*ManagementMethod, error) {
res.Methods, err = func(item stackitem.Item) ([]*ManagementMethod, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
@ -790,13 +790,13 @@ func (res *ManagementABI) FromStackItem(item stackitem.Item) error {
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Methods: %w", err)
}
index++
res.Events, err = func (item stackitem.Item) ([]*ManagementEvent, error) {
res.Events, err = func(item stackitem.Item) ([]*ManagementEvent, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
@ -809,7 +809,7 @@ func (res *ManagementABI) FromStackItem(item stackitem.Item) error {
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Events: %w", err)
}
@ -855,7 +855,7 @@ func (res *ManagementContract) FromStackItem(item stackitem.Item) error {
}
index++
res.Hash, err = func (item stackitem.Item) (util.Uint160, error) {
res.Hash, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -865,7 +865,7 @@ func (res *ManagementContract) FromStackItem(item stackitem.Item) error {
return util.Uint160{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Hash: %w", err)
}
@ -911,7 +911,7 @@ func (res *ManagementEvent) FromStackItem(item stackitem.Item) error {
err error
)
index++
res.Name, err = func (item stackitem.Item) (string, error) {
res.Name, err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
@ -920,13 +920,13 @@ func (res *ManagementEvent) FromStackItem(item stackitem.Item) error {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Name: %w", err)
}
index++
res.Params, err = func (item stackitem.Item) ([]*ManagementParameter, error) {
res.Params, err = func(item stackitem.Item) ([]*ManagementParameter, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
@ -939,7 +939,7 @@ func (res *ManagementEvent) FromStackItem(item stackitem.Item) error {
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Params: %w", err)
}
@ -973,7 +973,7 @@ func (res *ManagementGroup) FromStackItem(item stackitem.Item) error {
err error
)
index++
res.PublicKey, err = func (item stackitem.Item) (*keys.PublicKey, error) {
res.PublicKey, err = func(item stackitem.Item) (*keys.PublicKey, error) {
b, err := item.TryBytes()
if err != nil {
return nil, err
@ -983,7 +983,7 @@ func (res *ManagementGroup) FromStackItem(item stackitem.Item) error {
return nil, err
}
return k, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field PublicKey: %w", err)
}
@ -1023,7 +1023,7 @@ func (res *ManagementManifest) FromStackItem(item stackitem.Item) error {
err error
)
index++
res.Name, err = func (item stackitem.Item) (string, error) {
res.Name, err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
@ -1032,13 +1032,13 @@ func (res *ManagementManifest) FromStackItem(item stackitem.Item) error {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Name: %w", err)
}
index++
res.Groups, err = func (item stackitem.Item) ([]*ManagementGroup, error) {
res.Groups, err = func(item stackitem.Item) ([]*ManagementGroup, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
@ -1051,20 +1051,20 @@ func (res *ManagementManifest) FromStackItem(item stackitem.Item) error {
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Groups: %w", err)
}
index++
res.Features, err = func (item stackitem.Item) (map[string]string, error) {
res.Features, err = func(item stackitem.Item) (map[string]string, error) {
m, ok := item.Value().([]stackitem.MapElement)
if !ok {
return nil, fmt.Errorf("%s is not a map", item.Type().String())
}
res := make(map[string]string)
for i := range m {
k, err := func (item stackitem.Item) (string, error) {
k, err := func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
@ -1073,11 +1073,11 @@ func (res *ManagementManifest) FromStackItem(item stackitem.Item) error {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
} (m[i].Key)
}(m[i].Key)
if err != nil {
return nil, fmt.Errorf("key %d: %w", i, err)
}
v, err := func (item stackitem.Item) (string, error) {
v, err := func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
@ -1086,27 +1086,27 @@ func (res *ManagementManifest) FromStackItem(item stackitem.Item) error {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
} (m[i].Value)
}(m[i].Value)
if err != nil {
return nil, fmt.Errorf("value %d: %w", i, err)
}
res[k] = v
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Features: %w", err)
}
index++
res.SupportedStandards, err = func (item stackitem.Item) ([]string, error) {
res.SupportedStandards, err = func(item stackitem.Item) ([]string, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
}
res := make([]string, len(arr))
for i := range res {
res[i], err = func (item stackitem.Item) (string, error) {
res[i], err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
@ -1115,13 +1115,13 @@ func (res *ManagementManifest) FromStackItem(item stackitem.Item) error {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
} (arr[i])
}(arr[i])
if err != nil {
return nil, fmt.Errorf("item %d: %w", i, err)
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field SupportedStandards: %w", err)
}
@ -1133,7 +1133,7 @@ func (res *ManagementManifest) FromStackItem(item stackitem.Item) error {
}
index++
res.Permissions, err = func (item stackitem.Item) ([]*ManagementPermission, error) {
res.Permissions, err = func(item stackitem.Item) ([]*ManagementPermission, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
@ -1146,20 +1146,20 @@ func (res *ManagementManifest) FromStackItem(item stackitem.Item) error {
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Permissions: %w", err)
}
index++
res.Trusts, err = func (item stackitem.Item) ([]util.Uint160, error) {
res.Trusts, err = func(item stackitem.Item) ([]util.Uint160, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
}
res := make([]util.Uint160, len(arr))
for i := range res {
res[i], err = func (item stackitem.Item) (util.Uint160, error) {
res[i], err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -1169,13 +1169,13 @@ func (res *ManagementManifest) FromStackItem(item stackitem.Item) error {
return util.Uint160{}, err
}
return u, nil
} (arr[i])
}(arr[i])
if err != nil {
return nil, fmt.Errorf("item %d: %w", i, err)
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Trusts: %w", err)
}
@ -1215,7 +1215,7 @@ func (res *ManagementMethod) FromStackItem(item stackitem.Item) error {
err error
)
index++
res.Name, err = func (item stackitem.Item) (string, error) {
res.Name, err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
@ -1224,13 +1224,13 @@ func (res *ManagementMethod) FromStackItem(item stackitem.Item) error {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Name: %w", err)
}
index++
res.Params, err = func (item stackitem.Item) ([]*ManagementParameter, error) {
res.Params, err = func(item stackitem.Item) ([]*ManagementParameter, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
@ -1243,7 +1243,7 @@ func (res *ManagementMethod) FromStackItem(item stackitem.Item) error {
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Params: %w", err)
}
@ -1295,7 +1295,7 @@ func (res *ManagementParameter) FromStackItem(item stackitem.Item) error {
err error
)
index++
res.Name, err = func (item stackitem.Item) (string, error) {
res.Name, err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
@ -1304,7 +1304,7 @@ func (res *ManagementParameter) FromStackItem(item stackitem.Item) error {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Name: %w", err)
}
@ -1344,7 +1344,7 @@ func (res *ManagementPermission) FromStackItem(item stackitem.Item) error {
err error
)
index++
res.Contract, err = func (item stackitem.Item) (util.Uint160, error) {
res.Contract, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -1354,20 +1354,20 @@ func (res *ManagementPermission) FromStackItem(item stackitem.Item) error {
return util.Uint160{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Contract: %w", err)
}
index++
res.Methods, err = func (item stackitem.Item) ([]string, error) {
res.Methods, err = func(item stackitem.Item) ([]string, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
}
res := make([]string, len(arr))
for i := range res {
res[i], err = func (item stackitem.Item) (string, error) {
res[i], err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
@ -1376,13 +1376,13 @@ func (res *ManagementPermission) FromStackItem(item stackitem.Item) error {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
} (arr[i])
}(arr[i])
if err != nil {
return nil, fmt.Errorf("item %d: %w", i, err)
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Methods: %w", err)
}
@ -1434,7 +1434,7 @@ func (res *StructsInternal) FromStackItem(item stackitem.Item) error {
}
index++
res.String, err = func (item stackitem.Item) (string, error) {
res.String, err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
@ -1443,13 +1443,13 @@ func (res *StructsInternal) FromStackItem(item stackitem.Item) error {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field String: %w", err)
}
index++
res.H160, err = func (item stackitem.Item) (util.Uint160, error) {
res.H160, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -1459,13 +1459,13 @@ func (res *StructsInternal) FromStackItem(item stackitem.Item) error {
return util.Uint160{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field H160: %w", err)
}
index++
res.H256, err = func (item stackitem.Item) (util.Uint256, error) {
res.H256, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -1475,13 +1475,13 @@ func (res *StructsInternal) FromStackItem(item stackitem.Item) error {
return util.Uint256{}, err
}
return u, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field H256: %w", err)
}
index++
res.PK, err = func (item stackitem.Item) (*keys.PublicKey, error) {
res.PK, err = func(item stackitem.Item) (*keys.PublicKey, error) {
b, err := item.TryBytes()
if err != nil {
return nil, err
@ -1491,13 +1491,13 @@ func (res *StructsInternal) FromStackItem(item stackitem.Item) error {
return nil, err
}
return k, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field PK: %w", err)
}
index++
res.PubKey, err = func (item stackitem.Item) (*keys.PublicKey, error) {
res.PubKey, err = func(item stackitem.Item) (*keys.PublicKey, error) {
b, err := item.TryBytes()
if err != nil {
return nil, err
@ -1507,7 +1507,7 @@ func (res *StructsInternal) FromStackItem(item stackitem.Item) error {
return nil, err
}
return k, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field PubKey: %w", err)
}
@ -1519,7 +1519,7 @@ func (res *StructsInternal) FromStackItem(item stackitem.Item) error {
}
index++
res.ArrOfBytes, err = func (item stackitem.Item) ([][]byte, error) {
res.ArrOfBytes, err = func(item stackitem.Item) ([][]byte, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
@ -1532,20 +1532,20 @@ func (res *StructsInternal) FromStackItem(item stackitem.Item) error {
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field ArrOfBytes: %w", err)
}
index++
res.ArrOfH160, err = func (item stackitem.Item) ([]util.Uint160, error) {
res.ArrOfH160, err = func(item stackitem.Item) ([]util.Uint160, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
}
res := make([]util.Uint160, len(arr))
for i := range res {
res[i], err = func (item stackitem.Item) (util.Uint160, error) {
res[i], err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -1555,19 +1555,19 @@ func (res *StructsInternal) FromStackItem(item stackitem.Item) error {
return util.Uint160{}, err
}
return u, nil
} (arr[i])
}(arr[i])
if err != nil {
return nil, fmt.Errorf("item %d: %w", i, err)
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field ArrOfH160: %w", err)
}
index++
res.Map, err = func (item stackitem.Item) (map[*big.Int]keys.PublicKeys, error) {
res.Map, err = func(item stackitem.Item) (map[*big.Int]keys.PublicKeys, error) {
m, ok := item.Value().([]stackitem.MapElement)
if !ok {
return nil, fmt.Errorf("%s is not a map", item.Type().String())
@ -1578,14 +1578,14 @@ func (res *StructsInternal) FromStackItem(item stackitem.Item) error {
if err != nil {
return nil, fmt.Errorf("key %d: %w", i, err)
}
v, err := func (item stackitem.Item) (keys.PublicKeys, error) {
v, err := func(item stackitem.Item) (keys.PublicKeys, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
}
res := make(keys.PublicKeys, len(arr))
for i := range res {
res[i], err = func (item stackitem.Item) (*keys.PublicKey, error) {
res[i], err = func(item stackitem.Item) (*keys.PublicKey, error) {
b, err := item.TryBytes()
if err != nil {
return nil, err
@ -1595,20 +1595,20 @@ func (res *StructsInternal) FromStackItem(item stackitem.Item) error {
return nil, err
}
return k, nil
} (arr[i])
}(arr[i])
if err != nil {
return nil, fmt.Errorf("item %d: %w", i, err)
}
}
return res, nil
} (m[i].Value)
}(m[i].Value)
if err != nil {
return nil, fmt.Errorf("value %d: %w", i, err)
}
res[k] = v
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Map: %w", err)
}

View file

@ -35,32 +35,32 @@ func NewReader(invoker Invoker) *ContractReader {
// AAAStrings invokes `aAAStrings` method of contract.
func (c *ContractReader) AAAStrings(s [][][]string) ([][][]string, error) {
return func (item stackitem.Item, err error) ([][][]string, error) {
return func(item stackitem.Item, err error) ([][][]string, error) {
if err != nil {
return nil, err
}
return func (item stackitem.Item) ([][][]string, error) {
return func(item stackitem.Item) ([][][]string, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
}
res := make([][][]string, len(arr))
for i := range res {
res[i], err = func (item stackitem.Item) ([][]string, error) {
res[i], err = func(item stackitem.Item) ([][]string, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
}
res := make([][]string, len(arr))
for i := range res {
res[i], err = func (item stackitem.Item) ([]string, error) {
res[i], err = func(item stackitem.Item) ([]string, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
}
res := make([]string, len(arr))
for i := range res {
res[i], err = func (item stackitem.Item) (string, error) {
res[i], err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
@ -69,45 +69,45 @@ func (c *ContractReader) AAAStrings(s [][][]string) ([][][]string, error) {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
} (arr[i])
}(arr[i])
if err != nil {
return nil, fmt.Errorf("item %d: %w", i, err)
}
}
return res, nil
} (arr[i])
}(arr[i])
if err != nil {
return nil, fmt.Errorf("item %d: %w", i, err)
}
}
return res, nil
} (arr[i])
}(arr[i])
if err != nil {
return nil, fmt.Errorf("item %d: %w", i, err)
}
}
return res, nil
} (item)
} (unwrap.Item(c.invoker.Call(c.hash, "aAAStrings", s)))
}(item)
}(unwrap.Item(c.invoker.Call(c.hash, "aAAStrings", s)))
}
// Any invokes `any` method of contract.
func (c *ContractReader) Any(a any) (any, error) {
return func (item stackitem.Item, err error) (any, error) {
return func(item stackitem.Item, err error) (any, error) {
if err != nil {
return nil, err
}
return item.Value(), error(nil)
} (unwrap.Item(c.invoker.Call(c.hash, "any", a)))
}(unwrap.Item(c.invoker.Call(c.hash, "any", a)))
}
// AnyMaps invokes `anyMaps` method of contract.
func (c *ContractReader) AnyMaps(m map[*big.Int]any) (map[*big.Int]any, error) {
return func (item stackitem.Item, err error) (map[*big.Int]any, error) {
return func(item stackitem.Item, err error) (map[*big.Int]any, error) {
if err != nil {
return nil, err
}
return func (item stackitem.Item) (map[*big.Int]any, error) {
return func(item stackitem.Item) (map[*big.Int]any, error) {
m, ok := item.Value().([]stackitem.MapElement)
if !ok {
return nil, fmt.Errorf("%s is not a map", item.Type().String())
@ -125,8 +125,8 @@ func (c *ContractReader) AnyMaps(m map[*big.Int]any) (map[*big.Int]any, error) {
res[k] = v
}
return res, nil
} (item)
} (unwrap.Item(c.invoker.Call(c.hash, "anyMaps", m)))
}(item)
}(unwrap.Item(c.invoker.Call(c.hash, "anyMaps", m)))
}
// Bool invokes `bool` method of contract.
@ -151,11 +151,11 @@ func (c *ContractReader) Bytess(b [][]byte) ([][]byte, error) {
// CrazyMaps invokes `crazyMaps` method of contract.
func (c *ContractReader) CrazyMaps(m map[*big.Int][]map[string][]util.Uint160) (map[*big.Int][]map[string][]util.Uint160, error) {
return func (item stackitem.Item, err error) (map[*big.Int][]map[string][]util.Uint160, error) {
return func(item stackitem.Item, err error) (map[*big.Int][]map[string][]util.Uint160, error) {
if err != nil {
return nil, err
}
return func (item stackitem.Item) (map[*big.Int][]map[string][]util.Uint160, error) {
return func(item stackitem.Item) (map[*big.Int][]map[string][]util.Uint160, error) {
m, ok := item.Value().([]stackitem.MapElement)
if !ok {
return nil, fmt.Errorf("%s is not a map", item.Type().String())
@ -166,21 +166,21 @@ func (c *ContractReader) CrazyMaps(m map[*big.Int][]map[string][]util.Uint160) (
if err != nil {
return nil, fmt.Errorf("key %d: %w", i, err)
}
v, err := func (item stackitem.Item) ([]map[string][]util.Uint160, error) {
v, err := func(item stackitem.Item) ([]map[string][]util.Uint160, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
}
res := make([]map[string][]util.Uint160, len(arr))
for i := range res {
res[i], err = func (item stackitem.Item) (map[string][]util.Uint160, error) {
res[i], err = func(item stackitem.Item) (map[string][]util.Uint160, error) {
m, ok := item.Value().([]stackitem.MapElement)
if !ok {
return nil, fmt.Errorf("%s is not a map", item.Type().String())
}
res := make(map[string][]util.Uint160)
for i := range m {
k, err := func (item stackitem.Item) (string, error) {
k, err := func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
@ -189,18 +189,18 @@ func (c *ContractReader) CrazyMaps(m map[*big.Int][]map[string][]util.Uint160) (
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
} (m[i].Key)
}(m[i].Key)
if err != nil {
return nil, fmt.Errorf("key %d: %w", i, err)
}
v, err := func (item stackitem.Item) ([]util.Uint160, error) {
v, err := func(item stackitem.Item) ([]util.Uint160, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
}
res := make([]util.Uint160, len(arr))
for i := range res {
res[i], err = func (item stackitem.Item) (util.Uint160, error) {
res[i], err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -210,34 +210,34 @@ func (c *ContractReader) CrazyMaps(m map[*big.Int][]map[string][]util.Uint160) (
return util.Uint160{}, err
}
return u, nil
} (arr[i])
}(arr[i])
if err != nil {
return nil, fmt.Errorf("item %d: %w", i, err)
}
}
return res, nil
} (m[i].Value)
}(m[i].Value)
if err != nil {
return nil, fmt.Errorf("value %d: %w", i, err)
}
res[k] = v
}
return res, nil
} (arr[i])
}(arr[i])
if err != nil {
return nil, fmt.Errorf("item %d: %w", i, err)
}
}
return res, nil
} (m[i].Value)
}(m[i].Value)
if err != nil {
return nil, fmt.Errorf("value %d: %w", i, err)
}
res[k] = v
}
return res, nil
} (item)
} (unwrap.Item(c.invoker.Call(c.hash, "crazyMaps", m)))
}(item)
}(unwrap.Item(c.invoker.Call(c.hash, "crazyMaps", m)))
}
// Hash160 invokes `hash160` method of contract.
@ -272,18 +272,18 @@ func (c *ContractReader) Ints(i []*big.Int) ([]*big.Int, error) {
// Maps invokes `maps` method of contract.
func (c *ContractReader) Maps(m map[string]string) (map[string]string, error) {
return func (item stackitem.Item, err error) (map[string]string, error) {
return func(item stackitem.Item, err error) (map[string]string, error) {
if err != nil {
return nil, err
}
return func (item stackitem.Item) (map[string]string, error) {
return func(item stackitem.Item) (map[string]string, error) {
m, ok := item.Value().([]stackitem.MapElement)
if !ok {
return nil, fmt.Errorf("%s is not a map", item.Type().String())
}
res := make(map[string]string)
for i := range m {
k, err := func (item stackitem.Item) (string, error) {
k, err := func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
@ -292,11 +292,11 @@ func (c *ContractReader) Maps(m map[string]string) (map[string]string, error) {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
} (m[i].Key)
}(m[i].Key)
if err != nil {
return nil, fmt.Errorf("key %d: %w", i, err)
}
v, err := func (item stackitem.Item) (string, error) {
v, err := func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
@ -305,15 +305,15 @@ func (c *ContractReader) Maps(m map[string]string) (map[string]string, error) {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
} (m[i].Value)
}(m[i].Value)
if err != nil {
return nil, fmt.Errorf("value %d: %w", i, err)
}
res[k] = v
}
return res, nil
} (item)
} (unwrap.Item(c.invoker.Call(c.hash, "maps", m)))
}(item)
}(unwrap.Item(c.invoker.Call(c.hash, "maps", m)))
}
// PublicKey invokes `publicKey` method of contract.

View file

@ -31,32 +31,32 @@ func NewReader(invoker Invoker, hash util.Uint160) *ContractReader {
// AAAStrings invokes `aAAStrings` method of contract.
func (c *ContractReader) AAAStrings(s [][][]string) ([][][]string, error) {
return func (item stackitem.Item, err error) ([][][]string, error) {
return func(item stackitem.Item, err error) ([][][]string, error) {
if err != nil {
return nil, err
}
return func (item stackitem.Item) ([][][]string, error) {
return func(item stackitem.Item) ([][][]string, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
}
res := make([][][]string, len(arr))
for i := range res {
res[i], err = func (item stackitem.Item) ([][]string, error) {
res[i], err = func(item stackitem.Item) ([][]string, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
}
res := make([][]string, len(arr))
for i := range res {
res[i], err = func (item stackitem.Item) ([]string, error) {
res[i], err = func(item stackitem.Item) ([]string, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
}
res := make([]string, len(arr))
for i := range res {
res[i], err = func (item stackitem.Item) (string, error) {
res[i], err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
@ -65,45 +65,45 @@ func (c *ContractReader) AAAStrings(s [][][]string) ([][][]string, error) {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
} (arr[i])
}(arr[i])
if err != nil {
return nil, fmt.Errorf("item %d: %w", i, err)
}
}
return res, nil
} (arr[i])
}(arr[i])
if err != nil {
return nil, fmt.Errorf("item %d: %w", i, err)
}
}
return res, nil
} (arr[i])
}(arr[i])
if err != nil {
return nil, fmt.Errorf("item %d: %w", i, err)
}
}
return res, nil
} (item)
} (unwrap.Item(c.invoker.Call(c.hash, "aAAStrings", s)))
}(item)
}(unwrap.Item(c.invoker.Call(c.hash, "aAAStrings", s)))
}
// Any invokes `any` method of contract.
func (c *ContractReader) Any(a any) (any, error) {
return func (item stackitem.Item, err error) (any, error) {
return func(item stackitem.Item, err error) (any, error) {
if err != nil {
return nil, err
}
return item.Value(), error(nil)
} (unwrap.Item(c.invoker.Call(c.hash, "any", a)))
}(unwrap.Item(c.invoker.Call(c.hash, "any", a)))
}
// AnyMaps invokes `anyMaps` method of contract.
func (c *ContractReader) AnyMaps(m map[*big.Int]any) (map[*big.Int]any, error) {
return func (item stackitem.Item, err error) (map[*big.Int]any, error) {
return func(item stackitem.Item, err error) (map[*big.Int]any, error) {
if err != nil {
return nil, err
}
return func (item stackitem.Item) (map[*big.Int]any, error) {
return func(item stackitem.Item) (map[*big.Int]any, error) {
m, ok := item.Value().([]stackitem.MapElement)
if !ok {
return nil, fmt.Errorf("%s is not a map", item.Type().String())
@ -121,8 +121,8 @@ func (c *ContractReader) AnyMaps(m map[*big.Int]any) (map[*big.Int]any, error) {
res[k] = v
}
return res, nil
} (item)
} (unwrap.Item(c.invoker.Call(c.hash, "anyMaps", m)))
}(item)
}(unwrap.Item(c.invoker.Call(c.hash, "anyMaps", m)))
}
// Bool invokes `bool` method of contract.
@ -147,11 +147,11 @@ func (c *ContractReader) Bytess(b [][]byte) ([][]byte, error) {
// CrazyMaps invokes `crazyMaps` method of contract.
func (c *ContractReader) CrazyMaps(m map[*big.Int][]map[string][]util.Uint160) (map[*big.Int][]map[string][]util.Uint160, error) {
return func (item stackitem.Item, err error) (map[*big.Int][]map[string][]util.Uint160, error) {
return func(item stackitem.Item, err error) (map[*big.Int][]map[string][]util.Uint160, error) {
if err != nil {
return nil, err
}
return func (item stackitem.Item) (map[*big.Int][]map[string][]util.Uint160, error) {
return func(item stackitem.Item) (map[*big.Int][]map[string][]util.Uint160, error) {
m, ok := item.Value().([]stackitem.MapElement)
if !ok {
return nil, fmt.Errorf("%s is not a map", item.Type().String())
@ -162,21 +162,21 @@ func (c *ContractReader) CrazyMaps(m map[*big.Int][]map[string][]util.Uint160) (
if err != nil {
return nil, fmt.Errorf("key %d: %w", i, err)
}
v, err := func (item stackitem.Item) ([]map[string][]util.Uint160, error) {
v, err := func(item stackitem.Item) ([]map[string][]util.Uint160, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
}
res := make([]map[string][]util.Uint160, len(arr))
for i := range res {
res[i], err = func (item stackitem.Item) (map[string][]util.Uint160, error) {
res[i], err = func(item stackitem.Item) (map[string][]util.Uint160, error) {
m, ok := item.Value().([]stackitem.MapElement)
if !ok {
return nil, fmt.Errorf("%s is not a map", item.Type().String())
}
res := make(map[string][]util.Uint160)
for i := range m {
k, err := func (item stackitem.Item) (string, error) {
k, err := func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
@ -185,18 +185,18 @@ func (c *ContractReader) CrazyMaps(m map[*big.Int][]map[string][]util.Uint160) (
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
} (m[i].Key)
}(m[i].Key)
if err != nil {
return nil, fmt.Errorf("key %d: %w", i, err)
}
v, err := func (item stackitem.Item) ([]util.Uint160, error) {
v, err := func(item stackitem.Item) ([]util.Uint160, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
}
res := make([]util.Uint160, len(arr))
for i := range res {
res[i], err = func (item stackitem.Item) (util.Uint160, error) {
res[i], err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -206,34 +206,34 @@ func (c *ContractReader) CrazyMaps(m map[*big.Int][]map[string][]util.Uint160) (
return util.Uint160{}, err
}
return u, nil
} (arr[i])
}(arr[i])
if err != nil {
return nil, fmt.Errorf("item %d: %w", i, err)
}
}
return res, nil
} (m[i].Value)
}(m[i].Value)
if err != nil {
return nil, fmt.Errorf("value %d: %w", i, err)
}
res[k] = v
}
return res, nil
} (arr[i])
}(arr[i])
if err != nil {
return nil, fmt.Errorf("item %d: %w", i, err)
}
}
return res, nil
} (m[i].Value)
}(m[i].Value)
if err != nil {
return nil, fmt.Errorf("value %d: %w", i, err)
}
res[k] = v
}
return res, nil
} (item)
} (unwrap.Item(c.invoker.Call(c.hash, "crazyMaps", m)))
}(item)
}(unwrap.Item(c.invoker.Call(c.hash, "crazyMaps", m)))
}
// Hash160 invokes `hash160` method of contract.
@ -268,18 +268,18 @@ func (c *ContractReader) Ints(i []*big.Int) ([]*big.Int, error) {
// Maps invokes `maps` method of contract.
func (c *ContractReader) Maps(m map[string]string) (map[string]string, error) {
return func (item stackitem.Item, err error) (map[string]string, error) {
return func(item stackitem.Item, err error) (map[string]string, error) {
if err != nil {
return nil, err
}
return func (item stackitem.Item) (map[string]string, error) {
return func(item stackitem.Item) (map[string]string, error) {
m, ok := item.Value().([]stackitem.MapElement)
if !ok {
return nil, fmt.Errorf("%s is not a map", item.Type().String())
}
res := make(map[string]string)
for i := range m {
k, err := func (item stackitem.Item) (string, error) {
k, err := func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
@ -288,11 +288,11 @@ func (c *ContractReader) Maps(m map[string]string) (map[string]string, error) {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
} (m[i].Key)
}(m[i].Key)
if err != nil {
return nil, fmt.Errorf("key %d: %w", i, err)
}
v, err := func (item stackitem.Item) (string, error) {
v, err := func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
@ -301,15 +301,15 @@ func (c *ContractReader) Maps(m map[string]string) (map[string]string, error) {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
} (m[i].Value)
}(m[i].Value)
if err != nil {
return nil, fmt.Errorf("value %d: %w", i, err)
}
res[k] = v
}
return res, nil
} (item)
} (unwrap.Item(c.invoker.Call(c.hash, "maps", m)))
}(item)
}(unwrap.Item(c.invoker.Call(c.hash, "maps", m)))
}
// PublicKey invokes `publicKey` method of contract.

View file

@ -123,7 +123,7 @@ func (e *HelloWorldEvent) FromStackItem(item *stackitem.Array) error {
err error
)
index++
e.Args, err = func (item stackitem.Item) ([]any, error) {
e.Args, err = func(item stackitem.Item) ([]any, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
@ -136,7 +136,7 @@ func (e *HelloWorldEvent) FromStackItem(item *stackitem.Array) error {
}
}
return res, nil
} (arr[index])
}(arr[index])
if err != nil {
return fmt.Errorf("field Args: %w", err)
}

View file

@ -3,6 +3,7 @@ package binding
import (
"bytes"
"fmt"
"go/format"
"go/token"
"io"
"sort"
@ -127,7 +128,32 @@ func Generate(cfg Config) error {
ctr.Imports = append(ctr.Imports, "github.com/nspcc-dev/neo-go/pkg/interop/neogointernal")
sort.Strings(ctr.Imports)
return srcTemplate.Execute(cfg.Output, ctr)
return FExecute(srcTemplate, cfg.Output, ctr)
}
// FExecute tries to execute given template over the data provided, apply gofmt
// rules to the result and write the result to the provided io.Writer. If a
// format error occurs while formatting the resulting binding, then the generated
// binding is written "as is" and no error is returned.
func FExecute(tmplt *template.Template, out io.Writer, data any) error {
in := bytes.NewBuffer(nil)
err := tmplt.Execute(in, data)
if err != nil {
return fmt.Errorf("failed to execute template: %w", err)
}
res := in.Bytes()
fmtRes, err := format.Source(res)
if err != nil {
// OK, still write something to the resulting file, our generator has known
// bugs that make the resulting code uncompilable.
fmtRes = res
}
_, err = out.Write(fmtRes)
if err != nil {
return fmt.Errorf("failed to write the resulting binding: %w", err)
}
return nil
}
func scTypeToGo(name string, typ smartcontract.ParamType, cfg *Config) (string, string) {

View file

@ -34,7 +34,7 @@ func (c *ContractReader) {{.Name}}({{range $index, $arg := .Arguments -}}
{{- if ne $index 0}}, {{end}}
{{- .Name}} {{.Type}}
{{- end}}) {{if .ReturnType }}({{ .ReturnType }}, error) {
return {{if and (not .ItemTo) (eq .Unwrapper "Item")}}func (item stackitem.Item, err error) ({{ .ReturnType }}, error) {
return {{if and (not .ItemTo) (eq .Unwrapper "Item")}}func(item stackitem.Item, err error) ({{ .ReturnType }}, error) {
if err != nil {
return nil, err
}
@ -464,7 +464,7 @@ func Generate(cfg binding.Config) error {
"upperFirst": upperFirst,
}).Parse(srcTmpl))
return srcTemplate.Execute(cfg.Output, ctr)
return binding.FExecute(srcTemplate, cfg.Output, ctr)
}
func dropManifestMethods(meths []manifest.Method, manifested []manifest.Method) []manifest.Method {
@ -570,7 +570,7 @@ func etTypeConverter(et binding.ExtendedType, v string) string {
case smartcontract.ByteArrayType, smartcontract.SignatureType:
return v + ".TryBytes()"
case smartcontract.StringType:
return `func (item stackitem.Item) (string, error) {
return `func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
@ -579,9 +579,9 @@ func etTypeConverter(et binding.ExtendedType, v string) string {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
} (` + v + `)`
}(` + v + `)`
case smartcontract.Hash160Type:
return `func (item stackitem.Item) (util.Uint160, error) {
return `func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
@ -591,9 +591,9 @@ func etTypeConverter(et binding.ExtendedType, v string) string {
return util.Uint160{}, err
}
return u, nil
} (` + v + `)`
}(` + v + `)`
case smartcontract.Hash256Type:
return `func (item stackitem.Item) (util.Uint256, error) {
return `func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
@ -603,9 +603,9 @@ func etTypeConverter(et binding.ExtendedType, v string) string {
return util.Uint256{}, err
}
return u, nil
} (` + v + `)`
}(` + v + `)`
case smartcontract.PublicKeyType:
return `func (item stackitem.Item) (*keys.PublicKey, error) {
return `func(item stackitem.Item) (*keys.PublicKey, error) {
b, err := item.TryBytes()
if err != nil {
return nil, err
@ -615,13 +615,13 @@ func etTypeConverter(et binding.ExtendedType, v string) string {
return nil, err
}
return k, nil
} (` + v + `)`
}(` + v + `)`
case smartcontract.ArrayType:
if len(et.Name) > 0 {
return "itemTo" + toTypeName(et.Name) + "(" + v + ", nil)"
} else if et.Value != nil {
at, _ := extendedTypeToGo(et, nil)
return `func (item stackitem.Item) (` + at + `, error) {
return `func(item stackitem.Item) (` + at + `, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
@ -634,7 +634,7 @@ func etTypeConverter(et binding.ExtendedType, v string) string {
}
}
return res, nil
} (` + v + `)`
}(` + v + `)`
}
return etTypeConverter(binding.ExtendedType{
Base: smartcontract.ArrayType,
@ -646,7 +646,7 @@ func etTypeConverter(et binding.ExtendedType, v string) string {
case smartcontract.MapType:
if et.Value != nil {
at, _ := extendedTypeToGo(et, nil)
return `func (item stackitem.Item) (` + at + `, error) {
return `func(item stackitem.Item) (` + at + `, error) {
m, ok := item.Value().([]stackitem.MapElement)
if !ok {
return nil, fmt.Errorf("%s is not a map", item.Type().String())
@ -664,7 +664,7 @@ func etTypeConverter(et binding.ExtendedType, v string) string {
res[k] = v
}
return res, nil
} (` + v + `)`
}(` + v + `)`
}
return etTypeConverter(binding.ExtendedType{
Base: smartcontract.MapType,

View file

@ -21,6 +21,7 @@ import (
"github.com/consensys/gnark/backend/groth16"
curve "github.com/consensys/gnark/backend/groth16/bls12-381"
"github.com/consensys/gnark/backend/witness"
"github.com/nspcc-dev/neo-go/pkg/smartcontract/binding"
"github.com/nspcc-dev/neo-go/pkg/util/slice"
)
@ -234,7 +235,7 @@ func GenerateVerifier(cfg Config) error {
"byteSliceToStr": byteSliceToStr,
}).Parse(goVerificationTmpl))
err := tmpl.Execute(cfg.Output, tmplParams{
err := binding.FExecute(tmpl, cfg.Output, tmplParams{
Alpha: alphaG1[:],
Beta: betaG2[:],
Gamma: gammaG2[:],
@ -242,7 +243,7 @@ func GenerateVerifier(cfg Config) error {
ICs: kvks,
})
if err != nil {
return fmt.Errorf("failed to generate template: %w", err)
return err
}
if cfg.CfgOutput != nil {