From 7ca5dc81bc0901d50f917dd464bb9e4531058338 Mon Sep 17 00:00:00 2001 From: sputn1ck Date: Wed, 30 Oct 2024 14:26:29 +0100 Subject: [PATCH] cmd: add fetchl402 cli command This commit adds a new command to the loop cli tool that fetches the a l402 token from the swap server. --- cmd/loop/l402.go | 28 ++++++++++++++++++++++++++++ cmd/loop/main.go | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/cmd/loop/l402.go b/cmd/loop/l402.go index fa7428fbf..5e1669a88 100644 --- a/cmd/loop/l402.go +++ b/cmd/loop/l402.go @@ -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 +} diff --git a/cmd/loop/main.go b/cmd/loop/main.go index 83a849205..cfed2c220 100644 --- a/cmd/loop/main.go +++ b/cmd/loop/main.go @@ -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,