@@ -193,6 +193,7 @@ describe('EtherspotTransactionKit', () => {
193193
194194 it ( 'should use default values for optional parameters' , ( ) => {
195195 const txParams = {
196+ chainId : 1 ,
196197 to : '0x1234567890123456789012345678901234567890' ,
197198 } ;
198199
@@ -206,15 +207,15 @@ describe('EtherspotTransactionKit', () => {
206207
207208 it ( 'should throw error for missing to address' , ( ) => {
208209 expect ( ( ) => {
209- transactionKit . transaction ( { to : '' } ) ;
210+ transactionKit . transaction ( { chainId : 1 , to : '' } ) ;
210211 } ) . toThrow ( 'transaction(): to is required.' ) ;
211212 } ) ;
212213
213214 it ( 'should throw error for invalid to address' , ( ) => {
214215 ( isAddress as unknown as jest . Mock ) . mockReturnValue ( false ) ;
215216
216217 expect ( ( ) => {
217- transactionKit . transaction ( { to : 'invalid-address' } ) ;
218+ transactionKit . transaction ( { chainId : 1 , to : 'invalid-address' } ) ;
218219 } ) . toThrow ( `transaction(): 'invalid-address' is not a valid address.` ) ;
219220 } ) ;
220221
@@ -230,6 +231,7 @@ describe('EtherspotTransactionKit', () => {
230231 it ( 'should throw error for invalid value' , ( ) => {
231232 expect ( ( ) => {
232233 transactionKit . transaction ( {
234+ chainId : 1 ,
233235 to : '0x1234567890123456789012345678901234567890' ,
234236 value : 'invalid' ,
235237 } ) ;
@@ -241,6 +243,7 @@ describe('EtherspotTransactionKit', () => {
241243 it ( 'should throw error for negative value' , ( ) => {
242244 expect ( ( ) => {
243245 transactionKit . transaction ( {
246+ chainId : 1 ,
244247 to : '0x1234567890123456789012345678901234567890' ,
245248 value : '-1' ,
246249 } ) ;
@@ -251,6 +254,7 @@ describe('EtherspotTransactionKit', () => {
251254
252255 it ( 'should accept bigint value' , ( ) => {
253256 const txParams = {
257+ chainId : 1 ,
254258 to : '0x1234567890123456789012345678901234567890' ,
255259 value : BigInt ( 1000 ) ,
256260 } ;
@@ -266,6 +270,7 @@ describe('EtherspotTransactionKit', () => {
266270 describe ( 'name' , ( ) => {
267271 beforeEach ( ( ) => {
268272 transactionKit . transaction ( {
273+ chainId : 1 ,
269274 to : '0x1234567890123456789012345678901234567890' ,
270275 } ) ;
271276 } ) ;
@@ -319,6 +324,7 @@ describe('EtherspotTransactionKit', () => {
319324 describe ( 'remove' , ( ) => {
320325 it ( 'should remove named transaction' , ( ) => {
321326 transactionKit . transaction ( {
327+ chainId : 1 ,
322328 to : '0x1234567890123456789012345678901234567890' ,
323329 } ) ;
324330 transactionKit . name ( { transactionName : 'test' } ) ;
@@ -341,6 +347,7 @@ describe('EtherspotTransactionKit', () => {
341347
342348 it ( 'should throw error if transaction not named' , ( ) => {
343349 transactionKit . transaction ( {
350+ chainId : 1 ,
344351 to : '0x1234567890123456789012345678901234567890' ,
345352 } ) ;
346353
@@ -355,6 +362,7 @@ describe('EtherspotTransactionKit', () => {
355362 describe ( 'update' , ( ) => {
356363 beforeEach ( ( ) => {
357364 transactionKit . transaction ( {
365+ chainId : 1 ,
358366 to : '0x1234567890123456789012345678901234567890' ,
359367 } ) ;
360368 transactionKit . name ( { transactionName : 'test' } ) ;
@@ -380,6 +388,7 @@ describe('EtherspotTransactionKit', () => {
380388 describe ( 'estimate' , ( ) => {
381389 beforeEach ( ( ) => {
382390 transactionKit . transaction ( {
391+ chainId : 1 ,
383392 to : '0x1234567890123456789012345678901234567890' ,
384393 value : '1000000000000000000' ,
385394 data : '0x1234' ,
@@ -504,6 +513,7 @@ describe('EtherspotTransactionKit', () => {
504513 it ( 'should allow transaction with value = 0 and data = 0x' , async ( ) => {
505514 const kit = new EtherspotTransactionKit ( mockConfig ) ;
506515 kit . transaction ( {
516+ chainId : 1 ,
507517 to : '0x1234567890123456789012345678901234567890' ,
508518 value : '0' ,
509519 data : '0x' ,
@@ -547,6 +557,7 @@ describe('EtherspotTransactionKit', () => {
547557 describe ( 'send' , ( ) => {
548558 beforeEach ( ( ) => {
549559 transactionKit . transaction ( {
560+ chainId : 1 ,
550561 to : '0x1234567890123456789012345678901234567890' ,
551562 value : '1000000000000000000' ,
552563 data : '0x1234' ,
@@ -658,6 +669,7 @@ describe('EtherspotTransactionKit', () => {
658669
659670 it ( 'should allow sending transaction with value = 0 and data = 0x' , async ( ) => {
660671 transactionKit . transaction ( {
672+ chainId : 1 ,
661673 to : '0x1234567890123456789012345678901234567890' ,
662674 value : '0' ,
663675 data : '0x' ,
@@ -743,6 +755,7 @@ describe('EtherspotTransactionKit', () => {
743755
744756 it ( 'should return state with transaction' , ( ) => {
745757 transactionKit . transaction ( {
758+ chainId : 1 ,
746759 to : '0x1234567890123456789012345678901234567890' ,
747760 value : '1000000000000000000' ,
748761 } ) ;
@@ -779,6 +792,7 @@ describe('EtherspotTransactionKit', () => {
779792 expect ( ( ) => {
780793 debugKit . setDebugMode ( true ) ;
781794 debugKit . transaction ( {
795+ chainId : 1 ,
782796 to : '0x1234567890123456789012345678901234567890' ,
783797 } ) ;
784798 debugKit . name ( { transactionName : 'debug-tx' } ) ;
@@ -828,6 +842,7 @@ describe('EtherspotTransactionKit', () => {
828842 it ( 'should reset all state' , ( ) => {
829843 // Set up some state
830844 transactionKit . transaction ( {
845+ chainId : 1 ,
831846 to : '0x1234567890123456789012345678901234567890' ,
832847 } ) ;
833848 transactionKit . name ( { transactionName : 'test' } ) ;
@@ -870,6 +885,7 @@ describe('EtherspotTransactionKit', () => {
870885 describe ( 'State management during operations' , ( ) => {
871886 beforeEach ( ( ) => {
872887 transactionKit . transaction ( {
888+ chainId : 1 ,
873889 to : '0x1234567890123456789012345678901234567890' ,
874890 value : '1000000000000000000' ,
875891 } ) ;
@@ -929,23 +945,24 @@ describe('EtherspotTransactionKit', () => {
929945 } ) ;
930946
931947 describe ( 'Provider integration' , ( ) => {
932- it ( 'should handle provider chain ID changes ' , ( ) => {
948+ it ( 'should use explicit chainId from transaction call ' , ( ) => {
933949 mockProvider . getChainId . mockReturnValue ( 5 ) ;
934950
935951 transactionKit . transaction ( {
952+ chainId : 1 ,
936953 to : '0x1234567890123456789012345678901234567890' ,
937954 } ) ;
938955
939956 const state = transactionKit . getState ( ) ;
940957 expect ( state . workingTransaction ?. chainId ) . toBe ( 1 ) ;
941958
942- // Test with no explicit chainId
943959 transactionKit . transaction ( {
960+ chainId : 137 ,
944961 to : '0x1234567890123456789012345678901234567890' ,
945962 value : '1' ,
946963 } ) ;
947964 const state2 = transactionKit . getState ( ) ;
948- expect ( state2 . workingTransaction ?. chainId ) . toBe ( 1 ) ; // Should use default
965+ expect ( state2 . workingTransaction ?. chainId ) . toBe ( 137 ) ;
949966 } ) ;
950967
951968 it ( 'should handle SDK instance errors gracefully' , async ( ) => {
@@ -972,12 +989,14 @@ describe('Batch operations', () => {
972989 mockSdk . send . mockReset ( ) ;
973990 mockSdk . totalGasEstimated . mockReset ( ) ;
974991 transactionKit . transaction ( {
992+ chainId : 1 ,
975993 to : '0x1111111111111111111111111111111111111111' ,
976994 value : '1000000000000000000' ,
977995 } ) ;
978996 transactionKit . name ( { transactionName : 'tx1' } ) ;
979997 transactionKit . addToBatch ( { batchName : 'batch1' } ) ;
980998 transactionKit . transaction ( {
999+ chainId : 1 ,
9811000 to : '0x2222222222222222222222222222222222222222' ,
9821001 value : '2000000000000000000' ,
9831002 } ) ;
0 commit comments