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

[vite-example-dapp] Vite version of the dapp example #258

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
9 changes: 9 additions & 0 deletions apps/nextjs-example/components/AppContext.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { AptosConnectWalletPlugin } from '@aptos-connect/wallet-adapter-plugin';
import { BitgetWallet } from "@bitget-wallet/aptos-wallet-adapter";
import { FewchaWallet } from "fewcha-plugin-wallet-adapter";
import { MartianWallet } from "@martianwallet/aptos-wallet-adapter";
Expand All @@ -17,7 +18,15 @@ const WalletContextProvider: FC<{ children: ReactNode }> = ({ children }) => {
const { autoConnect } = useAutoConnect();
const { setErrorAlertMessage } = useAlert();

const clientSidePlugins = typeof global.window !== 'undefined' ? [
new AptosConnectWalletPlugin({
network: Network.DEVNET,
// frontendBaseURL: 'http://localhost:3000'
}),
] : [];

const wallets = [
...clientSidePlugins,
new IdentityConnectWallet("57fa42a9-29c6-4f1e-939c-4eefa36d9ff5", {
networkName: Network.TESTNET,
}),
Expand Down
4 changes: 3 additions & 1 deletion apps/nextjs-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"lint": "next lint"
},
"dependencies": {
"@aptos-labs/ts-sdk": "^1.13.2",
"@aptos-connect/wallet-api": "^0.0.3",
"@aptos-connect/wallet-adapter-plugin": "^0.0.6",
"@aptos-labs/ts-sdk": "^1.18.1",
"@aptos-labs/wallet-adapter-ant-design": "workspace:*",
"@aptos-labs/wallet-adapter-core": "workspace:*",
"@aptos-labs/wallet-adapter-mui-design": "workspace:*",
Expand Down
1 change: 1 addition & 0 deletions apps/vite-example/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_IC_FRONTEND_URL=http://localhost:3000
1 change: 1 addition & 0 deletions apps/vite-example/.env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_IC_FRONTEND_URL=http://localhost:3000
1 change: 1 addition & 0 deletions apps/vite-example/.eslintcache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"/Users/gabriele/workspace/identity-connect/apps/examples/dapp/src/AccountsSection/AccountsListItem.tsx":"1","/Users/gabriele/workspace/identity-connect/apps/examples/dapp/src/AccountsSection/AccountsSection.tsx":"2","/Users/gabriele/workspace/identity-connect/apps/examples/dapp/src/AccountsSection/index.ts":"3","/Users/gabriele/workspace/identity-connect/apps/examples/dapp/src/App.tsx":"4","/Users/gabriele/workspace/identity-connect/apps/examples/dapp/src/AppStateContext.ts":"5","/Users/gabriele/workspace/identity-connect/apps/examples/dapp/src/DappClientContext.ts":"6","/Users/gabriele/workspace/identity-connect/apps/examples/dapp/src/NewRequestSection/NewRequestSection.tsx":"7","/Users/gabriele/workspace/identity-connect/apps/examples/dapp/src/NewRequestSection/index.ts":"8","/Users/gabriele/workspace/identity-connect/apps/examples/dapp/src/main.tsx":"9","/Users/gabriele/workspace/identity-connect/apps/examples/dapp/src/utils/makeContext.tsx":"10","/Users/gabriele/workspace/identity-connect/apps/examples/dapp/src/utils/makeLocalStorageAppStateContext.ts":"11","/Users/gabriele/workspace/identity-connect/apps/examples/dapp/src/utils/useAsyncAction.ts":"12","/Users/gabriele/workspace/identity-connect/apps/examples/dapp/src/vite-env.d.ts":"13"},{"size":2113,"mtime":1697658845520,"results":"14","hashOfConfig":"15"},{"size":1058,"mtime":1697658845520,"results":"16","hashOfConfig":"15"},{"size":148,"mtime":1697658845520,"results":"17","hashOfConfig":"15"},{"size":476,"mtime":1697658845520,"results":"18","hashOfConfig":"15"},{"size":620,"mtime":1697658845520,"results":"19","hashOfConfig":"15"},{"size":1546,"mtime":1697658845520,"results":"20","hashOfConfig":"15"},{"size":7438,"mtime":1697658845521,"results":"21","hashOfConfig":"15"},{"size":154,"mtime":1697658845521,"results":"22","hashOfConfig":"15"},{"size":579,"mtime":1697658845521,"results":"23","hashOfConfig":"15"},{"size":1286,"mtime":1697658845521,"results":"24","hashOfConfig":"15"},{"size":2369,"mtime":1697658845521,"results":"25","hashOfConfig":"15"},{"size":492,"mtime":1697658845521,"results":"26","hashOfConfig":"15"},{"size":303,"mtime":1697658845521,"results":"27","hashOfConfig":"15"},{"filePath":"28","messages":"29","suppressedMessages":"30","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"18orfr",{"filePath":"31","messages":"32","suppressedMessages":"33","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"34","messages":"35","suppressedMessages":"36","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"37","messages":"38","suppressedMessages":"39","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"40","messages":"41","suppressedMessages":"42","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"43","messages":"44","suppressedMessages":"45","errorCount":0,"fatalErrorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"46","messages":"47","suppressedMessages":"48","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"49","messages":"50","suppressedMessages":"51","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"52","messages":"53","suppressedMessages":"54","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"55","messages":"56","suppressedMessages":"57","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"58","messages":"59","suppressedMessages":"60","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"61","messages":"62","suppressedMessages":"63","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"64","messages":"65","suppressedMessages":"66","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/Users/gabriele/workspace/identity-connect/apps/examples/dapp/src/AccountsSection/AccountsListItem.tsx",[],[],"/Users/gabriele/workspace/identity-connect/apps/examples/dapp/src/AccountsSection/AccountsSection.tsx",[],[],"/Users/gabriele/workspace/identity-connect/apps/examples/dapp/src/AccountsSection/index.ts",[],[],"/Users/gabriele/workspace/identity-connect/apps/examples/dapp/src/App.tsx",[],[],"/Users/gabriele/workspace/identity-connect/apps/examples/dapp/src/AppStateContext.ts",[],[],"/Users/gabriele/workspace/identity-connect/apps/examples/dapp/src/DappClientContext.ts",["67"],[],"/Users/gabriele/workspace/identity-connect/apps/examples/dapp/src/NewRequestSection/NewRequestSection.tsx",[],["68","69","70","71","72","73","74","75"],"/Users/gabriele/workspace/identity-connect/apps/examples/dapp/src/NewRequestSection/index.ts",[],[],"/Users/gabriele/workspace/identity-connect/apps/examples/dapp/src/main.tsx",[],[],"/Users/gabriele/workspace/identity-connect/apps/examples/dapp/src/utils/makeContext.tsx",[],["76"],"/Users/gabriele/workspace/identity-connect/apps/examples/dapp/src/utils/makeLocalStorageAppStateContext.ts",[],["77","78"],"/Users/gabriele/workspace/identity-connect/apps/examples/dapp/src/utils/useAsyncAction.ts",[],[],"/Users/gabriele/workspace/identity-connect/apps/examples/dapp/src/vite-env.d.ts",[],[],{"ruleId":"79","severity":1,"message":"80","line":43,"column":6,"nodeType":"81","endLine":43,"endColumn":33,"suggestions":"82"},{"ruleId":"83","severity":1,"message":"84","line":60,"column":5,"nodeType":"85","messageId":"86","endLine":60,"endColumn":16,"suppressions":"87"},{"ruleId":"83","severity":1,"message":"84","line":69,"column":5,"nodeType":"85","messageId":"86","endLine":69,"endColumn":16,"suppressions":"88"},{"ruleId":"83","severity":1,"message":"84","line":78,"column":5,"nodeType":"85","messageId":"86","endLine":78,"endColumn":16,"suppressions":"89"},{"ruleId":"83","severity":1,"message":"84","line":105,"column":5,"nodeType":"85","messageId":"86","endLine":105,"endColumn":16,"suppressions":"90"},{"ruleId":"83","severity":1,"message":"84","line":114,"column":5,"nodeType":"85","messageId":"86","endLine":114,"endColumn":16,"suppressions":"91"},{"ruleId":"83","severity":1,"message":"84","line":123,"column":5,"nodeType":"85","messageId":"86","endLine":123,"endColumn":16,"suppressions":"92"},{"ruleId":"83","severity":1,"message":"84","line":132,"column":5,"nodeType":"85","messageId":"86","endLine":132,"endColumn":16,"suppressions":"93"},{"ruleId":"83","severity":1,"message":"84","line":148,"column":5,"nodeType":"85","messageId":"86","endLine":148,"endColumn":16,"suppressions":"94"},{"ruleId":"95","severity":2,"message":"96","line":31,"column":27,"nodeType":"97","messageId":"98","endLine":34,"endColumn":4,"fix":"99","suppressions":"100"},{"ruleId":"101","severity":2,"message":"102","line":42,"column":33,"nodeType":"103","endLine":42,"endColumn":41,"suppressions":"104"},{"ruleId":"101","severity":2,"message":"105","line":44,"column":7,"nodeType":"103","endLine":44,"endColumn":16,"suppressions":"106"},"react-hooks/exhaustive-deps","React Hook useMemo has an unnecessary dependency: 'selectedNetwork'. Either exclude it or remove the dependency array.","ArrayExpression",["107"],"no-console","Unexpected console statement.","MemberExpression","unexpected",["108"],["109"],["110"],["111"],["112"],["113"],["114"],["115"],"react/function-component-definition","Function component is not a function declaration","ArrowFunctionExpression","function-declaration",{"range":"116","text":"117"},["118"],"react-hooks/rules-of-hooks","React Hook \"useState\" is called in function \"watch\" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter. React Hook names must start with the word \"use\".","Identifier",["119"],"React Hook \"useEffect\" is called in function \"watch\" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter. React Hook names must start with the word \"use\".",["120"],{"desc":"121","fix":"122"},{"kind":"123","justification":"124"},{"kind":"123","justification":"124"},{"kind":"123","justification":"124"},{"kind":"123","justification":"124"},{"kind":"123","justification":"124"},{"kind":"123","justification":"124"},{"kind":"123","justification":"124"},{"kind":"123","justification":"124"},[981,1190],"function ContextProvider({ children, ...props }: PropsWithChildren<TProps>) {\n const value = valueProvider(props as TProps);\n return <Context.Provider value={value}>{children}</Context.Provider>;\n }",{"kind":"123","justification":"124"},{"kind":"123","justification":"124"},{"kind":"123","justification":"124"},"Update the dependencies array to be: [appState]",{"range":"125","text":"126"},"directive","",[1511,1538],"[appState]"]
20 changes: 20 additions & 0 deletions apps/vite-example/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright © Aptos
// SPDX-License-Identifier: Apache-2.0

const devTools = ['./vite.config.ts'];

module.exports = {
env: { browser: true, es2020: true },
extends: ["@aptos-labs/eslint-config-adapter"],
parserOptions: {
project: ['tsconfig.json', 'tsconfig.node.json'],
},
plugins: ['react-refresh'],
root: true,
rules: {
'import/extensions': 'off',
'import/no-extraneous-dependencies': ['error', { devDependencies: devTools }],
'react-refresh/only-export-components': 'warn',
'react/react-in-jsx-scope': 'off',
},
};
24 changes: 24 additions & 0 deletions apps/vite-example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
13 changes: 13 additions & 0 deletions apps/vite-example/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" type="image/png" href="/favicon.ico">
<title>Example Dapp</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
60 changes: 60 additions & 0 deletions apps/vite-example/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"name": "@aptos-labs/wallet-adapter-vite-example",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"lint": "prettier --check src",
"lint:fix": "prettier --write src && eslint --cache ./src --fix",
"preview": "vite preview"
},
"dependencies": {
"@aptos-connect/wallet-api": "^0.0.3",
"@aptos-labs/ts-sdk": "^1.18.1",
"@aptos-labs/wallet-adapter-ant-design": "workspace:*",
"@aptos-labs/wallet-adapter-core": "workspace:*",
"@aptos-labs/wallet-adapter-mui-design": "workspace:*",
"@aptos-labs/wallet-adapter-react": "workspace:*",
"@aptos-labs/wallet-standard": "^0.0.11",
"@aptos-connect/wallet-adapter-plugin": "^0.0.6",
"@bitget-wallet/aptos-wallet-adapter": "^0.1.0",
"@blocto/aptos-wallet-adapter-plugin": "^0.2.2",
"@flipperplatform/wallet-adapter-plugin": "^0.1.0",
"@haechi-labs/face-aptos-adapter-plugin": "^0.0.4",
"@haechi-labs/face-sdk": "^1.10.8",
"@haechi-labs/face-types": "^1.10.8",
"@identity-connect/wallet-adapter-plugin": "^1.2.5",
"@martianwallet/aptos-wallet-adapter": "^0.0.5",
"@msafe/aptos-wallet-adapter": "^1.0.11",
"@okwallet/aptos-wallet-adapter": "^0.0.3",
"@onekeyfe/aptos-wallet-adapter": "^0.1.2",
"@openblockhq/aptos-wallet-adapter": "^0.1.5",
"@pontem/wallet-adapter-plugin": "^0.2.1",
"@rise-wallet/wallet-adapter": "^0.1.2",
"@tp-lab/aptos-wallet-adapter": "^1.0.1",
"@trustwallet/aptos-wallet-adapter": "^0.1.6",
"@welldone-studio/aptos-wallet-adapter": "^0.1.4",
"antd": "^5.1.2",
"ethers": "^5.7.2",
"fewcha-plugin-wallet-adapter": "^0.1.3",
"petra-plugin-wallet-adapter": "^0.4.5",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"@babel/core": "^7.0.0",
"@types/node": "^17.0.12",
"@types/react": "18.0.28",
"@types/react-dom": "^18.0.11",
"@vitejs/plugin-react-swc": "^3.0.0",
"autoprefixer": "^10.4.13",
"eslint": "8.57.0",
"eslint-plugin-react-refresh": "^0.3.4",
"postcss": "^8.4.19",
"tailwindcss": "^3.2.4",
"typescript": "5.0.4",
"vite": "^4.3.9"
}
}
6 changes: 6 additions & 0 deletions apps/vite-example/postcss.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
Binary file added apps/vite-example/public/favicon.ico
Binary file not shown.
1 change: 1 addition & 0 deletions apps/vite-example/public/identity-connect.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
identity-connect-57fa42a9-29c6-4f1e-939c-4eefa36d9ff5
Loading
Loading