Skip to content

Commit 7ca5dc8

Browse files
committed
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.
1 parent 830220a commit 7ca5dc8

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

cmd/loop/l402.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,31 @@ func listAuth(ctx *cli.Context) error {
7373
printJSON(tokens)
7474
return nil
7575
}
76+
77+
var fetchL402Command = cli.Command{
78+
Name: "fetchl402",
79+
Usage: "fetches a new L402 authentication token from the server",
80+
Description: "Fetches a new L402 authentication token from the server. " +
81+
"This token is required to listen to notifications from the server, " +
82+
"such as reservation notifications. If a L402 is already present in " +
83+
"the store, this command is a no-op.",
84+
Action: fetchL402,
85+
}
86+
87+
func fetchL402(ctx *cli.Context) error {
88+
client, cleanup, err := getClient(ctx)
89+
if err != nil {
90+
return err
91+
}
92+
defer cleanup()
93+
94+
res, err := client.FetchL402Token(
95+
context.Background(), &looprpc.FetchL402TokenRequest{},
96+
)
97+
if err != nil {
98+
return err
99+
}
100+
101+
printRespJSON(res)
102+
return nil
103+
}

cmd/loop/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func main() {
144144
}
145145
app.Commands = []cli.Command{
146146
loopOutCommand, loopInCommand, termsCommand,
147-
monitorCommand, quoteCommand, listAuthCommand,
147+
monitorCommand, quoteCommand, listAuthCommand, fetchL402Command,
148148
listSwapsCommand, swapInfoCommand, getLiquidityParamsCommand,
149149
setLiquidityRuleCommand, suggestSwapCommand, setParamsCommand,
150150
getInfoCommand, abandonSwapCommand, reservationsCommands,

0 commit comments

Comments
 (0)