create-near-app 8.5.0 → 9.0.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.
Files changed (67) hide show
  1. package/dist/app.js +2 -1
  2. package/dist/make.js +7 -27
  3. package/dist/messages.js +1 -9
  4. package/dist/types.js +3 -2
  5. package/dist/user-input.js +32 -13
  6. package/dist/utils/index.js +1 -3
  7. package/package.json +2 -1
  8. package/templates/contracts/auction/rs/Cargo.toml +57 -0
  9. package/templates/contracts/auction/rs/README.md +39 -0
  10. package/templates/contracts/auction/rs/rust-toolchain.toml +4 -0
  11. package/templates/contracts/auction/rs/src/lib.rs +118 -0
  12. package/templates/contracts/auction/rs/tests/test_basics.rs +182 -0
  13. package/templates/contracts/auction/ts/README.md +47 -0
  14. package/templates/contracts/auction/ts/package.json +22 -0
  15. package/templates/contracts/auction/ts/sandbox-test/main.ava.js +88 -0
  16. package/templates/contracts/auction/ts/src/contract.ts +72 -0
  17. package/templates/contracts/auction/ts/tsconfig.json +14 -0
  18. package/templates/contracts/{rs → auction-adv/rs}/Cargo.toml +9 -7
  19. package/templates/contracts/auction-adv/rs/README.md +35 -0
  20. package/templates/contracts/{rs → auction-adv/rs}/rust-toolchain.toml +1 -1
  21. package/templates/contracts/auction-adv/rs/src/ext.rs +17 -0
  22. package/templates/contracts/auction-adv/rs/src/lib.rs +159 -0
  23. package/templates/contracts/auction-adv/rs/tests/fungible_token.wasm +0 -0
  24. package/templates/contracts/auction-adv/rs/tests/non_fungible_token.wasm +0 -0
  25. package/templates/contracts/auction-adv/rs/tests/test_basics.rs +430 -0
  26. package/templates/contracts/auction-adv/ts/README.md +45 -0
  27. package/templates/contracts/auction-adv/ts/package.json +22 -0
  28. package/templates/contracts/auction-adv/ts/sandbox-test/fungible_token.wasm +0 -0
  29. package/templates/contracts/auction-adv/ts/sandbox-test/main.ava.js +165 -0
  30. package/templates/contracts/auction-adv/ts/sandbox-test/non_fungible_token.wasm +0 -0
  31. package/templates/contracts/auction-adv/ts/src/contract.ts +87 -0
  32. package/templates/frontend/next-app/package.json +2 -28
  33. package/templates/frontend/next-app/src/app/hello-near/page.tsx +2 -4
  34. package/templates/frontend/next-app/src/app/layout.tsx +3 -58
  35. package/templates/frontend/next-app/src/components/navigation.tsx +14 -14
  36. package/templates/frontend/next-page/package.json +3 -24
  37. package/templates/frontend/next-page/src/components/cards.tsx +0 -1
  38. package/templates/frontend/next-page/src/components/navigation.tsx +14 -14
  39. package/templates/frontend/next-page/src/pages/_app.tsx +3 -56
  40. package/templates/frontend/next-page/src/pages/hello-near/index.tsx +2 -2
  41. package/templates/frontend/vite-react/package.json +6 -28
  42. package/templates/frontend/vite-react/src/App.tsx +3 -62
  43. package/templates/frontend/vite-react/src/components/navigation.tsx +13 -19
  44. package/templates/frontend/vite-react/src/global.d.ts +13 -0
  45. package/templates/frontend/vite-react/src/pages/hello_near.tsx +3 -3
  46. package/templates/contracts/py/.python-version +0 -1
  47. package/templates/contracts/py/README.md +0 -74
  48. package/templates/contracts/py/contract.py +0 -31
  49. package/templates/contracts/py/pyproject.toml +0 -10
  50. package/templates/contracts/py/tests/test_mod.py +0 -53
  51. package/templates/contracts/py/uv.lock +0 -878
  52. package/templates/contracts/rs/.github/workflows/deploy-production.yml +0 -25
  53. package/templates/contracts/rs/.github/workflows/deploy-staging.yml +0 -52
  54. package/templates/contracts/rs/.github/workflows/test.yml +0 -34
  55. package/templates/contracts/rs/.github/workflows/undeploy-staging.yml +0 -23
  56. package/templates/contracts/rs/README.md +0 -43
  57. package/templates/contracts/rs/src/lib.rs +0 -55
  58. package/templates/contracts/rs/tests/test_basics.rs +0 -30
  59. package/templates/contracts/ts/README.md +0 -83
  60. package/templates/contracts/ts/package.json +0 -23
  61. package/templates/contracts/ts/sandbox-test/main.ava.js +0 -45
  62. package/templates/contracts/ts/src/contract.ts +0 -23
  63. package/templates/contracts/ts/yarn.lock +0 -3290
  64. package/templates/frontend/next-app/src/wallets/web3modal.ts +0 -27
  65. package/templates/frontend/next-page/src/wallets/web3modal.ts +0 -27
  66. package/templates/frontend/vite-react/src/wallets/web3modal.ts +0 -27
  67. /package/templates/contracts/{ts → auction-adv/ts}/tsconfig.json +0 -0
