Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into drogus/fix-identity
Browse files Browse the repository at this point in the history
  • Loading branch information
drogus committed Oct 12, 2023
2 parents 7f86add + f22b6fd commit 8cdab32
Show file tree
Hide file tree
Showing 10 changed files with 1,060 additions and 212 deletions.
17 changes: 9 additions & 8 deletions examples/quickstart/client/src/module_bindings/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
AlgebraicValue,
ReducerEvent,
Identity,
Address,
} from "@clockworklabs/spacetimedb-sdk";

export class Message extends IDatabaseTable {
Expand All @@ -36,7 +37,7 @@ export class Message extends IDatabaseTable {
public static getAlgebraicType(): AlgebraicType {
return AlgebraicType.createProductType([
new ProductTypeElement(
"Sender",
"sender",
AlgebraicType.createProductType([
new ProductTypeElement(
"__identity_bytes",
Expand All @@ -47,24 +48,24 @@ export class Message extends IDatabaseTable {
])
),
new ProductTypeElement(
"Sent",
AlgebraicType.createPrimitiveType(BuiltinType.Type.I64)
"sent",
AlgebraicType.createPrimitiveType(BuiltinType.Type.U64)
),
new ProductTypeElement(
"Text",
"text",
AlgebraicType.createPrimitiveType(BuiltinType.Type.String)
),
]);
}

public static fromValue(value: AlgebraicValue): Message {
let productValue = value.asProductValue();
let __Sender = new Identity(
let __sender = new Identity(
productValue.elements[0].asProductValue().elements[0].asBytes()
);
let __Sent = productValue.elements[1].asNumber();
let __Text = productValue.elements[2].asString();
return new this(__Sender, __Sent, __Text);
let __sent = productValue.elements[1].asNumber();
let __text = productValue.elements[2].asString();
return new this(__sender, __sent, __text);
}

public static count(): number {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
SumTypeVariant,
Serializer,
Identity,
Address,
ReducerEvent,
} from "@clockworklabs/spacetimedb-sdk";

Expand All @@ -25,7 +26,7 @@ export class SendMessageReducer {
BuiltinType.Type.String
);
serializer.write(_textType, _text);
__SPACETIMEDB__.spacetimeDBClient.call("SendMessage", serializer);
__SPACETIMEDB__.spacetimeDBClient.call("send_message", serializer);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
SumTypeVariant,
Serializer,
Identity,
Address,
ReducerEvent,
} from "@clockworklabs/spacetimedb-sdk";

Expand All @@ -25,7 +26,7 @@ export class SetNameReducer {
BuiltinType.Type.String
);
serializer.write(_nameType, _name);
__SPACETIMEDB__.spacetimeDBClient.call("SetName", serializer);
__SPACETIMEDB__.spacetimeDBClient.call("set_name", serializer);
}
}

Expand Down
15 changes: 8 additions & 7 deletions examples/quickstart/client/src/module_bindings/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
AlgebraicValue,
ReducerEvent,
Identity,
Address,
} from "@clockworklabs/spacetimedb-sdk";

export class User extends IDatabaseTable {
Expand Down Expand Up @@ -42,7 +43,7 @@ export class User extends IDatabaseTable {
public static getAlgebraicType(): AlgebraicType {
return AlgebraicType.createProductType([
new ProductTypeElement(
"Identity",
"identity",
AlgebraicType.createProductType([
new ProductTypeElement(
"__identity_bytes",
Expand All @@ -53,7 +54,7 @@ export class User extends IDatabaseTable {
])
),
new ProductTypeElement(
"Name",
"name",
AlgebraicType.createSumType([
new SumTypeVariant(
"some",
Expand All @@ -63,23 +64,23 @@ export class User extends IDatabaseTable {
])
),
new ProductTypeElement(
"Online",
"online",
AlgebraicType.createPrimitiveType(BuiltinType.Type.Bool)
),
]);
}

public static fromValue(value: AlgebraicValue): User {
let productValue = value.asProductValue();
let __Identity = new Identity(
let __identity = new Identity(
productValue.elements[0].asProductValue().elements[0].asBytes()
);
let __Name =
let __name =
productValue.elements[1].asSumValue().tag == 1
? null
: productValue.elements[1].asSumValue().value.asString();
let __Online = productValue.elements[2].asBoolean();
return new this(__Identity, __Name, __Online);
let __online = productValue.elements[2].asBoolean();
return new this(__identity, __name, __online);
}

public static count(): number {
Expand Down
Loading

0 comments on commit 8cdab32

Please sign in to comment.