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

chore: upgrade useink and setup vite #288

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 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
1 change: 1 addition & 0 deletions frontend/.eslintcache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"/Users/gaboesquivel/Code/ink-link/frontend/src/main.tsx":"1","/Users/gaboesquivel/Code/ink-link/frontend/src/contexts/index.ts":"2","/Users/gaboesquivel/Code/ink-link/frontend/src/components/Notifications/index.ts":"3","/Users/gaboesquivel/Code/ink-link/frontend/src/App.tsx":"4","/Users/gaboesquivel/Code/ink-link/frontend/src/contexts/LinkContract.tsx":"5","/Users/gaboesquivel/Code/ink-link/frontend/src/contexts/UIContext.tsx":"6","/Users/gaboesquivel/Code/ink-link/frontend/src/components/Notifications/Snackbar.tsx":"7","/Users/gaboesquivel/Code/ink-link/frontend/src/components/Notifications/Notifications.tsx":"8","/Users/gaboesquivel/Code/ink-link/frontend/src/components/index.ts":"9","/Users/gaboesquivel/Code/ink-link/frontend/src/hooks/index.ts":"10","/Users/gaboesquivel/Code/ink-link/frontend/src/Resolver.tsx":"11","/Users/gaboesquivel/Code/ink-link/frontend/src/const/index.ts":"12","/Users/gaboesquivel/Code/ink-link/frontend/src/components/Button.tsx":"13","/Users/gaboesquivel/Code/ink-link/frontend/src/components/ConnectWallet.tsx":"14","/Users/gaboesquivel/Code/ink-link/frontend/src/components/FormContainer.tsx":"15","/Users/gaboesquivel/Code/ink-link/frontend/src/components/DryRunResult.tsx":"16","/Users/gaboesquivel/Code/ink-link/frontend/src/components/Header.tsx":"17","/Users/gaboesquivel/Code/ink-link/frontend/src/components/Loader.tsx":"18","/Users/gaboesquivel/Code/ink-link/frontend/src/components/Modal.tsx":"19","/Users/gaboesquivel/Code/ink-link/frontend/src/hooks/useLinkContract.ts":"20","/Users/gaboesquivel/Code/ink-link/frontend/src/components/NewUserGuide.tsx":"21","/Users/gaboesquivel/Code/ink-link/frontend/src/hooks/useSubmitHandler.ts":"22","/Users/gaboesquivel/Code/ink-link/frontend/src/hooks/useUI.ts":"23","/Users/gaboesquivel/Code/ink-link/frontend/src/components/LinksOverview.tsx":"24","/Users/gaboesquivel/Code/ink-link/frontend/src/lib/converter.ts":"25","/Users/gaboesquivel/Code/ink-link/frontend/src/components/Form.tsx":"26","/Users/gaboesquivel/Code/ink-link/frontend/src/components/SubmitResult.tsx":"27","/Users/gaboesquivel/Code/ink-link/frontend/src/components/AccountsDropdown.tsx":"28"},{"size":1132,"mtime":1692901862513,"results":"29","hashOfConfig":"30"},{"size":61,"mtime":1692896573527,"results":"31","hashOfConfig":"30"},{"size":60,"mtime":1692896573526,"results":"32","hashOfConfig":"30"},{"size":484,"mtime":1692896573523,"results":"33","hashOfConfig":"30"},{"size":1565,"mtime":1692896573527,"results":"34","hashOfConfig":"30"},{"size":562,"mtime":1692896573527,"results":"35","hashOfConfig":"30"},{"size":1105,"mtime":1692896573526,"results":"36","hashOfConfig":"30"},{"size":591,"mtime":1692896573525,"results":"37","hashOfConfig":"30"},{"size":266,"mtime":1692896573526,"results":"38","hashOfConfig":"30"},{"size":96,"mtime":1692896573527,"results":"39","hashOfConfig":"30"},{"size":2411,"mtime":1692901547363,"results":"40","hashOfConfig":"30"},{"size":572,"mtime":1692896573526,"results":"41","hashOfConfig":"30"},{"size":886,"mtime":1692896573524,"results":"42","hashOfConfig":"30"},{"size":2219,"mtime":1692896573524,"results":"43","hashOfConfig":"30"},{"size":1744,"mtime":1692939070985,"results":"44","hashOfConfig":"30"},{"size":1998,"mtime":1692896573524,"results":"45","hashOfConfig":"30"},{"size":1235,"mtime":1692941289642,"results":"46","hashOfConfig":"30"},{"size":1150,"mtime":1692939077251,"results":"47","hashOfConfig":"30"},{"size":1888,"mtime":1692896573525,"results":"48","hashOfConfig":"30"},{"size":330,"mtime":1692896573528,"results":"49","hashOfConfig":"30"},{"size":689,"mtime":1692896573525,"results":"50","hashOfConfig":"30"},{"size":2188,"mtime":1692900886603,"results":"51","hashOfConfig":"30"},{"size":299,"mtime":1692896573528,"results":"52","hashOfConfig":"30"},{"size":783,"mtime":1692896573525,"results":"53","hashOfConfig":"30"},{"size":207,"mtime":1692901537290,"results":"54","hashOfConfig":"30"},{"size":3317,"mtime":1692896573524,"results":"55","hashOfConfig":"30"},{"size":2907,"mtime":1692896573526,"results":"56","hashOfConfig":"30"},{"size":3249,"mtime":1692896573523,"results":"57","hashOfConfig":"30"},{"filePath":"58","messages":"59","suppressedMessages":"60","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"61"},"1uz336x",{"filePath":"62","messages":"63","suppressedMessages":"64","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"61"},{"filePath":"65","messages":"66","suppressedMessages":"67","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"61"},{"filePath":"68","messages":"69","suppressedMessages":"70","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"61"},{"filePath":"71","messages":"72","suppressedMessages":"73","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"61"},{"filePath":"74","messages":"75","suppressedMessages":"76","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"61"},{"filePath":"77","messages":"78","suppressedMessages":"79","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"61"},{"filePath":"80","messages":"81","suppressedMessages":"82","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"61"},{"filePath":"83","messages":"84","suppressedMessages":"85","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"61"},{"filePath":"86","messages":"87","suppressedMessages":"88","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"61"},{"filePath":"89","messages":"90","suppressedMessages":"91","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"61"},{"filePath":"92","messages":"93","suppressedMessages":"94","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"61"},{"filePath":"95","messages":"96","suppressedMessages":"97","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"61"},{"filePath":"98","messages":"99","suppressedMessages":"100","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"61"},{"filePath":"101","messages":"102","suppressedMessages":"103","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"61"},{"filePath":"104","messages":"105","suppressedMessages":"106","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"61"},{"filePath":"107","messages":"108","suppressedMessages":"109","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"110","messages":"111","suppressedMessages":"112","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"61"},{"filePath":"113","messages":"114","suppressedMessages":"115","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"61"},{"filePath":"116","messages":"117","suppressedMessages":"118","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"61"},{"filePath":"119","messages":"120","suppressedMessages":"121","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"61"},{"filePath":"122","messages":"123","suppressedMessages":"124","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"61"},{"filePath":"125","messages":"126","suppressedMessages":"127","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"61"},{"filePath":"128","messages":"129","suppressedMessages":"130","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"61"},{"filePath":"131","messages":"132","suppressedMessages":"133","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"61"},{"filePath":"134","messages":"135","suppressedMessages":"136","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"61"},{"filePath":"137","messages":"138","suppressedMessages":"139","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"61"},{"filePath":"140","messages":"141","suppressedMessages":"142","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/Users/gaboesquivel/Code/ink-link/frontend/src/main.tsx",[],[],[],"/Users/gaboesquivel/Code/ink-link/frontend/src/contexts/index.ts",[],[],"/Users/gaboesquivel/Code/ink-link/frontend/src/components/Notifications/index.ts",[],[],"/Users/gaboesquivel/Code/ink-link/frontend/src/App.tsx",[],[],"/Users/gaboesquivel/Code/ink-link/frontend/src/contexts/LinkContract.tsx",[],[],"/Users/gaboesquivel/Code/ink-link/frontend/src/contexts/UIContext.tsx",[],[],"/Users/gaboesquivel/Code/ink-link/frontend/src/components/Notifications/Snackbar.tsx",[],[],"/Users/gaboesquivel/Code/ink-link/frontend/src/components/Notifications/Notifications.tsx",[],[],"/Users/gaboesquivel/Code/ink-link/frontend/src/components/index.ts",[],[],"/Users/gaboesquivel/Code/ink-link/frontend/src/hooks/index.ts",[],[],"/Users/gaboesquivel/Code/ink-link/frontend/src/Resolver.tsx",[],["143","144"],"/Users/gaboesquivel/Code/ink-link/frontend/src/const/index.ts",[],[],"/Users/gaboesquivel/Code/ink-link/frontend/src/components/Button.tsx",[],[],"/Users/gaboesquivel/Code/ink-link/frontend/src/components/ConnectWallet.tsx",[],[],"/Users/gaboesquivel/Code/ink-link/frontend/src/components/FormContainer.tsx",[],[],"/Users/gaboesquivel/Code/ink-link/frontend/src/components/DryRunResult.tsx",[],["145"],"/Users/gaboesquivel/Code/ink-link/frontend/src/components/Header.tsx",[],[],"/Users/gaboesquivel/Code/ink-link/frontend/src/components/Loader.tsx",[],[],"/Users/gaboesquivel/Code/ink-link/frontend/src/components/Modal.tsx",[],[],"/Users/gaboesquivel/Code/ink-link/frontend/src/hooks/useLinkContract.ts",[],[],"/Users/gaboesquivel/Code/ink-link/frontend/src/components/NewUserGuide.tsx",[],[],"/Users/gaboesquivel/Code/ink-link/frontend/src/hooks/useSubmitHandler.ts",[],[],"/Users/gaboesquivel/Code/ink-link/frontend/src/hooks/useUI.ts",[],[],"/Users/gaboesquivel/Code/ink-link/frontend/src/components/LinksOverview.tsx",[],[],"/Users/gaboesquivel/Code/ink-link/frontend/src/lib/converter.ts",[],[],"/Users/gaboesquivel/Code/ink-link/frontend/src/components/Form.tsx",[],[],"/Users/gaboesquivel/Code/ink-link/frontend/src/components/SubmitResult.tsx",[],[],"/Users/gaboesquivel/Code/ink-link/frontend/src/components/AccountsDropdown.tsx",[],[],{"ruleId":"146","severity":1,"message":"147","line":44,"column":6,"nodeType":"148","endLine":44,"endColumn":23,"suggestions":"149","suppressions":"150"},{"ruleId":"146","severity":1,"message":"151","line":53,"column":6,"nodeType":"148","endLine":53,"endColumn":8,"suggestions":"152","suppressions":"153"},{"ruleId":"146","severity":1,"message":"154","line":31,"column":6,"nodeType":"148","endLine":31,"endColumn":53,"suggestions":"155","suppressions":"156"},"react-hooks/exhaustive-deps","React Hook useMemo has missing dependencies: 'abi' and 'link.contract'. Either include them or remove the dependency array.","ArrayExpression",["157"],["158"],"React Hook useEffect has missing dependencies: 'resolve' and 'slug'. Either include them or remove the dependency array.",["159"],["160"],"React Hook useEffect has a missing dependency: 'shortenDryRun'. Either include it or remove the dependency array.",["161"],["162"],{"desc":"163","fix":"164"},{"kind":"165","justification":"166"},{"desc":"167","fix":"168"},{"kind":"165","justification":"166"},{"desc":"169","fix":"170"},{"kind":"165","justification":"166"},"Update the dependencies array to be: [abi, link.contract, resolve.result?.ok, resolve.result.value.raw]",{"range":"171","text":"172"},"directive","","Update the dependencies array to be: [resolve, slug]",{"range":"173","text":"174"},"Update the dependencies array to be: [shortenDryRun, shortenDryRun.send, values.alias, values.url]",{"range":"175","text":"176"},[1521,1538],"[abi, link.contract, resolve.result?.ok, resolve.result.value.raw]",[1786,1788],"[resolve, slug]",[921,968],"[shortenDryRun, shortenDryRun.send, values.alias, values.url]"]
gaboesquivel marked this conversation as resolved.
Show resolved Hide resolved
15 changes: 15 additions & 0 deletions frontend/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="theme-color" content="#000000" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Link! Url Shortener</title>
<meta name="description" content=">Link! Url Shortener." />
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
28 changes: 20 additions & 8 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,39 @@
"bn.js": "^5.2.1",
"classnames": "^2.3.2",
"formik": "^2.2.9",
"node-stdlib-browser": "^1.2.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.11.1",
"typescript": "^5.0.4",
"useink": "^1.4.4",
"typescript": "^5.2.2",
"useink": "^1.13.0",
"web-vitals": "^3.3.1",
"ws": "^8.13.0",
"yup": "^1.1.1"
},
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.0",
"@nabla/vite-plugin-eslint": "^1.5.0",
"@types/hoist-non-react-statics": "^3.3.1",
"@types/node": "^20.1.1",
"@types/react": "^18.2.6",
"@types/react-dom": "^18.2.4",
"react-scripts": "5.0.1",
"tailwindcss": "^3.3.2"
"@vitejs/plugin-react": "^4.0.4",
"autoprefixer": "^10.4.15",
"eslint": "^8.47.0",
"eslint-config-react-app": "^7.0.1",
"file-loader": "^6.2.0",
"postcss": "^8.4.28",
"tailwindcss": "^3.3.3",
"vite": "^4.4.9",
"vite-plugin-node-stdlib-browser": "^0.2.1",
"vite-plugin-svgr": "^3.2.0",
"vite-tsconfig-paths": "^4.2.0"
},
"scripts": {
"start": "GENERATE_SOURCEMAP=false react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"start": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
},
"eslintConfig": {
"extends": [
Expand Down
6 changes: 6 additions & 0 deletions frontend/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};
37 changes: 0 additions & 37 deletions frontend/public/index.html

This file was deleted.

3 changes: 0 additions & 3 deletions frontend/public/robots.txt

This file was deleted.

39 changes: 22 additions & 17 deletions frontend/src/Resolver.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import "./App.css";
import { useEffect, useMemo } from "react";
import { useParams } from "react-router-dom";
import { Loader } from "./components";
import { hexToString } from 'useink/utils';
import { useLinkContract } from "./hooks";
import { AbiMessage, ContractExecResult, Registry } from "useink/core";
import { useAbiMessage } from "useink";
import './App.css';
import { useEffect, useMemo } from 'react';
import { useParams } from 'react-router-dom';
import { Loader } from './components';

import { useLinkContract } from './hooks';
import { AbiMessage, ContractExecResult, Registry } from 'useink/core';
import { useAbiMessage } from 'useink';
import { hexToString } from './lib/converter';

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you explain why you changed the hexToString import?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems the new version of useink doesnt export that function

// useink will decode results for ink! v4 +, but this dApp was built with ink! v3 and
// requires this custom decoding function.
Expand All @@ -14,13 +15,13 @@ export function decodeURL(
message: AbiMessage,
registry: Registry,
): string | undefined {
if (result.isErr || !message.returnType) return
if (result.isErr || !message.returnType) return;

const returnTypeName = message.returnType.lookupName || message.returnType.type
const returnTypeName = message.returnType.lookupName || message.returnType.type;
const raw = registry.createTypeUnsafe(returnTypeName, [result.asOk.data]);

const OptionNoneResponse = '0x00';
if (raw.toHuman() === OptionNoneResponse) return
if (raw.toHuman() === OptionNoneResponse) return;

const url = hexToString(raw.toHuman() as any);

Expand All @@ -39,7 +40,7 @@ const Resolver: React.FC = () => {
}

return undefined;
// eslint-disable-next-line react-hooks/exhaustive-deps
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [resolve?.result]);

useEffect(() => {
Expand All @@ -48,16 +49,20 @@ const Resolver: React.FC = () => {

useEffect(() => {
slug && resolve?.send([slug], { defaultCaller: true });
// eslint-disable-next-line react-hooks/exhaustive-deps
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

return (
<div className="App h-screen flex flex-col justify-center">
{resolve?.isSubmitting && <Loader message={resolvedUrl ? `Redirecting to ${resolvedUrl}` : ""} />}
<div className="flex flex-col justify-center h-screen App">
{resolve?.isSubmitting && <Loader message={resolvedUrl ? `Redirecting to ${resolvedUrl}` : ''} />}
{!resolve?.isSubmitting && resolve?.result?.ok && !resolvedUrl && (
<div className="text-center">
<h1 className="text-2xl font-bold text-center">URL not found for <span className="bg-white/5 rounded-md p-2">{slug}</span></h1>
<p className="mt-6">Go back to <a href="/">shortener</a>.</p>
<h1 className="text-2xl font-bold text-center">
URL not found for <span className="p-2 rounded-md bg-white/5">{slug}</span>
gaboesquivel marked this conversation as resolved.
Show resolved Hide resolved
</h1>
<p className="mt-6">
Go back to <a href="/">shortener</a>.
</p>
</div>
)}
</div>
Expand Down
Loading
Loading