@@ -0,0 +1,87 @@
1
+ // Find all our documentation at https://docs.near.org
2
+ import { NearBindgen, near, call, view, AccountId, NearPromise, initialize, assert } from "near-sdk-js";
3
+
4
+ class Bid {
5
+ bidder: AccountId;
6
+ bid: bigint;
7
+ }
8
+
9
+ const THIRTY_TGAS = BigInt("30000000000000");
10
+ const NO_DEPOSIT = BigInt(0);
11
+
12
+ @NearBindgen({ requireInit: true })
13
+ class AuctionContract {
14
+ highest_bid: Bid = { bidder: '', bid: BigInt(1) };
15
+ auction_end_time: bigint = BigInt(0);
16
+ auctioneer: AccountId = "";
17
+ claimed: boolean = false;
18
+ ft_contract: AccountId = "";
19
+ nft_contract: AccountId = "";
20
+ token_id: string = "";
21
+
22
+ @initialize({ privateFunction: true })
23
+ init({ end_time, auctioneer, ft_contract, nft_contract, token_id, starting_price }: { end_time: bigint, auctioneer: AccountId, ft_contract: AccountId, nft_contract: AccountId, token_id: string, starting_price: bigint }) {
24
+ this.auction_end_time = end_time;
25
+ this.highest_bid = { bidder: near.currentAccountId(), bid: starting_price };
26
+ this.auctioneer = auctioneer;
27
+ this.ft_contract = ft_contract;
28
+ this.nft_contract = nft_contract;
29
+ this.token_id = token_id;
30
+ }
31
+
32
+ @call({})
33
+ ft_on_transfer({ sender_id, amount, msg }: { sender_id: AccountId, amount: bigint, msg: String }) {
34
+
35
+ const previous = { ...this.highest_bid };
36
+
37
+ assert(this.auction_end_time > near.blockTimestamp(), "Auction has ended");
38
+ assert(near.predecessorAccountId() == this.ft_contract, "The token is not supported");
39
+ assert(BigInt(amount) >= BigInt(previous.bid), "You must place a higher bid");
40
+ this.highest_bid = {
41
+ bidder: sender_id,
42
+ bid: amount,
43
+ };
44
+
45
+ return NearPromise.new(this.ft_contract)
46
+ .functionCall("ft_transfer", JSON.stringify({ receiver_id: previous.bidder, amount: previous.bid }), BigInt(1), THIRTY_TGAS)
47
+ .then(
48
+ NearPromise.new(near.currentAccountId())
49
+ .functionCall("ft_transfer_callback", JSON.stringify({}), NO_DEPOSIT, THIRTY_TGAS)
50
+ )
51
+ .asReturn()
52
+ }
53
+
54
+ @call({})
55
+ claim() {
56
+ assert(this.auction_end_time <= near.blockTimestamp(), "Auction has not ended yet");
57
+ assert(!this.claimed, "Auction has been claimed");
58
+
59
+ this.claimed = true;
60
+
61
+ return NearPromise.new(this.nft_contract)
62
+ .functionCall("nft_transfer", JSON.stringify({ receiver_id: this.highest_bid.bidder, token_id: this.token_id }), BigInt(1), THIRTY_TGAS)
63
+ .then(NearPromise.new(this.ft_contract)
64
+ .functionCall("ft_transfer", JSON.stringify({ receiver_id: this.auctioneer, amount: this.highest_bid.bid }), BigInt(1), THIRTY_TGAS))
65
+ .asReturn()
66
+ }
67
+
68
+ @call({ privateFunction: true })
69
+ ft_transfer_callback({ }): BigInt {
70
+ return BigInt(0);
71
+ }
72
+
73
+ @view({})
74
+ get_highest_bid(): Bid {
75
+ return this.highest_bid;
76
+ }
77
+
78
+ @view({})
79
+ get_auction_end_time(): BigInt {
80
+ return this.auction_end_time;
81
+ }
82
+
83
+ @view({})
84
+ get_auction_info(): AuctionContract {
85
+ return this;
86
+ }
87
+ }
@@ -12,34 +12,12 @@
12
12
  "lint": "next lint"
