Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/support multiple wallets #424

Merged
merged 24 commits into from
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
61fe7cf
build(frontend): add dependency '@rainbow-me/rainbowkit'
mattyg May 26, 2022
015b241
build(frontend): fix build issue due to webpack 5 update removing pol…
mattyg May 26, 2022
886dfe9
refactor: login & activate frontends to use a shared 'SignMessageLayo…
mattyg May 28, 2022
5df7f4e
build(frontend): remove unused dependencies @web3-react
mattyg May 28, 2022
91df29d
refactor(frontend): revert to standard EthAccount component in SignMe…
mattyg May 28, 2022
508994d
fix(frontend): auth util imports
mattyg May 28, 2022
5d0f240
feat(frontend): remove walletconnect support, add all wallets with bu…
mattyg May 28, 2022
59f5d54
fix(frontend): removed unused eth connection code
mattyg May 28, 2022
cc50991
fix(frontend): prevent state where only loading spinner displays when…
mattyg May 28, 2022
553070c
style(frontend): adjust rainowkit button to match site theming
mattyg May 28, 2022
34abb9b
style(frontend): minor rainowkit button styling adjustment
mattyg May 28, 2022
1fbf2fd
fix(frontend): prevent warnings on 'craco start' by disabling sourcem…
mattyg Jun 3, 2022
da16ac6
fix(frontend): remove not-working wallets 'argent' and 'steakwallet',…
mattyg Jun 5, 2022
1163cb1
feat(frontend): implement EthAccountDialog to copy current eth addres…
mattyg Jun 5, 2022
d74d30f
chore(frontend): move EthAccount into components/account/ subdir
mattyg Jun 5, 2022
8d6a002
fix(frontend): minor styling adjustment for Jazzicon in EthAccount
mattyg Jun 5, 2022
8556b3c
fix(frontend): ensure EthAccountDialog appears above Nav menu in mobi…
mattyg Jun 5, 2022
8000f41
Merge branch 'main' into feat/support_multiple_wallets
mattyg Jun 5, 2022
d42008f
fix(frontend): run build before source-map-explorer (as dev builds no…
mattyg Jun 5, 2022
52e97fb
fix(frontend): supress source-map-loader warnings via webpack config …
mattyg Jun 5, 2022
f36bd0d
Merge branch 'main' into feat/support_multiple_wallets
kristoferlund Jun 7, 2022
ad3283c
Merge branch 'main' into feat/support_multiple_wallets
kristoferlund Jun 7, 2022
f6f7db1
Fix: Removed capitalisation and uppercase buttons
kristoferlund Jun 7, 2022
51b7720
CHANGELOG
kristoferlund Jun 7, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions packages/api/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ node_modules
tsconfig.tsbuildinfo
uploads/*
!*uploads/praise_logo.png
!*uploads/gnosischain_logo.png
.nyc_output
17 changes: 3 additions & 14 deletions packages/api/src/activate/controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,7 @@ import { UserAccountModel } from '@useraccount/entities';
import { ethers } from 'ethers';
import { Response } from 'express';
import { ActivateRequestBody } from './types';

const generateLoginMessage = (
accountId: string,
ethereumAddress: string,
token: string
): string => {
return (
'SIGN THIS MESSAGE TO ACTIVATE YOUR ACCOUNT.\n\n' +
`ACCOUNT ID:\n${accountId}\n\n` +
`ADDRESS:\n${ethereumAddress}\n\n` +
`TOKEN:\n${token}`
);
};
import { generateActivateMessage } from './utils';

const activate = async (
req: TypedRequestBody<ActivateRequestBody>,
Expand All @@ -46,7 +34,7 @@ const activate = async (
throw new BadRequestError('User account already activated.');

// Generate expected message, token included.
const generatedMsg = generateLoginMessage(
const generatedMsg = generateActivateMessage(
accountId,
ethereumAddress,
userAccount.activateToken
Expand All @@ -68,6 +56,7 @@ const activate = async (

// Link user account with user
userAccount.user = user;
userAccount.activateToken = undefined;
await userAccount.save();

await logEvent(EventLogTypeKey.AUTHENTICATION, 'Activated account', {
Expand Down
12 changes: 12 additions & 0 deletions packages/api/src/activate/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export const generateActivateMessage = (
accountId: string,
ethereumAddress: string,
token: string
): string => {
return (
'SIGN THIS MESSAGE TO ACTIVATE YOUR ACCOUNT.\n\n' +
`ACCOUNT ID:\n${accountId}\n\n` +
`ADDRESS:\n${ethereumAddress}\n\n` +
`TOKEN:\n${token}`
);
};
9 changes: 1 addition & 8 deletions packages/api/src/auth/controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,10 @@ import {
RefreshRequestInput,
TokenSet,
} from './types';
import { generateLoginMessage } from './utils';

const jwtService = new JwtService();

const generateLoginMessage = (account: string, nonce: string): string => {
return (
'SIGN THIS MESSAGE TO LOGIN TO PRAISE.\n\n' +
`ADDRESS:\n${account}\n\n` +
`NONCE:\n${nonce}`
);
};

/**
* Description
* @param
Expand Down
11 changes: 11 additions & 0 deletions packages/api/src/auth/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,14 @@ export const extractAccessTokenFromRequest = (req: Request): string => {

return accessToken;
};

export const generateLoginMessage = (
account: string,
nonce: string
): string => {
return (
'SIGN THIS MESSAGE TO LOGIN TO PRAISE.\n\n' +
`ADDRESS:\n${account}\n\n` +
`NONCE:\n${nonce}`
);
};
Binary file added packages/api/uploads/gnosischain_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions packages/frontend/craco.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,22 @@ module.exports = {
eslint: {
enable: false, //TODO enable eslint during build
},
webpack: {
configure: {
resolve: {
/**
* with CRA 5 (webpack5), webpack no longer ships with node polyfills.
* Craco's team is looking to give it up (https://github.com/gsoft-inc/craco/issues/415).
* Possible alternatives: react-app-rewired or ejecting from CRA
*/
fallback: {
'util': require.resolve("util/"),
},
},
// with CRA 5 (webpack5), sourceMapLoader now complains about every third-party app that was compiled from
// typescript but doesn't have 'ts' files. This line ignores them.
// See: https://github.com/facebook/create-react-app/issues/11924
ignoreWarnings: [/to parse source map/i],
}
}
};
13 changes: 7 additions & 6 deletions packages/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@
"@fortawesome/react-fontawesome": "^0.1.17",
"@headlessui/react": "^1.4.1",
"@mui/material": "^5.3.0",
"@rainbow-me/rainbowkit": "^0.2.0",
"@tailwindcss/forms": "latest",
"@typescript-eslint/eslint-plugin": "^5.18.0",
"@typescript-eslint/parser": "^5.18.0",
"@ukstv/jazzicon-react": "^1.0.0",
"@web3-react/abstract-connector": "^6.0.7",
"@web3-react/core": "latest",
"@web3-react/injected-connector": "^6.0.7",
"api": "workspace:^",
"autoprefixer": "^10.4.7",
"axios": "^0.22.0",
Expand All @@ -38,6 +36,7 @@
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.28.0",
"eslint-plugin-react-hooks": "^4.3.0",
"ethers": "^5.6.8",
"final-form": "^4.20.4",
"jstz": "^2.1.1",
"jwt-decode": "^3.1.2",
Expand All @@ -61,11 +60,13 @@
"recoil-persist": "^4.0.0",
"source-map-explorer": "^2.5.2",
"tailwindcss": "^3.0.24",
"use-error-boundary": "^2.0.6"
"use-error-boundary": "^2.0.6",
"util": "^0.12.4",
"wagmi": "^0.4.3"
},
"scripts": {
"build": "craco build",
"analyze": "source-map-explorer 'build/static/js/*.js'",
"analyze": "yarn run build && source-map-explorer 'build/static/js/*.js'",
"load-env": "env-cmd --silent --no-override -f ../../.env env-cmd --silent --no-override",
"start": "TAILWIND_MODE=watch yarn run load-env craco start",
"lint": "eslint . --ext .ts --ext .tsx",
Expand All @@ -91,4 +92,4 @@
"@types/react-table": "^7.7.6",
"typescript": "^4.5.5"
}
}
}
27 changes: 0 additions & 27 deletions packages/frontend/src/components/EthAccount.tsx

