diff --git a/cli/smartcontract/generate_test.go b/cli/smartcontract/generate_test.go index d5674e5b0..4354ea4cc 100644 --- a/cli/smartcontract/generate_test.go +++ b/cli/smartcontract/generate_test.go @@ -310,7 +310,7 @@ type Invoker interface { // ContractReader implements safe contract methods. type ContractReader struct { invoker Invoker - hash util.Uint160 + hash util.Uint160 } // NewReader creates an instance of ContractReader using Hash and the given Invoker. diff --git a/cli/smartcontract/testdata/gas/gas.go b/cli/smartcontract/testdata/gas/gas.go index e83072fbb..ca890f291 100644 --- a/cli/smartcontract/testdata/gas/gas.go +++ b/cli/smartcontract/testdata/gas/gas.go @@ -25,7 +25,7 @@ type Actor interface { type ContractReader struct { nep17.TokenReader invoker Invoker - hash util.Uint160 + hash util.Uint160 } // Contract implements all contract methods. @@ -33,7 +33,7 @@ type Contract struct { ContractReader nep17.TokenWriter actor Actor - hash util.Uint160 + hash util.Uint160 } // NewReader creates an instance of ContractReader using Hash and the given Invoker. diff --git a/cli/smartcontract/testdata/nameservice/nns.go b/cli/smartcontract/testdata/nameservice/nns.go index 97bd878a3..aec40e3b8 100644 --- a/cli/smartcontract/testdata/nameservice/nns.go +++ b/cli/smartcontract/testdata/nameservice/nns.go @@ -21,14 +21,14 @@ var Hash = util.Uint160{0xde, 0x46, 0x5f, 0x5d, 0x50, 0x57, 0xcf, 0x33, 0x28, 0x // SetAdminEvent represents "SetAdmin" event emitted by the contract. type SetAdminEvent struct { - Name string + Name string OldAdmin util.Uint160 NewAdmin util.Uint160 } // RenewEvent represents "Renew" event emitted by the contract. type RenewEvent struct { - Name string + Name string OldExpiration *big.Int NewExpiration *big.Int } @@ -56,7 +56,7 @@ type Actor interface { type ContractReader struct { nep11.NonDivisibleReader invoker Invoker - hash util.Uint160 + hash util.Uint160 } // Contract implements all contract methods. @@ -64,7 +64,7 @@ type Contract struct { ContractReader nep11.BaseWriter actor Actor - hash util.Uint160 + hash util.Uint160 } // NewReader creates an instance of ContractReader using Hash and the given Invoker. @@ -383,10 +383,10 @@ func (e *SetAdminEvent) FromStackItem(item *stackitem.Array) error { var ( index = -1 - err 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) } @@ -476,10 +476,10 @@ func (e *RenewEvent) FromStackItem(item *stackitem.Array) error { var ( index = -1 - err 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) } diff --git a/cli/smartcontract/testdata/nex/nex.go b/cli/smartcontract/testdata/nex/nex.go index 296a3d0e3..089d10f79 100644 --- a/cli/smartcontract/testdata/nex/nex.go +++ b/cli/smartcontract/testdata/nex/nex.go @@ -19,8 +19,8 @@ var Hash = util.Uint160{0xa8, 0x1a, 0xa1, 0xf0, 0x4b, 0xf, 0xdc, 0x4a, 0xa2, 0xc // OnMintEvent represents "OnMint" event emitted by the contract. type OnMintEvent struct { - From util.Uint160 - To util.Uint160 + From util.Uint160 + To util.Uint160 Amount *big.Int SwapId *big.Int } @@ -48,7 +48,7 @@ type Actor interface { type ContractReader struct { nep17.TokenReader invoker Invoker - hash util.Uint160 + hash util.Uint160 } // Contract implements all contract methods. @@ -56,7 +56,7 @@ type Contract struct { ContractReader nep17.TokenWriter actor Actor - hash util.Uint160 + hash util.Uint160 } // NewReader creates an instance of ContractReader using Hash and the given Invoker. @@ -287,10 +287,10 @@ func (e *OnMintEvent) FromStackItem(item *stackitem.Array) error { var ( index = -1 - err 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) } diff --git a/cli/smartcontract/testdata/nonepiter/iter.go b/cli/smartcontract/testdata/nonepiter/iter.go index d9fac3f73..c296ade05 100644 --- a/cli/smartcontract/testdata/nonepiter/iter.go +++ b/cli/smartcontract/testdata/nonepiter/iter.go @@ -23,7 +23,7 @@ type Invoker interface { // ContractReader implements safe contract methods. type ContractReader struct { invoker Invoker - hash util.Uint160 + hash util.Uint160 } // NewReader creates an instance of ContractReader using Hash and the given Invoker. diff --git a/cli/smartcontract/testdata/rpcbindings/notifications/rpcbindings.out b/cli/smartcontract/testdata/rpcbindings/notifications/rpcbindings.out index be2bb47be..399e0e283 100644 --- a/cli/smartcontract/testdata/rpcbindings/notifications/rpcbindings.out +++ b/cli/smartcontract/testdata/rpcbindings/notifications/rpcbindings.out @@ -19,61 +19,61 @@ var Hash = util.Uint160{0x33, 0x22, 0x11, 0x0, 0xff, 0xee, 0xdd, 0xcc, 0xbb, 0xa // LedgerBlock is a contract-specific ledger.Block type used by its methods. type LedgerBlock struct { - Hash util.Uint256 - Version *big.Int - PrevHash util.Uint256 - MerkleRoot util.Uint256 - Timestamp *big.Int - Nonce *big.Int - Index *big.Int - NextConsensus util.Uint160 + Hash util.Uint256 + Version *big.Int + PrevHash util.Uint256 + MerkleRoot util.Uint256 + Timestamp *big.Int + Nonce *big.Int + Index *big.Int + NextConsensus util.Uint160 TransactionsLength *big.Int } // LedgerBlockSR is a contract-specific ledger.BlockSR type used by its methods. type LedgerBlockSR struct { - Hash util.Uint256 - Version *big.Int - PrevHash util.Uint256 - MerkleRoot util.Uint256 - Timestamp *big.Int - Nonce *big.Int - Index *big.Int - NextConsensus util.Uint160 + Hash util.Uint256 + Version *big.Int + PrevHash util.Uint256 + MerkleRoot util.Uint256 + Timestamp *big.Int + Nonce *big.Int + Index *big.Int + NextConsensus util.Uint160 TransactionsLength *big.Int - PrevStateRoot util.Uint256 + PrevStateRoot util.Uint256 } // LedgerTransaction is a contract-specific ledger.Transaction type used by its methods. type LedgerTransaction struct { - Hash util.Uint256 - Version *big.Int - Nonce *big.Int - Sender util.Uint160 - SysFee *big.Int - NetFee *big.Int + Hash util.Uint256 + Version *big.Int + Nonce *big.Int + Sender util.Uint160 + SysFee *big.Int + NetFee *big.Int ValidUntilBlock *big.Int - Script []byte + Script []byte } // LedgerTransactionSigner is a contract-specific ledger.TransactionSigner type used by its methods. type LedgerTransactionSigner struct { - Account util.Uint160 - Scopes *big.Int + Account util.Uint160 + Scopes *big.Int AllowedContracts []util.Uint160 - AllowedGroups keys.PublicKeys - Rules []*LedgerWitnessRule + AllowedGroups keys.PublicKeys + Rules []*LedgerWitnessRule } // LedgerWitnessCondition is a contract-specific ledger.WitnessCondition type used by its methods. type LedgerWitnessCondition struct { - Type *big.Int + Type *big.Int Value any } // LedgerWitnessRule is a contract-specific ledger.WitnessRule type used by its methods. type LedgerWitnessRule struct { - Action *big.Int + Action *big.Int Condition *LedgerWitnessCondition } @@ -115,7 +115,7 @@ type Actor interface { // Contract implements all contract methods. type Contract struct { actor Actor - hash util.Uint160 + hash util.Uint160 } // New creates an instance of Contract using Hash and the given Actor. @@ -257,10 +257,10 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error { var ( index = -1 - err 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) } @@ -379,10 +379,10 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error { var ( index = -1 - err 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) } @@ -517,10 +517,10 @@ func (res *LedgerTransaction) FromStackItem(item stackitem.Item) error { var ( index = -1 - err 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) } @@ -613,10 +613,10 @@ func (res *LedgerTransactionSigner) FromStackItem(item stackitem.Item) error { var ( index = -1 - err 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) } @@ -740,7 +740,7 @@ func (res *LedgerWitnessCondition) FromStackItem(item stackitem.Item) error { var ( index = -1 - err error + err error ) index++ res.Type, err = arr[index].TryInteger() @@ -780,7 +780,7 @@ func (res *LedgerWitnessRule) FromStackItem(item stackitem.Item) error { var ( index = -1 - err error + err error ) index++ res.Action, err = arr[index].TryInteger() @@ -838,10 +838,10 @@ func (e *ComplicatedNameEvent) FromStackItem(item *stackitem.Array) error { var ( index = -1 - err 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) } @@ -899,10 +899,10 @@ func (e *SomeMapEvent) FromStackItem(item *stackitem.Array) error { var ( index = -1 - err 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) } @@ -969,10 +969,10 @@ func (e *SomeStructEvent) FromStackItem(item *stackitem.Array) error { var ( index = -1 - err 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) } @@ -1034,10 +1034,10 @@ func (e *SomeArrayEvent) FromStackItem(item *stackitem.Array) error { var ( index = -1 - err 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) } @@ -1099,10 +1099,10 @@ func (e *SomeUnexportedFieldEvent) FromStackItem(item *stackitem.Array) error { var ( index = -1 - err 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) } diff --git a/cli/smartcontract/testdata/rpcbindings/notifications/rpcbindings_extended.out b/cli/smartcontract/testdata/rpcbindings/notifications/rpcbindings_extended.out index 915814a00..1276a8238 100755 --- a/cli/smartcontract/testdata/rpcbindings/notifications/rpcbindings_extended.out +++ b/cli/smartcontract/testdata/rpcbindings/notifications/rpcbindings_extended.out @@ -25,61 +25,61 @@ type CrazyStruct struct { // LedgerBlock is a contract-specific ledger.Block type used by its methods. type LedgerBlock struct { - Hash util.Uint256 - Version *big.Int - PrevHash util.Uint256 - MerkleRoot util.Uint256 - Timestamp *big.Int - Nonce *big.Int - Index *big.Int - NextConsensus util.Uint160 + Hash util.Uint256 + Version *big.Int + PrevHash util.Uint256 + MerkleRoot util.Uint256 + Timestamp *big.Int + Nonce *big.Int + Index *big.Int + NextConsensus util.Uint160 TransactionsLength *big.Int } // LedgerBlockSR is a contract-specific ledger.BlockSR type used by its methods. type LedgerBlockSR struct { - Hash util.Uint256 - Version *big.Int - PrevHash util.Uint256 - MerkleRoot util.Uint256 - Timestamp *big.Int - Nonce *big.Int - Index *big.Int - NextConsensus util.Uint160 + Hash util.Uint256 + Version *big.Int + PrevHash util.Uint256 + MerkleRoot util.Uint256 + Timestamp *big.Int + Nonce *big.Int + Index *big.Int + NextConsensus util.Uint160 TransactionsLength *big.Int - PrevStateRoot util.Uint256 + PrevStateRoot util.Uint256 } // LedgerTransaction is a contract-specific ledger.Transaction type used by its methods. type LedgerTransaction struct { - Hash util.Uint256 - Version *big.Int - Nonce *big.Int - Sender util.Uint160 - SysFee *big.Int - NetFee *big.Int + Hash util.Uint256 + Version *big.Int + Nonce *big.Int + Sender util.Uint160 + SysFee *big.Int + NetFee *big.Int ValidUntilBlock *big.Int - Script []byte + Script []byte } // LedgerTransactionSigner is a contract-specific ledger.TransactionSigner type used by its methods. type LedgerTransactionSigner struct { - Account util.Uint160 - Scopes *big.Int + Account util.Uint160 + Scopes *big.Int AllowedContracts []util.Uint160 - AllowedGroups keys.PublicKeys - Rules []*LedgerWitnessRule + AllowedGroups keys.PublicKeys + Rules []*LedgerWitnessRule } // LedgerWitnessCondition is a contract-specific ledger.WitnessCondition type used by its methods. type LedgerWitnessCondition struct { - Type *big.Int + Type *big.Int Value any } // LedgerWitnessRule is a contract-specific ledger.WitnessRule type used by its methods. type LedgerWitnessRule struct { - Action *big.Int + Action *big.Int Condition *LedgerWitnessCondition } @@ -126,7 +126,7 @@ type Actor interface { // Contract implements all contract methods. type Contract struct { actor Actor - hash util.Uint160 + hash util.Uint160 } // New creates an instance of Contract using Hash and the given Actor. @@ -268,7 +268,7 @@ func (res *CrazyStruct) FromStackItem(item stackitem.Item) error { var ( index = -1 - err error + err error ) index++ res.I, err = arr[index].TryInteger() @@ -308,10 +308,10 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error { var ( index = -1 - err 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) } @@ -430,10 +430,10 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error { var ( index = -1 - err 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) } @@ -568,10 +568,10 @@ func (res *LedgerTransaction) FromStackItem(item stackitem.Item) error { var ( index = -1 - err 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) } @@ -664,10 +664,10 @@ func (res *LedgerTransactionSigner) FromStackItem(item stackitem.Item) error { var ( index = -1 - err 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) } @@ -791,7 +791,7 @@ func (res *LedgerWitnessCondition) FromStackItem(item stackitem.Item) error { var ( index = -1 - err error + err error ) index++ res.Type, err = arr[index].TryInteger() @@ -831,7 +831,7 @@ func (res *LedgerWitnessRule) FromStackItem(item stackitem.Item) error { var ( index = -1 - err error + err error ) index++ res.Action, err = arr[index].TryInteger() @@ -871,7 +871,7 @@ func (res *SimpleStruct) FromStackItem(item stackitem.Item) error { var ( index = -1 - err error + err error ) index++ res.I, err = arr[index].TryInteger() @@ -923,10 +923,10 @@ func (e *ComplicatedNameEvent) FromStackItem(item *stackitem.Array) error { var ( index = -1 - err 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) } @@ -984,10 +984,10 @@ func (e *SomeMapEvent) FromStackItem(item *stackitem.Array) error { var ( index = -1 - err 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) } @@ -1104,7 +1104,7 @@ func (e *SomeStructEvent) FromStackItem(item *stackitem.Array) error { var ( index = -1 - err error + err error ) index++ e.S, err = itemToCrazyStruct(arr[index], nil) @@ -1156,17 +1156,17 @@ func (e *SomeArrayEvent) FromStackItem(item *stackitem.Array) error { var ( index = -1 - err 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) } @@ -1234,7 +1234,7 @@ func (e *SomeUnexportedFieldEvent) FromStackItem(item *stackitem.Array) error { var ( index = -1 - err error + err error ) index++ e.S, err = itemToSimpleStruct(arr[index], nil) diff --git a/cli/smartcontract/testdata/rpcbindings/notifications/rpcbindings_guessed.out b/cli/smartcontract/testdata/rpcbindings/notifications/rpcbindings_guessed.out index bf7032c70..025a47ee7 100755 --- a/cli/smartcontract/testdata/rpcbindings/notifications/rpcbindings_guessed.out +++ b/cli/smartcontract/testdata/rpcbindings/notifications/rpcbindings_guessed.out @@ -19,61 +19,61 @@ var Hash = util.Uint160{0x33, 0x22, 0x11, 0x0, 0xff, 0xee, 0xdd, 0xcc, 0xbb, 0xa // LedgerBlock is a contract-specific ledger.Block type used by its methods. type LedgerBlock struct { - Hash util.Uint256 - Version *big.Int - PrevHash util.Uint256 - MerkleRoot util.Uint256 - Timestamp *big.Int - Nonce *big.Int - Index *big.Int - NextConsensus util.Uint160 + Hash util.Uint256 + Version *big.Int + PrevHash util.Uint256 + MerkleRoot util.Uint256 + Timestamp *big.Int + Nonce *big.Int + Index *big.Int + NextConsensus util.Uint160 TransactionsLength *big.Int } // LedgerBlockSR is a contract-specific ledger.BlockSR type used by its methods. type LedgerBlockSR struct { - Hash util.Uint256 - Version *big.Int - PrevHash util.Uint256 - MerkleRoot util.Uint256 - Timestamp *big.Int - Nonce *big.Int - Index *big.Int - NextConsensus util.Uint160 + Hash util.Uint256 + Version *big.Int + PrevHash util.Uint256 + MerkleRoot util.Uint256 + Timestamp *big.Int + Nonce *big.Int + Index *big.Int + NextConsensus util.Uint160 TransactionsLength *big.Int - PrevStateRoot util.Uint256 + PrevStateRoot util.Uint256 } // LedgerTransaction is a contract-specific ledger.Transaction type used by its methods. type LedgerTransaction struct { - Hash util.Uint256 - Version *big.Int - Nonce *big.Int - Sender util.Uint160 - SysFee *big.Int - NetFee *big.Int + Hash util.Uint256 + Version *big.Int + Nonce *big.Int + Sender util.Uint160 + SysFee *big.Int + NetFee *big.Int ValidUntilBlock *big.Int - Script []byte + Script []byte } // LedgerTransactionSigner is a contract-specific ledger.TransactionSigner type used by its methods. type LedgerTransactionSigner struct { - Account util.Uint160 - Scopes *big.Int + Account util.Uint160 + Scopes *big.Int AllowedContracts []util.Uint160 - AllowedGroups keys.PublicKeys - Rules []*LedgerWitnessRule + AllowedGroups keys.PublicKeys + Rules []*LedgerWitnessRule } // LedgerWitnessCondition is a contract-specific ledger.WitnessCondition type used by its methods. type LedgerWitnessCondition struct { - Type *big.Int + Type *big.Int Value any } // LedgerWitnessRule is a contract-specific ledger.WitnessRule type used by its methods. type LedgerWitnessRule struct { - Action *big.Int + Action *big.Int Condition *LedgerWitnessCondition } @@ -121,7 +121,7 @@ type Actor interface { // Contract implements all contract methods. type Contract struct { actor Actor - hash util.Uint160 + hash util.Uint160 } // New creates an instance of Contract using Hash and the given Actor. @@ -263,10 +263,10 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error { var ( index = -1 - err 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) } @@ -385,10 +385,10 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error { var ( index = -1 - err 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) } @@ -523,10 +523,10 @@ func (res *LedgerTransaction) FromStackItem(item stackitem.Item) error { var ( index = -1 - err 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) } @@ -619,10 +619,10 @@ func (res *LedgerTransactionSigner) FromStackItem(item stackitem.Item) error { var ( index = -1 - err 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) } @@ -746,7 +746,7 @@ func (res *LedgerWitnessCondition) FromStackItem(item stackitem.Item) error { var ( index = -1 - err error + err error ) index++ res.Type, err = arr[index].TryInteger() @@ -786,7 +786,7 @@ func (res *LedgerWitnessRule) FromStackItem(item stackitem.Item) error { var ( index = -1 - err error + err error ) index++ res.Action, err = arr[index].TryInteger() @@ -826,7 +826,7 @@ func (res *Unnamed) FromStackItem(item stackitem.Item) error { var ( index = -1 - err error + err error ) index++ res.I, err = arr[index].TryInteger() @@ -884,10 +884,10 @@ func (e *ComplicatedNameEvent) FromStackItem(item *stackitem.Array) error { var ( index = -1 - err 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) } @@ -945,10 +945,10 @@ func (e *SomeMapEvent) FromStackItem(item *stackitem.Array) error { var ( index = -1 - err 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) } @@ -1078,7 +1078,7 @@ func (e *SomeStructEvent) FromStackItem(item *stackitem.Array) error { var ( index = -1 - err error + err error ) index++ e.S, err = itemToUnnamed(arr[index], nil) @@ -1130,17 +1130,17 @@ func (e *SomeArrayEvent) FromStackItem(item *stackitem.Array) error { var ( index = -1 - err 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) } @@ -1208,7 +1208,7 @@ func (e *SomeUnexportedFieldEvent) FromStackItem(item *stackitem.Array) error { var ( index = -1 - err error + err error ) index++ e.S, err = itemToUnnamed(arr[index], nil) diff --git a/cli/smartcontract/testdata/rpcbindings/structs/rpcbindings.out b/cli/smartcontract/testdata/rpcbindings/structs/rpcbindings.out index d9c7ebdcc..0afbef67a 100644 --- a/cli/smartcontract/testdata/rpcbindings/structs/rpcbindings.out +++ b/cli/smartcontract/testdata/rpcbindings/structs/rpcbindings.out @@ -19,82 +19,82 @@ var Hash = util.Uint160{0x33, 0x22, 0x11, 0x0, 0xff, 0xee, 0xdd, 0xcc, 0xbb, 0xa // LedgerBlock is a contract-specific ledger.Block type used by its methods. type LedgerBlock struct { - Hash util.Uint256 - Version *big.Int - PrevHash util.Uint256 - MerkleRoot util.Uint256 - Timestamp *big.Int - Nonce *big.Int - Index *big.Int - NextConsensus util.Uint160 + Hash util.Uint256 + Version *big.Int + PrevHash util.Uint256 + MerkleRoot util.Uint256 + Timestamp *big.Int + Nonce *big.Int + Index *big.Int + NextConsensus util.Uint160 TransactionsLength *big.Int } // LedgerBlockSR is a contract-specific ledger.BlockSR type used by its methods. type LedgerBlockSR struct { - Hash util.Uint256 - Version *big.Int - PrevHash util.Uint256 - MerkleRoot util.Uint256 - Timestamp *big.Int - Nonce *big.Int - Index *big.Int - NextConsensus util.Uint160 + Hash util.Uint256 + Version *big.Int + PrevHash util.Uint256 + MerkleRoot util.Uint256 + Timestamp *big.Int + Nonce *big.Int + Index *big.Int + NextConsensus util.Uint160 TransactionsLength *big.Int - PrevStateRoot util.Uint256 + PrevStateRoot util.Uint256 } // LedgerTransaction is a contract-specific ledger.Transaction type used by its methods. type LedgerTransaction struct { - Hash util.Uint256 - Version *big.Int - Nonce *big.Int - Sender util.Uint160 - SysFee *big.Int - NetFee *big.Int + Hash util.Uint256 + Version *big.Int + Nonce *big.Int + Sender util.Uint160 + SysFee *big.Int + NetFee *big.Int ValidUntilBlock *big.Int - Script []byte + Script []byte } // LedgerTransactionSigner is a contract-specific ledger.TransactionSigner type used by its methods. type LedgerTransactionSigner struct { - Account util.Uint160 - Scopes *big.Int + Account util.Uint160 + Scopes *big.Int AllowedContracts []util.Uint160 - AllowedGroups keys.PublicKeys - Rules []*LedgerWitnessRule + AllowedGroups keys.PublicKeys + Rules []*LedgerWitnessRule } // LedgerWitnessCondition is a contract-specific ledger.WitnessCondition type used by its methods. type LedgerWitnessCondition struct { - Type *big.Int + Type *big.Int Value any } // LedgerWitnessRule is a contract-specific ledger.WitnessRule type used by its methods. type LedgerWitnessRule struct { - Action *big.Int + Action *big.Int Condition *LedgerWitnessCondition } // ManagementABI is a contract-specific management.ABI type used by its methods. type ManagementABI struct { Methods []*ManagementMethod - Events []*ManagementEvent + Events []*ManagementEvent } // ManagementContract is a contract-specific management.Contract type used by its methods. type ManagementContract struct { - ID *big.Int + ID *big.Int UpdateCounter *big.Int - Hash util.Uint160 - NEF []byte - Manifest *ManagementManifest + Hash util.Uint160 + NEF []byte + Manifest *ManagementManifest } // ManagementEvent is a contract-specific management.Event type used by its methods. type ManagementEvent struct { - Name string + Name string Params []*ManagementParameter } @@ -106,23 +106,23 @@ type ManagementGroup struct { // ManagementManifest is a contract-specific management.Manifest type used by its methods. type ManagementManifest struct { - Name string - Groups []*ManagementGroup - Features map[string]string + Name string + Groups []*ManagementGroup + Features map[string]string SupportedStandards []string - ABI *ManagementABI - Permissions []*ManagementPermission - Trusts []util.Uint160 - Extra any + ABI *ManagementABI + Permissions []*ManagementPermission + Trusts []util.Uint160 + Extra any } // ManagementMethod is a contract-specific management.Method type used by its methods. type ManagementMethod struct { - Name string - Params []*ManagementParameter + Name string + Params []*ManagementParameter ReturnType *big.Int - Offset *big.Int - Safe bool + Offset *big.Int + Safe bool } // ManagementParameter is a contract-specific management.Parameter type used by its methods. @@ -134,24 +134,24 @@ type ManagementParameter struct { // ManagementPermission is a contract-specific management.Permission type used by its methods. type ManagementPermission struct { Contract util.Uint160 - Methods []string + Methods []string } // StructsInternal is a contract-specific structs.Internal type used by its methods. type StructsInternal struct { - Bool bool - Int *big.Int - Bytes []byte - String string - H160 util.Uint160 - H256 util.Uint256 - PK *keys.PublicKey - PubKey *keys.PublicKey - Sign []byte - ArrOfBytes [][]byte - ArrOfH160 []util.Uint160 - Map map[*big.Int]keys.PublicKeys - Struct *StructsInternal + Bool bool + Int *big.Int + Bytes []byte + String string + H160 util.Uint160 + H256 util.Uint256 + PK *keys.PublicKey + PubKey *keys.PublicKey + Sign []byte + ArrOfBytes [][]byte + ArrOfH160 []util.Uint160 + Map map[*big.Int]keys.PublicKeys + Struct *StructsInternal UnexportedField *big.Int } @@ -163,7 +163,7 @@ type Invoker interface { // ContractReader implements safe contract methods. type ContractReader struct { invoker Invoker - hash util.Uint160 + hash util.Uint160 } // NewReader creates an instance of ContractReader using Hash and the given Invoker. @@ -215,10 +215,10 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error { var ( index = -1 - err 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) } @@ -337,10 +337,10 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error { var ( index = -1 - err 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) } @@ -475,10 +475,10 @@ func (res *LedgerTransaction) FromStackItem(item stackitem.Item) error { var ( index = -1 - err 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) } @@ -571,10 +571,10 @@ func (res *LedgerTransactionSigner) FromStackItem(item stackitem.Item) error { var ( index = -1 - err 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) } @@ -698,7 +698,7 @@ func (res *LedgerWitnessCondition) FromStackItem(item stackitem.Item) error { var ( index = -1 - err error + err error ) index++ res.Type, err = arr[index].TryInteger() @@ -738,7 +738,7 @@ func (res *LedgerWitnessRule) FromStackItem(item stackitem.Item) error { var ( index = -1 - err error + err error ) index++ res.Action, err = arr[index].TryInteger() @@ -778,10 +778,10 @@ func (res *ManagementABI) FromStackItem(item stackitem.Item) error { var ( index = -1 - err 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) } @@ -844,7 +844,7 @@ func (res *ManagementContract) FromStackItem(item stackitem.Item) error { var ( index = -1 - err error + err error ) index++ res.ID, err = arr[index].TryInteger() @@ -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) } @@ -912,10 +912,10 @@ func (res *ManagementEvent) FromStackItem(item stackitem.Item) error { var ( index = -1 - err 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) } @@ -974,10 +974,10 @@ func (res *ManagementGroup) FromStackItem(item stackitem.Item) error { var ( index = -1 - err 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) } @@ -1024,10 +1024,10 @@ func (res *ManagementManifest) FromStackItem(item stackitem.Item) error { var ( index = -1 - err 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) } @@ -1216,10 +1216,10 @@ func (res *ManagementMethod) FromStackItem(item stackitem.Item) error { var ( index = -1 - err 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) } @@ -1296,10 +1296,10 @@ func (res *ManagementParameter) FromStackItem(item stackitem.Item) error { var ( index = -1 - err 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) } @@ -1345,10 +1345,10 @@ func (res *ManagementPermission) FromStackItem(item stackitem.Item) error { var ( index = -1 - err 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) } @@ -1417,7 +1417,7 @@ func (res *StructsInternal) FromStackItem(item stackitem.Item) error { var ( index = -1 - err error + err error ) index++ res.Bool, err = arr[index].TryBool() @@ -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) } diff --git a/cli/smartcontract/testdata/rpcbindings/structs/rpcbindings_dynamic_hash.out b/cli/smartcontract/testdata/rpcbindings/structs/rpcbindings_dynamic_hash.out index 98280d010..e869574da 100755 --- a/cli/smartcontract/testdata/rpcbindings/structs/rpcbindings_dynamic_hash.out +++ b/cli/smartcontract/testdata/rpcbindings/structs/rpcbindings_dynamic_hash.out @@ -16,82 +16,82 @@ import ( // LedgerBlock is a contract-specific ledger.Block type used by its methods. type LedgerBlock struct { - Hash util.Uint256 - Version *big.Int - PrevHash util.Uint256 - MerkleRoot util.Uint256 - Timestamp *big.Int - Nonce *big.Int - Index *big.Int - NextConsensus util.Uint160 + Hash util.Uint256 + Version *big.Int + PrevHash util.Uint256 + MerkleRoot util.Uint256 + Timestamp *big.Int + Nonce *big.Int + Index *big.Int + NextConsensus util.Uint160 TransactionsLength *big.Int } // LedgerBlockSR is a contract-specific ledger.BlockSR type used by its methods. type LedgerBlockSR struct { - Hash util.Uint256 - Version *big.Int - PrevHash util.Uint256 - MerkleRoot util.Uint256 - Timestamp *big.Int - Nonce *big.Int - Index *big.Int - NextConsensus util.Uint160 + Hash util.Uint256 + Version *big.Int + PrevHash util.Uint256 + MerkleRoot util.Uint256 + Timestamp *big.Int + Nonce *big.Int + Index *big.Int + NextConsensus util.Uint160 TransactionsLength *big.Int - PrevStateRoot util.Uint256 + PrevStateRoot util.Uint256 } // LedgerTransaction is a contract-specific ledger.Transaction type used by its methods. type LedgerTransaction struct { - Hash util.Uint256 - Version *big.Int - Nonce *big.Int - Sender util.Uint160 - SysFee *big.Int - NetFee *big.Int + Hash util.Uint256 + Version *big.Int + Nonce *big.Int + Sender util.Uint160 + SysFee *big.Int + NetFee *big.Int ValidUntilBlock *big.Int - Script []byte + Script []byte } // LedgerTransactionSigner is a contract-specific ledger.TransactionSigner type used by its methods. type LedgerTransactionSigner struct { - Account util.Uint160 - Scopes *big.Int + Account util.Uint160 + Scopes *big.Int AllowedContracts []util.Uint160 - AllowedGroups keys.PublicKeys - Rules []*LedgerWitnessRule + AllowedGroups keys.PublicKeys + Rules []*LedgerWitnessRule } // LedgerWitnessCondition is a contract-specific ledger.WitnessCondition type used by its methods. type LedgerWitnessCondition struct { - Type *big.Int + Type *big.Int Value any } // LedgerWitnessRule is a contract-specific ledger.WitnessRule type used by its methods. type LedgerWitnessRule struct { - Action *big.Int + Action *big.Int Condition *LedgerWitnessCondition } // ManagementABI is a contract-specific management.ABI type used by its methods. type ManagementABI struct { Methods []*ManagementMethod - Events []*ManagementEvent + Events []*ManagementEvent } // ManagementContract is a contract-specific management.Contract type used by its methods. type ManagementContract struct { - ID *big.Int + ID *big.Int UpdateCounter *big.Int - Hash util.Uint160 - NEF []byte - Manifest *ManagementManifest + Hash util.Uint160 + NEF []byte + Manifest *ManagementManifest } // ManagementEvent is a contract-specific management.Event type used by its methods. type ManagementEvent struct { - Name string + Name string Params []*ManagementParameter } @@ -103,23 +103,23 @@ type ManagementGroup struct { // ManagementManifest is a contract-specific management.Manifest type used by its methods. type ManagementManifest struct { - Name string - Groups []*ManagementGroup - Features map[string]string + Name string + Groups []*ManagementGroup + Features map[string]string SupportedStandards []string - ABI *ManagementABI - Permissions []*ManagementPermission - Trusts []util.Uint160 - Extra any + ABI *ManagementABI + Permissions []*ManagementPermission + Trusts []util.Uint160 + Extra any } // ManagementMethod is a contract-specific management.Method type used by its methods. type ManagementMethod struct { - Name string - Params []*ManagementParameter + Name string + Params []*ManagementParameter ReturnType *big.Int - Offset *big.Int - Safe bool + Offset *big.Int + Safe bool } // ManagementParameter is a contract-specific management.Parameter type used by its methods. @@ -131,24 +131,24 @@ type ManagementParameter struct { // ManagementPermission is a contract-specific management.Permission type used by its methods. type ManagementPermission struct { Contract util.Uint160 - Methods []string + Methods []string } // StructsInternal is a contract-specific structs.Internal type used by its methods. type StructsInternal struct { - Bool bool - Int *big.Int - Bytes []byte - String string - H160 util.Uint160 - H256 util.Uint256 - PK *keys.PublicKey - PubKey *keys.PublicKey - Sign []byte - ArrOfBytes [][]byte - ArrOfH160 []util.Uint160 - Map map[*big.Int]keys.PublicKeys - Struct *StructsInternal + Bool bool + Int *big.Int + Bytes []byte + String string + H160 util.Uint160 + H256 util.Uint256 + PK *keys.PublicKey + PubKey *keys.PublicKey + Sign []byte + ArrOfBytes [][]byte + ArrOfH160 []util.Uint160 + Map map[*big.Int]keys.PublicKeys + Struct *StructsInternal UnexportedField *big.Int } @@ -160,7 +160,7 @@ type Invoker interface { // ContractReader implements safe contract methods. type ContractReader struct { invoker Invoker - hash util.Uint160 + hash util.Uint160 } // NewReader creates an instance of ContractReader using provided contract hash and the given Invoker. @@ -211,10 +211,10 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error { var ( index = -1 - err 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) } @@ -333,10 +333,10 @@ func (res *LedgerBlockSR) FromStackItem(item stackitem.Item) error { var ( index = -1 - err 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) } @@ -471,10 +471,10 @@ func (res *LedgerTransaction) FromStackItem(item stackitem.Item) error { var ( index = -1 - err 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) } @@ -567,10 +567,10 @@ func (res *LedgerTransactionSigner) FromStackItem(item stackitem.Item) error { var ( index = -1 - err 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) } @@ -694,7 +694,7 @@ func (res *LedgerWitnessCondition) FromStackItem(item stackitem.Item) error { var ( index = -1 - err error + err error ) index++ res.Type, err = arr[index].TryInteger() @@ -734,7 +734,7 @@ func (res *LedgerWitnessRule) FromStackItem(item stackitem.Item) error { var ( index = -1 - err error + err error ) index++ res.Action, err = arr[index].TryInteger() @@ -774,10 +774,10 @@ func (res *ManagementABI) FromStackItem(item stackitem.Item) error { var ( index = -1 - err 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) } @@ -840,7 +840,7 @@ func (res *ManagementContract) FromStackItem(item stackitem.Item) error { var ( index = -1 - err error + err error ) index++ res.ID, err = arr[index].TryInteger() @@ -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) } @@ -908,10 +908,10 @@ func (res *ManagementEvent) FromStackItem(item stackitem.Item) error { var ( index = -1 - err 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) } @@ -970,10 +970,10 @@ func (res *ManagementGroup) FromStackItem(item stackitem.Item) error { var ( index = -1 - err 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) } @@ -1020,10 +1020,10 @@ func (res *ManagementManifest) FromStackItem(item stackitem.Item) error { var ( index = -1 - err 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) } @@ -1212,10 +1212,10 @@ func (res *ManagementMethod) FromStackItem(item stackitem.Item) error { var ( index = -1 - err 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) } @@ -1292,10 +1292,10 @@ func (res *ManagementParameter) FromStackItem(item stackitem.Item) error { var ( index = -1 - err 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) } @@ -1341,10 +1341,10 @@ func (res *ManagementPermission) FromStackItem(item stackitem.Item) error { var ( index = -1 - err 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) } @@ -1413,7 +1413,7 @@ func (res *StructsInternal) FromStackItem(item stackitem.Item) error { var ( index = -1 - err error + err error ) index++ res.Bool, err = arr[index].TryBool() @@ -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) } diff --git a/cli/smartcontract/testdata/rpcbindings/types/rpcbindings.out b/cli/smartcontract/testdata/rpcbindings/types/rpcbindings.out index ee61838d1..765c20937 100644 --- a/cli/smartcontract/testdata/rpcbindings/types/rpcbindings.out +++ b/cli/smartcontract/testdata/rpcbindings/types/rpcbindings.out @@ -24,7 +24,7 @@ type Invoker interface { // ContractReader implements safe contract methods. type ContractReader struct { invoker Invoker - hash util.Uint160 + hash util.Uint160 } // NewReader creates an instance of ContractReader using Hash and the given Invoker. @@ -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. diff --git a/cli/smartcontract/testdata/rpcbindings/types/rpcbindings_dynamic_hash.out b/cli/smartcontract/testdata/rpcbindings/types/rpcbindings_dynamic_hash.out index 1075e3260..0530e9912 100755 --- a/cli/smartcontract/testdata/rpcbindings/types/rpcbindings_dynamic_hash.out +++ b/cli/smartcontract/testdata/rpcbindings/types/rpcbindings_dynamic_hash.out @@ -21,7 +21,7 @@ type Invoker interface { // ContractReader implements safe contract methods. type ContractReader struct { invoker Invoker - hash util.Uint160 + hash util.Uint160 } // NewReader creates an instance of ContractReader using provided contract hash and the given Invoker. @@ -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. diff --git a/cli/smartcontract/testdata/verifyrpc/verify.go b/cli/smartcontract/testdata/verifyrpc/verify.go index 6a755aec0..905c3fb88 100644 --- a/cli/smartcontract/testdata/verifyrpc/verify.go +++ b/cli/smartcontract/testdata/verifyrpc/verify.go @@ -32,7 +32,7 @@ type Actor interface { // Contract implements all contract methods. type Contract struct { actor Actor - hash util.Uint160 + hash util.Uint160 } // New creates an instance of Contract using Hash and the given Actor. @@ -120,10 +120,10 @@ func (e *HelloWorldEvent) FromStackItem(item *stackitem.Array) error { var ( index = -1 - err 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) } diff --git a/pkg/smartcontract/binding/generate.go b/pkg/smartcontract/binding/generate.go index 7e6716908..a49d56029 100644 --- a/pkg/smartcontract/binding/generate.go +++ b/pkg/smartcontract/binding/generate.go @@ -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) { diff --git a/pkg/smartcontract/rpcbinding/binding.go b/pkg/smartcontract/rpcbinding/binding.go index 942791d9a..6e7b8bb29 100644 --- a/pkg/smartcontract/rpcbinding/binding.go +++ b/pkg/smartcontract/rpcbinding/binding.go @@ -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 { diff --git a/pkg/smartcontract/zkpbinding/binding.go b/pkg/smartcontract/zkpbinding/binding.go index fccfbf2ca..133f4bcf3 100644 --- a/pkg/smartcontract/zkpbinding/binding.go +++ b/pkg/smartcontract/zkpbinding/binding.go @@ -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 {