Skip to content

Commit feb5bbb

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 a7f176d commit feb5bbb

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

cmd/loop/l402.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,30 @@ 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.",
83+
Action: fetchL402,
84+
}
85+
86+
func fetchL402(ctx *cli.Context) error {
87+
client, cleanup, err := getClient(ctx)
88+
if err != nil {
89+
return err
90+
}
91+
defer cleanup()
92+
93+
res, err := client.FetchL402Token(
94+
context.Background(), &looprpc.FetchL402TokenRequest{},
95+
)
96+
if err != nil {
97+
return err
98+
}
99+
100+
printRespJSON(res)
101+
return nil
102+
}

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)