Skip to content

Commit

Permalink
cmd: add fetchl402 cli command
Browse files Browse the repository at this point in the history
This commit adds a new command to the loop cli tool that fetches the
a l402 token from the swap server.
  • Loading branch information
sputn1ck committed Oct 30, 2024
1 parent 830220a commit 7ca5dc8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
28 changes: 28 additions & 0 deletions cmd/loop/l402.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,31 @@ func listAuth(ctx *cli.Context) error {
printJSON(tokens)
return nil
}

var fetchL402Command = cli.Command{
Name: "fetchl402",
Usage: "fetches a new L402 authentication token from the server",
Description: "Fetches a new L402 authentication token from the server. " +
"This token is required to listen to notifications from the server, " +
"such as reservation notifications. If a L402 is already present in " +
"the store, this command is a no-op.",
Action: fetchL402,
}

func fetchL402(ctx *cli.Context) error {
client, cleanup, err := getClient(ctx)
if err != nil {
return err
}
defer cleanup()

res, err := client.FetchL402Token(
context.Background(), &looprpc.FetchL402TokenRequest{},
)
if err != nil {
return err
}

printRespJSON(res)
return nil
}
2 changes: 1 addition & 1 deletion cmd/loop/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func main() {
}
app.Commands = []cli.Command{
loopOutCommand, loopInCommand, termsCommand,
monitorCommand, quoteCommand, listAuthCommand,
monitorCommand, quoteCommand, listAuthCommand, fetchL402Command,
listSwapsCommand, swapInfoCommand, getLiquidityParamsCommand,
setLiquidityRuleCommand, suggestSwapCommand, setParamsCommand,
getInfoCommand, abandonSwapCommand, reservationsCommands,
Expand Down

0 comments on commit 7ca5dc8

Please sign in to comment.