1
1
import * as core from "@shapeshiftoss/hdwallet-core" ;
2
2
import * as ledger from "@shapeshiftoss/hdwallet-ledger" ;
3
+ import * as metamask from "@shapeshiftoss/hdwallet-metamask-multichain" ;
3
4
import * as native from "@shapeshiftoss/hdwallet-native" ;
4
5
import * as phantom from "@shapeshiftoss/hdwallet-phantom" ;
5
6
import * as portis from "@shapeshiftoss/hdwallet-portis" ;
@@ -62,6 +63,8 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
62
63
"btcSupportsCoin()" ,
63
64
async ( ) => {
64
65
if ( ! wallet || portis . isPortis ( wallet ) ) return ;
66
+ // Non-EVM things are a pain to test with snaps on test env, this wasn't tested before and still isn't
67
+ if ( metamask . isMetaMask ( wallet ) ) return ;
65
68
expect ( wallet . btcSupportsCoin ( "Bitcoin" ) ) . toBeTruthy ( ) ;
66
69
expect ( await info . btcSupportsCoin ( "Bitcoin" ) ) . toBeTruthy ( ) ;
67
70
} ,
@@ -71,7 +74,7 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
71
74
test (
72
75
"btcSupportsCoin() - Testnet" ,
73
76
async ( ) => {
74
- if ( ! wallet || portis . isPortis ( wallet ) || phantom . isPhantom ( wallet ) ) return ;
77
+ if ( ! wallet || portis . isPortis ( wallet ) || phantom . isPhantom ( wallet ) || metamask . isMetaMask ( wallet ) ) return ;
75
78
expect ( wallet . btcSupportsCoin ( "Testnet" ) ) . toBeTruthy ( ) ;
76
79
expect ( await info . btcSupportsCoin ( "Testnet" ) ) . toBeTruthy ( ) ;
77
80
} ,
@@ -88,6 +91,9 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
88
91
)
89
92
return ;
90
93
94
+ // Non-EVM things are a pain to test with snaps on test env, this wasn't tested before and still isn't
95
+ if ( metamask . isMetaMask ( wallet ) ) return ;
96
+
91
97
/* FIXME: Expected failure (trezor does not use scriptType in deriving public keys
92
98
and ledger's dependency bitcoinjs-lib/src/crypto.js throws a mysterious TypeError
93
99
in between mock transport calls.
@@ -210,10 +216,14 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
210
216
const scriptType = args [ 3 ] as core . BTCInputScriptType ;
211
217
const expected = args [ 4 ] as string ;
212
218
219
+ // Non-EVM things are a pain to test with snaps on test env, this wasn't tested before and still isn't
220
+ if ( metamask . isMetaMask ( wallet ) ) return ;
221
+
213
222
if ( ! ( await wallet . btcSupportsCoin ( coin ) ) ) return ;
214
223
expect ( await info . btcSupportsCoin ( coin ) ) . toBeTruthy ( ) ;
215
224
if ( ! ( await wallet . btcSupportsScriptType ( coin , scriptType ) ) ) return ;
216
225
expect ( await info . btcSupportsScriptType ( coin , scriptType ) ) . toBeTruthy ( ) ;
226
+
217
227
const res = await wallet . btcGetAddress ( {
218
228
addressNList : core . bip32ToAddressNList ( path ) ,
219
229
coin : coin ,
@@ -230,7 +240,7 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
230
240
test (
231
241
"btcSignTx() - p2pkh" ,
232
242
async ( ) => {
233
- if ( ! wallet || portis . isPortis ( wallet ) || phantom . isPhantom ( wallet ) ) return ;
243
+ if ( ! wallet || portis . isPortis ( wallet ) || phantom . isPhantom ( wallet ) || metamask . isMetaMask ( wallet ) ) return ;
234
244
if ( ledger . isLedger ( wallet ) ) return ; // FIXME: Expected failure
235
245
const tx : core . BitcoinTx = {
236
246
version : 1 ,
@@ -305,7 +315,7 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
305
315
test (
306
316
"btcSignTx() - thorchain swap" ,
307
317
async ( ) => {
308
- if ( ! wallet || portis . isPortis ( wallet ) || phantom . isPhantom ( wallet ) ) return ;
318
+ if ( ! wallet || portis . isPortis ( wallet ) || phantom . isPhantom ( wallet ) || metamask . isMetaMask ( wallet ) ) return ;
309
319
if ( ledger . isLedger ( wallet ) ) return ; // FIXME: Expected failure
310
320
if ( trezor . isTrezor ( wallet ) ) return ; //TODO: Add trezor support for op return data passed at top level
311
321
const tx : core . BitcoinTx = {
@@ -391,6 +401,8 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
391
401
"btcSignMessage()" ,
392
402
async ( ) => {
393
403
if ( ! wallet ) return ;
404
+ // Non-EVM things are a pain to test with snaps on test env, this wasn't tested before and still isn't
405
+ if ( metamask . isMetaMask ( wallet ) ) return ;
394
406
395
407
// not implemented for native
396
408
if ( native . isNative ( wallet ) ) {
@@ -424,6 +436,8 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
424
436
"btcVerifyMessage() - good" ,
425
437
async ( ) => {
426
438
if ( ! wallet ) return ;
439
+ // Non-EVM things are a pain to test with snaps on test env, this wasn't tested before and still isn't
440
+ if ( metamask . isMetaMask ( wallet ) ) return ;
427
441
428
442
// not implemented for native
429
443
if ( native . isNative ( wallet ) ) {
@@ -447,6 +461,8 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
447
461
"btcVerifyMessage() - bad" ,
448
462
async ( ) => {
449
463
if ( ! wallet ) return ;
464
+ // Non-EVM things are a pain to test with snaps on test env, this wasn't tested before and still isn't
465
+ if ( metamask . isMetaMask ( wallet ) ) return ;
450
466
451
467
// not implemented for native
452
468
if ( native . isNative ( wallet ) ) {
@@ -470,6 +486,8 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
470
486
"btcSupportsSecureTransfer()" ,
471
487
async ( ) => {
472
488
if ( ! wallet ) return ;
489
+ // Non-EVM things are a pain to test with snaps on test env, this wasn't tested before and still isn't
490
+ if ( metamask . isMetaMask ( wallet ) ) return ;
473
491
expect ( typeof ( await wallet . btcSupportsSecureTransfer ( ) ) === typeof true ) . toBeTruthy ( ) ;
474
492
if ( await wallet . btcSupportsSecureTransfer ( ) ) {
475
493
// eslint-disable-next-line jest/no-conditional-expect
@@ -484,6 +502,8 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
484
502
"btcSupportsNativeShapeShift()" ,
485
503
async ( ) => {
486
504
if ( ! wallet ) return ;
505
+ // Non-EVM things are a pain to test with snaps on test env, this wasn't tested before and still isn't
506
+ if ( metamask . isMetaMask ( wallet ) ) return ;
487
507
expect ( typeof wallet . btcSupportsNativeShapeShift ( ) ) . toBe ( "boolean" ) ;
488
508
if ( wallet . btcSupportsNativeShapeShift ( ) ) {
489
509
// eslint-disable-next-line jest/no-conditional-expect
@@ -515,6 +535,8 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
515
535
const accountIdx = args [ 1 ] as number ;
516
536
const scriptType = args [ 2 ] as core . BTCInputScriptType ;
517
537
if ( ! wallet ) return ;
538
+ // Non-EVM things are a pain to test with snaps on test env, this wasn't tested before and still isn't
539
+ if ( metamask . isMetaMask ( wallet ) ) return ;
518
540
if ( ! ( await wallet . btcSupportsCoin ( coin ) ) ) return ;
519
541
expect ( await info . btcSupportsCoin ( coin ) ) . toBeTruthy ( ) ;
520
542
if ( ! ( await wallet . btcSupportsScriptType ( coin , scriptType ) ) ) return ;
@@ -537,29 +559,5 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
537
559
} ,
538
560
TIMEOUT
539
561
) ;
540
-
541
- test (
542
- "btcIsSameAccount()" ,
543
- async ( ) => {
544
- if ( ! wallet || phantom . isPhantom ( wallet ) ) return ;
545
- [ 0 , 1 , 9 ] . forEach ( ( idx ) => {
546
- const paths = wallet . btcGetAccountPaths ( {
547
- coin : "Bitcoin" ,
548
- accountIdx : idx ,
549
- } ) ;
550
- expect ( typeof wallet . btcIsSameAccount ( paths ) === typeof true ) . toBeTruthy ( ) ;
551
- paths . forEach ( ( path ) => {
552
- if ( wallet . getVendor ( ) === "Portis" ) {
553
- // eslint-disable-next-line jest/no-conditional-expect
554
- expect ( wallet . btcNextAccountPath ( path ) ) . toBeUndefined ( ) ;
555
- } else {
556
- // eslint-disable-next-line jest/no-conditional-expect
557
- expect ( wallet . btcNextAccountPath ( path ) ) . not . toBeUndefined ( ) ;
558
- }
559
- } ) ;
560
- } ) ;
561
- } ,
562
- TIMEOUT
563
- ) ;
564
562
} ) ;
565
563
}
0 commit comments