All files getWeb3.js

87.5% Statements 14/16
50% Branches 2/4
100% Functions 2/2
100% Lines 14/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27          1x 1x   1x 1x 1x 1x   1x     1x 1x   1x 1x 1x 1x   1x    
import Web3 from 'web3';
 
let homeWeb3;
let foreignWeb3;
 
export const getHomeWeb3 = config => {
    Iif (homeWeb3) return homeWeb3;
 
    homeWeb3 = new Web3(config.homeNodeUrl);
    homeWeb3.eth.defaultBlock = 'pending';
    const account = homeWeb3.eth.accounts.privateKeyToAccount(config.pk);
    homeWeb3.eth.accounts.wallet.add(account);
 
    return homeWeb3;
};
 
export const getForeignWeb3 = config => {
    Iif (foreignWeb3) return foreignWeb3;
 
    foreignWeb3 = new Web3(config.foreignNodeUrl);
    foreignWeb3.eth.defaultBlock = 'pending';
    const account = foreignWeb3.eth.accounts.privateKeyToAccount(config.pk);
    foreignWeb3.eth.accounts.wallet.add(account);
 
    return foreignWeb3;
};