Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions cmd/blockchaincmd/add_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ import (
"strings"
"time"

"github.com/ava-labs/avalanchego/config"
"github.com/ava-labs/avalanchego/ids"
avagoconstants "github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/avalanchego/utils/formatting/address"
"github.com/ava-labs/avalanchego/utils/logging"
"github.com/ava-labs/avalanchego/utils/units"
warpMessage "github.com/ava-labs/avalanchego/vms/platformvm/warp/message"
"github.com/ethereum/go-ethereum/common"
"github.com/spf13/cobra"

"github.com/ava-labs/avalanche-cli/pkg/blockchain"
"github.com/ava-labs/avalanche-cli/pkg/cobrautils"
"github.com/ava-labs/avalanche-cli/pkg/constants"
Expand All @@ -24,15 +34,6 @@ import (
"github.com/ava-labs/avalanche-cli/pkg/validatormanager"
sdkutils "github.com/ava-labs/avalanche-cli/sdk/utils"
"github.com/ava-labs/avalanche-cli/sdk/validator"
"github.com/ava-labs/avalanchego/config"
"github.com/ava-labs/avalanchego/ids"
avagoconstants "github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/avalanchego/utils/formatting/address"
"github.com/ava-labs/avalanchego/utils/logging"
"github.com/ava-labs/avalanchego/utils/units"
warpMessage "github.com/ava-labs/avalanchego/vms/platformvm/warp/message"
"github.com/ethereum/go-ethereum/common"
"github.com/spf13/cobra"
)

var (
Expand Down Expand Up @@ -199,14 +200,16 @@ func addValidator(cmd *cobra.Command, args []string) error {
}

// TODO: will estimate fee in subsecuent PR
var kc *keychain.Keychain
fee := uint64(0)
kc, err := keychain.GetKeychainFromCmdLineFlags(
kc, err = keychain.GetKeychainFromCmdLineFlags(
app,
"to pay for transaction fees on P-Chain",
network,
keyName,
useEwoq,
useLedger,
useFireblocks,
ledgerAddresses,
fee,
)
Expand Down
4 changes: 3 additions & 1 deletion cmd/blockchaincmd/change_owner.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ package blockchaincmd
import (
"fmt"

"github.com/ava-labs/avalanchego/ids"

"github.com/ava-labs/avalanche-cli/pkg/cobrautils"
"github.com/ava-labs/avalanche-cli/pkg/keychain"
"github.com/ava-labs/avalanche-cli/pkg/networkoptions"
Expand All @@ -13,7 +15,6 @@ import (
"github.com/ava-labs/avalanche-cli/pkg/txutils"
"github.com/ava-labs/avalanche-cli/pkg/utils"
"github.com/ava-labs/avalanche-cli/pkg/ux"
"github.com/ava-labs/avalanchego/ids"

"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -65,6 +66,7 @@ func changeOwner(_ *cobra.Command, args []string) error {
keyName,
useEwoq,
useLedger,
useFireblocks,
ledgerAddresses,
fee,
)
Expand Down
14 changes: 8 additions & 6 deletions cmd/blockchaincmd/change_weight.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ package blockchaincmd
import (
"fmt"

"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/utils/crypto/bls"
"github.com/ava-labs/avalanchego/utils/formatting"
"github.com/ava-labs/avalanchego/utils/formatting/address"
"github.com/ava-labs/avalanchego/utils/units"
"github.com/spf13/cobra"

"github.com/ava-labs/avalanche-cli/pkg/cobrautils"
"github.com/ava-labs/avalanche-cli/pkg/constants"
"github.com/ava-labs/avalanche-cli/pkg/contract"
Expand All @@ -17,12 +24,6 @@ import (
"github.com/ava-labs/avalanche-cli/pkg/utils"
"github.com/ava-labs/avalanche-cli/pkg/ux"
"github.com/ava-labs/avalanche-cli/sdk/validator"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/utils/crypto/bls"
"github.com/ava-labs/avalanchego/utils/formatting"
"github.com/ava-labs/avalanchego/utils/formatting/address"
"github.com/ava-labs/avalanchego/utils/units"
"github.com/spf13/cobra"
)

var newWeight uint64
Expand Down Expand Up @@ -81,6 +82,7 @@ func setWeight(_ *cobra.Command, args []string) error {
keyName,
useEwoq,
useLedger,
useFireblocks,
ledgerAddresses,
fee,
)
Expand Down
14 changes: 8 additions & 6 deletions cmd/blockchaincmd/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ import (
"strings"
"time"

"github.com/ava-labs/avalanchego/api/info"
"github.com/ava-labs/avalanchego/config"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/utils/logging"
"github.com/ava-labs/avalanchego/utils/units"
"github.com/ava-labs/avalanchego/vms/platformvm/txs"

"github.com/ava-labs/avalanche-cli/pkg/blockchain"
"github.com/ava-labs/avalanche-cli/pkg/cobrautils"
"github.com/ava-labs/avalanche-cli/pkg/constants"
Expand All @@ -30,12 +37,6 @@ import (
blockchainSDK "github.com/ava-labs/avalanche-cli/sdk/blockchain"
sdkutils "github.com/ava-labs/avalanche-cli/sdk/utils"
validatorManagerSDK "github.com/ava-labs/avalanche-cli/sdk/validatormanager"
"github.com/ava-labs/avalanchego/api/info"
"github.com/ava-labs/avalanchego/config"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/utils/logging"
"github.com/ava-labs/avalanchego/utils/units"
"github.com/ava-labs/avalanchego/vms/platformvm/txs"

"github.com/ethereum/go-ethereum/common"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -619,6 +620,7 @@ func convertBlockchain(_ *cobra.Command, args []string) error {
keyName,
useEwoq,
useLedger,
useFireblocks,
ledgerAddresses,
fee,
)
Expand Down
31 changes: 17 additions & 14 deletions cmd/blockchaincmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ import (

"github.com/ava-labs/avalanche-cli/pkg/blockchain"

anrutils "github.com/ava-labs/avalanche-network-runner/utils"
"github.com/ava-labs/avalanchego/api/info"
"github.com/ava-labs/avalanchego/ids"
avagoutils "github.com/ava-labs/avalanchego/utils"
"github.com/ava-labs/avalanchego/utils/formatting/address"
"github.com/ava-labs/avalanchego/utils/logging"
"github.com/ava-labs/avalanchego/utils/set"
"github.com/ava-labs/avalanchego/utils/units"
"github.com/ava-labs/avalanchego/vms/platformvm/fx"
"github.com/ava-labs/avalanchego/vms/platformvm/signer"
"github.com/ava-labs/avalanchego/vms/platformvm/txs"
"github.com/ava-labs/avalanchego/vms/platformvm/warp/message"

"github.com/ava-labs/avalanche-cli/cmd/interchaincmd/messengercmd"
"github.com/ava-labs/avalanche-cli/cmd/interchaincmd/relayercmd"
"github.com/ava-labs/avalanche-cli/cmd/networkcmd"
Expand All @@ -31,18 +44,6 @@ import (
"github.com/ava-labs/avalanche-cli/pkg/utils"
"github.com/ava-labs/avalanche-cli/pkg/ux"
"github.com/ava-labs/avalanche-cli/pkg/vm"
anrutils "github.com/ava-labs/avalanche-network-runner/utils"
"github.com/ava-labs/avalanchego/api/info"
"github.com/ava-labs/avalanchego/ids"
avagoutils "github.com/ava-labs/avalanchego/utils"
"github.com/ava-labs/avalanchego/utils/formatting/address"
"github.com/ava-labs/avalanchego/utils/logging"
"github.com/ava-labs/avalanchego/utils/set"
"github.com/ava-labs/avalanchego/utils/units"
"github.com/ava-labs/avalanchego/vms/platformvm/fx"
"github.com/ava-labs/avalanchego/vms/platformvm/signer"
"github.com/ava-labs/avalanchego/vms/platformvm/txs"
"github.com/ava-labs/avalanchego/vms/platformvm/warp/message"

"github.com/jedib0t/go-pretty/v6/table"
"github.com/spf13/cobra"
Expand All @@ -59,6 +60,7 @@ var (
userProvidedAvagoVersion string
outputTxPath string
useLedger bool
useFireblocks bool
useLocalMachine bool
useEwoq bool
ledgerAddresses []string
Expand Down Expand Up @@ -134,6 +136,7 @@ so you can take your locally tested Blockchain and deploy it on Fuji or Mainnet.
cmd.Flags().StringVar(&outputTxPath, "output-tx-path", "", "file path of the blockchain creation tx")
cmd.Flags().BoolVarP(&useEwoq, "ewoq", "e", false, "use ewoq key [fuji/devnet deploy only]")
cmd.Flags().BoolVarP(&useLedger, "ledger", "g", false, "use ledger instead of key (always true on mainnet, defaults to false on fuji/devnet)")
cmd.Flags().BoolVar(&useFireblocks, "fireblocks", false, "use Fireblocks instead of key")
cmd.Flags().StringSliceVar(&ledgerAddresses, "ledger-addrs", []string{}, "use the given ledger addresses")
cmd.Flags().StringVarP(&subnetIDStr, "subnet-id", "u", "", "do not create a subnet, deploy the blockchain into the given subnet id")
cmd.Flags().Uint32Var(&mainnetChainID, "mainnet-chain-id", 0, "use different ChainID for mainnet deployment")
Expand Down Expand Up @@ -554,14 +557,14 @@ func deployBlockchain(cmd *cobra.Command, args []string) error {
// !subnetonly: add blockchain fee
// createSubnet: add subnet fee
fee := uint64(0)

kc, err := keychain.GetKeychainFromCmdLineFlags(
app,
constants.PayTxsFeesMsg,
network,
keyName,
useEwoq,
useLedger,
useFireblocks,
ledgerAddresses,
fee,
)
Expand Down Expand Up @@ -663,7 +666,7 @@ func deployBlockchain(cmd *cobra.Command, args []string) error {

if createSubnet {
if sidecar.Sovereign {
sameControlKey = true
sameControlKey = false
}
controlKeys, threshold, err = promptOwners(
kc,
Expand Down
12 changes: 7 additions & 5 deletions cmd/blockchaincmd/remove_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ import (
"os"
"strings"

"github.com/ava-labs/avalanchego/api/info"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/utils/logging"
"github.com/ava-labs/avalanchego/vms/platformvm/warp"
"github.com/ethereum/go-ethereum/common"

"github.com/ava-labs/avalanche-cli/pkg/blockchain"
"github.com/ava-labs/avalanche-cli/pkg/cobrautils"
"github.com/ava-labs/avalanche-cli/pkg/constants"
Expand All @@ -24,11 +30,6 @@ import (
sdkutils "github.com/ava-labs/avalanche-cli/sdk/utils"
validatorsdk "github.com/ava-labs/avalanche-cli/sdk/validator"
validatormanagerSDK "github.com/ava-labs/avalanche-cli/sdk/validatormanager"
"github.com/ava-labs/avalanchego/api/info"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/utils/logging"
"github.com/ava-labs/avalanchego/vms/platformvm/warp"
"github.com/ethereum/go-ethereum/common"

"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -106,6 +107,7 @@ func removeValidator(_ *cobra.Command, args []string) error {
keyName,
useEwoq,
useLedger,
useFireblocks,
ledgerAddresses,
fee,
)
Expand Down
63 changes: 63 additions & 0 deletions cmd/fireblockscmd/addresscmd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package fireblockscmd

import (
"fmt"

"github.com/ava-labs/avalanchego/utils/formatting/address"
"github.com/spf13/cobra"

"github.com/ava-labs/avalanche-cli/cmd/fireblockscmd/fireblocks"
"github.com/ava-labs/avalanche-cli/pkg/cobrautils"
"github.com/ava-labs/avalanche-cli/pkg/prompts"
)

var (
apiAddr string
priKey string
apiKey string
vaultId string
assetId string
chainAlias string
chainHrp string
)

func newAddressCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "address",
Short: "show fireblocks avalanche short id",
RunE: addresscmd,
Args: cobrautils.ExactArgs(0),
Hidden: false,
}
cmd.Flags().StringVar(&apiAddr, "api-addr", "https://sandbox-api.fireblocks.io", "fireblocks api address")
cmd.Flags().StringVar(&priKey, "private-key", "/srv/landslide/fireblocks_secret_editor_e4fafe6f-742f-423c-b5fa-2af197e932d8.key", "absolute path to fireblocks api private key")
cmd.Flags().StringVar(&apiKey, "api-key", "e4fafe6f-742f-423c-b5fa-2af197e932d8", "fireblocks api key")
cmd.Flags().StringVar(&vaultId, "vault-id", "220", "fireblocks vault id")
cmd.Flags().StringVar(&assetId, "asset-id", "BTC_TEST", "fireblocks asset id")
cmd.Flags().StringVar(&chainAlias, "avalanche-chain-alias", "P", "avalanche network alias asset id")
cmd.Flags().StringVar(&chainHrp, "avalanche-chain-hrp", "fuji", "avalanche network hrp")
return cmd
}

func addresscmd(_ *cobra.Command, _ []string) error {
fbParams, err := prompts.PromptFireblocks(app.Prompt)
if err != nil {
return err
}
keychain, err := fireblocks.NewFireblocksKeychain(fbParams)
if err != nil {
return err
}
addresses := keychain.Addresses()
addr, exists := addresses.Peek()
if !exists {
return fmt.Errorf("no address")
}
fmt.Printf("ShortID: %s\n", addr)
pChainAddress, err := address.Format(chainAlias, chainHrp, addr.Bytes())
if err != nil {
return err
}
fmt.Printf("Fireblocks address: %s\n", pChainAddress)
return nil
}
Loading