13
13
  },
14
14
  "dependencies": {
15
- "@near-wallet-selector/bitget-wallet": "9.5.4",
16
- "@near-wallet-selector/coin98-wallet": "9.5.4",
17
- "@near-wallet-selector/core": "9.5.4",
18
- "@near-wallet-selector/ethereum-wallets": "9.5.4",
19
- "@near-wallet-selector/hot-wallet": "9.5.4",
20
- "@near-wallet-selector/intear-wallet": "9.5.4",
21
- "@near-wallet-selector/ledger": "9.5.4",
22
- "@near-wallet-selector/math-wallet": "9.5.4",
23
- "@near-wallet-selector/meteor-wallet": "9.5.4",
24
- "@near-wallet-selector/meteor-wallet-app": "9.5.4",
25
- "@near-wallet-selector/modal-ui": "9.5.4",
26
- "@near-wallet-selector/near-mobile-wallet": "9.5.4",
27
- "@near-wallet-selector/okx-wallet": "9.5.4",
28
- "@near-wallet-selector/ramper-wallet": "9.5.4",
29
- "@near-wallet-selector/react-hook": "9.5.4",
30
- "@near-wallet-selector/sender": "9.5.4",
31
- "@near-wallet-selector/unity-wallet": "9.5.4",
32
- "@near-wallet-selector/welldone-wallet": "9.5.4",
33
- "@reown/appkit": "^1.7.7",
34
- "@reown/appkit-adapter-wagmi": "^1.7.7",
35
- "@wagmi/core": "^2.17.2",
36
15
  "bootstrap": "^5",
37
16
  "bootstrap-icons": "^1.11.3",
38
- "near-api-js": "^5.0.0",
17
+ "near-connect-hooks": "^1.0.2",
39
18
  "next": "^15",
40
19
  "react": "^18",
41
- "react-dom": "^18",
42
- "viem": "^2.30.5"
20
+ "react-dom": "^18"
43
21
  },
44
22
  "devDependencies": {
45
23
  "@types/node": "^24.7.0",
@@ -50,9 +28,5 @@
50
28
  "eslint-config-next": "^15",
51
29
  "pino-pretty": "^11.2.2",
52
30
  "typescript": "^5.9.3"
53
- },
54
- "overrides": {
55
- "@wagmi/core": "^2.17.2",
56
- "viem": "^2.30.5"
57
31
  }
58
32
  }
