on master help sign in
eth: update Ethereum Provider integration

The Ethereum Provider API was recently updated: https://medium.com/metamask/breaking-changes-to-the-metamask-provider-are-here-7b11c9388be9 This change fixes Brave Wallet integration by using the new format.

commit8fb988ea7a2e17ec9178a61570d5cf88950c88a8 authortomholford <tomholford@users.noreply.github.com> dateWed 9 Feb 2022, 19:15 (5 years ago) parent3628fc5
2 files changed+13−6
src/views/Login/LoginSelector.tsx+10−5 src/views/Login/Metamask.js+3−1
src/views/Login/LoginSelector.tsx+10−5
@@ -79,14 +79,19 @@ export default function LoginSelector({
7979
8080 const selectMetamask = useCallback(async () => {
8181 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+ }
8287 setMetamask(true);
8388 setMetamaskSelected(true);
84− const accounts = await (window as any).ethereum.send(
85− 'eth_requestAccounts'
86− );
87− const wallet = new MetamaskWallet(accounts.result[0]);
89+ const accounts = await window.ethereum.request({
90+ method: 'eth_requestAccounts',
91+ });
92+ const wallet = new MetamaskWallet(accounts[0]);
8893
89− const web3 = new Web3((window as any).ethereum);
94+ const web3 = new Web3(window.ethereum);
9095 const authToken = await getAuthToken({
9196 address: wallet.address,
9297 walletType: WALLET_TYPES.METAMASK,
src/views/Login/Metamask.js+3−1
@@ -33,7 +33,9 @@ export default function Metamask({ className, goHome }) {
3333 const onSubmit = useCallback(async () => {
3434 try {
3535 setMetamask(true);
36− const accounts = await window.ethereum.send('eth_requestAccounts');
36+ const accounts = await window.ethereum.request({
37+ method: 'eth_requestAccounts',
38+ });
3739 const wallet = new MetamaskWallet(accounts.result[0]);
3840
3941 const web3 = new Web3(window.ethereum);