on master help sign in
Merge pull request #950 from urbit/t/brave-wallet-accounts
54f5889tomholford
src/views/Login/LoginSelector.tsx+10−5
@@ -79,14 +79,19 @@ export default function LoginSelector({
79
79
80 const selectMetamask = useCallback(async () => {
80 const selectMetamask = useCallback(async () => {
81 try {
81 try {
82+ if (!window.ethereum) {
83+ throw new Error(
84+ 'Device does not have an Ethereum provider available (is Metamask or Brave Wallet installed?)'
85+ );
86+ }
82 setMetamask(true);
87 setMetamask(true);
83 setMetamaskSelected(true);
88 setMetamaskSelected(true);
84− const accounts = await (window as any).ethereum.send(
89+ const accounts = await window.ethereum.request({
85− 'eth_requestAccounts'
90+ method: 'eth_requestAccounts',
86− );
91+ });
87− const wallet = new MetamaskWallet(accounts.result[0]);
92+ const wallet = new MetamaskWallet(accounts[0]);
88
93
89− const web3 = new Web3((window as any).ethereum);
94+ const web3 = new Web3(window.ethereum);
90 const authToken = await getAuthToken({
95 const authToken = await getAuthToken({
91 address: wallet.address,
96 address: wallet.address,
92 walletType: WALLET_TYPES.METAMASK,
97 walletType: WALLET_TYPES.METAMASK,
src/views/Login/Metamask.js+3−1
@@ -33,7 +33,9 @@ export default function Metamask({ className, goHome }) {
33 const onSubmit = useCallback(async () => {
33 const onSubmit = useCallback(async () => {
34 try {
34 try {
35 setMetamask(true);
35 setMetamask(true);
36− const accounts = await window.ethereum.send('eth_requestAccounts');
36+ const accounts = await window.ethereum.request({
37+ method: 'eth_requestAccounts',
38+ });
37 const wallet = new MetamaskWallet(accounts.result[0]);
39 const wallet = new MetamaskWallet(accounts.result[0]);
38
40
39 const web3 = new Web3(window.ethereum);
41 const web3 = new Web3(window.ethereum);