@@ -5,13 +5,11 @@ import styles from '@/app/app.module.css';
5
5
  import { Cards } from '@/components/cards';
6
6
 
7
7
  import { HelloNearContract } from '@/config';
8
- import { useWalletSelector } from '@near-wallet-selector/react-hook';
8
+ import { useNearWallet } from 'near-connect-hooks';
9
9
 
10
- // Contract that the app will interact with
11
- const CONTRACT = HelloNearContract;
12
10
 
13
11
  export default function HelloNear() {
14
- const { signedAccountId, viewFunction, callFunction } = useWalletSelector();
12
+ const { signedAccountId, viewFunction, callFunction } = useNearWallet();
15
13
 
16
14
  const [greeting, setGreeting] = useState<string>('loading...');
17
15
  const [newGreeting, setNewGreeting] = useState('loading...');
@@ -1,66 +1,11 @@
1
1
  'use client';
2
-
3
2
  import '@/app/globals.css';
4
- import '@near-wallet-selector/modal-ui/styles.css';
5
3
 
6
4
  import { Navigation } from '@/components/navigation';
7
- import { HelloNearContract, NetworkId } from '@/config';
8
- import { WalletSelectorProvider } from '@near-wallet-selector/react-hook';
5
+ import { NearProvider } from 'near-connect-hooks';
9
6
 
10
7
  import { ReactNode } from 'react';
11
8
 
12
- // Wallet setups
13
- import { setupMeteorWallet } from "@near-wallet-selector/meteor-wallet";
14
- import { setupMeteorWalletApp } from "@near-wallet-selector/meteor-wallet-app";
15
- import { setupEthereumWallets } from "@near-wallet-selector/ethereum-wallets";
16
- import { setupHotWallet } from "@near-wallet-selector/hot-wallet";
17
- import { setupLedger } from "@near-wallet-selector/ledger";
18
- import { setupSender } from "@near-wallet-selector/sender";
19
- import { setupNearMobileWallet } from "@near-wallet-selector/near-mobile-wallet";
20
- import { setupWelldoneWallet } from "@near-wallet-selector/welldone-wallet";
21
- import { setupMathWallet } from "@near-wallet-selector/math-wallet";
22
- import { setupBitgetWallet } from "@near-wallet-selector/bitget-wallet";
23
- import { setupRamperWallet } from "@near-wallet-selector/ramper-wallet";
24
- import { setupUnityWallet } from "@near-wallet-selector/unity-wallet";
25
- import { setupOKXWallet } from "@near-wallet-selector/okx-wallet";
26
- import { setupCoin98Wallet } from "@near-wallet-selector/coin98-wallet";
27
- import { setupIntearWallet } from "@near-wallet-selector/intear-wallet";
28
-
29
- // Ethereum adapters
30
- import { wagmiAdapter, web3Modal } from '@/wallets/web3modal';
31
-
32
- // Types
33
- import type { WalletModuleFactory, Network, WalletSelectorParams } from "@near-wallet-selector/core";
34
-
35
- const walletSelectorConfig: WalletSelectorParams = {
36
- network: NetworkId as unknown as Network,
37
- modules: [
38
- setupEthereumWallets({ wagmiConfig: wagmiAdapter.wagmiConfig, web3Modal }),
39
- setupMeteorWallet(),
40
- setupMeteorWalletApp({ contractId: HelloNearContract }),
41
- setupHotWallet(),
42
- setupLedger(),
43
- setupSender(),
44
- setupNearMobileWallet(),
45
- setupWelldoneWallet(),
46
- setupMathWallet(),
47
- setupBitgetWallet(),
48
- setupRamperWallet(),
49
- setupUnityWallet({
50
- projectId: "your-project-id",
51
- metadata: {
52
- name: "Hello NEAR",
53
- description: "Hello NEAR Example",
54
- url: "https://near.org",
55
- icons: ["https://near.org/favicon.ico"],
56
- }
57
- }),
58
- setupOKXWallet(),
59
- setupCoin98Wallet(),
60
- setupIntearWallet(),
61
- ] as WalletModuleFactory[]
62
- };
63
-
64
9
  // Layout Component
65
10
  interface RootLayoutProps {
66
11
  children: ReactNode;
@@ -70,10 +15,10 @@ export default function RootLayout({ children }: RootLayoutProps) {
70
15
  return (
71
16
  <html lang="en">
72
17
  <body>
73
- <WalletSelectorProvider config={walletSelectorConfig}>
18
+ <NearProvider>
74
19
  <Navigation />
75
20
  {children}
76
- </WalletSelectorProvider>
21
+ </NearProvider>
77
22
  </body>
78
23
  </html>
79
24
  );
@@ -1,30 +1,30 @@
1
1
  import Image from 'next/image';
2
2
  import Link from 'next/link';
3
- import { useEffect, useState } from 'react';
4
- import { useWalletSelector } from '@near-wallet-selector/react-hook';
3
+ import { useNearWallet } from 'near-connect-hooks';
5
4
 
6
5
  import NearLogo from '../../public/near-logo.svg';
7
6
 
8
7
  export const Navigation = () => {
9
- // Type the action as a function that returns void
10
- const [action, setAction] = useState<() => void>(() => () => {});
11
- const [label, setLabel] = useState<string>('Loading...');
12
- const { signedAccountId, signIn, signOut } = useWalletSelector();
8
+ const { signedAccountId, loading, signIn, signOut } = useNearWallet();
13
9
 
14
- useEffect(() => {
10
+ const handleAction = () => {
15
11
  if (signedAccountId) {
16
- setAction(() => signOut);
17
- setLabel(`Logout ${signedAccountId}`);
12
+ signOut();
18
13
  } else {
19
- setAction(() => signIn);
20
- setLabel('Login');
14
+ signIn();
21
15
  }
22
- }, [signedAccountId, signIn, signOut]);
16
+ };
17
+
18
+ const label = loading
19
+ ? "Loading..."
20
+ : signedAccountId
21
+ ? `Logout ${signedAccountId}`
22
+ : "Login";
23
23
 
24
24
  return (
25
25
  <nav className="navbar navbar-expand-lg">
26
26
  <div className="container-fluid">
27
- <Link href="/" passHref>
27
+ <Link href="/">
28
28
  <Image
29
29
  priority
30
30
  src={NearLogo}
@@ -35,7 +35,7 @@ export const Navigation = () => {
35
35
  />
36
36
  </Link>
37
37
  <div className="navbar-nav pt-1">
38
- <button className="btn btn-secondary" onClick={action}>
38
+ <button className="btn btn-secondary" onClick={handleAction}>
39
39
  {label}
40
40
  </button>
41
41
  </div>
@@ -12,36 +12,15 @@
12
12
  "lint": "next lint"
13
13
  },
14
14
  "dependencies": {
15
- "@near-wallet-selector/bitget-wallet": "9.5.4",
16
- "@near-wallet-selector/coin98-wallet": "9.5.4",
17
- "@near-wallet-selector/core": "9.5.4",
18
- "@near-wallet-selector/ethereum-wallets": "9.5.4",
19
- "@near-wallet-selector/hot-wallet": "9.5.4",
20
- "@near-wallet-selector/intear-wallet": "9.5.4",
21
- "@near-wallet-selector/ledger": "9.5.4",
22
- "@near-wallet-selector/math-wallet": "9.5.4",
23
- "@near-wallet-selector/meteor-wallet": "9.5.4",
24
- "@near-wallet-selector/meteor-wallet-app": "9.5.4",
25
- "@near-wallet-selector/modal-ui": "9.5.4",
26
- "@near-wallet-selector/near-mobile-wallet": "9.5.4",
27
- "@near-wallet-selector/okx-wallet": "9.5.4",
28
- "@near-wallet-selector/ramper-wallet": "9.5.4",
29
- "@near-wallet-selector/react-hook": "9.5.4",
30
- "@near-wallet-selector/sender": "9.5.4",
31
- "@near-wallet-selector/unity-wallet": "9.5.4",
32
- "@near-wallet-selector/welldone-wallet": "9.5.4",
33
- "@reown/appkit": "^1.7.7",
34
- "@reown/appkit-adapter-wagmi": "^1.7.7",
35
- "@wagmi/core": "^2.17.2",
36
15
  "bootstrap": "^5",
37
16
  "bootstrap-icons": "^1.11.3",
38
- "near-api-js": "^5.0.0",
17
+ "near-connect-hooks": "^1.0.2",
39
18
  "next": "^15",
40
19
  "react": "^18",
41
- "react-dom": "^18",
42
- "viem": "^2.30.5"
20
+ "react-dom": "^18"
43
21
  },
44
22
  "devDependencies": {
23
+ "@types/node": "24.8.1",
45
24
  "@types/react": "^18.3.26",
46
25
  "@types/react-dom": "^18.3.7",
47
26
  "encoding": "^0.1.13",
@@ -20,7 +20,6 @@ export const Cards = () => {
20
20
  <Link
21
21
  href="/hello-near"
22
22
  className={styles.card}
23
- rel="noopener noreferrer"
24
23
  >
25
24
  <h2>
26
25
  Near Integration <span>-&gt;</span>
@@ -1,30 +1,30 @@
1
1
  import Image from 'next/image';
2
2
  import Link from 'next/link';
3
- import { useEffect, useState } from 'react';
4
- import { useWalletSelector } from '@near-wallet-selector/react-hook';
3
+ import { useNearWallet } from 'near-connect-hooks';
5
4
 
6
5
  import NearLogo from '../../public/near-logo.svg';
7
6
 
8
7
  export const Navigation = () => {
9
- // Type the action as a function that returns void
10
- const [action, setAction] = useState<() => void>(() => () => {});
11
- const [label, setLabel] = useState<string>('Loading...');
12
- const { signedAccountId, signIn, signOut } = useWalletSelector();
8
+ const { signedAccountId, loading, signIn, signOut } = useNearWallet();
13
9
 
14
- useEffect(() => {
10
+ const handleAction = () => {
15
11
  if (signedAccountId) {
16
- setAction(() => signOut);
17
- setLabel(`Logout ${signedAccountId}`);
12
+ signOut();
18
13
  } else {
19
- setAction(() => signIn);
20
- setLabel('Login');
14
+ signIn();
21
15
  }
22
- }, [signedAccountId, signIn, signOut]);
16
+ };
17
+
18
+ const label = loading
19
+ ? "Loading..."
20
+ : signedAccountId
21
+ ? `Logout ${signedAccountId}`
22
+ : "Login";
23
23
 
24
24
  return (
25
25
  <nav className="navbar navbar-expand-lg">
26
26
  <div className="container-fluid">
27
- <Link href="/" passHref legacyBehavior>
27
+ <Link href="/">
28
28
  <Image
29
29
  priority
30
30
  src={NearLogo}
@@ -35,7 +35,7 @@ export const Navigation = () => {
35
35
  />
36
36
  </Link>
37
37
  <div className="navbar-nav pt-1">
38
- <button className="btn btn-secondary" onClick={action}>
38
+ <button className="btn btn-secondary" onClick={handleAction}>
39
39
  {label}
40
40
  </button>
41
41
  </div>
@@ -1,68 +1,15 @@
1
1
  import "@/styles/globals.css";
2
- import "@near-wallet-selector/modal-ui/styles.css";
3
2
 
4
3
  import type { AppProps } from "next/app";
5
- import { WalletSelectorProvider } from "@near-wallet-selector/react-hook";
6
4
  import { Navigation } from "@/components/navigation";
7
- import { HelloNearContract, NetworkId } from "@/config";
5
+ import { NearProvider } from 'near-connect-hooks';
8
6
 
9
- // Wallet setups
10
- import { setupMeteorWallet } from "@near-wallet-selector/meteor-wallet";
11
- import { setupMeteorWalletApp } from "@near-wallet-selector/meteor-wallet-app";
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 { setupNearMobileWallet } from "@near-wallet-selector/near-mobile-wallet";
17
- import { setupWelldoneWallet } from "@near-wallet-selector/welldone-wallet";
18
- import { setupMathWallet } from "@near-wallet-selector/math-wallet";
19
- import { setupBitgetWallet } from "@near-wallet-selector/bitget-wallet";
20
- import { setupRamperWallet } from "@near-wallet-selector/ramper-wallet";
21
- import { setupUnityWallet } from "@near-wallet-selector/unity-wallet";
22
- import { setupOKXWallet } from "@near-wallet-selector/okx-wallet";
23
- import { setupCoin98Wallet } from "@near-wallet-selector/coin98-wallet";
24
- import { setupIntearWallet } from "@near-wallet-selector/intear-wallet";
25
-
26
- // Ethereum adapters
27
- import { wagmiAdapter, web3Modal } from "@/wallets/web3modal";
28
-
29
- // Types
30
- import type { WalletModuleFactory } from "@near-wallet-selector/core";
31
-
32
- const walletSelectorConfig = {
33
- network: NetworkId,
34
- modules: [
35
- setupEthereumWallets({ wagmiConfig: wagmiAdapter.wagmiConfig, web3Modal }),
36
- setupMeteorWallet(),
37
- setupMeteorWalletApp({ contractId: HelloNearContract }),
38
- setupHotWallet(),
39
- setupLedger(),
40
- setupSender(),
41
- setupNearMobileWallet(),
42
- setupWelldoneWallet(),
43
- setupMathWallet(),
44
- setupBitgetWallet(),
45
- setupRamperWallet(),
46
- setupUnityWallet({
47
- projectId: "your-project-id",
48
- metadata: {
49
- name: "Hello NEAR",
50
- description: "Hello NEAR Example",
51
- url: "https://near.org",
52
- icons: ["https://near.org/favicon.ico"],
53
- }
54
- }),
55
- setupOKXWallet(),
56
- setupCoin98Wallet(),
57
- setupIntearWallet(),
58
- ] as WalletModuleFactory[]
59
- };
60
7
 
61
8
  export default function App({ Component, pageProps }: AppProps) {
62
9
  return (
63
- <WalletSelectorProvider config={walletSelectorConfig}>
10
+ <NearProvider>
64
11
  <Navigation />
65
12
  <Component {...pageProps} />
66
- </WalletSelectorProvider>
13
+ </NearProvider>
67
14
  );
68
15
  }
@@ -6,10 +6,10 @@ import styles from '@/styles/app.module.css';
6
6
 
7
7
  import { HelloNearContract } from '../../config';
8
8
 
9
- import { useWalletSelector } from '@near-wallet-selector/react-hook';
9
+ import { useNearWallet } from 'near-connect-hooks';
10
10
 
11
11
  export default function HelloNear() {
12
- const { signedAccountId, viewFunction, callFunction } = useWalletSelector();
12
+ const { signedAccountId, viewFunction, callFunction } = useNearWallet();
13
13
 
14
14
  const [greeting, setGreeting] = useState<string>('loading...');
15
15
  const [newGreeting, setNewGreeting] = useState('');
@@ -9,39 +9,17 @@
9
9
  "preview": "vite preview"
10
10
  },
11
11
  "dependencies": {
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",
32
- "@wagmi/core": "^2.17.1",
33
12
  "bootstrap": "^5",
34
13
  "bootstrap-icons": "^1.11.3",
35
- "near-api-js": "^5.1.1",
36
- "react": "^18",
37
- "react-dom": "^18",
38
- "react-router": "^7",
39
- "viem": "^2.30.5"
14
+ "near-connect-hooks": "^1.0.2",
15
+ "react": "^19",
16
+ "react-dom": "^19",
17
+ "react-router": "^7"
40
18
  },
41
19
  "devDependencies": {
42
20
  "@eslint/js": "^9.17.0",
43
- "@types/react": "^18",
44
- "@types/react-dom": "^18",
21
+ "@types/react": "^19",
22
+ "@types/react-dom": "^19",
45
23
  "@vitejs/plugin-react": "^4.3.4",
46
24
  "eslint": "^9.17.0",
47
25
  "eslint-plugin-react": "^7.37.2",
@@ -3,70 +3,11 @@ import { BrowserRouter, Routes, Route } from "react-router";
3
3
  import { Navigation } from "@/components/navigation";
4
4
  import Home from "@/pages/home";
5
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
- };
6
+ import { NearProvider } from 'near-connect-hooks';
66
7
 
67
8
  function App () {
68
9
  return (
69
- <WalletSelectorProvider config={walletSelectorConfig}>
10
+ <NearProvider>
70
11
  <BrowserRouter>
71
12
  <Navigation />
72
13
  <Routes>
@@ -74,7 +15,7 @@ function App () {
74
15
  <Route path="/hello-near" element={<HelloNear />} />
75
16
  </Routes>
76
17
  </BrowserRouter>
77
- </WalletSelectorProvider>
18
+ </NearProvider>
78
19
  );
79
20
  };
80
21
 
@@ -1,30 +1,24 @@
1
- import { useEffect, useState } from 'react';
2
1
  import { Link } from 'react-router'
3
2
  import NearLogo from '@/assets/near-logo.svg';
4
3
  import styles from '@/styles/app.module.css';
5
- import { useWalletSelector } from '@near-wallet-selector/react-hook';
6
-
7
- interface WalletSelectorHook {
8
- signedAccountId: string | null;
9
- signIn: () => void;
10
- signOut: () => void;
11
- }
4
+ import { useNearWallet } from 'near-connect-hooks';
12
5
 
13
6
  export const Navigation = () => {
14
- const { signedAccountId, signIn, signOut } = useWalletSelector() as WalletSelectorHook;
15
-
16
- const [action, setAction] = useState<() => void>(() => () => {});
17
- const [label, setLabel] = useState<string>('Loading...');
7
+ const { signedAccountId, loading, signIn, signOut } = useNearWallet();
18
8
 
19
- useEffect(() => {
9
+ const handleAction = () => {
20
10
  if (signedAccountId) {
21
- setAction(() => signOut);
22
- setLabel(`Logout ${signedAccountId}`);
11
+ signOut();
23
12
  } else {
24
- setAction(() => signIn);
25
- setLabel('Login');
13
+ signIn();
26
14
  }
27
- }, [signedAccountId, signIn, signOut]);
15
+ };
16
+
17
+ const label = loading
18
+ ? "Loading..."
19
+ : signedAccountId
20
+ ? `Logout ${signedAccountId}`
21
+ : "Login";
28
22
 
29
23
  return (
30
24
  <nav className="navbar navbar-expand-lg">
@@ -39,7 +33,7 @@ export const Navigation = () => {
39
33
  />
40
34
  </Link>
41
35
  <div className="navbar-nav pt-1">
42
- <button className="btn btn-secondary" onClick={action}>
36
+ <button className="btn btn-secondary" onClick={handleAction}>
43
37
  {label}
44
38
  </button>
45
39
  </div>
@@ -0,0 +1,13 @@
1
+ // CSS module declarations
2
+ declare module '*.module.css';
3
+ declare module '*.module.scss';
4
+ declare module '*.module.sass';
5
+
6
+ // Image declarations
7
+ declare module '*.svg';
8
+ declare module '*.png';
9
+ declare module '*.jpg';
10
+ declare module '*.jpeg';
11
+ declare module '*.gif';
12
+ declare module '*.webp';
13
+