From ac1a75d043a709d94f2b92c0189af3ab807de463 Mon Sep 17 00:00:00 2001 From: kompotkot Date: Tue, 6 Jun 2023 12:25:07 +0000 Subject: [PATCH 1/2] Updated robots placement --- robots/.gitignore | 55 + robots/README.md | 49 + robots/cmd/robots/airdrop.go | 285 +++++ robots/cmd/robots/cli.go | 139 +++ robots/cmd/robots/configs.go | 133 ++ robots/cmd/robots/entity.go | 145 +++ robots/cmd/robots/main.go | 5 + robots/cmd/robots/networks.go | 80 ++ robots/cmd/robots/signer.go | 65 + robots/cmd/robots/terminus.go | 73 ++ robots/cmd/robots/version.go | 3 + robots/deploy/deploy.bash | 57 + robots/deploy/robots-airdrop.service | 16 + robots/dev.sh | 10 + robots/go.mod | 24 + robots/go.sum | 75 ++ robots/pkg/terminus/terminus.go | 1733 ++++++++++++++++++++++++++ robots/sample.env | 11 + 18 files changed, 2958 insertions(+) create mode 100644 robots/.gitignore create mode 100644 robots/README.md create mode 100644 robots/cmd/robots/airdrop.go create mode 100644 robots/cmd/robots/cli.go create mode 100644 robots/cmd/robots/configs.go create mode 100644 robots/cmd/robots/entity.go create mode 100644 robots/cmd/robots/main.go create mode 100644 robots/cmd/robots/networks.go create mode 100644 robots/cmd/robots/signer.go create mode 100644 robots/cmd/robots/terminus.go create mode 100644 robots/cmd/robots/version.go create mode 100755 robots/deploy/deploy.bash create mode 100644 robots/deploy/robots-airdrop.service create mode 100755 robots/dev.sh create mode 100644 robots/go.mod create mode 100644 robots/go.sum create mode 100644 robots/pkg/terminus/terminus.go create mode 100644 robots/sample.env diff --git a/robots/.gitignore b/robots/.gitignore new file mode 100644 index 00000000..3fa95c99 --- /dev/null +++ b/robots/.gitignore @@ -0,0 +1,55 @@ +# Created by https://www.toptal.com/developers/gitignore/api/go,visualstudiocode +# Edit at https://www.toptal.com/developers/gitignore?templates=go,visualstudiocode + +### Go ### +# If you prefer the allow list template instead of the deny list, see community template: +# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore +# +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Dependency directories (remove the comment below to include it) +# vendor/ + +# Go workspace file +go.work + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history +.ionide + +# End of https://www.toptal.com/developers/gitignore/api/go,visualstudiocode + +# Custom +robots_dev +.secrets/ +dev.env +test.env +prod.env + +abi/ diff --git a/robots/README.md b/robots/README.md new file mode 100644 index 00000000..71a11798 --- /dev/null +++ b/robots/README.md @@ -0,0 +1,49 @@ +# robots + +Generate terminus interface: + +```bash +mkdir -p pkg/terminus +abigen --abi abi/TerminusFacet.json --pkg terminus --out pkg/terminus/terminus.go +``` + +## Airdrop preparations + +Prepare Entity collection: + +```bash +curl "https://api.moonstream.to/entity/collections" \ + --header "Authorization: Bearer ${MOONSTREAM_ACCESS_TOKEN}" \ + --header "Content-Type: application/json" \ + --data '{ + "name": "Test whitelist 1" + }' +``` + +### Spire + +Currently, the creation of public entity collections is available only to administrators through `spire` CLI. + +```bash +export COLLECTION_ID="" +``` + +List available public autogenerated users: + +```bash +public-journals users list +``` + +Create public user, if required: + +```bash +public-journals users create --name "test-public-user" +``` + +Make collection public with `--entry-update` or `--entry-create` flags if required: + +```bash +public-journals journals make --token "${MOONSTREAM_ACCESS_TOKEN}" \ + --journal-id "${COLLECTION_ID}" \ + --public-user-id "${PUBLIC_USER_ID}" +``` diff --git a/robots/cmd/robots/airdrop.go b/robots/cmd/robots/airdrop.go new file mode 100644 index 00000000..6c287f7f --- /dev/null +++ b/robots/cmd/robots/airdrop.go @@ -0,0 +1,285 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + "log" + "math" + "math/big" + "sync" + "sync/atomic" + "time" + + humbug "github.com/bugout-dev/humbug/go/pkg" + "github.com/google/uuid" +) + +type RobotInstance struct { + ValueToClaim int64 + MaxValueToClaim int64 + + ContractTerminusInstance ContractTerminusInstance + EntityInstance EntityInstance + NetworkInstance NetworkInstance + SignerInstance SignerInstance + + MintCounter int64 +} + +func Airdrop(configs *[]RobotsConfig) { + sessionID := uuid.New().String() + consent := humbug.CreateHumbugConsent(humbug.True) + reporter, err := humbug.CreateHumbugReporter(consent, "moonstream-robots", sessionID, HUMBUG_REPORTER_ROBOTS_HEARTBEAT_TOKEN) + if err != nil { + log.Printf("Unable to specify humbug heartbeat reporter, %v", err) + } + // Record system information + reporter.Publish(humbug.SystemReport()) + + var robots []RobotInstance + + // Configure networks + networks, err := InitializeNetworks() + if err != nil { + log.Fatal(err) + } + log.Println("Initialized configuration of network endpoints and chain IDs") + + ctx := context.Background() + for _, config := range *configs { + robot := RobotInstance{ + ValueToClaim: config.ValueToClaim, + MaxValueToClaim: config.MaxValueToClaim, + MintCounter: 0, // TODO(kompotkot): Fetch minted number from blockchain + } + + // Configure network client + network := networks[config.Blockchain] + client, err := GenDialRpcClient(network.Endpoint) + if err != nil { + log.Fatal(err) + } + robot.NetworkInstance = NetworkInstance{ + Blockchain: config.Blockchain, + Endpoint: network.Endpoint, + ChainID: network.ChainID, + + Client: client, + } + log.Printf("Initialized configuration of JSON RPC network client for %s blockchain", config.Blockchain) + + // Fetch required opts + err = robot.NetworkInstance.FetchSuggestedGasPrice(ctx) + if err != nil { + log.Fatal(err) + } + + // Define contract instance + contractAddress := GetTerminusContractAddress(config.TerminusAddress) + contractTerminusInstance, err := InitializeTerminusContractInstance(client, contractAddress) + if err != nil { + log.Fatal(err) + } + robot.ContractTerminusInstance = ContractTerminusInstance{ + Address: contractAddress, + Instance: contractTerminusInstance, + TerminusPoolId: config.TerminusPoolId, + } + log.Printf("Initialized configuration of terminus contract instance for %s blockchain", config.Blockchain) + + // Configure entity client + entityInstance, err := InitializeEntityInstance(config.CollectionId) + if err != nil { + log.Fatal(err) + } + robot.EntityInstance = *entityInstance + log.Printf("Initialized configuration of entity client for '%s' collection", robot.EntityInstance.CollectionId) + + // Configure signer + signer, err := initializeSigner(config.SignerKeyfileName, config.SignerPasswordFileName) + if err != nil { + log.Fatal(err) + } + robot.SignerInstance = *signer + log.Printf("Initialized configuration of signer %s", robot.SignerInstance.Address.String()) + + robots = append(robots, robot) + } + + var wg sync.WaitGroup + for idx, robot := range robots { + wg.Add(1) + go robotRun( + &wg, + robot, + reporter, + idx, + ) + } + wg.Wait() +} + +type RobotHeartBeatReport struct { + CollectionId string `json:"collection_id"` + CollectionName string `json:"collection_name"` + SignerAddress string `json:"signer_address"` + TerminusPoolId int64 `json:"terminus_pool_id"` + Blockchain string `json:"blockchain"` + MintCounter int64 `json:"mint_counter"` +} + +// heartBeat prepares and send HeartBeat report for robot +func heartBeat( + robot RobotInstance, + reporter *humbug.HumbugReporter, + idx int, +) { + reportContent := []byte{} + robotHeartBeatReport := &RobotHeartBeatReport{ + CollectionId: robot.EntityInstance.CollectionId, + CollectionName: robot.EntityInstance.CollectionName, + SignerAddress: robot.SignerInstance.Address.String(), + TerminusPoolId: robot.ContractTerminusInstance.TerminusPoolId, + Blockchain: robot.NetworkInstance.Blockchain, + MintCounter: robot.MintCounter, + } + reportContent, err := json.Marshal(robotHeartBeatReport) + if err != nil { + log.Printf("Unable to prepare report content for HeartBeat %v", err) + } + heartBeatReport := humbug.Report{ + Title: fmt.Sprintf("Robot %d HB - %s - %s", idx, robot.NetworkInstance.Blockchain, robot.EntityInstance.CollectionName), + Tags: []string{ + fmt.Sprintf("index:%d", idx), + fmt.Sprintf("blockchain:%s", robot.NetworkInstance.Blockchain), + fmt.Sprintf("collection_id:%s", robot.EntityInstance.CollectionId), + fmt.Sprintf("terminus_pool_id:%d", robot.ContractTerminusInstance.TerminusPoolId), + fmt.Sprintf("signer_address:%s", robot.SignerInstance.Address.String()), + }, + Content: string(reportContent), + } + reporter.Publish(heartBeatReport) +} + +// robotRun represents of each robot instance for specific airdrop +func robotRun( + wg *sync.WaitGroup, + robot RobotInstance, + reporter *humbug.HumbugReporter, + idx int, +) { + defer wg.Done() + + log.Printf( + "Spawned robot %d for blockchain %s, signer %s, entity collection %s, pool %d", + idx, + robot.NetworkInstance.Blockchain, + robot.SignerInstance.Address.String(), + robot.EntityInstance.CollectionId, + robot.ContractTerminusInstance.TerminusPoolId, + ) + minSleepTime := 5 + maxSleepTime := 60 + timer := minSleepTime + ticker := time.NewTicker(time.Duration(minSleepTime) * time.Second) + + for { + select { + case <-ticker.C: + heartBeat(robot, reporter, idx) + + empty_addresses_len, err := airdropRun(&robot, idx) + if err != nil { + log.Printf("Robot %d - During AirdropRun an error occurred, err: %v", idx, err) + timer = timer + 10 + ticker.Reset(time.Duration(timer) * time.Second) + continue + } + if empty_addresses_len == 0 { + timer = int(math.Min(float64(maxSleepTime), float64(timer+1))) + ticker.Reset(time.Duration(timer) * time.Second) + log.Printf("Robot %d - Sleeping for %d seconds because of no new empty addresses", idx, timer) + continue + } + timer = int(math.Max(float64(minSleepTime), float64(timer-10))) + ticker.Reset(time.Duration(timer) * time.Second) + } + } +} + +type Claimant struct { + EntityId string + Address string +} + +func airdropRun(robot *RobotInstance, idx int) (int64, error) { + status_code, search_data, err := robot.EntityInstance.FetchPublicSearchUntouched(JOURNAL_SEARCH_BATCH_SIZE) + if err != nil { + return 0, err + } + log.Printf("Robot %d - Received response %d from entities API for collection %s with %d results", idx, status_code, robot.EntityInstance.CollectionId, search_data.TotalResults) + + var claimants_len int64 + var claimants []Claimant + for _, entity := range search_data.Entities { + claimants = append(claimants, Claimant{ + EntityId: entity.EntityId, + Address: entity.Address, + }) + claimants_len++ + } + + if claimants_len == 0 { + return claimants_len, nil + } + + // Fetch balances for addresses and update list + balances, err := robot.ContractTerminusInstance.BalanceOfBatch(nil, claimants, robot.ContractTerminusInstance.TerminusPoolId) + if err != nil { + return 0, err + } + + maxMintBigInt := big.NewInt(robot.MaxValueToClaim) + var emptyClaimantsLen int64 + var emptyClaimants []Claimant + for i, balance := range balances { + // Allow to claim only if less then maxMintBigInt + if balance.Cmp(maxMintBigInt) == -1 { + emptyClaimants = append(emptyClaimants, claimants[i]) + emptyClaimantsLen++ + } + } + + if emptyClaimantsLen > 0 { + log.Printf("Robot %d - Ready to send tokens for %d addresses from collection %s", idx, emptyClaimantsLen, robot.EntityInstance.CollectionId) + + auth, err := robot.SignerInstance.CreateTransactor(robot.NetworkInstance) + if err != nil { + return emptyClaimantsLen, err + } + if robot.NetworkInstance.Blockchain == "wyrm" { + auth.GasPrice = big.NewInt(0) + } + + tx, err := robot.ContractTerminusInstance.PoolMintBatch(auth, emptyClaimants, robot.ValueToClaim) + if err != nil { + return emptyClaimantsLen, err + } + atomic.AddInt64(&robot.MintCounter, emptyClaimantsLen) + log.Printf("Robot %d - Pending tx for PoolMintBatch on blockchain %s at pool ID %d: 0x%x", idx, robot.NetworkInstance.Blockchain, robot.ContractTerminusInstance.TerminusPoolId, tx.Hash()) + } + + var touched_entities int64 + for _, claimant := range claimants { + _, _, err := robot.EntityInstance.TouchPublicEntity(claimant.EntityId, 10) + if err != nil { + log.Printf("Robot %d - Unable to touch entity with ID: %s for claimant: %s, err: %v", idx, claimant.EntityId, claimant.Address, err) + continue + } + touched_entities++ + } + log.Printf("Robot %d - Marked %d entities from %d claimants total", idx, touched_entities, claimants_len) + + return emptyClaimantsLen, nil +} diff --git a/robots/cmd/robots/cli.go b/robots/cmd/robots/cli.go new file mode 100644 index 00000000..19d5d1e5 --- /dev/null +++ b/robots/cmd/robots/cli.go @@ -0,0 +1,139 @@ +package main + +import ( + "flag" + "fmt" + "os" + "strings" +) + +var ( + // Storing CLI definitions at server startup + stateCLI StateCLI +) + +// Command Line Interface state +type StateCLI struct { + generateConfigCmd *flag.FlagSet + airdropCmd *flag.FlagSet + versionCmd *flag.FlagSet + + // Common flags + configPathFlag string + helpFlag bool + + // Airdrop flags + reportMapDuration int +} + +type flagSlice []string + +func (i *flagSlice) String() string { + return strings.Join(*i, ", ") +} + +func (i *flagSlice) Set(value string) error { + *i = append(*i, value) + return nil +} + +func (s *StateCLI) usage() { + fmt.Printf(`usage: robots [-h] {%[1]s,%[2]s,%[3]s} ... + +Moonstream robots CLI +optional arguments: + -h, --help show this help message and exit + +subcommands: + {%[1]s,%[2]s,%[3]s} +`, s.generateConfigCmd.Name(), s.airdropCmd.Name(), s.versionCmd.Name()) +} + +// Check if required flags are set +func (s *StateCLI) checkRequirements() { + if s.helpFlag { + switch { + case s.generateConfigCmd.Parsed(): + fmt.Printf("Generate new configuration\n\n") + s.generateConfigCmd.PrintDefaults() + os.Exit(0) + case s.airdropCmd.Parsed(): + fmt.Printf("Run Airdrop robots\n\n") + s.airdropCmd.PrintDefaults() + os.Exit(0) + case s.versionCmd.Parsed(): + fmt.Printf("Show version\n\n") + s.versionCmd.PrintDefaults() + os.Exit(0) + default: + s.usage() + os.Exit(0) + } + } +} + +func (s *StateCLI) populateCLI() { + // Subcommands setup + s.generateConfigCmd = flag.NewFlagSet("generate-config", flag.ExitOnError) + s.airdropCmd = flag.NewFlagSet("airdrop", flag.ExitOnError) + s.versionCmd = flag.NewFlagSet("version", flag.ExitOnError) + + // Common flag pointers + for _, fs := range []*flag.FlagSet{s.generateConfigCmd, s.airdropCmd, s.versionCmd} { + fs.BoolVar(&s.helpFlag, "help", false, "Show help message") + fs.StringVar(&s.configPathFlag, "config", "", "Path to configuration file (default: ~/.robots/config.json)") + } + + // Airdrop list subcommand flag pointers + s.airdropCmd.IntVar(&s.reportMapDuration, "report-map-duration", 60, "How often to push report map in Humbug journal in seconds, default: 60") +} + +func cli() { + stateCLI.populateCLI() + if len(os.Args) < 2 { + stateCLI.usage() + os.Exit(1) + } + + // Parse subcommands and appropriate FlagSet + switch os.Args[1] { + case "generate-config": + stateCLI.generateConfigCmd.Parse(os.Args[2:]) + stateCLI.checkRequirements() + + configPlacement, err := PrepareConfigPlacement(stateCLI.configPathFlag) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + if err := GenerateDefaultConfig(configPlacement); err != nil { + fmt.Println(err) + os.Exit(1) + } + case "airdrop": + stateCLI.airdropCmd.Parse(os.Args[2:]) + stateCLI.checkRequirements() + + // Load configuration + configPlacement, err := PrepareConfigPlacement(stateCLI.configPathFlag) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + configs, err := LoadConfig(configPlacement.ConfigPath) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + Airdrop(configs) + case "version": + stateCLI.versionCmd.Parse(os.Args[2:]) + + fmt.Printf("v%s\n", ROBOTS_VERSION) + default: + stateCLI.usage() + os.Exit(1) + } +} diff --git a/robots/cmd/robots/configs.go b/robots/cmd/robots/configs.go new file mode 100644 index 00000000..e4975dd1 --- /dev/null +++ b/robots/cmd/robots/configs.go @@ -0,0 +1,133 @@ +/* +Configurations for robots server. +*/ +package main + +import ( + "encoding/json" + "fmt" + "io/ioutil" + "log" + "os" + "path/filepath" + "strings" +) + +var ( + NODEBALANCER_ACCESS_ID = os.Getenv("ENGINE_NODEBALANCER_ACCESS_ID") + MUMBAI_WEB3_PROVIDER_URI = os.Getenv("MOONSTREAM_MUMBAI_WEB3_PROVIDER_URI") + POLYGON_WEB3_PROVIDER_URI = os.Getenv("MOONSTREAM_POLYGON_WEB3_PROVIDER_URI") + WYRM_WEB3_PROVIDER_URI = os.Getenv("MOONSTREAM_WYRM_WEB3_PROVIDER_URI") + + JOURNAL_SEARCH_BATCH_SIZE = 20 + + ROBOTS_SIGNER_SECRETS_DIR_PATH = os.Getenv("ENGINE_ROBOTS_SECRETS_DIR") + + HUMBUG_REPORTER_ROBOTS_HEARTBEAT_TOKEN = os.Getenv("HUMBUG_REPORTER_ROBOTS_HEARTBEAT_TOKEN") +) + +type RobotsConfig struct { + CollectionId string `json:"collection_id"` + SignerKeyfileName string `json:"signer_keyfile_name"` + SignerPasswordFileName string `json:"signer_password_file_name"` + TerminusPoolId int64 `json:"terminus_pool_id"` + Blockchain string `json:"blockchain"` + TerminusAddress string `json:"terminus_address"` + ValueToClaim int64 `json:"value_to_claim"` + MaxValueToClaim int64 `json:"max_value_to_claim"` +} + +func LoadConfig(configPath string) (*[]RobotsConfig, error) { + rawBytes, err := ioutil.ReadFile(configPath) + if err != nil { + return nil, err + } + robotsConfigs := &[]RobotsConfig{} + err = json.Unmarshal(rawBytes, robotsConfigs) + if err != nil { + return nil, err + } + return robotsConfigs, nil +} + +type ConfigPlacement struct { + ConfigDirPath string + ConfigDirExists bool + + ConfigPath string + ConfigExists bool +} + +// CheckPathExists checks if path to file exists +func CheckPathExists(path string) (bool, error) { + var exists = true + _, err := os.Stat(path) + if err != nil { + if os.IsNotExist(err) { + exists = false + } else { + return exists, fmt.Errorf("Error due checking file path exists, err: %v", err) + } + } + + return exists, nil +} + +func PrepareConfigPlacement(providedPath string) (*ConfigPlacement, error) { + var configDirPath, configPath string + if providedPath == "" { + homeDir, err := os.UserHomeDir() + if err != nil { + return nil, fmt.Errorf("Unable to find user home directory, %v", err) + } + configDirPath = fmt.Sprintf("%s/.robots", homeDir) + configPath = fmt.Sprintf("%s/config.json", configDirPath) + } else { + configPath = strings.TrimSuffix(providedPath, "/") + configDirPath = filepath.Dir(configPath) + } + + configDirPathExists, err := CheckPathExists(configDirPath) + if err != nil { + return nil, err + } + configPathExists, err := CheckPathExists(configPath) + if err != nil { + return nil, err + } + + configPlacement := &ConfigPlacement{ + ConfigDirPath: configDirPath, + ConfigDirExists: configDirPathExists, + + ConfigPath: configPath, + ConfigExists: configPathExists, + } + + return configPlacement, nil +} + +// Generates empty list of robots configuration +func GenerateDefaultConfig(config *ConfigPlacement) error { + if !config.ConfigDirExists { + if err := os.MkdirAll(config.ConfigDirPath, os.ModePerm); err != nil { + return fmt.Errorf("Unable to create directory, %v", err) + } + log.Printf("Config directory created at: %s", config.ConfigDirPath) + } + + if !config.ConfigExists { + tempConfig := []RobotsConfig{} + tempConfigJson, err := json.Marshal(tempConfig) + if err != nil { + return fmt.Errorf("Unable to marshal configuration data, err: %v", err) + } + err = ioutil.WriteFile(config.ConfigPath, tempConfigJson, os.ModePerm) + if err != nil { + return fmt.Errorf("Unable to write default config to file %s, err: %v", config.ConfigPath, err) + } + log.Printf("Created default configuration at %s", config.ConfigPath) + } + + return nil +} diff --git a/robots/cmd/robots/entity.go b/robots/cmd/robots/entity.go new file mode 100644 index 00000000..54cfba02 --- /dev/null +++ b/robots/cmd/robots/entity.go @@ -0,0 +1,145 @@ +package main + +import ( + "encoding/json" + "errors" + "fmt" + "io" + "io/ioutil" + "net/http" + "os" + "time" +) + +type EntityInstance struct { + PublicEndpoint string + CollectionId string + CollectionName string + + Headers map[string]string +} + +type EntityResponse struct { + EntityId string `json:"entity_id"` + CollectionId string `json:"collection_id"` + Address string `json:"address"` + Blockchain string `json:"blockchain"` + Name string `json:"name"` + RequiredFields []map[string]string `json:"required_fields"` + CreatedAt string `json:"created_at"` + UpdatedAt string `json:"updated_at"` +} + +type EntitySearchResponse struct { + TotalResults int64 `json:"total_results"` + Offset int64 `json:"offset"` + NextOffset int64 `json:"next_offset"` + MaxScore float64 `json:"max_score"` + Entities []EntityResponse `json:"entities"` +} + +type EntityCollectionResponse struct { + CollectionId string `json:"collection_id"` + Name string `json:"name"` +} + +func InitializeEntityInstance(collectionId string) (*EntityInstance, error) { + MOONSTREAM_ENTITY_URL := os.Getenv("MOONSTREAM_ENTITY_URL") + if MOONSTREAM_ENTITY_URL == "" { + return nil, errors.New("Environment variable MOONSTREAM_ENTITY_URL should be specified") + } + + publicEndpoint := fmt.Sprintf("%s/public", MOONSTREAM_ENTITY_URL) + headers := make(map[string]string) + headers["X-Moonstream-Robots"] = "airdrop-robot" + + url := fmt.Sprintf("%s/collections/%s", publicEndpoint, collectionId) + body, _, err := caller("GET", url, nil, headers, 15) + if err != nil { + return nil, err + } + + var resp EntityCollectionResponse + err = json.Unmarshal(*body, &resp) + if err != nil { + return nil, err + } + + entityInstance := EntityInstance{ + PublicEndpoint: publicEndpoint, + CollectionId: collectionId, + CollectionName: resp.Name, + Headers: headers, + } + + return &entityInstance, nil +} + +// Make HTTP calls to required servers +func caller(method, url string, reqBody io.Reader, headers map[string]string, timeout int) (*[]byte, int, error) { + req, err := http.NewRequest(method, url, reqBody) + if err != nil { + return nil, 0, err + } + if len(headers) > 0 { + for k, v := range headers { + req.Header.Set(k, v) + } + } + + client := http.Client{Timeout: time.Second * time.Duration(timeout)} + resp, err := client.Do(req) + if err != nil { + return nil, 0, err + } + defer resp.Body.Close() + + // Parse response + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + return nil, resp.StatusCode, err + } + + return &body, resp.StatusCode, nil +} + +// FetchPublicSearchUntouched request not touched entities, ready to airdrop +// TODO(kompotkot): Pass with robots header unique identifier of robot +func (ec *EntityInstance) FetchPublicSearchUntouched(limit int) (int, EntitySearchResponse, error) { + data := EntitySearchResponse{} + + url := fmt.Sprintf("%s/collections/%s/search?required_field=!touch:true&limit=%d", ec.PublicEndpoint, ec.CollectionId, limit) + body, status_code, err := caller("GET", url, nil, ec.Headers, 15) + if err != nil { + return status_code, data, err + } + + var resp EntitySearchResponse + err = json.Unmarshal(*body, &resp) + if err != nil { + return status_code, data, err + } + data = resp + + return status_code, data, nil +} + +// TODO(kompotkot): Create batch endpoint for tags creation +func (ec *EntityInstance) TouchPublicEntity(entityId string, timeout int) (int, []string, error) { + var data []string + + url := fmt.Sprintf("%s/collections/%s/entities/%s", ec.PublicEndpoint, ec.CollectionId, entityId) + body, status_code, err := caller("PUT", url, nil, ec.Headers, timeout) + if err != nil { + return status_code, data, err + } + + var resp []string + err = json.Unmarshal(*body, &resp) + if err != nil { + return status_code, data, err + } + data = resp + + return status_code, data, nil +} diff --git a/robots/cmd/robots/main.go b/robots/cmd/robots/main.go new file mode 100644 index 00000000..cee85c6c --- /dev/null +++ b/robots/cmd/robots/main.go @@ -0,0 +1,5 @@ +package main + +func main() { + cli() +} diff --git a/robots/cmd/robots/networks.go b/robots/cmd/robots/networks.go new file mode 100644 index 00000000..93fd8495 --- /dev/null +++ b/robots/cmd/robots/networks.go @@ -0,0 +1,80 @@ +package main + +import ( + "context" + "errors" + "fmt" + "math/big" + + "github.com/ethereum/go-ethereum/ethclient" +) + +type NetworkClient struct { + Endpoint string + ChainID *big.Int +} + +type NetworkInstance struct { + Blockchain string + Endpoint string + ChainID *big.Int + + Client *ethclient.Client + + GasPrice *big.Int +} + +func InitializeNetworks() (map[string]NetworkClient, error) { + networks := make(map[string]NetworkClient) + + if NODEBALANCER_ACCESS_ID == "" { + return nil, errors.New("Environment variable ENGINE_NODEBALANCER_ACCESS_ID should be specified") + } + + if MUMBAI_WEB3_PROVIDER_URI == "" { + return nil, errors.New("Environment variable MUMBAI_WEB3_PROVIDER_URI should be specified") + } + if POLYGON_WEB3_PROVIDER_URI == "" { + return nil, errors.New("Environment variable POLYGON_WEB3_PROVIDER_URI should be specified") + } + if WYRM_WEB3_PROVIDER_URI == "" { + return nil, errors.New("Environment variable MOONSTREAM_WYRM_WEB3_PROVIDER_URI should be specified") + } + + networks["mumbai"] = NetworkClient{ + Endpoint: fmt.Sprintf("%s?access_id=%s&data_source=blockchain", MUMBAI_WEB3_PROVIDER_URI, NODEBALANCER_ACCESS_ID), + ChainID: big.NewInt(80001), + } + networks["polygon"] = NetworkClient{ + Endpoint: fmt.Sprintf("%s?access_id=%s&data_source=blockchain", POLYGON_WEB3_PROVIDER_URI, NODEBALANCER_ACCESS_ID), + ChainID: big.NewInt(137), + } + networks["wyrm"] = NetworkClient{ + Endpoint: WYRM_WEB3_PROVIDER_URI, + ChainID: big.NewInt(322), + } + + return networks, nil +} + +// GenDialRpcClient parse PRC endpoint to dial client +func GenDialRpcClient(rpc_endpoint_uri string) (*ethclient.Client, error) { + client, err := ethclient.Dial(rpc_endpoint_uri) + if err != nil { + return nil, err + } + + return client, nil +} + +// FetchSuggestedGasPrice fetch network for suggested gas price +func (ni *NetworkInstance) FetchSuggestedGasPrice(ctx context.Context) error { + gas_price, err := ni.Client.SuggestGasPrice(ctx) + if err != nil { + return err + } + + ni.GasPrice = gas_price + + return nil +} diff --git a/robots/cmd/robots/signer.go b/robots/cmd/robots/signer.go new file mode 100644 index 00000000..a15915b2 --- /dev/null +++ b/robots/cmd/robots/signer.go @@ -0,0 +1,65 @@ +package main + +import ( + "errors" + "fmt" + "io/ioutil" + "strings" + + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/accounts/keystore" + "github.com/ethereum/go-ethereum/common" +) + +type SignerInstance struct { + Address common.Address + PrivateKey *keystore.Key +} + +// initializeSigner parse secrets directory with keyfile and passfile, +// then opens keyfile with password to privateKey +func initializeSigner(keyfileName, passfileName string) (*SignerInstance, error) { + if ROBOTS_SIGNER_SECRETS_DIR_PATH == "" { + return nil, errors.New("Directory with signer secrets not set") + } + + keyfilePath := fmt.Sprintf("%s/%s", ROBOTS_SIGNER_SECRETS_DIR_PATH, keyfileName) + keyfilePasswordPath := fmt.Sprintf("%s/%s", ROBOTS_SIGNER_SECRETS_DIR_PATH, passfileName) + + passfile, err := ioutil.ReadFile(keyfilePasswordPath) + if err != nil { + return nil, err + } + passfile_lines := strings.Split(string(passfile), "\n") + password := passfile_lines[0] + + keyfile, err := ioutil.ReadFile(keyfilePath) + if err != nil { + return nil, err + } + + privateKey, err := keystore.DecryptKey(keyfile, password) + if err != nil { + return nil, err + } + + signer := SignerInstance{ + Address: privateKey.Address, + PrivateKey: privateKey, + } + + return &signer, nil +} + +func (s *SignerInstance) CreateTransactor(network NetworkInstance) (*bind.TransactOpts, error) { + auth, err := bind.NewKeyedTransactorWithChainID(s.PrivateKey.PrivateKey, network.ChainID) + if err != nil { + return nil, err + } + // auth.Nonce = big.NewInt(int64(nonce)) + // auth.Value = big.NewInt(0) + // auth.GasLimit = uint64(300000) + // auth.GasPrice = gasPrice + + return auth, nil +} diff --git a/robots/cmd/robots/terminus.go b/robots/cmd/robots/terminus.go new file mode 100644 index 00000000..2e6c0fcd --- /dev/null +++ b/robots/cmd/robots/terminus.go @@ -0,0 +1,73 @@ +package main + +import ( + "math/big" + + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/ethclient" + + terminus_contract "github.com/bugout-dev/engine/robots/pkg/terminus" +) + +type ContractTerminusInstance struct { + Address common.Address + Instance *terminus_contract.Terminus + TerminusPoolId int64 +} + +func GetTerminusContractAddress(terminusAddress string) common.Address { + return common.HexToAddress(terminusAddress) +} + +// InitializeContractInstance parse contract to instance +func InitializeTerminusContractInstance(client *ethclient.Client, address common.Address) (*terminus_contract.Terminus, error) { + contractInstance, err := terminus_contract.NewTerminus(address, client) + if err != nil { + return nil, err + } + + return contractInstance, nil +} + +func (ct *ContractTerminusInstance) FetchPoolCapacity(pool_id int64) (*big.Int, error) { + pool_capacity, err := ct.Instance.TerminusPoolCapacity(nil, big.NewInt(pool_id)) + if err != nil { + return nil, err + } + + return pool_capacity, nil +} + +// PoolMintBatch executes PoolMintBatch for list of address with same value amount +func (cti *ContractTerminusInstance) PoolMintBatch(auth *bind.TransactOpts, claimants []Claimant, value int64) (*types.Transaction, error) { + to_addresses := []common.Address{} + values := []*big.Int{} + for _, claimant := range claimants { + to_addresses = append(to_addresses, common.HexToAddress(claimant.Address)) + values = append(values, big.NewInt(value)) + } + + tx, err := cti.Instance.PoolMintBatch(auth, big.NewInt(cti.TerminusPoolId), to_addresses, values) + if err != nil { + return nil, err + } + + return tx, nil +} + +func (cti *ContractTerminusInstance) BalanceOfBatch(auth *bind.CallOpts, claimants []Claimant, id_int int64) ([]*big.Int, error) { + addresses := []common.Address{} + ids := []*big.Int{} + for _, claimant := range claimants { + addresses = append(addresses, common.HexToAddress(claimant.Address)) + ids = append(ids, big.NewInt(id_int)) + } + balances, err := cti.Instance.BalanceOfBatch(auth, addresses, ids) + if err != nil { + return nil, err + } + + return balances, nil +} diff --git a/robots/cmd/robots/version.go b/robots/cmd/robots/version.go new file mode 100644 index 00000000..0c1aba9c --- /dev/null +++ b/robots/cmd/robots/version.go @@ -0,0 +1,3 @@ +package main + +var ROBOTS_VERSION = "0.0.2" diff --git a/robots/deploy/deploy.bash b/robots/deploy/deploy.bash new file mode 100755 index 00000000..83d24f31 --- /dev/null +++ b/robots/deploy/deploy.bash @@ -0,0 +1,57 @@ +#!/usr/bin/env bash + +# Deployment script - intended to run on Robots server + +# Colors +C_RESET='\033[0m' +C_RED='\033[1;31m' +C_GREEN='\033[1;32m' +C_YELLOW='\033[1;33m' + +# Logs +PREFIX_INFO="${C_GREEN}[INFO]${C_RESET} [$(date +%d-%m\ %T)]" +PREFIX_WARN="${C_YELLOW}[WARN]${C_RESET} [$(date +%d-%m\ %T)]" +PREFIX_CRIT="${C_RED}[CRIT]${C_RESET} [$(date +%d-%m\ %T)]" + +# Main +APP_DIR="${APP_DIR:-/home/ubuntu/engine/robots}" +AWS_DEFAULT_REGION="${AWS_DEFAULT_REGION:-us-east-1}" +SCRIPT_DIR="$(realpath $(dirname $0))" +SECRETS_DIR="${SECRETS_DIR:-/home/ubuntu/robots-secrets}" +PARAMETERS_ENV_PATH="${SECRETS_DIR}/app.env" + +# Airdrop service +ROBOTS_AIRDROP_SERVICE_FILE="robots-airdrop.service" + +set -eu + +if [ ! -d "$SECRETS_DIR" ]; then + echo -e "${PREFIX_WARN} Created new directory for environment variables" + mkdir "$SECRETS_DIR" +fi + +echo +echo +echo -e "${PREFIX_INFO} Install checkenv" +HOME=/home/ubuntu /usr/local/go/bin/go install github.com/bugout-dev/checkenv@latest + +echo +echo +echo -e "${PREFIX_INFO} Retrieving addition deployment parameters" +AWS_DEFAULT_REGION="${AWS_DEFAULT_REGION}" /home/ubuntu/go/bin/checkenv show aws_ssm+robots:true > "${PARAMETERS_ENV_PATH}" + +echo +echo +echo -e "${PREFIX_INFO} Building executable robots script with Go" +EXEC_DIR=$(pwd) +cd "${APP_DIR}" +HOME=/home/ubuntu /usr/local/go/bin/go build -o "${APP_DIR}/robots" "${APP_DIR}/cmd/robots/" +cd "${EXEC_DIR}" + +echo +echo +echo -e "${PREFIX_INFO} Replacing existing Airdrop robots service definition with ${ROBOTS_AIRDROP_SERVICE_FILE}" +chmod 644 "${SCRIPT_DIR}/${ROBOTS_AIRDROP_SERVICE_FILE}" +cp "${SCRIPT_DIR}/${ROBOTS_AIRDROP_SERVICE_FILE}" "/home/ubuntu/.config/systemd/user/${ROBOTS_AIRDROP_SERVICE_FILE}" +XDG_RUNTIME_DIR="/run/user/1000" systemctl --user daemon-reload +XDG_RUNTIME_DIR="/run/user/1000" systemctl --user restart "${ROBOTS_AIRDROP_SERVICE_FILE}" diff --git a/robots/deploy/robots-airdrop.service b/robots/deploy/robots-airdrop.service new file mode 100644 index 00000000..8cc16459 --- /dev/null +++ b/robots/deploy/robots-airdrop.service @@ -0,0 +1,16 @@ +[Unit] +Description=Airdrop Engine robots +After=network.target +StartLimitIntervalSec=300 +StartLimitBurst=3 + +[Service] +WorkingDirectory=/home/ubuntu/engine/robots +EnvironmentFile=/home/ubuntu/robots-secrets/app.env +Restart=on-failure +RestartSec=15s +ExecStart=/home/ubuntu/engine/robots/robots airdrop +SyslogIdentifier=robots-airdrop + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/robots/dev.sh b/robots/dev.sh new file mode 100755 index 00000000..f8600154 --- /dev/null +++ b/robots/dev.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env sh + +# Compile application and run with provided arguments +set -e + +PROGRAM_NAME="robots_dev" + +go build -o "$PROGRAM_NAME" cmd/robots/*.go + +./"$PROGRAM_NAME" "$@" diff --git a/robots/go.mod b/robots/go.mod new file mode 100644 index 00000000..f5e4988c --- /dev/null +++ b/robots/go.mod @@ -0,0 +1,24 @@ +module github.com/bugout-dev/engine/robots + +go 1.19 + +require github.com/ethereum/go-ethereum v1.10.26 + +require ( + github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect + github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect + github.com/bugout-dev/humbug/go v0.0.0-20230221171050-e0a1715ec546 // indirect + github.com/deckarep/golang-set v1.8.0 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect + github.com/go-ole/go-ole v1.2.1 // indirect + github.com/go-stack/stack v1.8.0 // indirect + github.com/google/uuid v1.2.0 // indirect + github.com/gorilla/websocket v1.4.2 // indirect + github.com/rjeczalik/notify v0.9.1 // indirect + github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect + github.com/tklauser/go-sysconf v0.3.5 // indirect + github.com/tklauser/numcpus v0.2.2 // indirect + golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect + golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect + gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect +) diff --git a/robots/go.sum b/robots/go.sum new file mode 100644 index 00000000..e2e12c38 --- /dev/null +++ b/robots/go.sum @@ -0,0 +1,75 @@ +github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 h1:fLjPD/aNc3UIOA6tDi6QXUemppXK3P9BI7mr2hd6gx8= +github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= +github.com/VictoriaMetrics/fastcache v1.6.0 h1:C/3Oi3EiBCqufydp1neRZkqcwmEiuRT9c3fqvvgKm5o= +github.com/btcsuite/btcd/btcec/v2 v2.2.0 h1:fzn1qaOt32TuLjFlkzYSsBC35Q3KUjT1SwPxiMSCF5k= +github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= +github.com/bugout-dev/humbug/go v0.0.0-20230221171050-e0a1715ec546 h1:qRPzjQAQwNxqfW+U+XkfBLQbCdXCp+sRxwVE0ydtqFM= +github.com/bugout-dev/humbug/go v0.0.0-20230221171050-e0a1715ec546/go.mod h1:U/NXHfc3tzGeQz+xVfpifXdPZi7p6VV8xdP/4ZKeWJU= +github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk= +github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= +github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4= +github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= +github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= +github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= +github.com/edsrzf/mmap-go v1.0.0 h1:CEBF7HpRnUCSJgGUb5h1Gm7e3VkmVDrR8lvWVLtrOFw= +github.com/ethereum/go-ethereum v1.10.26 h1:i/7d9RBBwiXCEuyduBQzJw/mKmnvzsN14jqBmytw72s= +github.com/ethereum/go-ethereum v1.10.26/go.mod h1:EYFyF19u3ezGLD4RqOkLq+ZCXzYbLoNDdZlMt7kyKFg= +github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c= +github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI= +github.com/go-ole/go-ole v1.2.1 h1:2lOsA72HgjxAuMlKpFiCbHTvu44PIVkZ5hqm3RSdI/E= +github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= +github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/golang-jwt/jwt/v4 v4.3.0 h1:kHL1vqdqWNfATmA0FNMdmZNMyZI1U6O31X4rlIPoBog= +github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= +github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs= +github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= +github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/hashicorp/go-bexpr v0.1.10 h1:9kuI5PFotCboP3dkDYFr/wi0gg0QVbSNz5oFRpxn4uE= +github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d h1:dg1dEPuWpEqDnvIw251EVy4zlP8gWbsGj4BsUKCRpYs= +github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= +github.com/holiman/uint256 v1.2.0 h1:gpSYcPLWGv4sG43I2mVLiDZCNDh/EpGjSk8tmtxitHM= +github.com/huin/goupnp v1.0.3 h1:N8No57ls+MnjlB+JPiCVSOyy/ot7MJTqlo7rn+NYSqQ= +github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= +github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8= +github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= +github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= +github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= +github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/prometheus/tsdb v0.7.1 h1:YZcsG11NqnK4czYLrWd9mpEuAJIHVQLwdrleYfszMAA= +github.com/rjeczalik/notify v0.9.1 h1:CLCKso/QK1snAlnhNR/CNvNiFU2saUtjV0bx3EwNeCE= +github.com/rjeczalik/notify v0.9.1/go.mod h1:rKwnCoCGeuQnwBtTSPL9Dad03Vh2n40ePRrjvIXnJho= +github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= +github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU= +github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= +github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4 h1:Gb2Tyox57NRNuZ2d3rmvB3pcmbu7O1RS3m8WRx7ilrg= +github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s= +github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= +github.com/tklauser/go-sysconf v0.3.5 h1:uu3Xl4nkLzQfXNsWn15rPc/HQCJKObbt1dKJeWp3vU4= +github.com/tklauser/go-sysconf v0.3.5/go.mod h1:MkWzOF4RMCshBAMXuhXJs64Rte09mITnppBXY/rYEFI= +github.com/tklauser/numcpus v0.2.2 h1:oyhllyrScuYI6g+h/zUvNXNp1wy7x8qQy3t/piefldA= +github.com/tklauser/numcpus v0.2.2/go.mod h1:x3qojaO3uyYt0i56EW/VUYs7uBvdl2fkfZFu0T9wgjM= +github.com/tyler-smith/go-bip39 v1.0.1-0.20181017060643-dbb3b84ba2ef h1:wHSqTBrZW24CsNJDfeh9Ex6Pm0Rcpc7qrgKBiL44vF4= +github.com/urfave/cli/v2 v2.10.2 h1:x3p8awjp/2arX+Nl/G2040AZpOCHS/eMJJ1/a+mye4Y= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= +golang.org/x/sys v0.0.0-20210316164454-77fc1eacc6aa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba h1:O8mE0/t419eoIwhTFpKVkHiTs/Igowgfkj25AcZrtiE= +gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU= +gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/robots/pkg/terminus/terminus.go b/robots/pkg/terminus/terminus.go new file mode 100644 index 00000000..b08ae9c5 --- /dev/null +++ b/robots/pkg/terminus/terminus.go @@ -0,0 +1,1733 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package terminus + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription +) + +// TerminusMetaData contains all meta data concerning the Terminus contract. +var TerminusMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"}],\"name\":\"ApprovalForAll\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"toAddresses\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"name\":\"PoolMintBatch\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"ids\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"values\",\"type\":\"uint256[]\"}],\"name\":\"TransferBatch\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"TransferSingle\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"string\",\"name\":\"value\",\"type\":\"string\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"}],\"name\":\"URI\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"poolID\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"}],\"name\":\"approveForPool\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"accounts\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"ids\",\"type\":\"uint256[]\"}],\"name\":\"balanceOfBatch\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"poolID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"burn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"contractURI\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_capacity\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"_transferable\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"_burnable\",\"type\":\"bool\"}],\"name\":\"createPoolV1\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_capacity\",\"type\":\"uint256\"}],\"name\":\"createSimplePool\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"}],\"name\":\"isApprovedForAll\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"poolID\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"}],\"name\":\"isApprovedForPool\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"poolID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"mint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256[]\",\"name\":\"poolIDs\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"mintBatch\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"paymentToken\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"poolBasePrice\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"address[]\",\"name\":\"toAddresses\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"name\":\"poolMintBatch\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256[]\",\"name\":\"ids\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"safeBatchTransferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"safeTransferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"}],\"name\":\"setApprovalForAll\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_contractURI\",\"type\":\"string\"}],\"name\":\"setContractURI\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newPaymentToken\",\"type\":\"address\"}],\"name\":\"setPaymentToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newBasePrice\",\"type\":\"uint256\"}],\"name\":\"setPoolBasePrice\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"poolID\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"newController\",\"type\":\"address\"}],\"name\":\"setPoolController\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"poolID\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"poolURI\",\"type\":\"string\"}],\"name\":\"setURI\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"terminusController\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"poolID\",\"type\":\"uint256\"}],\"name\":\"terminusPoolCapacity\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"poolID\",\"type\":\"uint256\"}],\"name\":\"terminusPoolController\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"poolID\",\"type\":\"uint256\"}],\"name\":\"terminusPoolSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalPools\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"poolID\",\"type\":\"uint256\"}],\"name\":\"uri\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"toAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"withdrawPayments\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", +} + +// TerminusABI is the input ABI used to generate the binding from. +// Deprecated: Use TerminusMetaData.ABI instead. +var TerminusABI = TerminusMetaData.ABI + +// Terminus is an auto generated Go binding around an Ethereum contract. +type Terminus struct { + TerminusCaller // Read-only binding to the contract + TerminusTransactor // Write-only binding to the contract + TerminusFilterer // Log filterer for contract events +} + +// TerminusCaller is an auto generated read-only Go binding around an Ethereum contract. +type TerminusCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// TerminusTransactor is an auto generated write-only Go binding around an Ethereum contract. +type TerminusTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// TerminusFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type TerminusFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// TerminusSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type TerminusSession struct { + Contract *Terminus // 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 +} + +// TerminusCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type TerminusCallerSession struct { + Contract *TerminusCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// TerminusTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type TerminusTransactorSession struct { + Contract *TerminusTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// TerminusRaw is an auto generated low-level Go binding around an Ethereum contract. +type TerminusRaw struct { + Contract *Terminus // Generic contract binding to access the raw methods on +} + +// TerminusCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type TerminusCallerRaw struct { + Contract *TerminusCaller // Generic read-only contract binding to access the raw methods on +} + +// TerminusTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type TerminusTransactorRaw struct { + Contract *TerminusTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewTerminus creates a new instance of Terminus, bound to a specific deployed contract. +func NewTerminus(address common.Address, backend bind.ContractBackend) (*Terminus, error) { + contract, err := bindTerminus(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &Terminus{TerminusCaller: TerminusCaller{contract: contract}, TerminusTransactor: TerminusTransactor{contract: contract}, TerminusFilterer: TerminusFilterer{contract: contract}}, nil +} + +// NewTerminusCaller creates a new read-only instance of Terminus, bound to a specific deployed contract. +func NewTerminusCaller(address common.Address, caller bind.ContractCaller) (*TerminusCaller, error) { + contract, err := bindTerminus(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &TerminusCaller{contract: contract}, nil +} + +// NewTerminusTransactor creates a new write-only instance of Terminus, bound to a specific deployed contract. +func NewTerminusTransactor(address common.Address, transactor bind.ContractTransactor) (*TerminusTransactor, error) { + contract, err := bindTerminus(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &TerminusTransactor{contract: contract}, nil +} + +// NewTerminusFilterer creates a new log filterer instance of Terminus, bound to a specific deployed contract. +func NewTerminusFilterer(address common.Address, filterer bind.ContractFilterer) (*TerminusFilterer, error) { + contract, err := bindTerminus(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &TerminusFilterer{contract: contract}, nil +} + +// bindTerminus binds a generic wrapper to an already deployed contract. +func bindTerminus(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := abi.JSON(strings.NewReader(TerminusABI)) + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_Terminus *TerminusRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Terminus.Contract.TerminusCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_Terminus *TerminusRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Terminus.Contract.TerminusTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Terminus *TerminusRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Terminus.Contract.TerminusTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_Terminus *TerminusCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Terminus.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_Terminus *TerminusTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Terminus.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Terminus *TerminusTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Terminus.Contract.contract.Transact(opts, method, params...) +} + +// BalanceOf is a free data retrieval call binding the contract method 0x00fdd58e. +// +// Solidity: function balanceOf(address account, uint256 id) view returns(uint256) +func (_Terminus *TerminusCaller) BalanceOf(opts *bind.CallOpts, account common.Address, id *big.Int) (*big.Int, error) { + var out []interface{} + err := _Terminus.contract.Call(opts, &out, "balanceOf", account, id) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// BalanceOf is a free data retrieval call binding the contract method 0x00fdd58e. +// +// Solidity: function balanceOf(address account, uint256 id) view returns(uint256) +func (_Terminus *TerminusSession) BalanceOf(account common.Address, id *big.Int) (*big.Int, error) { + return _Terminus.Contract.BalanceOf(&_Terminus.CallOpts, account, id) +} + +// BalanceOf is a free data retrieval call binding the contract method 0x00fdd58e. +// +// Solidity: function balanceOf(address account, uint256 id) view returns(uint256) +func (_Terminus *TerminusCallerSession) BalanceOf(account common.Address, id *big.Int) (*big.Int, error) { + return _Terminus.Contract.BalanceOf(&_Terminus.CallOpts, account, id) +} + +// BalanceOfBatch is a free data retrieval call binding the contract method 0x4e1273f4. +// +// Solidity: function balanceOfBatch(address[] accounts, uint256[] ids) view returns(uint256[]) +func (_Terminus *TerminusCaller) BalanceOfBatch(opts *bind.CallOpts, accounts []common.Address, ids []*big.Int) ([]*big.Int, error) { + var out []interface{} + err := _Terminus.contract.Call(opts, &out, "balanceOfBatch", accounts, ids) + + if err != nil { + return *new([]*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new([]*big.Int)).(*[]*big.Int) + + return out0, err + +} + +// BalanceOfBatch is a free data retrieval call binding the contract method 0x4e1273f4. +// +// Solidity: function balanceOfBatch(address[] accounts, uint256[] ids) view returns(uint256[]) +func (_Terminus *TerminusSession) BalanceOfBatch(accounts []common.Address, ids []*big.Int) ([]*big.Int, error) { + return _Terminus.Contract.BalanceOfBatch(&_Terminus.CallOpts, accounts, ids) +} + +// BalanceOfBatch is a free data retrieval call binding the contract method 0x4e1273f4. +// +// Solidity: function balanceOfBatch(address[] accounts, uint256[] ids) view returns(uint256[]) +func (_Terminus *TerminusCallerSession) BalanceOfBatch(accounts []common.Address, ids []*big.Int) ([]*big.Int, error) { + return _Terminus.Contract.BalanceOfBatch(&_Terminus.CallOpts, accounts, ids) +} + +// ContractURI is a free data retrieval call binding the contract method 0xe8a3d485. +// +// Solidity: function contractURI() view returns(string) +func (_Terminus *TerminusCaller) ContractURI(opts *bind.CallOpts) (string, error) { + var out []interface{} + err := _Terminus.contract.Call(opts, &out, "contractURI") + + if err != nil { + return *new(string), err + } + + out0 := *abi.ConvertType(out[0], new(string)).(*string) + + return out0, err + +} + +// ContractURI is a free data retrieval call binding the contract method 0xe8a3d485. +// +// Solidity: function contractURI() view returns(string) +func (_Terminus *TerminusSession) ContractURI() (string, error) { + return _Terminus.Contract.ContractURI(&_Terminus.CallOpts) +} + +// ContractURI is a free data retrieval call binding the contract method 0xe8a3d485. +// +// Solidity: function contractURI() view returns(string) +func (_Terminus *TerminusCallerSession) ContractURI() (string, error) { + return _Terminus.Contract.ContractURI(&_Terminus.CallOpts) +} + +// IsApprovedForAll is a free data retrieval call binding the contract method 0xe985e9c5. +// +// Solidity: function isApprovedForAll(address account, address operator) view returns(bool) +func (_Terminus *TerminusCaller) IsApprovedForAll(opts *bind.CallOpts, account common.Address, operator common.Address) (bool, error) { + var out []interface{} + err := _Terminus.contract.Call(opts, &out, "isApprovedForAll", account, operator) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// IsApprovedForAll is a free data retrieval call binding the contract method 0xe985e9c5. +// +// Solidity: function isApprovedForAll(address account, address operator) view returns(bool) +func (_Terminus *TerminusSession) IsApprovedForAll(account common.Address, operator common.Address) (bool, error) { + return _Terminus.Contract.IsApprovedForAll(&_Terminus.CallOpts, account, operator) +} + +// IsApprovedForAll is a free data retrieval call binding the contract method 0xe985e9c5. +// +// Solidity: function isApprovedForAll(address account, address operator) view returns(bool) +func (_Terminus *TerminusCallerSession) IsApprovedForAll(account common.Address, operator common.Address) (bool, error) { + return _Terminus.Contract.IsApprovedForAll(&_Terminus.CallOpts, account, operator) +} + +// IsApprovedForPool is a free data retrieval call binding the contract method 0x027b3fc2. +// +// Solidity: function isApprovedForPool(uint256 poolID, address operator) view returns(bool) +func (_Terminus *TerminusCaller) IsApprovedForPool(opts *bind.CallOpts, poolID *big.Int, operator common.Address) (bool, error) { + var out []interface{} + err := _Terminus.contract.Call(opts, &out, "isApprovedForPool", poolID, operator) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// IsApprovedForPool is a free data retrieval call binding the contract method 0x027b3fc2. +// +// Solidity: function isApprovedForPool(uint256 poolID, address operator) view returns(bool) +func (_Terminus *TerminusSession) IsApprovedForPool(poolID *big.Int, operator common.Address) (bool, error) { + return _Terminus.Contract.IsApprovedForPool(&_Terminus.CallOpts, poolID, operator) +} + +// IsApprovedForPool is a free data retrieval call binding the contract method 0x027b3fc2. +// +// Solidity: function isApprovedForPool(uint256 poolID, address operator) view returns(bool) +func (_Terminus *TerminusCallerSession) IsApprovedForPool(poolID *big.Int, operator common.Address) (bool, error) { + return _Terminus.Contract.IsApprovedForPool(&_Terminus.CallOpts, poolID, operator) +} + +// PaymentToken is a free data retrieval call binding the contract method 0x3013ce29. +// +// Solidity: function paymentToken() view returns(address) +func (_Terminus *TerminusCaller) PaymentToken(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Terminus.contract.Call(opts, &out, "paymentToken") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// PaymentToken is a free data retrieval call binding the contract method 0x3013ce29. +// +// Solidity: function paymentToken() view returns(address) +func (_Terminus *TerminusSession) PaymentToken() (common.Address, error) { + return _Terminus.Contract.PaymentToken(&_Terminus.CallOpts) +} + +// PaymentToken is a free data retrieval call binding the contract method 0x3013ce29. +// +// Solidity: function paymentToken() view returns(address) +func (_Terminus *TerminusCallerSession) PaymentToken() (common.Address, error) { + return _Terminus.Contract.PaymentToken(&_Terminus.CallOpts) +} + +// PoolBasePrice is a free data retrieval call binding the contract method 0x8925d013. +// +// Solidity: function poolBasePrice() view returns(uint256) +func (_Terminus *TerminusCaller) PoolBasePrice(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _Terminus.contract.Call(opts, &out, "poolBasePrice") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// PoolBasePrice is a free data retrieval call binding the contract method 0x8925d013. +// +// Solidity: function poolBasePrice() view returns(uint256) +func (_Terminus *TerminusSession) PoolBasePrice() (*big.Int, error) { + return _Terminus.Contract.PoolBasePrice(&_Terminus.CallOpts) +} + +// PoolBasePrice is a free data retrieval call binding the contract method 0x8925d013. +// +// Solidity: function poolBasePrice() view returns(uint256) +func (_Terminus *TerminusCallerSession) PoolBasePrice() (*big.Int, error) { + return _Terminus.Contract.PoolBasePrice(&_Terminus.CallOpts) +} + +// SupportsInterface is a free data retrieval call binding the contract method 0x01ffc9a7. +// +// Solidity: function supportsInterface(bytes4 interfaceId) view returns(bool) +func (_Terminus *TerminusCaller) SupportsInterface(opts *bind.CallOpts, interfaceId [4]byte) (bool, error) { + var out []interface{} + err := _Terminus.contract.Call(opts, &out, "supportsInterface", interfaceId) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// SupportsInterface is a free data retrieval call binding the contract method 0x01ffc9a7. +// +// Solidity: function supportsInterface(bytes4 interfaceId) view returns(bool) +func (_Terminus *TerminusSession) SupportsInterface(interfaceId [4]byte) (bool, error) { + return _Terminus.Contract.SupportsInterface(&_Terminus.CallOpts, interfaceId) +} + +// SupportsInterface is a free data retrieval call binding the contract method 0x01ffc9a7. +// +// Solidity: function supportsInterface(bytes4 interfaceId) view returns(bool) +func (_Terminus *TerminusCallerSession) SupportsInterface(interfaceId [4]byte) (bool, error) { + return _Terminus.Contract.SupportsInterface(&_Terminus.CallOpts, interfaceId) +} + +// TerminusController is a free data retrieval call binding the contract method 0x366e59e3. +// +// Solidity: function terminusController() view returns(address) +func (_Terminus *TerminusCaller) TerminusController(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Terminus.contract.Call(opts, &out, "terminusController") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// TerminusController is a free data retrieval call binding the contract method 0x366e59e3. +// +// Solidity: function terminusController() view returns(address) +func (_Terminus *TerminusSession) TerminusController() (common.Address, error) { + return _Terminus.Contract.TerminusController(&_Terminus.CallOpts) +} + +// TerminusController is a free data retrieval call binding the contract method 0x366e59e3. +// +// Solidity: function terminusController() view returns(address) +func (_Terminus *TerminusCallerSession) TerminusController() (common.Address, error) { + return _Terminus.Contract.TerminusController(&_Terminus.CallOpts) +} + +// TerminusPoolCapacity is a free data retrieval call binding the contract method 0x5dc8bdf8. +// +// Solidity: function terminusPoolCapacity(uint256 poolID) view returns(uint256) +func (_Terminus *TerminusCaller) TerminusPoolCapacity(opts *bind.CallOpts, poolID *big.Int) (*big.Int, error) { + var out []interface{} + err := _Terminus.contract.Call(opts, &out, "terminusPoolCapacity", poolID) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// TerminusPoolCapacity is a free data retrieval call binding the contract method 0x5dc8bdf8. +// +// Solidity: function terminusPoolCapacity(uint256 poolID) view returns(uint256) +func (_Terminus *TerminusSession) TerminusPoolCapacity(poolID *big.Int) (*big.Int, error) { + return _Terminus.Contract.TerminusPoolCapacity(&_Terminus.CallOpts, poolID) +} + +// TerminusPoolCapacity is a free data retrieval call binding the contract method 0x5dc8bdf8. +// +// Solidity: function terminusPoolCapacity(uint256 poolID) view returns(uint256) +func (_Terminus *TerminusCallerSession) TerminusPoolCapacity(poolID *big.Int) (*big.Int, error) { + return _Terminus.Contract.TerminusPoolCapacity(&_Terminus.CallOpts, poolID) +} + +// TerminusPoolController is a free data retrieval call binding the contract method 0xd0c402e5. +// +// Solidity: function terminusPoolController(uint256 poolID) view returns(address) +func (_Terminus *TerminusCaller) TerminusPoolController(opts *bind.CallOpts, poolID *big.Int) (common.Address, error) { + var out []interface{} + err := _Terminus.contract.Call(opts, &out, "terminusPoolController", poolID) + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// TerminusPoolController is a free data retrieval call binding the contract method 0xd0c402e5. +// +// Solidity: function terminusPoolController(uint256 poolID) view returns(address) +func (_Terminus *TerminusSession) TerminusPoolController(poolID *big.Int) (common.Address, error) { + return _Terminus.Contract.TerminusPoolController(&_Terminus.CallOpts, poolID) +} + +// TerminusPoolController is a free data retrieval call binding the contract method 0xd0c402e5. +// +// Solidity: function terminusPoolController(uint256 poolID) view returns(address) +func (_Terminus *TerminusCallerSession) TerminusPoolController(poolID *big.Int) (common.Address, error) { + return _Terminus.Contract.TerminusPoolController(&_Terminus.CallOpts, poolID) +} + +// TerminusPoolSupply is a free data retrieval call binding the contract method 0xa44cfc82. +// +// Solidity: function terminusPoolSupply(uint256 poolID) view returns(uint256) +func (_Terminus *TerminusCaller) TerminusPoolSupply(opts *bind.CallOpts, poolID *big.Int) (*big.Int, error) { + var out []interface{} + err := _Terminus.contract.Call(opts, &out, "terminusPoolSupply", poolID) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// TerminusPoolSupply is a free data retrieval call binding the contract method 0xa44cfc82. +// +// Solidity: function terminusPoolSupply(uint256 poolID) view returns(uint256) +func (_Terminus *TerminusSession) TerminusPoolSupply(poolID *big.Int) (*big.Int, error) { + return _Terminus.Contract.TerminusPoolSupply(&_Terminus.CallOpts, poolID) +} + +// TerminusPoolSupply is a free data retrieval call binding the contract method 0xa44cfc82. +// +// Solidity: function terminusPoolSupply(uint256 poolID) view returns(uint256) +func (_Terminus *TerminusCallerSession) TerminusPoolSupply(poolID *big.Int) (*big.Int, error) { + return _Terminus.Contract.TerminusPoolSupply(&_Terminus.CallOpts, poolID) +} + +// TotalPools is a free data retrieval call binding the contract method 0xab3c7e52. +// +// Solidity: function totalPools() view returns(uint256) +func (_Terminus *TerminusCaller) TotalPools(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _Terminus.contract.Call(opts, &out, "totalPools") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// TotalPools is a free data retrieval call binding the contract method 0xab3c7e52. +// +// Solidity: function totalPools() view returns(uint256) +func (_Terminus *TerminusSession) TotalPools() (*big.Int, error) { + return _Terminus.Contract.TotalPools(&_Terminus.CallOpts) +} + +// TotalPools is a free data retrieval call binding the contract method 0xab3c7e52. +// +// Solidity: function totalPools() view returns(uint256) +func (_Terminus *TerminusCallerSession) TotalPools() (*big.Int, error) { + return _Terminus.Contract.TotalPools(&_Terminus.CallOpts) +} + +// Uri is a free data retrieval call binding the contract method 0x0e89341c. +// +// Solidity: function uri(uint256 poolID) view returns(string) +func (_Terminus *TerminusCaller) Uri(opts *bind.CallOpts, poolID *big.Int) (string, error) { + var out []interface{} + err := _Terminus.contract.Call(opts, &out, "uri", poolID) + + if err != nil { + return *new(string), err + } + + out0 := *abi.ConvertType(out[0], new(string)).(*string) + + return out0, err + +} + +// Uri is a free data retrieval call binding the contract method 0x0e89341c. +// +// Solidity: function uri(uint256 poolID) view returns(string) +func (_Terminus *TerminusSession) Uri(poolID *big.Int) (string, error) { + return _Terminus.Contract.Uri(&_Terminus.CallOpts, poolID) +} + +// Uri is a free data retrieval call binding the contract method 0x0e89341c. +// +// Solidity: function uri(uint256 poolID) view returns(string) +func (_Terminus *TerminusCallerSession) Uri(poolID *big.Int) (string, error) { + return _Terminus.Contract.Uri(&_Terminus.CallOpts, poolID) +} + +// ApproveForPool is a paid mutator transaction binding the contract method 0x85bc82e2. +// +// Solidity: function approveForPool(uint256 poolID, address operator) returns() +func (_Terminus *TerminusTransactor) ApproveForPool(opts *bind.TransactOpts, poolID *big.Int, operator common.Address) (*types.Transaction, error) { + return _Terminus.contract.Transact(opts, "approveForPool", poolID, operator) +} + +// ApproveForPool is a paid mutator transaction binding the contract method 0x85bc82e2. +// +// Solidity: function approveForPool(uint256 poolID, address operator) returns() +func (_Terminus *TerminusSession) ApproveForPool(poolID *big.Int, operator common.Address) (*types.Transaction, error) { + return _Terminus.Contract.ApproveForPool(&_Terminus.TransactOpts, poolID, operator) +} + +// ApproveForPool is a paid mutator transaction binding the contract method 0x85bc82e2. +// +// Solidity: function approveForPool(uint256 poolID, address operator) returns() +func (_Terminus *TerminusTransactorSession) ApproveForPool(poolID *big.Int, operator common.Address) (*types.Transaction, error) { + return _Terminus.Contract.ApproveForPool(&_Terminus.TransactOpts, poolID, operator) +} + +// Burn is a paid mutator transaction binding the contract method 0xf5298aca. +// +// Solidity: function burn(address from, uint256 poolID, uint256 amount) returns() +func (_Terminus *TerminusTransactor) Burn(opts *bind.TransactOpts, from common.Address, poolID *big.Int, amount *big.Int) (*types.Transaction, error) { + return _Terminus.contract.Transact(opts, "burn", from, poolID, amount) +} + +// Burn is a paid mutator transaction binding the contract method 0xf5298aca. +// +// Solidity: function burn(address from, uint256 poolID, uint256 amount) returns() +func (_Terminus *TerminusSession) Burn(from common.Address, poolID *big.Int, amount *big.Int) (*types.Transaction, error) { + return _Terminus.Contract.Burn(&_Terminus.TransactOpts, from, poolID, amount) +} + +// Burn is a paid mutator transaction binding the contract method 0xf5298aca. +// +// Solidity: function burn(address from, uint256 poolID, uint256 amount) returns() +func (_Terminus *TerminusTransactorSession) Burn(from common.Address, poolID *big.Int, amount *big.Int) (*types.Transaction, error) { + return _Terminus.Contract.Burn(&_Terminus.TransactOpts, from, poolID, amount) +} + +// CreatePoolV1 is a paid mutator transaction binding the contract method 0x3bad2d82. +// +// Solidity: function createPoolV1(uint256 _capacity, bool _transferable, bool _burnable) returns(uint256) +func (_Terminus *TerminusTransactor) CreatePoolV1(opts *bind.TransactOpts, _capacity *big.Int, _transferable bool, _burnable bool) (*types.Transaction, error) { + return _Terminus.contract.Transact(opts, "createPoolV1", _capacity, _transferable, _burnable) +} + +// CreatePoolV1 is a paid mutator transaction binding the contract method 0x3bad2d82. +// +// Solidity: function createPoolV1(uint256 _capacity, bool _transferable, bool _burnable) returns(uint256) +func (_Terminus *TerminusSession) CreatePoolV1(_capacity *big.Int, _transferable bool, _burnable bool) (*types.Transaction, error) { + return _Terminus.Contract.CreatePoolV1(&_Terminus.TransactOpts, _capacity, _transferable, _burnable) +} + +// CreatePoolV1 is a paid mutator transaction binding the contract method 0x3bad2d82. +// +// Solidity: function createPoolV1(uint256 _capacity, bool _transferable, bool _burnable) returns(uint256) +func (_Terminus *TerminusTransactorSession) CreatePoolV1(_capacity *big.Int, _transferable bool, _burnable bool) (*types.Transaction, error) { + return _Terminus.Contract.CreatePoolV1(&_Terminus.TransactOpts, _capacity, _transferable, _burnable) +} + +// CreateSimplePool is a paid mutator transaction binding the contract method 0xb507ef52. +// +// Solidity: function createSimplePool(uint256 _capacity) returns(uint256) +func (_Terminus *TerminusTransactor) CreateSimplePool(opts *bind.TransactOpts, _capacity *big.Int) (*types.Transaction, error) { + return _Terminus.contract.Transact(opts, "createSimplePool", _capacity) +} + +// CreateSimplePool is a paid mutator transaction binding the contract method 0xb507ef52. +// +// Solidity: function createSimplePool(uint256 _capacity) returns(uint256) +func (_Terminus *TerminusSession) CreateSimplePool(_capacity *big.Int) (*types.Transaction, error) { + return _Terminus.Contract.CreateSimplePool(&_Terminus.TransactOpts, _capacity) +} + +// CreateSimplePool is a paid mutator transaction binding the contract method 0xb507ef52. +// +// Solidity: function createSimplePool(uint256 _capacity) returns(uint256) +func (_Terminus *TerminusTransactorSession) CreateSimplePool(_capacity *big.Int) (*types.Transaction, error) { + return _Terminus.Contract.CreateSimplePool(&_Terminus.TransactOpts, _capacity) +} + +// Mint is a paid mutator transaction binding the contract method 0x731133e9. +// +// Solidity: function mint(address to, uint256 poolID, uint256 amount, bytes data) returns() +func (_Terminus *TerminusTransactor) Mint(opts *bind.TransactOpts, to common.Address, poolID *big.Int, amount *big.Int, data []byte) (*types.Transaction, error) { + return _Terminus.contract.Transact(opts, "mint", to, poolID, amount, data) +} + +// Mint is a paid mutator transaction binding the contract method 0x731133e9. +// +// Solidity: function mint(address to, uint256 poolID, uint256 amount, bytes data) returns() +func (_Terminus *TerminusSession) Mint(to common.Address, poolID *big.Int, amount *big.Int, data []byte) (*types.Transaction, error) { + return _Terminus.Contract.Mint(&_Terminus.TransactOpts, to, poolID, amount, data) +} + +// Mint is a paid mutator transaction binding the contract method 0x731133e9. +// +// Solidity: function mint(address to, uint256 poolID, uint256 amount, bytes data) returns() +func (_Terminus *TerminusTransactorSession) Mint(to common.Address, poolID *big.Int, amount *big.Int, data []byte) (*types.Transaction, error) { + return _Terminus.Contract.Mint(&_Terminus.TransactOpts, to, poolID, amount, data) +} + +// MintBatch is a paid mutator transaction binding the contract method 0x1f7fdffa. +// +// Solidity: function mintBatch(address to, uint256[] poolIDs, uint256[] amounts, bytes data) returns() +func (_Terminus *TerminusTransactor) MintBatch(opts *bind.TransactOpts, to common.Address, poolIDs []*big.Int, amounts []*big.Int, data []byte) (*types.Transaction, error) { + return _Terminus.contract.Transact(opts, "mintBatch", to, poolIDs, amounts, data) +} + +// MintBatch is a paid mutator transaction binding the contract method 0x1f7fdffa. +// +// Solidity: function mintBatch(address to, uint256[] poolIDs, uint256[] amounts, bytes data) returns() +func (_Terminus *TerminusSession) MintBatch(to common.Address, poolIDs []*big.Int, amounts []*big.Int, data []byte) (*types.Transaction, error) { + return _Terminus.Contract.MintBatch(&_Terminus.TransactOpts, to, poolIDs, amounts, data) +} + +// MintBatch is a paid mutator transaction binding the contract method 0x1f7fdffa. +// +// Solidity: function mintBatch(address to, uint256[] poolIDs, uint256[] amounts, bytes data) returns() +func (_Terminus *TerminusTransactorSession) MintBatch(to common.Address, poolIDs []*big.Int, amounts []*big.Int, data []byte) (*types.Transaction, error) { + return _Terminus.Contract.MintBatch(&_Terminus.TransactOpts, to, poolIDs, amounts, data) +} + +// PoolMintBatch is a paid mutator transaction binding the contract method 0x21adca96. +// +// Solidity: function poolMintBatch(uint256 id, address[] toAddresses, uint256[] amounts) returns() +func (_Terminus *TerminusTransactor) PoolMintBatch(opts *bind.TransactOpts, id *big.Int, toAddresses []common.Address, amounts []*big.Int) (*types.Transaction, error) { + return _Terminus.contract.Transact(opts, "poolMintBatch", id, toAddresses, amounts) +} + +// PoolMintBatch is a paid mutator transaction binding the contract method 0x21adca96. +// +// Solidity: function poolMintBatch(uint256 id, address[] toAddresses, uint256[] amounts) returns() +func (_Terminus *TerminusSession) PoolMintBatch(id *big.Int, toAddresses []common.Address, amounts []*big.Int) (*types.Transaction, error) { + return _Terminus.Contract.PoolMintBatch(&_Terminus.TransactOpts, id, toAddresses, amounts) +} + +// PoolMintBatch is a paid mutator transaction binding the contract method 0x21adca96. +// +// Solidity: function poolMintBatch(uint256 id, address[] toAddresses, uint256[] amounts) returns() +func (_Terminus *TerminusTransactorSession) PoolMintBatch(id *big.Int, toAddresses []common.Address, amounts []*big.Int) (*types.Transaction, error) { + return _Terminus.Contract.PoolMintBatch(&_Terminus.TransactOpts, id, toAddresses, amounts) +} + +// SafeBatchTransferFrom is a paid mutator transaction binding the contract method 0x2eb2c2d6. +// +// Solidity: function safeBatchTransferFrom(address from, address to, uint256[] ids, uint256[] amounts, bytes data) returns() +func (_Terminus *TerminusTransactor) SafeBatchTransferFrom(opts *bind.TransactOpts, from common.Address, to common.Address, ids []*big.Int, amounts []*big.Int, data []byte) (*types.Transaction, error) { + return _Terminus.contract.Transact(opts, "safeBatchTransferFrom", from, to, ids, amounts, data) +} + +// SafeBatchTransferFrom is a paid mutator transaction binding the contract method 0x2eb2c2d6. +// +// Solidity: function safeBatchTransferFrom(address from, address to, uint256[] ids, uint256[] amounts, bytes data) returns() +func (_Terminus *TerminusSession) SafeBatchTransferFrom(from common.Address, to common.Address, ids []*big.Int, amounts []*big.Int, data []byte) (*types.Transaction, error) { + return _Terminus.Contract.SafeBatchTransferFrom(&_Terminus.TransactOpts, from, to, ids, amounts, data) +} + +// SafeBatchTransferFrom is a paid mutator transaction binding the contract method 0x2eb2c2d6. +// +// Solidity: function safeBatchTransferFrom(address from, address to, uint256[] ids, uint256[] amounts, bytes data) returns() +func (_Terminus *TerminusTransactorSession) SafeBatchTransferFrom(from common.Address, to common.Address, ids []*big.Int, amounts []*big.Int, data []byte) (*types.Transaction, error) { + return _Terminus.Contract.SafeBatchTransferFrom(&_Terminus.TransactOpts, from, to, ids, amounts, data) +} + +// SafeTransferFrom is a paid mutator transaction binding the contract method 0xf242432a. +// +// Solidity: function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes data) returns() +func (_Terminus *TerminusTransactor) SafeTransferFrom(opts *bind.TransactOpts, from common.Address, to common.Address, id *big.Int, amount *big.Int, data []byte) (*types.Transaction, error) { + return _Terminus.contract.Transact(opts, "safeTransferFrom", from, to, id, amount, data) +} + +// SafeTransferFrom is a paid mutator transaction binding the contract method 0xf242432a. +// +// Solidity: function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes data) returns() +func (_Terminus *TerminusSession) SafeTransferFrom(from common.Address, to common.Address, id *big.Int, amount *big.Int, data []byte) (*types.Transaction, error) { + return _Terminus.Contract.SafeTransferFrom(&_Terminus.TransactOpts, from, to, id, amount, data) +} + +// SafeTransferFrom is a paid mutator transaction binding the contract method 0xf242432a. +// +// Solidity: function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes data) returns() +func (_Terminus *TerminusTransactorSession) SafeTransferFrom(from common.Address, to common.Address, id *big.Int, amount *big.Int, data []byte) (*types.Transaction, error) { + return _Terminus.Contract.SafeTransferFrom(&_Terminus.TransactOpts, from, to, id, amount, data) +} + +// SetApprovalForAll is a paid mutator transaction binding the contract method 0xa22cb465. +// +// Solidity: function setApprovalForAll(address operator, bool approved) returns() +func (_Terminus *TerminusTransactor) SetApprovalForAll(opts *bind.TransactOpts, operator common.Address, approved bool) (*types.Transaction, error) { + return _Terminus.contract.Transact(opts, "setApprovalForAll", operator, approved) +} + +// SetApprovalForAll is a paid mutator transaction binding the contract method 0xa22cb465. +// +// Solidity: function setApprovalForAll(address operator, bool approved) returns() +func (_Terminus *TerminusSession) SetApprovalForAll(operator common.Address, approved bool) (*types.Transaction, error) { + return _Terminus.Contract.SetApprovalForAll(&_Terminus.TransactOpts, operator, approved) +} + +// SetApprovalForAll is a paid mutator transaction binding the contract method 0xa22cb465. +// +// Solidity: function setApprovalForAll(address operator, bool approved) returns() +func (_Terminus *TerminusTransactorSession) SetApprovalForAll(operator common.Address, approved bool) (*types.Transaction, error) { + return _Terminus.Contract.SetApprovalForAll(&_Terminus.TransactOpts, operator, approved) +} + +// SetContractURI is a paid mutator transaction binding the contract method 0x938e3d7b. +// +// Solidity: function setContractURI(string _contractURI) returns() +func (_Terminus *TerminusTransactor) SetContractURI(opts *bind.TransactOpts, _contractURI string) (*types.Transaction, error) { + return _Terminus.contract.Transact(opts, "setContractURI", _contractURI) +} + +// SetContractURI is a paid mutator transaction binding the contract method 0x938e3d7b. +// +// Solidity: function setContractURI(string _contractURI) returns() +func (_Terminus *TerminusSession) SetContractURI(_contractURI string) (*types.Transaction, error) { + return _Terminus.Contract.SetContractURI(&_Terminus.TransactOpts, _contractURI) +} + +// SetContractURI is a paid mutator transaction binding the contract method 0x938e3d7b. +// +// Solidity: function setContractURI(string _contractURI) returns() +func (_Terminus *TerminusTransactorSession) SetContractURI(_contractURI string) (*types.Transaction, error) { + return _Terminus.Contract.SetContractURI(&_Terminus.TransactOpts, _contractURI) +} + +// SetPaymentToken is a paid mutator transaction binding the contract method 0x6a326ab1. +// +// Solidity: function setPaymentToken(address newPaymentToken) returns() +func (_Terminus *TerminusTransactor) SetPaymentToken(opts *bind.TransactOpts, newPaymentToken common.Address) (*types.Transaction, error) { + return _Terminus.contract.Transact(opts, "setPaymentToken", newPaymentToken) +} + +// SetPaymentToken is a paid mutator transaction binding the contract method 0x6a326ab1. +// +// Solidity: function setPaymentToken(address newPaymentToken) returns() +func (_Terminus *TerminusSession) SetPaymentToken(newPaymentToken common.Address) (*types.Transaction, error) { + return _Terminus.Contract.SetPaymentToken(&_Terminus.TransactOpts, newPaymentToken) +} + +// SetPaymentToken is a paid mutator transaction binding the contract method 0x6a326ab1. +// +// Solidity: function setPaymentToken(address newPaymentToken) returns() +func (_Terminus *TerminusTransactorSession) SetPaymentToken(newPaymentToken common.Address) (*types.Transaction, error) { + return _Terminus.Contract.SetPaymentToken(&_Terminus.TransactOpts, newPaymentToken) +} + +// SetPoolBasePrice is a paid mutator transaction binding the contract method 0x78cf2e84. +// +// Solidity: function setPoolBasePrice(uint256 newBasePrice) returns() +func (_Terminus *TerminusTransactor) SetPoolBasePrice(opts *bind.TransactOpts, newBasePrice *big.Int) (*types.Transaction, error) { + return _Terminus.contract.Transact(opts, "setPoolBasePrice", newBasePrice) +} + +// SetPoolBasePrice is a paid mutator transaction binding the contract method 0x78cf2e84. +// +// Solidity: function setPoolBasePrice(uint256 newBasePrice) returns() +func (_Terminus *TerminusSession) SetPoolBasePrice(newBasePrice *big.Int) (*types.Transaction, error) { + return _Terminus.Contract.SetPoolBasePrice(&_Terminus.TransactOpts, newBasePrice) +} + +// SetPoolBasePrice is a paid mutator transaction binding the contract method 0x78cf2e84. +// +// Solidity: function setPoolBasePrice(uint256 newBasePrice) returns() +func (_Terminus *TerminusTransactorSession) SetPoolBasePrice(newBasePrice *big.Int) (*types.Transaction, error) { + return _Terminus.Contract.SetPoolBasePrice(&_Terminus.TransactOpts, newBasePrice) +} + +// SetPoolController is a paid mutator transaction binding the contract method 0xdc55d0b2. +// +// Solidity: function setPoolController(uint256 poolID, address newController) returns() +func (_Terminus *TerminusTransactor) SetPoolController(opts *bind.TransactOpts, poolID *big.Int, newController common.Address) (*types.Transaction, error) { + return _Terminus.contract.Transact(opts, "setPoolController", poolID, newController) +} + +// SetPoolController is a paid mutator transaction binding the contract method 0xdc55d0b2. +// +// Solidity: function setPoolController(uint256 poolID, address newController) returns() +func (_Terminus *TerminusSession) SetPoolController(poolID *big.Int, newController common.Address) (*types.Transaction, error) { + return _Terminus.Contract.SetPoolController(&_Terminus.TransactOpts, poolID, newController) +} + +// SetPoolController is a paid mutator transaction binding the contract method 0xdc55d0b2. +// +// Solidity: function setPoolController(uint256 poolID, address newController) returns() +func (_Terminus *TerminusTransactorSession) SetPoolController(poolID *big.Int, newController common.Address) (*types.Transaction, error) { + return _Terminus.Contract.SetPoolController(&_Terminus.TransactOpts, poolID, newController) +} + +// SetURI is a paid mutator transaction binding the contract method 0x862440e2. +// +// Solidity: function setURI(uint256 poolID, string poolURI) returns() +func (_Terminus *TerminusTransactor) SetURI(opts *bind.TransactOpts, poolID *big.Int, poolURI string) (*types.Transaction, error) { + return _Terminus.contract.Transact(opts, "setURI", poolID, poolURI) +} + +// SetURI is a paid mutator transaction binding the contract method 0x862440e2. +// +// Solidity: function setURI(uint256 poolID, string poolURI) returns() +func (_Terminus *TerminusSession) SetURI(poolID *big.Int, poolURI string) (*types.Transaction, error) { + return _Terminus.Contract.SetURI(&_Terminus.TransactOpts, poolID, poolURI) +} + +// SetURI is a paid mutator transaction binding the contract method 0x862440e2. +// +// Solidity: function setURI(uint256 poolID, string poolURI) returns() +func (_Terminus *TerminusTransactorSession) SetURI(poolID *big.Int, poolURI string) (*types.Transaction, error) { + return _Terminus.Contract.SetURI(&_Terminus.TransactOpts, poolID, poolURI) +} + +// WithdrawPayments is a paid mutator transaction binding the contract method 0x0e7afec5. +// +// Solidity: function withdrawPayments(address toAddress, uint256 amount) returns() +func (_Terminus *TerminusTransactor) WithdrawPayments(opts *bind.TransactOpts, toAddress common.Address, amount *big.Int) (*types.Transaction, error) { + return _Terminus.contract.Transact(opts, "withdrawPayments", toAddress, amount) +} + +// WithdrawPayments is a paid mutator transaction binding the contract method 0x0e7afec5. +// +// Solidity: function withdrawPayments(address toAddress, uint256 amount) returns() +func (_Terminus *TerminusSession) WithdrawPayments(toAddress common.Address, amount *big.Int) (*types.Transaction, error) { + return _Terminus.Contract.WithdrawPayments(&_Terminus.TransactOpts, toAddress, amount) +} + +// WithdrawPayments is a paid mutator transaction binding the contract method 0x0e7afec5. +// +// Solidity: function withdrawPayments(address toAddress, uint256 amount) returns() +func (_Terminus *TerminusTransactorSession) WithdrawPayments(toAddress common.Address, amount *big.Int) (*types.Transaction, error) { + return _Terminus.Contract.WithdrawPayments(&_Terminus.TransactOpts, toAddress, amount) +} + +// TerminusApprovalForAllIterator is returned from FilterApprovalForAll and is used to iterate over the raw logs and unpacked data for ApprovalForAll events raised by the Terminus contract. +type TerminusApprovalForAllIterator struct { + Event *TerminusApprovalForAll // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *TerminusApprovalForAllIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(TerminusApprovalForAll) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(TerminusApprovalForAll) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *TerminusApprovalForAllIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *TerminusApprovalForAllIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// TerminusApprovalForAll represents a ApprovalForAll event raised by the Terminus contract. +type TerminusApprovalForAll struct { + Account common.Address + Operator common.Address + Approved bool + Raw types.Log // Blockchain specific contextual infos +} + +// FilterApprovalForAll is a free log retrieval operation binding the contract event 0x17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31. +// +// Solidity: event ApprovalForAll(address indexed account, address indexed operator, bool approved) +func (_Terminus *TerminusFilterer) FilterApprovalForAll(opts *bind.FilterOpts, account []common.Address, operator []common.Address) (*TerminusApprovalForAllIterator, error) { + + var accountRule []interface{} + for _, accountItem := range account { + accountRule = append(accountRule, accountItem) + } + var operatorRule []interface{} + for _, operatorItem := range operator { + operatorRule = append(operatorRule, operatorItem) + } + + logs, sub, err := _Terminus.contract.FilterLogs(opts, "ApprovalForAll", accountRule, operatorRule) + if err != nil { + return nil, err + } + return &TerminusApprovalForAllIterator{contract: _Terminus.contract, event: "ApprovalForAll", logs: logs, sub: sub}, nil +} + +// WatchApprovalForAll is a free log subscription operation binding the contract event 0x17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31. +// +// Solidity: event ApprovalForAll(address indexed account, address indexed operator, bool approved) +func (_Terminus *TerminusFilterer) WatchApprovalForAll(opts *bind.WatchOpts, sink chan<- *TerminusApprovalForAll, account []common.Address, operator []common.Address) (event.Subscription, error) { + + var accountRule []interface{} + for _, accountItem := range account { + accountRule = append(accountRule, accountItem) + } + var operatorRule []interface{} + for _, operatorItem := range operator { + operatorRule = append(operatorRule, operatorItem) + } + + logs, sub, err := _Terminus.contract.WatchLogs(opts, "ApprovalForAll", accountRule, operatorRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(TerminusApprovalForAll) + if err := _Terminus.contract.UnpackLog(event, "ApprovalForAll", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseApprovalForAll is a log parse operation binding the contract event 0x17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31. +// +// Solidity: event ApprovalForAll(address indexed account, address indexed operator, bool approved) +func (_Terminus *TerminusFilterer) ParseApprovalForAll(log types.Log) (*TerminusApprovalForAll, error) { + event := new(TerminusApprovalForAll) + if err := _Terminus.contract.UnpackLog(event, "ApprovalForAll", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// TerminusPoolMintBatchIterator is returned from FilterPoolMintBatch and is used to iterate over the raw logs and unpacked data for PoolMintBatch events raised by the Terminus contract. +type TerminusPoolMintBatchIterator struct { + Event *TerminusPoolMintBatch // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *TerminusPoolMintBatchIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(TerminusPoolMintBatch) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(TerminusPoolMintBatch) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *TerminusPoolMintBatchIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *TerminusPoolMintBatchIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// TerminusPoolMintBatch represents a PoolMintBatch event raised by the Terminus contract. +type TerminusPoolMintBatch struct { + Id *big.Int + Operator common.Address + From common.Address + ToAddresses []common.Address + Amounts []*big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterPoolMintBatch is a free log retrieval operation binding the contract event 0xba62777935b5e992de16a785941daef9f13517ff268a40563288072025b50238. +// +// Solidity: event PoolMintBatch(uint256 indexed id, address indexed operator, address from, address[] toAddresses, uint256[] amounts) +func (_Terminus *TerminusFilterer) FilterPoolMintBatch(opts *bind.FilterOpts, id []*big.Int, operator []common.Address) (*TerminusPoolMintBatchIterator, error) { + + var idRule []interface{} + for _, idItem := range id { + idRule = append(idRule, idItem) + } + var operatorRule []interface{} + for _, operatorItem := range operator { + operatorRule = append(operatorRule, operatorItem) + } + + logs, sub, err := _Terminus.contract.FilterLogs(opts, "PoolMintBatch", idRule, operatorRule) + if err != nil { + return nil, err + } + return &TerminusPoolMintBatchIterator{contract: _Terminus.contract, event: "PoolMintBatch", logs: logs, sub: sub}, nil +} + +// WatchPoolMintBatch is a free log subscription operation binding the contract event 0xba62777935b5e992de16a785941daef9f13517ff268a40563288072025b50238. +// +// Solidity: event PoolMintBatch(uint256 indexed id, address indexed operator, address from, address[] toAddresses, uint256[] amounts) +func (_Terminus *TerminusFilterer) WatchPoolMintBatch(opts *bind.WatchOpts, sink chan<- *TerminusPoolMintBatch, id []*big.Int, operator []common.Address) (event.Subscription, error) { + + var idRule []interface{} + for _, idItem := range id { + idRule = append(idRule, idItem) + } + var operatorRule []interface{} + for _, operatorItem := range operator { + operatorRule = append(operatorRule, operatorItem) + } + + logs, sub, err := _Terminus.contract.WatchLogs(opts, "PoolMintBatch", idRule, operatorRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(TerminusPoolMintBatch) + if err := _Terminus.contract.UnpackLog(event, "PoolMintBatch", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParsePoolMintBatch is a log parse operation binding the contract event 0xba62777935b5e992de16a785941daef9f13517ff268a40563288072025b50238. +// +// Solidity: event PoolMintBatch(uint256 indexed id, address indexed operator, address from, address[] toAddresses, uint256[] amounts) +func (_Terminus *TerminusFilterer) ParsePoolMintBatch(log types.Log) (*TerminusPoolMintBatch, error) { + event := new(TerminusPoolMintBatch) + if err := _Terminus.contract.UnpackLog(event, "PoolMintBatch", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// TerminusTransferBatchIterator is returned from FilterTransferBatch and is used to iterate over the raw logs and unpacked data for TransferBatch events raised by the Terminus contract. +type TerminusTransferBatchIterator struct { + Event *TerminusTransferBatch // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *TerminusTransferBatchIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(TerminusTransferBatch) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(TerminusTransferBatch) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *TerminusTransferBatchIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *TerminusTransferBatchIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// TerminusTransferBatch represents a TransferBatch event raised by the Terminus contract. +type TerminusTransferBatch struct { + Operator common.Address + From common.Address + To common.Address + Ids []*big.Int + Values []*big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterTransferBatch is a free log retrieval operation binding the contract event 0x4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb. +// +// Solidity: event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values) +func (_Terminus *TerminusFilterer) FilterTransferBatch(opts *bind.FilterOpts, operator []common.Address, from []common.Address, to []common.Address) (*TerminusTransferBatchIterator, error) { + + var operatorRule []interface{} + for _, operatorItem := range operator { + operatorRule = append(operatorRule, operatorItem) + } + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _Terminus.contract.FilterLogs(opts, "TransferBatch", operatorRule, fromRule, toRule) + if err != nil { + return nil, err + } + return &TerminusTransferBatchIterator{contract: _Terminus.contract, event: "TransferBatch", logs: logs, sub: sub}, nil +} + +// WatchTransferBatch is a free log subscription operation binding the contract event 0x4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb. +// +// Solidity: event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values) +func (_Terminus *TerminusFilterer) WatchTransferBatch(opts *bind.WatchOpts, sink chan<- *TerminusTransferBatch, operator []common.Address, from []common.Address, to []common.Address) (event.Subscription, error) { + + var operatorRule []interface{} + for _, operatorItem := range operator { + operatorRule = append(operatorRule, operatorItem) + } + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _Terminus.contract.WatchLogs(opts, "TransferBatch", operatorRule, fromRule, toRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(TerminusTransferBatch) + if err := _Terminus.contract.UnpackLog(event, "TransferBatch", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseTransferBatch is a log parse operation binding the contract event 0x4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb. +// +// Solidity: event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values) +func (_Terminus *TerminusFilterer) ParseTransferBatch(log types.Log) (*TerminusTransferBatch, error) { + event := new(TerminusTransferBatch) + if err := _Terminus.contract.UnpackLog(event, "TransferBatch", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// TerminusTransferSingleIterator is returned from FilterTransferSingle and is used to iterate over the raw logs and unpacked data for TransferSingle events raised by the Terminus contract. +type TerminusTransferSingleIterator struct { + Event *TerminusTransferSingle // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *TerminusTransferSingleIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(TerminusTransferSingle) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(TerminusTransferSingle) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *TerminusTransferSingleIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *TerminusTransferSingleIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// TerminusTransferSingle represents a TransferSingle event raised by the Terminus contract. +type TerminusTransferSingle struct { + Operator common.Address + From common.Address + To common.Address + Id *big.Int + Value *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterTransferSingle is a free log retrieval operation binding the contract event 0xc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62. +// +// Solidity: event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value) +func (_Terminus *TerminusFilterer) FilterTransferSingle(opts *bind.FilterOpts, operator []common.Address, from []common.Address, to []common.Address) (*TerminusTransferSingleIterator, error) { + + var operatorRule []interface{} + for _, operatorItem := range operator { + operatorRule = append(operatorRule, operatorItem) + } + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _Terminus.contract.FilterLogs(opts, "TransferSingle", operatorRule, fromRule, toRule) + if err != nil { + return nil, err + } + return &TerminusTransferSingleIterator{contract: _Terminus.contract, event: "TransferSingle", logs: logs, sub: sub}, nil +} + +// WatchTransferSingle is a free log subscription operation binding the contract event 0xc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62. +// +// Solidity: event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value) +func (_Terminus *TerminusFilterer) WatchTransferSingle(opts *bind.WatchOpts, sink chan<- *TerminusTransferSingle, operator []common.Address, from []common.Address, to []common.Address) (event.Subscription, error) { + + var operatorRule []interface{} + for _, operatorItem := range operator { + operatorRule = append(operatorRule, operatorItem) + } + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _Terminus.contract.WatchLogs(opts, "TransferSingle", operatorRule, fromRule, toRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(TerminusTransferSingle) + if err := _Terminus.contract.UnpackLog(event, "TransferSingle", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseTransferSingle is a log parse operation binding the contract event 0xc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62. +// +// Solidity: event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value) +func (_Terminus *TerminusFilterer) ParseTransferSingle(log types.Log) (*TerminusTransferSingle, error) { + event := new(TerminusTransferSingle) + if err := _Terminus.contract.UnpackLog(event, "TransferSingle", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// TerminusURIIterator is returned from FilterURI and is used to iterate over the raw logs and unpacked data for URI events raised by the Terminus contract. +type TerminusURIIterator struct { + Event *TerminusURI // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *TerminusURIIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(TerminusURI) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(TerminusURI) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *TerminusURIIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *TerminusURIIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// TerminusURI represents a URI event raised by the Terminus contract. +type TerminusURI struct { + Value string + Id *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterURI is a free log retrieval operation binding the contract event 0x6bb7ff708619ba0610cba295a58592e0451dee2622938c8755667688daf3529b. +// +// Solidity: event URI(string value, uint256 indexed id) +func (_Terminus *TerminusFilterer) FilterURI(opts *bind.FilterOpts, id []*big.Int) (*TerminusURIIterator, error) { + + var idRule []interface{} + for _, idItem := range id { + idRule = append(idRule, idItem) + } + + logs, sub, err := _Terminus.contract.FilterLogs(opts, "URI", idRule) + if err != nil { + return nil, err + } + return &TerminusURIIterator{contract: _Terminus.contract, event: "URI", logs: logs, sub: sub}, nil +} + +// WatchURI is a free log subscription operation binding the contract event 0x6bb7ff708619ba0610cba295a58592e0451dee2622938c8755667688daf3529b. +// +// Solidity: event URI(string value, uint256 indexed id) +func (_Terminus *TerminusFilterer) WatchURI(opts *bind.WatchOpts, sink chan<- *TerminusURI, id []*big.Int) (event.Subscription, error) { + + var idRule []interface{} + for _, idItem := range id { + idRule = append(idRule, idItem) + } + + logs, sub, err := _Terminus.contract.WatchLogs(opts, "URI", idRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(TerminusURI) + if err := _Terminus.contract.UnpackLog(event, "URI", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseURI is a log parse operation binding the contract event 0x6bb7ff708619ba0610cba295a58592e0451dee2622938c8755667688daf3529b. +// +// Solidity: event URI(string value, uint256 indexed id) +func (_Terminus *TerminusFilterer) ParseURI(log types.Log) (*TerminusURI, error) { + event := new(TerminusURI) + if err := _Terminus.contract.UnpackLog(event, "URI", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/robots/sample.env b/robots/sample.env new file mode 100644 index 00000000..603a3fa9 --- /dev/null +++ b/robots/sample.env @@ -0,0 +1,11 @@ +export MOONSTREAM_ENTITY_URL="https://api.moonstream.to/entity" +export MOONSTREAM_POLYGON_WEB3_PROVIDER_URI="" +export MOONSTREAM_MUMBAI_WEB3_PROVIDER_URI="" +export MOONSTREAM_WYRM_WEB3_PROVIDER_URI="" +export ENGINE_NODEBALANCER_ACCESS_ID="" +export ENGINE_ROBOTS_SECRETS_DIR="" +export HUMBUG_REPORTER_ROBOTS_HEARTBEAT_TOKEN="" + +export MOONSTREAM_TERMINUS_DIAMOND_CONTRACT_POLYGON_ADDRESS="" +export MOONSTREAM_TERMINUS_DIAMOND_CONTRACT_MUMBAI_ADDRESS="" +export MOONSTREAM_TERMINUS_DIAMOND_CONTRACT_WYRM_ADDRESS="" From 820adb4ce3de4355d4ad2ae28ea0f00614a2f64f Mon Sep 17 00:00:00 2001 From: kompotkot Date: Tue, 6 Jun 2023 12:29:29 +0000 Subject: [PATCH 2/2] Robots deployment from api repo --- robots/deploy/deploy.bash | 2 +- robots/deploy/robots-airdrop.service | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/robots/deploy/deploy.bash b/robots/deploy/deploy.bash index 83d24f31..87b95611 100755 --- a/robots/deploy/deploy.bash +++ b/robots/deploy/deploy.bash @@ -14,7 +14,7 @@ PREFIX_WARN="${C_YELLOW}[WARN]${C_RESET} [$(date +%d-%m\ %T)]" PREFIX_CRIT="${C_RED}[CRIT]${C_RESET} [$(date +%d-%m\ %T)]" # Main -APP_DIR="${APP_DIR:-/home/ubuntu/engine/robots}" +APP_DIR="${APP_DIR:-/home/ubuntu/api/robots}" AWS_DEFAULT_REGION="${AWS_DEFAULT_REGION:-us-east-1}" SCRIPT_DIR="$(realpath $(dirname $0))" SECRETS_DIR="${SECRETS_DIR:-/home/ubuntu/robots-secrets}" diff --git a/robots/deploy/robots-airdrop.service b/robots/deploy/robots-airdrop.service index 8cc16459..409dfa04 100644 --- a/robots/deploy/robots-airdrop.service +++ b/robots/deploy/robots-airdrop.service @@ -1,15 +1,15 @@ [Unit] -Description=Airdrop Engine robots +Description=Airdrop robots After=network.target StartLimitIntervalSec=300 StartLimitBurst=3 [Service] -WorkingDirectory=/home/ubuntu/engine/robots +WorkingDirectory=/home/ubuntu/api/robots EnvironmentFile=/home/ubuntu/robots-secrets/app.env Restart=on-failure RestartSec=15s -ExecStart=/home/ubuntu/engine/robots/robots airdrop +ExecStart=/home/ubuntu/api/robots/robots airdrop SyslogIdentifier=robots-airdrop [Install]