Skip to content

holochain/hc-state-cli-node

Repository files navigation

hc-state CLI

CLI tool for querying holochain over admin port (default = 4444) or app port (default = 42233)

CLI:

usage:
    hc-state --command arg

    Commands:
        listApps|a                                                                  list all installed apps: calls listApps({status_filter: null}) -> [AppInfo: any]
        installApp|b [options] <InstalledAppId> <AgentHash> <AppBundleSource>       install provided happ bundle with given id and details:
                                                                                        calls installApp(
                                                                                                agent_key,
                                                                                                installed_app_id,
                                                                                                membrane_proofs?,
                                                                                                network_seed?
                                                                                                path,
                                                                                            ) -> {
                                                                                                installed_app_id,
                                                                                                cell_data: [ { cell_id, cell_nick } ],
                                                                                                status: { inactive: { reason: [Object] } }
                                                                                            }
        listCellIds|c                                                               list installed cells IDs: calls listCellIds(void) -> [CellId: CellIdBase64]
        listDnas|d                                                                  list installed DNAs: calls ListDnas(void) -> [DnaHash: string]
        listEnabledApps|e                                                           list enabled apps: calls listApps({status_filter: "enabled"}) -> [AppInfo: any]
        stateDump|s <CellIdBase6>                                                   dump chain state for app: calls dumpState(CellIdBase64 | Index) -> [stateDump: any]
        enableApp|o <InstalledAppId>                                                activate provided app bundle: calls enableApp(installed_app_id) -> void
        appInfo|i <InstalledAppId>                                                  print app info for app:
                                                                                        calls appInfo(installed_app_id) -> {
                                                                                            installed_app_id: string,
                                                                                            cell_data: [{cell_id: CellIdBase64, cell_nick: string}],
                                                                                            active: boolean
                                                                                        }
        zomeCall|z <DnaHash> <AgentHash> <ZomeName> <ZomeFunction> <Payload>         call zome function for cell:
                                                                                        calls callZome(
                                                                                            cell_id,
                                                                                            zome_name,
                                                                                            fn_name,
                                                                                            payload,
                                                                                            provenence) -> ZomeCallResult: any
        help [command]                                                               display help for command



    Options:
        -V, --version               output the version number
        -p, --app-port <port>       assigns app port for outbound app-interface calls (default: 42233)
        -m, --admin-port <port>     assigns admin port for outbond admin-interface calls (default: 4444)
        -h, --help                  display help for command
        -v, --verbose               prints full tree of the result using util.inspect. Useful if you're seeing [object] or [array] in your results and want to see the contents

        where
            CellIdBase64 =
            [
                DnaHashBase64: string, // base64 representation of Buffer length 39
                AgentPubKeyBase64: string // base64 representation of Buffer length 39
            ]

        example
            hc-state s "['hC0kqcfqvJ8krBR0bNnPsmLtFiEiMOHM0fX+U8FW+ROc7P10tUdc','hCAkcIRv7RZNVg8FWc6/oJZo04dZTXm7JP6tfMk3RptPY02cBQac']"
            // arg is the CellIdBase64 as a continuous string (should not contain spaces)
            or
            hc-state s 0
            // arg is the numeric index of cell ID returned by ListCellIds

Build

npm i
npm run build

will build main.js into dist/

To Run

You will need to open 2 terminals when running the api locally. One will dedicated to running the holochain environement, and the other for the cli calls themselves.

Please note that the happ file path must point to a file that ends in a .happ extention.

Terminal 1

nix develop
AGENTS=<num> BOOTSTRAP_PORT=<num> SIGNAL_PORT=<num> APP_BUNDLE_PATH=<path-to-file.happ> yarn hc:run

Terminal 2

eg:
node dist/main.js a -m 8888

To Test

Locally:

You will need to open 2 terminals when testing locally. One will dedicated to running the holochain environement, and the other the tests.

Please note that the happ file path must point to a file that ends in a .happ extention.

Terminal 1

nix develop
AGENTS=<num> BOOTSTRAP_PORT=<num> SIGNAL_PORT=<num> APP_BUNDLE_PATH=<path-to-file.happ> yarn hc:run

Terminal 2

yarn api:test

CI:

There is a separate script that CI uses located at test/ci-testing.sh.

This is meant for test automation and CI purposes. To run a local instance for testing see above.

Prerequisites

node 12.x

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages