chore(release): clean up repo for v0.0.1 release
Excluded from release bundle:
- CONTEXT.md, CHANGELOG.md (agent/project working notes)
- client-app/ (React Native messenger — tracked separately)
- contracts/hello_go/ (unused standalone example)
Kept contracts/counter/ and contracts/name_registry/ as vm-test fixtures
(referenced by vm/vm_test.go; NOT production contracts).
Docs refactor:
- docs/README.md — new top-level index with cross-references
- docs/quickstart.md — rewrite around single-node as primary path
- docs/node/README.md — full rewrite, all CLI flags, schema table
- docs/api/README.md — add /api/well-known-version, /api/update-check
- docs/contracts/README.md — split native (Go) vs WASM (user-deployable)
- docs/update-system.md — new, full 5-layer update system design
- README.md — link into docs/, drop CHANGELOG/client-app references
Build-time version system (inherited from earlier commits this branch):
- node --version / client --version with ldflags-injected metadata
- /api/well-known-version with {build, protocol_version, features[]}
- Peer-version gossip on dchain/version/v1
- /api/update-check against Gitea release API
- deploy/single/update.sh with semver guard + 15-min systemd jitter
This commit is contained in:
@@ -1,38 +0,0 @@
|
||||
{
|
||||
"contract": "hello_go",
|
||||
"version": "1.0.0",
|
||||
"description": "Example DChain contract written in Go (TinyGo SDK). Demonstrates counter, owner-gated reset, string args, and inter-contract calls.",
|
||||
"build": "tinygo build -o hello_go.wasm -target wasip1 -no-debug .",
|
||||
"methods": [
|
||||
{
|
||||
"name": "increment",
|
||||
"description": "Add 1 to the counter. Logs 'counter: N'.",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "get",
|
||||
"description": "Log the current counter value without changing state.",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "reset",
|
||||
"description": "Reset counter to 0. First caller becomes the owner; only owner can reset.",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "greet",
|
||||
"description": "Log a greeting. Logs 'hello, <name>! block=N'.",
|
||||
"args": [
|
||||
{"name": "name", "type": "string", "description": "Name to greet (defaults to 'world')"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ping",
|
||||
"description": "Call a method on another contract (inter-contract call demo).",
|
||||
"args": [
|
||||
{"name": "contract_id", "type": "string", "description": "Target contract ID"},
|
||||
{"name": "method", "type": "string", "description": "Method to call on target"}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
// Package main is an example DChain smart contract written in Go.
|
||||
//
|
||||
// # Build
|
||||
//
|
||||
// tinygo build -o hello_go.wasm -target wasip1 -no-debug .
|
||||
//
|
||||
// # Deploy
|
||||
//
|
||||
// client deploy-contract --key /keys/node1.json \
|
||||
// --wasm hello_go.wasm --abi hello_go_abi.json \
|
||||
// --node http://localhost:8081
|
||||
//
|
||||
// # Use
|
||||
//
|
||||
// client call-contract --key /keys/node1.json --contract $ID \
|
||||
// --method increment --gas 5000 --node http://localhost:8081
|
||||
//
|
||||
// The contract implements a simple counter with owner-gated reset.
|
||||
// It demonstrates every SDK primitive: arguments, state, caller, logging,
|
||||
// and inter-contract calls.
|
||||
package main
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
dc "go-blockchain/contracts/sdk"
|
||||
)
|
||||
|
||||
// increment adds 1 to the counter and logs the new value.
|
||||
//
|
||||
//export increment
|
||||
func increment() {
|
||||
v := dc.GetU64("counter")
|
||||
v++
|
||||
dc.PutU64("counter", v)
|
||||
dc.Log("counter: " + strconv.FormatUint(v, 10))
|
||||
}
|
||||
|
||||
// get logs the current counter value without changing state.
|
||||
//
|
||||
//export get
|
||||
func get() {
|
||||
v := dc.GetU64("counter")
|
||||
dc.Log("counter: " + strconv.FormatUint(v, 10))
|
||||
}
|
||||
|
||||
// reset sets the counter to 0. On first call the caller becomes the owner.
|
||||
// Subsequent calls are restricted to the owner.
|
||||
//
|
||||
//export reset
|
||||
func reset() {
|
||||
owner := dc.GetStateStr("owner")
|
||||
caller := dc.Caller()
|
||||
if owner == "" {
|
||||
dc.SetStateStr("owner", caller)
|
||||
dc.PutU64("counter", 0)
|
||||
dc.Log("initialized — owner: " + caller[:min8(caller)])
|
||||
return
|
||||
}
|
||||
if caller != owner {
|
||||
dc.Log("unauthorized: " + caller[:min8(caller)])
|
||||
return
|
||||
}
|
||||
dc.PutU64("counter", 0)
|
||||
dc.Log("reset by owner")
|
||||
}
|
||||
|
||||
// greet logs a personalised greeting using the first call argument.
|
||||
//
|
||||
//export greet
|
||||
func greet() {
|
||||
name := dc.ArgStr(0, 64)
|
||||
if name == "" {
|
||||
name = "world"
|
||||
}
|
||||
dc.Log("hello, " + name + "! block=" + strconv.FormatUint(dc.BlockHeight(), 10))
|
||||
}
|
||||
|
||||
// ping calls another contract's method (demonstrates inter-contract calls).
|
||||
// Args: contract_id (string), method (string)
|
||||
//
|
||||
//export ping
|
||||
func ping() {
|
||||
target := dc.ArgStr(0, 64)
|
||||
method := dc.ArgStr(1, 64)
|
||||
if target == "" || method == "" {
|
||||
dc.Log("ping: target and method required")
|
||||
return
|
||||
}
|
||||
if dc.CallContract(target, method, "[]") {
|
||||
dc.Log("ping: " + method + " ok")
|
||||
} else {
|
||||
dc.Log("ping: " + method + " failed")
|
||||
}
|
||||
}
|
||||
|
||||
func min8(s string) int {
|
||||
if len(s) < 8 {
|
||||
return len(s)
|
||||
}
|
||||
return 8
|
||||
}
|
||||
|
||||
func main() {}
|
||||
Reference in New Issue
Block a user