feat: 30 Core actions + RegisterAllActions master registration
Asset actions: blockchain.asset.{info,list,deploy}
Forge actions: blockchain.forge.{release,issue,build,event}
RegisterAllActions(c, chain) wires everything in one call.
Tests: AssetInfo, AssetList, AssetDeploy validation, RegisterAll
verifies all 5 action groups register successfully.
30 total Core actions. Every one is CLI + MCP + API.
Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
parent
35312476ac
commit
1fbeeed992
2 changed files with 86 additions and 0 deletions
58
actions.go
58
actions.go
|
|
@ -340,3 +340,61 @@ func actionValidateAddress(ctx context.Context, opts core.Options) core.Result {
|
|||
"valid": valid, "type": addrType,
|
||||
}, OK: true}
|
||||
}
|
||||
|
||||
// RegisterAssetActions registers HF5 confidential asset actions.
|
||||
//
|
||||
// blockchain.RegisterAssetActions(c)
|
||||
func RegisterAssetActions(c *core.Core) {
|
||||
c.Action("blockchain.asset.info", actionAssetInfo)
|
||||
c.Action("blockchain.asset.list", actionAssetList)
|
||||
c.Action("blockchain.asset.deploy", actionAssetDeploy)
|
||||
}
|
||||
|
||||
func actionAssetInfo(ctx context.Context, opts core.Options) core.Result {
|
||||
assetID := opts.String("asset_id")
|
||||
if assetID == "" || assetID == "LTHN" {
|
||||
return core.Result{Value: map[string]interface{}{
|
||||
"ticker": "LTHN", "name": "Lethean", "decimals": 12,
|
||||
"native": true,
|
||||
}, OK: true}
|
||||
}
|
||||
return core.Result{OK: false}
|
||||
}
|
||||
|
||||
func actionAssetList(ctx context.Context, opts core.Options) core.Result {
|
||||
return core.Result{Value: []map[string]interface{}{
|
||||
{"ticker": "LTHN", "name": "Lethean", "native": true},
|
||||
}, OK: true}
|
||||
}
|
||||
|
||||
func actionAssetDeploy(ctx context.Context, opts core.Options) core.Result {
|
||||
ticker := opts.String("ticker")
|
||||
name := opts.String("name")
|
||||
if ticker == "" || name == "" {
|
||||
return core.Result{OK: false}
|
||||
}
|
||||
return core.Result{Value: map[string]interface{}{
|
||||
"ticker": ticker, "name": name, "status": "ready_for_hf5",
|
||||
}, OK: true}
|
||||
}
|
||||
|
||||
// RegisterForgeActions registers forge integration actions.
|
||||
//
|
||||
// blockchain.RegisterForgeActions(c)
|
||||
func RegisterForgeActions(c *core.Core) {
|
||||
c.Action("blockchain.forge.release", forgePublishRelease)
|
||||
c.Action("blockchain.forge.issue", forgeCreateIssue)
|
||||
c.Action("blockchain.forge.build", forgeDispatchBuild)
|
||||
c.Action("blockchain.forge.event", forgeChainEvent)
|
||||
}
|
||||
|
||||
// RegisterAllActions registers every blockchain action with Core.
|
||||
//
|
||||
// blockchain.RegisterAllActions(c, chain)
|
||||
func RegisterAllActions(c *core.Core, ch *chain.Chain) {
|
||||
RegisterActions(c, ch)
|
||||
RegisterWalletActions(c)
|
||||
RegisterCryptoActions(c)
|
||||
RegisterAssetActions(c)
|
||||
RegisterForgeActions(c)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,3 +71,31 @@ func TestAction_ValidateAddress_Good(t *testing.T) {
|
|||
t.Errorf("type: got %v, want standard", m["type"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestAction_AssetInfo_Good(t *testing.T) {
|
||||
result := actionAssetInfo(context.Background(), core.NewOptions(core.Option{Key: "asset_id", Value: "LTHN"}))
|
||||
if !result.OK { t.Fatal("failed") }
|
||||
m := result.Value.(map[string]interface{})
|
||||
if m["ticker"] != "LTHN" { t.Error("wrong ticker") }
|
||||
}
|
||||
|
||||
func TestAction_AssetList_Good(t *testing.T) {
|
||||
result := actionAssetList(context.Background(), core.Options{})
|
||||
if !result.OK { t.Fatal("failed") }
|
||||
}
|
||||
|
||||
func TestAction_AssetDeploy_Bad(t *testing.T) {
|
||||
result := actionAssetDeploy(context.Background(), core.Options{})
|
||||
if result.OK { t.Error("should fail without ticker") }
|
||||
}
|
||||
|
||||
func TestAction_RegisterAll_Good(t *testing.T) {
|
||||
c := core.New()
|
||||
RegisterAllActions(c, nil)
|
||||
// Verify actions exist
|
||||
if !c.Action("blockchain.chain.height").Exists() { t.Error("chain.height not registered") }
|
||||
if !c.Action("blockchain.wallet.create").Exists() { t.Error("wallet.create not registered") }
|
||||
if !c.Action("blockchain.crypto.hash").Exists() { t.Error("crypto.hash not registered") }
|
||||
if !c.Action("blockchain.asset.info").Exists() { t.Error("asset.info not registered") }
|
||||
if !c.Action("blockchain.forge.release").Exists() { t.Error("forge.release not registered") }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue