Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update dependency and support new api #80

Merged
merged 19 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from 12 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
27 changes: 8 additions & 19 deletions cmd/cmd_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,9 @@ func getAccountBalance(ctx *cli.Context) error {
c, cancelCreateBucket := context.WithCancel(globalContext)
defer cancelCreateBucket()

var addr string
flagAddr := ctx.String(addressFlag)
if flagAddr != "" {
_, err = sdk.AccAddressFromHexUnsafe(flagAddr)
if err != nil {
return toCmdErr(err)
}
addr = flagAddr
} else {
acct, err := client.GetDefaultAccount()
if err != nil {
return toCmdErr(err)
}
addr = acct.GetAddress().String()
addr, err := getUserAddress(ctx)
if err != nil {
return err
}

resp, err := client.GetAccountBalance(c, addr)
Expand Down Expand Up @@ -201,6 +190,11 @@ $ gnfd-cmd bank bridge --toAddress 0x.. --amount 12345`,
}

func importKey(ctx *cli.Context) error {
privateKeyFile := ctx.Args().First()
if privateKeyFile == "" {
return toCmdErr(errors.New("fail to get the private key file info"))
}

keyFilePath := ctx.String("keystore")
if keyFilePath == "" {
homeDir, err := getHomeDir(ctx)
Expand All @@ -216,11 +210,6 @@ func importKey(ctx *cli.Context) error {
return toCmdErr(err)
}

privateKeyFile := ctx.Args().First()
if privateKeyFile == "" {
return toCmdErr(errors.New("fail to get the private key file info"))
}

// Load private key from file.
privateKey, addr, err := loadKey(privateKeyFile)
if err != nil {
Expand Down
16 changes: 11 additions & 5 deletions cmd/cmd_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
"time"

"cosmossdk.io/math"
Expand Down Expand Up @@ -119,12 +120,18 @@ Mirror a bucket as NFT to BSC

Examples:
# Mirror a bucket using bucket id
$ gnfd-cmd bucket mirror --id 1
$ gnfd-cmd bucket mirror --destChainId 97 --id 1

# Mirror a bucket using bucket name
$ gnfd-cmd bucket mirror --bucketName yourBucketName
$ gnfd-cmd bucket mirror --destChainId 97 --bucketName yourBucketName
`,
Flags: []cli.Flag{
&cli.StringFlag{
Name: DestChainIdFlag,
Value: "",
Usage: "target chain id",
Required: true,
},
&cli.StringFlag{
Name: IdFlag,
Value: "",
Expand Down Expand Up @@ -308,18 +315,17 @@ func mirrorBucket(ctx *cli.Context) error {
if err != nil {
return toCmdErr(err)
}

id := math.NewUint(0)
if ctx.String(IdFlag) != "" {
id = math.NewUintFromString(ctx.String(IdFlag))
}

destChainId := ctx.Int64(DestChainIdFlag)
bucketName := ctx.String(bucketNameFlag)

c, cancelContext := context.WithCancel(globalContext)
defer cancelContext()

txResp, err := client.MirrorBucket(c, id, bucketName, types.TxOption{})
txResp, err := client.MirrorBucket(c, sdk.ChainID(destChainId), id, bucketName, types.TxOption{})
if err != nil {
return toCmdErr(err)
}
Expand Down
Loading