create-near-app 8.4.0 → 8.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/templates/frontend/next-app/next-env.d.ts +6 -0
- package/templates/frontend/next-app/package.json +28 -16
- package/templates/frontend/{vite-react/src/pages/hello_near.jsx → next-app/src/app/hello-near/page.tsx} +17 -13
- package/templates/frontend/next-app/src/app/layout.tsx +80 -0
- package/templates/frontend/next-app/src/components/{cards.js → cards.tsx} +4 -9
- package/templates/frontend/next-app/src/components/{navigation.js → navigation.tsx} +17 -7
- package/templates/frontend/{next-page/src/wallets/web3modal.js → next-app/src/wallets/web3modal.ts} +0 -1
- package/templates/frontend/next-app/tsconfig.json +42 -0
- package/templates/frontend/next-page/next-env.d.ts +6 -0
- package/templates/frontend/next-page/package.json +23 -16
- package/templates/frontend/next-page/src/components/{navigation.js → navigation.tsx} +18 -8
- package/templates/frontend/next-page/src/pages/_app.tsx +68 -0
- package/templates/frontend/next-page/src/pages/hello-near/{index.js → index.tsx} +22 -21
- package/templates/frontend/next-page/src/pages/{index.js → index.tsx} +8 -8
- package/templates/frontend/{vite-react/src/wallets/web3modal.js → next-page/src/wallets/web3modal.ts} +0 -1
- package/templates/frontend/next-page/tsconfig.json +35 -0
- package/templates/frontend/vite-react/eslint.config.js +4 -1
- package/templates/frontend/vite-react/package.json +22 -17
- package/templates/frontend/vite-react/src/App.tsx +81 -0
- package/templates/frontend/vite-react/src/components/{cards.jsx → cards.tsx} +4 -4
- package/templates/frontend/vite-react/src/components/{navigation.jsx → navigation.tsx} +19 -7
- package/templates/frontend/vite-react/src/{config.js → config.ts} +1 -1
- package/templates/frontend/vite-react/src/main.tsx +14 -0
- package/templates/frontend/vite-react/src/pages/hello_near.tsx +95 -0
- package/templates/frontend/{next-app/src/wallets/web3modal.js → vite-react/src/wallets/web3modal.ts} +0 -1
- package/templates/frontend/vite-react/tsconfig.json +35 -0
- package/templates/frontend/next-app/jsconfig.json +0 -7
- package/templates/frontend/next-app/src/app/hello-near/page.js +0 -67
- package/templates/frontend/next-app/src/app/layout.js +0 -54
- package/templates/frontend/next-page/jsconfig.json +0 -7
- package/templates/frontend/next-page/src/pages/_app.js +0 -45
- package/templates/frontend/vite-react/src/App.jsx +0 -56
- package/templates/frontend/vite-react/src/main.jsx +0 -11
- /package/templates/frontend/next-app/src/app/{page.js → page.tsx} +0 -0
- /package/templates/frontend/next-app/src/{config.js → config.ts} +0 -0
- /package/templates/frontend/next-page/src/components/{cards.js → cards.tsx} +0 -0
- /package/templates/frontend/next-page/src/{config.js → config.ts} +0 -0
- /package/templates/frontend/vite-react/src/pages/{home.jsx → home.tsx} +0 -0
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { WagmiAdapter } from "@reown/appkit-adapter-wagmi";
|
|
2
2
|
import { createAppKit } from "@reown/appkit/react";
|
|
3
3
|
import { nearTestnet } from "@reown/appkit/networks";
|
|
4
|
-
import { reconnect } from "@wagmi/core";
|
|
5
4
|
|
|
6
5
|
// Get a project ID at https://cloud.reown.com
|
|
7
6
|
const projectId = "30147604c5f01d0bc4482ab0665b5697";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"baseUrl": ".",
|
|
4
|
+
"paths": {
|
|
5
|
+
"@/*": [
|
|
6
|
+
"./src/*"
|
|
7
|
+
]
|
|
8
|
+
},
|
|
9
|
+
"jsx": "preserve",
|
|
10
|
+
"strict": true,
|
|
11
|
+
"moduleResolution": "node",
|
|
12
|
+
"skipLibCheck": true,
|
|
13
|
+
"target": "ES2017",
|
|
14
|
+
"lib": [
|
|
15
|
+
"dom",
|
|
16
|
+
"dom.iterable",
|
|
17
|
+
"esnext"
|
|
18
|
+
],
|
|
19
|
+
"allowJs": true,
|
|
20
|
+
"noEmit": true,
|
|
21
|
+
"incremental": true,
|
|
22
|
+
"module": "esnext",
|
|
23
|
+
"esModuleInterop": true,
|
|
24
|
+
"resolveJsonModule": true,
|
|
25
|
+
"isolatedModules": true
|
|
26
|
+
},
|
|
27
|
+
"include": [
|
|
28
|
+
"**/*.ts",
|
|
29
|
+
"**/*.tsx",
|
|
30
|
+
"global.d.ts"
|
|
31
|
+
],
|
|
32
|
+
"exclude": [
|
|
33
|
+
"node_modules"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
@@ -7,10 +7,11 @@ import reactRefresh from 'eslint-plugin-react-refresh'
|
|
|
7
7
|
export default [
|
|
8
8
|
{ ignores: ['dist'] },
|
|
9
9
|
{
|
|
10
|
-
files: ['**/*.{js,jsx}'],
|
|
10
|
+
files: ['**/*.{js,jsx,ts,tsx}'],
|
|
11
11
|
languageOptions: {
|
|
12
12
|
ecmaVersion: 2020,
|
|
13
13
|
globals: globals.browser,
|
|
14
|
+
parser: tseslint.parser,
|
|
14
15
|
parserOptions: {
|
|
15
16
|
ecmaVersion: 'latest',
|
|
16
17
|
ecmaFeatures: { jsx: true },
|
|
@@ -22,12 +23,14 @@ export default [
|
|
|
22
23
|
react,
|
|
23
24
|
'react-hooks': reactHooks,
|
|
24
25
|
'react-refresh': reactRefresh,
|
|
26
|
+
'@typescript-eslint': tseslint.plugin,
|
|
25
27
|
},
|
|
26
28
|
rules: {
|
|
27
29
|
...js.configs.recommended.rules,
|
|
28
30
|
...react.configs.recommended.rules,
|
|
29
31
|
...react.configs['jsx-runtime'].rules,
|
|
30
32
|
...reactHooks.configs.recommended.rules,
|
|
33
|
+
...tseslint.configs.recommended.rules,
|
|
31
34
|
'react/jsx-no-target-blank': 'off',
|
|
32
35
|
'react-refresh/only-export-components': [
|
|
33
36
|
'warn',
|
|
@@ -9,22 +9,26 @@
|
|
|
9
9
|
"preview": "vite preview"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@near-wallet-selector/
|
|
13
|
-
"@near-wallet-selector/
|
|
14
|
-
"@near-wallet-selector/
|
|
15
|
-
"@near-wallet-selector/
|
|
16
|
-
"@near-wallet-selector/hot-wallet": "
|
|
17
|
-
"@near-wallet-selector/
|
|
18
|
-
"@near-wallet-selector/
|
|
19
|
-
"@near-wallet-selector/
|
|
20
|
-
"@near-wallet-selector/
|
|
21
|
-
"@near-wallet-selector/
|
|
22
|
-
"@near-wallet-selector/
|
|
23
|
-
"@near-wallet-selector/
|
|
24
|
-
"@near-wallet-selector/
|
|
25
|
-
"@near-wallet-selector/
|
|
26
|
-
"@
|
|
27
|
-
"@
|
|
12
|
+
"@near-wallet-selector/bitget-wallet": "9.5.4",
|
|
13
|
+
"@near-wallet-selector/coin98-wallet": "9.5.4",
|
|
14
|
+
"@near-wallet-selector/core": "9.5.4",
|
|
15
|
+
"@near-wallet-selector/ethereum-wallets": "9.5.4",
|
|
16
|
+
"@near-wallet-selector/hot-wallet": "9.5.4",
|
|
17
|
+
"@near-wallet-selector/intear-wallet": "9.5.4",
|
|
18
|
+
"@near-wallet-selector/ledger": "9.5.4",
|
|
19
|
+
"@near-wallet-selector/math-wallet": "9.5.4",
|
|
20
|
+
"@near-wallet-selector/meteor-wallet": "9.5.4",
|
|
21
|
+
"@near-wallet-selector/meteor-wallet-app": "9.5.4",
|
|
22
|
+
"@near-wallet-selector/modal-ui": "9.5.4",
|
|
23
|
+
"@near-wallet-selector/near-mobile-wallet": "9.5.4",
|
|
24
|
+
"@near-wallet-selector/okx-wallet": "9.5.4",
|
|
25
|
+
"@near-wallet-selector/ramper-wallet": "9.5.4",
|
|
26
|
+
"@near-wallet-selector/react-hook": "9.5.4",
|
|
27
|
+
"@near-wallet-selector/sender": "9.5.4",
|
|
28
|
+
"@near-wallet-selector/unity-wallet": "9.5.4",
|
|
29
|
+
"@near-wallet-selector/welldone-wallet": "9.5.4",
|
|
30
|
+
"@reown/appkit": "^1.7.7",
|
|
31
|
+
"@reown/appkit-adapter-wagmi": "^1.7.7",
|
|
28
32
|
"@wagmi/core": "^2.17.1",
|
|
29
33
|
"bootstrap": "^5",
|
|
30
34
|
"bootstrap-icons": "^1.11.3",
|
|
@@ -44,7 +48,8 @@
|
|
|
44
48
|
"eslint-plugin-react-hooks": "^5.0.0",
|
|
45
49
|
"eslint-plugin-react-refresh": "^0.4.16",
|
|
46
50
|
"globals": "^15.14.0",
|
|
51
|
+
"typescript": "^5.9.3",
|
|
47
52
|
"vite": "^6.3.5",
|
|
48
|
-
"vite-plugin-node-polyfills": "
|
|
53
|
+
"vite-plugin-node-polyfills": "0.23.0"
|
|
49
54
|
}
|
|
50
55
|
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { BrowserRouter, Routes, Route } from "react-router";
|
|
2
|
+
|
|
3
|
+
import { Navigation } from "@/components/navigation";
|
|
4
|
+
import Home from "@/pages/home";
|
|
5
|
+
import HelloNear from "@/pages/hello_near";
|
|
6
|
+
import { HelloNearContract, NetworkId } from "@/config";
|
|
7
|
+
|
|
8
|
+
import "@near-wallet-selector/modal-ui/styles.css";
|
|
9
|
+
|
|
10
|
+
// Wallet setups
|
|
11
|
+
import { setupMeteorWallet } from "@near-wallet-selector/meteor-wallet";
|
|
12
|
+
import { setupMeteorWalletApp } from "@near-wallet-selector/meteor-wallet-app";
|
|
13
|
+
import { setupEthereumWallets } from "@near-wallet-selector/ethereum-wallets";
|
|
14
|
+
import { setupHotWallet } from "@near-wallet-selector/hot-wallet";
|
|
15
|
+
import { setupLedger } from "@near-wallet-selector/ledger";
|
|
16
|
+
import { setupSender } from "@near-wallet-selector/sender";
|
|
17
|
+
import { setupNearMobileWallet } from "@near-wallet-selector/near-mobile-wallet";
|
|
18
|
+
import { setupWelldoneWallet } from "@near-wallet-selector/welldone-wallet";
|
|
19
|
+
import { setupMathWallet } from "@near-wallet-selector/math-wallet";
|
|
20
|
+
import { setupBitgetWallet } from "@near-wallet-selector/bitget-wallet";
|
|
21
|
+
import { setupRamperWallet } from "@near-wallet-selector/ramper-wallet";
|
|
22
|
+
import { setupUnityWallet } from "@near-wallet-selector/unity-wallet";
|
|
23
|
+
import { setupOKXWallet } from "@near-wallet-selector/okx-wallet";
|
|
24
|
+
import { setupCoin98Wallet } from "@near-wallet-selector/coin98-wallet";
|
|
25
|
+
import { setupIntearWallet } from "@near-wallet-selector/intear-wallet";
|
|
26
|
+
|
|
27
|
+
import { WalletSelectorProvider } from '@near-wallet-selector/react-hook';
|
|
28
|
+
|
|
29
|
+
// Ethereum adapters
|
|
30
|
+
import { wagmiAdapter, web3Modal } from "@/wallets/web3modal";
|
|
31
|
+
|
|
32
|
+
// Types
|
|
33
|
+
import type { WalletModuleFactory } from "@near-wallet-selector/core";
|
|
34
|
+
|
|
35
|
+
const walletSelectorConfig = {
|
|
36
|
+
network: NetworkId,
|
|
37
|
+
modules: [
|
|
38
|
+
setupEthereumWallets({
|
|
39
|
+
wagmiConfig: wagmiAdapter.wagmiConfig,
|
|
40
|
+
web3Modal,
|
|
41
|
+
}),
|
|
42
|
+
setupMeteorWallet(),
|
|
43
|
+
setupMeteorWalletApp({ contractId: HelloNearContract }),
|
|
44
|
+
setupHotWallet(),
|
|
45
|
+
setupLedger(),
|
|
46
|
+
setupSender(),
|
|
47
|
+
setupNearMobileWallet(),
|
|
48
|
+
setupWelldoneWallet(),
|
|
49
|
+
setupMathWallet(),
|
|
50
|
+
setupBitgetWallet(),
|
|
51
|
+
setupRamperWallet(),
|
|
52
|
+
setupUnityWallet({
|
|
53
|
+
projectId: "your-project-id",
|
|
54
|
+
metadata: {
|
|
55
|
+
name: "Hello NEAR",
|
|
56
|
+
description: "Hello NEAR Example",
|
|
57
|
+
url: "https://near.org",
|
|
58
|
+
icons: ["https://near.org/favicon.ico"],
|
|
59
|
+
}
|
|
60
|
+
}),
|
|
61
|
+
setupOKXWallet(),
|
|
62
|
+
setupCoin98Wallet(),
|
|
63
|
+
setupIntearWallet(),
|
|
64
|
+
] as WalletModuleFactory[]
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
function App () {
|
|
68
|
+
return (
|
|
69
|
+
<WalletSelectorProvider config={walletSelectorConfig}>
|
|
70
|
+
<BrowserRouter>
|
|
71
|
+
<Navigation />
|
|
72
|
+
<Routes>
|
|
73
|
+
<Route path="/" element={<Home />} />
|
|
74
|
+
<Route path="/hello-near" element={<HelloNear />} />
|
|
75
|
+
</Routes>
|
|
76
|
+
</BrowserRouter>
|
|
77
|
+
</WalletSelectorProvider>
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export default App;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import styles from '@/styles/app.module.css'
|
|
2
|
-
import { Link } from 'react-router'
|
|
1
|
+
import styles from '@/styles/app.module.css'
|
|
2
|
+
import { Link } from 'react-router'
|
|
3
3
|
|
|
4
4
|
export const Cards = () => {
|
|
5
5
|
return (
|
|
@@ -23,5 +23,5 @@ export const Cards = () => {
|
|
|
23
23
|
<p>Discover how simple it is to interact with a Near smart contract.</p>
|
|
24
24
|
</Link>
|
|
25
25
|
</div>
|
|
26
|
-
)
|
|
27
|
-
}
|
|
26
|
+
)
|
|
27
|
+
}
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
|
-
|
|
2
|
+
import { Link } from 'react-router'
|
|
3
3
|
import NearLogo from '@/assets/near-logo.svg';
|
|
4
|
-
import { Link } from "react-router";
|
|
5
4
|
import styles from '@/styles/app.module.css';
|
|
6
5
|
import { useWalletSelector } from '@near-wallet-selector/react-hook';
|
|
7
6
|
|
|
7
|
+
interface WalletSelectorHook {
|
|
8
|
+
signedAccountId: string | null;
|
|
9
|
+
signIn: () => void;
|
|
10
|
+
signOut: () => void;
|
|
11
|
+
}
|
|
12
|
+
|
|
8
13
|
export const Navigation = () => {
|
|
9
|
-
const { signedAccountId, signIn, signOut } = useWalletSelector();
|
|
10
|
-
|
|
11
|
-
const [
|
|
14
|
+
const { signedAccountId, signIn, signOut } = useWalletSelector() as WalletSelectorHook;
|
|
15
|
+
|
|
16
|
+
const [action, setAction] = useState<() => void>(() => () => {});
|
|
17
|
+
const [label, setLabel] = useState<string>('Loading...');
|
|
12
18
|
|
|
13
19
|
useEffect(() => {
|
|
14
20
|
if (signedAccountId) {
|
|
@@ -16,7 +22,7 @@ export const Navigation = () => {
|
|
|
16
22
|
setLabel(`Logout ${signedAccountId}`);
|
|
17
23
|
} else {
|
|
18
24
|
setAction(() => signIn);
|
|
19
|
-
setLabel(
|
|
25
|
+
setLabel('Login');
|
|
20
26
|
}
|
|
21
27
|
}, [signedAccountId, signIn, signOut]);
|
|
22
28
|
|
|
@@ -24,7 +30,13 @@ export const Navigation = () => {
|
|
|
24
30
|
<nav className="navbar navbar-expand-lg">
|
|
25
31
|
<div className="container-fluid">
|
|
26
32
|
<Link to="/">
|
|
27
|
-
<img
|
|
33
|
+
<img
|
|
34
|
+
src={NearLogo}
|
|
35
|
+
alt="NEAR"
|
|
36
|
+
width={30}
|
|
37
|
+
height={24}
|
|
38
|
+
className={styles.logo}
|
|
39
|
+
/>
|
|
28
40
|
</Link>
|
|
29
41
|
<div className="navbar-nav pt-1">
|
|
30
42
|
<button className="btn btn-secondary" onClick={action}>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { StrictMode } from 'react';
|
|
2
|
+
import { createRoot } from 'react-dom/client';
|
|
3
|
+
import '@/styles/globals.css';
|
|
4
|
+
import App from '@/App';
|
|
5
|
+
|
|
6
|
+
const rootElement = document.getElementById('root');
|
|
7
|
+
|
|
8
|
+
if (rootElement) {
|
|
9
|
+
createRoot(rootElement).render(
|
|
10
|
+
<StrictMode>
|
|
11
|
+
<App />
|
|
12
|
+
</StrictMode>
|
|
13
|
+
);
|
|
14
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { useEffect, useState, ChangeEvent } from 'react';
|
|
2
|
+
import { Cards } from '@/components/cards';
|
|
3
|
+
import styles from '@/styles/app.module.css';
|
|
4
|
+
|
|
5
|
+
import { HelloNearContract } from '@/config';
|
|
6
|
+
import { useWalletSelector } from '@near-wallet-selector/react-hook';
|
|
7
|
+
|
|
8
|
+
interface WalletSelectorHook {
|
|
9
|
+
signedAccountId: string | null;
|
|
10
|
+
viewFunction: (params: { contractId: string; method: string; args?: Record<string, unknown> }) => Promise<any>;
|
|
11
|
+
callFunction: (params: { contractId: string; method: string; args?: Record<string, unknown> }) => Promise<any>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Contract constant
|
|
15
|
+
const CONTRACT = HelloNearContract as string;
|
|
16
|
+
|
|
17
|
+
export default function HelloNear() {
|
|
18
|
+
const { signedAccountId, viewFunction, callFunction } = useWalletSelector() as WalletSelectorHook;
|
|
19
|
+
|
|
20
|
+
const [greeting, setGreeting] = useState<string>('loading...');
|
|
21
|
+
const [newGreeting, setNewGreeting] = useState<string>('loading...');
|
|
22
|
+
const [loggedIn, setLoggedIn] = useState<boolean>(false);
|
|
23
|
+
const [showSpinner, setShowSpinner] = useState<boolean>(false);
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
viewFunction({ contractId: CONTRACT, method: 'get_greeting' })
|
|
27
|
+
.then((greeting) => setGreeting(greeting))
|
|
28
|
+
.catch(console.error);
|
|
29
|
+
}, [viewFunction]);
|
|
30
|
+
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
setLoggedIn(!!signedAccountId);
|
|
33
|
+
}, [signedAccountId]);
|
|
34
|
+
|
|
35
|
+
const saveGreeting = async () => {
|
|
36
|
+
try {
|
|
37
|
+
await callFunction({
|
|
38
|
+
contractId: CONTRACT,
|
|
39
|
+
method: 'set_greeting',
|
|
40
|
+
args: { greeting: newGreeting },
|
|
41
|
+
});
|
|
42
|
+
} catch (error) {
|
|
43
|
+
console.error(error);
|
|
44
|
+
const greeting = await viewFunction({ contractId: CONTRACT, method: 'get_greeting' });
|
|
45
|
+
setGreeting(greeting);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
setShowSpinner(true);
|
|
49
|
+
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
50
|
+
setGreeting(newGreeting);
|
|
51
|
+
setShowSpinner(false);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
|
|
55
|
+
setNewGreeting(e.target.value);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<main className={styles.main}>
|
|
60
|
+
<div className={styles.description}>
|
|
61
|
+
<p>
|
|
62
|
+
Interacting with the contract:
|
|
63
|
+
<code className={styles.code}>{CONTRACT}</code>
|
|
64
|
+
</p>
|
|
65
|
+
</div>
|
|
66
|
+
<div className={styles.center}>
|
|
67
|
+
<h1 className="w-100">
|
|
68
|
+
The contract says: <code>{greeting}</code>
|
|
69
|
+
</h1>
|
|
70
|
+
|
|
71
|
+
{loggedIn ? (
|
|
72
|
+
<div className="input-group">
|
|
73
|
+
<input
|
|
74
|
+
type="text"
|
|
75
|
+
className="form-control w-20"
|
|
76
|
+
placeholder="Store a new greeting"
|
|
77
|
+
onChange={handleChange}
|
|
78
|
+
/>
|
|
79
|
+
<div className="input-group-append">
|
|
80
|
+
<button className="btn btn-secondary" onClick={saveGreeting}>
|
|
81
|
+
<span hidden={showSpinner}>Save</span>
|
|
82
|
+
<i className="spinner-border spinner-border-sm" hidden={!showSpinner}></i>
|
|
83
|
+
</button>
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
) : (
|
|
87
|
+
<div className="w-100 text-end align-text-center">
|
|
88
|
+
<p className="m-0">Please login to change the greeting</p>
|
|
89
|
+
</div>
|
|
90
|
+
)}
|
|
91
|
+
</div>
|
|
92
|
+
<Cards />
|
|
93
|
+
</main>
|
|
94
|
+
);
|
|
95
|
+
}
|
package/templates/frontend/{next-app/src/wallets/web3modal.js → vite-react/src/wallets/web3modal.ts}
RENAMED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { WagmiAdapter } from "@reown/appkit-adapter-wagmi";
|
|
2
2
|
import { createAppKit } from "@reown/appkit/react";
|
|
3
3
|
import { nearTestnet } from "@reown/appkit/networks";
|
|
4
|
-
import { reconnect } from "@wagmi/core";
|
|
5
4
|
|
|
6
5
|
// Get a project ID at https://cloud.reown.com
|
|
7
6
|
const projectId = "30147604c5f01d0bc4482ab0665b5697";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"baseUrl": ".",
|
|
4
|
+
"paths": {
|
|
5
|
+
"@/*": [
|
|
6
|
+
"./src/*"
|
|
7
|
+
]
|
|
8
|
+
},
|
|
9
|
+
"jsx": "preserve",
|
|
10
|
+
"strict": true,
|
|
11
|
+
"moduleResolution": "node",
|
|
12
|
+
"skipLibCheck": true,
|
|
13
|
+
"target": "ES2017",
|
|
14
|
+
"lib": [
|
|
15
|
+
"dom",
|
|
16
|
+
"dom.iterable",
|
|
17
|
+
"esnext"
|
|
18
|
+
],
|
|
19
|
+
"allowJs": true,
|
|
20
|
+
"noEmit": true,
|
|
21
|
+
"incremental": true,
|
|
22
|
+
"module": "esnext",
|
|
23
|
+
"esModuleInterop": true,
|
|
24
|
+
"resolveJsonModule": true,
|
|
25
|
+
"isolatedModules": true
|
|
26
|
+
},
|
|
27
|
+
"include": [
|
|
28
|
+
"**/*.ts",
|
|
29
|
+
"**/*.tsx",
|
|
30
|
+
"global.d.ts"
|
|
31
|
+
],
|
|
32
|
+
"exclude": [
|
|
33
|
+
"node_modules"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { useState, useEffect } from 'react';
|
|
3
|
-
|
|
4
|
-
import styles from '@/app/app.module.css';
|
|
5
|
-
import { Cards } from '@/components/cards';
|
|
6
|
-
|
|
7
|
-
import { HelloNearContract } from '@/config';
|
|
8
|
-
import { useWalletSelector } from '@near-wallet-selector/react-hook';
|
|
9
|
-
|
|
10
|
-
// Contract that the app will interact with
|
|
11
|
-
const CONTRACT = HelloNearContract;
|
|
12
|
-
|
|
13
|
-
export default function HelloNear() {
|
|
14
|
-
const { signedAccountId, viewFunction, callFunction } = useWalletSelector();
|
|
15
|
-
|
|
16
|
-
const [greeting, setGreeting] = useState('loading...');
|
|
17
|
-
const [newGreeting, setNewGreeting] = useState('loading...');
|
|
18
|
-
const [loggedIn, setLoggedIn] = useState(false);
|
|
19
|
-
const [showSpinner, setShowSpinner] = useState(false);
|
|
20
|
-
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
viewFunction({ contractId: CONTRACT, method: 'get_greeting' })
|
|
23
|
-
.then(greeting => setGreeting(greeting));
|
|
24
|
-
}, [viewFunction]);
|
|
25
|
-
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
setLoggedIn(!!signedAccountId);
|
|
28
|
-
}, [signedAccountId]);
|
|
29
|
-
|
|
30
|
-
const storeGreeting = async () => {
|
|
31
|
-
setShowSpinner(true);
|
|
32
|
-
await callFunction({ contractId: CONTRACT, method: 'set_greeting', args: { greeting: newGreeting } });
|
|
33
|
-
const greeting = await viewFunction({ contractId: CONTRACT, method: 'get_greeting' });
|
|
34
|
-
setGreeting(greeting);
|
|
35
|
-
setShowSpinner(false);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
<main className={styles.main}>
|
|
40
|
-
<div className={styles.description}>
|
|
41
|
-
<p>
|
|
42
|
-
Interacting with the contract:
|
|
43
|
-
<code className={styles.code}>{CONTRACT}</code>
|
|
44
|
-
</p>
|
|
45
|
-
</div>
|
|
46
|
-
|
|
47
|
-
<div className={styles.center}>
|
|
48
|
-
<h1 className="w-100"> The contract says: <code>{greeting}</code> </h1>
|
|
49
|
-
<div className="input-group" hidden={!loggedIn}>
|
|
50
|
-
<input type="text" className="form-control w-20" placeholder="Store a new greeting" onChange={t => setNewGreeting(t.target.value)} />
|
|
51
|
-
<div className="input-group-append">
|
|
52
|
-
<button className="btn btn-secondary" onClick={storeGreeting}>
|
|
53
|
-
<span hidden={showSpinner}> Save </span>
|
|
54
|
-
<i className="spinner-border spinner-border-sm" hidden={!showSpinner}></i>
|
|
55
|
-
</button>
|
|
56
|
-
</div>
|
|
57
|
-
</div>
|
|
58
|
-
<div className='w-100 text-end align-text-center' hidden={loggedIn}>
|
|
59
|
-
<p className='m-0'> Please login to change the greeting </p>
|
|
60
|
-
</div>
|
|
61
|
-
</div>
|
|
62
|
-
<div className={styles.grid}>
|
|
63
|
-
<Cards />
|
|
64
|
-
</div>
|
|
65
|
-
</main>
|
|
66
|
-
);
|
|
67
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { useEffect, useState } from 'react';
|
|
4
|
-
|
|
5
|
-
import '@/app/globals.css';
|
|
6
|
-
import { Navigation } from '@/components/navigation';
|
|
7
|
-
import '@near-wallet-selector/modal-ui/styles.css';
|
|
8
|
-
import { setupMyNearWallet } from '@near-wallet-selector/my-near-wallet';
|
|
9
|
-
import { setupMeteorWallet } from '@near-wallet-selector/meteor-wallet';
|
|
10
|
-
import { setupMeteorWalletApp } from '@near-wallet-selector/meteor-wallet-app';
|
|
11
|
-
import { setupBitteWallet } from '@near-wallet-selector/bitte-wallet';
|
|
12
|
-
import { setupEthereumWallets } from '@near-wallet-selector/ethereum-wallets';
|
|
13
|
-
import { setupHotWallet } from '@near-wallet-selector/hot-wallet';
|
|
14
|
-
import { setupLedger } from '@near-wallet-selector/ledger';
|
|
15
|
-
import { setupSender } from '@near-wallet-selector/sender';
|
|
16
|
-
import { setupHereWallet } from '@near-wallet-selector/here-wallet';
|
|
17
|
-
import { setupNearMobileWallet } from '@near-wallet-selector/near-mobile-wallet';
|
|
18
|
-
import { setupWelldoneWallet } from '@near-wallet-selector/welldone-wallet';
|
|
19
|
-
import { HelloNearContract, NetworkId } from '@/config';
|
|
20
|
-
import { WalletSelectorProvider } from '@near-wallet-selector/react-hook';
|
|
21
|
-
import { wagmiAdapter, web3Modal } from '@/wallets/web3modal';
|
|
22
|
-
|
|
23
|
-
const walletSelectorConfig = {
|
|
24
|
-
network: NetworkId,
|
|
25
|
-
// createAccessKeyFor: HelloNearContract,
|
|
26
|
-
modules: [
|
|
27
|
-
setupMeteorWallet(),
|
|
28
|
-
setupEthereumWallets({ wagmiConfig: wagmiAdapter.wagmiConfig, web3Modal }),
|
|
29
|
-
setupBitteWallet(),
|
|
30
|
-
setupMeteorWalletApp({ contractId: HelloNearContract }),
|
|
31
|
-
setupHotWallet(),
|
|
32
|
-
setupLedger(),
|
|
33
|
-
setupSender(),
|
|
34
|
-
setupHereWallet(),
|
|
35
|
-
setupNearMobileWallet(),
|
|
36
|
-
setupWelldoneWallet(),
|
|
37
|
-
setupMyNearWallet(),
|
|
38
|
-
],
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Layout Component
|
|
42
|
-
export default function RootLayout({ children }) {
|
|
43
|
-
|
|
44
|
-
return (
|
|
45
|
-
<html lang="en">
|
|
46
|
-
<body>
|
|
47
|
-
<WalletSelectorProvider config={walletSelectorConfig}>
|
|
48
|
-
<Navigation />
|
|
49
|
-
{children}
|
|
50
|
-
</WalletSelectorProvider>
|
|
51
|
-
</body>
|
|
52
|
-
</html>
|
|
53
|
-
);
|
|
54
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import '@/styles/globals.css';
|
|
2
|
-
import { Navigation } from '@/components/navigation';
|
|
3
|
-
|
|
4
|
-
import '@near-wallet-selector/modal-ui/styles.css';
|
|
5
|
-
import { setupMyNearWallet } from '@near-wallet-selector/my-near-wallet';
|
|
6
|
-
import { setupMeteorWallet } from '@near-wallet-selector/meteor-wallet';
|
|
7
|
-
import { setupMeteorWalletApp } from '@near-wallet-selector/meteor-wallet-app';
|
|
8
|
-
import { setupBitteWallet } from '@near-wallet-selector/bitte-wallet';
|
|
9
|
-
import { setupEthereumWallets } from '@near-wallet-selector/ethereum-wallets';
|
|
10
|
-
import { setupHotWallet } from '@near-wallet-selector/hot-wallet';
|
|
11
|
-
import { setupLedger } from '@near-wallet-selector/ledger';
|
|
12
|
-
import { setupSender } from '@near-wallet-selector/sender';
|
|
13
|
-
import { setupHereWallet } from '@near-wallet-selector/here-wallet';
|
|
14
|
-
import { setupNearMobileWallet } from '@near-wallet-selector/near-mobile-wallet';
|
|
15
|
-
import { setupWelldoneWallet } from '@near-wallet-selector/welldone-wallet';
|
|
16
|
-
import { HelloNearContract, NetworkId } from '@/config';
|
|
17
|
-
import { WalletSelectorProvider } from '@near-wallet-selector/react-hook';
|
|
18
|
-
import { wagmiAdapter, web3Modal } from '@/wallets/web3modal';
|
|
19
|
-
|
|
20
|
-
const walletSelectorConfig = {
|
|
21
|
-
network: NetworkId,
|
|
22
|
-
// createAccessKeyFor: HelloNearContract,
|
|
23
|
-
modules: [
|
|
24
|
-
setupMeteorWallet(),
|
|
25
|
-
setupEthereumWallets({ wagmiConfig: wagmiAdapter.wagmiConfig, web3Modal }),
|
|
26
|
-
setupBitteWallet(),
|
|
27
|
-
setupMeteorWalletApp({ contractId: HelloNearContract }),
|
|
28
|
-
setupHotWallet(),
|
|
29
|
-
setupLedger(),
|
|
30
|
-
setupSender(),
|
|
31
|
-
setupHereWallet(),
|
|
32
|
-
setupNearMobileWallet(),
|
|
33
|
-
setupWelldoneWallet(),
|
|
34
|
-
setupMyNearWallet(),
|
|
35
|
-
],
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export default function MyApp({ Component, pageProps }) {
|
|
39
|
-
return (
|
|
40
|
-
<WalletSelectorProvider config={walletSelectorConfig}>
|
|
41
|
-
<Navigation />
|
|
42
|
-
<Component {...pageProps} />
|
|
43
|
-
</WalletSelectorProvider>
|
|
44
|
-
);
|
|
45
|
-
}
|