Often you may want to be able an action on all wallets aviable (eg. checking if it has been ingected );
this can easly be done with a simple for
loop iterating over Wallet.stringNames
array as follows
NOTE: it is assumed that all the wallet are already enabled
for( let i = 0; i < Wallet.stringNames.length; i++ )
{
const thisCycleWallet = Wallet.get( Wallet.stringNames[i] );
doStuffWithWallet( thisCycleWallet );
}
this way we can also define our own utility function such as:
function allWalletsAreInjected()
{
return Wallet.stringNames.every(
wName => Wallet.has( wName )
);
}
NOTE:
Array.every
acts asarr.map( arrElem => hasProperty( arrElem ) ).reduce( (a,b) => a && b , true )
but should be overall more efficient since it does not have to test every element but can returnfalse
at the first element that is indeedfalse