Skip to content

Commit

Permalink
Use BW timestamp or generate
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelBCarter committed Apr 10, 2024
1 parent 2b13779 commit ee3b650
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ export const payloadToDbRepresentation = async <T extends Payload>(payload: T):
return { ...fields, _$hash: $hash, _$meta: $meta, _hash, _timestamp: Date.now() } as unknown as PayloadWithMongoMeta<T>
}

export const boundWitnessToDbRepresentation = async <T extends BoundWitness>(payload: T): Promise<BoundWitnessMongoMeta<T>> => {
const built = await PayloadBuilder.build(payload)
export const boundWitnessToDbRepresentation = async <T extends BoundWitness>(bw: T): Promise<BoundWitnessMongoMeta<T>> => {
const built = await PayloadBuilder.build(bw)
const _hash = await PayloadBuilder.hash(built)
const { $hash, $meta, ...fields } = built
return { ...fields, _$hash: $hash, _$meta: $meta, _hash, _timestamp: Date.now() } as unknown as BoundWitnessMongoMeta<T>
return { ...fields, _$hash: $hash, _$meta: $meta, _hash, _timestamp: bw.timestamp ?? Date.now() } as unknown as BoundWitnessMongoMeta<T>
}

export const toDbRepresentation = <T extends Payload | BoundWitness>(value: T) => {
Expand Down

0 comments on commit ee3b650

Please sign in to comment.