diff --git a/.ci/hello/HelloWorld.go b/.ci/hello/HelloWorld.go index acc9b05f..1393ceee 100644 --- a/.ci/hello/HelloWorld.go +++ b/.ci/hello/HelloWorld.go @@ -299,11 +299,11 @@ type HelloWorldSetValue struct { // WatchSetValue is a free log subscription operation binding the contract event 0x1cede41e194608a414a2e1d67987cf390338e67d0ff22be86dee2f3737c23d53. // // Solidity: event setValue(string v, address indexed from, address indexed to, uint256 value) -func (_HelloWorld *HelloWorldFilterer) WatchSetValue(fromBlock *uint64, handler func(int, []types.Log), from common.Address, to common.Address) (string, error) { +func (_HelloWorld *HelloWorldFilterer) WatchSetValue(fromBlock *int64, handler func(int, []types.Log), from common.Address, to common.Address) (string, error) { return _HelloWorld.contract.WatchLogs(fromBlock, handler, "setValue", from, to) } -func (_HelloWorld *HelloWorldFilterer) WatchAllSetValue(fromBlock *uint64, handler func(int, []types.Log)) (string, error) { +func (_HelloWorld *HelloWorldFilterer) WatchAllSetValue(fromBlock *int64, handler func(int, []types.Log)) (string, error) { return _HelloWorld.contract.WatchLogs(fromBlock, handler, "setValue") } @@ -321,11 +321,11 @@ func (_HelloWorld *HelloWorldFilterer) ParseSetValue(log types.Log) (*HelloWorld // WatchSetValue is a free log subscription operation binding the contract event 0x1cede41e194608a414a2e1d67987cf390338e67d0ff22be86dee2f3737c23d53. // // Solidity: event setValue(string v, address indexed from, address indexed to, uint256 value) -func (_HelloWorld *HelloWorldSession) WatchSetValue(fromBlock *uint64, handler func(int, []types.Log), from common.Address, to common.Address) (string, error) { +func (_HelloWorld *HelloWorldSession) WatchSetValue(fromBlock *int64, handler func(int, []types.Log), from common.Address, to common.Address) (string, error) { return _HelloWorld.Contract.WatchSetValue(fromBlock, handler, from, to) } -func (_HelloWorld *HelloWorldSession) WatchAllSetValue(fromBlock *uint64, handler func(int, []types.Log)) (string, error) { +func (_HelloWorld *HelloWorldSession) WatchAllSetValue(fromBlock *int64, handler func(int, []types.Log)) (string, error) { return _HelloWorld.Contract.WatchAllSetValue(fromBlock, handler) } diff --git a/.ci/store/Store.go b/.ci/store/Store.go index ebf8e5ed..01689e97 100644 --- a/.ci/store/Store.go +++ b/.ci/store/Store.go @@ -294,11 +294,11 @@ type StoreItemSet struct { // WatchItemSet is a free log subscription operation binding the contract event 0xe79e73da417710ae99aa2088575580a60415d359acfad9cdd3382d59c80281d4. // // Solidity: event ItemSet(bytes32 key, bytes32 value) -func (_Store *StoreFilterer) WatchItemSet(fromBlock *uint64, handler func(int, []types.Log)) error { +func (_Store *StoreFilterer) WatchItemSet(fromBlock *int64, handler func(int, []types.Log)) error { return _Store.contract.WatchLogs(fromBlock, handler, "ItemSet") } -func (_Store *StoreFilterer) WatchAllItemSet(fromBlock *uint64, handler func(int, []types.Log)) error { +func (_Store *StoreFilterer) WatchAllItemSet(fromBlock *int64, handler func(int, []types.Log)) error { return _Store.contract.WatchLogs(fromBlock, handler, "ItemSet") } @@ -316,11 +316,11 @@ func (_Store *StoreFilterer) ParseItemSet(log types.Log) (*StoreItemSet, error) // WatchItemSet is a free log subscription operation binding the contract event 0xe79e73da417710ae99aa2088575580a60415d359acfad9cdd3382d59c80281d4. // // Solidity: event ItemSet(bytes32 key, bytes32 value) -func (_Store *StoreSession) WatchItemSet(fromBlock *uint64, handler func(int, []types.Log)) error { +func (_Store *StoreSession) WatchItemSet(fromBlock *int64, handler func(int, []types.Log)) error { return _Store.Contract.WatchItemSet(fromBlock, handler) } -func (_Store *StoreSession) WatchAllItemSet(fromBlock *uint64, handler func(int, []types.Log)) error { +func (_Store *StoreSession) WatchAllItemSet(fromBlock *int64, handler func(int, []types.Log)) error { return _Store.Contract.WatchAllItemSet(fromBlock, handler) } diff --git a/README.md b/README.md index 57cc9af1..fce2d3a6 100644 --- a/README.md +++ b/README.md @@ -164,6 +164,7 @@ cp .ci/hello/HelloWorld.sol ./hello ```bash # 国密请使用 ./abigen --bin ./hello/HelloWorld.bin --abi ./hello/HelloWorld.abi --pkg hello --type HelloWorld --out ./hello/HelloWorld.go --smcrypto=true +# 注意:国密模式,请使用国密solc编译得到bin ./abigen --bin ./hello/HelloWorld.bin --abi ./hello/HelloWorld.abi --pkg hello --type HelloWorld --out ./hello/HelloWorld.go ``` @@ -243,7 +244,12 @@ func main() { return } done := make(chan bool) - _, err = helloSession.WatchAllSetValue(nil, func(ret int, logs []types.Log) { + currentBlock, err := client.GetBlockNumber(context.Background()) + if err != nil { + fmt.Printf("GetBlockNumber() failed: %v", err) + return + } + _, err = helloSession.WatchAllSetValue(¤tBlock, func(ret int, logs []types.Log) { fmt.Printf("WatchAllSetValue receive statud: %d, logs: %v\n", ret, logs) setValue, err := helloSession.ParseSetValue(logs[0]) if err != nil { diff --git a/v3/abi/bind/base.go b/v3/abi/bind/base.go index 53a8c4f6..4238ad29 100755 --- a/v3/abi/bind/base.go +++ b/v3/abi/bind/base.go @@ -248,7 +248,7 @@ func (c *BoundContract) asyncTransact(opts *TransactOpts, contract *common.Addre // WatchLogs filters subscribes to contract logs for future blocks, returning a // subscription object that can be used to tear down the watcher. -func (c *BoundContract) WatchLogs(fromBlock *uint64, handler func(int, []types.Log), name string, query ...interface{}) (string, error) { +func (c *BoundContract) WatchLogs(fromBlock *int64, handler func(int, []types.Log), name string, query ...interface{}) (string, error) { from := int64(1) to := int64(-1) // Don't crash on a lazy user diff --git a/v3/abi/bind/template.go b/v3/abi/bind/template.go index e61138d6..5e0e7f1b 100644 --- a/v3/abi/bind/template.go +++ b/v3/abi/bind/template.go @@ -400,11 +400,11 @@ var ( // Watch{{.Normalized.Name}} is a free log subscription operation binding the contract event 0x{{printf "%x" .Original.ID}}. // // Solidity: {{formatevent .Original $structs}} - func (_{{$contract.Type}} *{{$contract.Type}}Filterer) Watch{{.Normalized.Name}}(fromBlock *uint64, handler func(int, []types.Log){{range .Normalized.Inputs}}{{if .Indexed}}, {{.Name}} {{bindtype .Type $structs}}{{end}}{{end}}) (string, error) { + func (_{{$contract.Type}} *{{$contract.Type}}Filterer) Watch{{.Normalized.Name}}(fromBlock *int64, handler func(int, []types.Log){{range .Normalized.Inputs}}{{if .Indexed}}, {{.Name}} {{bindtype .Type $structs}}{{end}}{{end}}) (string, error) { return _{{$contract.Type}}.contract.WatchLogs(fromBlock, handler, "{{.Original.Name}}"{{range .Normalized.Inputs}}{{if .Indexed}}, {{.Name}}{{end}}{{end}}) } - func (_{{$contract.Type}} *{{$contract.Type}}Filterer) WatchAll{{.Normalized.Name}}(fromBlock *uint64, handler func(int, []types.Log)) (string, error) { + func (_{{$contract.Type}} *{{$contract.Type}}Filterer) WatchAll{{.Normalized.Name}}(fromBlock *int64, handler func(int, []types.Log)) (string, error) { return _{{$contract.Type}}.contract.WatchLogs(fromBlock, handler, "{{.Original.Name}}") } @@ -422,11 +422,11 @@ var ( // Watch{{.Normalized.Name}} is a free log subscription operation binding the contract event 0x{{printf "%x" .Original.ID}}. // // Solidity: {{formatevent .Original $structs}} - func (_{{$contract.Type}} *{{$contract.Type}}Session) Watch{{.Normalized.Name}}(fromBlock *uint64, handler func(int, []types.Log){{range .Normalized.Inputs}}{{if .Indexed}}, {{.Name}} {{bindtype .Type $structs}}{{end}}{{end}}) (string, error) { + func (_{{$contract.Type}} *{{$contract.Type}}Session) Watch{{.Normalized.Name}}(fromBlock *int64, handler func(int, []types.Log){{range .Normalized.Inputs}}{{if .Indexed}}, {{.Name}} {{bindtype .Type $structs}}{{end}}{{end}}) (string, error) { return _{{$contract.Type}}.Contract.Watch{{.Normalized.Name}}(fromBlock, handler {{range .Normalized.Inputs}}{{if .Indexed}}, {{.Name}}{{end}}{{end}}) } - func (_{{$contract.Type}} *{{$contract.Type}}Session) WatchAll{{.Normalized.Name}}(fromBlock *uint64, handler func(int, []types.Log)) (string, error) { + func (_{{$contract.Type}} *{{$contract.Type}}Session) WatchAll{{.Normalized.Name}}(fromBlock *int64, handler func(int, []types.Log)) (string, error) { return _{{$contract.Type}}.Contract.WatchAll{{.Normalized.Name}}(fromBlock, handler) } diff --git a/v3/client/config.go b/v3/client/config.go index 18a9a142..c4a697eb 100644 --- a/v3/client/config.go +++ b/v3/client/config.go @@ -37,11 +37,11 @@ func ParseConfigOptions(caFile string, key string, cert, keyFile string, groupId if err != nil { return nil, fmt.Errorf("parse private key failed, err: %v", err) } - if config.IsSMCrypto && curve != sm2p256v1 { - return nil, fmt.Errorf("smcrypto must use sm2p256v1 private key, but found %s", curve) + if config.IsSMCrypto && curve != Sm2p256v1 { + return nil, fmt.Errorf("smcrypto should use sm2p256v1 private key, but found %s", curve) } - if !config.IsSMCrypto && curve != secp256k1 { - return nil, fmt.Errorf("must use secp256k1 private key, but found %s", curve) + if !config.IsSMCrypto && curve != Secp256k1 { + return nil, fmt.Errorf("must should secp256k1 private key, but found %s", curve) } config.PrivateKey = keyBytes return &config, nil diff --git a/v3/client/parse_pem.go b/v3/client/parse_pem.go index 6649a969..72cfb708 100644 --- a/v3/client/parse_pem.go +++ b/v3/client/parse_pem.go @@ -11,8 +11,8 @@ import ( ) const ( - secp256k1 = "secp256k1" - sm2p256v1 = "sm2p256v1" + Secp256k1 = "secp256k1" + Sm2p256v1 = "sm2p256v1" ) var ( diff --git a/v3/cmd/commandline/commands.go b/v3/cmd/commandline/commands.go index 5d857dd5..18e287e2 100644 --- a/v3/cmd/commandline/commands.go +++ b/v3/cmd/commandline/commands.go @@ -56,7 +56,7 @@ const ( // and reset your terminal to use autocompletion.`, // Run: func(cmd *cobra.Command, args []string) { // rootCmd.GenZshCompletionFile("_console"); -// fmt.Println("zsh file _console had created on your current diretory successfully.") +// fmt.Println("zsh file _console had created on your current directory successfully.") // }, // } @@ -89,8 +89,8 @@ The block height is encoded in hex`, }, } -var getPbftViewCmd = &cobra.Command{ - Use: "getPbftView", +var getPBFTViewCmd = &cobra.Command{ + Use: "getPBFTView", Short: " Get the latest PBFT view(PBFT consensus only)", Long: `Returns the latest PBFT view in the specified group where the node is located. The PBFT view is encoded in hex`, @@ -376,7 +376,7 @@ For more information please refer: fmt.Printf("block not found: %v\n", err) return } - js, err := json.MarshalIndent(block, "", indent) + js, _ := json.MarshalIndent(block, "", indent) fmt.Printf("Block: \n%s\n", js) }, } @@ -658,7 +658,7 @@ func init() { // add common command rootCmd.AddCommand(completionCmd) // add node command - rootCmd.AddCommand(getGroupIDCmd, getBlockNumberCmd, getPbftViewCmd, getSealerListCmd) + rootCmd.AddCommand(getGroupIDCmd, getBlockNumberCmd, getPBFTViewCmd, getSealerListCmd) rootCmd.AddCommand(getObserverListCmd, getConsensusStatusCmd, getSyncStatusCmd, getPeersCmd, getGroupPeersCmd) rootCmd.AddCommand(getNodeIDListCmd, getGroupListCmd, getNodeInfoCmd, getGroupInfoCmd, getGroupInfoListCmd) // add block access command @@ -671,33 +671,33 @@ func init() { // cobra.OnInitialize(initConfig) - // FIXME: add a custom help command or find a way to make help command work without network - // Here you will define your flags and configuration settings. // Cobra supports persistent flags, which, if defined here, // will be global for your application. - rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is the project directory ./config.ini)") - - // Cobra also supports local flags, which will only run - // when this action is called directly. - // rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") + // rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "", "config file (default is the project directory ./config.ini)") + rootCmd.Flags().StringVarP(&cfgFile, "privateKeyPath", "p", "", "private key file path of pem format") + rootCmd.Flags().BoolVarP(&smCrypto, "smCrypto", "s", false, "use smCrypto or not, default is false") + rootCmd.Flags().BoolVarP(&disableSsl, "disableSsl", "d", false, "switch off ssl or not, default use ssl") + rootCmd.PersistentFlags().StringVarP(&groupID, "groupID", "g", "group0", "groupID of FISCO BCOS chain") + rootCmd.PersistentFlags().StringVarP(&nodeEndpoint, "nodeEndpoint", "n", "127.0.0.1:20200", "node endpoint, default is 127.0.0.1:20200") + rootCmd.PersistentFlags().StringVarP(&certPath, "certPath", "c", "./conf", "cert path, default is ./conf, should contain ca.crt, sdk.crt, sdk.key") } func isValidHex(str string) (bool, error) { // starts with "0x" if strings.HasPrefix(str, "0x") { if len(str) == 2 { - return false, fmt.Errorf("not a valid hex string: arguments error: please check your inpunt: %s%s", str, info) + return false, fmt.Errorf("not a valid hex string: arguments error: please check your input: %s%s", str, info) } // is hex string _, err := hexutil.Decode(str) if err != nil { - return false, fmt.Errorf("not a valid hex string: arguments error: please check your inpunt: %s%s: %v", str, info, err) + return false, fmt.Errorf("not a valid hex string: arguments error: please check your input: %s%s: %v", str, info, err) } return true, nil } - return false, fmt.Errorf("arguments error: Not a valid hex string, please check your inpunt: %s%s", str, info) + return false, fmt.Errorf("arguments error: Not a valid hex string, please check your input: %s%s", str, info) } func isBlockNumberOutOfRange(blockNumber int64) (bool, error) { diff --git a/v3/cmd/commandline/kvTable.go b/v3/cmd/commandline/kvTable.go index cd67b66f..24190cdb 100644 --- a/v3/cmd/commandline/kvTable.go +++ b/v3/cmd/commandline/kvTable.go @@ -9,7 +9,7 @@ import ( var createTable = &cobra.Command{ Use: "createTable", - Short: "[tableName] [keyName] [valueName] create table", + Short: " ", Long: `createTable. Arguments: [tableName]: string @@ -18,11 +18,7 @@ Arguments: For example: - [createTable] [table1] [key1] [value1] - -For more information please refer: - - https://fisco-bcos-documentation.readthedocs.io/zh_CN/latest/docs/manual/console.html#addobserver`, + createTable table1 key1 value1`, Args: cobra.ExactArgs(3), Run: func(cmd *cobra.Command, args []string) { tableName := args[0] @@ -60,11 +56,7 @@ Arguments: For example: - [set] [table1] [key1] [value1] - -For more information please refer: - - https://fisco-bcos-documentation.readthedocs.io/zh_CN/latest/docs/manual/console.html#addsealer`, + set table1 key1 value1`, Args: cobra.ExactArgs(3), Run: func(cmd *cobra.Command, args []string) { tableName := args[0] @@ -104,11 +96,7 @@ Arguments: For example: - [get] [tableName] [key1] - -For more information please refer: - - https://fisco-bcos-documentation.readthedocs.io/zh_CN/latest/docs/manual/console.html#removenode`, + [get] [tableName] [key1]`, Args: cobra.ExactArgs(2), Run: func(cmd *cobra.Command, args []string) { tableName := args[0] diff --git a/v3/cmd/commandline/root.go b/v3/cmd/commandline/root.go index 09e927b3..82d15b35 100644 --- a/v3/cmd/commandline/root.go +++ b/v3/cmd/commandline/root.go @@ -5,25 +5,24 @@ import ( "encoding/hex" "fmt" "os" + "strconv" + "strings" "github.com/FISCO-BCOS/go-sdk/v3/client" "github.com/spf13/cobra" ) var cfgFile string +var privateKeyFilePath string +var smCrypto bool +var disableSsl bool +var nodeEndpoint string +var groupID string +var certPath string // RPC is the client connected to the blockchain var RPC *client.Client -// GroupID default -var GroupID uint - -// ChainID default -var ChainID int64 - -// URL default -var URL string - // GetClient is used for test, it will be init by a config file later. func getClient(config *client.Config) *client.Client { // RPC API @@ -39,7 +38,7 @@ func getClient(config *client.Config) *client.Client { var rootCmd = &cobra.Command{ Use: "console", Short: "console is a command line tool for FISCO BCOS 3.0.0", - Version: "0.10.0", + Version: "3.0.0", Long: `console is a Golang client for FISCO BCOS 3.0.0 and it supports the JSON-RPC service and the contract operations(e.g. deploying && writing contracts). @@ -71,8 +70,32 @@ func Execute() { // initConfig reads in config file and ENV variables if set. func initConfig() { - privateKey, _ := hex.DecodeString("145e247e170ba3afd6ae97e88f00dbc976c2345d511b0f6713355d19d8b80b58") - config := &client.Config{IsSMCrypto: false, GroupID: "group0", - PrivateKey: privateKey, Host: "127.0.0.1", Port: 20200, TLSCaFile: "./ca.crt", TLSKeyFile: "./sdk.key", TLSCertFile: "./sdk.crt"} + var privateKey []byte + if len(privateKeyFilePath) != 0 { + _, err := os.Stat(privateKeyFilePath) + if err != nil && os.IsNotExist(err) { + fmt.Println("private key file set but not exist, use default private key") + } + key, curve, err := client.LoadECPrivateKeyFromPEM(privateKeyFilePath) + if err != nil { + fmt.Printf("parse private key failed, err: %v\n", err) + return + } + if smCrypto && curve != client.Sm2p256v1 { + fmt.Printf("smCrypto should use sm2p256v1 private key, but found %s\n", curve) + return + } + if !smCrypto && curve != client.Secp256k1 { + fmt.Printf("should use secp256k1 private key, but found %s\n", curve) + } + privateKey = key + } else { + privateKey, _ = hex.DecodeString("145e247e170ba3afd6ae97e88f00dbc976c2345d511b0f6713355d19d8b80b58") + } + ret := strings.Split(nodeEndpoint, ":") + host := ret[0] + port, _ := strconv.Atoi(ret[1]) + config := &client.Config{IsSMCrypto: smCrypto, GroupID: groupID, DisableSsl: disableSsl, + PrivateKey: privateKey, Host: host, Port: port, TLSCaFile: certPath + "/ca.crt", TLSKeyFile: certPath + "/sdk.key", TLSCertFile: certPath + "/sdk.crt"} RPC = getClient(config) } diff --git a/v3/cmd/commandline/system_config.go b/v3/cmd/commandline/system_config.go index 312c678c..4e8ab391 100644 --- a/v3/cmd/commandline/system_config.go +++ b/v3/cmd/commandline/system_config.go @@ -17,11 +17,7 @@ Arguments: For example: - [setSystemConfigByKey] [tx_count_limit] 10000 - -For more information please refer: - - https://fisco-bcos-documentation.readthedocs.io/zh_CN/latest/docs/api.html#`, + [setSystemConfigByKey] [tx_count_limit] 10000`, Args: cobra.ExactArgs(2), Run: func(cmd *cobra.Command, args []string) { //configMap := make(map[string]struct{}) diff --git a/v3/examples/KVTableTest.go b/v3/examples/KVTableTest.go index 2b7d8cfa..c201da6c 100644 --- a/v3/examples/KVTableTest.go +++ b/v3/examples/KVTableTest.go @@ -271,11 +271,11 @@ type KVTableTestInsertResult struct { // WatchInsertResult is a free log subscription operation binding the contract event 0xc57b01fa77f41df77eaab79a0e2623fab2e7ae3e9530d9b1cab225ad65f2b7ce. // // Solidity: event InsertResult(int256 count) -func (_KVTableTest *KVTableTestFilterer) WatchInsertResult(fromBlock *uint64, handler func(int, []types.Log)) (string, error) { +func (_KVTableTest *KVTableTestFilterer) WatchInsertResult(fromBlock *int64, handler func(int, []types.Log)) (string, error) { return _KVTableTest.contract.WatchLogs(fromBlock, handler, "InsertResult") } -func (_KVTableTest *KVTableTestFilterer) WatchAllInsertResult(fromBlock *uint64, handler func(int, []types.Log)) (string, error) { +func (_KVTableTest *KVTableTestFilterer) WatchAllInsertResult(fromBlock *int64, handler func(int, []types.Log)) (string, error) { return _KVTableTest.contract.WatchLogs(fromBlock, handler, "InsertResult") } @@ -293,11 +293,11 @@ func (_KVTableTest *KVTableTestFilterer) ParseInsertResult(log types.Log) (*KVTa // WatchInsertResult is a free log subscription operation binding the contract event 0xc57b01fa77f41df77eaab79a0e2623fab2e7ae3e9530d9b1cab225ad65f2b7ce. // // Solidity: event InsertResult(int256 count) -func (_KVTableTest *KVTableTestSession) WatchInsertResult(fromBlock *uint64, handler func(int, []types.Log)) (string, error) { +func (_KVTableTest *KVTableTestSession) WatchInsertResult(fromBlock *int64, handler func(int, []types.Log)) (string, error) { return _KVTableTest.Contract.WatchInsertResult(fromBlock, handler) } -func (_KVTableTest *KVTableTestSession) WatchAllInsertResult(fromBlock *uint64, handler func(int, []types.Log)) (string, error) { +func (_KVTableTest *KVTableTestSession) WatchAllInsertResult(fromBlock *int64, handler func(int, []types.Log)) (string, error) { return _KVTableTest.Contract.WatchAllInsertResult(fromBlock, handler) } diff --git a/v3/examples/hello_world/manual/main.go b/v3/examples/hello_world/manual/main.go index 5d5aeba3..5f6fae07 100644 --- a/v3/examples/hello_world/manual/main.go +++ b/v3/examples/hello_world/manual/main.go @@ -75,8 +75,12 @@ func main() { address := common.HexToAddress(receipt.ContractAddress) // SubscribeEventLogs hello := bind.NewBoundContract(address, parsed, client, client, client) - fromBlock := uint64(0) - hello.WatchLogs(&fromBlock, func(ret int, logs []types.Log) { + currentBlock, err := client.GetBlockNumber(context.Background()) + if err != nil { + fmt.Printf("GetBlockNumber() failed: %v", err) + return + } + hello.WatchLogs(¤tBlock, func(ret int, logs []types.Log) { setValue := &struct { V string From common.Address diff --git a/v3/examples/hello_world/wrapper/HelloWorld.go b/v3/examples/hello_world/wrapper/HelloWorld.go index f82b9118..8f854f3a 100644 --- a/v3/examples/hello_world/wrapper/HelloWorld.go +++ b/v3/examples/hello_world/wrapper/HelloWorld.go @@ -82,7 +82,7 @@ type HelloWorldFilterer struct { // HelloWorldSession is an auto generated Go binding around a Solidity contract, // with pre-set call and transact options. type HelloWorldSession struct { - Contract *HelloWorld // Generic contract binding to set the session for + Contract *HelloWorld // Generic contract binding to set the session for CallOpts bind.CallOpts // Call options to use throughout this session TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session } @@ -90,15 +90,15 @@ type HelloWorldSession struct { // HelloWorldCallerSession is an auto generated read-only Go binding around a Solidity contract, // with pre-set call options. type HelloWorldCallerSession struct { - Contract *HelloWorldCaller // Generic contract caller binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session + Contract *HelloWorldCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session } // HelloWorldTransactorSession is an auto generated write-only Go binding around a Solidity contract, // with pre-set transact options. type HelloWorldTransactorSession struct { - Contract *HelloWorldTransactor // Generic contract transactor binding to set the session for - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session + Contract *HelloWorldTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session } // HelloWorldRaw is an auto generated low-level Go binding around a Solidity contract. @@ -301,11 +301,11 @@ type HelloWorldSetValue struct { // WatchSetValue is a free log subscription operation binding the contract event 0xc3bf5911f8e0476e774566ef3fa1259f04156ba5c61ea5ff35c0201390381f96. // // Solidity: event setValue(string v, address indexed from, address indexed to, int256 value) -func (_HelloWorld *HelloWorldFilterer) WatchSetValue(fromBlock *uint64, handler func(int, []types.Log), from common.Address, to common.Address) (string, error) { +func (_HelloWorld *HelloWorldFilterer) WatchSetValue(fromBlock *int64, handler func(int, []types.Log), from common.Address, to common.Address) (string, error) { return _HelloWorld.contract.WatchLogs(fromBlock, handler, "setValue", from, to) } -func (_HelloWorld *HelloWorldFilterer) WatchAllSetValue(fromBlock *uint64, handler func(int, []types.Log)) (string, error) { +func (_HelloWorld *HelloWorldFilterer) WatchAllSetValue(fromBlock *int64, handler func(int, []types.Log)) (string, error) { return _HelloWorld.contract.WatchLogs(fromBlock, handler, "setValue") } @@ -323,11 +323,11 @@ func (_HelloWorld *HelloWorldFilterer) ParseSetValue(log types.Log) (*HelloWorld // WatchSetValue is a free log subscription operation binding the contract event 0xc3bf5911f8e0476e774566ef3fa1259f04156ba5c61ea5ff35c0201390381f96. // // Solidity: event setValue(string v, address indexed from, address indexed to, int256 value) -func (_HelloWorld *HelloWorldSession) WatchSetValue(fromBlock *uint64, handler func(int, []types.Log), from common.Address, to common.Address) (string, error) { +func (_HelloWorld *HelloWorldSession) WatchSetValue(fromBlock *int64, handler func(int, []types.Log), from common.Address, to common.Address) (string, error) { return _HelloWorld.Contract.WatchSetValue(fromBlock, handler, from, to) } -func (_HelloWorld *HelloWorldSession) WatchAllSetValue(fromBlock *uint64, handler func(int, []types.Log)) (string, error) { +func (_HelloWorld *HelloWorldSession) WatchAllSetValue(fromBlock *int64, handler func(int, []types.Log)) (string, error) { return _HelloWorld.Contract.WatchAllSetValue(fromBlock, handler) } diff --git a/v3/examples/hello_world/wrapper/main.go b/v3/examples/hello_world/wrapper/main.go index 015fd169..f45d1835 100644 --- a/v3/examples/hello_world/wrapper/main.go +++ b/v3/examples/hello_world/wrapper/main.go @@ -51,7 +51,12 @@ func main() { return } done := make(chan bool) - _, err = helloSession.WatchAllSetValue(nil, func(ret int, logs []types.Log) { + currentBlock, err := client.GetBlockNumber(context.Background()) + if err != nil { + fmt.Printf("GetBlockNumber() failed: %v", err) + return + } + _, err = helloSession.WatchAllSetValue(¤tBlock, func(ret int, logs []types.Log) { fmt.Printf("receive event SetValue: %d, logs: %v\n", ret, logs) setValue, err := helloSession.ParseSetValue(logs[0]) if err != nil { diff --git a/v3/precompiled/auth/CommitteeManager.go b/v3/precompiled/auth/CommitteeManager.go index cd038564..60f25ec0 100644 --- a/v3/precompiled/auth/CommitteeManager.go +++ b/v3/precompiled/auth/CommitteeManager.go @@ -726,11 +726,11 @@ type CommitteeManagerExecResult struct { // WatchExecResult is a free log subscription operation binding the contract event 0x7251e13f6f51fdfe60094817f80310366d2e1148fe8a46cb475b582d35bfdea8. // // Solidity: event execResult(int256 ) -func (_CommitteeManager *CommitteeManagerFilterer) WatchExecResult(fromBlock *uint64, handler func(int, []types.Log)) (string, error) { +func (_CommitteeManager *CommitteeManagerFilterer) WatchExecResult(fromBlock *int64, handler func(int, []types.Log)) (string, error) { return _CommitteeManager.contract.WatchLogs(fromBlock, handler, "execResult") } -func (_CommitteeManager *CommitteeManagerFilterer) WatchAllExecResult(fromBlock *uint64, handler func(int, []types.Log)) (string, error) { +func (_CommitteeManager *CommitteeManagerFilterer) WatchAllExecResult(fromBlock *int64, handler func(int, []types.Log)) (string, error) { return _CommitteeManager.contract.WatchLogs(fromBlock, handler, "execResult") } @@ -748,11 +748,11 @@ func (_CommitteeManager *CommitteeManagerFilterer) ParseExecResult(log types.Log // WatchExecResult is a free log subscription operation binding the contract event 0x7251e13f6f51fdfe60094817f80310366d2e1148fe8a46cb475b582d35bfdea8. // // Solidity: event execResult(int256 ) -func (_CommitteeManager *CommitteeManagerSession) WatchExecResult(fromBlock *uint64, handler func(int, []types.Log)) (string, error) { +func (_CommitteeManager *CommitteeManagerSession) WatchExecResult(fromBlock *int64, handler func(int, []types.Log)) (string, error) { return _CommitteeManager.Contract.WatchExecResult(fromBlock, handler) } -func (_CommitteeManager *CommitteeManagerSession) WatchAllExecResult(fromBlock *uint64, handler func(int, []types.Log)) (string, error) { +func (_CommitteeManager *CommitteeManagerSession) WatchAllExecResult(fromBlock *int64, handler func(int, []types.Log)) (string, error) { return _CommitteeManager.Contract.WatchAllExecResult(fromBlock, handler) } diff --git a/v3/test/performanceTest/contract/kvTableTest/KVTableTest.go b/v3/test/performanceTest/contract/kvTableTest/KVTableTest.go index ef37d54d..2e5ce12d 100644 --- a/v3/test/performanceTest/contract/kvTableTest/KVTableTest.go +++ b/v3/test/performanceTest/contract/kvTableTest/KVTableTest.go @@ -271,11 +271,11 @@ type KVTableTestInsertResult struct { // WatchInsertResult is a free log subscription operation binding the contract event 0xc57b01fa77f41df77eaab79a0e2623fab2e7ae3e9530d9b1cab225ad65f2b7ce. // // Solidity: event InsertResult(int256 count) -func (_KVTableTest *KVTableTestFilterer) WatchInsertResult(fromBlock *uint64, handler func(int, []types.Log)) (string, error) { +func (_KVTableTest *KVTableTestFilterer) WatchInsertResult(fromBlock *int64, handler func(int, []types.Log)) (string, error) { return _KVTableTest.contract.WatchLogs(fromBlock, handler, "InsertResult") } -func (_KVTableTest *KVTableTestFilterer) WatchAllInsertResult(fromBlock *uint64, handler func(int, []types.Log)) (string, error) { +func (_KVTableTest *KVTableTestFilterer) WatchAllInsertResult(fromBlock *int64, handler func(int, []types.Log)) (string, error) { return _KVTableTest.contract.WatchLogs(fromBlock, handler, "InsertResult") } @@ -293,11 +293,11 @@ func (_KVTableTest *KVTableTestFilterer) ParseInsertResult(log types.Log) (*KVTa // WatchInsertResult is a free log subscription operation binding the contract event 0xc57b01fa77f41df77eaab79a0e2623fab2e7ae3e9530d9b1cab225ad65f2b7ce. // // Solidity: event InsertResult(int256 count) -func (_KVTableTest *KVTableTestSession) WatchInsertResult(fromBlock *uint64, handler func(int, []types.Log)) (string, error) { +func (_KVTableTest *KVTableTestSession) WatchInsertResult(fromBlock *int64, handler func(int, []types.Log)) (string, error) { return _KVTableTest.Contract.WatchInsertResult(fromBlock, handler) } -func (_KVTableTest *KVTableTestSession) WatchAllInsertResult(fromBlock *uint64, handler func(int, []types.Log)) (string, error) { +func (_KVTableTest *KVTableTestSession) WatchAllInsertResult(fromBlock *int64, handler func(int, []types.Log)) (string, error) { return _KVTableTest.Contract.WatchAllInsertResult(fromBlock, handler) }