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: add editor config #30

Merged
merged 6 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
root = true

[*]
charset = utf-8
indent_size = 4
end_of_line = lf
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.yml]
indent_size = 4
indent_style = space
2 changes: 1 addition & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"semi": true,
"tabWidth": 2,
"tabWidth": 4,
"printWidth": 100,
"singleQuote": true,
"trailingComma": "all",
Expand Down
168 changes: 84 additions & 84 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,86 +1,86 @@
{
"name": "ark-connect-webext",
"private": true,
"version": "1.4.1",
"type": "module",
"scripts": {
"dev": "VITE_SEED_ADDRESSES=true vite",
"dev:firefox": "VITE_SEED_ADDRESSES=true BROWSER=firefox vite",
"dev:bare": "vite",
"dev:bare:firefox": "BROWSER=firefox vite",
"test": "vitest",
"build": "rm -rf dist && tsc && vite build && zip build.zip dist",
"build:firefox": "rm -rf dist && BROWSER=firefox vite build --config vite.production.config.ts",
"build:chrome": "rm -rf dist && BROWSER=chrome vite build --config vite.production.config.ts",
"lint": "npx eslint -c .eslintrc.json --cache --ext .jsx,.js,.tsx,.ts src --fix",
"format": "prettier --write src/**/*.{js,jsx,ts,tsx} --config .prettierrc.json",
"preview": "vite preview",
"generate:icons": "node scripts/generate-icons.js"
},
"dependencies": {
"@ardenthq/sdk": "1.3.0-beta.1",
"@ardenthq/sdk-ark": "1.3.0-beta.1",
"@ardenthq/sdk-cryptography": "1.3.0-beta.1",
"@ardenthq/sdk-helpers": "1.3.0-beta.1",
"@ardenthq/sdk-intl": "1.3.0-beta.1",
"@ardenthq/sdk-ledger": "1.3.0-beta.1",
"@ardenthq/sdk-profiles": "1.3.0-beta.1",
"@reduxjs/toolkit": "^1.9.5",
"@sentry/react": "^7.69.0",
"@styled-system/should-forward-prop": "^5.1.5",
"@tippyjs/react": "^4.2.6",
"assert": "2.0.0",
"crypto-js": "^4.1.1",
"focus-trap-react": "^10.2.3",
"formik": "^2.4.3",
"locale-currency": "^0.0.2",
"node-fetch": "2.6.11",
"p-retry": "^6.2.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-idle-timer": "^5.7.2",
"react-redux": "^8.1.2",
"react-refresh": "^0.14.0",
"react-router-dom": "^6.15.0",
"redux": "^5.0.1",
"redux-persist": "^6.0.0",
"semver": "^7.5.4",
"socks-proxy-agent": "^7.0.0",
"string-hash": "^1.1.3",
"styled-components": "^6.0.7",
"styled-system": "^5.1.5",
"tippy.js": "^6.3.7",
"uuid": "^9.0.1",
"xss": "^1.0.14",
"yup": "^1.2.0"
},
"devDependencies": {
"@samrum/vite-plugin-web-extension": "^5.0.0",
"@testing-library/react": "^14.1.2",
"@types/crypto-js": "^4.1.1",
"@types/react": "^18.2.15",
"@types/react-dom": "^18.2.7",
"@types/semver": "^7.5.6",
"@types/string-hash": "^1.1.1",
"@types/styled-components": "^5.1.26",
"@types/styled-system": "^5.1.16",
"@types/styled-system__should-forward-prop": "^5.1.2",
"@types/uuid": "^9.0.5",
"@types/webextension-polyfill": "^0.10.0",
"@typescript-eslint/eslint-plugin": "^6.3.0",
"@typescript-eslint/parser": "^6.3.0",
"@vitejs/plugin-react": "^4.0.4",
"eslint": "^8.46.0",
"eslint-plugin-react": "^7.33.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"jsdom": "^24.0.0",
"prettier": "^3.0.1",
"svgo": "^3.0.2",
"typescript": "^5.0.2",
"vite": "^5.0.12",
"vite-plugin-web-extension": "^4.1.1",
"vitest": "^1.2.1",
"webextension-polyfill": "^0.10.0"
}
"name": "ark-connect-webext",
"private": true,
"version": "1.4.1",
"type": "module",
"scripts": {
"dev": "VITE_SEED_ADDRESSES=true vite",
"dev:firefox": "VITE_SEED_ADDRESSES=true BROWSER=firefox vite",
"dev:bare": "vite",
"dev:bare:firefox": "BROWSER=firefox vite",
"test": "vitest",
"build": "rm -rf dist && tsc && vite build && zip build.zip dist",
"build:firefox": "rm -rf dist && BROWSER=firefox vite build --config vite.production.config.ts",
"build:chrome": "rm -rf dist && BROWSER=chrome vite build --config vite.production.config.ts",
"lint": "npx eslint -c .eslintrc.json --cache --ext .jsx,.js,.tsx,.ts src --fix",
"format": "prettier --write src/**/*.{ts,tsx} --config .prettierrc.json",
"preview": "vite preview",
"generate:icons": "node scripts/generate-icons.js"
},
"dependencies": {
"@ardenthq/sdk": "1.3.0-beta.1",
"@ardenthq/sdk-ark": "1.3.0-beta.1",
"@ardenthq/sdk-cryptography": "1.3.0-beta.1",
"@ardenthq/sdk-helpers": "1.3.0-beta.1",
"@ardenthq/sdk-intl": "1.3.0-beta.1",
"@ardenthq/sdk-ledger": "1.3.0-beta.1",
"@ardenthq/sdk-profiles": "1.3.0-beta.1",
"@reduxjs/toolkit": "^1.9.5",
"@sentry/react": "^7.69.0",
"@styled-system/should-forward-prop": "^5.1.5",
"@tippyjs/react": "^4.2.6",
"assert": "2.0.0",
"crypto-js": "^4.1.1",
"focus-trap-react": "^10.2.3",
"formik": "^2.4.3",
"locale-currency": "^0.0.2",
"node-fetch": "2.6.11",
"p-retry": "^6.2.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-idle-timer": "^5.7.2",
"react-redux": "^8.1.2",
"react-refresh": "^0.14.0",
"react-router-dom": "^6.15.0",
"redux": "^5.0.1",
"redux-persist": "^6.0.0",
"semver": "^7.5.4",
"socks-proxy-agent": "^7.0.0",
"string-hash": "^1.1.3",
"styled-components": "^6.0.7",
"styled-system": "^5.1.5",
"tippy.js": "^6.3.7",
"uuid": "^9.0.1",
"xss": "^1.0.14",
"yup": "^1.2.0"
},
"devDependencies": {
"@samrum/vite-plugin-web-extension": "^5.0.0",
"@testing-library/react": "^14.1.2",
"@types/crypto-js": "^4.1.1",
"@types/react": "^18.2.15",
"@types/react-dom": "^18.2.7",
"@types/semver": "^7.5.6",
"@types/string-hash": "^1.1.1",
"@types/styled-components": "^5.1.26",
"@types/styled-system": "^5.1.16",
"@types/styled-system__should-forward-prop": "^5.1.2",
"@types/uuid": "^9.0.5",
"@types/webextension-polyfill": "^0.10.0",
"@typescript-eslint/eslint-plugin": "^6.3.0",
"@typescript-eslint/parser": "^6.3.0",
"@vitejs/plugin-react": "^4.0.4",
"eslint": "^8.46.0",
"eslint-plugin-react": "^7.33.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"jsdom": "^24.0.0",
"prettier": "^3.0.1",
"svgo": "^3.0.2",
"typescript": "^5.0.2",
"vite": "^5.0.12",
"vite-plugin-web-extension": "^4.1.1",
"vitest": "^1.2.1",
"webextension-polyfill": "^0.10.0"
}
}
118 changes: 59 additions & 59 deletions src/components/AutoUnlockWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,80 +11,80 @@ import { useIdleTimer } from 'react-idle-timer';
import browser from 'webextension-polyfill';

