@@ -19,6 +19,7 @@ import {
1919 formatRefundEntryLine ,
2020} from "../../commands/escrow" ;
2121import { listStoreNames } from "../../commands/storeManagement" ;
22+ import { resolveTransferRecipient } from "../transfer" ;
2223import { addAuthOptions } from "./authOptions" ;
2324import { prepareContext } from "../context" ;
2425import { prepareReadOnlyContext } from "./lookup" ;
@@ -30,10 +31,22 @@ import {
3031 handleCommandError ,
3132} from "./jsonHelpers" ;
3233import { formatWeiAsEther } from "../../utils/formatting" ;
34+ import type { ReadOnlyContext } from "../../types/types" ;
3335
3436const DEFAULT_REFUND_PAGE_SIZE = 50 ;
3537const MAX_REFUND_PAGE_SIZE = 200 ;
3638
39+ async function resolveRecipientOption (
40+ jsonOutput : boolean ,
41+ context : ReadOnlyContext ,
42+ recipientOption : string | undefined ,
43+ ) : Promise < Address > {
44+ if ( ! recipientOption ) return context . evmAddress as Address ;
45+ return maybeQuiet ( jsonOutput , ( ) =>
46+ resolveTransferRecipient ( context . clientWrapper , context . account . address , recipientOption ) ,
47+ ) ;
48+ }
49+
3750interface EscrowCommonOptions {
3851 rpc ?: string ;
3952}
@@ -110,7 +123,10 @@ export function attachEscrowCommands(root: Command) {
110123 const balanceCommand = escrowCommand
111124 . command ( "balance" )
112125 . description ( "Show the caller's claimable pull-payment balance" )
113- . option ( "--recipient <address>" , "Recipient EVM address (defaults to caller)" )
126+ . option (
127+ "--recipient <address>" ,
128+ "Recipient EVM address, SS58 address, or .dot label (defaults to caller)" ,
129+ )
114130 . option ( "--json" , "Output result as JSON (suppresses all other output)" , false ) ;
115131 addAuthOptions ( balanceCommand ) . action ( async ( options : RefundListOptions , command : Command ) => {
116132 const jsonOutput = getJsonFlag ( command ) ;
@@ -120,7 +136,7 @@ export function attachEscrowCommands(root: Command) {
120136 prepareReadOnlyContext ( mergedOptions as any ) ,
121137 ) ;
122138
123- const recipient = ( options . recipient ?? context . evmAddress ) as Address ;
139+ const recipient = await resolveRecipientOption ( jsonOutput , context , options . recipient ) ;
124140
125141 if ( ! jsonOutput ) console . log ( chalk . bold ( "\n▶ Escrow balance\n" ) ) ;
126142 const spinner = ora ( ) ;
@@ -143,7 +159,10 @@ export function attachEscrowCommands(root: Command) {
143159 const positionsCommand = escrowCommand
144160 . command ( "positions" )
145161 . description ( "List all escrow positions for the caller and the total locked" )
146- . option ( "--recipient <address>" , "Recipient EVM address (defaults to caller)" )
162+ . option (
163+ "--recipient <address>" ,
164+ "Recipient EVM address, SS58 address, or .dot label (defaults to caller)" ,
165+ )
147166 . option ( "--json" , "Output result as JSON (suppresses all other output)" , false ) ;
148167 addAuthOptions ( positionsCommand ) . action ( async ( options : RefundListOptions , command : Command ) => {
149168 const jsonOutput = getJsonFlag ( command ) ;
@@ -153,7 +172,7 @@ export function attachEscrowCommands(root: Command) {
153172 prepareReadOnlyContext ( mergedOptions as any ) ,
154173 ) ;
155174
156- const recipient = ( options . recipient ?? context . evmAddress ) as Address ;
175+ const recipient = await resolveRecipientOption ( jsonOutput , context , options . recipient ) ;
157176
158177 if ( ! jsonOutput ) console . log ( chalk . bold ( "\n▶ Escrow positions\n" ) ) ;
159178 const spinner = ora ( ) ;
@@ -344,7 +363,10 @@ export function attachEscrowCommands(root: Command) {
344363 const refundsListCommand = refundsCommand
345364 . command ( "list" )
346365 . description ( "List pending refund entries for the caller (or a specified recipient)" )
347- . option ( "--recipient <address>" , "Recipient EVM address (defaults to caller)" )
366+ . option (
367+ "--recipient <address>" ,
368+ "Recipient EVM address, SS58 address, or .dot label (defaults to caller)" ,
369+ )
348370 . option ( "--offset <n>" , "Page offset" , "0" )
349371 . option (
350372 "--limit <n>" ,
@@ -369,7 +391,7 @@ export function attachEscrowCommands(root: Command) {
369391 throw new Error ( `limit must be between 1 and ${ MAX_REFUND_PAGE_SIZE } ` ) ;
370392 }
371393
372- const recipient = ( options . recipient ?? context . evmAddress ) as Address ;
394+ const recipient = await resolveRecipientOption ( jsonOutput , context , options . recipient ) ;
373395
374396 if ( ! jsonOutput ) console . log ( chalk . bold ( "\n▶ Refund ledger\n" ) ) ;
375397 const spinner = ora ( ) ;
0 commit comments