File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -176,7 +176,10 @@ export class Flr extends AbstractEthLikeNewCoins {
176176 if ( ! txHex ) {
177177 throw new Error ( 'missing txHex in explain tx parameters' ) ;
178178 }
179- if ( params . crossChainType ) {
179+ // Avalanche atomic transactions are identified by their codec prefix (0x00000000).
180+ // Auto-detect them so callers don't need to pass crossChainType explicitly.
181+ const hexWithout0x = txHex . startsWith ( '0x' ) ? txHex . slice ( 2 ) : txHex ;
182+ if ( params . crossChainType || hexWithout0x . startsWith ( '0000' ) ) {
180183 return this . explainAtomicTransaction ( txHex ) ;
181184 }
182185 if ( ! params . feeInfo ) {
Original file line number Diff line number Diff line change @@ -249,6 +249,19 @@ describe('flr', function () {
249249 txExplain . changeOutputs . should . be . empty ( ) ;
250250 } ) ;
251251
252+ it ( 'should explain an export in C transaction without crossChainType when hex is atomic' , async function ( ) {
253+ const testData = EXPORT_C_TEST_DATA ;
254+ // Wallet platform may omit crossChainType; auto-detection via codec prefix must still return
255+ // the recipient P-chain address so the UI can display it.
256+ const txExplain = await tflrCoin . explainTransaction ( {
257+ txHex : testData . fullsigntxHex ,
258+ } ) ;
259+ txExplain . type . should . equal ( TransactionType . Export ) ;
260+ const sortedPAddresses = testData . pAddresses . slice ( ) . sort ( ) . join ( '~' ) ;
261+ txExplain . outputs [ 0 ] . address . should . equal ( sortedPAddresses ) ;
262+ txExplain . outputAmount . should . equal ( testData . amount ) ;
263+ } ) ;
264+
252265 it ( 'should throw error when missing txHex' , async function ( ) {
253266 await tflrCoin
254267 . explainTransaction ( { crossChainType : 'export' } as ExplainTransactionOptions )
Original file line number Diff line number Diff line change @@ -282,6 +282,19 @@ describe('Flrp test cases', function () {
282282 txExplain . changeOutputs . should . be . empty ( ) ;
283283 } ) ;
284284
285+ it ( 'should explain a signed export from C-chain transaction and include recipient P-chain address' , async ( ) => {
286+ const txExplain = await basecoin . explainTransaction ( { txHex : EXPORT_IN_C . signedHex } ) ;
287+
288+ txExplain . type . should . equal ( TransactionType . Export ) ;
289+ txExplain . outputs . should . be . an . Array ( ) ;
290+ txExplain . outputs . length . should . equal ( 1 ) ;
291+ // The recipient address must be the P-chain destination — not empty.
292+ txExplain . outputs [ 0 ] . address . should . be . a . String ( ) ;
293+ txExplain . outputs [ 0 ] . address . should . not . be . empty ( ) ;
294+ txExplain . outputs [ 0 ] . address . should . startWith ( 'P-' ) ;
295+ txExplain . changeOutputs . should . be . empty ( ) ;
296+ } ) ;
297+
285298 it ( 'should fail when transaction hex is not provided' , async ( ) => {
286299 await basecoin . explainTransaction ( { } ) . should . be . rejectedWith ( 'missing transaction hex' ) ;
287300 } ) ;
You can’t perform that action at this time.
0 commit comments