@@ -20,17 +20,10 @@ const testTxHash =
2020const testMsgSig =
2121 '0x68dc980608bceb5f99f691e62c32caccaee05317309015e9454eba1a14c3cd4505d1dd098b8339801239c9bcaac3c4df95569dcf307108b92f68711379be14d81c' ;
2222
23- const createProviderAndEngine = ( ) => {
24- const engine = new JsonRpcEngine ( ) ;
25- const provider = providerFromEngine ( engine ) ;
26-
27- return { engine, provider } ;
28- } ;
29-
3023describe ( 'wallet' , ( ) => {
3124 describe ( 'accounts' , ( ) => {
3225 it ( 'returns null for coinbase when no accounts' , async ( ) => {
33- const { engine } = createProviderAndEngine ( ) ;
26+ const engine = new JsonRpcEngine ( ) ;
3427 const getAccounts = async ( ) => [ ] ;
3528 engine . push ( createWalletMiddleware ( { getAccounts } ) ) ;
3629 const coinbaseResult = await pify ( engine . handle ) . call ( engine , {
@@ -40,7 +33,7 @@ describe('wallet', () => {
4033 } ) ;
4134
4235 it ( 'should return the correct value from getAccounts' , async ( ) => {
43- const { engine } = createProviderAndEngine ( ) ;
36+ const engine = new JsonRpcEngine ( ) ;
4437 const getAccounts = async ( ) => testAddresses . slice ( ) ;
4538 engine . push ( createWalletMiddleware ( { getAccounts } ) ) ;
4639 const coinbaseResult = await pify ( engine . handle ) . call ( engine , {
@@ -50,7 +43,7 @@ describe('wallet', () => {
5043 } ) ;
5144
5245 it ( 'should return the correct value from getAccounts with multiple accounts' , async ( ) => {
53- const { engine } = createProviderAndEngine ( ) ;
46+ const engine = new JsonRpcEngine ( ) ;
5447 const getAccounts = async ( ) => testAddresses . slice ( 0 , 2 ) ;
5548 engine . push ( createWalletMiddleware ( { getAccounts } ) ) ;
5649 const coinbaseResult = await pify ( engine . handle ) . call ( engine , {
@@ -62,7 +55,7 @@ describe('wallet', () => {
6255
6356 describe ( 'transactions' , ( ) => {
6457 it ( 'processes transaction with valid address' , async ( ) => {
65- const { engine } = createProviderAndEngine ( ) ;
58+ const engine = new JsonRpcEngine ( ) ;
6659 const getAccounts = async ( ) => testAddresses . slice ( 0 , 2 ) ;
6760 const witnessedTxParams : TransactionParams [ ] = [ ] ;
6861 const processTransaction = async ( _txParams : TransactionParams ) => {
@@ -84,7 +77,7 @@ describe('wallet', () => {
8477 } ) ;
8578
8679 it ( 'throws when provided an invalid address' , async ( ) => {
87- const { engine } = createProviderAndEngine ( ) ;
80+ const engine = new JsonRpcEngine ( ) ;
8881 const getAccounts = async ( ) => testAddresses . slice ( 0 , 2 ) ;
8982 const witnessedTxParams : TransactionParams [ ] = [ ] ;
9083 const processTransaction = async ( _txParams : TransactionParams ) => {
@@ -103,7 +96,7 @@ describe('wallet', () => {
10396 } ) ;
10497
10598 it ( 'throws unauthorized for unknown addresses' , async ( ) => {
106- const { engine } = createProviderAndEngine ( ) ;
99+ const engine = new JsonRpcEngine ( ) ;
107100 const getAccounts = async ( ) => testAddresses . slice ( 0 , 2 ) ;
108101 const witnessedTxParams : TransactionParams [ ] = [ ] ;
109102 const processTransaction = async ( _txParams : TransactionParams ) => {
@@ -123,7 +116,7 @@ describe('wallet', () => {
123116 } ) ;
124117
125118 it ( 'should not override other request params' , async ( ) => {
126- const { engine } = createProviderAndEngine ( ) ;
119+ const engine = new JsonRpcEngine ( ) ;
127120 const getAccounts = async ( ) => testAddresses . slice ( 0 , 2 ) ;
128121 const witnessedTxParams : TransactionParams [ ] = [ ] ;
129122 const processTransaction = async ( _txParams : TransactionParams ) => {
@@ -145,7 +138,7 @@ describe('wallet', () => {
145138
146139 describe ( 'signTransaction' , ( ) => {
147140 it ( 'should process sign transaction when provided a valid address' , async ( ) => {
148- const { engine } = createProviderAndEngine ( ) ;
141+ const engine = new JsonRpcEngine ( ) ;
149142 const getAccounts = async ( ) => testAddresses . slice ( 0 , 2 ) ;
150143 const witnessedTxParams : TransactionParams [ ] = [ ] ;
151144 const processSignTransaction = async ( _txParams : TransactionParams ) => {
@@ -170,7 +163,7 @@ describe('wallet', () => {
170163 } ) ;
171164
172165 it ( 'should not override other request params' , async ( ) => {
173- const { engine } = createProviderAndEngine ( ) ;
166+ const engine = new JsonRpcEngine ( ) ;
174167 const getAccounts = async ( ) => testAddresses . slice ( 0 , 2 ) ;
175168 const witnessedTxParams : TransactionParams [ ] = [ ] ;
176169 const processSignTransaction = async ( _txParams : TransactionParams ) => {
@@ -193,7 +186,7 @@ describe('wallet', () => {
193186 } ) ;
194187
195188 it ( 'should throw when provided invalid address' , async ( ) => {
196- const { engine } = createProviderAndEngine ( ) ;
189+ const engine = new JsonRpcEngine ( ) ;
197190 const getAccounts = async ( ) => testAddresses . slice ( 0 , 2 ) ;
198191 const witnessedTxParams : TransactionParams [ ] = [ ] ;
199192 const processSignTransaction = async ( _txParams : TransactionParams ) => {
@@ -215,7 +208,7 @@ describe('wallet', () => {
215208 } ) ;
216209
217210 it ( 'should throw when provided unknown address' , async ( ) => {
218- const { engine } = createProviderAndEngine ( ) ;
211+ const engine = new JsonRpcEngine ( ) ;
219212 const getAccounts = async ( ) => testAddresses . slice ( 0 , 2 ) ;
220213 const witnessedTxParams : TransactionParams [ ] = [ ] ;
221214 const processSignTransaction = async ( _txParams : TransactionParams ) => {
@@ -240,7 +233,7 @@ describe('wallet', () => {
240233
241234 describe ( 'signTypedData' , ( ) => {
242235 it ( 'should sign with a valid address' , async ( ) => {
243- const { engine } = createProviderAndEngine ( ) ;
236+ const engine = new JsonRpcEngine ( ) ;
244237 const getAccounts = async ( ) => testAddresses . slice ( ) ;
245238 const witnessedMsgParams : TypedMessageV1Params [ ] = [ ] ;
246239 const processTypedMessage = async ( msgParams : TypedMessageV1Params ) => {
@@ -276,7 +269,7 @@ describe('wallet', () => {
276269 } ) ;
277270
278271 it ( 'should throw with invalid address' , async ( ) => {
279- const { engine } = createProviderAndEngine ( ) ;
272+ const engine = new JsonRpcEngine ( ) ;
280273 const getAccounts = async ( ) => testAddresses . slice ( ) ;
281274 const witnessedMsgParams : TypedMessageV1Params [ ] = [ ] ;
282275 const processTypedMessage = async ( msgParams : TypedMessageV1Params ) => {
@@ -303,7 +296,7 @@ describe('wallet', () => {
303296 } ) ;
304297
305298 it ( 'should throw with unknown address' , async ( ) => {
306- const { engine } = createProviderAndEngine ( ) ;
299+ const engine = new JsonRpcEngine ( ) ;
307300 const getAccounts = async ( ) => testAddresses . slice ( ) ;
308301 const witnessedMsgParams : TypedMessageV1Params [ ] = [ ] ;
309302 const processTypedMessage = async ( msgParams : TypedMessageV1Params ) => {
@@ -333,7 +326,7 @@ describe('wallet', () => {
333326
334327 describe ( 'signTypedDataV3' , ( ) => {
335328 it ( 'should sign data and normalizes verifyingContract' , async ( ) => {
336- const { engine } = createProviderAndEngine ( ) ;
329+ const engine = new JsonRpcEngine ( ) ;
337330 const getAccounts = async ( ) => testAddresses . slice ( ) ;
338331 const witnessedMsgParams : TypedMessageParams [ ] = [ ] ;
339332 const processTypedMessageV3 = async ( msgParams : TypedMessageParams ) => {
@@ -393,7 +386,7 @@ describe('wallet', () => {
393386 } ) ;
394387
395388 it ( 'should throw if verifyingContract is invalid hex value' , async ( ) => {
396- const { engine } = createProviderAndEngine ( ) ;
389+ const engine = new JsonRpcEngine ( ) ;
397390 const getAccounts = async ( ) => testAddresses . slice ( ) ;
398391 const witnessedMsgParams : TypedMessageParams [ ] = [ ] ;
399392 const processTypedMessageV3 = async ( msgParams : TypedMessageParams ) => {
@@ -434,7 +427,7 @@ describe('wallet', () => {
434427 } ) ;
435428
436429 it ( 'should not throw if verifyingContract is undefined' , async ( ) => {
437- const { engine } = createProviderAndEngine ( ) ;
430+ const engine = new JsonRpcEngine ( ) ;
438431 const getAccounts = async ( ) => testAddresses . slice ( ) ;
439432 const witnessedMsgParams : TypedMessageParams [ ] = [ ] ;
440433 const processTypedMessageV3 = async ( msgParams : TypedMessageParams ) => {
@@ -513,7 +506,7 @@ describe('wallet', () => {
513506 } ) ;
514507
515508 it ( 'should not throw if request is permit with valid hex value for verifyingContract address' , async ( ) => {
516- const { engine } = createProviderAndEngine ( ) ;
509+ const engine = new JsonRpcEngine ( ) ;
517510 const getAccounts = async ( ) => testAddresses . slice ( ) ;
518511 const witnessedMsgParams : TypedMessageParams [ ] = [ ] ;
519512 const processTypedMessageV4 = async ( msgParams : TypedMessageParams ) => {
@@ -542,7 +535,7 @@ describe('wallet', () => {
542535 } ) ;
543536
544537 it ( 'should throw if request is permit with invalid hex value for verifyingContract address' , async ( ) => {
545- const { engine } = createProviderAndEngine ( ) ;
538+ const engine = new JsonRpcEngine ( ) ;
546539 const getAccounts = async ( ) => testAddresses . slice ( ) ;
547540 const witnessedMsgParams : TypedMessageParams [ ] = [ ] ;
548541 const processTypedMessageV4 = async ( msgParams : TypedMessageParams ) => {
@@ -570,7 +563,7 @@ describe('wallet', () => {
570563 } ) ;
571564
572565 it ( 'should not throw if request is permit with undefined value for verifyingContract address' , async ( ) => {
573- const { engine } = createProviderAndEngine ( ) ;
566+ const engine = new JsonRpcEngine ( ) ;
574567 const getAccounts = async ( ) => testAddresses . slice ( ) ;
575568 const witnessedMsgParams : TypedMessageParams [ ] = [ ] ;
576569 const processTypedMessageV4 = async ( msgParams : TypedMessageParams ) => {
@@ -599,7 +592,7 @@ describe('wallet', () => {
599592 } ) ;
600593
601594 it ( 'should not throw if request is permit with verifyingContract address equal to "cosmos"' , async ( ) => {
602- const { engine } = createProviderAndEngine ( ) ;
595+ const engine = new JsonRpcEngine ( ) ;
603596 const getAccounts = async ( ) => testAddresses . slice ( ) ;
604597 const witnessedMsgParams : TypedMessageParams [ ] = [ ] ;
605598 const processTypedMessageV4 = async ( msgParams : TypedMessageParams ) => {
@@ -628,7 +621,7 @@ describe('wallet', () => {
628621 } ) ;
629622
630623 it ( 'should throw if message does not have types defined' , async ( ) => {
631- const { engine } = createProviderAndEngine ( ) ;
624+ const engine = new JsonRpcEngine ( ) ;
632625 const getAccounts = async ( ) => testAddresses . slice ( ) ;
633626 const witnessedMsgParams : TypedMessageParams [ ] = [ ] ;
634627 const processTypedMessageV4 = async ( msgParams : TypedMessageParams ) => {
@@ -655,7 +648,7 @@ describe('wallet', () => {
655648 } ) ;
656649
657650 it ( 'should throw if type of primaryType is not defined' , async ( ) => {
658- const { engine } = createProviderAndEngine ( ) ;
651+ const engine = new JsonRpcEngine ( ) ;
659652 const getAccounts = async ( ) => testAddresses . slice ( ) ;
660653 const witnessedMsgParams : TypedMessageParams [ ] = [ ] ;
661654 const processTypedMessageV4 = async ( msgParams : TypedMessageParams ) => {
@@ -687,7 +680,7 @@ describe('wallet', () => {
687680
688681 describe ( 'sign' , ( ) => {
689682 it ( 'should sign with a valid address' , async ( ) => {
690- const { engine } = createProviderAndEngine ( ) ;
683+ const engine = new JsonRpcEngine ( ) ;
691684 const getAccounts = async ( ) => testAddresses . slice ( ) ;
692685 const witnessedMsgParams : MessageParams [ ] = [ ] ;
693686 const processPersonalMessage = async ( msgParams : MessageParams ) => {
@@ -718,7 +711,7 @@ describe('wallet', () => {
718711 } ) ;
719712
720713 it ( 'should error when provided invalid address' , async ( ) => {
721- const { engine } = createProviderAndEngine ( ) ;
714+ const engine = new JsonRpcEngine ( ) ;
722715 const getAccounts = async ( ) => testAddresses . slice ( ) ;
723716 const witnessedMsgParams : MessageParams [ ] = [ ] ;
724717 const processPersonalMessage = async ( msgParams : MessageParams ) => {
@@ -742,7 +735,7 @@ describe('wallet', () => {
742735 } ) ;
743736
744737 it ( 'should error when provided unknown address' , async ( ) => {
745- const { engine } = createProviderAndEngine ( ) ;
738+ const engine = new JsonRpcEngine ( ) ;
746739 const getAccounts = async ( ) => testAddresses . slice ( ) ;
747740 const witnessedMsgParams : MessageParams [ ] = [ ] ;
748741 const processPersonalMessage = async ( msgParams : MessageParams ) => {
@@ -779,7 +772,7 @@ describe('wallet', () => {
779772 addressHex : '0xbe93f9bacbcffc8ee6663f2647917ed7a20a57bb' ,
780773 } ;
781774
782- const { engine } = createProviderAndEngine ( ) ;
775+ const engine = new JsonRpcEngine ( ) ;
783776 engine . push ( createWalletMiddleware ( { getAccounts } ) ) ;
784777
785778 const payload = {
@@ -805,7 +798,7 @@ describe('wallet', () => {
805798 addressHex : '0xbe93f9bacbcffc8ee6663f2647917ed7a20a57bb' ,
806799 } ;
807800
808- const { engine } = createProviderAndEngine ( ) ;
801+ const engine = new JsonRpcEngine ( ) ;
809802 engine . push ( createWalletMiddleware ( { getAccounts } ) ) ;
810803
811804 const payload = {
0 commit comments