Support only external Ethereum auth for now

This commit is contained in:
Alex Gleason
2022-02-10 19:34:23 -06:00
parent 01dd53328b
commit abcd55752d
5 changed files with 58 additions and 39 deletions

View File

@ -0,0 +1,26 @@
export const ethereum = () => window.ethereum;
export const hasEthereum = () => Boolean(ethereum());
// Requests an Ethereum wallet from the browser
// Returns a Promise containing the Ethereum wallet address (string).
export const getWallet = () => {
return ethereum().request({ method: 'eth_requestAccounts' })
.then(wallets => wallets[0]);
};
// Asks the browser to sign a message with Ethereum.
// Returns a Promise containing the signature (string).
export const signMessage = (wallet, message) => {
return ethereum().request({ method: 'personal_sign', params: [message, wallet] });
};
// Combines the above functions.
// Returns an object with the `wallet` and `signature`
export const getWalletAndSign = message => {
return getWallet().then(wallet => {
return signMessage(wallet, message).then(signature => {
return { wallet, signature };
});
});
};

View File

@ -8,7 +8,8 @@ export const getQuirks = createSelector([
], (v) => {
return {
invertedPagination: v.software === PLEROMA,
ethereumLoginOnly: v.software === MITRA,
noApps: v.software === MITRA,
noOAuthForm: v.software === MITRA,
};
});