@@ -5,9 +5,11 @@ import { BitGoAPI } from '@bitgo/sdk-api';
55
66import { Flr , Tflr } from '../../src/index' ;
77import { UnsignedSweepTxMPCv2 } from '@bitgo/abstract-eth' ;
8- import { mockDataUnsignedSweep } from '../resources' ;
8+ import { mockDataUnsignedSweep , mockDataNonBitGoRecovery } from '../resources' ;
99import nock from 'nock' ;
1010import { common } from '@bitgo/sdk-core' ;
11+ import { FeeMarketEIP1559Transaction } from '@ethereumjs/tx' ;
12+ import { stripHexPrefix } from '@ethereumjs/util' ;
1113
1214const bitgo : TestBitGoAPI = TestBitGo . decorate ( BitGoAPI , { env : 'test' } ) ;
1315
@@ -100,3 +102,47 @@ describe('Build Unsigned Sweep for Self-Custody Cold Wallets - (MPCv2)', functio
100102 tx . unsignedTx . parsedTx ?. should . have . property ( 'outputs' ) ;
101103 } ) ;
102104} ) ;
105+
106+ describe ( 'Non Bitgo Recovery for Hot Wallets' , function ( ) {
107+ const bitgo = TestBitGo . decorate ( BitGoAPI , { env : 'test' } ) ;
108+ const explorerUrl = common . Environments [ bitgo . getEnv ( ) ] . flrExplorerBaseUrl as string ;
109+ const maxFeePerGasvalue = 30000000000 ;
110+ const maxPriorityFeePerGasValue = 15000000000 ;
111+ const chain_id = 114 ;
112+ const gasLimitvalue = 500000 ;
113+
114+ it ( 'should generate a signed non-bitgo recovery tx' , async ( ) => {
115+ nock ( explorerUrl )
116+ . get ( '/api' )
117+ . twice ( )
118+ . query ( mockDataNonBitGoRecovery . getTxListRequest )
119+ . reply ( 200 , mockDataNonBitGoRecovery . getTxListResponse ) ;
120+ nock ( explorerUrl )
121+ . get ( '/api' )
122+ . query ( mockDataNonBitGoRecovery . getBalanceRequest )
123+ . reply ( 200 , mockDataNonBitGoRecovery . getBalanceResponse ) ;
124+
125+ const baseCoin : any = bitgo . coin ( 'tflr' ) ;
126+ const transaction = await baseCoin . recover ( {
127+ userKey : mockDataNonBitGoRecovery . userKeyData ,
128+ backupKey : mockDataNonBitGoRecovery . backupKeyData ,
129+ walletContractAddress : mockDataNonBitGoRecovery . walletRootAddress ,
130+ walletPassphrase : mockDataNonBitGoRecovery . walletPassphrase ,
131+ recoveryDestination : mockDataNonBitGoRecovery . recoveryDestination ,
132+ isTss : true ,
133+ eip1559 : { maxFeePerGas : maxFeePerGasvalue , maxPriorityFeePerGas : maxPriorityFeePerGasValue } ,
134+ gasLimit : gasLimitvalue ,
135+ replayProtectionOptions : {
136+ chain : chain_id ,
137+ hardfork : 'london' ,
138+ } ,
139+ } ) ;
140+ should . exist ( transaction ) ;
141+ transaction . should . have . property ( 'id' ) ;
142+ transaction . should . have . property ( 'tx' ) ;
143+ const tx = FeeMarketEIP1559Transaction . fromSerializedTx ( Buffer . from ( stripHexPrefix ( transaction . tx ) , 'hex' ) ) ;
144+ tx . getSenderAddress ( ) . toString ( ) . should . equal ( mockDataNonBitGoRecovery . walletRootAddress ) ;
145+ const jsonTx = tx . toJSON ( ) ;
146+ jsonTx . to ?. should . equal ( mockDataNonBitGoRecovery . recoveryDestination ) ;
147+ } ) ;
148+ } ) ;
0 commit comments