-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
52cd49a
commit c108f86
Showing
15 changed files
with
238 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import getWallets from './getWallets.evm' | ||
|
||
const getConnectedWallets = async()=>{ | ||
|
||
let connectedWallets = (await Promise.all( | ||
getWallets().map(async(wallet)=>{ | ||
if(await wallet.account()) { | ||
return wallet | ||
} | ||
}) | ||
)).filter((value)=>!!value) | ||
|
||
return connectedWallets | ||
} | ||
|
||
export default getConnectedWallets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import getWallets from './getWallets' | ||
|
||
const getConnectedWallets = async()=>{ | ||
|
||
let connectedWallets = (await Promise.all( | ||
getWallets().map(async(wallet)=>{ | ||
if(await wallet.account()) { | ||
return wallet | ||
} | ||
}) | ||
)).filter((value)=>!!value) | ||
|
||
return connectedWallets | ||
} | ||
|
||
export default getConnectedWallets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { getConnectedWallets } from 'src/index.evm' | ||
import { mock, resetMocks, trigger } from '@depay/web3-mock' | ||
import { supported as supportedBlockchains } from 'src/blockchains.evm' | ||
|
||
describe('getConnectedWallets', () => { | ||
|
||
let wallet | ||
|
||
describe('with no supported wallet connected', ()=>{ | ||
|
||
beforeEach(resetMocks) | ||
|
||
it('provides no connected wallets', async () => { | ||
expect(await getConnectedWallets()).toStrictEqual([]) | ||
}) | ||
}) | ||
|
||
describe('with supported wallet connected', ()=>{ | ||
|
||
const account = '0xd8da6bf26964af9d7eed9e03e53415d37aa96045' | ||
beforeEach(resetMocks) | ||
beforeEach(()=>{ | ||
mock({ blockchain: 'ethereum', accounts: { return: [account] } }) | ||
}) | ||
|
||
it('provides list of connected wallets', async () => { | ||
expect((await getConnectedWallets()).map((wallet)=>wallet.name)).toStrictEqual(["Wallet (Ethereum)"]) | ||
}) | ||
}) | ||
|
||
describe('with multiple supported wallets connected', ()=>{ | ||
|
||
const account = '0xd8da6bf26964af9d7eed9e03e53415d37aa96045' | ||
beforeEach(resetMocks) | ||
beforeEach(()=>{ | ||
mock({ blockchain: 'ethereum', accounts: { return: [account] } }) | ||
mock({ blockchain: 'bsc', accounts: { return: [account] }, wallet: 'metamask' }) | ||
mock({ blockchain: 'solana', accounts: { return: [account] }, wallet: 'phantom' }) | ||
}) | ||
|
||
it('provides list of connected wallets', async () => { | ||
expect((await getConnectedWallets()).map((wallet)=>wallet.name)).toStrictEqual(["MetaMask"]) | ||
}) | ||
}) | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { getConnectedWallets } from 'src' | ||
import { mock, resetMocks, trigger } from '@depay/web3-mock' | ||
import { supported as supportedBlockchains } from 'src/blockchains' | ||
|
||
describe('getConnectedWallets', () => { | ||
|
||
let wallet | ||
|
||
describe('with no supported wallet connected', ()=>{ | ||
|
||
beforeEach(resetMocks) | ||
|
||
it('provides no connected wallets', async () => { | ||
expect(await getConnectedWallets()).toStrictEqual([]) | ||
}) | ||
}) | ||
|
||
describe('with supported wallet connected', ()=>{ | ||
|
||
const account = '0xd8da6bf26964af9d7eed9e03e53415d37aa96045' | ||
beforeEach(resetMocks) | ||
beforeEach(()=>{ | ||
mock({ blockchain: 'ethereum', accounts: { return: [account] } }) | ||
}) | ||
|
||
it('provides list of connected wallets', async () => { | ||
expect((await getConnectedWallets()).map((wallet)=>wallet.name)).toStrictEqual(["Wallet (Ethereum)"]) | ||
}) | ||
}) | ||
|
||
describe('with multiple supported wallets connected', ()=>{ | ||
|
||
const account = '0xd8da6bf26964af9d7eed9e03e53415d37aa96045' | ||
beforeEach(resetMocks) | ||
beforeEach(()=>{ | ||
mock({ blockchain: 'ethereum', accounts: { return: [account] } }) | ||
mock({ blockchain: 'bsc', accounts: { return: [account] }, wallet: 'metamask' }) | ||
mock({ blockchain: 'solana', accounts: { return: [account] }, wallet: 'phantom' }) | ||
}) | ||
|
||
it('provides list of connected wallets', async () => { | ||
expect((await getConnectedWallets()).map((wallet)=>wallet.name)).toStrictEqual(["MetaMask"]) | ||
}) | ||
}) | ||
}) | ||
|