11import {
22 paymentText ,
3+ roundtripText ,
4+ catalogUpdateText ,
5+ serveText ,
36 providerListText ,
47 providerShowText ,
58 providerEndpointsText ,
@@ -89,6 +92,7 @@ const payCommand: CommandDefinition = {
8992 wallet : "optional" ,
9093 auth : "conditional" ,
9194 broadcasts : true ,
95+ supportsWait : false ,
9296 capability : "x402.pay" ,
9397 positionals : [ { field : "url" } ] ,
9498 summary : "Request an endpoint and pay an x402 challenge" ,
@@ -115,12 +119,24 @@ const payCommand: CommandDefinition = {
115119} ;
116120
117121const listFields = z . object ( {
118- limit : integerLiteral ( 1 , 200 ) . default ( 20 ) ,
119- offset : integerLiteral ( 0 , Number . MAX_SAFE_INTEGER ) . default ( 0 ) ,
120- type : z . string ( ) . trim ( ) . min ( 1 ) . optional ( ) ,
121- category : z . string ( ) . trim ( ) . min ( 1 ) . optional ( ) ,
122- capability : z . string ( ) . trim ( ) . min ( 1 ) . optional ( ) ,
123- network : z . string ( ) . trim ( ) . min ( 1 ) . optional ( ) . describe ( "CAIP-2 network id" ) ,
122+ limit : integerLiteral ( 1 , 200 ) . default ( 20 ) . describe ( "maximum providers to return" ) ,
123+ offset : integerLiteral ( 0 , Number . MAX_SAFE_INTEGER )
124+ . default ( 0 )
125+ . describe ( "zero-based pagination offset" ) ,
126+
127+ category : z
128+ . string ( )
129+ . trim ( )
130+ . min ( 1 )
131+ . optional ( )
132+ . describe ( "filter by a category exposed by the provider catalog" ) ,
133+ capability : z
134+ . string ( )
135+ . trim ( )
136+ . min ( 1 )
137+ . optional ( )
138+ . describe ( "filter by a featured tag exposed by the provider catalog" ) ,
139+ network : z . string ( ) . trim ( ) . min ( 1 ) . optional ( ) . describe ( "network alias or CAIP-2 network id" ) ,
124140 includeBlocked : z . boolean ( ) . default ( false ) . describe ( "include providers marked as blocked" ) ,
125141} ) ;
126142
@@ -178,7 +194,8 @@ const roundtripFields = serveFields.omit({ host: true, resourceUrl: true, daemon
178194const roundtripInput = roundtripFields
179195 . superRefine ( serveRefinement )
180196 . refine ( ( value ) => ! ( value . maxGasfreeFee !== undefined && value . maxGasfreeFeeRaw !== undefined ) , {
181- message : "GasFree fee limits are mutually exclusive" ,
197+ path : [ "maxGasfreeFee" ] ,
198+ message : "cannot be combined with --max-gasfree-fee-raw" ,
182199 params : { errorCode : "invalid_option" } ,
183200 } ) ;
184201
@@ -212,6 +229,7 @@ export function registerX402Commands(registry: CommandRegistry, service: X402Ser
212229
213230 registry . add ( {
214231 path : [ "x402" , "serve" ] ,
232+ formatText : serveText ,
215233 network : "optional" ,
216234 wallet : "none" ,
217235 auth : "none" ,
@@ -225,16 +243,21 @@ export function registerX402Commands(registry: CommandRegistry, service: X402Ser
225243 ] ,
226244 run : async ( _ctx , network , input ) => {
227245 if ( ! network ) throw new Error ( "x402 serve requires a resolved network" ) ;
228- return service . serve ( network , input ) ;
246+ return service . serve ( network , {
247+ ...input ,
248+ ...( _ctx . output === "text" ? { accessLog : "text" as const } : { } ) ,
249+ } ) ;
229250 } ,
230251 } satisfies CommandDefinition ) ;
231252
232253 registry . add ( {
233254 path : [ "x402" , "roundtrip" ] ,
255+ formatText : roundtripText ,
234256 network : "optional" ,
235257 wallet : "optional" ,
236258 auth : "conditional" ,
237259 broadcasts : true ,
260+ supportsWait : false ,
238261 capability : "x402.pay" ,
239262 summary : "Start a local paywall, pay it, and exit" ,
240263 fields : roundtripFields ,
@@ -257,7 +280,7 @@ export function registerX402Commands(registry: CommandRegistry, service: X402Ser
257280 input : listFields ,
258281 examples : [
259282 { cmd : "wallet-cli x402 provider-list" } ,
260- { cmd : "wallet-cli x402 provider-list --network tron:728126428 --capability recharge " } ,
283+ { cmd : "wallet-cli x402 provider-list --network tron:728126428" } ,
261284 ] ,
262285 run : async ( _ctx , _network , input ) => providerResult ( _ctx , service . providerList ( input ) ) ,
263286 } satisfies CommandDefinition ) ;
@@ -281,14 +304,15 @@ export function registerX402Commands(registry: CommandRegistry, service: X402Ser
281304 summary,
282305 fields,
283306 input : fields ,
284- examples : [ { cmd : `wallet-cli x402 ${ verb } bai/recharge ` } ] ,
307+ examples : [ { cmd : `wallet-cli x402 ${ verb } defillama ` } ] ,
285308 run : async ( _ctx , _network , input ) => providerResult ( _ctx , run ( input . provider ) ) ,
286309 } satisfies CommandDefinition ) ;
287310 }
288311
289312 const empty = z . object ( { } ) ;
290313 registry . add ( {
291314 path : [ "x402" , "update-catalog" ] ,
315+ formatText : catalogUpdateText ,
292316 network : "none" ,
293317 wallet : "none" ,
294318 auth : "none" ,
@@ -337,6 +361,7 @@ async function providerResult(
337361 ctx : Parameters < CommandDefinition [ "run" ] > [ 0 ] ,
338362 pending : Promise < Record < string , unknown > > ,
339363) {
364+ ctx . emit ( { type : "activity" , message : "Loading provider catalog data…" } ) ;
340365 const { warnings, ...data } = await pending ;
341366 if ( Array . isArray ( warnings ) )
342367 for ( const warning of warnings ) if ( typeof warning === "string" ) ctx . warn ( warning ) ;
0 commit comments