diff --git a/CHANGELOG.md b/CHANGELOG.md index 50ffbbed..7cf5bb6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Added ### Removed ### Changed +- Support new `roles_settings` field in `AppOptions`. ### Fixed ## 2024-11-25: v0.18.0-dev.2 @@ -230,7 +231,7 @@ Compatible with Holochain v0.1.0 ## [0.6.2] ### Added -- feat(common): add app and role id options to hApp installation +- feat(common): add app and role id options to hApp installation - feat(common): add mem-proofs to installAgentsHapps (#139) - feat(trycp): add multiple clients by array of URLs - feat(trycp): add multiple clients/players diff --git a/Cargo.lock b/Cargo.lock index b0f38bd0..6957d984 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1148,9 +1148,9 @@ dependencies = [ [[package]] name = "hdi" -version = "0.6.0-dev.3" +version = "0.6.0-dev.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07faadf3f9a01463006a0cdab618f3b15349b77f20b26d924ed98fd18e2ff6bb" +checksum = "fd2b81d1ca8036deba19b4d55ece09def176eeb062a49391369ccb424223c917" dependencies = [ "getrandom", "hdk_derive", @@ -1166,9 +1166,9 @@ dependencies = [ [[package]] name = "hdk" -version = "0.5.0-dev.5" +version = "0.5.0-dev.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adc930d98b193eedb1854095c64bdc53941ae29170035541cda89a6bbd9b13e1" +checksum = "bdca5784af969790afdbc1c6bf30ec677ddfde2e3961bcea07fe73d7ecd15c39" dependencies = [ "getrandom", "hdi", @@ -1186,9 +1186,9 @@ dependencies = [ [[package]] name = "hdk_derive" -version = "0.5.0-dev.3" +version = "0.5.0-dev.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c1de80512ee3489781c48731771e772da4b1efa4411b9828c60dae15c868480" +checksum = "3477a3b1fa6e302d14144397a7cf669e7806e6b116e6f432411d232d8c3c243d" dependencies = [ "darling 0.14.4", "heck 0.5.0", @@ -1244,9 +1244,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "holo_hash" -version = "0.5.0-dev.2" +version = "0.5.0-dev.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52b1609ab3426ffbc6b96c0ae917d5281682f6bde22c1799fdc2d2f65d1c716d" +checksum = "e9ef5f1b831a64ab1e1d2a2d6c76b8140c59660cd9b6c745eaf0c4b0d03b9257" dependencies = [ "base64 0.22.1", "blake2b_simd", @@ -1262,14 +1262,15 @@ dependencies = [ "rusqlite", "serde", "serde_bytes", + "sha2", "thiserror 1.0.69", ] [[package]] name = "holochain_conductor_api" -version = "0.5.0-dev.5" +version = "0.5.0-dev.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138dfb6a34285a9d2f842b4eedb1c54a5db47845557fd2da6493ed928d1562d8" +checksum = "721649eecde51d31d6602d3a7f6cdfd10cabff55145a76f487d31a7addc668d2" dependencies = [ "cfg-if 1.0.0", "derive_more", @@ -1293,9 +1294,9 @@ dependencies = [ [[package]] name = "holochain_integrity_types" -version = "0.5.0-dev.2" +version = "0.5.0-dev.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad6856a52474f4d99818b3492260e1a53e8d7a766584bce1e8dfd2a3475dfc3" +checksum = "8835be40ef1c0dffbfa111991611169a886506c48d45c91dce9523eae7639a14" dependencies = [ "derive_builder", "holo_hash", @@ -1312,9 +1313,9 @@ dependencies = [ [[package]] name = "holochain_keystore" -version = "0.5.0-dev.5" +version = "0.5.0-dev.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89d0ba47f19341ed3b800281005063cf911ea31cc12bbbe21add55579d1d1661" +checksum = "d36f5c77333a5afaacc3b630b10b7b9757b1a515925b2f0a98449e8d242a7e48" dependencies = [ "base64 0.22.1", "derive_more", @@ -1388,9 +1389,9 @@ dependencies = [ [[package]] name = "holochain_sqlite" -version = "0.5.0-dev.5" +version = "0.5.0-dev.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e286aaa294e4384e3913aafb57ffb4e9feedfab265883ff6ffe71d80cec58583" +checksum = "eae44976a186d612094ad2ecbb9e449c22f02e8c732bb6860e2a482059797940" dependencies = [ "anyhow", "async-trait", @@ -1433,9 +1434,9 @@ dependencies = [ [[package]] name = "holochain_state_types" -version = "0.5.0-dev.2" +version = "0.5.0-dev.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c76a97edf926319b79483ae226e5d02bf86344b157c8021f8949e06578bead4" +checksum = "93937b0ae3bb6ac53216ae8a59c8212442591875720d9c8310299b9fbcaf913b" dependencies = [ "holo_hash", "holochain_integrity_types", @@ -1462,9 +1463,9 @@ dependencies = [ [[package]] name = "holochain_types" -version = "0.5.0-dev.5" +version = "0.5.0-dev.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "547e0ac56c691964337ebd46b5fbdb9ea36e6d01689079ca4bdc36e52088913e" +checksum = "dabc1aeb326eea615e9cd38b10c70105ecc871704cee3cd448883e54bbb3f75b" dependencies = [ "anyhow", "async-trait", @@ -1559,9 +1560,9 @@ dependencies = [ [[package]] name = "holochain_zome_types" -version = "0.5.0-dev.5" +version = "0.5.0-dev.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50bbfe610c4fb8fb0d10cf1e06ce8bf67616d94b7d58245a3be1d1c26263d61f" +checksum = "53206125cfcc90d3aeca074bd97f715e64909443b5bda6b52569e0a82216e19c" dependencies = [ "derive_builder", "derive_more", @@ -3586,6 +3587,17 @@ dependencies = [ "digest", ] +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if 1.0.0", + "cpufeatures", + "digest", +] + [[package]] name = "sharded-slab" version = "0.1.7" diff --git a/Cargo.toml b/Cargo.toml index 0b43dba9..77c33c64 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,8 +10,8 @@ resolver = "2" [workspace.dependencies] futures = "0.3" -hdi = "0.6.0-dev.3" -hdk = "0.5.0-dev.5" +hdi = "0.6.0-dev.4" +hdk = "0.5.0-dev.7" nix = { version = "0.29.0", features = ["signal"] } once_cell = "1.5.0" parking_lot = "0.12" diff --git a/crates/trycp_server/Cargo.toml b/crates/trycp_server/Cargo.toml index baec3fac..4bcad114 100644 --- a/crates/trycp_server/Cargo.toml +++ b/crates/trycp_server/Cargo.toml @@ -37,7 +37,7 @@ trycp_api = { workspace = true } url = { workspace = true } [dev-dependencies] -holochain_conductor_api = "0.5.0-dev.5" +holochain_conductor_api = "0.5.0-dev.7" rand = "0.8" serde_yaml = "0.9" trycp_client = { path = "../trycp_client" } diff --git a/docs/tryorama.appoptions.md b/docs/tryorama.appoptions.md index 7f1345b9..ce0ce695 100644 --- a/docs/tryorama.appoptions.md +++ b/docs/tryorama.appoptions.md @@ -75,7 +75,7 @@ _(Optional)_ App ID to override the app manifest's app name. -[membraneProofs?](./tryorama.appoptions.membraneproofs.md) +[networkSeed?](./tryorama.appoptions.networkseed.md) @@ -83,18 +83,18 @@ _(Optional)_ App ID to override the app manifest's app name. -Record<string, MembraneProof> +string -_(Optional)_ Proofs of membership for the hApp. +_(Optional)_ A network seed to override the hApps' network seed. -[networkSeed?](./tryorama.appoptions.networkseed.md) +[rolesSettings?](./tryorama.appoptions.rolessettings.md) @@ -102,12 +102,12 @@ _(Optional)_ Proofs of membership for the hApp. -string +RoleSettingsMap -_(Optional)_ A network seed to override the hApps' network seed. +_(Optional)_ Role specific settings or modifiers that will override any settings in the hApp's dna manifest(s). diff --git a/docs/tryorama.appoptions.membraneproofs.md b/docs/tryorama.appoptions.membraneproofs.md deleted file mode 100644 index 2d29defb..00000000 --- a/docs/tryorama.appoptions.membraneproofs.md +++ /dev/null @@ -1,13 +0,0 @@ - - -[Home](./index.md) > [@holochain/tryorama](./tryorama.md) > [AppOptions](./tryorama.appoptions.md) > [membraneProofs](./tryorama.appoptions.membraneproofs.md) - -## AppOptions.membraneProofs property - -Proofs of membership for the hApp. - -**Signature:** - -```typescript -membraneProofs?: Record; -``` diff --git a/docs/tryorama.appoptions.rolessettings.md b/docs/tryorama.appoptions.rolessettings.md new file mode 100644 index 00000000..b4c48981 --- /dev/null +++ b/docs/tryorama.appoptions.rolessettings.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@holochain/tryorama](./tryorama.md) > [AppOptions](./tryorama.appoptions.md) > [rolesSettings](./tryorama.appoptions.rolessettings.md) + +## AppOptions.rolesSettings property + +Role specific settings or modifiers that will override any settings in the hApp's dna manifest(s). + +**Signature:** + +```typescript +rolesSettings?: RoleSettingsMap; +``` diff --git a/flake.lock b/flake.lock index 060dbb4c..1df01615 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "crane": { "locked": { - "lastModified": 1731974733, - "narHash": "sha256-enYSSZVVl15FI5p+0Y5/Ckf5DZAvXe6fBrHxyhA/njc=", + "lastModified": 1732407143, + "narHash": "sha256-qJOGDT6PACoX+GbNH2PPx2ievlmtT1NVeTB80EkRLys=", "owner": "ipetkov", "repo": "crane", - "rev": "3cb338ce81076ce5e461cf77f7824476addb0e1c", + "rev": "f2b4b472983817021d9ffb60838b2b36b9376b20", "type": "github" }, "original": { @@ -70,16 +70,16 @@ "holochain": { "flake": false, "locked": { - "lastModified": 1732065228, - "narHash": "sha256-4QBB/HAv6MoVaHVYsbhhvj2UnfIT0bCb0cgcoeNn07A=", + "lastModified": 1732669495, + "narHash": "sha256-JPT3ZJQHlMjoDmdyYn46IFp5QhJ9TwsVS9ELTT30+t0=", "owner": "holochain", "repo": "holochain", - "rev": "0069772823ce6f761f793544ca7ec8877cd47a39", + "rev": "f441becbea4b7a3bdfc45239d024c751869ab1e4", "type": "github" }, "original": { "owner": "holochain", - "ref": "holochain-0.5.0-dev.6", + "ref": "holochain-0.5.0-dev.7", "repo": "holochain", "type": "github" } @@ -100,11 +100,11 @@ ] }, "locked": { - "lastModified": 1732123243, - "narHash": "sha256-ugJEN44UgCQYPoxV1WN32ybPxij9M8uTnDLCfWi4Rb0=", + "lastModified": 1732727927, + "narHash": "sha256-smpX2X7CaFfhqe8nDdq6GS8ssmgAk7ck5qUuhrig7a0=", "owner": "holochain", "repo": "holonix", - "rev": "f58fb5e1c490704d90daa1b461701de7c70d685a", + "rev": "1dbf7e73ab36172f0b57ba003ecb83dcd81fa5c9", "type": "github" }, "original": { @@ -178,11 +178,11 @@ ] }, "locked": { - "lastModified": 1732156292, - "narHash": "sha256-XuTCME5ZausokOJ28AsIoayBVD1soscdoiKweT4VY50=", + "lastModified": 1732802692, + "narHash": "sha256-kFrxb45qj52TT/OFUFyTdmvXkn/KXDUL0/DOtjHEQvs=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "2d484c7a0db32f2700e253160bcd2aaa6cdca3ba", + "rev": "34971069ec33755b2adf2481851f66d8ec9a6bfa", "type": "github" }, "original": { diff --git a/package-lock.json b/package-lock.json index 904e52f4..b1c78535 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.18.0-dev.2", "license": "MIT", "dependencies": { - "@holochain/client": "^0.19.0-dev.5", + "@holochain/client": "^0.19.0-dev.6", "get-port": "^6.1.2", "lodash": "^4.17.21", "uuid": "^8.3.2", @@ -32,6 +32,7 @@ "eslint-config-prettier": "^8.10.0", "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-tsdoc": "^0.2.17", + "js-yaml": "^4.1.0", "prettier": "^2.8.1", "rimraf": "^3.0.2", "tape": "^5.7.5", @@ -563,26 +564,6 @@ "url": "https://github.com/sponsors/epoberezkin" } }, - "node_modules/@eslint/eslintrc/node_modules/argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true, - "license": "Python-2.0" - }, - "node_modules/@eslint/eslintrc/node_modules/js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", - "dev": true, - "license": "MIT", - "dependencies": { - "argparse": "^2.0.1" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, "node_modules/@eslint/eslintrc/node_modules/json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", @@ -614,9 +595,10 @@ } }, "node_modules/@holochain/client": { - "version": "0.19.0-dev.5", - "resolved": "https://registry.npmjs.org/@holochain/client/-/client-0.19.0-dev.5.tgz", - "integrity": "sha512-XQAeURuqIm3f0knRnIByU5ZLiATjVK8BqGlIARwgzR4+mC77isU9jsBEGqOp5uitOAIx6qvcguE5divn2Xo9Fg==", + "version": "0.19.0-dev.6", + "resolved": "https://registry.npmjs.org/@holochain/client/-/client-0.19.0-dev.6.tgz", + "integrity": "sha512-u4noOle+liqVTkJ/Ad5Kq5du13kPR6N4Z9ZbxPedgrwe0zSpO7UDNMAzEBM/cO6bjJH/toOES1oJnfmwAhw69Q==", + "license": "CAL-1.0", "dependencies": { "@bitgo/blake2b": "^3.2.4", "@msgpack/msgpack": "^2.8.0", @@ -716,6 +698,20 @@ "api-documenter": "bin/api-documenter" } }, + "node_modules/@microsoft/api-documenter/node_modules/js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "dev": true, + "license": "MIT", + "dependencies": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, "node_modules/@microsoft/api-extractor": { "version": "7.47.9", "resolved": "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.47.9.tgz", @@ -2282,13 +2278,6 @@ "url": "https://github.com/sponsors/epoberezkin" } }, - "node_modules/eslint/node_modules/argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true, - "license": "Python-2.0" - }, "node_modules/eslint/node_modules/eslint-scope": { "version": "7.2.2", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", @@ -2316,19 +2305,6 @@ "node": ">=4.0" } }, - "node_modules/eslint/node_modules/js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", - "dev": true, - "license": "MIT", - "dependencies": { - "argparse": "^2.0.1" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, "node_modules/eslint/node_modules/json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", @@ -3517,19 +3493,25 @@ "integrity": "sha512-mirki9WS/SUahm+1TbAPkqvbCiCfOAAsyXeHxK1UkullnJVVqoJG2pL9ObvT05CN+tM7fxhfYm0NbXn+1hWoZg==" }, "node_modules/js-yaml": { - "version": "3.13.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", - "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", "dev": true, "license": "MIT", "dependencies": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" + "argparse": "^2.0.1" }, "bin": { "js-yaml": "bin/js-yaml.js" } }, + "node_modules/js-yaml/node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true, + "license": "Python-2.0" + }, "node_modules/json-buffer": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", diff --git a/package.json b/package.json index 598e7d66..b6a6beb5 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "prepublishOnly": "npm run build" }, "dependencies": { - "@holochain/client": "^0.19.0-dev.5", + "@holochain/client": "^0.19.0-dev.6", "get-port": "^6.1.2", "lodash": "^4.17.21", "uuid": "^8.3.2", @@ -66,6 +66,7 @@ "eslint-config-prettier": "^8.10.0", "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-tsdoc": "^0.2.17", + "js-yaml": "^4.1.0", "prettier": "^2.8.1", "rimraf": "^3.0.2", "tape": "^5.7.5", diff --git a/ts/src/local/conductor.ts b/ts/src/local/conductor.ts index c393c04c..4fc3a767 100644 --- a/ts/src/local/conductor.ts +++ b/ts/src/local/conductor.ts @@ -7,7 +7,6 @@ import { getSigningCredentials, InstallAppRequest, AppAuthenticationToken, - NetworkSeed, CallZomeRequest, RoleNameCallZomeRequest, } from "@holochain/client"; @@ -386,21 +385,21 @@ export class Conductor implements IConductor { const agent_key = options?.agentPubKey ?? (await this.adminWs().generateAgentPubKey()); const installed_app_id = options?.installedAppId ?? `app-${uuidv4()}`; - const membrane_proofs = options?.membraneProofs ?? {}; + const roles_settings = options?.rolesSettings; const network_seed = options?.networkSeed; const installAppRequest: InstallAppRequest = "bundle" in appBundleSource ? { bundle: appBundleSource.bundle, agent_key, - membrane_proofs, + roles_settings, installed_app_id, network_seed, } : { path: appBundleSource.path, agent_key, - membrane_proofs, + roles_settings, installed_app_id, network_seed, }; @@ -420,7 +419,7 @@ export class Conductor implements IConductor { options.agentsApps.map((appsForAgent) => this.installApp(appsForAgent.app, { agentPubKey: appsForAgent.agentPubKey, - membraneProofs: appsForAgent.membraneProofs, + rolesSettings: appsForAgent.rolesSettings, installedAppId: options.installedAppId, networkSeed: options.networkSeed, }) diff --git a/ts/src/trycp/conductor/conductor.ts b/ts/src/trycp/conductor/conductor.ts index 0c697380..d5b93b15 100644 --- a/ts/src/trycp/conductor/conductor.ts +++ b/ts/src/trycp/conductor/conductor.ts @@ -7,7 +7,6 @@ import { SignalCb, AttachAppInterfaceRequest, CallZomeRequest, - CallZomeRequestSigned, CapSecret, CellId, CreateCloneCellRequest, @@ -1037,7 +1036,7 @@ export class TryCpConductor implements IConductor { async installApp(appBundleSource: AppBundleSource, options?: AppOptions) { const agent_key = options?.agentPubKey ?? (await this.adminWs().generateAgentPubKey()); - const membrane_proofs = options?.membraneProofs ?? {}; + const roles_settings = options?.rolesSettings; const installed_app_id = options?.installedAppId ?? `app-${uuidv4()}`; const network_seed = options?.networkSeed; const installAppRequest: InstallAppRequest = @@ -1045,14 +1044,14 @@ export class TryCpConductor implements IConductor { ? { bundle: appBundleSource.bundle, agent_key, - membrane_proofs, + roles_settings, installed_app_id, network_seed, } : { path: appBundleSource.path, agent_key, - membrane_proofs, + roles_settings, installed_app_id, network_seed, }; @@ -1071,7 +1070,7 @@ export class TryCpConductor implements IConductor { const agent_key = appForAgent.agentPubKey ?? (await this.adminWs().generateAgentPubKey()); - const membrane_proofs = appForAgent.membraneProofs ?? {}; + const roles_settings = appForAgent.rolesSettings; const installed_app_id = options.installedAppId ?? `app-${uuidv4()}`; const network_seed = options.networkSeed; const installAppRequest: InstallAppRequest = @@ -1079,14 +1078,14 @@ export class TryCpConductor implements IConductor { ? { bundle: appForAgent.app.bundle, agent_key, - membrane_proofs, + roles_settings, installed_app_id, network_seed, } : { path: appForAgent.app.path, agent_key, - membrane_proofs, + roles_settings, installed_app_id, network_seed, }; diff --git a/ts/src/types.ts b/ts/src/types.ts index 905897ff..ab0bb45c 100644 --- a/ts/src/types.ts +++ b/ts/src/types.ts @@ -18,7 +18,7 @@ import type { ProvisionedCell, RegisterDnaRequest, RoleName, - CallZomeRequestSigned, + RoleSettingsMap, } from "@holochain/client"; /** @@ -145,9 +145,9 @@ export interface AppOptions { */ networkSeed?: string; /** - * Proofs of membership for the hApp. + * Role specific settings or modifiers that will override any settings in the hApp's dna manifest(s). */ - membraneProofs?: Record; + rolesSettings?: RoleSettingsMap; /** * A signal handler for the conductor. */ diff --git a/ts/test/local/conductor.ts b/ts/test/local/conductor.ts index 292418aa..aec720d0 100644 --- a/ts/test/local/conductor.ts +++ b/ts/test/local/conductor.ts @@ -3,8 +3,12 @@ import { AppBundleSource, AppSignal, CellProvisioningStrategy, + CellType, CloneId, + Duration, EntryHash, + fakeAgentPubKey, + ProvisionedCell, RevokeAgentKeyResponse, Signal, SignalCb, @@ -26,6 +30,8 @@ import { stopLocalServices, } from "../../src"; import { FIXTURE_DNA_URL, FIXTURE_HAPP_URL } from "../fixture"; +import { decode } from "@msgpack/msgpack"; +import yaml from "js-yaml"; const ROLE_NAME = "test"; @@ -300,6 +306,80 @@ test("Local Conductor - install app with deferred memproofs", async (t) => { await cleanAllConductors(); }); +test("Local Conductor - install app with roles settings", async (t) => { + const { servicesProcess, signalingServerUrl } = await runLocalServices(); + const conductor = await createConductor(signalingServerUrl); + + const originTime = Date.now(); + const quantumTime: Duration = { + secs: originTime, + nanos: 0, + }; + + const progenitorKey = Uint8Array.from(await fakeAgentPubKey()); + + const app = await conductor.installApp( + { + bundle: { + manifest: { + manifest_version: "1", + name: "app", + roles: [ + { + name: ROLE_NAME, + provisioning: { + strategy: CellProvisioningStrategy.Create, + deferred: false, + }, + dna: { + path: realpathSync(FIXTURE_DNA_URL), + modifiers: { network_seed: "some_seed" }, + }, + }, + ], + membrane_proofs_deferred: true, + }, + resources: {}, + }, + }, + { + rolesSettings: { + [ROLE_NAME]: { + type: "Provisioned", + membrane_proof: new Uint8Array(6), + modifiers: { + network_seed: "hello", + properties: yaml.dump({ progenitor: progenitorKey }), + origin_time: originTime, + quantum_time: quantumTime, + }, + }, + }, + } + ); + + const port = await conductor.attachAppInterface(); + const issued = await conductor + .adminWs() + .issueAppAuthenticationToken({ installed_app_id: app.installed_app_id }); + const appWs = await conductor.connectAppWs(issued.token, port); + + const appInfo = await appWs.appInfo(); + const provisionedCell: ProvisionedCell = + appInfo.cell_info[ROLE_NAME][0][CellType.Provisioned]; + t.equal(provisionedCell.dna_modifiers.network_seed, "hello"); + t.deepEqual( + yaml.load(decode(provisionedCell.dna_modifiers.properties) as string), + { progenitor: progenitorKey } + ); + t.equal(provisionedCell.dna_modifiers.origin_time, originTime); + t.deepEqual(provisionedCell.dna_modifiers.quantum_time, quantumTime); + + await conductor.shutDown(); + await stopLocalServices(servicesProcess); + await cleanAllConductors(); +}); + test("Local Conductor - install and call an app", async (t) => { const { servicesProcess, signalingServerUrl } = await runLocalServices(); const conductor = await createConductor(signalingServerUrl); @@ -478,7 +558,6 @@ test("Local Conductor - create and read an entry using the entry zome", async (t const entryContent = "test-content"; const createEntryHash: EntryHash = await appWs.callZome({ - cap_secret: null, cell_id, zome_name: "coordinator", fn_name: "create", @@ -490,7 +569,6 @@ test("Local Conductor - create and read an entry using the entry zome", async (t t.ok(createdEntryHashB64.startsWith("hCkk")); const readEntryResponse: typeof entryContent = await appWs.callZome({ - cap_secret: null, cell_id, zome_name: "coordinator", fn_name: "read", @@ -545,7 +623,6 @@ test("Local Conductor - clone cell management", async (t) => { zome_name: "coordinator", fn_name: "create", payload: testContent, - cap_secret: null, provenance: agentPubKey, }); @@ -558,7 +635,6 @@ test("Local Conductor - clone cell management", async (t) => { zome_name: "coordinator", fn_name: "read", payload: entryActionHash, - cap_secret: null, provenance: agentPubKey, }), "disabled clone cell cannot be called" @@ -578,7 +654,6 @@ test("Local Conductor - clone cell management", async (t) => { zome_name: "coordinator", fn_name: "read", payload: entryActionHash, - cap_secret: null, provenance: agentPubKey, }, 40000 diff --git a/ts/test/local/scenario.ts b/ts/test/local/scenario.ts index 59384d88..339148e5 100644 --- a/ts/test/local/scenario.ts +++ b/ts/test/local/scenario.ts @@ -2,15 +2,12 @@ import { ActionHash, AppBundleSource, AppSignal, - AppWebsocket, EntryHash, - PreflightResponse, Signal, SignalCb, SignalType, } from "@holochain/client"; import assert from "node:assert/strict"; -import { readFileSync } from "node:fs"; import test from "tape-promise/tape.js"; import { Scenario, dhtSync, getZomeCaller, runScenario } from "../../src"; import { FIXTURE_HAPP_URL } from "../fixture"; @@ -374,8 +371,7 @@ test("Local Scenario - runScenario - call zome by role name", async (t) => { path: FIXTURE_HAPP_URL.pathname, }); - const result = (await alice.appWs.callZome({ - role_name: "test", + const result = (await alice.namedCells.get("test")?.callZome({ zome_name: "coordinator", fn_name: "create", payload: "hello", diff --git a/ts/test/trycp/client.ts b/ts/test/trycp/client.ts index ae7e608a..4762ea59 100644 --- a/ts/test/trycp/client.ts +++ b/ts/test/trycp/client.ts @@ -3,11 +3,7 @@ import { Buffer } from "node:buffer"; import { URL } from "node:url"; import test from "tape-promise/tape.js"; import { _ALLOWED_ORIGIN, enableAndGetAgentApp } from "../../src/common.js"; -import { - createTryCpConductor, - DEFAULT_PARTIAL_PLAYER_CONFIG, - TryCpConductor, -} from "../../src/trycp/index.js"; +import { createTryCpConductor, TryCpConductor } from "../../src/trycp/index.js"; import { TryCpClient } from "../../src/trycp/trycp-client.js"; import { TRYCP_SERVER_HOST, diff --git a/ts/test/trycp/conductor.ts b/ts/test/trycp/conductor.ts index 7bcbe0a7..e3c745f8 100644 --- a/ts/test/trycp/conductor.ts +++ b/ts/test/trycp/conductor.ts @@ -10,6 +10,9 @@ import { SignalType, GrantedFunctionsType, RevokeAgentKeyResponse, + Duration, + fakeAgentPubKey, + ProvisionedCell, } from "@holochain/client"; import assert from "node:assert"; import { Buffer } from "node:buffer"; @@ -26,6 +29,8 @@ import { TryCpPlayer, createTryCpConductor } from "../../src"; import { TRYCP_SERVER_HOST, TRYCP_SERVER_PORT, TryCpServer } from "../../src"; import { TRYCP_SUCCESS_RESPONSE } from "../../src"; import { FIXTURE_DNA_URL, FIXTURE_HAPP_URL } from "../fixture"; +import { decode } from "@msgpack/msgpack"; +import yaml from "js-yaml"; const SERVER_URL = new URL(`ws://${TRYCP_SERVER_HOST}:${TRYCP_SERVER_PORT}`); const ROLE_NAME = "test"; @@ -41,7 +46,6 @@ const ROLE_NAME = "test"; // const appInfo = await conductor.adminWs().installApp({ // path: FIXTURE_HAPP_URL.pathname, // agent_key, -// membrane_proofs: {}, // }); // await conductor // .adminWs() @@ -64,7 +68,6 @@ const ROLE_NAME = "test"; // const appInfo = await conductor.adminWs().installApp({ // path: FIXTURE_HAPP_URL.pathname, // agent_key, -// membrane_proofs: {}, // }); // await conductor // .adminWs() @@ -281,6 +284,86 @@ test("TryCP Conductor - install app with deferred memproofs", async (t) => { await localTryCpServer.stop(); }); +test("TryCP Conductor - install app with roles settings", async (t) => { + const localTryCpServer = await TryCpServer.start(); + const { servicesProcess, signalingServerUrl } = await runLocalServices(); + const client = await TryCpClient.create(SERVER_URL); + client.signalingServerUrl = signalingServerUrl; + const conductor = await createTryCpConductor(client); + const adminWs = conductor.adminWs(); + + const originTime = Date.now(); + const quantumTime: Duration = { + secs: originTime, + nanos: 0, + }; + + const progenitorKey = Uint8Array.from(await fakeAgentPubKey()); + + const app = await conductor.installApp( + { + bundle: { + manifest: { + manifest_version: "1", + name: "app", + roles: [ + { + name: ROLE_NAME, + provisioning: { + strategy: CellProvisioningStrategy.Create, + deferred: false, + }, + dna: { + path: realpathSync(FIXTURE_DNA_URL), + modifiers: { network_seed: "some_seed" }, + }, + }, + ], + membrane_proofs_deferred: true, + }, + resources: {}, + }, + }, + { + rolesSettings: { + [ROLE_NAME]: { + type: "Provisioned", + membrane_proof: new Uint8Array(6), + modifiers: { + network_seed: "hello", + properties: yaml.dump({ progenitor: progenitorKey }), + origin_time: originTime, + quantum_time: quantumTime, + }, + }, + }, + } + ); + + const { port } = await adminWs.attachAppInterface(); + const issued = await adminWs.issueAppAuthenticationToken({ + installed_app_id: app.installed_app_id, + }); + await conductor.connectAppInterface(issued.token, port); + const appWs = await conductor.connectAppWs(issued.token, port); + + const appInfo = await appWs.appInfo(); + assert(appInfo); + const provisionedCell: ProvisionedCell = + appInfo.cell_info[ROLE_NAME][0][CellType.Provisioned]; + t.equal(provisionedCell.dna_modifiers.network_seed, "hello"); + t.deepEqual( + yaml.load(decode(provisionedCell.dna_modifiers.properties) as string), + { progenitor: progenitorKey } + ); + t.equal(provisionedCell.dna_modifiers.origin_time, originTime); + t.deepEqual(provisionedCell.dna_modifiers.quantum_time, quantumTime); + + await stopLocalServices(servicesProcess); + await client.cleanUp(); + await localTryCpServer.stop(); +}); + test("TryCP Conductor - install hApp bundle and access cell by role name", async (t) => { const localTryCpServer = await TryCpServer.start(); const { servicesProcess, signalingServerUrl } = await runLocalServices(); @@ -390,7 +473,6 @@ test("TryCP Conductor - request storage info", async (t) => { const appInfo = await conductor.adminWs().installApp({ path: FIXTURE_HAPP_URL.pathname, agent_key: agentPubKey, - membrane_proofs: {}, }); const storageInfo = await conductor.adminWs().storageInfo(); @@ -422,7 +504,6 @@ test("TryCP Conductor - request network info", async (t) => { path: FIXTURE_HAPP_URL.pathname, agent_key: agentPubKey, network_seed: Date.now().toString(), - membrane_proofs: {}, }); await conductor .adminWs() @@ -505,7 +586,6 @@ test("TryCP Conductor - receive a signal", async (t) => { const appInfo = await conductor.adminWs().installApp({ path: FIXTURE_HAPP_URL.pathname, agent_key: agentPubKey, - membrane_proofs: {}, }); const { port } = await conductor.adminWs().attachAppInterface(); const issued = await conductor.adminWs().issueAppAuthenticationToken({ @@ -563,7 +643,6 @@ test("TryCP Conductor - create and read an entry using the entry zome", async (t const appId = "entry-app"; const appInfo = await conductor.adminWs().installApp({ path: FIXTURE_HAPP_URL.pathname, - membrane_proofs: {}, installed_app_id: appId, agent_key: agentPubKey, }); @@ -680,7 +759,6 @@ test("TryCP Conductor - create and read an entry using the entry zome, 1 conduct path: FIXTURE_HAPP_URL.pathname, installed_app_id: appId1, agent_key: agent1PubKey, - membrane_proofs: {}, }); assert(CellType.Provisioned in appInfo1.cell_info[ROLE_NAME][0]); const cellId1 = @@ -699,7 +777,6 @@ test("TryCP Conductor - create and read an entry using the entry zome, 1 conduct path: FIXTURE_HAPP_URL.pathname, installed_app_id: appId2, agent_key: agent2PubKey, - membrane_proofs: {}, }); assert(CellType.Provisioned in appInfo2.cell_info[ROLE_NAME][0]); const cellId2 = @@ -796,7 +873,6 @@ test("TryCP Conductor - clone cell management", async (t) => { path: FIXTURE_HAPP_URL.pathname, installed_app_id: appId, agent_key: agentPubKey, - membrane_proofs: {}, }); assert(CellType.Provisioned in appInfo.cell_info[ROLE_NAME][0]); const { cell_id } = appInfo.cell_info[ROLE_NAME][0][CellType.Provisioned];