This repository has been archived by the owner on Oct 27, 2020. It is now read-only.
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
9e7df28
commit ad454b9
Showing
12 changed files
with
46 additions
and
95 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 @@ | ||
declare module 'truffle-hdwallet-provider' |
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 |
---|---|---|
@@ -1,48 +1,48 @@ | ||
import Web3 from 'web3' | ||
import { nodeUri } from '../config' | ||
const bip39 = require('bip39') | ||
const HDWalletProvider = require('truffle-hdwallet-provider') | ||
import bip39 from 'bip39' | ||
import HDWalletProvider from 'truffle-hdwallet-provider' | ||
|
||
export class BurnerWalletProvider { | ||
web3: Web3 | ||
private web3: Web3 | ||
|
||
constructor() { | ||
public constructor() { | ||
// Default | ||
this.web3 = null as any | ||
} | ||
|
||
async isAvaliable() { | ||
public async isAvailable() { | ||
return true | ||
} | ||
|
||
async isLogged() { | ||
public async isLogged() { | ||
if (localStorage.getItem('seedphrase') !== null) { | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
async startLogin() { | ||
public async startLogin() { | ||
if (await this.isLogged()) { | ||
const mnemonic = localStorage.getItem('seedphrase') as string | ||
localStorage.setItem('logType', 'BurnerWallet') | ||
const provider = new HDWalletProvider(mnemonic, `${nodeUri}`, 0, 1); | ||
const provider = new HDWalletProvider(mnemonic, `${nodeUri}`, 0, 1) | ||
this.web3 = new Web3(provider) | ||
} else { | ||
const mnemonic = bip39.generateMnemonic() | ||
localStorage.setItem('seedphrase', mnemonic) | ||
localStorage.setItem('logType', 'BurnerWallet') | ||
const provider = new HDWalletProvider(mnemonic, `${nodeUri}`, 0, 1); | ||
const provider = new HDWalletProvider(mnemonic, `${nodeUri}`, 0, 1) | ||
this.web3 = new Web3(provider) | ||
} | ||
} | ||
|
||
async logout() { | ||
public async logout() { | ||
localStorage.removeItem('seedphrase') | ||
localStorage.removeItem('logType') | ||
} | ||
|
||
getProvider() { | ||
public getProvider() { | ||
return this.web3 | ||
} | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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