Skip to content

Commit

Permalink
Merge pull request #204 from holochain/restore-zome-call-by-role-name
Browse files Browse the repository at this point in the history
Restore zome call by role name instead of cell id
  • Loading branch information
ThetaSinner authored Apr 29, 2024
2 parents f6b5b3c + 4f855e4 commit f2a2e7f
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
### Changed
### Fixed

## 2024-04-29: v0.16.0-dev.6
### Fixed
- Restored the ability to make a zome call on the app websocket using a role name instead of a cell id.

## 2024-04-27: v0.16.0-dev.5
### Changed
- Update the version of the JS client to v0.17.0-dev.12.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@holochain/tryorama",
"description": "Toolset to manage Holochain conductors and facilitate running test scenarios",
"version": "0.16.0-dev.5",
"version": "0.16.0-dev.6",
"author": "Holochain Foundation",
"license": "MIT",
"keywords": [
Expand Down
22 changes: 14 additions & 8 deletions ts/src/local/conductor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import {
AppBundleSource,
AppWebsocket,
AttachAppInterfaceRequest,
CallZomeRequest,
CallZomeRequestSigned,
encodeHashToBase64,
getSigningCredentials,
InstallAppRequest,
AppAuthenticationToken,
AppCallZomeRequest,
} from "@holochain/client";
import getPort, { portNumbers } from "get-port";
import pick from "lodash/pick.js";
Expand Down Expand Up @@ -317,12 +316,19 @@ export class Conductor implements IConductor {

// set up automatic zome call signing
const callZome = appWs.callZome.bind(appWs);
appWs.callZome = async (
req: CallZomeRequest | CallZomeRequestSigned,
timeout?: number
) => {
if (!getSigningCredentials(req.cell_id)) {
await this.adminWs().authorizeSigningCredentials(req.cell_id);
appWs.callZome = async (req: AppCallZomeRequest, timeout?: number) => {
let cellId;
if ("role_name" in req) {
assert(appWs.cachedAppInfo);
cellId = appWs.getCellIdFromRoleName(
req.role_name,
appWs.cachedAppInfo
);
} else {
cellId = req.cell_id;
}
if (!getSigningCredentials(cellId)) {
await this.adminWs().authorizeSigningCredentials(cellId);
}
return callZome(req, timeout);
};
Expand Down
18 changes: 18 additions & 0 deletions ts/test/local/scenario.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
ActionHash,
AppBundleSource,
AppSignal,
AppSignalCb,
Expand Down Expand Up @@ -278,3 +279,20 @@ test("Local Scenario - pauseUntilDhtEqual - Create multiple entries, read the la

await scenario.cleanUp();
});

test("Local Scenario - runScenario - call zome by role name", async (t) => {
await runScenario(async (scenario: Scenario) => {
const alice = await scenario.addPlayerWithApp({
path: FIXTURE_HAPP_URL.pathname,
});

const result = (await alice.appWs.callZome({
role_name: "test",
zome_name: "coordinator",
fn_name: "create",
payload: "hello",
})) as ActionHash;

t.ok(result);
});
});

0 comments on commit f2a2e7f

Please sign in to comment.