This file was deleted.

89 changes: 0 additions & 89 deletions packages/frontend/src/components/EthConnection.tsx

This file was deleted.

53 changes: 53 additions & 0 deletions packages/frontend/src/components/account/EthAccount.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { shortenEthAddress } from 'api/dist/user/utils';
import { Jazzicon } from '@ukstv/jazzicon-react';
import { useAccount } from 'wagmi';
import { faAngleDown, faAngleRight } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { useState } from 'react';
import EthAccountDialog from './EthAccountDialog';

interface EthAccountParams {
className?: string;
showDownCaret?: boolean;
showRightCaret?: boolean;
}

export default function EthAccount({
className,
showDownCaret = true,
showRightCaret = false,
}: EthAccountParams): JSX.Element | null {
const { data } = useAccount();
const [isDialogOpen, setIsDialogOpen] = useState<boolean>(false);

if (!data?.address) return null;

return (
<>
<div
className={`flex justify-between items-center cursor-pointer ${className}`}
onClick={(): void => setIsDialogOpen(true)}
>
<div className="flex items-center space-x-2">
<div className="inline-block h-5">
<Jazzicon address={data.address} className="w-4 h-4" />
</div>
<span>{shortenEthAddress(data.address)}</span>
</div>
<div>
{showDownCaret && (
<FontAwesomeIcon icon={faAngleDown} className="w-4 h-4" />
)}
{showRightCaret && (
<FontAwesomeIcon icon={faAngleRight} className="w-4 h-4" />
)}
</div>
</div>
<EthAccountDialog
open={isDialogOpen}
address={data.address}
onClose={(): void => setIsDialogOpen(false)}
/>
</>
);
}
Loading