Skip to content

Commit

Permalink
[CLI] Add --rest optional flag to init command (ark-network#363)
Browse files Browse the repository at this point in the history
  • Loading branch information
louisinger authored Oct 31, 2024
1 parent 786a69d commit 04e57f8
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ var (
Name: "force",
Usage: "force redemption without collaboration",
}
restFlag = &cli.BoolFlag{
Name: "rest",
Usage: "use REST client instead of gRPC",
Value: false,
DefaultText: "false",
}
)

var (
Expand All @@ -136,7 +142,7 @@ var (
Action: func(ctx *cli.Context) error {
return initArkSdk(ctx)
},
Flags: []cli.Flag{networkFlag, passwordFlag, privateKeyFlag, urlFlag, explorerFlag},
Flags: []cli.Flag{networkFlag, passwordFlag, privateKeyFlag, urlFlag, explorerFlag, restFlag},
}
configCommand = cli.Command{
Name: "config",
Expand Down Expand Up @@ -200,9 +206,14 @@ func initArkSdk(ctx *cli.Context) error {
return err
}

clientType := arksdk.GrpcClient
if ctx.Bool(restFlag.Name) {
clientType = arksdk.RestClient
}

return arkSdkClient.Init(
ctx.Context, arksdk.InitArgs{
ClientType: arksdk.GrpcClient,
ClientType: clientType,
WalletType: arksdk.SingleKeyWallet,
AspUrl: ctx.String(urlFlag.Name),
Seed: ctx.String(privateKeyFlag.Name),
Expand Down

0 comments on commit 04e57f8

Please sign in to comment.