-
Notifications
You must be signed in to change notification settings - Fork 33
[Utility] Local Proof of Stake CLI - CLI and RPC client [part 1/2] - Issue #112 #177
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
Changes from 64 commits
b0f2531
78c8d7d
32e3072
4f791f0
ee1003a
83ec894
d7c8f5d
2bda3f3
bc6ad76
e60ea54
ec76e05
6ae396e
b87b721
b80a57c
5e185e4
ecc360c
655f3d0
d876e0e
ae0faa4
a86e273
a2eb0e9
349ea3a
6081c34
0bebfa8
1e8e2de
0633550
5726671
915fcfb
a4e7e79
d258fd5
d07c14a
653f6d7
dda85a0
e5c3ae5
bd42240
35914a8
377cf14
21459d3
7823a87
e7d9c4e
60d3c14
2625979
2283910
2cea452
2b8a9d1
663fb8a
dca3786
c04285b
5b61539
daffff9
0c85a8c
7458c0a
40b93b6
20f2ebc
52b46a3
f40f742
42a3831
accd5c8
dbdeccf
8aef547
f02a670
69ffc84
1b1a0ed
8763125
35f8ef2
bf38384
db4bbdd
aa1c737
65326d5
e626d93
67bc84c
d3c726a
8d7a1a4
27e36c2
1eabec4
13485a2
ce28724
e91a1ab
476b124
3c0f0ba
c740614
1a95835
f75a872
4cfae32
c9efa96
20c3918
b0a5a78
225be2f
5cecd49
7238b03
d9743f5
2ec2448
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| package cli | ||
|
|
||
| import ( | ||
| "fmt" | ||
|
|
||
| "github.com/pokt-network/pocket/shared/crypto" | ||
| "github.com/pokt-network/pocket/utility/types" | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| func init() { | ||
| actorCmd := NewAccountCommand() | ||
deblasis marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| actorCmd.Flags().StringVar(&pwd, "pwd", "", "passphrase used by the cmd, non empty usage bypass interactive prompt") | ||
| rootCmd.AddCommand(actorCmd) | ||
| } | ||
|
|
||
| func NewAccountCommand() *cobra.Command { | ||
| cmd := &cobra.Command{ | ||
| Use: "Account", | ||
| Short: "Account specific commands", | ||
| Aliases: []string{"account"}, | ||
| Args: cobra.ExactArgs(0), | ||
| } | ||
|
|
||
| cmd.AddCommand(accountCommands()...) | ||
|
|
||
| return cmd | ||
| } | ||
|
|
||
| func accountCommands() []*cobra.Command { | ||
| cmds := []*cobra.Command{ | ||
| { | ||
| Use: "Send <fromAddr> <to> <amount>", | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm excited for this :)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. soon 🚀 |
||
| Short: "Send <fromAddr> <to> <amount>", | ||
| Long: "Sends <amount> to address <to> from address <fromAddr>", | ||
| Aliases: []string{"send"}, | ||
| Args: cobra.ExactArgs(3), | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| // TODO(pocket/issues/150): update when we have keybase | ||
deblasis marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| pk, err := readEd25519PrivateKeyFromFile(privateKeyFilePath) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| // currently ignored since we are using the address from the PrivateKey | ||
|
||
| // fromAddr := crypto.AddressFromString(args[0]) | ||
| toAddr := crypto.AddressFromString(args[1]) | ||
| amount := args[2] | ||
|
|
||
| msg := &types.MessageSend{ | ||
| FromAddress: pk.Address(), | ||
| ToAddress: toAddr, | ||
| Amount: amount, | ||
| } | ||
|
|
||
| tx, err := prepareTxJson(msg, pk) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| resp, err := postRawTx(cmd.Context(), pk, tx) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| // DISCUSS(team): define UX for return values - should we return the raw response or a parsed/human readable response? For now, I am simply printing to stdout | ||
deblasis marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| fmt.Println(resp) | ||
|
|
||
| return nil | ||
| }, | ||
| }, | ||
| } | ||
| return cmds | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.