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.
- package/dist/app.js +2 -1
- package/dist/make.js +7 -27
- package/dist/messages.js +1 -9
- package/dist/types.js +3 -2
- package/dist/user-input.js +32 -13
- package/dist/utils/index.js +1 -3
- package/package.json +2 -1
- package/templates/contracts/auction/rs/Cargo.toml +57 -0
- package/templates/contracts/auction/rs/README.md +39 -0
- package/templates/contracts/auction/rs/rust-toolchain.toml +4 -0
- package/templates/contracts/auction/rs/src/lib.rs +118 -0
- package/templates/contracts/auction/rs/tests/test_basics.rs +182 -0
- package/templates/contracts/auction/ts/README.md +47 -0
- package/templates/contracts/auction/ts/package.json +22 -0
- package/templates/contracts/auction/ts/sandbox-test/main.ava.js +88 -0
- package/templates/contracts/auction/ts/src/contract.ts +72 -0
- package/templates/contracts/auction/ts/tsconfig.json +14 -0
- package/templates/contracts/{rs → auction-adv/rs}/Cargo.toml +9 -7
- package/templates/contracts/auction-adv/rs/README.md +35 -0
- package/templates/contracts/{rs → auction-adv/rs}/rust-toolchain.toml +1 -1
- package/templates/contracts/auction-adv/rs/src/ext.rs +17 -0
- package/templates/contracts/auction-adv/rs/src/lib.rs +159 -0
- package/templates/contracts/auction-adv/rs/tests/fungible_token.wasm +0 -0
- package/templates/contracts/auction-adv/rs/tests/non_fungible_token.wasm +0 -0
- package/templates/contracts/auction-adv/rs/tests/test_basics.rs +430 -0
- package/templates/contracts/auction-adv/ts/README.md +45 -0
- package/templates/contracts/auction-adv/ts/package.json +22 -0
- package/templates/contracts/auction-adv/ts/sandbox-test/fungible_token.wasm +0 -0
- package/templates/contracts/auction-adv/ts/sandbox-test/main.ava.js +165 -0
- package/templates/contracts/auction-adv/ts/sandbox-test/non_fungible_token.wasm +0 -0
- package/templates/contracts/auction-adv/ts/src/contract.ts +87 -0
- package/templates/frontend/next-app/package.json +2 -28
- package/templates/frontend/next-app/src/app/hello-near/page.tsx +2 -4
- package/templates/frontend/next-app/src/app/layout.tsx +3 -58
- package/templates/frontend/next-app/src/components/navigation.tsx +14 -14
- package/templates/frontend/next-page/package.json +3 -24
- package/templates/frontend/next-page/src/components/cards.tsx +0 -1
- package/templates/frontend/next-page/src/components/navigation.tsx +14 -14
- package/templates/frontend/next-page/src/pages/_app.tsx +3 -56
- package/templates/frontend/next-page/src/pages/hello-near/index.tsx +2 -2
- package/templates/frontend/vite-react/package.json +6 -28
- package/templates/frontend/vite-react/src/App.tsx +3 -62
- package/templates/frontend/vite-react/src/components/navigation.tsx +13 -19
- package/templates/frontend/vite-react/src/global.d.ts +13 -0
- package/templates/frontend/vite-react/src/pages/hello_near.tsx +3 -3
- package/templates/contracts/py/.python-version +0 -1
- package/templates/contracts/py/README.md +0 -74
- package/templates/contracts/py/contract.py +0 -31
- package/templates/contracts/py/pyproject.toml +0 -10
- package/templates/contracts/py/tests/test_mod.py +0 -53
- package/templates/contracts/py/uv.lock +0 -878
- package/templates/contracts/rs/.github/workflows/deploy-production.yml +0 -25
- package/templates/contracts/rs/.github/workflows/deploy-staging.yml +0 -52
- package/templates/contracts/rs/.github/workflows/test.yml +0 -34
- package/templates/contracts/rs/.github/workflows/undeploy-staging.yml +0 -23
- package/templates/contracts/rs/README.md +0 -43
- package/templates/contracts/rs/src/lib.rs +0 -55
- package/templates/contracts/rs/tests/test_basics.rs +0 -30
- package/templates/contracts/ts/README.md +0 -83
- package/templates/contracts/ts/package.json +0 -23
- package/templates/contracts/ts/sandbox-test/main.ava.js +0 -45
- package/templates/contracts/ts/src/contract.ts +0 -23
- package/templates/contracts/ts/yarn.lock +0 -3290
- package/templates/frontend/next-app/src/wallets/web3modal.ts +0 -27
- package/templates/frontend/next-page/src/wallets/web3modal.ts +0 -27
- package/templates/frontend/vite-react/src/wallets/web3modal.ts +0 -27
- /package/templates/contracts/{ts → auction-adv/ts}/tsconfig.json +0 -0
|
@@ -3,9 +3,9 @@ import { Cards } from '@/components/cards';
|
|
|
3
3
|
import styles from '@/styles/app.module.css';
|
|
4
4
|
|
|
5
5
|
import { HelloNearContract } from '@/config';
|
|
6
|
-
import {
|
|
6
|
+
import { useNearWallet } from 'near-connect-hooks';
|
|
7
7
|
|
|
8
|
-
interface
|
|
8
|
+
interface useNearHook {
|
|
9
9
|
signedAccountId: string | null;
|
|
10
10
|
viewFunction: (params: { contractId: string; method: string; args?: Record<string, unknown> }) => Promise<any>;
|
|
11
11
|
callFunction: (params: { contractId: string; method: string; args?: Record<string, unknown> }) => Promise<any>;
|
|
@@ -15,7 +15,7 @@ interface WalletSelectorHook {
|
|
|
15
15
|
const CONTRACT = HelloNearContract as string;
|
|
16
16
|
|
|
17
17
|
export default function HelloNear() {
|
|
18
|
-
const { signedAccountId, viewFunction, callFunction } =
|
|
18
|
+
const { signedAccountId, viewFunction, callFunction } = useNearWallet() as useNearHook;
|
|
19
19
|
|
|
20
20
|
const [greeting, setGreeting] = useState<string>('loading...');
|
|
21
21
|
const [newGreeting, setNewGreeting] = useState<string>('loading...');
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
3.13
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
# contract-py
|
|
2
|
-
|
|
3
|
-
cargo-near-new-project-description
|
|
4
|
-
|
|
5
|
-
## How to Build Locally?
|
|
6
|
-
|
|
7
|
-
Install Python and Emscripten:
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
# Install Python (if not already installed)
|
|
11
|
-
# Use your system's package manager or download from https://www.python.org/downloads/
|
|
12
|
-
|
|
13
|
-
# Install Emscripten (required for compiling Python contracts to WebAssembly)
|
|
14
|
-
# For Linux/macOS:
|
|
15
|
-
git clone https://github.com/emscripten-core/emsdk.git
|
|
16
|
-
cd emsdk
|
|
17
|
-
./emsdk install latest
|
|
18
|
-
./emsdk activate latest
|
|
19
|
-
source ./emsdk_env.sh
|
|
20
|
-
# Add to your .bashrc or .zshrc for permanent installation:
|
|
21
|
-
# echo 'source "/path/to/emsdk/emsdk_env.sh"' >> ~/.bashrc
|
|
22
|
-
cd ..
|
|
23
|
-
|
|
24
|
-
# For Windows:
|
|
25
|
-
# Download and extract: https://github.com/emscripten-core/emsdk
|
|
26
|
-
# Then in Command Prompt:
|
|
27
|
-
# cd emsdk
|
|
28
|
-
# emsdk install latest
|
|
29
|
-
# emsdk activate latest
|
|
30
|
-
# emsdk_env.bat
|
|
31
|
-
|
|
32
|
-
# Verify installation with:
|
|
33
|
-
emcc --version
|
|
34
|
-
|
|
35
|
-
# Install uv for Python package management
|
|
36
|
-
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
37
|
-
|
|
38
|
-
# Install NEAR CLI-RS to deploy and interact with the contract
|
|
39
|
-
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/near-cli-rs/releases/latest/download/near-cli-rs-installer.sh | sh
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
Then run:
|
|
43
|
-
|
|
44
|
-
```bash
|
|
45
|
-
uvx nearc greeting_contract.py
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
## How to Test Locally?
|
|
49
|
-
|
|
50
|
-
```bash
|
|
51
|
-
uv run pytest
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
## How to Deploy?
|
|
55
|
-
|
|
56
|
-
To deploy manually, install [`cargo-near`](https://github.com/near/cargo-near) and run:
|
|
57
|
-
|
|
58
|
-
```bash
|
|
59
|
-
# Create a new account
|
|
60
|
-
cargo near create-dev-account
|
|
61
|
-
|
|
62
|
-
# Deploy the contract on it
|
|
63
|
-
cargo near deploy <account-id>
|
|
64
|
-
```
|
|
65
|
-
## Useful Links
|
|
66
|
-
|
|
67
|
-
- [cargo-near](https://github.com/near/cargo-near) - NEAR smart contract development toolkit for Rust
|
|
68
|
-
- [near CLI](https://near.cli.rs) - Iteract with NEAR blockchain from command line
|
|
69
|
-
- [NEAR Python SDK Documentation](https://github.com/r-near/near-sdk-py)
|
|
70
|
-
- [NEAR Documentation](https://docs.near.org)
|
|
71
|
-
- [NEAR StackOverflow](https://stackoverflow.com/questions/tagged/nearprotocol)
|
|
72
|
-
- [NEAR Discord](https://near.chat)
|
|
73
|
-
- [NEAR Telegram Developers Community Group](https://t.me/neardev)
|
|
74
|
-
- NEAR DevHub: [Telegram](https://t.me/neardevhub), [Twitter](https://twitter.com/neardevhub)
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
from near_sdk_py import Contract, view, call, init
|
|
2
|
-
|
|
3
|
-
class GreetingContract(Contract):
|
|
4
|
-
"""
|
|
5
|
-
A simple greeting contract that stores and returns a message.
|
|
6
|
-
"""
|
|
7
|
-
|
|
8
|
-
@init
|
|
9
|
-
def initialize(self, default_message="Hello, NEAR world!"):
|
|
10
|
-
"""
|
|
11
|
-
Initialize the contract with a default greeting message.
|
|
12
|
-
"""
|
|
13
|
-
self.storage["greeting"] = default_message
|
|
14
|
-
return {"success": True}
|
|
15
|
-
|
|
16
|
-
@call
|
|
17
|
-
def set_greeting(self, message: str):
|
|
18
|
-
"""
|
|
19
|
-
Change the greeting message.
|
|
20
|
-
"""
|
|
21
|
-
self.storage["greeting"] = message
|
|
22
|
-
self.log_info(f"Saving greeting: {message}")
|
|
23
|
-
return {"success": True}
|
|
24
|
-
|
|
25
|
-
@view
|
|
26
|
-
def get_greeting(self):
|
|
27
|
-
"""
|
|
28
|
-
Retrieve the current greeting message.
|
|
29
|
-
"""
|
|
30
|
-
return self.storage.get("greeting", "Hello, NEAR world!")
|
|
31
|
-
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
from near_pytest.testing import NearTestCase
|
|
2
|
-
import json
|
|
3
|
-
|
|
4
|
-
class TestGreetingContract(NearTestCase):
|
|
5
|
-
@classmethod
|
|
6
|
-
def setup_class(cls):
|
|
7
|
-
"""Compile and deploy the greeting contract."""
|
|
8
|
-
super().setup_class()
|
|
9
|
-
|
|
10
|
-
# Compile the contract
|
|
11
|
-
wasm_path = cls.compile_contract(
|
|
12
|
-
"contract.py",
|
|
13
|
-
single_file=True
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
# Deploy the contract
|
|
17
|
-
cls.contract_account = cls.create_account("contract")
|
|
18
|
-
cls.instance = cls.deploy_contract(cls.contract_account, wasm_path)
|
|
19
|
-
|
|
20
|
-
# Initialize the contract
|
|
21
|
-
cls.instance.call_as(
|
|
22
|
-
account=cls.contract_account,
|
|
23
|
-
method_name="initialize",
|
|
24
|
-
args={"default_message": "Initial greeting"},
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
# Create test user
|
|
28
|
-
cls.user = cls.create_account("user")
|
|
29
|
-
|
|
30
|
-
# Save state for future resets
|
|
31
|
-
cls.save_state()
|
|
32
|
-
|
|
33
|
-
def setup_method(self):
|
|
34
|
-
"""Reset state before each test method."""
|
|
35
|
-
self.reset_state()
|
|
36
|
-
|
|
37
|
-
def test_greeting(self):
|
|
38
|
-
# Set greeting as user
|
|
39
|
-
result = self.instance.call_as(
|
|
40
|
-
account=self.user,
|
|
41
|
-
method_name="set_greeting",
|
|
42
|
-
args={"message": "Hello from test!"}
|
|
43
|
-
)
|
|
44
|
-
result = json.loads(result.text)
|
|
45
|
-
assert result["success"] == True
|
|
46
|
-
|
|
47
|
-
# Get greeting
|
|
48
|
-
greeting = self.instance.call_as(
|
|
49
|
-
account=self.user,
|
|
50
|
-
method_name="get_greeting"
|
|
51
|
-
)
|
|
52
|
-
assert greeting.text == "Hello from test!"
|
|
53
|
-
|