type Props = {
children: React.ReactNode | React.ReactNode[];
children: React.ReactNode | React.ReactNode[];
};

const AutoUnlockWrapper = ({ children }: Props) => {
const dispatch = useAppDispatch();
const { currentThemeMode } = useThemeMode();
const { persistScreen } = getPersistedValues();
const { profile, isProfileReady } = useProfileContext();
const navigate = useNavigate();
const [isLoadingLocalData, setIsLoadingLocalData] = useState<boolean>(true);
const locked = useAppSelector(UIStore.selectLocked);
const dispatch = useAppDispatch();
const { currentThemeMode } = useThemeMode();
const { persistScreen } = getPersistedValues();
const { profile, isProfileReady } = useProfileContext();
const navigate = useNavigate();
const [isLoadingLocalData, setIsLoadingLocalData] = useState<boolean>(true);
const locked = useAppSelector(UIStore.selectLocked);

useLayoutEffect(() => {
const checkLocked = async () => {
const status = await browser.runtime.sendMessage({ type: 'CHECK_LOCK' });
useLayoutEffect(() => {
const checkLocked = async () => {
const status = await browser.runtime.sendMessage({ type: 'CHECK_LOCK' });

dispatch(UIStore.lockedChanged(status.isLocked));
};
dispatch(UIStore.lockedChanged(status.isLocked));
};

void checkLocked();
}, [locked]);
void checkLocked();
}, [locked]);

useEffect(() => {
handleAutoLockNavigation();
setIsLoadingLocalData(false);
useEffect(() => {
handleAutoLockNavigation();
setIsLoadingLocalData(false);

handlePersistScreenRedirect();
handleLedgerNavigation();
}, [locked, profile.id()]);
handlePersistScreenRedirect();
handleLedgerNavigation();
}, [locked, profile.id()]);

useIdleTimer({
throttle: 1000,
onAction: () => {
browser.runtime.sendMessage({ type: 'REGISTERED_ACTIVITY' });
},
disabled: locked,
});
useIdleTimer({
throttle: 1000,
onAction: () => {
browser.runtime.sendMessage({ type: 'REGISTERED_ACTIVITY' });
},
disabled: locked,
});

const handleLedgerNavigation = () => {
const locationHref = window.location.href;
const handleLedgerNavigation = () => {
const locationHref = window.location.href;

if (!locationHref.includes('import_with_ledger')) return;
navigate('/ledger-import');
};
if (!locationHref.includes('import_with_ledger')) return;
navigate('/ledger-import');
};

const handlePersistScreenRedirect = () => {
if (!persistScreen) return;
navigate(persistScreen.screen);
};
const handlePersistScreenRedirect = () => {
if (!persistScreen) return;
navigate(persistScreen.screen);
};

const handleAutoLockNavigation = () => {
if (locked) {
navigate('/enter-password');
return;
}
const handleAutoLockNavigation = () => {
if (locked) {
navigate('/enter-password');
return;
}

if (isProfileReady && profile.wallets().count() === 0) {
navigate('/splash-screen');
return;
}
};
if (isProfileReady && profile.wallets().count() === 0) {
navigate('/splash-screen');
return;
}
};

return (
<FlexContainer
flexDirection='column'
height='100vh'
width='100vw'
justifyContent='center'
alignItems='center'
bg={currentThemeMode === UIStore.ThemeMode.DARK ? 'lightBlack' : 'subtleWhite'}
>
<HandleLoadingState loading={isLoadingLocalData}>{children}</HandleLoadingState>
</FlexContainer>
);
return (
<FlexContainer
flexDirection='column'
height='100vh'
width='100vw'
justifyContent='center'
alignItems='center'
bg={currentThemeMode === UIStore.ThemeMode.DARK ? 'lightBlack' : 'subtleWhite'}
>
<HandleLoadingState loading={isLoadingLocalData}>{children}</HandleLoadingState>
</FlexContainer>
);
};

export default AutoUnlockWrapper;
8 changes: 4 additions & 4 deletions src/components/Logo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { Icon } from '@/shared/components/';
import { Theme } from '@/shared/theme';

type LogoProps = {
className?: string;
className?: string;
} & ColorProps<Theme> &
LayoutProps<Theme>;
LayoutProps<Theme>;

export const Logo = ({ className, ...rest }: LogoProps) => {
return <Icon className={className} width='147px' height='18px' icon='logo' {...rest} />;
return <Icon className={className} width='147px' height='18px' icon='logo' {...rest} />;
};

export const LogoIcon = ({ className, ...rest }: LogoProps) => {
return <Icon className={className} width='24px' height='24px' icon='logo-inverted' {...rest} />;
return <Icon className={className} width='24px' height='24px' icon='logo-inverted' {...rest} />;
};
Loading
Loading