Skip to content

Commit 63a7351

Browse files
committed
chore: update remote storage
1 parent 6776bcb commit 63a7351

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

typescript/packages/common-charm/src/storage/remote.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import type { EntityId, Cancel } from "@commontools/runner";
22
import { log } from "../storage.js";
33
import { type StorageProvider, type StorageValue } from "./base.js";
4-
import type { Entity, JSONValue, MemorySpace } from "@commontools/memory/interface";
4+
import type { Entity, JSONValue, MemorySpace, Protocol } from "@commontools/memory/interface";
55
import * as Memory from "@commontools/memory/consumer";
6+
import * as Principal from "@commontools/memory/principal";
67
import { assert } from "@commontools/memory/fact";
78
import * as Changes from "@commontools/memory/changes";
89
export * from "@commontools/memory/interface";
@@ -32,17 +33,22 @@ interface MemoryState<Space extends MemorySpace = MemorySpace> {
3233
* ed25519 key derived from the sha256 of the "common knowledge".
3334
*/
3435
const HOME = "did:key:z6Mko2qR9b8mbdPnaEKXvcYwdK7iDnRkh8mEcEP2719aCu6P";
36+
3537
/**
3638
* ed25519 key derived from the sha256 of the "common operator".
3739
*/
38-
const AS = "did:key:z6Mkge3xkXc4ksLsf8CtRxunUxcX6dByT4QdWCVEHbUJ8YVn";
40+
const AS =
41+
Principal.ED25519Signer.fromString<"did:key:z6Mkge3xkXc4ksLsf8CtRxunUxcX6dByT4QdWCVEHbUJ8YVn">(
42+
"MgCZHlm5ODrbwDGXGIgBhqp2HmKj3dcxxyaqkopec6vK7xO0BIHsZlqE1qjfTHd7TN9Xcw59xgzDElFlwH2OmKQOO0Gk=",
43+
);
44+
3945
export class RemoteStorageProvider implements StorageProvider {
4046
connection: WebSocket | null = null;
4147
address: URL;
4248
workspace: MemorySpace;
4349
the: string;
4450
state: Map<MemorySpace, MemoryState> = new Map();
45-
session: Memory.MemorySession;
51+
session: Memory.MemorySession<MemorySpace>;
4652

4753
/**
4854
* queue that holds commands that we read from the session, but could not
@@ -61,7 +67,7 @@ export class RemoteStorageProvider implements StorageProvider {
6167
the = "application/json",
6268
}: {
6369
address: URL;
64-
as?: Memory.DID;
70+
as?: Memory.Signer;
6571
space?: MemorySpace;
6672
the?: string;
6773
}) {
@@ -377,7 +383,7 @@ export interface Subscriber {
377383
class Query<Space extends MemorySpace> {
378384
reader: ReadableStreamDefaultReader;
379385
constructor(
380-
public query: Memory.QueryView<Space>,
386+
public query: Memory.QueryView<Space, Protocol<Space>>,
381387
public subscribers: Set<Subscriber> = new Set(),
382388
) {
383389
this.reader = query.subscribe().getReader();

typescript/packages/common-memory/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"./fact": "./fact.ts",
99
"./transaction": "./transaction.ts",
1010
"./changes": "./changes.ts",
11-
"./commit": "./commit.ts"
11+
"./commit": "./commit.ts",
12+
"./principal": "./principal.ts"
1213
},
1314
"dependencies": {
1415
"merkle-reference": "^2.0.1",

0 commit comments

Comments
 (0)