File tree Expand file tree Collapse file tree 3 files changed +10
-6
lines changed
hypergraph/src/space-events Expand file tree Collapse file tree 3 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -354,9 +354,13 @@ export function HypergraphAppProvider({
354354 let state : SpaceEvents . SpaceState | undefined = undefined ;
355355
356356 for ( const event of response . events ) {
357- const applyEventResult = await Effect . runPromiseExit ( SpaceEvents . applyEvent ( { state : undefined , event } ) ) ;
357+ // Not sure why but type inference doesn't work here
358+ const applyEventResult : Exit . Exit < SpaceEvents . SpaceState , SpaceEvents . ApplyError > =
359+ await Effect . runPromiseExit ( SpaceEvents . applyEvent ( { state, event } ) ) ;
358360 if ( Exit . isSuccess ( applyEventResult ) ) {
359361 state = applyEventResult . value ;
362+ } else {
363+ console . log ( 'Failed to apply event' , applyEventResult ) ;
360364 }
361365 }
362366
Original file line number Diff line number Diff line change 11import { secp256k1 } from '@noble/curves/secp256k1' ;
22import { sha256 } from '@noble/hashes/sha256' ;
33import { Effect , Schema } from 'effect' ;
4- import type { ParseError } from 'effect/ParseResult' ;
54import { canonicalize , stringToUint8Array } from '../utils/index.js' ;
65import { hashEvent } from './hash-event.js' ;
76import {
7+ type ApplyError ,
88 InvalidEventError ,
99 SpaceEvent ,
1010 type SpaceInvitation ,
@@ -20,10 +20,7 @@ type Params = {
2020
2121const decodeSpaceEvent = Schema . decodeUnknownEither ( SpaceEvent ) ;
2222
23- export const applyEvent = ( {
24- state,
25- event : rawEvent ,
26- } : Params ) : Effect . Effect < SpaceState , ParseError | VerifySignatureError | InvalidEventError > => {
23+ export const applyEvent = ( { state, event : rawEvent } : Params ) : Effect . Effect < SpaceState , ApplyError > => {
2724 const decodedEvent = decodeSpaceEvent ( rawEvent ) ;
2825 if ( decodedEvent . _tag === 'Left' ) {
2926 return decodedEvent . left ;
Original file line number Diff line number Diff line change 1+ import type { ParseError } from 'effect/ParseResult' ;
12import * as Schema from 'effect/Schema' ;
23import { SignatureWithRecovery } from '../types.js' ;
34
@@ -101,3 +102,5 @@ export class VerifySignatureError {
101102export class InvalidEventError {
102103 readonly _tag = 'InvalidEventError' ;
103104}
105+
106+ export type ApplyError = ParseError | VerifySignatureError | InvalidEventError ;
You can’t perform that action at this time.
0 commit comments