Add Makefile, reorganize scripts, and fix Rhai contract_call API #4

Merged
mik-tf merged 9 commits from master-tests into master 2026-01-02 05:22:04 +00:00
Contributor

Description

This PR restructures the HERO Near project for better organization and developer experience, adds comprehensive build automation via Makefile, and fixes the Rhai contract_call() API to enable full system testing.


Changes

🏗️ Build Automation - New Makefile

Added a comprehensive Makefile with 15+ targets for building, testing, and deployment:

make build              # Build all contracts
make test               # Run smoke + full system tests (42 tests)
make deploy-local-fresh # Single command: reset + deploy + test
make status             # Show contract deployment status
make clean              # Clean build artifacts

📁 Scripts Reorganization

Restructured scripts directory for clarity:

scripts/
├── deploy/           # Deployment scripts
│   ├── build.sh
│   ├── install.sh
│   ├── setup.sh      # Local deployment
│   └── setup_testnet.sh
├── tests/            # Test scripts
│   ├── test_smoke.rhai        # 9 quick health checks
│   ├── test_full_system.rhai  # 33 comprehensive tests
│   └── test_*.rhai
└── examples/         # Rhai examples
    ├── dns_*.rhai
    └── *.rhai

🔧 Rhai API Improvements

  • Added contract_call() function for fluent contract interactions
  • Added set_contract() method for flexible builder pattern
  • Added set_deposit_str() for large yoctoNEAR values (avoids i64 overflow)
// New flexible API
contract_call()
    .signer(account)
    .contract("my_contract.test.near")
    .method("set")
    .args(#{ key: "value" })
    .deposit("1000000000000000000000000")  // String for large values
    .execute();

🧪 Test Fixes

  • Fixed method names: get_thresholdget_required_confirmations
  • Fixed KVS method names: kv_set/kv_getset/get/exists
  • Fixed namespace validation (10+ chars with dot required)
  • Fixed byte array serialization (use base64 for Vec)

📚 Documentation Updates

  • Updated README.md with Makefile usage
  • Updated DEPLOYMENT.md with new directory structure
  • Updated ARCHITECTURE.md with current layout
  • Updated SETUP.md with simplified commands
  • Removed duplicate examples from /examples (kept in scripts/examples)

Test Results

✅ 9/9 Smoke Tests - All systems operational
✅ 33/33 Full System Tests - All features validated
────────────────────────────────────────
📊 Total: 42/42 tests passing

Feature Coverage:

  • Account operations
  • Token contracts (SPORE, GLD, USDH)
  • SPORE 2-of-3 multisig governance
  • Token transfers
  • SPOREX exchange with 10% rate limits
  • DNS system
  • Credit vault
  • Groups contract
  • KVS contract
  • Security features

Files Changed

Category Files Lines
New Makefile 1 +183
Rhai API 2 +42
Script reorganization 15 moved -
Documentation 8 ±400
Removed duplicates 7 -1549
Total 38 files -1127 net

Breaking Changes

None - all existing functionality preserved.


How to Test

cd geomind_research/hero_near

# Full deployment with tests (single command)
make deploy-local-fresh

# Or run tests only (if already deployed)
make test

Next Steps

  • Phase 3: Testnet Deployment
  • Phase 4: Mainnet Deployment
### Description This PR restructures the HERO Near project for better organization and developer experience, adds comprehensive build automation via Makefile, and fixes the Rhai `contract_call()` API to enable full system testing. --- ### Changes #### 🏗️ Build Automation - New Makefile Added a comprehensive Makefile with 15+ targets for building, testing, and deployment: ```makefile make build # Build all contracts make test # Run smoke + full system tests (42 tests) make deploy-local-fresh # Single command: reset + deploy + test make status # Show contract deployment status make clean # Clean build artifacts ``` #### 📁 Scripts Reorganization Restructured scripts directory for clarity: ``` scripts/ ├── deploy/ # Deployment scripts │ ├── build.sh │ ├── install.sh │ ├── setup.sh # Local deployment │ └── setup_testnet.sh ├── tests/ # Test scripts │ ├── test_smoke.rhai # 9 quick health checks │ ├── test_full_system.rhai # 33 comprehensive tests │ └── test_*.rhai └── examples/ # Rhai examples ├── dns_*.rhai └── *.rhai ``` #### 🔧 Rhai API Improvements - Added `contract_call()` function for fluent contract interactions - Added `set_contract()` method for flexible builder pattern - Added `set_deposit_str()` for large yoctoNEAR values (avoids i64 overflow) ```rhai // New flexible API contract_call() .signer(account) .contract("my_contract.test.near") .method("set") .args(#{ key: "value" }) .deposit("1000000000000000000000000") // String for large values .execute(); ``` #### 🧪 Test Fixes - Fixed method names: `get_threshold` → `get_required_confirmations` - Fixed KVS method names: `kv_set`/`kv_get` → `set`/`get`/`exists` - Fixed namespace validation (10+ chars with dot required) - Fixed byte array serialization (use base64 for Vec<u8>) #### 📚 Documentation Updates - Updated README.md with Makefile usage - Updated DEPLOYMENT.md with new directory structure - Updated ARCHITECTURE.md with current layout - Updated SETUP.md with simplified commands - Removed duplicate examples from /examples (kept in scripts/examples) --- ### Test Results ``` ✅ 9/9 Smoke Tests - All systems operational ✅ 33/33 Full System Tests - All features validated ──────────────────────────────────────── 📊 Total: 42/42 tests passing ``` **Feature Coverage:** - ✅ Account operations - ✅ Token contracts (SPORE, GLD, USDH) - ✅ SPORE 2-of-3 multisig governance - ✅ Token transfers - ✅ SPOREX exchange with 10% rate limits - ✅ DNS system - ✅ Credit vault - ✅ Groups contract - ✅ KVS contract - ✅ Security features --- ### Files Changed | Category | Files | Lines | |----------|-------|-------| | New Makefile | 1 | +183 | | Rhai API | 2 | +42 | | Script reorganization | 15 moved | - | | Documentation | 8 | ±400 | | Removed duplicates | 7 | -1549 | | **Total** | **38 files** | **-1127 net** | --- ### Breaking Changes None - all existing functionality preserved. --- ### How to Test ```bash cd geomind_research/hero_near # Full deployment with tests (single command) make deploy-local-fresh # Or run tests only (if already deployed) make test ``` --- ### Next Steps - Phase 3: Testnet Deployment - Phase 4: Mainnet Deployment
mik-tf merged commit 776551988b into master 2026-01-02 05:22:04 +00:00
mik-tf deleted branch master-tests 2026-01-02 05:22:05 +00:00
Sign in to join this conversation.
No reviewers
No labels
urgent
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
geomind_research/hero_ledger!4
No description provided.