Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async login() {
try {
const torus = new Torus({
buttonPosition: 'bottom-left'
})
window.torus = torus
await torus.init({
buildEnv: this.buildEnv,
enabledVerifiers: {
reddit: false
},
enableLogging: true,
network: {
host: 'rinkeby', // mandatory
chainId: 4
},
showTorusButton: true
})
await torus.login() // await torus.ethereum.enable()
export const loginWithTorus = () => async (
dispatch: ThunkDispatch
) => {
const networkId = getNetworkId();
const torusNetwork = getTorusNetwork(networkId);
let accountObject: Partial = {};
if (torusNetwork) {
const torus: any = new Torus({});
try {
await torus.init({
network: { host: torusNetwork },
showTorusButton: false,
});
await torus.login();
const web3 = new Web3(torus.provider);
const provider = new Web3Provider(torus.provider);
const isWeb3 = true;
windowRef.torus = torus;
const accounts = await web3.eth.getAccounts();
const account = accounts[0];
initialize: async function() {
const torus = new Torus()
await torus.init()
await torus.login()
web3Obj.setweb3(torus.provider)
}
}
window.provider = async (config) => {
const torus = new Torus.default();
await torus.init();
await torus.setProvider(config.provider.network);
return torus.provider;
}