|
|
@ -9,9 +9,17 @@ export const walletEnabled = () => { |
|
|
|
} else if (window.ethereum.isUnlocked === false && window.ethereum.isNiftyWallet) { // Nifty Wallet
|
|
|
|
} else if (window.ethereum.isUnlocked === false && window.ethereum.isNiftyWallet) { // Nifty Wallet
|
|
|
|
return Promise.resolve(false) |
|
|
|
return Promise.resolve(false) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
window.ethereum.enable() |
|
|
|
if (window.ethereum.request) { |
|
|
|
window.web3 = new Web3(window.web3.currentProvider) |
|
|
|
return window.ethereum.request({ method: 'eth_requestAccounts' }) |
|
|
|
return Promise.resolve(true) |
|
|
|
.then((_res) => { |
|
|
|
|
|
|
|
window.web3 = new Web3(window.web3.currentProvider) |
|
|
|
|
|
|
|
return Promise.resolve(true) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
window.ethereum.enable() |
|
|
|
|
|
|
|
window.web3 = new Web3(window.web3.currentProvider) |
|
|
|
|
|
|
|
return Promise.resolve(true) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (window.web3) { |
|
|
|
} else if (window.web3) { |
|
|
|
window.web3 = new Web3(window.web3.currentProvider) |
|
|
|
window.web3 = new Web3(window.web3.currentProvider) |
|
|
@ -23,7 +31,11 @@ export const walletEnabled = () => { |
|
|
|
|
|
|
|
|
|
|
|
export const connectToWallet = () => { |
|
|
|
export const connectToWallet = () => { |
|
|
|
if (window.ethereum) { |
|
|
|
if (window.ethereum) { |
|
|
|
window.ethereum.enable() |
|
|
|
if (window.ethereum.request) { |
|
|
|
|
|
|
|
window.ethereum.request({ method: 'eth_requestAccounts' }) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
window.ethereum.enable() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -35,20 +47,28 @@ export const getCurrentAccount = async () => { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export const hideConnectButton = () => { |
|
|
|
export const hideConnectButton = () => { |
|
|
|
if (window.ethereum) { |
|
|
|
return new Promise((resolve) => { |
|
|
|
window.web3 = new Web3(window.ethereum) |
|
|
|
if (window.ethereum) { |
|
|
|
if (window.ethereum.isNiftyWallet) { |
|
|
|
window.web3 = new Web3(window.ethereum) |
|
|
|
return true |
|
|
|
if (window.ethereum.isNiftyWallet) { |
|
|
|
} else if (window.ethereum.isMetaMask) { |
|
|
|
resolve({ shouldHide: true, account: window.ethereum.selectedAddress }) |
|
|
|
if (window.ethereum.selectedAddress) { |
|
|
|
} else if (window.ethereum.isMetaMask) { |
|
|
|
return true |
|
|
|
window.ethereum.sendAsync({ method: 'eth_accounts' }, function (error, resp) { |
|
|
|
|
|
|
|
if (error) { |
|
|
|
|
|
|
|
resolve({ shouldHide: false }) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (resp) { |
|
|
|
|
|
|
|
const { result: accounts } = resp |
|
|
|
|
|
|
|
accounts.length > 0 ? resolve({ shouldHide: true, account: accounts[0] }) : resolve({ shouldHide: false }) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return false |
|
|
|
console.log(window.ethereum.selectedAddress) |
|
|
|
|
|
|
|
resolve({ shouldHide: true, account: window.ethereum.selectedAddress }) |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return true |
|
|
|
resolve({ shouldHide: false }) |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
}) |
|
|
|
return false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|