diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml new file mode 100644 index 00000000..c82ea837 --- /dev/null +++ b/.github/workflows/golangci-lint.yml @@ -0,0 +1,29 @@ +--- + +name: Go linters +"on": + push: + tags: + - v* + branches: + - main + pull_request: +permissions: + contents: read + # Optional: allow read access to pull request. Use with `only-new-issues` option. + # pull-requests: read +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: '1.21.5' + - uses: actions/checkout@v4 + - name: golangci-lint + uses: golangci/golangci-lint-action@v3.7.0 + with: + version: v1.55.2 + args: --config .golangci.toml diff --git a/.golangci.toml b/.golangci.toml new file mode 100644 index 00000000..c704ade9 --- /dev/null +++ b/.golangci.toml @@ -0,0 +1,42 @@ +[run] +allow-parallel-runners = true +print-linter-name = true +timeout = '15m0s' + +[issues] +max-issues-per-linter = 0 +max-same-issues = 0 + +[linters] +disable-all = true +enable = [ + "exhaustive", + "gofumpt", + "govet", + "gci", + "ineffassign", + "staticcheck", + "unconvert", + "unparam", + "unused", + "wastedassign", + "whitespace", +] + +[linters-settings.gci] +custom-order = true +sections = [ + "standard", # Standard section: captures all standard packages. + "prefix(github.com/vegaprotocol/devopstools)", # Custom section: groups all imports with the specified Prefix. + "prefix(code.vegaprotocol.io/vega)", # Custom section: groups all imports with the specified Prefix. + "default", # Default section: contains all imports that could not be matched to another section type. + "blank", # Blank section: contains all blank imports. This section is not present unless explicitly enabled. + "dot", +] + +# protoc doesn't want us copying protobuf messages because they can have some internal state +# that shouldn't be copied; but we do it a lot. see below for details +# https://stackoverflow.com/questions/64183794/why-do-the-go-generated-protobuf-files-contain-mutex-locks +[[issues.exclude-rules]] +linters = ["govet"] +text = "impl.MessageState contains sync.Mutex" diff --git a/README.md b/README.md index a0184c43..208d6f33 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ We want to minimise usage of `bash` and replace it with `Golang`. We assume that: - we have `Go` installed on every machine -- we run our scripts `go run main.go ...` fashion, ineased of: `tag version`->`complie`->`publish`->`download`->`run` +- we run our scripts `go run main.go ...` fashion, instead of: `tag version`->`complie`->`publish`->`download`->`run` - we use `cobra` to manage all CLI aspects ### Usual use-case diff --git a/backup/config.go b/backup/config.go index 930e0977..c924e673 100644 --- a/backup/config.go +++ b/backup/config.go @@ -6,8 +6,9 @@ import ( "os/exec" "time" - "github.com/pelletier/go-toml" "github.com/vegaprotocol/devopstools/tools" + + "github.com/pelletier/go-toml" ) type S3Config struct { @@ -76,7 +77,6 @@ func LoadConfig(filePath string) (*Config, error) { func (conf Config) Marshal() (string, error) { str, err := toml.Marshal(conf) - if err != nil { return "", fmt.Errorf("failed to marshal config: %w", err) } diff --git a/cmd/args.go b/cmd/args.go index 34d99b9a..b7c4e5ef 100644 --- a/cmd/args.go +++ b/cmd/args.go @@ -8,6 +8,7 @@ import ( "github.com/vegaprotocol/devopstools/secrets/hcvault" "github.com/vegaprotocol/devopstools/smartcontracts" "github.com/vegaprotocol/devopstools/wallet" + "go.uber.org/zap" ) @@ -37,7 +38,6 @@ func (ra *RootArgs) getHCVaultSecretStore() (*hcvault.HCVaultSecretStore, error) } } return ra.hcVaultSecretStore, nil - } func (ra *RootArgs) GetNodeSecretStore() (secrets.NodeSecretStore, error) { diff --git a/cmd/backup/create.go b/cmd/backup/create.go index 087bb014..0bb75620 100644 --- a/cmd/backup/create.go +++ b/cmd/backup/create.go @@ -9,11 +9,11 @@ import ( "strings" "time" - "github.com/spf13/cobra" - "go.uber.org/zap" - "github.com/vegaprotocol/devopstools/backup" "github.com/vegaprotocol/devopstools/tools" + + "github.com/spf13/cobra" + "go.uber.org/zap" ) type CreateArgs struct { diff --git a/cmd/backup/print_config.go b/cmd/backup/print_config.go index 8273c11f..b25153af 100644 --- a/cmd/backup/print_config.go +++ b/cmd/backup/print_config.go @@ -3,8 +3,9 @@ package backup import ( "fmt" - "github.com/spf13/cobra" "github.com/vegaprotocol/devopstools/backup" + + "github.com/spf13/cobra" "go.uber.org/zap" ) @@ -21,7 +22,6 @@ var printConfigCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { conf := backup.DefaultConfig() confStr, err := conf.Marshal() - if err != nil { printConfigArgs.Logger.Fatal("failed to marshal config", zap.Error(err)) } diff --git a/cmd/backup/root.go b/cmd/backup/root.go index e81a8866..ec05b576 100644 --- a/cmd/backup/root.go +++ b/cmd/backup/root.go @@ -1,8 +1,9 @@ package backup import ( - "github.com/spf13/cobra" rootCmd "github.com/vegaprotocol/devopstools/cmd" + + "github.com/spf13/cobra" ) type BackupArgs struct { diff --git a/cmd/batch/root.go b/cmd/batch/root.go index c461e790..a4841a6d 100644 --- a/cmd/batch/root.go +++ b/cmd/batch/root.go @@ -5,11 +5,13 @@ import ( "log" "time" - walletpb "code.vegaprotocol.io/vega/protos/vega/wallet/v1" - "github.com/spf13/cobra" rootCmd "github.com/vegaprotocol/devopstools/cmd" "github.com/vegaprotocol/devopstools/governance" "github.com/vegaprotocol/devopstools/tools" + + walletpb "code.vegaprotocol.io/vega/protos/vega/wallet/v1" + + "github.com/spf13/cobra" ) type BatchArgs struct { diff --git a/cmd/benchmark/eth-rpc.go b/cmd/benchmark/eth-rpc.go index 2a2bc3a7..4bbf9f49 100644 --- a/cmd/benchmark/eth-rpc.go +++ b/cmd/benchmark/eth-rpc.go @@ -132,7 +132,7 @@ func SubscribeToEvents(endpoints []RPCEndpoint) { evtNoPerBlock := make(map[uint64]int) for _, vLog := range logs { evtNoPerBlock[vLog.BlockNumber] += 1 - //fmt.Printf("%s: %s: %s\n", time.Now().Format(time.RFC850), endpoint.URL, vLog.TxHash) + // fmt.Printf("%s: %s: %s\n", time.Now().Format(time.RFC850), endpoint.URL, vLog.TxHash) } sortedBlocks := make([]uint64, 0, len(evtNoPerBlock)) diff --git a/cmd/benchmark/root.go b/cmd/benchmark/root.go index 3d02b4a8..5bcdc7d8 100644 --- a/cmd/benchmark/root.go +++ b/cmd/benchmark/root.go @@ -1,8 +1,9 @@ package benchmark import ( - "github.com/spf13/cobra" rootCmd "github.com/vegaprotocol/devopstools/cmd" + + "github.com/spf13/cobra" ) type BenchmarkArgs struct { diff --git a/cmd/bot/get.go b/cmd/bot/get.go index bf911017..eb3e12f0 100644 --- a/cmd/bot/get.go +++ b/cmd/bot/get.go @@ -5,8 +5,9 @@ import ( "fmt" "os" - "github.com/spf13/cobra" "github.com/vegaprotocol/devopstools/bots" + + "github.com/spf13/cobra" "go.uber.org/zap" ) diff --git a/cmd/bot/referral.go b/cmd/bot/referral.go index 61698e04..dc37d1c5 100644 --- a/cmd/bot/referral.go +++ b/cmd/bot/referral.go @@ -9,13 +9,6 @@ import ( "strings" "time" - "golang.org/x/exp/slices" - - commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" - walletpb "code.vegaprotocol.io/vega/protos/vega/wallet/v1" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - ethtypes "github.com/ethereum/go-ethereum/core/types" - "github.com/spf13/cobra" "github.com/vegaprotocol/devopstools/bots" "github.com/vegaprotocol/devopstools/ethutils" "github.com/vegaprotocol/devopstools/generate" @@ -23,7 +16,15 @@ import ( "github.com/vegaprotocol/devopstools/vegaapi" "github.com/vegaprotocol/devopstools/veganetwork" "github.com/vegaprotocol/devopstools/wallet" + + commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" + walletpb "code.vegaprotocol.io/vega/protos/vega/wallet/v1" + + "github.com/ethereum/go-ethereum/accounts/abi/bind" + ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/spf13/cobra" "go.uber.org/zap" + "golang.org/x/exp/slices" ) const waitTimeout = 5 * time.Minute @@ -166,8 +167,8 @@ func runReferral(args ReferralArgs) error { logger.Info("Teams created") logger.Info("Waiting for referral set to be created") - if err := waitForReferralSets(logger, teams, network.DataNodeClient, !args.SetupBotsInReferralProgram, waitTimeout); err != nil { - return fmt.Errorf("failed to wait for referral sets: %w") + if err := waitForReferralSets(logger, teams, network.DataNodeClient, waitTimeout); err != nil { + return fmt.Errorf("failed to wait for referral sets: %w", err) } logger.Info("All referral sets are ready") @@ -180,13 +181,7 @@ func runReferral(args ReferralArgs) error { return nil } -func waitForReferralSets( - logger *zap.Logger, - teams []Team, - dataNodeClient vegaapi.DataNodeClient, - dryRun bool, - timeout time.Duration, -) error { +func waitForReferralSets(logger *zap.Logger, teams []Team, dataNodeClient vegaapi.DataNodeClient, timeout time.Duration) error { wantedTeamsLeaderPubKeys := make([]string, len(teams)) for _, team := range teams { wantedTeamsLeaderPubKeys = append(wantedTeamsLeaderPubKeys, team.Leader.Wallet.PublicKey) @@ -236,8 +231,6 @@ func waitForReferralSets( return fmt.Errorf("timeout exceeded") } } - - return nil } // prepareTeams should generate deterministic teams based on the response from the /traders endpoint @@ -389,7 +382,6 @@ func joinMemberTeams( dataNodeClient vegaapi.DataNodeClient, dryRun bool, ) error { - logger.Info("Join Referral Sets (teams)") referralSets, err := dataNodeClient.GetReferralSets() if err != nil { @@ -475,7 +467,7 @@ func stakeToTeamLeaders( for _, team := range teams { currentStake, err := dataNodeClient.GetPartyTotalStake(team.Leader.Wallet.PublicKey) if err != nil { - return fmt.Errorf("failed to create referral sets, failed to get stake for %: %w", team.Leader.Wallet.PublicKey, err) + return fmt.Errorf("failed to create referral sets, failed to get stake for %q: %w", team.Leader.Wallet.PublicKey, err) } if currentStake.Cmp(minStake) < 0 { // rand stake @@ -662,7 +654,6 @@ func doStake( } logger.Info("successfully increased allowance", zap.String("ethWallet", wallet.Address.Hex()), zap.String("tokenAddress", vegaToken.Address.Hex())) - } else { logger.Info("no need to increase allowance", zap.String("tokenAddress", vegaToken.Address.Hex()), zap.String("ethWallet", wallet.Address.Hex()), diff --git a/cmd/bot/root.go b/cmd/bot/root.go index 2aa5e405..ac7cd51d 100644 --- a/cmd/bot/root.go +++ b/cmd/bot/root.go @@ -3,8 +3,9 @@ package bot import ( "log" - "github.com/spf13/cobra" rootCmd "github.com/vegaprotocol/devopstools/cmd" + + "github.com/spf13/cobra" ) type BotArgs struct { diff --git a/cmd/erc20token/info.go b/cmd/erc20token/info.go deleted file mode 100644 index fcb0cf8e..00000000 --- a/cmd/erc20token/info.go +++ /dev/null @@ -1,54 +0,0 @@ -package erc20token - -import ( - "encoding/json" - "fmt" - "os" - - "github.com/spf13/cobra" - "go.uber.org/zap" -) - -type InfoArgs struct { - *ERC20tokenArgs - VegaNetworkName string - InfoId string -} - -var infoArgs InfoArgs - -// infoCmd represents the info command -var infoCmd = &cobra.Command{ - Use: "info", - Short: "Get information about token", - Long: `Get information about token`, - Run: func(cmd *cobra.Command, args []string) { - if err := RunInfo(infoArgs); err != nil { - infoArgs.Logger.Error("Error", zap.Error(err)) - os.Exit(1) - } - }, -} - -func init() { - infoArgs.ERC20tokenArgs = &erc20tokenArgs - - ERC20tokenCmd.AddCommand(infoCmd) -} - -func RunInfo(args InfoArgs) error { - token, err := args.GetToken() - if err != nil { - return err - } - info, err := token.GetInfo() - if err != nil { - return err - } - byteInfo, err := json.MarshalIndent(info, "", "\t") - if err != nil { - return fmt.Errorf("failed to parse stats for network '%s', %w", args.VegaNetworkName, err) - } - fmt.Println(string(byteInfo)) - return nil -} diff --git a/cmd/erc20token/root.go b/cmd/erc20token/root.go deleted file mode 100644 index c9400790..00000000 --- a/cmd/erc20token/root.go +++ /dev/null @@ -1,75 +0,0 @@ -package erc20token - -import ( - "fmt" - - "github.com/spf13/cobra" - rootCmd "github.com/vegaprotocol/devopstools/cmd" - "github.com/vegaprotocol/devopstools/smartcontracts" - "github.com/vegaprotocol/devopstools/smartcontracts/erc20token" - "github.com/vegaprotocol/devopstools/types" -) - -type ERC20tokenArgs struct { - *rootCmd.RootArgs - Address string - EthNetwork string - TokenVersion string - TokenName string - EthereumURL string -} - -var erc20tokenArgs ERC20tokenArgs - -// Root Command for OPS -var ERC20tokenCmd = &cobra.Command{ - Use: "erc20token", - Short: "General erc20token tasks", - Long: `General erc20token tasks`, -} - -func init() { - erc20tokenArgs.RootArgs = &rootCmd.Args - - ERC20tokenCmd.PersistentFlags().StringVar(&erc20tokenArgs.TokenName, "token", "", "Name of a token") - ERC20tokenCmd.PersistentFlags().StringVar(&erc20tokenArgs.Address, "address", "", "Token address") - ERC20tokenCmd.PersistentFlags().StringVar(&erc20tokenArgs.EthNetwork, "eth-network", "sepolia", "Used with address, specify which Ethereum Network to use") - ERC20tokenCmd.PersistentFlags().StringVar(&erc20tokenArgs.TokenVersion, "token-version", "TokenBase", "Used with address, specify version of a token, allowed values: TokenBase, TokenOther and TokenMinimal") - - ERC20tokenCmd.PersistentFlags().StringVar(&erc20tokenArgs.EthereumURL, "ethereum-url", "", "Optional URL to connect to ethereum network, e.g. infura") -} - -func (ra *ERC20tokenArgs) GetSmartContractsManager() (*smartcontracts.SmartContractsManager, error) { - if len(ra.EthereumURL) > 0 { - return smartcontracts.NewSmartContractsManagerWithEthURL(ra.EthereumURL), nil - } else { - return ra.RootArgs.GetSmartContractsManager() - } -} - -func (ra *ERC20tokenArgs) GetToken() (*erc20token.ERC20Token, error) { - smartContractManager, err := ra.GetSmartContractsManager() - if err != nil { - return nil, err - } - if len(ra.TokenName) > 0 { - return smartContractManager.GetAssetWithName(ra.TokenName) - } - if len(ra.Address) > 0 { - if len(ra.EthNetwork) == 0 { - return nil, fmt.Errorf("need to provide --eth-network when using --address") - } - ethNetwork := types.ETHNetwork(ra.EthNetwork) - if err = ethNetwork.IsValid(); err != nil { - return nil, fmt.Errorf("wrong eth network %s, %w", ra.EthNetwork, err) - } - tokenVersion := erc20token.ERC20TokenVersion(ra.TokenVersion) - if err = tokenVersion.IsValid(); err != nil { - return nil, fmt.Errorf("wrong token version %s, %w", ra.TokenVersion, err) - } - return smartContractManager.GetAsset( - ra.Address, ethNetwork, tokenVersion, - ) - } - return nil, fmt.Errorf("need to provide token or address") -} diff --git a/cmd/helper/stakespam.go b/cmd/helper/stakespam.go index 5d6a04e9..ea4b207d 100644 --- a/cmd/helper/stakespam.go +++ b/cmd/helper/stakespam.go @@ -8,16 +8,16 @@ import ( "math/big" "os" + "github.com/vegaprotocol/devopstools/smartcontracts/erc20bridge" + "github.com/vegaprotocol/devopstools/smartcontracts/erc20token" + "github.com/vegaprotocol/devopstools/smartcontracts/stakingbridge" + "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/crypto" "github.com/ethereum/go-ethereum/ethclient" "github.com/spf13/cobra" - - "github.com/vegaprotocol/devopstools/smartcontracts/erc20bridge" - "github.com/vegaprotocol/devopstools/smartcontracts/erc20token" - "github.com/vegaprotocol/devopstools/smartcontracts/stakingbridge" ) type StakeSpamArgs struct { @@ -98,7 +98,10 @@ func increaseAllowance(client *ethclient.Client, fromAddress common.Address, pri return fmt.Errorf("erc20 token instance is invalid") } - auth := bind.NewKeyedTransactor(privateKey) + auth, err := bind.NewKeyedTransactorWithChainID(privateKey, nil) + if err != nil { + return err + } auth.Nonce = big.NewInt(int64(nonce)) auth.Value = big.NewInt(0) // in wei auth.GasLimit = uint64(300000) // in units @@ -199,7 +202,6 @@ func executeSpam(client *ethclient.Client, collateralBridgeAddress string, stakingBridgeAddress string, ) error { - nonce, err := client.PendingNonceAt(context.Background(), fromAddress) if err != nil { return fmt.Errorf("failed to get pending nonce: %w", err) @@ -210,7 +212,10 @@ func executeSpam(client *ethclient.Client, return fmt.Errorf("failed to get suggested gas price: %w", err) } - auth := bind.NewKeyedTransactor(privateKey) + auth, err := bind.NewKeyedTransactorWithChainID(privateKey, nil) + if err != nil { + return err + } auth.Nonce = big.NewInt(int64(nonce)) auth.Value = big.NewInt(0) // in wei auth.GasLimit = uint64(300000) // in units diff --git a/cmd/incentive/network_params.go b/cmd/incentive/network_params.go index adb29d7b..a1375964 100644 --- a/cmd/incentive/network_params.go +++ b/cmd/incentive/network_params.go @@ -4,13 +4,13 @@ import ( "fmt" "os" - "golang.org/x/exp/slices" - - "github.com/spf13/cobra" "github.com/vegaprotocol/devopstools/governance" "github.com/vegaprotocol/devopstools/types" "github.com/vegaprotocol/devopstools/veganetwork" + + "github.com/spf13/cobra" "go.uber.org/zap" + "golang.org/x/exp/slices" ) type NetworkParamsArgs struct { @@ -105,7 +105,7 @@ func RunNetworkParams(args NetworkParamsArgs) error { } defer network.Disconnect() - toUpdate, err := checkNetworkParams(network) + toUpdate := checkNetworkParams(network) if err != nil { return err } @@ -122,7 +122,7 @@ func RunNetworkParams(args NetworkParamsArgs) error { return err } } - _, err = checkNetworkParams(network) + _ = checkNetworkParams(network) if err != nil { return err } @@ -131,7 +131,7 @@ func RunNetworkParams(args NetworkParamsArgs) error { return nil } -func checkNetworkParams(network *veganetwork.VegaNetwork) (map[string]string, error) { +func checkNetworkParams(network *veganetwork.VegaNetwork) map[string]string { yellowText := "\033[1;33m%s\033[0m" greenText := "\033[1;32m%s\033[0m" redText := "\033[1;31m%s\033[0m" @@ -152,5 +152,5 @@ func checkNetworkParams(network *veganetwork.VegaNetwork) (map[string]string, er } } - return toUpdate, nil + return toUpdate } diff --git a/cmd/incentive/root.go b/cmd/incentive/root.go index d5fd0b2a..f0dbc9f8 100644 --- a/cmd/incentive/root.go +++ b/cmd/incentive/root.go @@ -3,8 +3,9 @@ package incentive import ( "log" - "github.com/spf13/cobra" rootCmd "github.com/vegaprotocol/devopstools/cmd" + + "github.com/spf13/cobra" ) type IncentiveArgs struct { diff --git a/cmd/live/nodename.go b/cmd/live/nodename.go index 34edae94..03d4de98 100644 --- a/cmd/live/nodename.go +++ b/cmd/live/nodename.go @@ -1,16 +1,16 @@ package live import ( + "crypto/rand" "fmt" "math/big" "os" "sort" "strings" - "crypto/rand" + "github.com/vegaprotocol/devopstools/networktools" "github.com/spf13/cobra" - "github.com/vegaprotocol/devopstools/networktools" "go.uber.org/zap" ) diff --git a/cmd/live/root.go b/cmd/live/root.go index 0c6a6e07..cff7ec23 100644 --- a/cmd/live/root.go +++ b/cmd/live/root.go @@ -3,8 +3,9 @@ package live import ( "log" - "github.com/spf13/cobra" rootCmd "github.com/vegaprotocol/devopstools/cmd" + + "github.com/spf13/cobra" ) type LiveArgs struct { diff --git a/cmd/live/statistics.go b/cmd/live/statistics.go index 6dacd448..ba0749a0 100644 --- a/cmd/live/statistics.go +++ b/cmd/live/statistics.go @@ -5,8 +5,9 @@ import ( "fmt" "os" - "github.com/spf13/cobra" "github.com/vegaprotocol/devopstools/networktools" + + "github.com/spf13/cobra" "go.uber.org/zap" ) @@ -53,7 +54,6 @@ func RunStatistics(args StatisticsArgs) error { return fmt.Errorf("failed to parse statistics for network '%s', %w", args.VegaNetworkName, err) } fmt.Println(string(byteStatistics)) - } else { statistics, err := network.GetRunningStatistics() if err != nil { diff --git a/cmd/market/config.go b/cmd/market/config.go index bacb5b75..c07914a0 100644 --- a/cmd/market/config.go +++ b/cmd/market/config.go @@ -1,10 +1,11 @@ package market import ( - "code.vegaprotocol.io/vega/protos/vega" - commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" "github.com/vegaprotocol/devopstools/governance/market" "github.com/vegaprotocol/devopstools/types" + + "code.vegaprotocol.io/vega/protos/vega" + commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" ) // The CoinBase Oracle data diff --git a/cmd/market/propose.go b/cmd/market/propose.go index afaa6339..b4b51a53 100644 --- a/cmd/market/propose.go +++ b/cmd/market/propose.go @@ -6,17 +6,18 @@ import ( "os" "time" + "github.com/vegaprotocol/devopstools/governance" + "github.com/vegaprotocol/devopstools/governance/networkparameters" + "github.com/vegaprotocol/devopstools/tools" + "github.com/vegaprotocol/devopstools/types" + "github.com/vegaprotocol/devopstools/veganetwork" + "code.vegaprotocol.io/vega/core/netparams" "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" walletpb "code.vegaprotocol.io/vega/protos/vega/wallet/v1" "github.com/spf13/cobra" - "github.com/vegaprotocol/devopstools/governance" - "github.com/vegaprotocol/devopstools/governance/networkparameters" - "github.com/vegaprotocol/devopstools/tools" - "github.com/vegaprotocol/devopstools/types" - "github.com/vegaprotocol/devopstools/veganetwork" "go.uber.org/zap" ) @@ -178,7 +179,6 @@ func preMarketDeployProposals(environment string, currentNetworkParams *types.Ne if err != nil { return nil, fmt.Errorf("failed to append ethereum sepolia config to the l2 config: %w", err) } - } if len(l2Configs[environment]) > 0 { diff --git a/cmd/market/providelp.go b/cmd/market/providelp.go deleted file mode 100644 index 43b06b4a..00000000 --- a/cmd/market/providelp.go +++ /dev/null @@ -1,149 +0,0 @@ -package market - -import ( - "fmt" - "math/big" - "os" - "time" - - vegaapipb "code.vegaprotocol.io/vega/protos/vega/api/v1" - commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" - walletpb "code.vegaprotocol.io/vega/protos/vega/wallet/v1" - "github.com/spf13/cobra" - "github.com/vegaprotocol/devopstools/cmd/topup" - "github.com/vegaprotocol/devopstools/governance" - "github.com/vegaprotocol/devopstools/networktools" - "github.com/vegaprotocol/devopstools/vegaapi" - "github.com/vegaprotocol/devopstools/wallet" - "go.uber.org/zap" -) - -type ProvideLPArgs struct { - *MarketArgs -} - -var provideLPArgs ProvideLPArgs - -// provideLPCmd represents the provideLP command -var provideLPCmd = &cobra.Command{ - Use: "provide-lp", - Short: "Provide Liquidity Provision", - Long: `Provide Liquidity Provision`, - Run: func(cmd *cobra.Command, args []string) { - if err := RunProvideLP(provideLPArgs); err != nil { - provideLPArgs.Logger.Error("Error", zap.Error(err)) - os.Exit(1) - } - }, -} - -func init() { - provideLPArgs.MarketArgs = &marketArgs - - MarketCmd.AddCommand(provideLPCmd) -} - -func RunProvideLP(args ProvideLPArgs) error { - var ( - logger = args.Logger - ) - network, err := args.ConnectToVegaNetwork(args.VegaNetworkName) - if err != nil { - return err - } - defer network.Disconnect() - tools, err := networktools.NewNetworkTools(args.VegaNetworkName, args.Logger) - if err != nil { - return err - } - - proposerVegawallet := network.VegaTokenWhale - markets, err := network.DataNodeClient.GetAllMarkets() - if err != nil { - return err - } - - failed := false - for _, marketCode := range []string{"AAPL.MF21", "AAVEDAI.MF21", "BTCUSD.MF21", "ETHBTC.QM21", "TSLA.QM21", "UNIDAI.MF21", "ETHDAI.MF21"} { - market := governance.GetMarket(markets, marketCode, "", governance.LiveMarketStates) - if market == nil { - logger.Info("market does not exists", zap.String("market_code", marketCode)) - } else { - assetId := market.TradableInstrument.Instrument.GetFuture().SettlementAsset - if err := topup.DepositAssetToParites( - network, tools, assetId, big.NewFloat(100000), []string{proposerVegawallet.PublicKey}, args.Logger, - ); err != nil { - return fmt.Errorf("failed to deposit assets to provider account, %w", err) - } - time.Sleep(5 * time.Second) - if err := provideLiquidity(marketCode, network.DataNodeClient, proposerVegawallet, args.Logger, market.Id); err != nil { - failed = true - } - } - - } - if failed { - return fmt.Errorf("at least one Provision LP failed") - } - - return nil -} - -func provideLiquidity( - name string, - dataNodeClient vegaapi.DataNodeClient, - proposerVegawallet *wallet.VegaWallet, - logger *zap.Logger, - marketId string, -) error { - // Prepare vegawallet Transaction Request - walletTxReq := walletpb.SubmitTransactionRequest{ - PubKey: proposerVegawallet.PublicKey, - Command: &walletpb.SubmitTransactionRequest_LiquidityProvisionSubmission{ - LiquidityProvisionSubmission: &commandspb.LiquidityProvisionSubmission{ - Fee: "0.01", - MarketId: marketId, - CommitmentAmount: "10000000", - }, - }, - } - - // Sign + Proof of Work vegawallet Transaction request - lastBlockData, err := dataNodeClient.LastBlockData() - if err != nil { - return err - } - signedTx, err := proposerVegawallet.SignTxWithPoW(&walletTxReq, lastBlockData) - if err != nil { - logger.Error("Failed to sign a trasnaction", zap.String("market", name), - zap.String("proposer", proposerVegawallet.PublicKey), - zap.Any("txReq", &walletTxReq), zap.Error(err)) - return err - } - - // wrap in vega Transaction Request - submitReq := &vegaapipb.SubmitTransactionRequest{ - Tx: signedTx, - Type: vegaapipb.SubmitTransactionRequest_TYPE_SYNC, - } - - // Submit Transaction - logger.Info("Submit transaction", zap.String("market", name), - zap.String("proposer", proposerVegawallet.PublicKey)) - submitResponse, err := dataNodeClient.SubmitTransaction(submitReq) - if err != nil { - logger.Error("Failed to submit a trasnaction", zap.String("market", name), - zap.String("proposer", proposerVegawallet.PublicKey), - zap.Any("txReq", submitReq), zap.Error(err)) - return err - } - if !submitResponse.Success { - logger.Error("Transaction submission response is not successful", zap.String("market", name), - zap.String("proposer", proposerVegawallet.PublicKey), - zap.Any("txReq", submitReq), zap.Any("response", submitResponse)) - return err - } - logger.Info("Successful Submision of Provide LP", zap.String("market", name), - zap.String("proposer", proposerVegawallet.PublicKey), zap.String("txHash", submitResponse.TxHash)) - return nil -} diff --git a/cmd/market/root.go b/cmd/market/root.go index 316585d8..81840042 100644 --- a/cmd/market/root.go +++ b/cmd/market/root.go @@ -3,8 +3,9 @@ package market import ( "log" - "github.com/spf13/cobra" rootCmd "github.com/vegaprotocol/devopstools/cmd" + + "github.com/spf13/cobra" ) type MarketArgs struct { diff --git a/cmd/market/terminate.go b/cmd/market/terminate.go index e452884c..4935e4ee 100644 --- a/cmd/market/terminate.go +++ b/cmd/market/terminate.go @@ -5,15 +5,17 @@ import ( "os" "time" + "github.com/vegaprotocol/devopstools/governance" + "github.com/vegaprotocol/devopstools/tools" + "github.com/vegaprotocol/devopstools/vegaapi" + "code.vegaprotocol.io/vega/core/netparams" v2 "code.vegaprotocol.io/vega/protos/data-node/api/v2" "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" walletpb "code.vegaprotocol.io/vega/protos/vega/wallet/v1" + "github.com/spf13/cobra" - "github.com/vegaprotocol/devopstools/governance" - "github.com/vegaprotocol/devopstools/tools" - "github.com/vegaprotocol/devopstools/vegaapi" "go.uber.org/zap" "golang.org/x/exp/slices" ) @@ -196,7 +198,6 @@ func RunTerminate(args *TerminateArgs) error { return proposalId, nil }) - if err != nil { return fmt.Errorf("failed to find proposal for terminate market %s: %w", marketDetails.name, err) } diff --git a/cmd/network/graph.go b/cmd/network/graph.go index 43900b34..db2f9897 100644 --- a/cmd/network/graph.go +++ b/cmd/network/graph.go @@ -3,8 +3,9 @@ package network import ( "os" - "github.com/spf13/cobra" "github.com/vegaprotocol/devopstools/networktools" + + "github.com/spf13/cobra" "go.uber.org/zap" ) diff --git a/cmd/network/healthynodes.go b/cmd/network/healthynodes.go index a0940291..b446c97e 100644 --- a/cmd/network/healthynodes.go +++ b/cmd/network/healthynodes.go @@ -3,16 +3,17 @@ package network import ( "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "os" "strconv" "strings" "time" - "github.com/spf13/cobra" "github.com/vegaprotocol/devopstools/networktools" toolslib "github.com/vegaprotocol/devopstools/tools" + + "github.com/spf13/cobra" "go.uber.org/zap" ) @@ -169,7 +170,7 @@ func isNodeHealthy(logger *zap.Logger, host string, dataNode bool) bool { } defer resp.Body.Close() - responseBytes, err := ioutil.ReadAll(resp.Body) + responseBytes, err := io.ReadAll(resp.Body) if err != nil { logger.Sugar().Debugf("Failed to read response body for node %s: %s", host, err.Error()) return false diff --git a/cmd/network/networkParams.go b/cmd/network/networkParams.go index 6f1abd41..2ba2a6c2 100644 --- a/cmd/network/networkParams.go +++ b/cmd/network/networkParams.go @@ -5,8 +5,9 @@ import ( "fmt" "os" - "github.com/spf13/cobra" "github.com/vegaprotocol/devopstools/networktools" + + "github.com/spf13/cobra" "go.uber.org/zap" ) diff --git a/cmd/network/root.go b/cmd/network/root.go index 45c251ae..3fa1c5ee 100644 --- a/cmd/network/root.go +++ b/cmd/network/root.go @@ -3,8 +3,9 @@ package network import ( "log" - "github.com/spf13/cobra" rootCmd "github.com/vegaprotocol/devopstools/cmd" + + "github.com/spf13/cobra" ) type NetworkArgs struct { diff --git a/cmd/network/selfdelegate.go b/cmd/network/selfdelegate.go index 0cf612ae..d355e01f 100644 --- a/cmd/network/selfdelegate.go +++ b/cmd/network/selfdelegate.go @@ -7,16 +7,17 @@ import ( "sync" "time" - "code.vegaprotocol.io/vega/protos/vega" + "github.com/vegaprotocol/devopstools/ethutils" + "github.com/vegaprotocol/devopstools/secrets" + "github.com/vegaprotocol/devopstools/wallet" + vegaapipb "code.vegaprotocol.io/vega/protos/vega/api/v1" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" walletpb "code.vegaprotocol.io/vega/protos/vega/wallet/v1" + "github.com/ethereum/go-ethereum/accounts/abi/bind" ethTypes "github.com/ethereum/go-ethereum/core/types" "github.com/spf13/cobra" - "github.com/vegaprotocol/devopstools/ethutils" - "github.com/vegaprotocol/devopstools/secrets" - "github.com/vegaprotocol/devopstools/wallet" "go.uber.org/zap" ) @@ -175,9 +176,9 @@ func RunSelfDelegate(args SelfDelegateArgs) error { // // Stake to nodes // - var ( - stakeTxs = map[string]*ethTypes.Transaction{} - ) + + stakeTxs := map[string]*ethTypes.Transaction{} + for name, humanStakeAmount := range humanMissingStake { var ( node = network.NodeSecrets[name] @@ -219,14 +220,9 @@ func RunSelfDelegate(args SelfDelegateArgs) error { if err != nil { return err } - statistics, err := network.DataNodeClient.Statistics() - if err != nil { - return err - } resultsChannel := make(chan error, len(network.ValidatorsById)) var wg sync.WaitGroup - //for id, validator := range network.ValidatorsById { for name, nodeSecrets := range network.NodeSecrets { validator, isValidator := network.ValidatorsById[nodeSecrets.VegaId] if !isValidator { @@ -250,11 +246,11 @@ func RunSelfDelegate(args SelfDelegateArgs) error { logger.Warn("party doesn't have visible stake yet - you might need to wait till next epoch", zap.String("node", name), zap.String("partyTotalStake", partyTotalStake.String())) // TODO: write wait functionality - //continue + // continue } wg.Add(1) - go func(name string, validator *vega.Node, nodeSecrets *secrets.VegaNodePrivate, lastBlockData *vegaapipb.LastBlockHeightResponse, chainID string, hasVisibleStake bool) { + go func(name string, nodeSecrets *secrets.VegaNodePrivate, lastBlockData *vegaapipb.LastBlockHeightResponse, hasVisibleStake bool) { defer wg.Done() vegawallet, err := wallet.NewVegaWallet(&secrets.VegaWalletPrivate{ Id: nodeSecrets.VegaId, @@ -312,7 +308,7 @@ func RunSelfDelegate(args SelfDelegateArgs) error { return } } - }(name, validator, nodeSecrets, lastBlockData, statistics.Statistics.ChainId, partyTotalStake.Cmp(minValidatorStake) >= 0) + }(name, nodeSecrets, lastBlockData, partyTotalStake.Cmp(minValidatorStake) >= 0) } wg.Wait() close(resultsChannel) diff --git a/cmd/network/stats.go b/cmd/network/stats.go index a7789ad2..e33cb870 100644 --- a/cmd/network/stats.go +++ b/cmd/network/stats.go @@ -5,8 +5,9 @@ import ( "fmt" "os" - "github.com/spf13/cobra" "github.com/vegaprotocol/devopstools/networktools" + + "github.com/spf13/cobra" "go.uber.org/zap" ) diff --git a/cmd/ops/pssh.go b/cmd/ops/pssh.go index ab203e1f..b5042e1b 100644 --- a/cmd/ops/pssh.go +++ b/cmd/ops/pssh.go @@ -6,8 +6,9 @@ import ( "os" "sort" - "github.com/spf13/cobra" "github.com/vegaprotocol/devopstools/networktools" + + "github.com/spf13/cobra" "go.uber.org/zap" ) @@ -67,7 +68,7 @@ func RunPSSH(args PsshArgs) error { ) hostNames := make([]string, 0) - for host, _ := range sshResults { + for host := range sshResults { hostNames = append(hostNames, host) } sort.Strings(hostNames) diff --git a/cmd/ops/root.go b/cmd/ops/root.go index d6b98bbb..ea4d8593 100644 --- a/cmd/ops/root.go +++ b/cmd/ops/root.go @@ -1,8 +1,9 @@ package ops import ( - "github.com/spf13/cobra" rootCmd "github.com/vegaprotocol/devopstools/cmd" + + "github.com/spf13/cobra" ) type OpsArgs struct { diff --git a/cmd/party/getstake.go b/cmd/party/getstake.go index 09329d1a..86d1c9c0 100644 --- a/cmd/party/getstake.go +++ b/cmd/party/getstake.go @@ -4,8 +4,9 @@ import ( "fmt" "os" - "github.com/spf13/cobra" "github.com/vegaprotocol/devopstools/networktools" + + "github.com/spf13/cobra" "go.uber.org/zap" ) diff --git a/cmd/party/root.go b/cmd/party/root.go index e9c2ec32..db5b238d 100644 --- a/cmd/party/root.go +++ b/cmd/party/root.go @@ -3,8 +3,9 @@ package party import ( "log" - "github.com/spf13/cobra" rootCmd "github.com/vegaprotocol/devopstools/cmd" + + "github.com/spf13/cobra" ) type PartyArgs struct { diff --git a/cmd/propose/assets.go b/cmd/propose/assets.go index eff46737..282bfeb9 100644 --- a/cmd/propose/assets.go +++ b/cmd/propose/assets.go @@ -7,17 +7,19 @@ import ( "strings" "time" + "github.com/vegaprotocol/devopstools/governance" + assetsgov "github.com/vegaprotocol/devopstools/governance/assets" + "github.com/vegaprotocol/devopstools/tools" + "github.com/vegaprotocol/devopstools/types" + "code.vegaprotocol.io/vega/core/netparams" v2 "code.vegaprotocol.io/vega/protos/data-node/api/v2" "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" walletpb "code.vegaprotocol.io/vega/protos/vega/wallet/v1" + "github.com/hashicorp/go-multierror" "github.com/spf13/cobra" - "github.com/vegaprotocol/devopstools/governance" - assetsgov "github.com/vegaprotocol/devopstools/governance/assets" - "github.com/vegaprotocol/devopstools/tools" - "github.com/vegaprotocol/devopstools/types" "go.uber.org/zap" ) @@ -247,7 +249,6 @@ func proposeAssetRun(args *ProposeAssetArgs) error { return proposalId, nil }) - if err != nil { cError := fmt.Errorf("failed to find proposal for new asset:%w", err) @@ -280,7 +281,7 @@ func proposeAssetRun(args *ProposeAssetArgs) error { }, } if err := governance.SubmitTx("vote on asset proposal", network.DataNodeClient, network.VegaTokenWhale, args.Logger, &voteWalletTxReq); err != nil { - cError := fmt.Errorf("failet to vote on the asset proposal: %w") + cError := fmt.Errorf("failet to vote on the asset proposal: %w", err) logger.Error( "failed to propose asset", diff --git a/cmd/propose/list.go b/cmd/propose/list.go index ddc59a4c..32b0b7c4 100644 --- a/cmd/propose/list.go +++ b/cmd/propose/list.go @@ -7,6 +7,7 @@ import ( "time" v2 "code.vegaprotocol.io/vega/protos/data-node/api/v2" + "github.com/spf13/cobra" "go.uber.org/zap" ) @@ -56,7 +57,6 @@ func RunList(args ListArgs) error { } func PrettyPrintProposal(proposal *v2.GovernanceDataEdge, details bool) { - fmt.Printf("Proposal: \"%s\" (%s)\n", proposal.Node.Proposal.Rationale.Title, proposal.Node.Proposal.State.String(), diff --git a/cmd/propose/network_parameter.go b/cmd/propose/network_parameter.go index 4440e7ee..8e5c448d 100644 --- a/cmd/propose/network_parameter.go +++ b/cmd/propose/network_parameter.go @@ -6,11 +6,13 @@ import ( "os" "time" + "github.com/vegaprotocol/devopstools/governance" + "github.com/vegaprotocol/devopstools/governance/networkparameters" + "code.vegaprotocol.io/vega/core/netparams" v2 "code.vegaprotocol.io/vega/protos/data-node/api/v2" + "github.com/spf13/cobra" - "github.com/vegaprotocol/devopstools/governance" - "github.com/vegaprotocol/devopstools/governance/networkparameters" "go.uber.org/zap" ) @@ -98,7 +100,6 @@ func RunNetworkParameter(args NetworkParameterArgs) error { proposalId, err := governance.SubmitProposal( "Update Network Parameter", proposerVegawallet, proposalConfig, network.DataNodeClient, logger, ) - if err != nil { return fmt.Errorf("failed to propose Update Network Paramter %w", err) } diff --git a/cmd/propose/referral.go b/cmd/propose/referral.go index 1458a4e4..cbd4bd40 100644 --- a/cmd/propose/referral.go +++ b/cmd/propose/referral.go @@ -6,12 +6,14 @@ import ( "strings" "time" - "code.vegaprotocol.io/vega/core/netparams" - "github.com/spf13/cobra" "github.com/vegaprotocol/devopstools/governance" "github.com/vegaprotocol/devopstools/governance/programs" "github.com/vegaprotocol/devopstools/types" "github.com/vegaprotocol/devopstools/veganetwork" + + "code.vegaprotocol.io/vega/core/netparams" + + "github.com/spf13/cobra" "go.uber.org/zap" ) diff --git a/cmd/propose/root.go b/cmd/propose/root.go index 8d81f3d4..330be7b2 100644 --- a/cmd/propose/root.go +++ b/cmd/propose/root.go @@ -3,8 +3,9 @@ package propose import ( "log" - "github.com/spf13/cobra" rootCmd "github.com/vegaprotocol/devopstools/cmd" + + "github.com/spf13/cobra" ) type ProposeArgs struct { diff --git a/cmd/propose/volume_discount.go b/cmd/propose/volume_discount.go index a96abbe0..cd491053 100644 --- a/cmd/propose/volume_discount.go +++ b/cmd/propose/volume_discount.go @@ -6,12 +6,14 @@ import ( "strings" "time" - "code.vegaprotocol.io/vega/core/netparams" - "github.com/spf13/cobra" "github.com/vegaprotocol/devopstools/governance" "github.com/vegaprotocol/devopstools/governance/programs" "github.com/vegaprotocol/devopstools/types" "github.com/vegaprotocol/devopstools/veganetwork" + + "code.vegaprotocol.io/vega/core/netparams" + + "github.com/spf13/cobra" "go.uber.org/zap" ) diff --git a/cmd/script/root.go b/cmd/script/root.go index 6792487d..9dc42427 100644 --- a/cmd/script/root.go +++ b/cmd/script/root.go @@ -1,8 +1,9 @@ package script import ( - "github.com/spf13/cobra" rootCmd "github.com/vegaprotocol/devopstools/cmd" + + "github.com/spf13/cobra" ) type ScriptArgs struct { diff --git a/cmd/secrets/create.go b/cmd/secrets/create.go index 85c29eb8..b37738d3 100644 --- a/cmd/secrets/create.go +++ b/cmd/secrets/create.go @@ -5,8 +5,9 @@ import ( "log" "os" - "github.com/spf13/cobra" "github.com/vegaprotocol/devopstools/generate" + + "github.com/spf13/cobra" "go.uber.org/zap" ) @@ -74,7 +75,6 @@ func RunCreate(args CreateArgs) error { } args.Logger.Info("updated", zap.String("node", nodeId), zap.Any("fields", updates)) } else { - newSecrets, err := generate.GenerateVegaNodeSecrets() if err != nil { return err diff --git a/cmd/secrets/createNode.go b/cmd/secrets/createNode.go index d3d2c1bd..13e7cc62 100644 --- a/cmd/secrets/createNode.go +++ b/cmd/secrets/createNode.go @@ -5,8 +5,9 @@ import ( "log" "os" - "github.com/spf13/cobra" "github.com/vegaprotocol/devopstools/generate" + + "github.com/spf13/cobra" "go.uber.org/zap" ) diff --git a/cmd/secrets/fillOut.go b/cmd/secrets/fillOut.go index 78c31b5e..f9a8523f 100644 --- a/cmd/secrets/fillOut.go +++ b/cmd/secrets/fillOut.go @@ -4,11 +4,13 @@ import ( "log" "os" + "github.com/vegaprotocol/devopstools/generate" + "github.com/vegaprotocol/devopstools/secrets" + "code.vegaprotocol.io/vega/wallet/wallet" + "github.com/ipfs/kubo/config" "github.com/spf13/cobra" - "github.com/vegaprotocol/devopstools/generate" - "github.com/vegaprotocol/devopstools/secrets" "go.uber.org/zap" ) @@ -45,9 +47,7 @@ func init() { } func RunFillOut(args FillOutArgs) error { - var ( - nodes map[string]*secrets.VegaNodePrivate - ) + var nodes map[string]*secrets.VegaNodePrivate secretStore, err := args.GetNodeSecretStore() if err != nil { return err @@ -85,9 +85,7 @@ func RunFillOut(args FillOutArgs) error { } func fillOutNodeData(nodeSecrets *secrets.VegaNodePrivate) (updatedFields map[string]string, err error) { - var ( - vegaWallet *wallet.HDWallet - ) + var vegaWallet *wallet.HDWallet updatedFields = map[string]string{} vegaWallet, err = wallet.ImportHDWallet("my wallet", nodeSecrets.VegaRecoveryPhrase, wallet.LatestVersion) diff --git a/cmd/secrets/root.go b/cmd/secrets/root.go index 0049f5ce..e121a3ae 100644 --- a/cmd/secrets/root.go +++ b/cmd/secrets/root.go @@ -1,8 +1,9 @@ package secrets import ( - "github.com/spf13/cobra" rootCmd "github.com/vegaprotocol/devopstools/cmd" + + "github.com/spf13/cobra" ) type SecretsArgs struct { diff --git a/cmd/smartcontracts/pull.go b/cmd/smartcontracts/pull.go deleted file mode 100644 index d0b2cfef..00000000 --- a/cmd/smartcontracts/pull.go +++ /dev/null @@ -1,77 +0,0 @@ -package smartcontracts - -import ( - "fmt" - "os" - "path/filepath" - - "github.com/spf13/cobra" - "github.com/vegaprotocol/devopstools/ethutils" - "github.com/vegaprotocol/devopstools/types" - "go.uber.org/zap" -) - -type smartContract struct { - Name string - Version string - HexAddress string - Network types.ETHNetwork - HomeDir string -} - -type PullArgs struct { - *SmartContractsArgs - SmartContracts []smartContract -} - -var pullArgs = PullArgs{ - SmartContracts: []smartContract{ - {Name: "MultisigControl", Version: "v1", Network: types.ETHMainnet, HexAddress: "0x164D322B2377C0fdDB73Cd32f24e972A7d9C72F9", HomeDir: "multisigcontrol"}, - {Name: "ERC20Bridge", Version: "v1", Network: types.ETHMainnet, HexAddress: "0xCd403f722b76366f7d609842C589906ca051310f", HomeDir: "erc20bridge"}, - {Name: "ERC20AssetPool", Version: "v1", Network: types.ETHMainnet, HexAddress: "0xA226E2A13e07e750EfBD2E5839C5c3Be80fE7D4d", HomeDir: "erc20assetpool"}, - {Name: "StakingBridge", Version: "v1", Network: types.ETHMainnet, HexAddress: "0x195064D33f09e0c42cF98E665D9506e0dC17de68", HomeDir: "stakingbridge"}, - {Name: "VestingBridge", Version: "v1", Network: types.ETHMainnet, HexAddress: "0x23d1bFE8fA50a167816fBD79D7932577c06011f4", HomeDir: "vestingbridge"}, - {Name: "ERC20BridgeRestricted", Version: "v2", Network: types.ETHMainnet, HexAddress: "0x23872549cE10B40e31D6577e0A920088B0E0666a", HomeDir: "erc20bridge"}, - {Name: "MultisigControl", Version: "v2", Network: types.ETHMainnet, HexAddress: "0xDD2df0E7583ff2acfed5e49Df4a424129cA9B58F", HomeDir: "multisigcontrol"}, - {Name: "ClaimCodes", Version: "v1", Network: types.ETHMainnet, HexAddress: "0x0ee1fb382caf98e86e97e51f9f42f8b4654020f3", HomeDir: "claimcodes"}, - }, -} - -// pullCmd represents the pull command -var pullCmd = &cobra.Command{ - Use: "pull", - Short: "Get Smart Contracts bytecode and source code from Ethereum Network to local", - Long: `Get Smart Contracts bytecode and source code`, - Run: func(cmd *cobra.Command, args []string) { - if err := RunPull(pullArgs); err != nil { - pullArgs.Logger.Error("Error", zap.Error(err)) - os.Exit(1) - } - }, -} - -func init() { - pullArgs.SmartContractsArgs = &smartContractsArgs - - SmartContractsCmd.AddCommand(pullCmd) -} - -func RunPull(args PullArgs) error { - secretStore, err := args.GetServiceSecretStore() - if err != nil { - return err - } - ethClientManager := ethutils.NewEthereumClientManager(secretStore) - for _, contract := range args.SmartContracts { - dir := filepath.Join("smartcontracts", contract.HomeDir, contract.Version) - - if err := ethutils.PullAndStoreSmartContractImmutableData( - contract.HexAddress, contract.Network, contract.Name, dir, ethClientManager, - ); err != nil { - return err - } - fmt.Printf(" - Downloaded %s(%s) from '%s' and stored in %s\n", - contract.Name, contract.HexAddress, contract.Network, dir) - } - return nil -} diff --git a/cmd/smartcontracts/root.go b/cmd/smartcontracts/root.go deleted file mode 100644 index fc6c2acc..00000000 --- a/cmd/smartcontracts/root.go +++ /dev/null @@ -1,23 +0,0 @@ -package smartcontracts - -import ( - "github.com/spf13/cobra" - rootCmd "github.com/vegaprotocol/devopstools/cmd" -) - -type SmartContractsArgs struct { - *rootCmd.RootArgs -} - -var smartContractsArgs SmartContractsArgs - -// Root Command for OPS -var SmartContractsCmd = &cobra.Command{ - Use: "smart-contracts", - Short: "General Smart Contracts tasks", - Long: `General Smart Contracts tasks`, -} - -func init() { - smartContractsArgs.RootArgs = &rootCmd.Args -} diff --git a/cmd/snapshotcompatibility/collect-snapshot.go b/cmd/snapshotcompatibility/collect-snapshot.go index 5a96c00e..012d86df 100644 --- a/cmd/snapshotcompatibility/collect-snapshot.go +++ b/cmd/snapshotcompatibility/collect-snapshot.go @@ -5,12 +5,12 @@ import ( "os" "path/filepath" - "github.com/spf13/cobra" - "go.uber.org/zap" - "github.com/vegaprotocol/devopstools/tools" "github.com/vegaprotocol/devopstools/vegacapsule" "github.com/vegaprotocol/devopstools/vegacmd" + + "github.com/spf13/cobra" + "go.uber.org/zap" ) type CollectSnapshotArgs struct { diff --git a/cmd/snapshotcompatibility/download-binary.go b/cmd/snapshotcompatibility/download-binary.go index 0d596af6..a591b203 100644 --- a/cmd/snapshotcompatibility/download-binary.go +++ b/cmd/snapshotcompatibility/download-binary.go @@ -6,14 +6,14 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "os" "strings" "time" - "github.com/spf13/cobra" "github.com/vegaprotocol/devopstools/tools" + + "github.com/spf13/cobra" "go.uber.org/zap" ) @@ -92,7 +92,7 @@ func getStatistics(endpoint string) (*statisticsResponse, error) { } defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return nil, fmt.Errorf("failed to read response body for statistics: %w", err) } @@ -173,7 +173,7 @@ func downloadVegaBinary(logger *zap.Logger, repository, version, destinationFile } defer binFile.Close() - err = os.Chmod(destinationFile, 0755) + err = os.Chmod(destinationFile, 0o755) if err != nil { return fmt.Errorf("failed to change permission for file %q: %w", destinationFile, err) } diff --git a/cmd/snapshotcompatibility/download-mainnet-snapshot.go b/cmd/snapshotcompatibility/download-mainnet-snapshot.go index 966dd0c2..fdd68838 100644 --- a/cmd/snapshotcompatibility/download-mainnet-snapshot.go +++ b/cmd/snapshotcompatibility/download-mainnet-snapshot.go @@ -6,12 +6,12 @@ import ( "path/filepath" "time" + "github.com/vegaprotocol/devopstools/ssh" + "github.com/vegaprotocol/devopstools/tools" + "github.com/spf13/cobra" "go.uber.org/zap" sshlib "golang.org/x/crypto/ssh" - - "github.com/vegaprotocol/devopstools/ssh" - "github.com/vegaprotocol/devopstools/tools" ) var ( diff --git a/cmd/snapshotcompatibility/load-snapshot.go b/cmd/snapshotcompatibility/load-snapshot.go index dc84ce19..f6f2004b 100644 --- a/cmd/snapshotcompatibility/load-snapshot.go +++ b/cmd/snapshotcompatibility/load-snapshot.go @@ -7,14 +7,14 @@ import ( "sort" "time" + "github.com/vegaprotocol/devopstools/tools" + "github.com/vegaprotocol/devopstools/vegacapsule" + "github.com/vegaprotocol/devopstools/vegacmd" + "github.com/spf13/cobra" "github.com/tomwright/dasel" "github.com/tomwright/dasel/storage" "go.uber.org/zap" - - "github.com/vegaprotocol/devopstools/tools" - "github.com/vegaprotocol/devopstools/vegacapsule" - "github.com/vegaprotocol/devopstools/vegacmd" ) type LoadSnapshotArgs struct { diff --git a/cmd/snapshotcompatibility/produce-new-snapshot.go b/cmd/snapshotcompatibility/produce-new-snapshot.go index e1601196..2e5434ee 100644 --- a/cmd/snapshotcompatibility/produce-new-snapshot.go +++ b/cmd/snapshotcompatibility/produce-new-snapshot.go @@ -9,14 +9,15 @@ import ( "strconv" "time" - vegaapipb "code.vegaprotocol.io/vega/protos/vega/api/v1" - "github.com/spf13/cobra" - "go.uber.org/zap" - "github.com/vegaprotocol/devopstools/tools" "github.com/vegaprotocol/devopstools/vegaapi" "github.com/vegaprotocol/devopstools/vegaapi/core" "github.com/vegaprotocol/devopstools/vegacapsule" + + vegaapipb "code.vegaprotocol.io/vega/protos/vega/api/v1" + + "github.com/spf13/cobra" + "go.uber.org/zap" ) type ProduceNewSnapshotArgs struct { @@ -204,7 +205,6 @@ func getNetworkHeight(coreClient vegaapi.VegaCoreClient) (int, error) { statistics, err := tools.RetryReturn(3, 3*time.Second, func() (*vegaapipb.StatisticsResponse, error) { return coreClient.Statistics() }) - if err != nil { return 0, fmt.Errorf("failed to get output from the statistic core api: %w", err) } diff --git a/cmd/snapshotcompatibility/root.go b/cmd/snapshotcompatibility/root.go index 796809bf..169d053c 100644 --- a/cmd/snapshotcompatibility/root.go +++ b/cmd/snapshotcompatibility/root.go @@ -1,9 +1,9 @@ package snapshotcompatibility import ( - "github.com/spf13/cobra" - rootCmd "github.com/vegaprotocol/devopstools/cmd" + + "github.com/spf13/cobra" ) type SnapshotCompatibilityArgs struct { diff --git a/cmd/spam/balance_manager.go b/cmd/spam/balance_manager.go index f4a90f8f..09e61aff 100644 --- a/cmd/spam/balance_manager.go +++ b/cmd/spam/balance_manager.go @@ -6,12 +6,13 @@ import ( "math/big" "time" + "github.com/vegaprotocol/devopstools/vegaapi" + "github.com/vegaprotocol/devopstools/wallet" + vegapb "code.vegaprotocol.io/vega/protos/vega" vegaapipb "code.vegaprotocol.io/vega/protos/vega/api/v1" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" walletpb "code.vegaprotocol.io/vega/protos/vega/wallet/v1" - "github.com/vegaprotocol/devopstools/vegaapi" - "github.com/vegaprotocol/devopstools/wallet" ) const ( @@ -160,7 +161,6 @@ func describeAssets(dataNodeClient vegaapi.DataNodeClient) (map[string]uint64, e func (bm *BalanceManager) requiredTopup(pair *AssetPartyPair) (*big.Int, error) { funds, err := bm.dataNodeClient.GetFunds(pair.partyId, vegapb.AccountType_ACCOUNT_TYPE_GENERAL, &pair.assetId) - if err != nil { return nil, fmt.Errorf("failed to get funds for %s: %w", pair, err) } diff --git a/cmd/spam/orders.go b/cmd/spam/orders.go index 8dcddbdc..aa0ea822 100644 --- a/cmd/spam/orders.go +++ b/cmd/spam/orders.go @@ -11,17 +11,18 @@ import ( "syscall" "time" - vegaapipb "code.vegaprotocol.io/vega/protos/vega/api/v1" - "go.uber.org/zap" + rootCmd "github.com/vegaprotocol/devopstools/cmd" + "github.com/vegaprotocol/devopstools/vegaapi" + "github.com/vegaprotocol/devopstools/veganetwork" + "github.com/vegaprotocol/devopstools/wallet" vegapb "code.vegaprotocol.io/vega/protos/vega" + vegaapipb "code.vegaprotocol.io/vega/protos/vega/api/v1" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" walletpb "code.vegaprotocol.io/vega/protos/vega/wallet/v1" + "github.com/spf13/cobra" - rootCmd "github.com/vegaprotocol/devopstools/cmd" - "github.com/vegaprotocol/devopstools/vegaapi" - "github.com/vegaprotocol/devopstools/veganetwork" - "github.com/vegaprotocol/devopstools/wallet" + "go.uber.org/zap" ) type OrdersArgs struct { @@ -313,7 +314,6 @@ func (spammer *OrderSpammer) Stop() { } func RunMarketSpam(args OrdersArgs) error { - rand.Seed(time.Now().UnixMicro()) stressDurationCtx, cancelDuration := context.WithTimeout(context.Background(), args.Duration) defer cancelDuration() diff --git a/cmd/topup/liqbot.go b/cmd/topup/liqbot.go deleted file mode 100644 index 520e3e61..00000000 --- a/cmd/topup/liqbot.go +++ /dev/null @@ -1,128 +0,0 @@ -package topup - -import ( - "context" - "fmt" - "log" - "math/big" - "os" - "sync" - - "code.vegaprotocol.io/vega/protos/vega" - "github.com/spf13/cobra" - "github.com/vegaprotocol/devopstools/ethutils" - "github.com/vegaprotocol/devopstools/networktools" - "go.uber.org/zap" -) - -type LiqbotArgs struct { - *TopUpArgs - VegaNetworkName string -} - -var liqbotArgs LiqbotArgs - -// liqbotCmd represents the liqbot command -var topUpLiqbotCmd = &cobra.Command{ - Use: "liqbot", - Short: "TopUp liqbot for network", - Long: `TopUp liqbot for network`, - Run: func(cmd *cobra.Command, args []string) { - if err := RunTopUpLiqbot(liqbotArgs); err != nil { - liqbotArgs.Logger.Error("Error", zap.Error(err)) - os.Exit(1) - } - }, -} - -func init() { - liqbotArgs.TopUpArgs = &topUpArgs - - TopUpCmd.AddCommand(topUpLiqbotCmd) - topUpLiqbotCmd.PersistentFlags().StringVar(&liqbotArgs.VegaNetworkName, "network", "", "Vega Network name") - if err := topUpLiqbotCmd.MarkPersistentFlagRequired("network"); err != nil { - log.Fatalf("%v\n", err) - } -} - -func RunTopUpLiqbot(args LiqbotArgs) error { - networktools, err := networktools.NewNetworkTools(args.VegaNetworkName, args.Logger) - if err != nil { - return err - } - traders, err := networktools.GetLiqbotTraders() - if err != nil { - return err - } - network, err := args.ConnectToVegaNetwork(args.VegaNetworkName) - if err != nil { - return err - } - defer network.Disconnect() - networkAssets, err := network.DataNodeClient.GetAssets() - if err != nil { - return err - } - - ethBalanceBefore, err := network.EthClient.BalanceAt(context.Background(), network.NetworkMainWallet.Address, nil) - if err != nil { - return err - } - humanEthBalanceBefore := ethutils.WeiToEther(ethBalanceBefore) - args.Logger.Info("eth balance of main wallet - before", zap.String("wallet", network.NetworkMainWallet.Address.Hex()), - zap.String("balance", humanEthBalanceBefore.String())) - defer func() { - ethBalanceAfter, err := network.EthClient.BalanceAt(context.Background(), network.NetworkMainWallet.Address, nil) - if err != nil { - return - } - humanEthBalanceAfter := ethutils.WeiToEther(ethBalanceAfter) - humanDiff := new(big.Float).Sub(humanEthBalanceBefore, humanEthBalanceAfter) - args.Logger.Info("eth balance of main wallet - after", zap.String("wallet", network.NetworkMainWallet.Address.Hex()), - zap.String("balance", humanEthBalanceAfter.String()), zap.String("cost", humanDiff.String())) - }() - - resultsChannel := make(chan error, len(traders.ByERC20TokenHexAddress)+len(traders.ByFakeAssetId)) - var wg sync.WaitGroup - - // Trigger ERC20 TopUps - for tokenHexAddress, vegaPubKeys := range traders.ByERC20TokenHexAddress { - wg.Add(1) - go func(tokenHexAddress string, vegaPubKeys []string) { - defer wg.Done() - err := depositERC20TokenToParties(network, tokenHexAddress, vegaPubKeys, big.NewFloat(1000000), args.Logger) - if err != nil { - resultsChannel <- err - } - }(tokenHexAddress, vegaPubKeys) - } - // Trigger Fake Assets TopUps - for assetId, vegaPubKeys := range traders.ByFakeAssetId { - asset, assetFound := networkAssets[assetId] - if !assetFound { - return fmt.Errorf("given asset %s not found in list of supported fake assets to top up", assetId) - } - wg.Add(1) - go func(assetId string, asset *vega.AssetDetails, vegaPubKeys []string) { - defer wg.Done() - err := depositFakeAssetToParties(networktools, assetId, asset, vegaPubKeys, big.NewFloat(1000000), args.Logger) - resultsChannel <- err - }(assetId, asset, vegaPubKeys) - } - wg.Wait() - close(resultsChannel) - - failed := false - for err := range resultsChannel { - //for _, err := range network.AssetMainWallet.WaitForQueue() { - if err != nil { - failed = true - args.Logger.Error("transaciton failed", zap.Error(err)) - } - } - if failed { - return fmt.Errorf("failed to top up all the parties") - } - fmt.Printf("DONE\n") - return nil -} diff --git a/cmd/topup/parties.go b/cmd/topup/parties.go deleted file mode 100644 index f11e87db..00000000 --- a/cmd/topup/parties.go +++ /dev/null @@ -1,159 +0,0 @@ -package topup - -import ( - "context" - "fmt" - "log" - "math/big" - "os" - "sync" - - "code.vegaprotocol.io/vega/protos/vega" - "github.com/spf13/cobra" - "github.com/vegaprotocol/devopstools/ethutils" - "github.com/vegaprotocol/devopstools/networktools" - "go.uber.org/zap" -) - -type PartiesArgs struct { - *TopUpArgs - VegaNetworkName string - ERC20TokenHexAddress string - FakeTokenAssetId string - PartiesVegaPubKeys []string - Amount string - Repeat uint16 -} - -var partiesArgs PartiesArgs - -// partiesCmd represents the parties command -var topUpPartiesCmd = &cobra.Command{ - Use: "parties", - Short: "TopUp parties for network", - Long: `TopUp parties for network`, - Run: func(cmd *cobra.Command, args []string) { - if err := RunTopUpParties(partiesArgs); err != nil { - partiesArgs.Logger.Error("Error", zap.Error(err)) - os.Exit(1) - } - }, -} - -func init() { - partiesArgs.TopUpArgs = &topUpArgs - - TopUpCmd.AddCommand(topUpPartiesCmd) - topUpPartiesCmd.PersistentFlags().StringVar(&partiesArgs.VegaNetworkName, "network", "", "Vega Network name") - if err := topUpPartiesCmd.MarkPersistentFlagRequired("network"); err != nil { - log.Fatalf("%v\n", err) - } - topUpPartiesCmd.PersistentFlags().StringVar(&partiesArgs.ERC20TokenHexAddress, "erc20-token-address", "", "Ethereum Address of the Asset (asset needs to be listed, and the whale account must have it)") - topUpPartiesCmd.PersistentFlags().StringVar(&partiesArgs.FakeTokenAssetId, "fake-asset-id", "", "Vega Asset Id of the fake token") - topUpPartiesCmd.PersistentFlags().StringSliceVar(&partiesArgs.PartiesVegaPubKeys, "parties", nil, "Comma separated list of parties pub keys") - if err := topUpPartiesCmd.MarkPersistentFlagRequired("parties"); err != nil { - log.Fatalf("%v\n", err) - } - topUpPartiesCmd.PersistentFlags().StringVar(&partiesArgs.Amount, "amount", "", "Amount to top up. IMPORTANT: without decimal places. You can use float") - if err := topUpPartiesCmd.MarkPersistentFlagRequired("amount"); err != nil { - log.Fatalf("%v\n", err) - } - topUpPartiesCmd.PersistentFlags().Uint16Var(&partiesArgs.Repeat, "repeat", 1, "Repeat the topup multiple times (useful if you are interested in generating deposit events).") -} - -func RunTopUpParties(args PartiesArgs) error { - var ( - traders = &networktools.Traders{ - ByERC20TokenHexAddress: map[string][]string{}, - ByFakeAssetId: map[string][]string{}, - } - amount = new(big.Float) - ) - if len(args.ERC20TokenHexAddress) > 0 { - traders.ByERC20TokenHexAddress[args.ERC20TokenHexAddress] = args.PartiesVegaPubKeys - for i := uint16(1); i < args.Repeat; i++ { - traders.ByERC20TokenHexAddress[args.ERC20TokenHexAddress] = append(traders.ByERC20TokenHexAddress[args.ERC20TokenHexAddress], args.PartiesVegaPubKeys...) - } - } else if len(args.FakeTokenAssetId) > 0 { - traders.ByFakeAssetId[args.FakeTokenAssetId] = args.PartiesVegaPubKeys - } else { - return fmt.Errorf("missing argument: either --erc20-token-address or --fake-asset-id needs to be set") - } - - if _, ok := amount.SetString(args.Amount); !ok { - return fmt.Errorf("failed to parse amount '%s' to float", args.Amount) - } - - networktools, err := networktools.NewNetworkTools(args.VegaNetworkName, args.Logger) - if err != nil { - return err - } - network, err := args.ConnectToVegaNetwork(args.VegaNetworkName) - if err != nil { - return err - } - defer network.Disconnect() - networkAssets, err := network.DataNodeClient.GetAssets() - if err != nil { - return err - } - - ethBalanceBefore, err := network.EthClient.BalanceAt(context.Background(), network.NetworkMainWallet.Address, nil) - if err != nil { - return err - } - humanEthBalanceBefore := ethutils.WeiToEther(ethBalanceBefore) - args.Logger.Info("eth balance of main wallet - before", zap.String("wallet", network.NetworkMainWallet.Address.Hex()), - zap.String("balance", humanEthBalanceBefore.String())) - defer func() { - ethBalanceAfter, err := network.EthClient.BalanceAt(context.Background(), network.NetworkMainWallet.Address, nil) - if err != nil { - return - } - humanEthBalanceAfter := ethutils.WeiToEther(ethBalanceAfter) - humanDiff := new(big.Float).Sub(humanEthBalanceBefore, humanEthBalanceAfter) - args.Logger.Info("eth balance of main wallet - after", zap.String("wallet", network.NetworkMainWallet.Address.Hex()), - zap.String("balance", humanEthBalanceAfter.String()), zap.String("cost", humanDiff.String())) - }() - - resultsChannel := make(chan error, len(traders.ByERC20TokenHexAddress)+len(traders.ByFakeAssetId)) - var wg sync.WaitGroup - - // Trigger ERC20 TopUps - for tokenHexAddress, vegaPubKeys := range traders.ByERC20TokenHexAddress { - wg.Add(1) - go func(tokenHexAddress string, vegaPubKeys []string) { - defer wg.Done() - err := depositERC20TokenToParties(network, tokenHexAddress, vegaPubKeys, amount, args.Logger) - if err != nil { - resultsChannel <- err - } - }(tokenHexAddress, vegaPubKeys) - } - // Trigger Fake Assets TopUps - for assetId, vegaPubKeys := range traders.ByFakeAssetId { - asset := networkAssets[assetId] - wg.Add(1) - go func(assetId string, asset *vega.AssetDetails, vegaPubKeys []string) { - defer wg.Done() - err := depositFakeAssetToParties(networktools, assetId, asset, vegaPubKeys, amount, args.Logger) - resultsChannel <- err - }(assetId, asset, vegaPubKeys) - } - wg.Wait() - close(resultsChannel) - - failed := false - for err := range resultsChannel { - //for _, err := range network.AssetMainWallet.WaitForQueue() { - if err != nil { - failed = true - args.Logger.Error("transaciton failed", zap.Error(err)) - } - } - if failed { - return fmt.Errorf("failed to top up all the parties") - } - fmt.Printf("DONE\n") - return nil -} diff --git a/cmd/topup/root.go b/cmd/topup/root.go index cb513253..00fcf9d1 100644 --- a/cmd/topup/root.go +++ b/cmd/topup/root.go @@ -1,8 +1,9 @@ package topup import ( - "github.com/spf13/cobra" rootCmd "github.com/vegaprotocol/devopstools/cmd" + + "github.com/spf13/cobra" ) type TopUpArgs struct { @@ -11,7 +12,6 @@ type TopUpArgs struct { var topUpArgs TopUpArgs -// Root Command for OPS var TopUpCmd = &cobra.Command{ Use: "topup", Short: "Deposit ERC20 assets to vega pub keys", diff --git a/cmd/topup/topup.go b/cmd/topup/topup.go deleted file mode 100644 index bab6bbde..00000000 --- a/cmd/topup/topup.go +++ /dev/null @@ -1,255 +0,0 @@ -package topup - -import ( - "encoding/hex" - "fmt" - "math/big" - "math/rand" - "sync" - "time" - - "code.vegaprotocol.io/vega/protos/vega" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - ethTypes "github.com/ethereum/go-ethereum/core/types" - "github.com/vegaprotocol/devopstools/ethutils" - "github.com/vegaprotocol/devopstools/networktools" - "github.com/vegaprotocol/devopstools/veganetwork" - "go.uber.org/zap" -) - -func DepositAssetToParites( - network *veganetwork.VegaNetwork, - networktools *networktools.NetworkTools, - assetId string, - humanDepositAmount *big.Float, - vegaPubKeys []string, - logger *zap.Logger, -) error { - assets, err := network.DataNodeClient.GetAssets() - if err != nil { - return err - } - asset, ok := assets[assetId] - if !ok { - return fmt.Errorf("no asset with id %s", assetId) - } - if fakeAsset := asset.GetBuiltinAsset(); fakeAsset != nil { - return depositFakeAssetToParties(networktools, assetId, asset, vegaPubKeys, humanDepositAmount, logger) - } else if erc20asset := asset.GetErc20(); erc20asset != nil { - return depositERC20TokenToParties( - network, erc20asset.ContractAddress, vegaPubKeys, humanDepositAmount, logger, - ) - } else { - return fmt.Errorf("unsupported asset type %+v", asset.GetSource()) - } -} - -func depositERC20TokenToParties( - network *veganetwork.VegaNetwork, - tokenHexAddress string, - vegaPubKeys []string, - humanDepositAmount *big.Float, // in full tokens, i.e. without decimals zeros - logger *zap.Logger, -) error { - // - // Setup - // - var ( - errMsg = fmt.Sprintf("failed to deposit %s to %d parites on %s network", tokenHexAddress, len(vegaPubKeys), network.Network) - minterWallet = network.NetworkMainWallet - erc20bridge = network.SmartContracts.ERC20Bridge - flowId = rand.Int() - ) - token, err := network.SmartContractsManager.GetAssetWithAddress(tokenHexAddress) - if err != nil { - return fmt.Errorf("failed to get token %s, %s: %w", tokenHexAddress, errMsg, err) - } - tokenInfo, err := token.GetInfo() - if err != nil { - return fmt.Errorf("failed to get token info %s, %s: %w", tokenHexAddress, errMsg, err) - } - logger.Info("deposit", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name), - zap.String("token-address", token.Address.Hex()), zap.String("erc20bridge", erc20bridge.Address.Hex()), - zap.String("minter", minterWallet.Address.Hex()), zap.String("amount-per-party", humanDepositAmount.String()), - zap.Int("party-count", len(vegaPubKeys)), zap.Any("parties", vegaPubKeys)) - - // - // Mint enough tokens and Increase Allowance - // - var ( - humanTotalDepositAmount = new(big.Float).Mul(humanDepositAmount, big.NewFloat(float64(len(vegaPubKeys)))) - totalDepositAmount = ethutils.TokenFromFullTokens(humanTotalDepositAmount, tokenInfo.Decimals) - balance *big.Int - allowance *big.Int - mintTx *ethTypes.Transaction - allowanceTx *ethTypes.Transaction - ) - balance, err = token.BalanceOf(&bind.CallOpts{}, minterWallet.Address) - if err != nil { - return fmt.Errorf("failed to get %s balance of minter %s, %s: %w", tokenInfo.Name, minterWallet.Address.Hex(), errMsg, err) - } - if balance.Cmp(totalDepositAmount) < 0 { - diff := new(big.Int).Sub(totalDepositAmount, balance) - opts := minterWallet.GetTransactOpts() - logger.Info("minting", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name), - zap.String("minter", minterWallet.Address.Hex()), - zap.String("balance", balance.String()), zap.String("mint-amount", diff.String()), - zap.String("required", totalDepositAmount.String())) - mintTx, err = token.Mint(opts, minterWallet.Address, diff) - if err != nil { - return fmt.Errorf("failed to mint, %s: %w", errMsg, err) - } - } else { - logger.Info("no need to mint", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name), - zap.String("minter", minterWallet.Address.Hex()), - zap.String("balance", balance.String()), zap.String("required", totalDepositAmount.String())) - } - allowance, err = token.Allowance(&bind.CallOpts{}, minterWallet.Address, erc20bridge.Address) - if err != nil { - return fmt.Errorf("failed to get allowance, %s: %w", errMsg, err) - } - if allowance.Cmp(totalDepositAmount) < 0 { - diff := new(big.Int).Sub(totalDepositAmount, allowance) - opts := minterWallet.GetTransactOpts() - logger.Info("increasing allowance", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name), - zap.String("minter", minterWallet.Address.Hex()), - zap.String("allowance", allowance.String()), zap.String("increasing-by", diff.String()), - zap.String("required", totalDepositAmount.String())) - allowanceTx, err = token.IncreaseAllowance(opts, erc20bridge.Address, diff) - if err != nil { - return fmt.Errorf("failed to increase allowance, %s: %w", errMsg, err) - } - } else { - logger.Info("no need to increasing allowance", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name), - zap.String("minter", minterWallet.Address.Hex()), - zap.String("allowance", allowance.String()), zap.String("required", totalDepositAmount.String())) - } - // wait - if mintTx != nil { - if err = ethutils.WaitForTransaction(network.EthClient, mintTx, time.Minute); err != nil { - logger.Error("failed to mint", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name), zap.Error(err)) - return fmt.Errorf("transaction failed to mint, %s: %w", errMsg, err) - } - logger.Info("successfully minted", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name)) - } - if allowanceTx != nil { - if err = ethutils.WaitForTransaction(network.EthClient, allowanceTx, time.Minute); err != nil { - logger.Error("failed to increase allowance", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name), zap.Error(err)) - return fmt.Errorf("transaction failed to increase allowance, %s: %w", errMsg, err) - } - logger.Info("successfully increased allowance", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name)) - } - - // - // DEPOSIT to ERC20 Bridge - // - var ( - depositTxs = make([]*ethTypes.Transaction, len(vegaPubKeys)) - depositAmount = ethutils.TokenFromFullTokens(humanDepositAmount, tokenInfo.Decimals) - success, failure int - ) - for i, pubKey := range vegaPubKeys { - bytePubKey, err := hex.DecodeString(pubKey) - if err != nil { - return err - } - var byte32PubKey [32]byte - copy(byte32PubKey[:], bytePubKey) - - opts := minterWallet.GetTransactOpts() - logger.Debug("depositing", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name), - zap.String("vegaPubKey", pubKey), zap.String("amount", depositAmount.String())) - depositTxs[i], err = erc20bridge.DepositAsset(opts, token.Address, depositAmount, byte32PubKey) - - if err != nil { - failure += 1 - logger.Error("failed to deposit", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name), - zap.String("vegaPubKey", pubKey), zap.String("amount", depositAmount.String()), - zap.Error(err)) - } - } - // wait - for i, tx := range depositTxs { - if tx == nil { - continue - } - logger.Debug("waiting", zap.Any("tx", tx)) - if err = ethutils.WaitForTransaction(network.EthClient, tx, time.Minute); err != nil { - failure += 1 - logger.Error("failed to deposit", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name), - zap.Any("tx", tx), - zap.String("vegaPubKey", vegaPubKeys[i]), zap.String("amount", depositAmount.String()), zap.Error(err)) - } else { - success += 1 - logger.Debug("successfully deposited", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name), - zap.String("vegaPubKey", vegaPubKeys[i]), zap.String("amount", depositAmount.String())) - } - } - logger.Info("Summary", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name), - zap.Int("success-count", success), zap.Int("fail-count", failure)) - if failure > 0 { - return fmt.Errorf("%s", errMsg) - } - return nil -} - -func depositFakeAssetToParties( - networktools *networktools.NetworkTools, - assetId string, - asset *vega.AssetDetails, - vegaPubKeys []string, - humanMintAmount *big.Float, // in full tokens, i.e. without decimals zeros - logger *zap.Logger, -) error { - if asset == nil { - return fmt.Errorf("given asset(%s) cannot be nil", assetId) - } - var ( - mintAmount = ethutils.TokenFromFullTokens(humanMintAmount, uint8(asset.Decimals)) - flowId = rand.Int() - ) - if maxFaucetMintAmount, ok := new(big.Int).SetString(asset.GetBuiltinAsset().MaxFaucetAmountMint, 0); ok { - if maxFaucetMintAmount.Cmp(mintAmount) < 0 { - mintAmount = maxFaucetMintAmount - } - } - logger.Info("topping up fake", zap.Int("flow", flowId), zap.String("mint amount", mintAmount.String()), zap.String("asset", asset.Name), zap.Int("parties-count", len(vegaPubKeys))) - - resultsChannel := make(chan error, len(vegaPubKeys)) - var wg sync.WaitGroup - - // Trigger ERC20 TopUps - for _, vegaPubKeys := range vegaPubKeys { - wg.Add(1) - go func(vegaAssetId string, vegaPubKey string) { - defer wg.Done() - err := networktools.MintFakeTokens(vegaPubKey, vegaAssetId, mintAmount) - resultsChannel <- err - if err != nil { - logger.Error("failed to mint", zap.Int("flow", flowId), zap.String("assetId", vegaAssetId), zap.String("vegaPubKey", vegaPubKey), zap.Error(err)) - } - }(assetId, vegaPubKeys) - } - wg.Wait() - close(resultsChannel) - - var ( - success, failure int - failed = false - ) - for err := range resultsChannel { - if err != nil { - failed = true - failure += 1 - } else { - success += 1 - } - } - logger.Info("Summary fake asset", zap.Int("flow", flowId), zap.String("sssetId", assetId), - zap.Int("success-count", success), zap.Int("fail-count", failure)) - if failed { - return fmt.Errorf("failed to top up all the parties (success: %d, failure: %d)", success, failure) - } - - return nil -} diff --git a/cmd/topup/traderbot.go b/cmd/topup/traderbot.go deleted file mode 100644 index 5b53f421..00000000 --- a/cmd/topup/traderbot.go +++ /dev/null @@ -1,132 +0,0 @@ -package topup - -import ( - "context" - "fmt" - "log" - "math/big" - "os" - "sync" - - "code.vegaprotocol.io/vega/protos/vega" - "github.com/spf13/cobra" - "github.com/vegaprotocol/devopstools/ethutils" - "github.com/vegaprotocol/devopstools/networktools" - "go.uber.org/zap" -) - -type TraderbotArgs struct { - *TopUpArgs - VegaNetworkName string - TraderBotsURL string - TraderBotId string -} - -var traderbotArgs TraderbotArgs - -// traderbotCmd represents the traderbot command -var topUpTraderbotCmd = &cobra.Command{ - Use: "traderbot", - Short: "TopUp traderbot for network", - Long: `TopUp traderbot for network`, - Run: func(cmd *cobra.Command, args []string) { - if err := RunTopUpTraderbot(traderbotArgs); err != nil { - traderbotArgs.Logger.Error("Error", zap.Error(err)) - os.Exit(1) - } - }, -} - -func init() { - traderbotArgs.TopUpArgs = &topUpArgs - - TopUpCmd.AddCommand(topUpTraderbotCmd) - topUpTraderbotCmd.PersistentFlags().StringVar(&traderbotArgs.VegaNetworkName, "network", "", "Vega Network name") - topUpTraderbotCmd.PersistentFlags().StringVar(&traderbotArgs.TraderBotsURL, "traderbots-url", "", "Traderbots URL(optional)") - topUpTraderbotCmd.PersistentFlags().StringVar(&traderbotArgs.TraderBotId, "traderbot-id", "", "Workaround for additional traderbot instances. If not empty this part is added to the url, example: traderbotXXX-stagnet1.vega.xyz/...") - if err := topUpTraderbotCmd.MarkPersistentFlagRequired("network"); err != nil { - log.Fatalf("%v\n", err) - } -} - -func RunTopUpTraderbot(args TraderbotArgs) error { - networktools, err := networktools.NewNetworkTools(args.VegaNetworkName, args.Logger) - if err != nil { - return err - } - traders, err := networktools.GetTraderbotTraders(traderbotArgs.TraderBotId, args.TraderBotsURL) - if err != nil { - return err - } - network, err := args.ConnectToVegaNetwork(args.VegaNetworkName) - if err != nil { - return err - } - defer network.Disconnect() - networkAssets, err := network.DataNodeClient.GetAssets() - if err != nil { - return err - } - - ethBalanceBefore, err := network.EthClient.BalanceAt(context.Background(), network.NetworkMainWallet.Address, nil) - if err != nil { - return err - } - humanEthBalanceBefore := ethutils.WeiToEther(ethBalanceBefore) - args.Logger.Info("eth balance of main wallet - before", zap.String("wallet", network.NetworkMainWallet.Address.Hex()), - zap.String("balance", humanEthBalanceBefore.String())) - defer func() { - ethBalanceAfter, err := network.EthClient.BalanceAt(context.Background(), network.NetworkMainWallet.Address, nil) - if err != nil { - return - } - humanEthBalanceAfter := ethutils.WeiToEther(ethBalanceAfter) - humanDiff := new(big.Float).Sub(humanEthBalanceBefore, humanEthBalanceAfter) - args.Logger.Info("eth balance of main wallet - after", zap.String("wallet", network.NetworkMainWallet.Address.Hex()), - zap.String("balance", humanEthBalanceAfter.String()), zap.String("cost", humanDiff.String())) - }() - - resultsChannel := make(chan error, len(traders.ByERC20TokenHexAddress)+len(traders.ByFakeAssetId)) - var wg sync.WaitGroup - - // Trigger ERC20 TopUps - for tokenHexAddress, vegaPubKeys := range traders.ByERC20TokenHexAddress { - wg.Add(1) - go func(tokenHexAddress string, vegaPubKeys []string) { - defer wg.Done() - err := depositERC20TokenToParties(network, tokenHexAddress, vegaPubKeys, big.NewFloat(1000000000), args.Logger) - if err != nil { - resultsChannel <- err - } - }(tokenHexAddress, vegaPubKeys) - } - // Trigger Fake Assets TopUps - for assetId, vegaPubKeys := range traders.ByFakeAssetId { - asset, assetFound := networkAssets[assetId] - if !assetFound { - return fmt.Errorf("given asset %s not found in list of supported fake assets to top up", assetId) - } - wg.Add(1) - go func(assetId string, asset *vega.AssetDetails, vegaPubKeys []string) { - defer wg.Done() - err := depositFakeAssetToParties(networktools, assetId, asset, vegaPubKeys, big.NewFloat(1000000), args.Logger) - resultsChannel <- err - }(assetId, asset, vegaPubKeys) - } - wg.Wait() - close(resultsChannel) - - failed := false - for err := range resultsChannel { - //for _, err := range network.AssetMainWallet.WaitForQueue() { - if err != nil { - failed = true - args.Logger.Error("transaciton failed", zap.Error(err)) - } - } - if failed { - return fmt.Errorf("failed to top up all the parties") - } - fmt.Printf("DONE\n") - return nil -} diff --git a/cmd/topup/with_transfer.go b/cmd/topup/with_transfer.go index f6aed783..1848687c 100644 --- a/cmd/topup/with_transfer.go +++ b/cmd/topup/with_transfer.go @@ -1,31 +1,37 @@ package topup import ( + "encoding/hex" "fmt" "log" "math/big" + "math/rand" "os" "strconv" "strings" "time" - "code.vegaprotocol.io/vega/protos/vega" - vegaapipb "code.vegaprotocol.io/vega/protos/vega/api/v1" - vegacmd "code.vegaprotocol.io/vega/protos/vega/commands/v1" - v1 "code.vegaprotocol.io/vega/protos/vega/wallet/v1" - "github.com/hashicorp/go-multierror" - "github.com/spf13/cobra" "github.com/vegaprotocol/devopstools/bots" + "github.com/vegaprotocol/devopstools/ethutils" "github.com/vegaprotocol/devopstools/governance" "github.com/vegaprotocol/devopstools/tools" "github.com/vegaprotocol/devopstools/vegaapi" "github.com/vegaprotocol/devopstools/veganetwork" "github.com/vegaprotocol/devopstools/wallet" + + "code.vegaprotocol.io/vega/protos/vega" + vegaapipb "code.vegaprotocol.io/vega/protos/vega/api/v1" + vegacmd "code.vegaprotocol.io/vega/protos/vega/commands/v1" + v1 "code.vegaprotocol.io/vega/protos/vega/wallet/v1" + + "github.com/ethereum/go-ethereum/accounts/abi/bind" + ethTypes "github.com/ethereum/go-ethereum/core/types" + "github.com/hashicorp/go-multierror" + "github.com/spf13/cobra" "go.uber.org/zap" ) const ( - DefaultTopUpValue = 10000 TraderTopUpFactor = 3.0 WhaleTopUpFactor = 10.0 ) @@ -45,7 +51,7 @@ var topUpWithTransferCmd = &cobra.Command{ Long: `TopUp parties on network with vega transfer`, Run: func(cmd *cobra.Command, args []string) { if err := RunTopUpWithTransfer(topUpWithTransferArgs); err != nil { - traderbotArgs.Logger.Error("Error", zap.Error(err)) + topUpWithTransferArgs.Logger.Error("Error", zap.Error(err)) os.Exit(1) } }, @@ -214,7 +220,6 @@ func prepareNetworkForTransfer(logger *zap.Logger, network *veganetwork.VegaNetw updateCount, err := governance.ProposeAndVoteOnNetworkParameters( updateParams, network.VegaTokenWhale, network.NetworkParams, network.DataNodeClient, logger, ) - if err != nil { return fmt.Errorf("failed to propose and vote on network parameters: %w", err) } @@ -335,7 +340,6 @@ func transferMoneyFromWhaleToBots( }, }, }, lastBlockData) - if err != nil { logger.Error( "failed to sign transaction with PoW", @@ -360,7 +364,6 @@ func transferMoneyFromWhaleToBots( Tx: signedTransaction, Type: vegaapipb.SubmitTransactionRequest_TYPE_SYNC, }) - if err != nil { logger.Error( "failed to send the signed transaction", @@ -579,3 +582,152 @@ func necessaryTopUp(currentBalance, wantedBalance, factor float64) float64 { // top up not required return 0 } + +func depositERC20TokenToParties( + network *veganetwork.VegaNetwork, + tokenHexAddress string, + vegaPubKeys []string, + humanDepositAmount *big.Float, // in full tokens, i.e. without decimals zeros + logger *zap.Logger, +) error { + // + // Setup + // + var ( + errMsg = fmt.Sprintf("failed to deposit %s to %d parites on %s network", tokenHexAddress, len(vegaPubKeys), network.Network) + minterWallet = network.NetworkMainWallet + erc20bridge = network.SmartContracts.ERC20Bridge + flowId = rand.Int() + ) + token, err := network.SmartContractsManager.GetAssetWithAddress(tokenHexAddress) + if err != nil { + return fmt.Errorf("failed to get token %s, %s: %w", tokenHexAddress, errMsg, err) + } + tokenInfo, err := token.GetInfo() + if err != nil { + return fmt.Errorf("failed to get token info %s, %s: %w", tokenHexAddress, errMsg, err) + } + logger.Info("deposit", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name), + zap.String("token-address", token.Address.Hex()), zap.String("erc20bridge", erc20bridge.Address.Hex()), + zap.String("minter", minterWallet.Address.Hex()), zap.String("amount-per-party", humanDepositAmount.String()), + zap.Int("party-count", len(vegaPubKeys)), zap.Any("parties", vegaPubKeys)) + + // + // Mint enough tokens and Increase Allowance + // + var ( + humanTotalDepositAmount = new(big.Float).Mul(humanDepositAmount, big.NewFloat(float64(len(vegaPubKeys)))) + totalDepositAmount = ethutils.TokenFromFullTokens(humanTotalDepositAmount, tokenInfo.Decimals) + balance *big.Int + allowance *big.Int + mintTx *ethTypes.Transaction + allowanceTx *ethTypes.Transaction + ) + balance, err = token.BalanceOf(&bind.CallOpts{}, minterWallet.Address) + if err != nil { + return fmt.Errorf("failed to get %s balance of minter %s, %s: %w", tokenInfo.Name, minterWallet.Address.Hex(), errMsg, err) + } + if balance.Cmp(totalDepositAmount) < 0 { + diff := new(big.Int).Sub(totalDepositAmount, balance) + opts := minterWallet.GetTransactOpts() + logger.Info("minting", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name), + zap.String("minter", minterWallet.Address.Hex()), + zap.String("balance", balance.String()), zap.String("mint-amount", diff.String()), + zap.String("required", totalDepositAmount.String())) + mintTx, err = token.Mint(opts, minterWallet.Address, diff) + if err != nil { + return fmt.Errorf("failed to mint, %s: %w", errMsg, err) + } + } else { + logger.Info("no need to mint", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name), + zap.String("minter", minterWallet.Address.Hex()), + zap.String("balance", balance.String()), zap.String("required", totalDepositAmount.String())) + } + allowance, err = token.Allowance(&bind.CallOpts{}, minterWallet.Address, erc20bridge.Address) + if err != nil { + return fmt.Errorf("failed to get allowance, %s: %w", errMsg, err) + } + if allowance.Cmp(totalDepositAmount) < 0 { + diff := new(big.Int).Sub(totalDepositAmount, allowance) + opts := minterWallet.GetTransactOpts() + logger.Info("increasing allowance", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name), + zap.String("minter", minterWallet.Address.Hex()), + zap.String("allowance", allowance.String()), zap.String("increasing-by", diff.String()), + zap.String("required", totalDepositAmount.String())) + allowanceTx, err = token.IncreaseAllowance(opts, erc20bridge.Address, diff) + if err != nil { + return fmt.Errorf("failed to increase allowance, %s: %w", errMsg, err) + } + } else { + logger.Info("no need to increasing allowance", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name), + zap.String("minter", minterWallet.Address.Hex()), + zap.String("allowance", allowance.String()), zap.String("required", totalDepositAmount.String())) + } + // wait + if mintTx != nil { + if err = ethutils.WaitForTransaction(network.EthClient, mintTx, time.Minute); err != nil { + logger.Error("failed to mint", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name), zap.Error(err)) + return fmt.Errorf("transaction failed to mint, %s: %w", errMsg, err) + } + logger.Info("successfully minted", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name)) + } + if allowanceTx != nil { + if err = ethutils.WaitForTransaction(network.EthClient, allowanceTx, time.Minute); err != nil { + logger.Error("failed to increase allowance", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name), zap.Error(err)) + return fmt.Errorf("transaction failed to increase allowance, %s: %w", errMsg, err) + } + logger.Info("successfully increased allowance", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name)) + } + + // + // DEPOSIT to ERC20 Bridge + // + var ( + depositTxs = make([]*ethTypes.Transaction, len(vegaPubKeys)) + depositAmount = ethutils.TokenFromFullTokens(humanDepositAmount, tokenInfo.Decimals) + success, failure int + ) + for i, pubKey := range vegaPubKeys { + bytePubKey, err := hex.DecodeString(pubKey) + if err != nil { + return err + } + var byte32PubKey [32]byte + copy(byte32PubKey[:], bytePubKey) + + opts := minterWallet.GetTransactOpts() + logger.Debug("depositing", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name), + zap.String("vegaPubKey", pubKey), zap.String("amount", depositAmount.String())) + depositTxs[i], err = erc20bridge.DepositAsset(opts, token.Address, depositAmount, byte32PubKey) + + if err != nil { + failure += 1 + logger.Error("failed to deposit", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name), + zap.String("vegaPubKey", pubKey), zap.String("amount", depositAmount.String()), + zap.Error(err)) + } + } + // wait + for i, tx := range depositTxs { + if tx == nil { + continue + } + logger.Debug("waiting", zap.Any("tx", tx)) + if err = ethutils.WaitForTransaction(network.EthClient, tx, time.Minute); err != nil { + failure += 1 + logger.Error("failed to deposit", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name), + zap.Any("tx", tx), + zap.String("vegaPubKey", vegaPubKeys[i]), zap.String("amount", depositAmount.String()), zap.Error(err)) + } else { + success += 1 + logger.Debug("successfully deposited", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name), + zap.String("vegaPubKey", vegaPubKeys[i]), zap.String("amount", depositAmount.String())) + } + } + logger.Info("Summary", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name), + zap.Int("success-count", success), zap.Int("fail-count", failure)) + if failure > 0 { + return fmt.Errorf("%s", errMsg) + } + return nil +} diff --git a/cmd/validator/join.go b/cmd/validator/join.go index 9060f1cf..6158130e 100644 --- a/cmd/validator/join.go +++ b/cmd/validator/join.go @@ -6,16 +6,18 @@ import ( "math/big" "os" - "code.vegaprotocol.io/vega/protos/vega" - vegaapipb "code.vegaprotocol.io/vega/protos/vega/api/v1" - commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" - walletpb "code.vegaprotocol.io/vega/protos/vega/wallet/v1" - "github.com/spf13/cobra" "github.com/vegaprotocol/devopstools/generate" "github.com/vegaprotocol/devopstools/networktools" "github.com/vegaprotocol/devopstools/secrets" "github.com/vegaprotocol/devopstools/types" "github.com/vegaprotocol/devopstools/wallet" + + "code.vegaprotocol.io/vega/protos/vega" + vegaapipb "code.vegaprotocol.io/vega/protos/vega/api/v1" + commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" + walletpb "code.vegaprotocol.io/vega/protos/vega/wallet/v1" + + "github.com/spf13/cobra" "go.uber.org/zap" ) diff --git a/cmd/validator/root.go b/cmd/validator/root.go index d520fb94..df4bdbda 100644 --- a/cmd/validator/root.go +++ b/cmd/validator/root.go @@ -1,8 +1,9 @@ package validator import ( - "github.com/spf13/cobra" rootCmd "github.com/vegaprotocol/devopstools/cmd" + + "github.com/spf13/cobra" ) type ValidatorArgs struct { diff --git a/cmd/vegacapsule/get_live_binary.go b/cmd/vegacapsule/get_live_binary.go index 02598e1a..bbf520bb 100644 --- a/cmd/vegacapsule/get_live_binary.go +++ b/cmd/vegacapsule/get_live_binary.go @@ -5,9 +5,10 @@ import ( "os" "path/filepath" - "github.com/spf13/cobra" "github.com/vegaprotocol/devopstools/tools" vctools "github.com/vegaprotocol/devopstools/vegacapsule" + + "github.com/spf13/cobra" "go.uber.org/zap" ) @@ -63,7 +64,6 @@ func init() { "If true, binary is removed when exists") VegacapsuleCmd.AddCommand(getLiveBInaryCmd) - } func copyBiinaryTo(logger *zap.Logger, binaryPath, outputFile string, overwrite bool) error { diff --git a/cmd/vegacapsule/root.go b/cmd/vegacapsule/root.go index aea00af4..5bf21032 100644 --- a/cmd/vegacapsule/root.go +++ b/cmd/vegacapsule/root.go @@ -1,8 +1,9 @@ package vegacapsule import ( - "github.com/spf13/cobra" rootCmd "github.com/vegaprotocol/devopstools/cmd" + + "github.com/spf13/cobra" ) type VegacapsuleArgs struct { diff --git a/cmd/vegacapsule/start_datanode_from_network_history.go b/cmd/vegacapsule/start_datanode_from_network_history.go index 227deec6..bf0ae441 100644 --- a/cmd/vegacapsule/start_datanode_from_network_history.go +++ b/cmd/vegacapsule/start_datanode_from_network_history.go @@ -10,16 +10,17 @@ import ( "strconv" "time" + "github.com/vegaprotocol/devopstools/tools" + "github.com/vegaprotocol/devopstools/vegaapi" + "github.com/vegaprotocol/devopstools/vegaapi/datanode" + vctools "github.com/vegaprotocol/devopstools/vegacapsule" + v1 "code.vegaprotocol.io/vega/protos/vega/events/v1" + "github.com/spf13/cobra" "github.com/tomwright/dasel" "github.com/tomwright/dasel/storage" "go.uber.org/zap" - - "github.com/vegaprotocol/devopstools/tools" - "github.com/vegaprotocol/devopstools/vegaapi" - "github.com/vegaprotocol/devopstools/vegaapi/datanode" - vctools "github.com/vegaprotocol/devopstools/vegacapsule" ) type StartDataNodeFromNetworkHistoryArgs struct { @@ -54,7 +55,6 @@ var startDataNodeFromNetworkHistoryCmd = &cobra.Command{ startDataNodeFromNetworkHistoryArgs.networkHomePath, startDataNodeFromNetworkHistoryArgs.waitForReplay, startDataNodeFromNetworkHistoryArgs.outFile) - if err != nil { startDataNodeFromNetworkHistoryArgs.Logger.Error("Error", zap.Error(err)) os.Exit(1) @@ -153,7 +153,6 @@ func startDataNodeFromNetworkHistory(logger *zap.Logger, vegacapsuleBinary, base newNodeDetails, err := vctools.AddNodes(logger, vegacapsuleBinary, vctools.AddNodesBaseOn{ Group: baseOnGroup, }, false, networkHomePath) - if err != nil { return fmt.Errorf("failed to add new node to the vegacapsule: %w", err) } @@ -327,8 +326,6 @@ func wait(logger *zap.Logger, ctx context.Context, checker func() error) error { } func checkHistorySegments(logger *zap.Logger, client vegaapi.DataNodeClient) func() error { - const minHistorySegments = 1 - return func() error { segment, err := client.LastNetworkHistorySegment() if err != nil { @@ -370,7 +367,6 @@ func checkSnapshots(client vegaapi.DataNodeClient, minimumSnapshotBlock uint64) // We do not have minimum number of snapshots if len(snapshots) < requiredSnapshots { - return fmt.Errorf("not enough snapshots, %d required, %d at the moment", requiredSnapshots, len(snapshots)) } @@ -457,7 +453,6 @@ func DescribeDataNode(logger *zap.Logger, nodeDetails vctools.NodeDetails, outFi result.GRPCURL = fmt.Sprintf("127.0.0.1:%s", grpcPort) data, err := json.Marshal(result) - if err != nil { return fmt.Errorf("failed to marshal new data-node details: %w", err) } diff --git a/etherscan/clinet.go b/etherscan/clinet.go index 8f8ac719..0e63cbb8 100644 --- a/etherscan/clinet.go +++ b/etherscan/clinet.go @@ -5,6 +5,7 @@ import ( "time" "github.com/vegaprotocol/devopstools/types" + "golang.org/x/time/rate" ) diff --git a/etherscan/data.go b/etherscan/data.go index 781f8a58..751b74ae 100644 --- a/etherscan/data.go +++ b/etherscan/data.go @@ -9,9 +9,7 @@ import ( "strings" ) -// // Helper: Get Smart Contract Data -// type SmartContractData struct { SourceCode map[string]string ABI string @@ -87,7 +85,7 @@ func parseSourceCode(ContractName string, sourceCode string) (map[string]string, } payload = payload2.Sources } - var result = map[string]string{} + result := map[string]string{} for name, data := range payload { name = filepath.Base(name) diff --git a/etherscan/getsourcecode.go b/etherscan/getsourcecode.go index ab0784d5..2fb6f892 100644 --- a/etherscan/getsourcecode.go +++ b/etherscan/getsourcecode.go @@ -7,9 +7,7 @@ import ( "net/http" ) -// // API: contract -> getsourcecode -// type EtherscanGetSourcecodeResponse struct { Status string `json:"status"` Message string `json:"message"` diff --git a/etherscan/txlist.go b/etherscan/txlist.go index 39eae58a..611934c3 100644 --- a/etherscan/txlist.go +++ b/etherscan/txlist.go @@ -7,9 +7,7 @@ import ( "net/http" ) -// // API: account -> txlist -// type EtherscanGetTxlistResponse struct { Status string `json:"status"` Message string `json:"message"` diff --git a/ethutils/clientmanager.go b/ethutils/clientmanager.go index 933cce71..e40468c4 100644 --- a/ethutils/clientmanager.go +++ b/ethutils/clientmanager.go @@ -5,10 +5,11 @@ import ( "fmt" "sync" - "github.com/ethereum/go-ethereum/ethclient" "github.com/vegaprotocol/devopstools/etherscan" "github.com/vegaprotocol/devopstools/secrets" "github.com/vegaprotocol/devopstools/types" + + "github.com/ethereum/go-ethereum/ethclient" ) type EthereumClientManager struct { @@ -31,7 +32,6 @@ func (m *EthereumClientManager) GetEthereumURL(ethNetwork types.ETHNetwork) (str var ethereumURL string switch ethNetwork { - case types.ETHMainnet, types.ETHSepolia, types.ETHGoerli, types.ETHRopsten: if m.serviceSecrets == nil { return "", fmt.Errorf("failed to get Ethereum URL for %s, Service Secret Store not provided", ethNetwork) diff --git a/ethutils/deploy.go b/ethutils/deploy.go index 00f85098..cc46c5f4 100644 --- a/ethutils/deploy.go +++ b/ethutils/deploy.go @@ -16,7 +16,6 @@ func ConfirmContractDeployed( address common.Address, ) error { _, err := bind.WaitDeployed(ctx, client, tx) - if err != nil { return fmt.Errorf("failed to deploy Smart Contract, %w", err) } diff --git a/ethutils/pull.go b/ethutils/pull.go index 3604d0e6..080a7b90 100644 --- a/ethutils/pull.go +++ b/ethutils/pull.go @@ -6,10 +6,11 @@ import ( "os" "path/filepath" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/ethclient" "github.com/vegaprotocol/devopstools/etherscan" "github.com/vegaprotocol/devopstools/types" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/ethclient" ) func PullAndStoreSmartContractImmutableData( @@ -73,9 +74,7 @@ func PullSmartContractImmutableData( name string, hexAddress string, ) (*SmartContractImmutableData, error) { - var ( - address = common.HexToAddress(hexAddress) - ) + address := common.HexToAddress(hexAddress) // Fetch Byte Code byteCode, err := ethClient.CodeAt(context.Background(), address, nil) @@ -134,39 +133,39 @@ func storeSmartContractImmutableData( return fmt.Errorf("failed to create directory %s. %w", dir, err) } - if err = os.WriteFile(downloadURLFile, []byte(data.DownloadURL), 0644); err != nil { + if err = os.WriteFile(downloadURLFile, []byte(data.DownloadURL), 0o644); err != nil { return fmt.Errorf("failed to write Download URL to file %s for %s. %w", downloadURLFile, name, err) } // Save Source Code for sourceCodeName, sourceCode := range data.SourceCode { sourceCodeFile := filepath.Join(dir, sourceCodeName) - if err = os.WriteFile(sourceCodeFile, []byte(sourceCode), 0644); err != nil { + if err = os.WriteFile(sourceCodeFile, []byte(sourceCode), 0o644); err != nil { return fmt.Errorf("failed to write Source Code to file %s for %s. %w", sourceCodeFile, name, err) } fmt.Printf("- %s: updated Source Code: %s\n", name, sourceCodeFile) } // Save Byte Code - if err = os.WriteFile(binaryFile, []byte(data.CreationHexByteCode[2:]), 0644); err != nil { + if err = os.WriteFile(binaryFile, []byte(data.CreationHexByteCode[2:]), 0o644); err != nil { return fmt.Errorf("failed to write Byte Code to file %s for %s. %w", binaryFile, name, err) } fmt.Printf("- %s: updated Binary Code: %s\n", name, binaryFile) // Save Byte Code Hash - if err = os.WriteFile(hashFile, []byte(data.ByteCodeHash), 0644); err != nil { + if err = os.WriteFile(hashFile, []byte(data.ByteCodeHash), 0o644); err != nil { return fmt.Errorf("failed to write Byte Code Hash to file %s for %s. %w", hashFile, name, err) } fmt.Printf("- %s: updated Hash: %s\n", name, hashFile) // Save ABI - if err = os.WriteFile(abiFile, []byte(data.ABI), 0644); err != nil { + if err = os.WriteFile(abiFile, []byte(data.ABI), 0o644); err != nil { return fmt.Errorf("failed to write ABI to file %s for %s. %w", abiFile, name, err) } fmt.Printf("- %s: updated ABI: %s\n", name, abiFile) // Save Go Bindings - if err = os.WriteFile(goBindingsFile, []byte(data.GoBindings), 0644); err != nil { + if err = os.WriteFile(goBindingsFile, []byte(data.GoBindings), 0o644); err != nil { return fmt.Errorf("failed to write Go Bindings to file %s for %s. %w", goBindingsFile, name, err) } fmt.Printf("- %s: updated Go Bindings: %s\n", name, goBindingsFile) diff --git a/ethutils/transfereth.go b/ethutils/transfereth.go index 4c889fc5..989303eb 100644 --- a/ethutils/transfereth.go +++ b/ethutils/transfereth.go @@ -29,9 +29,7 @@ func TransferEthNoWaitWithNonce( amount *big.Int, nonce uint64, ) (*ethTypes.Transaction, error) { - var ( - errMsg = "failed to send ethereum transaction, %w" - ) + errMsg := "failed to send ethereum transaction, %w" transactionData, err := GetNextTransactionData(ethClient) if err != nil { @@ -46,7 +44,7 @@ func TransferEthNoWaitWithNonce( Gas: uint64(21000), // gas limit for a standard ETH transfer is 21000 units To: &toAddress, Value: amount, - //Data: txData, + // Data: txData, }) signedTx, err := ethTypes.SignTx(tx, types.NewLondonSigner(transactionData.chainID), fromPrivateKey) diff --git a/generate/binarywallets.go b/generate/binarywallets.go index 86476aa1..ef0f303b 100644 --- a/generate/binarywallets.go +++ b/generate/binarywallets.go @@ -10,14 +10,16 @@ import ( "path" "strings" + "github.com/vegaprotocol/devopstools/secrets" + "code.vegaprotocol.io/vega/core/nodewallets" "code.vegaprotocol.io/vega/core/nodewallets/registry" "code.vegaprotocol.io/vega/paths" "code.vegaprotocol.io/vega/wallet/wallet" "code.vegaprotocol.io/vega/wallet/wallets" + "github.com/ethereum/go-ethereum/accounts/keystore" "github.com/ethereum/go-ethereum/crypto" - "github.com/vegaprotocol/devopstools/secrets" ) func CreateBinaryWallets( @@ -43,7 +45,7 @@ func CreateBinaryWallets( if err != nil { return nil, err } - //fmt.Printf("nodewalletPath=%+v\n", nodewalletPath) + // fmt.Printf("nodewalletPath=%+v\n", nodewalletPath) // // Tendermint Key @@ -54,7 +56,7 @@ func CreateBinaryWallets( if err != nil { return nil, err } - //fmt.Printf("ImportTendermintPubkey=%+v\n", data) + // fmt.Printf("ImportTendermintPubkey=%+v\n", data) // // VegaWallet @@ -70,9 +72,9 @@ func CreateBinaryWallets( if err != nil { return nil, err } - //fmt.Printf("ImportVegaWallet=%+v\n", data) + // fmt.Printf("ImportVegaWallet=%+v\n", data) vegaWalletPath = data["walletFilePath"] - //fmt.Printf("vegaWalletPath=%+v\n", vegaWalletPath) + // fmt.Printf("vegaWalletPath=%+v\n", vegaWalletPath) // // Ethereum wallet @@ -89,9 +91,9 @@ func CreateBinaryWallets( if err != nil { return nil, err } - //fmt.Printf("ImportEthereumWallet=%+v\n", data) + // fmt.Printf("ImportEthereumWallet=%+v\n", data) ethWalletPath = data["walletFilePath"] - //fmt.Printf("ethWalletPath=%+v\n", ethWalletPath) + // fmt.Printf("ethWalletPath=%+v\n", ethWalletPath) nodewalletBase64, err := encodeToBase64(nodewalletPath) if err != nil { @@ -125,7 +127,7 @@ func createNodewallet( return "", err } nodewalletPath := nodewalletRegistry.RegistryFilePath() - //fmt.Printf("nodewalletPath=%s\n", nodewalletPath) + // fmt.Printf("nodewalletPath=%s\n", nodewalletPath) return nodewalletPath, nil } @@ -135,7 +137,6 @@ func createVegawallet( vegaHome string, walletPassphrase string, ) (string, error) { - // create a wallet with name vegaWalletName := "isolatedValidatorWallet" vegaWallet, err := wallet.ImportHDWallet(vegaWalletName, vegaWalletRecoveryPhrase, wallet.LatestVersion) @@ -161,10 +162,10 @@ func createVegawallet( if err != nil { return "", err } - //fmt.Printf("wallet.ID()=%+v\n", wallet) + // fmt.Printf("wallet.ID()=%+v\n", wallet) // get path of the new wallet in store vegaWalletPath := vegaWalletStore.GetWalletPath(vegaWalletName) - //fmt.Printf("vegaWalletPath=%v\n", vegaWalletPath) + // fmt.Printf("vegaWalletPath=%v\n", vegaWalletPath) return vegaWalletPath, nil } @@ -174,7 +175,6 @@ func createEthereumWallet( vegaHome string, walletPassphrase string, ) (string, error) { - ethPrivateKey, err := crypto.HexToECDSA(ethereumPrivateKey) if err != nil { return "", err @@ -198,7 +198,7 @@ func createEthereumWallet( if err := os.Rename(ethWalletOrigPath, ethWalletPath); err != nil { return "", err } - //fmt.Printf("ethWalletPath=%v\n", ethWalletPath) + // fmt.Printf("ethWalletPath=%v\n", ethWalletPath) return ethWalletPath, nil } diff --git a/generate/dehistory.go b/generate/dehistory.go index 9c6040cb..5d22858c 100644 --- a/generate/dehistory.go +++ b/generate/dehistory.go @@ -6,8 +6,8 @@ import ( "encoding/base64" "github.com/ipfs/kubo/config" - "github.com/libp2p/go-libp2p-core/crypto" - "github.com/libp2p/go-libp2p-core/peer" + "github.com/libp2p/go-libp2p/core/crypto" + "github.com/libp2p/go-libp2p/core/peer" ) func GenerateDeHistoryIdentity(seed string) (config.Identity, error) { diff --git a/generate/ethereumwallet.go b/generate/ethereumwallet.go index 8d511e7f..08e37cff 100644 --- a/generate/ethereumwallet.go +++ b/generate/ethereumwallet.go @@ -4,10 +4,11 @@ import ( "encoding/hex" "fmt" + "github.com/vegaprotocol/devopstools/secrets" + "github.com/cosmos/go-bip39" "github.com/ethereum/go-ethereum/crypto" hdwallet "github.com/miguelmota/go-ethereum-hdwallet" - "github.com/vegaprotocol/devopstools/secrets" ) func GenerateNewEthereumWallet() (*secrets.EthereumWalletPrivate, error) { diff --git a/generate/name.go b/generate/name.go index 8546ed0b..bb2a3cfd 100644 --- a/generate/name.go +++ b/generate/name.go @@ -105,9 +105,7 @@ func GenerateAvatarURL() (string, error) { } func GenerateRandomWikiURL() (string, error) { - var ( - errMsg = "failed to generate random wiki url" - ) + errMsg := "failed to generate random wiki url" req, err := http.NewRequest(http.MethodGet, "https://en.wikipedia.org/wiki/Special:Random", nil) if err != nil { return "", fmt.Errorf("%s, %w", errMsg, err) @@ -125,7 +123,7 @@ func GenerateRandomWikiURL() (string, error) { return "", fmt.Errorf("%s, %w", errMsg, err) } defer response.Body.Close() - if response.StatusCode == http.StatusFound { //status code 302 + if response.StatusCode == http.StatusFound { // status code 302 url, err := response.Location() if err != nil { return "", fmt.Errorf("%s, %w", errMsg, err) diff --git a/generate/nodesecrets.go b/generate/nodesecrets.go index c551f6c9..254029fb 100644 --- a/generate/nodesecrets.go +++ b/generate/nodesecrets.go @@ -7,7 +7,6 @@ import ( ) func GenerateVegaNodeSecrets() (*secrets.VegaNodePrivate, error) { - metadata, err := GenerateNodeMetadata() if err != nil { return nil, err diff --git a/generate/vegawallet.go b/generate/vegawallet.go index 8c4e00de..283f963e 100644 --- a/generate/vegawallet.go +++ b/generate/vegawallet.go @@ -3,8 +3,9 @@ package generate import ( "fmt" - "code.vegaprotocol.io/vega/wallet/wallet" "github.com/vegaprotocol/devopstools/secrets" + + "code.vegaprotocol.io/vega/wallet/wallet" ) func GenerateVegaWallet() (*secrets.VegaWalletPrivate, error) { @@ -29,7 +30,6 @@ func ValidateVegawalletIdAndPubKeyAndPrivKeyWithRecoveryPhrase( id string, publicKey string, privateKey string, recoveryPhrase string, ) error { vegaWallet, err := wallet.ImportHDWallet("my wallet", recoveryPhrase, wallet.LatestVersion) - if err != nil { return fmt.Errorf("failed to get vegawallet with recovery phrase %w", err) } diff --git a/go.mod b/go.mod index 5d96f9d1..5500ca37 100644 --- a/go.mod +++ b/go.mod @@ -5,14 +5,13 @@ go 1.21 toolchain go1.21.5 require ( - code.vegaprotocol.io/shared v0.0.0-20221010085458-55c50711135f code.vegaprotocol.io/vega v0.75.1 github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d github.com/ethereum/go-ethereum v1.11.6 github.com/hashicorp/go-multierror v1.1.1 github.com/hashicorp/vault/api v1.8.1 github.com/ipfs/kubo v0.23.0 - github.com/libp2p/go-libp2p-core v0.20.1 + github.com/libp2p/go-libp2p v0.31.0 github.com/miguelmota/go-ethereum-hdwallet v0.1.1 github.com/pelletier/go-toml v1.9.5 github.com/spf13/cobra v1.8.0 @@ -124,7 +123,6 @@ require ( github.com/klauspost/compress v1.17.0 // indirect github.com/klauspost/cpuid/v2 v2.2.5 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect - github.com/libp2p/go-libp2p v0.31.0 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.19 // indirect diff --git a/go.sum b/go.sum index 4213116a..1744a378 100644 --- a/go.sum +++ b/go.sum @@ -16,8 +16,6 @@ cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2k cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= -code.vegaprotocol.io/shared v0.0.0-20221010085458-55c50711135f h1:ivaWSXN7XKESShqYw/QFuT6b2mvThWPQLO7lW5sadHs= -code.vegaprotocol.io/shared v0.0.0-20221010085458-55c50711135f/go.mod h1:XzX67GsyOHzvytMr0QOHX4CCTdCZDYKUUi88rx40Nt0= code.vegaprotocol.io/vega v0.75.1 h1:2oT1bfYfM9gxh1lCINhR/vStffXfqx00W2CB0f7J93c= code.vegaprotocol.io/vega v0.75.1/go.mod h1:BsCaA1w1yC5MOrsuGx8VJWih59sKmq1xCt6Gd1hsrbw= collectd.org v0.3.0/go.mod h1:A/8DzQBkF6abtvrT2j/AU/4tiBgJWYyh0y/oB/4MlWE= @@ -569,8 +567,6 @@ github.com/libp2p/go-libp2p v0.31.0 h1:LFShhP8F6xthWiBBq3euxbKjZsoRajVEyBS9snfHx github.com/libp2p/go-libp2p v0.31.0/go.mod h1:W/FEK1c/t04PbRH3fA9i5oucu5YcgrG0JVoBWT1B7Eg= github.com/libp2p/go-libp2p-asn-util v0.3.0 h1:gMDcMyYiZKkocGXDQ5nsUQyquC9+H+iLEQHwOCZ7s8s= github.com/libp2p/go-libp2p-asn-util v0.3.0/go.mod h1:B1mcOrKUE35Xq/ASTmQ4tN3LNzVVaMNmq2NACuqyB9w= -github.com/libp2p/go-libp2p-core v0.20.1 h1:fQz4BJyIFmSZAiTbKV8qoYhEH5Dtv/cVhZbG3Ib/+Cw= -github.com/libp2p/go-libp2p-core v0.20.1/go.mod h1:6zR8H7CvQWgYLsbG4on6oLNSGcyKaYFSEYyDt51+bIY= github.com/libp2p/go-libp2p-record v0.2.0 h1:oiNUOCWno2BFuxt3my4i1frNrt7PerzB3queqa1NkQ0= github.com/libp2p/go-libp2p-record v0.2.0/go.mod h1:I+3zMkvvg5m2OcSdoL0KPljyJyvNDFGKX7QdlpYUcwk= github.com/libp2p/go-libp2p-testing v0.12.0 h1:EPvBb4kKMWO29qP4mZGyhVzUyR25dvfUIK5WDu6iPUA= diff --git a/go1.21.6.linux-amd64.tar.gz b/go1.21.6.linux-amd64.tar.gz deleted file mode 100644 index 228cb49f..00000000 Binary files a/go1.21.6.linux-amd64.tar.gz and /dev/null differ diff --git a/governance/assets/proposals.go b/governance/assets/proposals.go index 34abca6a..94044347 100644 --- a/governance/assets/proposals.go +++ b/governance/assets/proposals.go @@ -5,9 +5,10 @@ import ( "math/big" "time" + "github.com/vegaprotocol/devopstools/tools" + "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" - "github.com/vegaprotocol/devopstools/tools" ) type AssetProposalDetails struct { diff --git a/governance/batch_proposal.go b/governance/batch_proposal.go index 8bfc4c44..dc40821b 100644 --- a/governance/batch_proposal.go +++ b/governance/batch_proposal.go @@ -4,9 +4,10 @@ import ( "fmt" "time" + "github.com/vegaprotocol/devopstools/tools" + "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" - "github.com/vegaprotocol/devopstools/tools" ) // NewBatchProposal either proposals or batchTerms can be nil @@ -24,7 +25,7 @@ func NewBatchProposal( for i, v := range proposals { if time.Unix(v.Terms.EnactmentTimestamp, 0).Before(closingTime) { - panic(fmt.Sprintf("proposal at index %v enact() before batching close() time", i, v.Terms.EnactmentTimestamp, closingTime.Unix())) + panic(fmt.Sprintf("proposal at index %v enact(%v) before batching close(%v) time", i, v.Terms.EnactmentTimestamp, closingTime.Unix())) } change := &vega.BatchProposalTermsChange{ @@ -33,27 +34,27 @@ func NewBatchProposal( switch ch := v.Terms.Change.(type) { case *vega.ProposalTerms_UpdateMarket: - change.Change = &vega.BatchProposalTermsChange_UpdateMarket{ch.UpdateMarket} + change.Change = &vega.BatchProposalTermsChange_UpdateMarket{UpdateMarket: ch.UpdateMarket} case *vega.ProposalTerms_NewMarket: - change.Change = &vega.BatchProposalTermsChange_NewMarket{ch.NewMarket} + change.Change = &vega.BatchProposalTermsChange_NewMarket{NewMarket: ch.NewMarket} case *vega.ProposalTerms_UpdateNetworkParameter: - change.Change = &vega.BatchProposalTermsChange_UpdateNetworkParameter{ch.UpdateNetworkParameter} + change.Change = &vega.BatchProposalTermsChange_UpdateNetworkParameter{UpdateNetworkParameter: ch.UpdateNetworkParameter} case *vega.ProposalTerms_NewFreeform: - change.Change = &vega.BatchProposalTermsChange_NewFreeform{ch.NewFreeform} + change.Change = &vega.BatchProposalTermsChange_NewFreeform{NewFreeform: ch.NewFreeform} case *vega.ProposalTerms_NewSpotMarket: - change.Change = &vega.BatchProposalTermsChange_NewSpotMarket{ch.NewSpotMarket} + change.Change = &vega.BatchProposalTermsChange_NewSpotMarket{NewSpotMarket: ch.NewSpotMarket} case *vega.ProposalTerms_UpdateSpotMarket: - change.Change = &vega.BatchProposalTermsChange_UpdateSpotMarket{ch.UpdateSpotMarket} + change.Change = &vega.BatchProposalTermsChange_UpdateSpotMarket{UpdateSpotMarket: ch.UpdateSpotMarket} case *vega.ProposalTerms_NewTransfer: - change.Change = &vega.BatchProposalTermsChange_NewTransfer{ch.NewTransfer} + change.Change = &vega.BatchProposalTermsChange_NewTransfer{NewTransfer: ch.NewTransfer} case *vega.ProposalTerms_CancelTransfer: - change.Change = &vega.BatchProposalTermsChange_CancelTransfer{ch.CancelTransfer} + change.Change = &vega.BatchProposalTermsChange_CancelTransfer{CancelTransfer: ch.CancelTransfer} case *vega.ProposalTerms_UpdateMarketState: - change.Change = &vega.BatchProposalTermsChange_UpdateMarketState{ch.UpdateMarketState} + change.Change = &vega.BatchProposalTermsChange_UpdateMarketState{UpdateMarketState: ch.UpdateMarketState} case *vega.ProposalTerms_UpdateReferralProgram: - change.Change = &vega.BatchProposalTermsChange_UpdateReferralProgram{ch.UpdateReferralProgram} + change.Change = &vega.BatchProposalTermsChange_UpdateReferralProgram{UpdateReferralProgram: ch.UpdateReferralProgram} case *vega.ProposalTerms_UpdateVolumeDiscountProgram: - change.Change = &vega.BatchProposalTermsChange_UpdateVolumeDiscountProgram{ch.UpdateVolumeDiscountProgram} + change.Change = &vega.BatchProposalTermsChange_UpdateVolumeDiscountProgram{UpdateVolumeDiscountProgram: ch.UpdateVolumeDiscountProgram} default: panic("unsupported market change in batch") } @@ -63,7 +64,7 @@ func NewBatchProposal( for i, v := range batchTerms { if time.Unix(v.EnactmentTimestamp, 0).Before(closingTime) { - panic(fmt.Sprintf("batch term at index %v enact() before batching close() time", i, v.EnactmentTimestamp, closingTime.Unix())) + panic(fmt.Sprintf("batch term at index %v enact(%v) before batching close(%v) time", i, v.EnactmentTimestamp, closingTime.Unix())) } changes = append(changes, v) diff --git a/governance/combo.go b/governance/combo.go index 283855bf..5eb71972 100644 --- a/governance/combo.go +++ b/governance/combo.go @@ -4,13 +4,15 @@ import ( "fmt" "time" + "github.com/vegaprotocol/devopstools/tools" + "github.com/vegaprotocol/devopstools/vegaapi" + "github.com/vegaprotocol/devopstools/wallet" + v2 "code.vegaprotocol.io/vega/protos/data-node/api/v2" "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" walletpb "code.vegaprotocol.io/vega/protos/vega/wallet/v1" - "github.com/vegaprotocol/devopstools/tools" - "github.com/vegaprotocol/devopstools/vegaapi" - "github.com/vegaprotocol/devopstools/wallet" + "go.uber.org/zap" ) @@ -113,8 +115,8 @@ func ProposeAndVote( logger *zap.Logger, proposerVegawallet *wallet.VegaWallet, dataNodeClient vegaapi.DataNodeClient, - proposal *commandspb.ProposalSubmission) error { - + proposal *commandspb.ProposalSubmission, +) error { reference := proposal.Reference // @@ -163,7 +165,6 @@ func ProposeAndVote( return proposalId, nil }) - if err != nil { return fmt.Errorf("failed to get proposal ID for reference: %s: %w", reference, err) } diff --git a/governance/mainnet_upgrade_batch_proposal.go b/governance/mainnet_upgrade_batch_proposal.go index eba7f691..3717bc36 100644 --- a/governance/mainnet_upgrade_batch_proposal.go +++ b/governance/mainnet_upgrade_batch_proposal.go @@ -3,9 +3,10 @@ package governance import ( "time" - commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" "github.com/vegaprotocol/devopstools/governance/market" "github.com/vegaprotocol/devopstools/governance/networkparameters" + + commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" ) func MainnetUpgradeBatchProposal2( diff --git a/governance/market.go b/governance/market.go index ba092e47..d36ec472 100644 --- a/governance/market.go +++ b/governance/market.go @@ -4,14 +4,16 @@ import ( "fmt" "time" + "github.com/vegaprotocol/devopstools/tools" + "github.com/vegaprotocol/devopstools/vegaapi" + "github.com/vegaprotocol/devopstools/wallet" + v2 "code.vegaprotocol.io/vega/protos/data-node/api/v2" "code.vegaprotocol.io/vega/protos/vega" vegaapipb "code.vegaprotocol.io/vega/protos/vega/api/v1" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" walletpb "code.vegaprotocol.io/vega/protos/vega/wallet/v1" - "github.com/vegaprotocol/devopstools/tools" - "github.com/vegaprotocol/devopstools/vegaapi" - "github.com/vegaprotocol/devopstools/wallet" + "go.uber.org/zap" "golang.org/x/exp/slices" ) @@ -203,7 +205,6 @@ func GetMarket(markets []*vega.Market, marketCode string, metadataTag string, va // } // } // } - } return nil } diff --git a/governance/market/future_btc_usdt.go b/governance/market/future_btc_usdt.go index e1c0e415..c99d3104 100644 --- a/governance/market/future_btc_usdt.go +++ b/governance/market/future_btc_usdt.go @@ -4,10 +4,11 @@ import ( "fmt" "time" + "github.com/vegaprotocol/devopstools/tools" + "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" datav1 "code.vegaprotocol.io/vega/protos/vega/data/v1" - "github.com/vegaprotocol/devopstools/tools" ) const MainnetBTCUSDTMetadataID = "auto:mainnet_btc_usdt" diff --git a/governance/market/future_eth_usdt.go b/governance/market/future_eth_usdt.go index c5f5254e..ad7373ce 100644 --- a/governance/market/future_eth_usdt.go +++ b/governance/market/future_eth_usdt.go @@ -4,10 +4,11 @@ import ( "fmt" "time" + "github.com/vegaprotocol/devopstools/tools" + "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" datav1 "code.vegaprotocol.io/vega/protos/vega/data/v1" - "github.com/vegaprotocol/devopstools/tools" ) const MainnetETHUSDTMetadataID = "auto:mainnet_eth_usdt" diff --git a/governance/market/incentive_btcusd.go b/governance/market/incentive_btcusd.go index e0169237..2faba448 100644 --- a/governance/market/incentive_btcusd.go +++ b/governance/market/incentive_btcusd.go @@ -4,16 +4,19 @@ import ( "fmt" "time" + "github.com/vegaprotocol/devopstools/tools" + "code.vegaprotocol.io/vega/libs/ptr" "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" datav1 "code.vegaprotocol.io/vega/protos/vega/data/v1" - "github.com/vegaprotocol/devopstools/tools" ) -const IncentiveBTCUSD = "auto:incentive_btc_usd" -const IncentiveBTCUSDOracleAddress = "0x1b44F3514812d835EB1BDB0acB33d3fA3351Ee43" -const IncentiveVegaAssetId = "4454ab1ec9d9710b2f8b0f4e24a379c409ef3767e5b2ec90c451873a71fedfa0" +const ( + IncentiveBTCUSD = "auto:incentive_btc_usd" + IncentiveBTCUSDOracleAddress = "0x1b44F3514812d835EB1BDB0acB33d3fA3351Ee43" + IncentiveVegaAssetId = "4454ab1ec9d9710b2f8b0f4e24a379c409ef3767e5b2ec90c451873a71fedfa0" +) func NewBTCUSDIncentiveMarketProposal( settlementVegaAssetId string, diff --git a/governance/market/mainnet_doge_usdt.go b/governance/market/mainnet_doge_usdt.go index e95641b1..e577ba7e 100644 --- a/governance/market/mainnet_doge_usdt.go +++ b/governance/market/mainnet_doge_usdt.go @@ -4,10 +4,11 @@ import ( "fmt" "time" + "github.com/vegaprotocol/devopstools/tools" + "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" datav1 "code.vegaprotocol.io/vega/protos/vega/data/v1" - "github.com/vegaprotocol/devopstools/tools" ) const MainnetDogeUSDTMetadataID = "auto:mainnet_doge_usdt" diff --git a/governance/market/mainnet_link_usdt.go b/governance/market/mainnet_link_usdt.go index 008ef2bd..aa2eeae2 100644 --- a/governance/market/mainnet_link_usdt.go +++ b/governance/market/mainnet_link_usdt.go @@ -4,10 +4,11 @@ import ( "fmt" "time" + "github.com/vegaprotocol/devopstools/tools" + "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" datav1 "code.vegaprotocol.io/vega/protos/vega/data/v1" - "github.com/vegaprotocol/devopstools/tools" ) const MainnetLinkUSDTMetadataID = "auto:mainnet_link_usdt" @@ -27,7 +28,6 @@ func NewMainnetLinkUSDT( enactmentTime time.Time, extraMetadata []string, ) *commandspb.ProposalSubmission { - reference := tools.RandAlphaNumericString(40) nowTime := time.Now() diff --git a/governance/market/mainnet_simulation_btcusdt_perp.go b/governance/market/mainnet_simulation_btcusdt_perp.go index 526c47c1..8a92ac1d 100644 --- a/governance/market/mainnet_simulation_btcusdt_perp.go +++ b/governance/market/mainnet_simulation_btcusdt_perp.go @@ -3,11 +3,13 @@ package market import ( "time" + "github.com/vegaprotocol/devopstools/tools" + "code.vegaprotocol.io/vega/libs/ptr" "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" datav1 "code.vegaprotocol.io/vega/protos/vega/data/v1" - "github.com/vegaprotocol/devopstools/tools" + "google.golang.org/protobuf/types/known/structpb" ) diff --git a/governance/market/mainnet_simulation_ethusdt_perp.go b/governance/market/mainnet_simulation_ethusdt_perp.go index f9f716c4..24c2a983 100644 --- a/governance/market/mainnet_simulation_ethusdt_perp.go +++ b/governance/market/mainnet_simulation_ethusdt_perp.go @@ -3,11 +3,13 @@ package market import ( "time" + "github.com/vegaprotocol/devopstools/tools" + "code.vegaprotocol.io/vega/libs/ptr" "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" datav1 "code.vegaprotocol.io/vega/protos/vega/data/v1" - "github.com/vegaprotocol/devopstools/tools" + "google.golang.org/protobuf/types/known/structpb" ) diff --git a/governance/market/mainnet_simulation_injusdt_perp.go b/governance/market/mainnet_simulation_injusdt_perp.go index 0a1dc2df..98637039 100644 --- a/governance/market/mainnet_simulation_injusdt_perp.go +++ b/governance/market/mainnet_simulation_injusdt_perp.go @@ -3,11 +3,13 @@ package market import ( "time" + "github.com/vegaprotocol/devopstools/tools" + "code.vegaprotocol.io/vega/libs/ptr" "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" datav1 "code.vegaprotocol.io/vega/protos/vega/data/v1" - "github.com/vegaprotocol/devopstools/tools" + "google.golang.org/protobuf/types/known/structpb" ) @@ -26,9 +28,7 @@ func NewMainnetSimulationINJUSDTPerp( enactmentTime time.Time, extraMetadata []string, ) *commandspb.ProposalSubmission { - var ( - reference = tools.RandAlphaNumericString(40) - ) + reference := tools.RandAlphaNumericString(40) const ( contractAddress = "0x9eb2EBD260D82410592758B3091F74977E4A404c" contractABI = `[{ diff --git a/governance/market/mainnet_simulation_ldousdt_perp.go b/governance/market/mainnet_simulation_ldousdt_perp.go index b498b462..8e2ac1f8 100644 --- a/governance/market/mainnet_simulation_ldousdt_perp.go +++ b/governance/market/mainnet_simulation_ldousdt_perp.go @@ -3,11 +3,13 @@ package market import ( "time" + "github.com/vegaprotocol/devopstools/tools" + "code.vegaprotocol.io/vega/libs/ptr" "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" datav1 "code.vegaprotocol.io/vega/protos/vega/data/v1" - "github.com/vegaprotocol/devopstools/tools" + "google.golang.org/protobuf/types/known/structpb" ) @@ -26,9 +28,7 @@ func NewMainnetSimulationLDOUSDTPerp( enactmentTime time.Time, extraMetadata []string, ) *commandspb.ProposalSubmission { - var ( - reference = tools.RandAlphaNumericString(40) - ) + reference := tools.RandAlphaNumericString(40) const ( contractAddress = "0x9eb2EBD260D82410592758B3091F74977E4A404c" contractABI = `[{ diff --git a/governance/market/mainnet_simulation_sxnusdt_perp.go b/governance/market/mainnet_simulation_sxnusdt_perp.go index 9512e053..9f05885c 100644 --- a/governance/market/mainnet_simulation_sxnusdt_perp.go +++ b/governance/market/mainnet_simulation_sxnusdt_perp.go @@ -3,11 +3,13 @@ package market import ( "time" + "github.com/vegaprotocol/devopstools/tools" + "code.vegaprotocol.io/vega/libs/ptr" "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" datav1 "code.vegaprotocol.io/vega/protos/vega/data/v1" - "github.com/vegaprotocol/devopstools/tools" + "google.golang.org/protobuf/types/known/structpb" ) @@ -26,9 +28,7 @@ func NewMainnetSimulationSNXUSDTPerp( enactmentTime time.Time, extraMetadata []string, ) *commandspb.ProposalSubmission { - var ( - reference = tools.RandAlphaNumericString(40) - ) + reference := tools.RandAlphaNumericString(40) const ( contractAddress = "0x9eb2EBD260D82410592758B3091F74977E4A404c" contractABI = `[{ diff --git a/governance/market/market_aapl.go b/governance/market/market_aapl.go index 2a41dccd..a7956b74 100644 --- a/governance/market/market_aapl.go +++ b/governance/market/market_aapl.go @@ -4,11 +4,12 @@ import ( "fmt" "time" + "github.com/vegaprotocol/devopstools/tools" + dstypes "code.vegaprotocol.io/vega/core/datasource/common" "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" datav1 "code.vegaprotocol.io/vega/protos/vega/data/v1" - "github.com/vegaprotocol/devopstools/tools" ) func NewAAPLMarketProposal( diff --git a/governance/market/market_aavedai.go b/governance/market/market_aavedai.go index 6f57f875..1de0ee32 100644 --- a/governance/market/market_aavedai.go +++ b/governance/market/market_aavedai.go @@ -4,11 +4,12 @@ import ( "fmt" "time" + "github.com/vegaprotocol/devopstools/tools" + dstypes "code.vegaprotocol.io/vega/core/datasource/common" "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" datav1 "code.vegaprotocol.io/vega/protos/vega/data/v1" - "github.com/vegaprotocol/devopstools/tools" ) func NewAAVEDAIMarketProposal( diff --git a/governance/market/market_btcusd.go b/governance/market/market_btcusd.go index 8faaccdb..2d8006f4 100644 --- a/governance/market/market_btcusd.go +++ b/governance/market/market_btcusd.go @@ -4,11 +4,12 @@ import ( "fmt" "time" + "github.com/vegaprotocol/devopstools/tools" + dstypes "code.vegaprotocol.io/vega/core/datasource/common" "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" datav1 "code.vegaprotocol.io/vega/protos/vega/data/v1" - "github.com/vegaprotocol/devopstools/tools" ) func NewBTCUSDMarketProposal( diff --git a/governance/market/market_ethbtc.go b/governance/market/market_ethbtc.go index e396db37..c80f86ad 100644 --- a/governance/market/market_ethbtc.go +++ b/governance/market/market_ethbtc.go @@ -4,11 +4,12 @@ import ( "fmt" "time" + "github.com/vegaprotocol/devopstools/tools" + dstypes "code.vegaprotocol.io/vega/core/datasource/common" "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" datav1 "code.vegaprotocol.io/vega/protos/vega/data/v1" - "github.com/vegaprotocol/devopstools/tools" ) func NewETHBTCMarketProposal( diff --git a/governance/market/market_ethdai.go b/governance/market/market_ethdai.go index b86704ac..455bc606 100644 --- a/governance/market/market_ethdai.go +++ b/governance/market/market_ethdai.go @@ -4,11 +4,12 @@ import ( "fmt" "time" + "github.com/vegaprotocol/devopstools/tools" + dstypes "code.vegaprotocol.io/vega/core/datasource/common" "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" datav1 "code.vegaprotocol.io/vega/protos/vega/data/v1" - "github.com/vegaprotocol/devopstools/tools" ) func NewETHDAIMarketProposal( diff --git a/governance/market/market_perp_btcusd.go b/governance/market/market_perp_btcusd.go index 9801dfbc..82e19610 100644 --- a/governance/market/market_perp_btcusd.go +++ b/governance/market/market_perp_btcusd.go @@ -3,15 +3,18 @@ package market import ( "time" + "github.com/vegaprotocol/devopstools/tools" + "code.vegaprotocol.io/vega/libs/ptr" "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" datav1 "code.vegaprotocol.io/vega/protos/vega/data/v1" - "github.com/vegaprotocol/devopstools/tools" ) -const PerpetualBTCUSD = "auto:perpetual_btc_usd" -const PerpetualBTCUSDOracleAddress = "0x1b44F3514812d835EB1BDB0acB33d3fA3351Ee43" +const ( + PerpetualBTCUSD = "auto:perpetual_btc_usd" + PerpetualBTCUSDOracleAddress = "0x1b44F3514812d835EB1BDB0acB33d3fA3351Ee43" +) func NewBTCUSDPerpetualMarketProposal( settlementVegaAssetId string, diff --git a/governance/market/market_perp_btcusd_gnosis.go b/governance/market/market_perp_btcusd_gnosis.go index 85b17d55..3107e53c 100644 --- a/governance/market/market_perp_btcusd_gnosis.go +++ b/governance/market/market_perp_btcusd_gnosis.go @@ -3,16 +3,20 @@ package market import ( "time" + "github.com/vegaprotocol/devopstools/tools" + "code.vegaprotocol.io/vega/libs/ptr" "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" datav1 "code.vegaprotocol.io/vega/protos/vega/data/v1" - "github.com/vegaprotocol/devopstools/tools" + "google.golang.org/protobuf/types/known/structpb" ) -const PerpetualBTCUSDGnosis = "auto:perpetual_btc_usd_gnosis" -const PerpetualBTCUSDOracleGnosisAddress = "0xf72475a8778E2e4b953f99a85f21a2feADbF77B9" +const ( + PerpetualBTCUSDGnosis = "auto:perpetual_btc_usd_gnosis" + PerpetualBTCUSDOracleGnosisAddress = "0xf72475a8778E2e4b953f99a85f21a2feADbF77B9" +) func NewBTCUSDGnosisPerpetualMarketProposal( settlementVegaAssetId string, diff --git a/governance/market/market_perp_btcusd_mainnet.go b/governance/market/market_perp_btcusd_mainnet.go index 9545bd3d..fb4684fe 100644 --- a/governance/market/market_perp_btcusd_mainnet.go +++ b/governance/market/market_perp_btcusd_mainnet.go @@ -3,11 +3,13 @@ package market import ( "time" + "github.com/vegaprotocol/devopstools/tools" + "code.vegaprotocol.io/vega/libs/ptr" "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" datav1 "code.vegaprotocol.io/vega/protos/vega/data/v1" - "github.com/vegaprotocol/devopstools/tools" + "google.golang.org/protobuf/types/known/structpb" ) @@ -19,9 +21,7 @@ func NewBTCUSDMainnetMarketProposal( enactmentTime time.Time, extraMetadata []string, ) *commandspb.ProposalSubmission { - var ( - reference = tools.RandAlphaNumericString(40) - ) + reference := tools.RandAlphaNumericString(40) contractABI := `[{ "inputs" : [ @@ -85,7 +85,7 @@ func NewBTCUSDMainnetMarketProposal( SourceWeights: []string{"0.0", "0.0", "0.0", "1.0"}, SourceStalenessTolerance: []string{"1m", "1m", "1m", "1m"}, DataSourcesSpec: []*vega.DataSourceDefinition{ - &vega.DataSourceDefinition{ + { SourceType: &vega.DataSourceDefinition_External{ External: &vega.DataSourceDefinitionExternal{ SourceType: &vega.DataSourceDefinitionExternal_EthOracle{ @@ -133,7 +133,7 @@ func NewBTCUSDMainnetMarketProposal( }, }, DataSourcesSpecBinding: []*vega.SpecBindingForCompositePrice{ - &vega.SpecBindingForCompositePrice{ + { PriceSourceProperty: "btc.price", }, }, diff --git a/governance/market/market_perp_btcusd_mainnet2.go b/governance/market/market_perp_btcusd_mainnet2.go index 19b1eb82..ea0c59f6 100644 --- a/governance/market/market_perp_btcusd_mainnet2.go +++ b/governance/market/market_perp_btcusd_mainnet2.go @@ -3,11 +3,13 @@ package market import ( "time" + "github.com/vegaprotocol/devopstools/tools" + "code.vegaprotocol.io/vega/libs/ptr" "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" datav1 "code.vegaprotocol.io/vega/protos/vega/data/v1" - "github.com/vegaprotocol/devopstools/tools" + "google.golang.org/protobuf/types/known/structpb" ) @@ -17,9 +19,7 @@ func NewBTCUSDMainnet2MarketProposal( enactmentTime time.Time, extraMetadata []string, ) *commandspb.ProposalSubmission { - var ( - reference = tools.RandAlphaNumericString(40) - ) + reference := tools.RandAlphaNumericString(40) contractABI := `[{ "inputs" : [ @@ -82,7 +82,7 @@ func NewBTCUSDMainnet2MarketProposal( CashAmount: "5000000", SourceStalenessTolerance: []string{"1m", "1m", "1m", "1m"}, DataSourcesSpec: []*vega.DataSourceDefinition{ - &vega.DataSourceDefinition{ + { SourceType: &vega.DataSourceDefinition_External{ External: &vega.DataSourceDefinitionExternal{ SourceType: &vega.DataSourceDefinitionExternal_EthOracle{ @@ -130,7 +130,7 @@ func NewBTCUSDMainnet2MarketProposal( }, }, DataSourcesSpecBinding: []*vega.SpecBindingForCompositePrice{ - &vega.SpecBindingForCompositePrice{ + { PriceSourceProperty: "btc.price", }, }, diff --git a/governance/market/market_perp_btcusd_pyth.go b/governance/market/market_perp_btcusd_pyth.go index 188f6a94..82f210b2 100644 --- a/governance/market/market_perp_btcusd_pyth.go +++ b/governance/market/market_perp_btcusd_pyth.go @@ -3,11 +3,13 @@ package market import ( "time" + "github.com/vegaprotocol/devopstools/tools" + "code.vegaprotocol.io/vega/libs/ptr" "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" datav1 "code.vegaprotocol.io/vega/protos/vega/data/v1" - "github.com/vegaprotocol/devopstools/tools" + "google.golang.org/protobuf/types/known/structpb" ) @@ -86,7 +88,7 @@ func NewBTCUSDPythPerpetualMarketProposal( SourceWeights: []string{"0.0", "0.0", "0.0", "1.0"}, SourceStalenessTolerance: []string{"1m", "1m", "1m", "1m"}, DataSourcesSpec: []*vega.DataSourceDefinition{ - &vega.DataSourceDefinition{ + { SourceType: &vega.DataSourceDefinition_External{ External: &vega.DataSourceDefinitionExternal{ SourceType: &vega.DataSourceDefinitionExternal_EthOracle{ @@ -134,7 +136,7 @@ func NewBTCUSDPythPerpetualMarketProposal( }, }, DataSourcesSpecBinding: []*vega.SpecBindingForCompositePrice{ - &vega.SpecBindingForCompositePrice{ + { PriceSourceProperty: "btc.price", }, }, diff --git a/governance/market/market_perp_daiusd.go b/governance/market/market_perp_daiusd.go index 5ca6998c..7bedd722 100644 --- a/governance/market/market_perp_daiusd.go +++ b/governance/market/market_perp_daiusd.go @@ -3,15 +3,18 @@ package market import ( "time" + "github.com/vegaprotocol/devopstools/tools" + "code.vegaprotocol.io/vega/libs/ptr" "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" datav1 "code.vegaprotocol.io/vega/protos/vega/data/v1" - "github.com/vegaprotocol/devopstools/tools" ) -const PerpetualDAIUSD = "auto:perpetual_dai_usd" -const PerpetualDAIUSDOracleAddress = "0x14866185B1962B63C3Ea9E03Bc1da838bab34C19" +const ( + PerpetualDAIUSD = "auto:perpetual_dai_usd" + PerpetualDAIUSDOracleAddress = "0x14866185B1962B63C3Ea9E03Bc1da838bab34C19" +) func NewDAIUSDPerpetualMarketProposal( settlementVegaAssetId string, diff --git a/governance/market/market_perp_ethusd.go b/governance/market/market_perp_ethusd.go index 39261210..2c5a403c 100644 --- a/governance/market/market_perp_ethusd.go +++ b/governance/market/market_perp_ethusd.go @@ -3,15 +3,18 @@ package market import ( "time" + "github.com/vegaprotocol/devopstools/tools" + "code.vegaprotocol.io/vega/libs/ptr" "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" datav1 "code.vegaprotocol.io/vega/protos/vega/data/v1" - "github.com/vegaprotocol/devopstools/tools" ) -const PerpetualETHUSD = "auto:perpetual_eth_usd" -const PerpetualETHUSDOracleAddress = "0x694AA1769357215DE4FAC081bf1f309aDC325306" +const ( + PerpetualETHUSD = "auto:perpetual_eth_usd" + PerpetualETHUSDOracleAddress = "0x694AA1769357215DE4FAC081bf1f309aDC325306" +) func NewETHUSDPerpetualMarketProposal( settlementVegaAssetId string, diff --git a/governance/market/market_perp_eurusd.go b/governance/market/market_perp_eurusd.go index 3f72f1b1..04b26eef 100644 --- a/governance/market/market_perp_eurusd.go +++ b/governance/market/market_perp_eurusd.go @@ -3,15 +3,18 @@ package market import ( "time" + "github.com/vegaprotocol/devopstools/tools" + "code.vegaprotocol.io/vega/libs/ptr" "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" datav1 "code.vegaprotocol.io/vega/protos/vega/data/v1" - "github.com/vegaprotocol/devopstools/tools" ) -const PerpetualEURUSD = "auto:perpetual_eur_usd" -const PerpetualEURUSDOracleAddress = "0x1a81afB8146aeFfCFc5E50e8479e826E7D55b910" +const ( + PerpetualEURUSD = "auto:perpetual_eur_usd" + PerpetualEURUSDOracleAddress = "0x1a81afB8146aeFfCFc5E50e8479e826E7D55b910" +) func NewEURUSDPerpetualMarketProposal( settlementVegaAssetId string, diff --git a/governance/market/market_perp_inj_uniswap.go b/governance/market/market_perp_inj_uniswap.go index ad28a460..b35133f0 100644 --- a/governance/market/market_perp_inj_uniswap.go +++ b/governance/market/market_perp_inj_uniswap.go @@ -3,11 +3,13 @@ package market import ( "time" + "github.com/vegaprotocol/devopstools/tools" + "code.vegaprotocol.io/vega/libs/ptr" "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" datav1 "code.vegaprotocol.io/vega/protos/vega/data/v1" - "github.com/vegaprotocol/devopstools/tools" + "google.golang.org/protobuf/types/known/structpb" ) diff --git a/governance/market/market_perp_jupusd_pyth.go b/governance/market/market_perp_jupusd_pyth.go index 0a20769d..ee15d39a 100644 --- a/governance/market/market_perp_jupusd_pyth.go +++ b/governance/market/market_perp_jupusd_pyth.go @@ -3,11 +3,13 @@ package market import ( "time" + "github.com/vegaprotocol/devopstools/tools" + "code.vegaprotocol.io/vega/libs/ptr" "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" datav1 "code.vegaprotocol.io/vega/protos/vega/data/v1" - "github.com/vegaprotocol/devopstools/tools" + "google.golang.org/protobuf/types/known/structpb" ) @@ -86,7 +88,7 @@ func NewJUPUSDPythPerpetualMarketProposal( SourceWeights: []string{"0.0", "0.0", "0.0", "1.0"}, SourceStalenessTolerance: []string{"1m", "1m", "1m", "1m"}, DataSourcesSpec: []*vega.DataSourceDefinition{ - &vega.DataSourceDefinition{ + { SourceType: &vega.DataSourceDefinition_External{ External: &vega.DataSourceDefinitionExternal{ SourceType: &vega.DataSourceDefinitionExternal_EthOracle{ @@ -134,7 +136,7 @@ func NewJUPUSDPythPerpetualMarketProposal( }, }, DataSourcesSpecBinding: []*vega.SpecBindingForCompositePrice{ - &vega.SpecBindingForCompositePrice{ + { PriceSourceProperty: "jup.price", }, }, diff --git a/governance/market/market_perp_linkusd.go b/governance/market/market_perp_linkusd.go index 58424f8f..68e82ddc 100644 --- a/governance/market/market_perp_linkusd.go +++ b/governance/market/market_perp_linkusd.go @@ -3,15 +3,18 @@ package market import ( "time" + "github.com/vegaprotocol/devopstools/tools" + "code.vegaprotocol.io/vega/libs/ptr" "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" datav1 "code.vegaprotocol.io/vega/protos/vega/data/v1" - "github.com/vegaprotocol/devopstools/tools" ) -const PerpetualLINKUSD = "auto:perpetual_link_usd" -const PerpetualLINKUSDOracleAddress = "0xc59E3633BAAC79493d908e63626716e204A45EdF" +const ( + PerpetualLINKUSD = "auto:perpetual_link_usd" + PerpetualLINKUSDOracleAddress = "0xc59E3633BAAC79493d908e63626716e204A45EdF" +) func NewLINKUSDPerpetualMarketProposal( settlementVegaAssetId string, diff --git a/governance/market/market_perp_pepe_uniswap.go b/governance/market/market_perp_pepe_uniswap.go index 598fa31a..1febdf49 100644 --- a/governance/market/market_perp_pepe_uniswap.go +++ b/governance/market/market_perp_pepe_uniswap.go @@ -3,11 +3,13 @@ package market import ( "time" + "github.com/vegaprotocol/devopstools/tools" + "code.vegaprotocol.io/vega/libs/ptr" "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" datav1 "code.vegaprotocol.io/vega/protos/vega/data/v1" - "github.com/vegaprotocol/devopstools/tools" + "google.golang.org/protobuf/types/known/structpb" ) diff --git a/governance/market/market_perp_snx_uniswap.go b/governance/market/market_perp_snx_uniswap.go index 0da66f1b..beba113c 100644 --- a/governance/market/market_perp_snx_uniswap.go +++ b/governance/market/market_perp_snx_uniswap.go @@ -3,11 +3,13 @@ package market import ( "time" + "github.com/vegaprotocol/devopstools/tools" + "code.vegaprotocol.io/vega/libs/ptr" "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" datav1 "code.vegaprotocol.io/vega/protos/vega/data/v1" - "github.com/vegaprotocol/devopstools/tools" + "google.golang.org/protobuf/types/known/structpb" ) diff --git a/governance/market/market_tsla.go b/governance/market/market_tsla.go index 842c4623..8269d742 100644 --- a/governance/market/market_tsla.go +++ b/governance/market/market_tsla.go @@ -4,11 +4,12 @@ import ( "fmt" "time" + "github.com/vegaprotocol/devopstools/tools" + dstypes "code.vegaprotocol.io/vega/core/datasource/common" "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" datav1 "code.vegaprotocol.io/vega/protos/vega/data/v1" - "github.com/vegaprotocol/devopstools/tools" ) func NewTSLAMarketProposal( diff --git a/governance/market/market_unidai.go b/governance/market/market_unidai.go index 11d734ac..d45c6ebc 100644 --- a/governance/market/market_unidai.go +++ b/governance/market/market_unidai.go @@ -4,11 +4,12 @@ import ( "fmt" "time" + "github.com/vegaprotocol/devopstools/tools" + dstypes "code.vegaprotocol.io/vega/core/datasource/common" "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" datav1 "code.vegaprotocol.io/vega/protos/vega/data/v1" - "github.com/vegaprotocol/devopstools/tools" ) func NewUNIDAIMarketProposal( diff --git a/governance/market/upadte_mainnet_btc_with_pyth.go b/governance/market/upadte_mainnet_btc_with_pyth.go index 676ec875..c97bd639 100644 --- a/governance/market/upadte_mainnet_btc_with_pyth.go +++ b/governance/market/upadte_mainnet_btc_with_pyth.go @@ -3,11 +3,13 @@ package market import ( "time" + "github.com/vegaprotocol/devopstools/tools" + "code.vegaprotocol.io/vega/libs/ptr" "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" datav1 "code.vegaprotocol.io/vega/protos/vega/data/v1" - "github.com/vegaprotocol/devopstools/tools" + "google.golang.org/protobuf/types/known/structpb" ) @@ -16,9 +18,7 @@ func UpdateBTCUSDMainnetMarketProposal( enactmentTime time.Time, extraMetadata []string, ) *commandspb.ProposalSubmission { - var ( - reference = tools.RandAlphaNumericString(40) - ) + reference := tools.RandAlphaNumericString(40) contractABI := `[{ "inputs": [ @@ -62,7 +62,7 @@ func UpdateBTCUSDMainnetMarketProposal( SourceWeights: []string{"0.0", "0.0", "0.0", "1.0"}, SourceStalenessTolerance: []string{"1m", "1m", "1m", "1m"}, DataSourcesSpec: []*vega.DataSourceDefinition{ - &vega.DataSourceDefinition{ + { SourceType: &vega.DataSourceDefinition_External{ External: &vega.DataSourceDefinitionExternal{ SourceType: &vega.DataSourceDefinitionExternal_EthOracle{ @@ -110,7 +110,7 @@ func UpdateBTCUSDMainnetMarketProposal( }, }, DataSourcesSpecBinding: []*vega.SpecBindingForCompositePrice{ - &vega.SpecBindingForCompositePrice{ + { PriceSourceProperty: "btc.price", }, }, diff --git a/governance/market/upadte_mainnet_eth_with_pyth.go b/governance/market/upadte_mainnet_eth_with_pyth.go index f632d16e..2b447065 100644 --- a/governance/market/upadte_mainnet_eth_with_pyth.go +++ b/governance/market/upadte_mainnet_eth_with_pyth.go @@ -3,11 +3,13 @@ package market import ( "time" + "github.com/vegaprotocol/devopstools/tools" + "code.vegaprotocol.io/vega/libs/ptr" "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" datav1 "code.vegaprotocol.io/vega/protos/vega/data/v1" - "github.com/vegaprotocol/devopstools/tools" + "google.golang.org/protobuf/types/known/structpb" ) @@ -16,9 +18,7 @@ func UpdateETHUSDMainnetMarketProposal( enactmentTime time.Time, extraMetadata []string, ) *commandspb.ProposalSubmission { - var ( - reference = tools.RandAlphaNumericString(40) - ) + reference := tools.RandAlphaNumericString(40) contractABI := `[{ "inputs": [ @@ -62,7 +62,7 @@ func UpdateETHUSDMainnetMarketProposal( SourceWeights: []string{"0.0", "0.0", "0.0", "1.0"}, SourceStalenessTolerance: []string{"1m", "1m", "1m", "1m"}, DataSourcesSpec: []*vega.DataSourceDefinition{ - &vega.DataSourceDefinition{ + { SourceType: &vega.DataSourceDefinition_External{ External: &vega.DataSourceDefinitionExternal{ SourceType: &vega.DataSourceDefinitionExternal_EthOracle{ @@ -110,7 +110,7 @@ func UpdateETHUSDMainnetMarketProposal( }, }, DataSourcesSpecBinding: []*vega.SpecBindingForCompositePrice{ - &vega.SpecBindingForCompositePrice{ + { PriceSourceProperty: "eth.price", }, }, diff --git a/governance/networkparameters/network.go b/governance/networkparameters/network.go index f141931b..960ef8b1 100644 --- a/governance/networkparameters/network.go +++ b/governance/networkparameters/network.go @@ -4,9 +4,10 @@ import ( "fmt" "time" + "github.com/vegaprotocol/devopstools/tools" + "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" - "github.com/vegaprotocol/devopstools/tools" ) func NewUpdateParameterProposalWithoutTime(k, v string) *commandspb.ProposalSubmission { diff --git a/governance/programs/referral.go b/governance/programs/referral.go index 61ab8b80..9abc2bbf 100644 --- a/governance/programs/referral.go +++ b/governance/programs/referral.go @@ -3,9 +3,10 @@ package programs import ( "time" + "github.com/vegaprotocol/devopstools/tools" + "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" - "github.com/vegaprotocol/devopstools/tools" ) func NewUpdateReferralProgramProposal(closingTime time.Time, enactmentTime time.Time) *commandspb.ProposalSubmission { @@ -22,7 +23,6 @@ func NewUpdateReferralProgramProposal(closingTime time.Time, enactmentTime time. UpdateReferralProgram: &vega.UpdateReferralProgram{ Changes: &vega.ReferralProgramChanges{ BenefitTiers: []*vega.BenefitTier{ - { MinimumRunningNotionalTakerVolume: "100000", MinimumEpochs: "1", diff --git a/governance/programs/volume_discount.go b/governance/programs/volume_discount.go index a92f12d0..6a11538c 100644 --- a/governance/programs/volume_discount.go +++ b/governance/programs/volume_discount.go @@ -3,9 +3,10 @@ package programs import ( "time" + "github.com/vegaprotocol/devopstools/tools" + "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" - "github.com/vegaprotocol/devopstools/tools" ) func NewUpdateVolumeDiscountProgramProposal(closingTime time.Time, enactmentTime time.Time) *commandspb.ProposalSubmission { diff --git a/governance/propose.go b/governance/propose.go index 29c95b70..968aaf33 100644 --- a/governance/propose.go +++ b/governance/propose.go @@ -4,17 +4,19 @@ import ( "fmt" "time" - "code.vegaprotocol.io/vega/core/netparams" - v2 "code.vegaprotocol.io/vega/protos/data-node/api/v2" - "code.vegaprotocol.io/vega/protos/vega" - commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" - walletpb "code.vegaprotocol.io/vega/protos/vega/wallet/v1" "github.com/vegaprotocol/devopstools/governance/networkparameters" "github.com/vegaprotocol/devopstools/tools" "github.com/vegaprotocol/devopstools/types" "github.com/vegaprotocol/devopstools/vegaapi" "github.com/vegaprotocol/devopstools/veganetwork" "github.com/vegaprotocol/devopstools/wallet" + + "code.vegaprotocol.io/vega/core/netparams" + v2 "code.vegaprotocol.io/vega/protos/data-node/api/v2" + "code.vegaprotocol.io/vega/protos/vega" + commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" + walletpb "code.vegaprotocol.io/vega/protos/vega/wallet/v1" + "go.uber.org/zap" "golang.org/x/exp/slices" ) @@ -45,10 +47,7 @@ func SubmitProposal( // Find Proposal // proposalId, err := tools.RetryReturn(6, 10*time.Second, func() (string, error) { - proposal, err := fetchProposalByReferenceAndProposer( - reference, proposerVegawallet.PublicKey, dataNodeClient, - ) - + proposal, err := fetchProposalByReferenceAndProposer(reference, dataNodeClient) if err != nil { return "", fmt.Errorf("failed to find proposal: %w", err) } @@ -98,10 +97,7 @@ func SubmitProposalList( // on test networks there can be a lot of proposals, so fetching one by one can be more efficient proposalId, err := tools.RetryReturn(6, 10*time.Second, func() (string, error) { - proposal, err := fetchProposalByReferenceAndProposer( - proposalConfig.Reference, proposerVegawallet.PublicKey, dataNodeClient, - ) - + proposal, err := fetchProposalByReferenceAndProposer(proposalConfig.Reference, dataNodeClient) if err != nil { return "", fmt.Errorf("failed to find proposal: %w", err) } @@ -111,13 +107,11 @@ func SubmitProposalList( return "", fmt.Errorf("got empty proposal id for the '%s', re %s reference", description, proposalConfig.Reference) }) - if err != nil { return nil, fmt.Errorf("failed to find proposal: %w", err) } descriptionToProposalId[description] = proposalId - } if len(descriptionToProposalId) < len(descriptionToProposalConfig) { @@ -127,17 +121,12 @@ func SubmitProposalList( return descriptionToProposalId, nil } -func fetchProposalByReferenceAndProposer( - reference string, - proposerPartyId string, - dataNodeClient vegaapi.DataNodeClient, -) (*vega.Proposal, error) { +func fetchProposalByReferenceAndProposer(reference string, dataNodeClient vegaapi.DataNodeClient) (*vega.Proposal, error) { res, err := tools.RetryReturn(6, 10*time.Second, func() (*v2.GetGovernanceDataResponse, error) { return dataNodeClient.GetGovernanceData(&v2.GetGovernanceDataRequest{ Reference: &reference, }) }) - if err != nil { return nil, err } @@ -150,7 +139,6 @@ func fetchProposalByReferenceAndProposer( return nil, fmt.Errorf("proposal '%s' is in wrong state %s: %+v", proposal.Rationale.Title, proposal.State.String(), proposal) } return proposal, nil - } return nil, nil } diff --git a/governance/tools.go b/governance/tools.go index a16fa712..8aadf20e 100644 --- a/governance/tools.go +++ b/governance/tools.go @@ -4,11 +4,13 @@ import ( "encoding/hex" "fmt" + "github.com/vegaprotocol/devopstools/vegaapi" + "github.com/vegaprotocol/devopstools/wallet" + vgcrypto "code.vegaprotocol.io/vega/libs/crypto" vegaapipb "code.vegaprotocol.io/vega/protos/vega/api/v1" walletpb "code.vegaprotocol.io/vega/protos/vega/wallet/v1" - "github.com/vegaprotocol/devopstools/vegaapi" - "github.com/vegaprotocol/devopstools/wallet" + "go.uber.org/zap" ) diff --git a/governance/vote.go b/governance/vote.go index 9e9435df..4ab03ce7 100644 --- a/governance/vote.go +++ b/governance/vote.go @@ -4,12 +4,14 @@ import ( "fmt" "time" + "github.com/vegaprotocol/devopstools/vegaapi" + "github.com/vegaprotocol/devopstools/wallet" + v2 "code.vegaprotocol.io/vega/protos/data-node/api/v2" "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" walletpb "code.vegaprotocol.io/vega/protos/vega/wallet/v1" - "github.com/vegaprotocol/devopstools/vegaapi" - "github.com/vegaprotocol/devopstools/wallet" + "go.uber.org/zap" ) diff --git a/governance/wait.go b/governance/wait.go index 74b470d7..e228cab0 100644 --- a/governance/wait.go +++ b/governance/wait.go @@ -4,9 +4,11 @@ import ( "fmt" "time" + "github.com/vegaprotocol/devopstools/vegaapi" + v2 "code.vegaprotocol.io/vega/protos/data-node/api/v2" "code.vegaprotocol.io/vega/protos/vega" - "github.com/vegaprotocol/devopstools/vegaapi" + "go.uber.org/zap" "golang.org/x/exp/slices" ) diff --git a/main.go b/main.go index 73add743..d6c56d07 100644 --- a/main.go +++ b/main.go @@ -6,7 +6,6 @@ import ( "github.com/vegaprotocol/devopstools/cmd/batch" "github.com/vegaprotocol/devopstools/cmd/benchmark" "github.com/vegaprotocol/devopstools/cmd/bot" - "github.com/vegaprotocol/devopstools/cmd/erc20token" "github.com/vegaprotocol/devopstools/cmd/helper" "github.com/vegaprotocol/devopstools/cmd/incentive" "github.com/vegaprotocol/devopstools/cmd/live" @@ -17,7 +16,6 @@ import ( "github.com/vegaprotocol/devopstools/cmd/propose" "github.com/vegaprotocol/devopstools/cmd/script" "github.com/vegaprotocol/devopstools/cmd/secrets" - "github.com/vegaprotocol/devopstools/cmd/smartcontracts" "github.com/vegaprotocol/devopstools/cmd/snapshotcompatibility" "github.com/vegaprotocol/devopstools/cmd/spam" "github.com/vegaprotocol/devopstools/cmd/topup" @@ -35,9 +33,7 @@ func init() { rootCmd.RootCmd.AddCommand(network.NetworkCmd) rootCmd.RootCmd.AddCommand(live.LiveCmd) rootCmd.RootCmd.AddCommand(secrets.SecretsCmd) - rootCmd.RootCmd.AddCommand(smartcontracts.SmartContractsCmd) rootCmd.RootCmd.AddCommand(party.PartyCmd) - rootCmd.RootCmd.AddCommand(erc20token.ERC20tokenCmd) rootCmd.RootCmd.AddCommand(script.ScriptCmd) rootCmd.RootCmd.AddCommand(topup.TopUpCmd) rootCmd.RootCmd.AddCommand(market.MarketCmd) diff --git a/networktools/api.go b/networktools/api.go index 6299be7b..7bfa8564 100644 --- a/networktools/api.go +++ b/networktools/api.go @@ -9,6 +9,7 @@ import ( "github.com/vegaprotocol/devopstools/vegaapi" "github.com/vegaprotocol/devopstools/vegaapi/core" "github.com/vegaprotocol/devopstools/vegaapi/datanode" + "go.uber.org/zap" ) diff --git a/networktools/network.go b/networktools/network.go index 14857f82..0d3e79e6 100644 --- a/networktools/network.go +++ b/networktools/network.go @@ -5,6 +5,7 @@ import ( "time" "github.com/vegaprotocol/devopstools/types" + "go.uber.org/zap" ) @@ -20,7 +21,7 @@ func NewNetworkTools( name string, logger *zap.Logger, ) (*NetworkTools, error) { - var network = NetworkTools{ + network := NetworkTools{ Name: name, logger: logger, restTimeout: time.Second, diff --git a/networktools/networkParameters.go b/networktools/networkParameters.go index de8a60d6..84a601bf 100644 --- a/networktools/networkParameters.go +++ b/networktools/networkParameters.go @@ -7,6 +7,7 @@ import ( "net/http" "github.com/vegaprotocol/devopstools/types" + "go.uber.org/zap" ) @@ -26,7 +27,6 @@ func (network *NetworkTools) GetNetworkParams() (*types.NetworkParams, error) { } func (network *NetworkTools) GetNetworkParamsFromHost(host string, tlsOnly bool) (*types.NetworkParams, error) { - statsURLs := []string{ fmt.Sprintf("https://%s/network/parameters", host), } @@ -38,7 +38,6 @@ func (network *NetworkTools) GetNetworkParamsFromHost(host string, tlsOnly bool) Timeout: network.restTimeout, } for _, statsURL := range statsURLs { - req, err := http.NewRequest(http.MethodGet, statsURL, nil) if err != nil { network.logger.Debug("failed to create new request", zap.String("url", statsURL), zap.Error(err)) diff --git a/networktools/nodes.go b/networktools/nodes.go index bf52538c..8a27af78 100644 --- a/networktools/nodes.go +++ b/networktools/nodes.go @@ -8,6 +8,7 @@ import ( "github.com/vegaprotocol/devopstools/tools" "github.com/vegaprotocol/devopstools/types" + "golang.org/x/exp/slices" ) @@ -119,7 +120,6 @@ func (network *NetworkTools) GetNetworkHealthyNodes() []string { // func (network *NetworkTools) GetNetworkDataNodes(healthyOnly bool) []string { - hosts := []string{} previousMissing := false httpClient := http.Client{ diff --git a/networktools/smartcontracts.go b/networktools/smartcontracts.go index c79bb079..c2eed39d 100644 --- a/networktools/smartcontracts.go +++ b/networktools/smartcontracts.go @@ -9,9 +9,7 @@ import ( ) func (network *NetworkTools) GetEthNetwork() (types.ETHNetwork, error) { - var ( - errMsg = fmt.Sprintf("failed to get Eth Network for %s network", network.Name) - ) + errMsg := fmt.Sprintf("failed to get Eth Network for %s network", network.Name) params, err := network.GetNetworkParams() if err != nil { return types.ETHNetwork("unknown"), fmt.Errorf("%s, %w", errMsg, err) @@ -30,9 +28,7 @@ func (network *NetworkTools) GetEthNetwork() (types.ETHNetwork, error) { func (network *NetworkTools) GetSmartContracts( ethClientManager *ethutils.EthereumClientManager, ) (*veganetworksmartcontracts.VegaNetworkSmartContracts, error) { - var ( - errMsg = fmt.Sprintf("failed to get Smart Contracts for %s network", network.Name) - ) + errMsg := fmt.Sprintf("failed to get Smart Contracts for %s network", network.Name) params, err := network.GetNetworkParams() if err != nil { return nil, fmt.Errorf("%s, %w", errMsg, err) diff --git a/networktools/statistics.go b/networktools/statistics.go index e968b152..896815ba 100644 --- a/networktools/statistics.go +++ b/networktools/statistics.go @@ -48,7 +48,6 @@ func (network *NetworkTools) GetRunningStatisticsForAllDataNodes() map[string]St } func (network *NetworkTools) GetRunningStatisticsForHosts(hosts []string, tlsOnly bool) map[string]Statistics { - type hostStats struct { Host string Statistics *Statistics @@ -95,7 +94,6 @@ func (network *NetworkTools) GetRunningStatisticsForHost(host string, tlsOnly bo Timeout: network.restTimeout, } for _, statsURL := range statsURLs { - req, err := http.NewRequest(http.MethodGet, statsURL, nil) if err != nil { network.logger.Debug("failed to create new request", zap.String("url", statsURL), zap.Error(err)) diff --git a/secrets/hcvault/node.go b/secrets/hcvault/node.go index 8843f260..6f3fa76e 100644 --- a/secrets/hcvault/node.go +++ b/secrets/hcvault/node.go @@ -48,7 +48,6 @@ func (c *HCVaultSecretStore) GetVegaNodeList(network string) ([]string, error) { } func (c *HCVaultSecretStore) GetAllVegaNode(network string) (map[string]*secrets.VegaNodePrivate, error) { - nodeList, err := c.GetVegaNodeList(network) if err != nil { return nil, err diff --git a/smartcontracts/assets.go b/smartcontracts/assets.go index 292e8d4f..1d9a698e 100644 --- a/smartcontracts/assets.go +++ b/smartcontracts/assets.go @@ -40,7 +40,7 @@ var ( EthNetwork: types.ETHSepolia, Version: erc20token.ERC20TokenBase, } - + // Sandbox VT_S VegaAsset = VegaAsset{ Name: "Vega Token Sandbox", @@ -49,7 +49,6 @@ var ( Version: erc20token.ERC20TokenBase, } - // New Fairground TEURO_F VegaAsset = VegaAsset{ Name: "tEURO TEST", @@ -175,7 +174,8 @@ var ( var allAssets = []VegaAsset{ TEURO, TDAI, TUSDC, TBTC, VT_S, TEURO_F, TDAI_F, TUSDC_F, TBTC_F, TEURORopsten, TDAIRopsten, TUSDCRopsten, TBTCRopsten, - VEGA_S3, LIQ_S3, TDAI_S3, TBTC_S3, TUSDC_S3, TAK_S3, TEURO_S3, MAK_S3, TIM_S3, WOZ_S3} + VEGA_S3, LIQ_S3, TDAI_S3, TBTC_S3, TUSDC_S3, TAK_S3, TEURO_S3, MAK_S3, TIM_S3, WOZ_S3, +} func (m *SmartContractsManager) GetAssetWithName(name string) (*erc20token.ERC20Token, error) { name = strings.ToLower(name) diff --git a/smartcontracts/claimcodes/claimcodes.go b/smartcontracts/claimcodes/claimcodes.go deleted file mode 100644 index 70c5180b..00000000 --- a/smartcontracts/claimcodes/claimcodes.go +++ /dev/null @@ -1,57 +0,0 @@ -package claimcodes - -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" - - ClaimCodes_V1 "github.com/vegaprotocol/devopstools/smartcontracts/claimcodes/v1" -) - -type ClaimCodesCommon interface { - AllowedCountries(opts *bind.CallOpts, arg0 [2]byte) (bool, error) - Commitments(opts *bind.CallOpts, arg0 [32]byte) (common.Address, error) - Controller(opts *bind.CallOpts) (common.Address, error) - Issuers(opts *bind.CallOpts, arg0 common.Address) (*big.Int, error) - AllowCountries(opts *bind.TransactOpts, countries [][2]byte) (*types.Transaction, error) - BlockCountries(opts *bind.TransactOpts, countries [][2]byte) (*types.Transaction, error) - ClaimTargeted(opts *bind.TransactOpts, sig ClaimCodes_V1.Signature, clm ClaimCodes_V1.Claim, country [2]byte, target common.Address) (*types.Transaction, error) - ClaimUntargeted(opts *bind.TransactOpts, sig ClaimCodes_V1.Signature, clm ClaimCodes_V1.Claim, country [2]byte) (*types.Transaction, error) - CommitUntargeted(opts *bind.TransactOpts, s [32]byte) (*types.Transaction, error) -} - -type ClaimCodes struct { - ClaimCodesCommon - Address common.Address - Version ClaimCodesVersion - client *ethclient.Client - - // Minimal implementation - v1 *ClaimCodes_V1.ClaimCodes -} - -func NewClaimCodes( - ethClient *ethclient.Client, - hexAddress string, - version ClaimCodesVersion, -) (*ClaimCodes, error) { - var err error - result := &ClaimCodes{ - Address: common.HexToAddress(hexAddress), - Version: version, - client: ethClient, - } - switch version { - case ClaimCodesV1: - result.v1, err = ClaimCodes_V1.NewClaimCodes(result.Address, result.client) - if err != nil { - return nil, err - } - result.ClaimCodesCommon = result.v1 - } - - return result, nil -} diff --git a/smartcontracts/claimcodes/deploy.go b/smartcontracts/claimcodes/deploy.go deleted file mode 100644 index 120aad4c..00000000 --- a/smartcontracts/claimcodes/deploy.go +++ /dev/null @@ -1,26 +0,0 @@ -package claimcodes - -import ( - "fmt" - - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - ethTypes "github.com/ethereum/go-ethereum/core/types" - - ClaimCodes_V1 "github.com/vegaprotocol/devopstools/smartcontracts/claimcodes/v1" -) - -func DeployClaimCodes( - version ClaimCodesVersion, - auth *bind.TransactOpts, - backend bind.ContractBackend, - vestingBridgeAddress common.Address, -) (address common.Address, tx *ethTypes.Transaction, err error) { - switch version { - case ClaimCodesV1: - address, tx, _, err = ClaimCodes_V1.DeployClaimCodes(auth, backend, vestingBridgeAddress) - default: - err = fmt.Errorf("Invalid ERC20 Asset Pool Version %s", version) - } - return -} diff --git a/smartcontracts/claimcodes/v1/ClaimCodes.bin b/smartcontracts/claimcodes/v1/ClaimCodes.bin deleted file mode 100644 index 7e2bee57..00000000 --- a/smartcontracts/claimcodes/v1/ClaimCodes.bin +++ /dev/null @@ -1 +0,0 @@ -60a060405234801561001057600080fd5b506040516111c03803806111c083398101604081905261002f91610058565b60601b6001600160601b03191660805260008054336001600160a01b0319909116179055610088565b60006020828403121561006a57600080fd5b81516001600160a01b038116811461008157600080fd5b9392505050565b60805160601c61111a6100a66000396000610937015261111a6000f3fe608060405234801561001057600080fd5b50600436106100df5760003560e01c806383197ef01161008c5780639cef4355116100665780639cef43551461020e578063b7d00d0c14610221578063c342cd9b14610234578063f77c47911461024757600080fd5b806383197ef014610198578063839df945146101a057806394a4ff3f146101fb57600080fd5b806334b4947b116100bd57806334b4947b1461011f57806338a7543e146101575780637eb1b5d71461018557600080fd5b806304df9479146100e457806326bc922a146100f9578063277817c71461010c575b600080fd5b6100f76100f2366004610f2d565b610267565b005b6100f7610107366004610e3f565b610279565b6100f761011a366004610e15565b61034b565b61014261012d366004610eb4565b60036020526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b610177610165366004610df3565b60026020526000908152604090205481565b60405190815260200161014e565b6100f7610193366004610df3565b610398565b6100f7610423565b6101d66101ae366004610ecf565b60016020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161014e565b6100f7610209366004610df3565b61044a565b6100f761021c366004610e3f565b610495565b6100f761022f366004610ee8565b610562565b6100f7610242366004610ecf565b61056f565b6000546101d69073ffffffffffffffffffffffffffffffffffffffff1681565b610273848483856105d6565b50505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461029d57600080fd5b60005b81811015610346576000600360008585858181106102c0576102c06110b5565b90506020020160208101906102d59190610eb4565b7fffff000000000000000000000000000000000000000000000000000000000000168152602081019190915260400160002080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169115159190911790558061033e8161104d565b9150506102a0565b505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461036f57600080fd5b73ffffffffffffffffffffffffffffffffffffffff909116600090815260026020526040902055565b60005473ffffffffffffffffffffffffffffffffffffffff1633146103bc57600080fd5b73ffffffffffffffffffffffffffffffffffffffff81166103dc57600080fd5b600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60005473ffffffffffffffffffffffffffffffffffffffff16331461044757600080fd5b33ff5b60005473ffffffffffffffffffffffffffffffffffffffff16331461046e57600080fd5b73ffffffffffffffffffffffffffffffffffffffff16600090815260026020526040812055565b60005473ffffffffffffffffffffffffffffffffffffffff1633146104b957600080fd5b60005b81811015610346576001600360008585858181106104dc576104dc6110b5565b90506020020160208101906104f19190610eb4565b7fffff000000000000000000000000000000000000000000000000000000000000168152602081019190915260400160002080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169115159190911790558061055a8161104d565b9150506104bc565b61034683836000846105d6565b60008181526001602052604090205473ffffffffffffffffffffffffffffffffffffffff161561059e57600080fd5b600090815260016020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001633179055565b426105e76060850160408601610f84565b63ffffffff1611610659576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f436c61696d20636f64652068617320657870697265640000000000000000000060448201526064015b60405180910390fd5b7fffff000000000000000000000000000000000000000000000000000000000000811660009081526003602052604090205460ff1661071a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f436c61696d20636f6465206973206e6f7420617661696c61626c6520696e207960448201527f6f757220636f756e7472790000000000000000000000000000000000000000006064820152608401610650565b6000610727468585610a1b565b905060006107358287610b35565b905073ffffffffffffffffffffffffffffffffffffffff81166107b4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f496e76616c696420636c61696d20636f646500000000000000000000000000006044820152606401610650565b6107be8685610be2565b93508373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610856576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f43616e6e6f7420636c61696d20746f20796f757273656c6600000000000000006044820152606401610650565b73ffffffffffffffffffffffffffffffffffffffff811660009081526002602052604090205485358110156108e7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f4f7574206f662066756e647300000000000000000000000000000000000000006044820152606401610650565b6108f2863582611036565b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663e2de6e6d868860200160208101906109859190610faa565b60405160e084901b7fffffffff0000000000000000000000000000000000000000000000000000000016815273ffffffffffffffffffffffffffffffffffffffff909216600483015260ff16602482015288356044820152606401600060405180830381600087803b1580156109fa57600080fd5b505af1158015610a0e573d6000803e3d6000fd5b5050505050505050505050565b600080848435610a316040870160208801610faa565b610a416060880160408901610f84565b604051602001610ab49493929190938452602084019290925260f81b7fff0000000000000000000000000000000000000000000000000000000000000016604083015260e01b7fffffffff0000000000000000000000000000000000000000000000000000000016604182015260450190565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152919052905073ffffffffffffffffffffffffffffffffffffffff831615610b25578083604051602001610b13929190610fcd565b60405160208183030381529060405290505b8051602090910120949350505050565b60007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a060408301351115610b6b57506000610bdc565b600183610b7b6020850185610faa565b604080516000815260208181018084529490945260ff9092168282015291850135606082015290840135608082015260a0016020604051602081039080840390855afa158015610bcf573d6000803e3d6000fd5b5050506020604051035190505b92915050565b604080830135600090815260016020529081205473ffffffffffffffffffffffffffffffffffffffff90811690831615610c9c5773ffffffffffffffffffffffffffffffffffffffff811660011415610c97576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f436c61696d20636f646520616c7265616479207370656e7400000000000000006044820152606401610650565b610d3e565b73ffffffffffffffffffffffffffffffffffffffff8116331480610cd4575073ffffffffffffffffffffffffffffffffffffffff8116155b610d3a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f436c61696d20636f646520616c7265616479207370656e7400000000000000006044820152606401610650565b3392505b505060409182013560009081526001602081905292902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001690921790915590565b803573ffffffffffffffffffffffffffffffffffffffff81168114610da657600080fd5b919050565b80357fffff00000000000000000000000000000000000000000000000000000000000081168114610da657600080fd5b600060608284031215610ded57600080fd5b50919050565b600060208284031215610e0557600080fd5b610e0e82610d82565b9392505050565b60008060408385031215610e2857600080fd5b610e3183610d82565b946020939093013593505050565b60008060208385031215610e5257600080fd5b823567ffffffffffffffff80821115610e6a57600080fd5b818501915085601f830112610e7e57600080fd5b813581811115610e8d57600080fd5b8660208260051b8501011115610ea257600080fd5b60209290920196919550909350505050565b600060208284031215610ec657600080fd5b610e0e82610dab565b600060208284031215610ee157600080fd5b5035919050565b600080600060e08486031215610efd57600080fd5b610f078585610ddb565b9250610f168560608601610ddb565b9150610f2460c08501610dab565b90509250925092565b6000806000806101008587031215610f4457600080fd5b610f4e8686610ddb565b9350610f5d8660608701610ddb565b9250610f6b60c08601610dab565b9150610f7960e08601610d82565b905092959194509250565b600060208284031215610f9657600080fd5b813563ffffffff81168114610e0e57600080fd5b600060208284031215610fbc57600080fd5b813560ff81168114610e0e57600080fd5b6000835160005b81811015610fee5760208187018101518583015201610fd4565b81811115610ffd576000828501525b5060609390931b7fffffffffffffffffffffffffffffffffffffffff000000000000000000000000169190920190815260140192915050565b60008282101561104857611048611086565b500390565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561107f5761107f611086565b5060010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fdfea26469706673582212202cc95c42f0a51f091c5ebc99a835d7215c8d0dff3046a6ca534be0104e81178664736f6c6343000807003300000000000000000000000023d1bfe8fa50a167816fbd79d7932577c06011f4 \ No newline at end of file diff --git a/smartcontracts/claimcodes/v1/ClaimCodes.go b/smartcontracts/claimcodes/v1/ClaimCodes.go deleted file mode 100644 index 7ae2c5ae..00000000 --- a/smartcontracts/claimcodes/v1/ClaimCodes.go +++ /dev/null @@ -1,530 +0,0 @@ -// Code generated - DO NOT EDIT. -// This file is a generated binding and any manual changes will be lost. - -package ClaimCodes - -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 - _ = abi.ConvertType -) - -// Claim is an auto generated low-level Go binding around an user-defined struct. -type Claim struct { - Amount *big.Int - Tranche uint8 - Expiry uint32 -} - -// Signature is an auto generated low-level Go binding around an user-defined struct. -type Signature struct { - V uint8 - R [32]byte - S [32]byte -} - -// ClaimCodesMetaData contains all meta data concerning the ClaimCodes contract. -var ClaimCodesMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"vesting_address\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"bytes2[]\",\"name\":\"countries\",\"type\":\"bytes2[]\"}],\"name\":\"allow_countries\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes2\",\"name\":\"\",\"type\":\"bytes2\"}],\"name\":\"allowed_countries\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes2[]\",\"name\":\"countries\",\"type\":\"bytes2[]\"}],\"name\":\"block_countries\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"internalType\":\"structSignature\",\"name\":\"sig\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"tranche\",\"type\":\"uint8\"},{\"internalType\":\"uint32\",\"name\":\"expiry\",\"type\":\"uint32\"}],\"internalType\":\"structClaim\",\"name\":\"clm\",\"type\":\"tuple\"},{\"internalType\":\"bytes2\",\"name\":\"country\",\"type\":\"bytes2\"},{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"}],\"name\":\"claim_targeted\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"internalType\":\"structSignature\",\"name\":\"sig\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"tranche\",\"type\":\"uint8\"},{\"internalType\":\"uint32\",\"name\":\"expiry\",\"type\":\"uint32\"}],\"internalType\":\"structClaim\",\"name\":\"clm\",\"type\":\"tuple\"},{\"internalType\":\"bytes2\",\"name\":\"country\",\"type\":\"bytes2\"}],\"name\":\"claim_untargeted\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"commit_untargeted\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"commitments\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"controller\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"destroy\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"issuers\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"issuer\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"permit_issuer\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"issuer\",\"type\":\"address\"}],\"name\":\"revoke_issuer\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_controller\",\"type\":\"address\"}],\"name\":\"swap_controller\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", - Bin: "0x60a060405234801561001057600080fd5b506040516111c03803806111c083398101604081905261002f91610058565b60601b6001600160601b03191660805260008054336001600160a01b0319909116179055610088565b60006020828403121561006a57600080fd5b81516001600160a01b038116811461008157600080fd5b9392505050565b60805160601c61111a6100a66000396000610937015261111a6000f3fe608060405234801561001057600080fd5b50600436106100df5760003560e01c806383197ef01161008c5780639cef4355116100665780639cef43551461020e578063b7d00d0c14610221578063c342cd9b14610234578063f77c47911461024757600080fd5b806383197ef014610198578063839df945146101a057806394a4ff3f146101fb57600080fd5b806334b4947b116100bd57806334b4947b1461011f57806338a7543e146101575780637eb1b5d71461018557600080fd5b806304df9479146100e457806326bc922a146100f9578063277817c71461010c575b600080fd5b6100f76100f2366004610f2d565b610267565b005b6100f7610107366004610e3f565b610279565b6100f761011a366004610e15565b61034b565b61014261012d366004610eb4565b60036020526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b610177610165366004610df3565b60026020526000908152604090205481565b60405190815260200161014e565b6100f7610193366004610df3565b610398565b6100f7610423565b6101d66101ae366004610ecf565b60016020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161014e565b6100f7610209366004610df3565b61044a565b6100f761021c366004610e3f565b610495565b6100f761022f366004610ee8565b610562565b6100f7610242366004610ecf565b61056f565b6000546101d69073ffffffffffffffffffffffffffffffffffffffff1681565b610273848483856105d6565b50505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461029d57600080fd5b60005b81811015610346576000600360008585858181106102c0576102c06110b5565b90506020020160208101906102d59190610eb4565b7fffff000000000000000000000000000000000000000000000000000000000000168152602081019190915260400160002080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169115159190911790558061033e8161104d565b9150506102a0565b505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461036f57600080fd5b73ffffffffffffffffffffffffffffffffffffffff909116600090815260026020526040902055565b60005473ffffffffffffffffffffffffffffffffffffffff1633146103bc57600080fd5b73ffffffffffffffffffffffffffffffffffffffff81166103dc57600080fd5b600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60005473ffffffffffffffffffffffffffffffffffffffff16331461044757600080fd5b33ff5b60005473ffffffffffffffffffffffffffffffffffffffff16331461046e57600080fd5b73ffffffffffffffffffffffffffffffffffffffff16600090815260026020526040812055565b60005473ffffffffffffffffffffffffffffffffffffffff1633146104b957600080fd5b60005b81811015610346576001600360008585858181106104dc576104dc6110b5565b90506020020160208101906104f19190610eb4565b7fffff000000000000000000000000000000000000000000000000000000000000168152602081019190915260400160002080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169115159190911790558061055a8161104d565b9150506104bc565b61034683836000846105d6565b60008181526001602052604090205473ffffffffffffffffffffffffffffffffffffffff161561059e57600080fd5b600090815260016020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001633179055565b426105e76060850160408601610f84565b63ffffffff1611610659576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f436c61696d20636f64652068617320657870697265640000000000000000000060448201526064015b60405180910390fd5b7fffff000000000000000000000000000000000000000000000000000000000000811660009081526003602052604090205460ff1661071a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f436c61696d20636f6465206973206e6f7420617661696c61626c6520696e207960448201527f6f757220636f756e7472790000000000000000000000000000000000000000006064820152608401610650565b6000610727468585610a1b565b905060006107358287610b35565b905073ffffffffffffffffffffffffffffffffffffffff81166107b4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f496e76616c696420636c61696d20636f646500000000000000000000000000006044820152606401610650565b6107be8685610be2565b93508373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610856576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f43616e6e6f7420636c61696d20746f20796f757273656c6600000000000000006044820152606401610650565b73ffffffffffffffffffffffffffffffffffffffff811660009081526002602052604090205485358110156108e7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f4f7574206f662066756e647300000000000000000000000000000000000000006044820152606401610650565b6108f2863582611036565b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663e2de6e6d868860200160208101906109859190610faa565b60405160e084901b7fffffffff0000000000000000000000000000000000000000000000000000000016815273ffffffffffffffffffffffffffffffffffffffff909216600483015260ff16602482015288356044820152606401600060405180830381600087803b1580156109fa57600080fd5b505af1158015610a0e573d6000803e3d6000fd5b5050505050505050505050565b600080848435610a316040870160208801610faa565b610a416060880160408901610f84565b604051602001610ab49493929190938452602084019290925260f81b7fff0000000000000000000000000000000000000000000000000000000000000016604083015260e01b7fffffffff0000000000000000000000000000000000000000000000000000000016604182015260450190565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152919052905073ffffffffffffffffffffffffffffffffffffffff831615610b25578083604051602001610b13929190610fcd565b60405160208183030381529060405290505b8051602090910120949350505050565b60007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a060408301351115610b6b57506000610bdc565b600183610b7b6020850185610faa565b604080516000815260208181018084529490945260ff9092168282015291850135606082015290840135608082015260a0016020604051602081039080840390855afa158015610bcf573d6000803e3d6000fd5b5050506020604051035190505b92915050565b604080830135600090815260016020529081205473ffffffffffffffffffffffffffffffffffffffff90811690831615610c9c5773ffffffffffffffffffffffffffffffffffffffff811660011415610c97576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f436c61696d20636f646520616c7265616479207370656e7400000000000000006044820152606401610650565b610d3e565b73ffffffffffffffffffffffffffffffffffffffff8116331480610cd4575073ffffffffffffffffffffffffffffffffffffffff8116155b610d3a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f436c61696d20636f646520616c7265616479207370656e7400000000000000006044820152606401610650565b3392505b505060409182013560009081526001602081905292902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001690921790915590565b803573ffffffffffffffffffffffffffffffffffffffff81168114610da657600080fd5b919050565b80357fffff00000000000000000000000000000000000000000000000000000000000081168114610da657600080fd5b600060608284031215610ded57600080fd5b50919050565b600060208284031215610e0557600080fd5b610e0e82610d82565b9392505050565b60008060408385031215610e2857600080fd5b610e3183610d82565b946020939093013593505050565b60008060208385031215610e5257600080fd5b823567ffffffffffffffff80821115610e6a57600080fd5b818501915085601f830112610e7e57600080fd5b813581811115610e8d57600080fd5b8660208260051b8501011115610ea257600080fd5b60209290920196919550909350505050565b600060208284031215610ec657600080fd5b610e0e82610dab565b600060208284031215610ee157600080fd5b5035919050565b600080600060e08486031215610efd57600080fd5b610f078585610ddb565b9250610f168560608601610ddb565b9150610f2460c08501610dab565b90509250925092565b6000806000806101008587031215610f4457600080fd5b610f4e8686610ddb565b9350610f5d8660608701610ddb565b9250610f6b60c08601610dab565b9150610f7960e08601610d82565b905092959194509250565b600060208284031215610f9657600080fd5b813563ffffffff81168114610e0e57600080fd5b600060208284031215610fbc57600080fd5b813560ff81168114610e0e57600080fd5b6000835160005b81811015610fee5760208187018101518583015201610fd4565b81811115610ffd576000828501525b5060609390931b7fffffffffffffffffffffffffffffffffffffffff000000000000000000000000169190920190815260140192915050565b60008282101561104857611048611086565b500390565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561107f5761107f611086565b5060010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fdfea26469706673582212202cc95c42f0a51f091c5ebc99a835d7215c8d0dff3046a6ca534be0104e81178664736f6c63430008070033", -} - -// ClaimCodesABI is the input ABI used to generate the binding from. -// Deprecated: Use ClaimCodesMetaData.ABI instead. -var ClaimCodesABI = ClaimCodesMetaData.ABI - -// ClaimCodesBin is the compiled bytecode used for deploying new contracts. -// Deprecated: Use ClaimCodesMetaData.Bin instead. -var ClaimCodesBin = ClaimCodesMetaData.Bin - -// DeployClaimCodes deploys a new Ethereum contract, binding an instance of ClaimCodes to it. -func DeployClaimCodes(auth *bind.TransactOpts, backend bind.ContractBackend, vesting_address common.Address) (common.Address, *types.Transaction, *ClaimCodes, error) { - parsed, err := ClaimCodesMetaData.GetAbi() - if err != nil { - return common.Address{}, nil, nil, err - } - if parsed == nil { - return common.Address{}, nil, nil, errors.New("GetABI returned nil") - } - - address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(ClaimCodesBin), backend, vesting_address) - if err != nil { - return common.Address{}, nil, nil, err - } - return address, tx, &ClaimCodes{ClaimCodesCaller: ClaimCodesCaller{contract: contract}, ClaimCodesTransactor: ClaimCodesTransactor{contract: contract}, ClaimCodesFilterer: ClaimCodesFilterer{contract: contract}}, nil -} - -// ClaimCodes is an auto generated Go binding around an Ethereum contract. -type ClaimCodes struct { - ClaimCodesCaller // Read-only binding to the contract - ClaimCodesTransactor // Write-only binding to the contract - ClaimCodesFilterer // Log filterer for contract events -} - -// ClaimCodesCaller is an auto generated read-only Go binding around an Ethereum contract. -type ClaimCodesCaller struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// ClaimCodesTransactor is an auto generated write-only Go binding around an Ethereum contract. -type ClaimCodesTransactor struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// ClaimCodesFilterer is an auto generated log filtering Go binding around an Ethereum contract events. -type ClaimCodesFilterer struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// ClaimCodesSession is an auto generated Go binding around an Ethereum contract, -// with pre-set call and transact options. -type ClaimCodesSession struct { - Contract *ClaimCodes // 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 -} - -// ClaimCodesCallerSession is an auto generated read-only Go binding around an Ethereum contract, -// with pre-set call options. -type ClaimCodesCallerSession struct { - Contract *ClaimCodesCaller // Generic contract caller binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session -} - -// ClaimCodesTransactorSession is an auto generated write-only Go binding around an Ethereum contract, -// with pre-set transact options. -type ClaimCodesTransactorSession struct { - Contract *ClaimCodesTransactor // Generic contract transactor binding to set the session for - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// ClaimCodesRaw is an auto generated low-level Go binding around an Ethereum contract. -type ClaimCodesRaw struct { - Contract *ClaimCodes // Generic contract binding to access the raw methods on -} - -// ClaimCodesCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. -type ClaimCodesCallerRaw struct { - Contract *ClaimCodesCaller // Generic read-only contract binding to access the raw methods on -} - -// ClaimCodesTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. -type ClaimCodesTransactorRaw struct { - Contract *ClaimCodesTransactor // Generic write-only contract binding to access the raw methods on -} - -// NewClaimCodes creates a new instance of ClaimCodes, bound to a specific deployed contract. -func NewClaimCodes(address common.Address, backend bind.ContractBackend) (*ClaimCodes, error) { - contract, err := bindClaimCodes(address, backend, backend, backend) - if err != nil { - return nil, err - } - return &ClaimCodes{ClaimCodesCaller: ClaimCodesCaller{contract: contract}, ClaimCodesTransactor: ClaimCodesTransactor{contract: contract}, ClaimCodesFilterer: ClaimCodesFilterer{contract: contract}}, nil -} - -// NewClaimCodesCaller creates a new read-only instance of ClaimCodes, bound to a specific deployed contract. -func NewClaimCodesCaller(address common.Address, caller bind.ContractCaller) (*ClaimCodesCaller, error) { - contract, err := bindClaimCodes(address, caller, nil, nil) - if err != nil { - return nil, err - } - return &ClaimCodesCaller{contract: contract}, nil -} - -// NewClaimCodesTransactor creates a new write-only instance of ClaimCodes, bound to a specific deployed contract. -func NewClaimCodesTransactor(address common.Address, transactor bind.ContractTransactor) (*ClaimCodesTransactor, error) { - contract, err := bindClaimCodes(address, nil, transactor, nil) - if err != nil { - return nil, err - } - return &ClaimCodesTransactor{contract: contract}, nil -} - -// NewClaimCodesFilterer creates a new log filterer instance of ClaimCodes, bound to a specific deployed contract. -func NewClaimCodesFilterer(address common.Address, filterer bind.ContractFilterer) (*ClaimCodesFilterer, error) { - contract, err := bindClaimCodes(address, nil, nil, filterer) - if err != nil { - return nil, err - } - return &ClaimCodesFilterer{contract: contract}, nil -} - -// bindClaimCodes binds a generic wrapper to an already deployed contract. -func bindClaimCodes(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := ClaimCodesMetaData.GetAbi() - 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 (_ClaimCodes *ClaimCodesRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _ClaimCodes.Contract.ClaimCodesCaller.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 (_ClaimCodes *ClaimCodesRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _ClaimCodes.Contract.ClaimCodesTransactor.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_ClaimCodes *ClaimCodesRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _ClaimCodes.Contract.ClaimCodesTransactor.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 (_ClaimCodes *ClaimCodesCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _ClaimCodes.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 (_ClaimCodes *ClaimCodesTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _ClaimCodes.Contract.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_ClaimCodes *ClaimCodesTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _ClaimCodes.Contract.contract.Transact(opts, method, params...) -} - -// AllowedCountries is a free data retrieval call binding the contract method 0x34b4947b. -// -// Solidity: function allowed_countries(bytes2 ) view returns(bool) -func (_ClaimCodes *ClaimCodesCaller) AllowedCountries(opts *bind.CallOpts, arg0 [2]byte) (bool, error) { - var out []interface{} - err := _ClaimCodes.contract.Call(opts, &out, "allowed_countries", arg0) - - if err != nil { - return *new(bool), err - } - - out0 := *abi.ConvertType(out[0], new(bool)).(*bool) - - return out0, err - -} - -// AllowedCountries is a free data retrieval call binding the contract method 0x34b4947b. -// -// Solidity: function allowed_countries(bytes2 ) view returns(bool) -func (_ClaimCodes *ClaimCodesSession) AllowedCountries(arg0 [2]byte) (bool, error) { - return _ClaimCodes.Contract.AllowedCountries(&_ClaimCodes.CallOpts, arg0) -} - -// AllowedCountries is a free data retrieval call binding the contract method 0x34b4947b. -// -// Solidity: function allowed_countries(bytes2 ) view returns(bool) -func (_ClaimCodes *ClaimCodesCallerSession) AllowedCountries(arg0 [2]byte) (bool, error) { - return _ClaimCodes.Contract.AllowedCountries(&_ClaimCodes.CallOpts, arg0) -} - -// Commitments is a free data retrieval call binding the contract method 0x839df945. -// -// Solidity: function commitments(bytes32 ) view returns(address) -func (_ClaimCodes *ClaimCodesCaller) Commitments(opts *bind.CallOpts, arg0 [32]byte) (common.Address, error) { - var out []interface{} - err := _ClaimCodes.contract.Call(opts, &out, "commitments", arg0) - - if err != nil { - return *new(common.Address), err - } - - out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) - - return out0, err - -} - -// Commitments is a free data retrieval call binding the contract method 0x839df945. -// -// Solidity: function commitments(bytes32 ) view returns(address) -func (_ClaimCodes *ClaimCodesSession) Commitments(arg0 [32]byte) (common.Address, error) { - return _ClaimCodes.Contract.Commitments(&_ClaimCodes.CallOpts, arg0) -} - -// Commitments is a free data retrieval call binding the contract method 0x839df945. -// -// Solidity: function commitments(bytes32 ) view returns(address) -func (_ClaimCodes *ClaimCodesCallerSession) Commitments(arg0 [32]byte) (common.Address, error) { - return _ClaimCodes.Contract.Commitments(&_ClaimCodes.CallOpts, arg0) -} - -// Controller is a free data retrieval call binding the contract method 0xf77c4791. -// -// Solidity: function controller() view returns(address) -func (_ClaimCodes *ClaimCodesCaller) Controller(opts *bind.CallOpts) (common.Address, error) { - var out []interface{} - err := _ClaimCodes.contract.Call(opts, &out, "controller") - - if err != nil { - return *new(common.Address), err - } - - out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) - - return out0, err - -} - -// Controller is a free data retrieval call binding the contract method 0xf77c4791. -// -// Solidity: function controller() view returns(address) -func (_ClaimCodes *ClaimCodesSession) Controller() (common.Address, error) { - return _ClaimCodes.Contract.Controller(&_ClaimCodes.CallOpts) -} - -// Controller is a free data retrieval call binding the contract method 0xf77c4791. -// -// Solidity: function controller() view returns(address) -func (_ClaimCodes *ClaimCodesCallerSession) Controller() (common.Address, error) { - return _ClaimCodes.Contract.Controller(&_ClaimCodes.CallOpts) -} - -// Issuers is a free data retrieval call binding the contract method 0x38a7543e. -// -// Solidity: function issuers(address ) view returns(uint256) -func (_ClaimCodes *ClaimCodesCaller) Issuers(opts *bind.CallOpts, arg0 common.Address) (*big.Int, error) { - var out []interface{} - err := _ClaimCodes.contract.Call(opts, &out, "issuers", arg0) - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// Issuers is a free data retrieval call binding the contract method 0x38a7543e. -// -// Solidity: function issuers(address ) view returns(uint256) -func (_ClaimCodes *ClaimCodesSession) Issuers(arg0 common.Address) (*big.Int, error) { - return _ClaimCodes.Contract.Issuers(&_ClaimCodes.CallOpts, arg0) -} - -// Issuers is a free data retrieval call binding the contract method 0x38a7543e. -// -// Solidity: function issuers(address ) view returns(uint256) -func (_ClaimCodes *ClaimCodesCallerSession) Issuers(arg0 common.Address) (*big.Int, error) { - return _ClaimCodes.Contract.Issuers(&_ClaimCodes.CallOpts, arg0) -} - -// AllowCountries is a paid mutator transaction binding the contract method 0x9cef4355. -// -// Solidity: function allow_countries(bytes2[] countries) returns() -func (_ClaimCodes *ClaimCodesTransactor) AllowCountries(opts *bind.TransactOpts, countries [][2]byte) (*types.Transaction, error) { - return _ClaimCodes.contract.Transact(opts, "allow_countries", countries) -} - -// AllowCountries is a paid mutator transaction binding the contract method 0x9cef4355. -// -// Solidity: function allow_countries(bytes2[] countries) returns() -func (_ClaimCodes *ClaimCodesSession) AllowCountries(countries [][2]byte) (*types.Transaction, error) { - return _ClaimCodes.Contract.AllowCountries(&_ClaimCodes.TransactOpts, countries) -} - -// AllowCountries is a paid mutator transaction binding the contract method 0x9cef4355. -// -// Solidity: function allow_countries(bytes2[] countries) returns() -func (_ClaimCodes *ClaimCodesTransactorSession) AllowCountries(countries [][2]byte) (*types.Transaction, error) { - return _ClaimCodes.Contract.AllowCountries(&_ClaimCodes.TransactOpts, countries) -} - -// BlockCountries is a paid mutator transaction binding the contract method 0x26bc922a. -// -// Solidity: function block_countries(bytes2[] countries) returns() -func (_ClaimCodes *ClaimCodesTransactor) BlockCountries(opts *bind.TransactOpts, countries [][2]byte) (*types.Transaction, error) { - return _ClaimCodes.contract.Transact(opts, "block_countries", countries) -} - -// BlockCountries is a paid mutator transaction binding the contract method 0x26bc922a. -// -// Solidity: function block_countries(bytes2[] countries) returns() -func (_ClaimCodes *ClaimCodesSession) BlockCountries(countries [][2]byte) (*types.Transaction, error) { - return _ClaimCodes.Contract.BlockCountries(&_ClaimCodes.TransactOpts, countries) -} - -// BlockCountries is a paid mutator transaction binding the contract method 0x26bc922a. -// -// Solidity: function block_countries(bytes2[] countries) returns() -func (_ClaimCodes *ClaimCodesTransactorSession) BlockCountries(countries [][2]byte) (*types.Transaction, error) { - return _ClaimCodes.Contract.BlockCountries(&_ClaimCodes.TransactOpts, countries) -} - -// ClaimTargeted is a paid mutator transaction binding the contract method 0x04df9479. -// -// Solidity: function claim_targeted((uint8,bytes32,bytes32) sig, (uint256,uint8,uint32) clm, bytes2 country, address target) returns() -func (_ClaimCodes *ClaimCodesTransactor) ClaimTargeted(opts *bind.TransactOpts, sig Signature, clm Claim, country [2]byte, target common.Address) (*types.Transaction, error) { - return _ClaimCodes.contract.Transact(opts, "claim_targeted", sig, clm, country, target) -} - -// ClaimTargeted is a paid mutator transaction binding the contract method 0x04df9479. -// -// Solidity: function claim_targeted((uint8,bytes32,bytes32) sig, (uint256,uint8,uint32) clm, bytes2 country, address target) returns() -func (_ClaimCodes *ClaimCodesSession) ClaimTargeted(sig Signature, clm Claim, country [2]byte, target common.Address) (*types.Transaction, error) { - return _ClaimCodes.Contract.ClaimTargeted(&_ClaimCodes.TransactOpts, sig, clm, country, target) -} - -// ClaimTargeted is a paid mutator transaction binding the contract method 0x04df9479. -// -// Solidity: function claim_targeted((uint8,bytes32,bytes32) sig, (uint256,uint8,uint32) clm, bytes2 country, address target) returns() -func (_ClaimCodes *ClaimCodesTransactorSession) ClaimTargeted(sig Signature, clm Claim, country [2]byte, target common.Address) (*types.Transaction, error) { - return _ClaimCodes.Contract.ClaimTargeted(&_ClaimCodes.TransactOpts, sig, clm, country, target) -} - -// ClaimUntargeted is a paid mutator transaction binding the contract method 0xb7d00d0c. -// -// Solidity: function claim_untargeted((uint8,bytes32,bytes32) sig, (uint256,uint8,uint32) clm, bytes2 country) returns() -func (_ClaimCodes *ClaimCodesTransactor) ClaimUntargeted(opts *bind.TransactOpts, sig Signature, clm Claim, country [2]byte) (*types.Transaction, error) { - return _ClaimCodes.contract.Transact(opts, "claim_untargeted", sig, clm, country) -} - -// ClaimUntargeted is a paid mutator transaction binding the contract method 0xb7d00d0c. -// -// Solidity: function claim_untargeted((uint8,bytes32,bytes32) sig, (uint256,uint8,uint32) clm, bytes2 country) returns() -func (_ClaimCodes *ClaimCodesSession) ClaimUntargeted(sig Signature, clm Claim, country [2]byte) (*types.Transaction, error) { - return _ClaimCodes.Contract.ClaimUntargeted(&_ClaimCodes.TransactOpts, sig, clm, country) -} - -// ClaimUntargeted is a paid mutator transaction binding the contract method 0xb7d00d0c. -// -// Solidity: function claim_untargeted((uint8,bytes32,bytes32) sig, (uint256,uint8,uint32) clm, bytes2 country) returns() -func (_ClaimCodes *ClaimCodesTransactorSession) ClaimUntargeted(sig Signature, clm Claim, country [2]byte) (*types.Transaction, error) { - return _ClaimCodes.Contract.ClaimUntargeted(&_ClaimCodes.TransactOpts, sig, clm, country) -} - -// CommitUntargeted is a paid mutator transaction binding the contract method 0xc342cd9b. -// -// Solidity: function commit_untargeted(bytes32 s) returns() -func (_ClaimCodes *ClaimCodesTransactor) CommitUntargeted(opts *bind.TransactOpts, s [32]byte) (*types.Transaction, error) { - return _ClaimCodes.contract.Transact(opts, "commit_untargeted", s) -} - -// CommitUntargeted is a paid mutator transaction binding the contract method 0xc342cd9b. -// -// Solidity: function commit_untargeted(bytes32 s) returns() -func (_ClaimCodes *ClaimCodesSession) CommitUntargeted(s [32]byte) (*types.Transaction, error) { - return _ClaimCodes.Contract.CommitUntargeted(&_ClaimCodes.TransactOpts, s) -} - -// CommitUntargeted is a paid mutator transaction binding the contract method 0xc342cd9b. -// -// Solidity: function commit_untargeted(bytes32 s) returns() -func (_ClaimCodes *ClaimCodesTransactorSession) CommitUntargeted(s [32]byte) (*types.Transaction, error) { - return _ClaimCodes.Contract.CommitUntargeted(&_ClaimCodes.TransactOpts, s) -} - -// Destroy is a paid mutator transaction binding the contract method 0x83197ef0. -// -// Solidity: function destroy() returns() -func (_ClaimCodes *ClaimCodesTransactor) Destroy(opts *bind.TransactOpts) (*types.Transaction, error) { - return _ClaimCodes.contract.Transact(opts, "destroy") -} - -// Destroy is a paid mutator transaction binding the contract method 0x83197ef0. -// -// Solidity: function destroy() returns() -func (_ClaimCodes *ClaimCodesSession) Destroy() (*types.Transaction, error) { - return _ClaimCodes.Contract.Destroy(&_ClaimCodes.TransactOpts) -} - -// Destroy is a paid mutator transaction binding the contract method 0x83197ef0. -// -// Solidity: function destroy() returns() -func (_ClaimCodes *ClaimCodesTransactorSession) Destroy() (*types.Transaction, error) { - return _ClaimCodes.Contract.Destroy(&_ClaimCodes.TransactOpts) -} - -// PermitIssuer is a paid mutator transaction binding the contract method 0x277817c7. -// -// Solidity: function permit_issuer(address issuer, uint256 amount) returns() -func (_ClaimCodes *ClaimCodesTransactor) PermitIssuer(opts *bind.TransactOpts, issuer common.Address, amount *big.Int) (*types.Transaction, error) { - return _ClaimCodes.contract.Transact(opts, "permit_issuer", issuer, amount) -} - -// PermitIssuer is a paid mutator transaction binding the contract method 0x277817c7. -// -// Solidity: function permit_issuer(address issuer, uint256 amount) returns() -func (_ClaimCodes *ClaimCodesSession) PermitIssuer(issuer common.Address, amount *big.Int) (*types.Transaction, error) { - return _ClaimCodes.Contract.PermitIssuer(&_ClaimCodes.TransactOpts, issuer, amount) -} - -// PermitIssuer is a paid mutator transaction binding the contract method 0x277817c7. -// -// Solidity: function permit_issuer(address issuer, uint256 amount) returns() -func (_ClaimCodes *ClaimCodesTransactorSession) PermitIssuer(issuer common.Address, amount *big.Int) (*types.Transaction, error) { - return _ClaimCodes.Contract.PermitIssuer(&_ClaimCodes.TransactOpts, issuer, amount) -} - -// RevokeIssuer is a paid mutator transaction binding the contract method 0x94a4ff3f. -// -// Solidity: function revoke_issuer(address issuer) returns() -func (_ClaimCodes *ClaimCodesTransactor) RevokeIssuer(opts *bind.TransactOpts, issuer common.Address) (*types.Transaction, error) { - return _ClaimCodes.contract.Transact(opts, "revoke_issuer", issuer) -} - -// RevokeIssuer is a paid mutator transaction binding the contract method 0x94a4ff3f. -// -// Solidity: function revoke_issuer(address issuer) returns() -func (_ClaimCodes *ClaimCodesSession) RevokeIssuer(issuer common.Address) (*types.Transaction, error) { - return _ClaimCodes.Contract.RevokeIssuer(&_ClaimCodes.TransactOpts, issuer) -} - -// RevokeIssuer is a paid mutator transaction binding the contract method 0x94a4ff3f. -// -// Solidity: function revoke_issuer(address issuer) returns() -func (_ClaimCodes *ClaimCodesTransactorSession) RevokeIssuer(issuer common.Address) (*types.Transaction, error) { - return _ClaimCodes.Contract.RevokeIssuer(&_ClaimCodes.TransactOpts, issuer) -} - -// SwapController is a paid mutator transaction binding the contract method 0x7eb1b5d7. -// -// Solidity: function swap_controller(address _controller) returns() -func (_ClaimCodes *ClaimCodesTransactor) SwapController(opts *bind.TransactOpts, _controller common.Address) (*types.Transaction, error) { - return _ClaimCodes.contract.Transact(opts, "swap_controller", _controller) -} - -// SwapController is a paid mutator transaction binding the contract method 0x7eb1b5d7. -// -// Solidity: function swap_controller(address _controller) returns() -func (_ClaimCodes *ClaimCodesSession) SwapController(_controller common.Address) (*types.Transaction, error) { - return _ClaimCodes.Contract.SwapController(&_ClaimCodes.TransactOpts, _controller) -} - -// SwapController is a paid mutator transaction binding the contract method 0x7eb1b5d7. -// -// Solidity: function swap_controller(address _controller) returns() -func (_ClaimCodes *ClaimCodesTransactorSession) SwapController(_controller common.Address) (*types.Transaction, error) { - return _ClaimCodes.Contract.SwapController(&_ClaimCodes.TransactOpts, _controller) -} diff --git a/smartcontracts/claimcodes/v1/Claim_Codes.sol b/smartcontracts/claimcodes/v1/Claim_Codes.sol deleted file mode 100644 index c00f9284..00000000 --- a/smartcontracts/claimcodes/v1/Claim_Codes.sol +++ /dev/null @@ -1,188 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.4; - -import "./IVesting.sol"; - -// Structs are used here as they do not incur any overhead, and -// make the function specifications below less tedious - -struct Claim { - uint256 amount; - uint8 tranche; - uint32 expiry; - // This is simply here for reference. Solidity does not have optional params - // and after the London fork, zero bytes are charged more in calldata, so we - // simply leave it out of the struct and add it as an argument where it's - // needed - /* address optionalTarget; */ -} - -// ECDSA signature as struct -struct Signature { - uint8 v; // Must be 27 or 28 - bytes32 r; - bytes32 s; // Must be small order -} - -function hash_claim ( - uint chainid, - Claim calldata c, - address target -) pure returns (bytes32) { - bytes memory _msg = abi.encodePacked(chainid, c.amount, c.tranche, c.expiry); - if (target != address(0)) { - _msg = abi.encodePacked(_msg, target); - } - - return keccak256(_msg); -} - -contract Claim_Codes { - // Only address able to perform management operations - address public controller; - - // Vega vesting contract, which must have this contract registered as an - // issuer for `issue_into_tranche` to work. Marked immutable to assist the - // solidity compiler in inlining - IVesting immutable trusted_vesting_contract; - - // Track committed and spent signatures (codes). The next constants are used - // as special placeholders. Note that uninitialised slots in a map always will - // have the default value (eg address 0x0 in this case) - mapping (bytes32 => address) public commitments; - address constant UNCLAIMED_CODE = address(0); - address constant SPENT_CODE = address(1); - - // Map issuers to their max allowed spending. We may consider here whether we - // actually care about limiting each issuer (signer) spending or not - mapping (address => uint256) public issuers; - - // Allow list of countries that can use claim codes. Mapping uppercase ascii - // ISO 2-letter country codes. - mapping (bytes2 => bool) public allowed_countries; - - constructor (address vesting_address) { - trusted_vesting_contract = IVesting(vesting_address); - controller = msg.sender; - } - - // To prevent front running on untargeted codes, the user can precommit to the - // S part of the signature (ie. the one-time key) - function commit_untargeted (bytes32 s) external { - require(commitments[s] == UNCLAIMED_CODE); - commitments[s] = msg.sender; - } - - // Since solidity/web3 do not support optional arguments, we must have a - // separate function with and without the target argument - function claim_targeted ( - Signature calldata sig, - Claim calldata clm, - bytes2 country, - address target - ) external { - _claim(sig, clm, target, country); - } - - function claim_untargeted ( - Signature calldata sig, - Claim calldata clm, - bytes2 country - ) external { - _claim(sig, clm, address(0), country); - } - - function _claim ( - Signature calldata sig, - Claim calldata clm, - address target, - bytes2 country - ) internal { - require(clm.expiry > block.timestamp, "Claim code has expired"); - require(allowed_countries[country], "Claim code is not available in your country"); - - // Verify the claim was signed by an issuer - bytes32 hash = hash_claim(block.chainid, clm, target); - address issuer = verify(hash, sig); - require(issuer != address(0), "Invalid claim code"); - - // Burn the claim - target = burn_claim(sig, target); - - require(issuer != target, "Cannot claim to yourself"); - uint256 issuer_amount = issuers[issuer]; - require(clm.amount <= issuer_amount, "Out of funds"); - issuers[issuer] = issuer_amount - clm.amount; - - trusted_vesting_contract.issue_into_tranche(target, clm.tranche, clm.amount); - } - - function allow_countries ( - bytes2[] calldata countries - ) only_controller external { - for (uint i = 0; i < countries.length; i++) { - allowed_countries[countries[i]] = true; - } - } - - function block_countries ( - bytes2[] calldata countries - ) only_controller external { - for (uint i = 0; i < countries.length; i++) { - allowed_countries[countries[i]] = false; - } - } - - function permit_issuer (address issuer, uint256 amount) only_controller external { - issuers[issuer] = amount; - } - - function revoke_issuer (address issuer) only_controller external { - delete(issuers[issuer]); - } - - function swap_controller(address _controller) only_controller external { - require(_controller != address(0)); - controller = _controller; - } - - function destroy () only_controller external { - selfdestruct(payable(msg.sender)); - } - - // Strict ECDSA recovery; - // - Only allow small-order s - // - Only allow correct v encoding (27 or 28) - function verify ( - bytes32 hash, - Signature calldata _sig - ) internal pure returns (address) { - if (_sig.s > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) return address(0); - return ecrecover(hash, _sig.v, bytes32(_sig.r), bytes32(_sig.s)); - } - - function burn_claim ( - Signature calldata sig, - address target - ) internal returns (address) { - address _tmp = commitments[sig.s]; - - // If targeted code, just check that it's unspent - if (target != address(0)) { - require(_tmp != SPENT_CODE, "Claim code already spent"); - } - // If untargeted, check that it was committed or unspent - else { - require(_tmp == msg.sender || _tmp == UNCLAIMED_CODE, "Claim code already spent"); - target = msg.sender; - } - - commitments[sig.s] = SPENT_CODE; - return target; - } - - modifier only_controller () { - require(msg.sender == controller); - _; - } -} diff --git a/smartcontracts/claimcodes/v1/IVesting.sol b/smartcontracts/claimcodes/v1/IVesting.sol deleted file mode 100644 index 9cf5b754..00000000 --- a/smartcontracts/claimcodes/v1/IVesting.sol +++ /dev/null @@ -1,10 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.4; - -interface IVesting { - function issue_into_tranche ( - address user, - uint8 tranche, - uint256 amount - ) external; -} diff --git a/smartcontracts/claimcodes/v1/abi.json b/smartcontracts/claimcodes/v1/abi.json deleted file mode 100644 index ee497f32..00000000 --- a/smartcontracts/claimcodes/v1/abi.json +++ /dev/null @@ -1,292 +0,0 @@ -[ - { - "inputs": [ - { - "internalType": "address", - "name": "vesting_address", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [ - { - "internalType": "bytes2[]", - "name": "countries", - "type": "bytes2[]" - } - ], - "name": "allow_countries", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes2", - "name": "", - "type": "bytes2" - } - ], - "name": "allowed_countries", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes2[]", - "name": "countries", - "type": "bytes2[]" - } - ], - "name": "block_countries", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "uint8", - "name": "v", - "type": "uint8" - }, - { - "internalType": "bytes32", - "name": "r", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "s", - "type": "bytes32" - } - ], - "internalType": "struct Signature", - "name": "sig", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - }, - { - "internalType": "uint8", - "name": "tranche", - "type": "uint8" - }, - { - "internalType": "uint32", - "name": "expiry", - "type": "uint32" - } - ], - "internalType": "struct Claim", - "name": "clm", - "type": "tuple" - }, - { - "internalType": "bytes2", - "name": "country", - "type": "bytes2" - }, - { - "internalType": "address", - "name": "target", - "type": "address" - } - ], - "name": "claim_targeted", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "uint8", - "name": "v", - "type": "uint8" - }, - { - "internalType": "bytes32", - "name": "r", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "s", - "type": "bytes32" - } - ], - "internalType": "struct Signature", - "name": "sig", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - }, - { - "internalType": "uint8", - "name": "tranche", - "type": "uint8" - }, - { - "internalType": "uint32", - "name": "expiry", - "type": "uint32" - } - ], - "internalType": "struct Claim", - "name": "clm", - "type": "tuple" - }, - { - "internalType": "bytes2", - "name": "country", - "type": "bytes2" - } - ], - "name": "claim_untargeted", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "s", - "type": "bytes32" - } - ], - "name": "commit_untargeted", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "name": "commitments", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "controller", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "destroy", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "issuers", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "issuer", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "permit_issuer", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "issuer", - "type": "address" - } - ], - "name": "revoke_issuer", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_controller", - "type": "address" - } - ], - "name": "swap_controller", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } -] \ No newline at end of file diff --git a/smartcontracts/claimcodes/v1/download_url.txt b/smartcontracts/claimcodes/v1/download_url.txt deleted file mode 100644 index 72ff60ce..00000000 --- a/smartcontracts/claimcodes/v1/download_url.txt +++ /dev/null @@ -1 +0,0 @@ -https://api.etherscan.io/api?module=contract&action=getsourcecode&address=0x0ee1fb382caf98e86e97e51f9f42f8b4654020f3 \ No newline at end of file diff --git a/smartcontracts/claimcodes/v1/hash.txt b/smartcontracts/claimcodes/v1/hash.txt deleted file mode 100644 index 0c12e917..00000000 --- a/smartcontracts/claimcodes/v1/hash.txt +++ /dev/null @@ -1 +0,0 @@ -ad4ad4f58cc04e4f093bb61dc104443b01689206a2a5e19b395a995a500058a6 \ No newline at end of file diff --git a/smartcontracts/claimcodes/version.go b/smartcontracts/claimcodes/version.go deleted file mode 100644 index 7f89f2af..00000000 --- a/smartcontracts/claimcodes/version.go +++ /dev/null @@ -1,19 +0,0 @@ -package claimcodes - -import ( - "fmt" -) - -type ClaimCodesVersion string - -const ( - ClaimCodesV1 ClaimCodesVersion = "v1" -) - -func (n ClaimCodesVersion) IsValid() error { - switch n { - case ClaimCodesV1: - return nil - } - return fmt.Errorf("Invalid Claim Codes Version %s", n) -} diff --git a/smartcontracts/erc20assetpool/assetpool.go b/smartcontracts/erc20assetpool/assetpool.go index 20244a94..ce6ca8d3 100644 --- a/smartcontracts/erc20assetpool/assetpool.go +++ b/smartcontracts/erc20assetpool/assetpool.go @@ -3,12 +3,12 @@ package erc20assetpool import ( "math/big" + ERC20AssetPool_V1 "github.com/vegaprotocol/devopstools/smartcontracts/erc20assetpool/v1" + "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" - - ERC20AssetPool_V1 "github.com/vegaprotocol/devopstools/smartcontracts/erc20assetpool/v1" ) type ERC20AssetPoolCommon interface { diff --git a/smartcontracts/erc20assetpool/deploy.go b/smartcontracts/erc20assetpool/deploy.go deleted file mode 100644 index f8281068..00000000 --- a/smartcontracts/erc20assetpool/deploy.go +++ /dev/null @@ -1,26 +0,0 @@ -package erc20assetpool - -import ( - "fmt" - - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - ethTypes "github.com/ethereum/go-ethereum/core/types" - - ERC20AssetPool_V1 "github.com/vegaprotocol/devopstools/smartcontracts/erc20assetpool/v1" -) - -func DeployERC20AssetPool( - version ERC20AssetPoolVersion, - auth *bind.TransactOpts, - backend bind.ContractBackend, - multisigControlAddress common.Address, -) (address common.Address, tx *ethTypes.Transaction, err error) { - switch version { - case ERC20AssetPoolV1: - address, tx, _, err = ERC20AssetPool_V1.DeployERC20AssetPool(auth, backend, multisigControlAddress) - default: - err = fmt.Errorf("Invalid ERC20 Asset Pool Version %s", version) - } - return -} diff --git a/smartcontracts/erc20bridge/deploy.go b/smartcontracts/erc20bridge/deploy.go deleted file mode 100644 index 5d8350a6..00000000 --- a/smartcontracts/erc20bridge/deploy.go +++ /dev/null @@ -1,30 +0,0 @@ -package erc20bridge - -import ( - "fmt" - - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - ethTypes "github.com/ethereum/go-ethereum/core/types" - - ERC20Bridge_V1 "github.com/vegaprotocol/devopstools/smartcontracts/erc20bridge/v1" - ERC20Bridge_V2 "github.com/vegaprotocol/devopstools/smartcontracts/erc20bridge/v2" -) - -func DeployERC20Bridge( - version ERC20BridgeVersion, - auth *bind.TransactOpts, - backend bind.ContractBackend, - multisigControlAddress common.Address, - erc20AssetPoolAddress common.Address, -) (address common.Address, tx *ethTypes.Transaction, err error) { - switch version { - case "v1": - address, tx, _, err = ERC20Bridge_V1.DeployERC20Bridge(auth, backend, multisigControlAddress, erc20AssetPoolAddress) - case "v2": - address, tx, _, err = ERC20Bridge_V2.DeployERC20BridgeRestricted(auth, backend, erc20AssetPoolAddress) - default: - err = fmt.Errorf("Invalid ERC20 Bridge Version %s", version) - } - return -} diff --git a/smartcontracts/erc20bridge/erc20bridge.go b/smartcontracts/erc20bridge/erc20bridge.go index 490cb6e2..c6599f06 100644 --- a/smartcontracts/erc20bridge/erc20bridge.go +++ b/smartcontracts/erc20bridge/erc20bridge.go @@ -3,29 +3,29 @@ package erc20bridge import ( "math/big" + ERC20Bridge_V1 "github.com/vegaprotocol/devopstools/smartcontracts/erc20bridge/v1" + ERC20Bridge_V2 "github.com/vegaprotocol/devopstools/smartcontracts/erc20bridge/v2" + "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" - - ERC20Bridge_V1 "github.com/vegaprotocol/devopstools/smartcontracts/erc20bridge/v1" - ERC20Bridge_V2 "github.com/vegaprotocol/devopstools/smartcontracts/erc20bridge/v2" ) type ERC20BridgeCommon interface { GetAssetSource(opts *bind.CallOpts, vega_asset_id [32]byte) (common.Address, error) - //GetDepositMaximum(opts *bind.CallOpts, asset_source common.Address) (*big.Int, error) // removed in v2 - //GetDepositMinimum(opts *bind.CallOpts, asset_source common.Address) (*big.Int, error) // removed in v2 + // GetDepositMaximum(opts *bind.CallOpts, asset_source common.Address) (*big.Int, error) // removed in v2 + // GetDepositMinimum(opts *bind.CallOpts, asset_source common.Address) (*big.Int, error) // removed in v2 GetMultisigControlAddress(opts *bind.CallOpts) (common.Address, error) GetVegaAssetId(opts *bind.CallOpts, asset_source common.Address) ([32]byte, error) IsAssetListed(opts *bind.CallOpts, asset_source common.Address) (bool, error) DepositAsset(opts *bind.TransactOpts, asset_source common.Address, amount *big.Int, vega_public_key [32]byte) (*types.Transaction, error) - //ListAsset(opts *bind.TransactOpts, asset_source common.Address, vega_asset_id [32]byte, nonce *big.Int, signatures []byte) (*types.Transaction, error) // changed in v2 + // ListAsset(opts *bind.TransactOpts, asset_source common.Address, vega_asset_id [32]byte, nonce *big.Int, signatures []byte) (*types.Transaction, error) // changed in v2 RemoveAsset(opts *bind.TransactOpts, asset_source common.Address, nonce *big.Int, signatures []byte) (*types.Transaction, error) - //SetDepositMaximum(opts *bind.TransactOpts, asset_source common.Address, maximum_amount *big.Int, nonce *big.Int, signatures []byte) (*types.Transaction, error) // removed in v2 - //SetDepositMinimum(opts *bind.TransactOpts, asset_source common.Address, minimum_amount *big.Int, nonce *big.Int, signatures []byte) (*types.Transaction, error) // removed in v2 - //WithdrawAsset(opts *bind.TransactOpts, asset_source common.Address, amount *big.Int, target common.Address, nonce *big.Int, signatures []byte) (*types.Transaction, error) // changed in v2 + // SetDepositMaximum(opts *bind.TransactOpts, asset_source common.Address, maximum_amount *big.Int, nonce *big.Int, signatures []byte) (*types.Transaction, error) // removed in v2 + // SetDepositMinimum(opts *bind.TransactOpts, asset_source common.Address, minimum_amount *big.Int, nonce *big.Int, signatures []byte) (*types.Transaction, error) // removed in v2 + // WithdrawAsset(opts *bind.TransactOpts, asset_source common.Address, amount *big.Int, target common.Address, nonce *big.Int, signatures []byte) (*types.Transaction, error) // changed in v2 } type ERC20BridgeNewInV2 interface { diff --git a/smartcontracts/erc20token/deploy.go b/smartcontracts/erc20token/deploy.go deleted file mode 100644 index 74e177c9..00000000 --- a/smartcontracts/erc20token/deploy.go +++ /dev/null @@ -1,30 +0,0 @@ -package erc20token - -import ( - "fmt" - "math/big" - - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - ethTypes "github.com/ethereum/go-ethereum/core/types" - - ERC20Token_TokenBase "github.com/vegaprotocol/devopstools/smartcontracts/erc20token/TokenBase" -) - -func DeployERC20Token( - version ERC20TokenVersion, - auth *bind.TransactOpts, - backend bind.ContractBackend, - name string, - symbol string, - decimals uint8, - totalSupply *big.Int, -) (address common.Address, tx *ethTypes.Transaction, err error) { - switch version { - case ERC20TokenBase: - address, tx, _, err = ERC20Token_TokenBase.DeployTokenBase(auth, backend, name, symbol, decimals, totalSupply) - default: - err = fmt.Errorf("Invalid ERC20 Token Version %s", version) - } - return -} diff --git a/smartcontracts/erc20token/erc20token.go b/smartcontracts/erc20token/erc20token.go index 9378beb9..7842317f 100644 --- a/smartcontracts/erc20token/erc20token.go +++ b/smartcontracts/erc20token/erc20token.go @@ -3,15 +3,15 @@ package erc20token 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" - ERC20Token_IERC20 "github.com/vegaprotocol/devopstools/smartcontracts/erc20token/IERC20" ERC20Token_TokenBase "github.com/vegaprotocol/devopstools/smartcontracts/erc20token/TokenBase" ERC20Token_TokenOld "github.com/vegaprotocol/devopstools/smartcontracts/erc20token/TokenOld" ERC20Token_TokenOther "github.com/vegaprotocol/devopstools/smartcontracts/erc20token/TokenOther" + + "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" ) // diff --git a/smartcontracts/erc20token/info.go b/smartcontracts/erc20token/info.go index 33d4c9b7..7659a08c 100644 --- a/smartcontracts/erc20token/info.go +++ b/smartcontracts/erc20token/info.go @@ -4,8 +4,9 @@ import ( "fmt" "math/big" - "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/vegaprotocol/devopstools/ethutils" + + "github.com/ethereum/go-ethereum/accounts/abi/bind" ) type ERC20TokenInfo struct { diff --git a/smartcontracts/erc20token/mint.go b/smartcontracts/erc20token/mint.go index fe3db9f3..14e0239b 100644 --- a/smartcontracts/erc20token/mint.go +++ b/smartcontracts/erc20token/mint.go @@ -10,12 +10,13 @@ import ( ) func (t *ERC20Token) Mint(opts *bind.TransactOpts, to common.Address, amount *big.Int) (*types.Transaction, error) { - switch t.Version { case ERC20TokenBase: return t.v_TokenBase.Mint(opts, to, amount) case ERC20TokenOld: return t.v_TokenOld.Issue(opts, to, amount) + case ERC20TokenOther, ERC20TokenMinimal: + return nil, nil default: return nil, fmt.Errorf("not implemented for token %s", t.Version) } diff --git a/smartcontracts/erc20token/version.go b/smartcontracts/erc20token/version.go index 7b562d3a..5ae95d42 100644 --- a/smartcontracts/erc20token/version.go +++ b/smartcontracts/erc20token/version.go @@ -18,5 +18,5 @@ func (n ERC20TokenVersion) IsValid() error { case ERC20TokenBase, ERC20TokenOld, ERC20TokenOther, ERC20TokenMinimal: return nil } - return fmt.Errorf("Invalid ERC20 Token Version %s", n) + return fmt.Errorf("invalid ERC20 Token Version %s", n) } diff --git a/smartcontracts/manager.go b/smartcontracts/manager.go index 33d1a613..01a7e68c 100644 --- a/smartcontracts/manager.go +++ b/smartcontracts/manager.go @@ -2,12 +2,12 @@ package smartcontracts import ( "github.com/vegaprotocol/devopstools/ethutils" + "go.uber.org/zap" ) type SmartContractsManager struct { ethClientManager *ethutils.EthereumClientManager - ethURL string logger *zap.Logger } @@ -20,15 +20,3 @@ func NewSmartContractsManager( logger: logger, } } - -// -// Instance created with this function provides limited functionality -// - -func NewSmartContractsManagerWithEthURL( - ethURL string, -) *SmartContractsManager { - return &SmartContractsManager{ - ethURL: ethURL, - } -} diff --git a/smartcontracts/multisigcontrol/deploy.go b/smartcontracts/multisigcontrol/deploy.go deleted file mode 100644 index 0d9596b8..00000000 --- a/smartcontracts/multisigcontrol/deploy.go +++ /dev/null @@ -1,28 +0,0 @@ -package multisigcontrol - -import ( - "fmt" - - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - ethTypes "github.com/ethereum/go-ethereum/core/types" - - MultisigControl_V1 "github.com/vegaprotocol/devopstools/smartcontracts/multisigcontrol/v1" - MultisigControl_V2 "github.com/vegaprotocol/devopstools/smartcontracts/multisigcontrol/v2" -) - -func DeployMultisigControl( - version MultisigControlVersion, - auth *bind.TransactOpts, - backend bind.ContractBackend, -) (address common.Address, tx *ethTypes.Transaction, err error) { - switch version { - case MultisigControlV1: - address, tx, _, err = MultisigControl_V1.DeployMultisigControl(auth, backend) - case MultisigControlV2: - address, tx, _, err = MultisigControl_V2.DeployMultisigControl(auth, backend) - default: - err = fmt.Errorf("Invalid Multisig Control Version %s", version) - } - return -} diff --git a/smartcontracts/multisigcontrol/multisigcontrol.go b/smartcontracts/multisigcontrol/multisigcontrol.go index aabf3888..76cc1930 100644 --- a/smartcontracts/multisigcontrol/multisigcontrol.go +++ b/smartcontracts/multisigcontrol/multisigcontrol.go @@ -3,13 +3,13 @@ package multisigcontrol import ( "math/big" + MultisigControl_V1 "github.com/vegaprotocol/devopstools/smartcontracts/multisigcontrol/v1" + MultisigControl_V2 "github.com/vegaprotocol/devopstools/smartcontracts/multisigcontrol/v2" + "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" ethTypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethclient" - - MultisigControl_V1 "github.com/vegaprotocol/devopstools/smartcontracts/multisigcontrol/v1" - MultisigControl_V2 "github.com/vegaprotocol/devopstools/smartcontracts/multisigcontrol/v2" ) type MultisigControlCommon interface { diff --git a/smartcontracts/stakingbridge/deploy.go b/smartcontracts/stakingbridge/deploy.go deleted file mode 100644 index 2c524c6e..00000000 --- a/smartcontracts/stakingbridge/deploy.go +++ /dev/null @@ -1,26 +0,0 @@ -package stakingbridge - -import ( - "fmt" - - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - ethTypes "github.com/ethereum/go-ethereum/core/types" - - StakingBridge_V1 "github.com/vegaprotocol/devopstools/smartcontracts/stakingbridge/v1" -) - -func DeployStakingBridge( - version StakingBridgeVersion, - auth *bind.TransactOpts, - backend bind.ContractBackend, - vegaTokenAddress common.Address, -) (address common.Address, tx *ethTypes.Transaction, err error) { - switch version { - case StakingBridgeV1: - address, tx, _, err = StakingBridge_V1.DeployStakingBridge(auth, backend, vegaTokenAddress) - default: - err = fmt.Errorf("Invalid Staking Bridge Version %s", version) - } - return -} diff --git a/smartcontracts/stakingbridge/stake.go b/smartcontracts/stakingbridge/stake.go index bfe50b5a..17b81477 100644 --- a/smartcontracts/stakingbridge/stake.go +++ b/smartcontracts/stakingbridge/stake.go @@ -5,11 +5,12 @@ import ( "fmt" "math/big" + "github.com/vegaprotocol/devopstools/ethutils" + StakingBridge_V1 "github.com/vegaprotocol/devopstools/smartcontracts/stakingbridge/v1" + "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/vegaprotocol/devopstools/ethutils" - StakingBridge_V1 "github.com/vegaprotocol/devopstools/smartcontracts/stakingbridge/v1" ) func (sb *StakingBridge) GetStakeBalance( @@ -55,7 +56,7 @@ func (sb *StakingBridge) GetStakeBalance( return nil, fmt.Errorf("failed to get balance for '%s', failed to Filter Stake Removed events, %w", vegaPubKey, err) } for removedIterator.Next() { - //fmt.Printf("remove %#v\n", depositedIterator.Event) + // fmt.Printf("remove %#v\n", depositedIterator.Event) balance = balance.Sub(balance, removedIterator.Event.Amount) } diff --git a/smartcontracts/stakingbridge/stakingbridge.go b/smartcontracts/stakingbridge/stakingbridge.go index f774872a..239a9a5a 100644 --- a/smartcontracts/stakingbridge/stakingbridge.go +++ b/smartcontracts/stakingbridge/stakingbridge.go @@ -3,12 +3,12 @@ package stakingbridge import ( "math/big" + StakingBridge_V1 "github.com/vegaprotocol/devopstools/smartcontracts/stakingbridge/v1" + "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" - - StakingBridge_V1 "github.com/vegaprotocol/devopstools/smartcontracts/stakingbridge/v1" ) type StakingBridgeCommon interface { diff --git a/tools/filesystem.go b/tools/filesystem.go index 382d9bb9..1d53e170 100644 --- a/tools/filesystem.go +++ b/tools/filesystem.go @@ -63,15 +63,16 @@ func CopyDir(src, dst string) error { // handle irregular files if !info.Mode().IsRegular() { - switch info.Mode().Type() & os.ModeType { + switch info.Mode().Type() & os.ModeType { //nolint:exhaustive case os.ModeSymlink: link, err := os.Readlink(path) if err != nil { return fmt.Errorf("failed to read link: %w", err) } return os.Symlink(link, outpath) + default: + return nil } - return nil } // copy contents of regular file efficiently diff --git a/tools/tendermint.go b/tools/tendermint.go index 1b524ef4..257e9aa5 100644 --- a/tools/tendermint.go +++ b/tools/tendermint.go @@ -38,9 +38,7 @@ type NetInfo struct { } func (c *TendermintRESTClient) GetNodeNetInfo(endpoint string) (*NetInfo, error) { - var ( - errMsg = "failed to get Tendermint Node Net Info, %w" - ) + errMsg := "failed to get Tendermint Node Net Info, %w" u, err := url.Parse(endpoint) if err != nil { return nil, fmt.Errorf(errMsg, err) @@ -77,9 +75,7 @@ type Status struct { } func (c *TendermintRESTClient) GetNodeStatus(endpoint string) (*Status, error) { - var ( - errMsg = "failed to get Tendermint Node Status, %w" - ) + errMsg := "failed to get Tendermint Node Status, %w" u, err := url.Parse(endpoint) if err != nil { return nil, fmt.Errorf(errMsg, err) diff --git a/types/ethereum.go b/types/ethereum.go index bb2ee454..c4a6f9bb 100644 --- a/types/ethereum.go +++ b/types/ethereum.go @@ -11,12 +11,11 @@ const ( ETHSepolia ETHNetwork = "sepolia" ETHGoerli ETHNetwork = "goerli" ETHRopsten ETHNetwork = "ropsten" - ETHLocal ETHNetwork = "local" ) func (n ETHNetwork) IsValid() error { switch n { - case ETHMainnet, ETHSepolia, ETHGoerli, ETHRopsten, ETHLocal: + case ETHMainnet, ETHSepolia, ETHGoerli, ETHRopsten: return nil } return fmt.Errorf("Invalid Ethereum network %s", n) diff --git a/types/networkparams.go b/types/networkparams.go index 47cc588c..fa94b44d 100644 --- a/types/networkparams.go +++ b/types/networkparams.go @@ -8,6 +8,7 @@ import ( "code.vegaprotocol.io/vega/core/netparams" "code.vegaprotocol.io/vega/protos/vega" + "google.golang.org/protobuf/encoding/protojson" ) diff --git a/vegaapi/client.go b/vegaapi/client.go index 634fd120..de89773d 100644 --- a/vegaapi/client.go +++ b/vegaapi/client.go @@ -3,13 +3,13 @@ package vegaapi import ( "math/big" + "github.com/vegaprotocol/devopstools/vegaapi/datanode" + dataapipb "code.vegaprotocol.io/vega/protos/data-node/api/v2" v2 "code.vegaprotocol.io/vega/protos/data-node/api/v2" "code.vegaprotocol.io/vega/protos/vega" vegaapipb "code.vegaprotocol.io/vega/protos/vega/api/v1" vegaeventspb "code.vegaprotocol.io/vega/protos/vega/events/v1" - - "github.com/vegaprotocol/devopstools/vegaapi/datanode" ) type VegaCoreClient interface { diff --git a/vegaapi/core/core.go b/vegaapi/core/core.go index 8c175460..f12676dc 100644 --- a/vegaapi/core/core.go +++ b/vegaapi/core/core.go @@ -4,11 +4,12 @@ import ( "context" "fmt" + e "github.com/vegaprotocol/devopstools/errors" + "code.vegaprotocol.io/vega/protos/vega" vegaapipb "code.vegaprotocol.io/vega/protos/vega/api/v1" - "google.golang.org/grpc/connectivity" - e "github.com/vegaprotocol/devopstools/errors" + "google.golang.org/grpc/connectivity" ) // === CoreService === diff --git a/vegaapi/core/coreclient.go b/vegaapi/core/coreclient.go index fed98a49..5ecb11a1 100644 --- a/vegaapi/core/coreclient.go +++ b/vegaapi/core/coreclient.go @@ -8,6 +8,7 @@ import ( "time" vegaapipb "code.vegaprotocol.io/vega/protos/vega/api/v1" + "go.uber.org/zap" "google.golang.org/grpc" "google.golang.org/grpc/connectivity" diff --git a/vegaapi/core/faucet.go b/vegaapi/core/faucet.go index a7815d0f..5b545be8 100644 --- a/vegaapi/core/faucet.go +++ b/vegaapi/core/faucet.go @@ -16,7 +16,6 @@ func (n *CoreClient) DepositBuiltinAsset( amount string, signAny func([]byte) ([]byte, string, error), ) (bool, error) { - chainEvent := &commandspb.ChainEvent{ Nonce: vgrand.NewNonce(), Event: &commandspb.ChainEvent_Builtin{ diff --git a/vegaapi/datanode/datanode.go b/vegaapi/datanode/datanode.go index 0f0aaf54..b1dc6d91 100644 --- a/vegaapi/datanode/datanode.go +++ b/vegaapi/datanode/datanode.go @@ -4,6 +4,7 @@ import ( "time" "github.com/vegaprotocol/devopstools/vegaapi/core" + "go.uber.org/zap" ) diff --git a/vegaapi/datanode/events.go b/vegaapi/datanode/events.go index 7c5ee7e6..8186d8e0 100644 --- a/vegaapi/datanode/events.go +++ b/vegaapi/datanode/events.go @@ -6,6 +6,7 @@ import ( dataapipb "code.vegaprotocol.io/vega/protos/data-node/api/v2" vegaeventspb "code.vegaprotocol.io/vega/protos/vega/events/v1" + "google.golang.org/grpc/connectivity" ) diff --git a/vegaapi/datanode/governance.go b/vegaapi/datanode/governance.go index bf25567c..98864292 100644 --- a/vegaapi/datanode/governance.go +++ b/vegaapi/datanode/governance.go @@ -4,8 +4,10 @@ import ( "context" "fmt" - dataapipb "code.vegaprotocol.io/vega/protos/data-node/api/v2" e "github.com/vegaprotocol/devopstools/errors" + + dataapipb "code.vegaprotocol.io/vega/protos/data-node/api/v2" + "google.golang.org/grpc/connectivity" ) diff --git a/vegaapi/datanode/networkhistory.go b/vegaapi/datanode/networkhistory.go index 0a2b18bd..f7ea8940 100644 --- a/vegaapi/datanode/networkhistory.go +++ b/vegaapi/datanode/networkhistory.go @@ -5,6 +5,7 @@ import ( "fmt" dataapipb "code.vegaprotocol.io/vega/protos/data-node/api/v2" + "google.golang.org/grpc/connectivity" ) diff --git a/vegaapi/datanode/party.go b/vegaapi/datanode/party.go index eed19210..bb4aa11f 100644 --- a/vegaapi/datanode/party.go +++ b/vegaapi/datanode/party.go @@ -5,9 +5,11 @@ import ( "fmt" "math/big" + e "github.com/vegaprotocol/devopstools/errors" + dataapipb "code.vegaprotocol.io/vega/protos/data-node/api/v2" "code.vegaprotocol.io/vega/protos/vega" - e "github.com/vegaprotocol/devopstools/errors" + "google.golang.org/grpc/connectivity" ) @@ -126,7 +128,6 @@ func (n *DataNode) GetFunds(partyID string, accountType vega.AccountType, assetI AssetId: assetIdFilter, }, }) - if err != nil { return nil, fmt.Errorf("failed to list accounts: %w", err) } diff --git a/vegaapi/datanode/referral.go b/vegaapi/datanode/referral.go index c8cc6612..a54b292b 100644 --- a/vegaapi/datanode/referral.go +++ b/vegaapi/datanode/referral.go @@ -4,9 +4,11 @@ import ( "context" "fmt" + e "github.com/vegaprotocol/devopstools/errors" + dataapipb "code.vegaprotocol.io/vega/protos/data-node/api/v2" v2 "code.vegaprotocol.io/vega/protos/data-node/api/v2" - e "github.com/vegaprotocol/devopstools/errors" + "google.golang.org/grpc/connectivity" ) @@ -110,7 +112,6 @@ func (n *DataNode) GetReferralSetReferees() (map[string]v2.ReferralSetReferee, e } } return referralSetReferees, nil - } func (n *DataNode) ListReferralSetReferees(req *dataapipb.ListReferralSetRefereesRequest) (response *dataapipb.ListReferralSetRefereesResponse, err error) { diff --git a/vegaapi/datanode/snapshots.go b/vegaapi/datanode/snapshots.go index fd4843a2..dd465c6a 100644 --- a/vegaapi/datanode/snapshots.go +++ b/vegaapi/datanode/snapshots.go @@ -6,6 +6,7 @@ import ( dataapipb "code.vegaprotocol.io/vega/protos/data-node/api/v2" vegaeventspb "code.vegaprotocol.io/vega/protos/vega/events/v1" + "google.golang.org/grpc/connectivity" ) diff --git a/vegaapi/datanode/stats.go b/vegaapi/datanode/stats.go index 2eec4861..e20573c1 100644 --- a/vegaapi/datanode/stats.go +++ b/vegaapi/datanode/stats.go @@ -4,9 +4,11 @@ import ( "context" "fmt" + e "github.com/vegaprotocol/devopstools/errors" + dataapipb "code.vegaprotocol.io/vega/protos/data-node/api/v2" "code.vegaprotocol.io/vega/protos/vega" - e "github.com/vegaprotocol/devopstools/errors" + "google.golang.org/grpc/connectivity" ) diff --git a/vegaapi/datanode/trading.go b/vegaapi/datanode/trading.go index 5e40af0f..0926df65 100644 --- a/vegaapi/datanode/trading.go +++ b/vegaapi/datanode/trading.go @@ -4,9 +4,11 @@ import ( "context" "fmt" + e "github.com/vegaprotocol/devopstools/errors" + dataapipb "code.vegaprotocol.io/vega/protos/data-node/api/v2" "code.vegaprotocol.io/vega/protos/vega" - e "github.com/vegaprotocol/devopstools/errors" + "google.golang.org/grpc/connectivity" ) diff --git a/vegaapi/datanode/volume_discount.go b/vegaapi/datanode/volume_discount.go index 8802624b..65cf72f3 100644 --- a/vegaapi/datanode/volume_discount.go +++ b/vegaapi/datanode/volume_discount.go @@ -4,8 +4,10 @@ import ( "context" "fmt" - dataapipb "code.vegaprotocol.io/vega/protos/data-node/api/v2" e "github.com/vegaprotocol/devopstools/errors" + + dataapipb "code.vegaprotocol.io/vega/protos/data-node/api/v2" + "google.golang.org/grpc/connectivity" ) diff --git a/vegacapsule/commands.go b/vegacapsule/commands.go index 6fa74ce4..9241464e 100644 --- a/vegacapsule/commands.go +++ b/vegacapsule/commands.go @@ -7,6 +7,7 @@ import ( "path/filepath" "github.com/vegaprotocol/devopstools/tools" + "go.uber.org/zap" ) diff --git a/veganetwork/deposit.go b/veganetwork/deposit.go index 9e14870f..f47f28c2 100644 --- a/veganetwork/deposit.go +++ b/veganetwork/deposit.go @@ -1,18 +1,14 @@ package veganetwork import ( - "encoding/hex" "fmt" "math/big" - "math/rand" "sync" - "time" - "code.vegaprotocol.io/vega/protos/vega" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - ethTypes "github.com/ethereum/go-ethereum/core/types" - "github.com/vegaprotocol/devopstools/ethutils" "github.com/vegaprotocol/devopstools/networktools" + + "code.vegaprotocol.io/vega/protos/vega" + "go.uber.org/zap" ) @@ -34,7 +30,6 @@ func DepositAssetsToParties( config []DepositConfig, logger *zap.Logger, ) []DepositResult { - resultsChannel := make(chan DepositResult, len(config)) var wg sync.WaitGroup @@ -58,7 +53,6 @@ func DepositAssetsToParties( } return result - } func DepositAssetToParties( @@ -67,7 +61,6 @@ func DepositAssetToParties( config DepositConfig, logger *zap.Logger, ) DepositResult { - assets, err := network.DataNodeClient.GetAssets() if err != nil { return DepositResult{ @@ -90,7 +83,6 @@ func DepositAssetToParties( network, erc20asset.ContractAddress, config, logger, ) } else { - return DepositResult{ AssetId: config.AssetId, Err: fmt.Errorf("unsupported asset type %+v", asset.GetSource()), @@ -99,10 +91,10 @@ func DepositAssetToParties( } func DepositERC20TokenToParties( - network *VegaNetwork, - tokenHexAddress string, - config DepositConfig, - logger *zap.Logger, + _ *VegaNetwork, + _ string, + _ DepositConfig, + _ *zap.Logger, ) DepositResult { return DepositResult{} } @@ -112,216 +104,10 @@ func DepositERC20TokenToParties( // func DepositFakeAssetToParties( - networktools *networktools.NetworkTools, - asset *vega.BuiltinAsset, - config DepositConfig, - logger *zap.Logger, + _ *networktools.NetworkTools, + _ *vega.BuiltinAsset, + _ DepositConfig, + _ *zap.Logger, ) DepositResult { return DepositResult{} } - -func depositERC20TokenToPartiess( - network *VegaNetwork, - tokenHexAddress string, - vegaPubKeys []string, - humanDepositAmount *big.Float, // in full tokens, i.e. without decimals zeros - logger *zap.Logger, -) error { - // - // Setup - // - var ( - errMsg = fmt.Sprintf("failed to deposit %s to %d parites on %s network", tokenHexAddress, len(vegaPubKeys), network.Network) - minterWallet = network.NetworkMainWallet - erc20bridge = network.SmartContracts.ERC20Bridge - flowId = rand.Int() - ) - token, err := network.SmartContractsManager.GetAssetWithAddress(tokenHexAddress) - if err != nil { - return fmt.Errorf("failed to get token %s, %s: %w", tokenHexAddress, errMsg, err) - } - tokenInfo, err := token.GetInfo() - if err != nil { - return fmt.Errorf("failed to get token info %s, %s: %w", tokenHexAddress, errMsg, err) - } - logger.Info("deposit", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name), - zap.String("token-address", token.Address.Hex()), zap.String("erc20bridge", erc20bridge.Address.Hex()), - zap.String("minter", minterWallet.Address.Hex()), zap.String("amount-per-party", humanDepositAmount.String()), - zap.Int("party-count", len(vegaPubKeys)), zap.Any("parties", vegaPubKeys)) - - // - // Mint enough tokens and Increase Allowance - // - var ( - humanTotalDepositAmount = new(big.Float).Mul(humanDepositAmount, big.NewFloat(float64(len(vegaPubKeys)))) - totalDepositAmount = ethutils.TokenFromFullTokens(humanTotalDepositAmount, tokenInfo.Decimals) - balance *big.Int - allowance *big.Int - mintTx *ethTypes.Transaction - allowanceTx *ethTypes.Transaction - ) - balance, err = token.BalanceOf(&bind.CallOpts{}, minterWallet.Address) - if err != nil { - return fmt.Errorf("failed to get %s balance of minter %s, %s: %w", tokenInfo.Name, minterWallet.Address.Hex(), errMsg, err) - } - if balance.Cmp(totalDepositAmount) < 0 { - diff := new(big.Int).Sub(totalDepositAmount, balance) - opts := minterWallet.GetTransactOpts() - logger.Info("minting", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name), - zap.String("minter", minterWallet.Address.Hex()), - zap.String("balance", balance.String()), zap.String("mint-amount", diff.String()), - zap.String("required", totalDepositAmount.String())) - mintTx, err = token.Mint(opts, minterWallet.Address, diff) - if err != nil { - return fmt.Errorf("failed to mint, %s: %w", errMsg, err) - } - } else { - logger.Info("no need to mint", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name), - zap.String("minter", minterWallet.Address.Hex()), - zap.String("balance", balance.String()), zap.String("required", totalDepositAmount.String())) - } - allowance, err = token.Allowance(&bind.CallOpts{}, minterWallet.Address, erc20bridge.Address) - if err != nil { - return fmt.Errorf("failed to get allowance, %s: %w", errMsg, err) - } - if allowance.Cmp(totalDepositAmount) < 0 { - diff := new(big.Int).Sub(totalDepositAmount, balance) - opts := minterWallet.GetTransactOpts() - logger.Info("increasing allowance", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name), - zap.String("minter", minterWallet.Address.Hex()), - zap.String("allowance", allowance.String()), zap.String("increasing-by", diff.String()), - zap.String("required", totalDepositAmount.String())) - allowanceTx, err = token.IncreaseAllowance(opts, erc20bridge.Address, diff) - if err != nil { - return fmt.Errorf("failed to increase allowance, %s: %w", errMsg, err) - } - } else { - logger.Info("no need to increasing allowance", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name), - zap.String("minter", minterWallet.Address.Hex()), - zap.String("allowance", allowance.String()), zap.String("required", totalDepositAmount.String())) - } - // wait - if mintTx != nil { - if err = ethutils.WaitForTransaction(network.EthClient, mintTx, time.Minute); err != nil { - logger.Error("failed to mint", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name), zap.Error(err)) - return fmt.Errorf("transaction failed to mint, %s: %w", errMsg, err) - } - logger.Info("successfully minted", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name)) - } - if allowanceTx != nil { - if err = ethutils.WaitForTransaction(network.EthClient, allowanceTx, time.Minute); err != nil { - logger.Error("failed to increase allowance", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name), zap.Error(err)) - return fmt.Errorf("transaction failed to increase allowance, %s: %w", errMsg, err) - } - logger.Info("successfully increased allowance", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name)) - } - - // - // DEPOSIT to ERC20 Bridge - // - var ( - depositTxs = make([]*ethTypes.Transaction, len(vegaPubKeys)) - depositAmount = ethutils.TokenFromFullTokens(humanDepositAmount, tokenInfo.Decimals) - success, failure int - ) - for i, pubKey := range vegaPubKeys { - bytePubKey, err := hex.DecodeString(pubKey) - if err != nil { - return err - } - var byte32PubKey [32]byte - copy(byte32PubKey[:], bytePubKey) - - opts := minterWallet.GetTransactOpts() - logger.Debug("depositing", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name), - zap.String("vegaPubKey", pubKey), zap.String("amount", depositAmount.String())) - depositTxs[i], err = erc20bridge.DepositAsset(opts, token.Address, depositAmount, byte32PubKey) - if err != nil { - failure += 1 - logger.Error("failed to deposit", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name), - zap.String("vegaPubKey", pubKey), zap.String("amount", depositAmount.String()), - zap.Error(err)) - } - } - // wait - for i, tx := range depositTxs { - if tx == nil { - continue - } - logger.Debug("waiting", zap.Any("tx", tx)) - if err = ethutils.WaitForTransaction(network.EthClient, tx, time.Minute); err != nil { - failure += 1 - logger.Error("failed to deposit", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name), - zap.Any("tx", tx), - zap.String("vegaPubKey", vegaPubKeys[i]), zap.String("amount", depositAmount.String()), zap.Error(err)) - } else { - success += 1 - logger.Debug("successfully deposited", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name), - zap.String("vegaPubKey", vegaPubKeys[i]), zap.String("amount", depositAmount.String())) - } - } - logger.Info("Summary", zap.Int("flow", flowId), zap.String("token", tokenInfo.Name), - zap.Int("success-count", success), zap.Int("fail-count", failure)) - if failure > 0 { - return fmt.Errorf("%s", errMsg) - } - return nil -} - -func depositFakeAssetToParties( - networktools *networktools.NetworkTools, - assetId string, - asset *vega.AssetDetails, - vegaPubKeys []string, - humanMintAmount *big.Float, // in full tokens, i.e. without decimals zeros - logger *zap.Logger, -) error { - var ( - mintAmount = ethutils.TokenFromFullTokens(humanMintAmount, uint8(asset.Decimals)) - flowId = rand.Int() - ) - if maxFaucetMintAmount, ok := new(big.Int).SetString(asset.GetBuiltinAsset().MaxFaucetAmountMint, 0); ok { - if maxFaucetMintAmount.Cmp(mintAmount) < 0 { - mintAmount = maxFaucetMintAmount - } - } - logger.Info("topping up fake", zap.Int("flow", flowId), zap.String("mint amount", mintAmount.String()), zap.String("asset", asset.Name), zap.Int("parties-count", len(vegaPubKeys))) - - resultsChannel := make(chan error, len(vegaPubKeys)) - var wg sync.WaitGroup - - // Trigger ERC20 TopUps - for _, vegaPubKeys := range vegaPubKeys { - wg.Add(1) - go func(vegaAssetId string, vegaPubKey string) { - defer wg.Done() - err := networktools.MintFakeTokens(vegaPubKey, vegaAssetId, mintAmount) - resultsChannel <- err - if err != nil { - logger.Error("failed to mint", zap.Int("flow", flowId), zap.String("assetId", vegaAssetId), zap.String("vegaPubKey", vegaPubKey), zap.Error(err)) - } - }(assetId, vegaPubKeys) - } - wg.Wait() - close(resultsChannel) - - var ( - success, failure int - failed = false - ) - for err := range resultsChannel { - if err != nil { - failed = true - failure += 1 - } else { - success += 1 - } - } - logger.Info("Summary fake asset", zap.Int("flow", flowId), zap.String("sssetId", assetId), - zap.Int("success-count", success), zap.Int("fail-count", failure)) - if failed { - return fmt.Errorf("failed to top up all the parties (success: %d, failure: %d)", success, failure) - } - - return nil -} diff --git a/veganetwork/network.go b/veganetwork/network.go index cdffbc70..322cc6ef 100644 --- a/veganetwork/network.go +++ b/veganetwork/network.go @@ -3,8 +3,6 @@ package veganetwork import ( "fmt" - "code.vegaprotocol.io/vega/protos/vega" - "github.com/ethereum/go-ethereum/ethclient" "github.com/vegaprotocol/devopstools/ethutils" "github.com/vegaprotocol/devopstools/secrets" "github.com/vegaprotocol/devopstools/smartcontracts" @@ -12,6 +10,10 @@ import ( "github.com/vegaprotocol/devopstools/vegaapi" "github.com/vegaprotocol/devopstools/veganetworksmartcontracts" "github.com/vegaprotocol/devopstools/wallet" + + "code.vegaprotocol.io/vega/protos/vega" + + "github.com/ethereum/go-ethereum/ethclient" "go.uber.org/zap" ) diff --git a/veganetworksmartcontracts/smartcontracts.go b/veganetworksmartcontracts/smartcontracts.go index 18f29a25..09d5cc3f 100644 --- a/veganetworksmartcontracts/smartcontracts.go +++ b/veganetworksmartcontracts/smartcontracts.go @@ -3,13 +3,14 @@ package veganetworksmartcontracts import ( "fmt" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/ethclient" "github.com/vegaprotocol/devopstools/smartcontracts/erc20assetpool" "github.com/vegaprotocol/devopstools/smartcontracts/erc20bridge" "github.com/vegaprotocol/devopstools/smartcontracts/erc20token" "github.com/vegaprotocol/devopstools/smartcontracts/multisigcontrol" "github.com/vegaprotocol/devopstools/smartcontracts/stakingbridge" + + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/ethclient" "go.uber.org/zap" ) diff --git a/veganetworksmartcontracts/stake.go b/veganetworksmartcontracts/stake.go index 4e9ed15e..1dbce591 100644 --- a/veganetworksmartcontracts/stake.go +++ b/veganetworksmartcontracts/stake.go @@ -5,10 +5,11 @@ import ( "math/big" "time" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - ethTypes "github.com/ethereum/go-ethereum/core/types" "github.com/vegaprotocol/devopstools/ethutils" "github.com/vegaprotocol/devopstools/wallet" + + "github.com/ethereum/go-ethereum/accounts/abi/bind" + ethTypes "github.com/ethereum/go-ethereum/core/types" "go.uber.org/zap" ) @@ -125,7 +126,7 @@ func (m *VegaNetworkSmartContracts) TopUpStake(minterWallet *wallet.EthWallet, r stakeSuccessCount = 0 stakeOKCount = 0 ) - for partyPubKey, _ := range requiredStakeByParty { + for partyPubKey := range requiredStakeByParty { if partyMissingStake, ok := missingStakeByParty[partyPubKey]; !ok { stakeOKCount += 1 m.logger.Info("No need to top up", zap.String("partyPubKey", partyPubKey)) @@ -187,7 +188,6 @@ func (m *VegaNetworkSmartContracts) RemoveStake(ethWallet *wallet.EthWallet, par } else { m.logger.Sugar().Infoln("success") } - } else { m.logger.Info("no stake to remove", zap.String("ethWallet", ethWallet.Address.Hex()), zap.String("partyPubKey", partyPubKey)) } diff --git a/wallet/ethwallet.go b/wallet/ethwallet.go index a41989af..cbde31a5 100644 --- a/wallet/ethwallet.go +++ b/wallet/ethwallet.go @@ -7,13 +7,14 @@ import ( "math/big" "sync/atomic" + "github.com/vegaprotocol/devopstools/ethutils" + "github.com/vegaprotocol/devopstools/secrets" + "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/crypto" "github.com/ethereum/go-ethereum/ethclient" - "github.com/vegaprotocol/devopstools/ethutils" - "github.com/vegaprotocol/devopstools/secrets" ) type EthWallet struct { @@ -73,7 +74,7 @@ func (w *EthWallet) GetNextNonce() uint64 { } func (w *EthWallet) GetTransactOpts() *bind.TransactOpts { - var newTransactOptions = *w.cachedTransactOpts + newTransactOptions := *w.cachedTransactOpts newTransactOptions.Nonce = big.NewInt(int64(w.GetNextNonce())) return &newTransactOptions diff --git a/wallet/manager.go b/wallet/manager.go index b5a51e7c..192430a8 100644 --- a/wallet/manager.go +++ b/wallet/manager.go @@ -80,7 +80,6 @@ func (wm *WalletManager) getEthereumWallet( } return ethWallet, nil }) - if err != nil { return nil, fmt.Errorf("failed to create new eth wallet: %w", err) } diff --git a/wallet/singleton.go b/wallet/singleton.go index 495ae0ba..a5e92ac7 100644 --- a/wallet/singleton.go +++ b/wallet/singleton.go @@ -3,8 +3,9 @@ package wallet import ( "fmt" - "code.vegaprotocol.io/vega/wallet/wallet" "github.com/vegaprotocol/devopstools/secrets" + + "code.vegaprotocol.io/vega/wallet/wallet" ) var ( diff --git a/wallet/vegawallet.go b/wallet/vegawallet.go index 7414f7c1..e5aabb83 100644 --- a/wallet/vegawallet.go +++ b/wallet/vegawallet.go @@ -3,14 +3,15 @@ package wallet import ( "fmt" - vgcrypto "code.vegaprotocol.io/shared/libs/crypto" + "github.com/vegaprotocol/devopstools/secrets" + "code.vegaprotocol.io/vega/commands" + vgcrypto "code.vegaprotocol.io/vega/libs/crypto" vegaapipb "code.vegaprotocol.io/vega/protos/vega/api/v1" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" walletpb "code.vegaprotocol.io/vega/protos/vega/wallet/v1" wcommands "code.vegaprotocol.io/vega/wallet/commands" "code.vegaprotocol.io/vega/wallet/wallet" - "github.com/vegaprotocol/devopstools/secrets" ) type VegaWallet struct {