@@ -232,6 +232,56 @@ describe('Optimism', function () {
232232 halfSignedRawTx . halfSigned . eip1559 . maxFeePerGas . should . equal ( '7593123' ) ;
233233 halfSignedRawTx . halfSigned . eip1559 . maxPriorityFeePerGas . should . equal ( '150' ) ;
234234 } ) ;
235+
236+ it ( 'should sign an unsigned test tx with data' , async function ( ) {
237+ const builder = getBuilder ( 'topeth' ) as TransactionBuilder ;
238+ builder . fee ( {
239+ fee : '280000000000' ,
240+ gasLimit : '7000000' ,
241+ eip1559 : {
242+ maxFeePerGas : '7593123' ,
243+ maxPriorityFeePerGas : '150' ,
244+ } ,
245+ } ) ;
246+ builder . counter ( 1 ) ;
247+ builder . type ( TransactionType . Send ) ;
248+ builder . contract ( account_1 . address ) ;
249+ const transferBuilder = builder . transfer ( ) as TransferBuilder ;
250+ transferBuilder . coin ( 'topeth' ) . amount ( '1' ) . to ( account_2 . address ) . expirationTime ( 10000 ) . contractSequenceId ( 1 ) ;
251+
252+ const unsignedTx = await builder . build ( ) ;
253+ const unsignedTxForBroadcasting = unsignedTx . toBroadcastFormat ( ) ;
254+
255+ const halfSignedRawTx = await basecoin . signTransaction ( {
256+ txPrebuild : {
257+ txHex : unsignedTxForBroadcasting ,
258+ eip1559 : {
259+ maxFeePerGas : '7593123' ,
260+ maxPriorityFeePerGas : '150' ,
261+ } ,
262+ recipients : [
263+ {
264+ address : account_2 . address ,
265+ amount : '1' ,
266+ data : '0xaaaa' ,
267+ } ,
268+ ] ,
269+ } ,
270+ prv : account_1 . owner_2 ,
271+ } ) ;
272+
273+ builder . transfer ( ) . key ( account_1 . owner_2 ) ;
274+ const halfSignedTx = await builder . build ( ) ;
275+ const halfSignedTxForBroadcasting = halfSignedTx . toBroadcastFormat ( ) ;
276+
277+ halfSignedRawTx . halfSigned . txHex . should . equals ( halfSignedTxForBroadcasting ) ;
278+ halfSignedRawTx . halfSigned . recipients . length . should . equals ( 1 ) ;
279+ halfSignedRawTx . halfSigned . recipients [ 0 ] . address . toLowerCase ( ) . should . equals ( account_2 . address . toLowerCase ( ) ) ;
280+ halfSignedRawTx . halfSigned . recipients [ 0 ] . amount . toLowerCase ( ) . should . equals ( '1' ) ;
281+ halfSignedRawTx . halfSigned . recipients [ 0 ] . data . toLowerCase ( ) . should . equals ( '0xaaaa' ) ;
282+ halfSignedRawTx . halfSigned . eip1559 . maxFeePerGas . should . equal ( '7593123' ) ;
283+ halfSignedRawTx . halfSigned . eip1559 . maxPriorityFeePerGas . should . equal ( '150' ) ;
284+ } ) ;
235285 } ) ;
236286
237287 describe ( 'Transaction Verification' , function ( ) {
0 commit comments