@@ -8,11 +8,13 @@ export async function ensureBalances({
88 iexec,
99 nRlcMin,
1010 weiMin,
11+ warnOnlyRlc = false ,
1112} : {
1213 spinner : Spinner ;
1314 iexec : IExec ;
1415 nRlcMin ?: BN ;
1516 weiMin ?: BN ;
17+ warnOnlyRlc ?: boolean ;
1618} ) : Promise < {
1719 wei : BN ;
1820 nRLC : BN ;
@@ -34,45 +36,72 @@ export async function ensureBalances({
3436 ( chainId !== 134 && totalRlc . isZero ( ) ) ||
3537 ( ! ! nRlcMin && totalRlc . lt ( nRlcMin ) ) ;
3638
37- if ( ! missingNative && ! missingRlc ) {
38- return {
39- wei,
40- nRLC,
41- stake,
42- } ;
43- }
44-
45- const helpers = [ ] ;
39+ // Always check native assets - they're required for transaction fees
4640 if ( missingNative ) {
4741 const msg = wei . isZero ( )
4842 ? ' - Native balance is empty'
4943 : ' - Native balance is insufficient' ;
5044 const requirement = weiMin
5145 ? ` (requires ${ utils . formatEth ( weiMin as BN ) } ether)`
5246 : '' ;
53- helpers . push ( `${ msg } ${ requirement } ` ) ;
47+
48+ spinner . log (
49+ warnBox ( `Current chain requires native asset to pay transaction fees!
50+
51+ Your wallet balance is insufficient:
52+ ${ msg } ${ requirement }
53+
54+ You can either:
55+ - Fund your wallet ${ emphasis ( address ) }
56+ - Import another wallet (run ${ command ( 'iapp wallet import' ) } )
57+ - Select an imported wallet (run ${ command ( 'iapp wallet select' ) } )
58+ - Use another chain (use option ${ command ( '--chain <name>' ) } )` )
59+ ) ;
60+ throw Error ( `Native balance is insufficient` ) ;
5461 }
62+
63+ // For RLC, either warn only or block based on warnOnlyRlc option
5564 if ( missingRlc ) {
56- const msg = totalRlc . isZero ( )
57- ? ' - RLC balance is empty'
58- : ' - RLC balance is insufficient' ;
59- const requirement = nRlcMin
60- ? ` (requires ${ utils . formatRLC ( nRlcMin as BN ) } RLC)`
61- : '' ;
62- helpers . push ( `${ msg } ${ requirement } ` ) ;
63- }
65+ if ( warnOnlyRlc ) {
66+ // Just warn for RLC, don't block
67+ const msg = totalRlc . isZero ( )
68+ ? ' - RLC balance is empty'
69+ : ' - RLC balance is insufficient' ;
70+ const requirement = nRlcMin
71+ ? ` (requires ${ utils . formatRLC ( nRlcMin as BN ) } RLC)`
72+ : '' ;
73+
74+ spinner . warn (
75+ `⚠️ Warning: Your wallet has insufficient RLC balance:${ msg } ${ requirement } . You'll need RLC to run your iApp later. Consider funding your wallet ${ emphasis ( address ) } or importing another wallet.`
76+ ) ;
77+ } else {
78+ // Block for RLC (original behavior)
79+ const msg = totalRlc . isZero ( )
80+ ? ' - RLC balance is empty'
81+ : ' - RLC balance is insufficient' ;
82+ const requirement = nRlcMin
83+ ? ` (requires ${ utils . formatRLC ( nRlcMin as BN ) } RLC)`
84+ : '' ;
6485
65- spinner . log (
66- warnBox ( `Current chain requires ${ chainId !== 134 ? 'native asset to pay transaction fees and ' : '' } RLC to pay iApp runs!
86+ spinner . log (
87+ warnBox ( `Current chain requires RLC to pay iApp runs!
6788
6889Your wallet balance is insufficient:
69- ${ helpers . join ( '\n' ) }
90+ ${ msg } ${ requirement }
7091
7192You can either:
7293 - Fund your wallet ${ emphasis ( address ) }
7394 - Import another wallet (run ${ command ( 'iapp wallet import' ) } )
7495 - Select an imported wallet (run ${ command ( 'iapp wallet select' ) } )
7596 - Use another chain (use option ${ command ( '--chain <name>' ) } )` )
76- ) ;
77- throw Error ( `Balance is insufficient` ) ;
97+ ) ;
98+ throw Error ( `RLC balance is insufficient` ) ;
99+ }
100+ }
101+
102+ return {
103+ wei,
104+ nRLC,
105+ stake,
106+ } ;
78107}
0 commit comments