Skip to content

Commit

Permalink
fix(didRegistry): update asset document
Browse files Browse the repository at this point in the history
  • Loading branch information
JGiter committed Jan 18, 2022
1 parent a0224b5 commit f219a5e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
36 changes: 36 additions & 0 deletions e2e/cacheClient.e2e.ts
@@ -0,0 +1,36 @@
import { initWithPrivateKeySigner, setCacheConfig } from "../src";

const rpcUrl = "https://volta-rpc.energyweb.org";
const privateKey = "";

describe.skip("Cache client", () => {
test("Asset owner should be able to update asset document", async () => {
setCacheConfig(73799, {
url: "https://identitycache-dev.energyweb.org/v1",
cacheServerSupportsAuth: true,
});

const metadata = { meterId: "SolarM" };

const { connectToCacheServer } = await initWithPrivateKeySigner(privateKey, rpcUrl);
const { connectToDidRegistry, assetsService } = await connectToCacheServer();
const { claimsService, didRegistry } = await connectToDidRegistry();

const assetAddress = await assetsService.registerAsset();
const assetDid = `did:ethr:volta:${assetAddress}`;

const claimUrl = await claimsService.createSelfSignedClaim({
data: metadata,
subject: assetDid,
});

await new Promise((r) => setTimeout(r, 30_000));

const assetDoc = await didRegistry.getDidDocument({ did: assetDid, includeClaims: true });
expect(
assetDoc.service.some(
(s) => s.serviceEndpoint === claimUrl && expect(s).toEqual(expect.objectContaining(metadata)),
),
);
}, 120000);
});
2 changes: 1 addition & 1 deletion src/modules/didRegistry/didRegistry.service.ts
Expand Up @@ -193,7 +193,7 @@ export class DidRegistry {
{ address: didContractAddress },
addressOf(assetDID)
);
const update = await operator.update(did, didAttribute, updateData);
const update = await operator.update(assetDID, didAttribute, updateData);

return Boolean(update);
}
Expand Down

0 comments on commit f219a5e

Please sign in to comment.