Skip to content

Commit

Permalink
Fix codecs (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
Carminepo2 authored Aug 7, 2024
1 parent f7d3593 commit 0578394
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/agreement/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function encodeOutboundAgreementEvent(event: AgreementEvent): string {
return JSON.stringify({
event_version: event.event_version,
type: event.type,
data: agreementEventToBinaryData(event),
data: Buffer.from(agreementEventToBinaryData(event)).toString("hex"),
stream_id: event.stream_id,
version: event.version,
timestamp: event.timestamp,
Expand Down
2 changes: 1 addition & 1 deletion src/eservice/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function encodeOutboundEServiceEvent(event: EServiceEvent): string {
return JSON.stringify({
event_version: event.event_version,
type: event.type,
data: eServiceEventToBinaryData(event),
data: Buffer.from(eServiceEventToBinaryData(event)).toString("hex"),
stream_id: event.stream_id,
version: event.version,
timestamp: event.timestamp,
Expand Down
2 changes: 1 addition & 1 deletion src/purpose/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function encodeOutboundPurposeEvent(event: PurposeEvent): string {
return JSON.stringify({
event_version: event.event_version,
type: event.type,
data: purposeEventToBinaryData(event),
data: Buffer.from(purposeEventToBinaryData(event)).toString("hex"),
stream_id: event.stream_id,
version: event.version,
timestamp: event.timestamp,
Expand Down
2 changes: 1 addition & 1 deletion src/tenant/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function encodeOutboundTenantEvent(event: TenantEvent): string {
return JSON.stringify({
event_version: event.event_version,
type: event.type,
data: tenantEventToBinaryData(event),
data: Buffer.from(tenantEventToBinaryData(event)).toString("hex"),
stream_id: event.stream_id,
version: event.version,
timestamp: event.timestamp,
Expand Down
6 changes: 1 addition & 5 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,5 @@ export const VersionedEvent = z.discriminatedUnion("event_version", [
export function protobufDecoder<I extends object>(
decoder: MessageType<I>
): ZodTransformer<ZodAny, I> {
return z
.any()
.transform((v) =>
decoder.fromBinary(Buffer.from(Object.values(v) as never, "hex"))
);
return z.any().transform((v) => decoder.fromBinary(Buffer.from(v, "hex")));
}

0 comments on commit 0578394

Please sign in to comment.