Skip to content

Commit

Permalink
Fixed payload builder to consume meta
Browse files Browse the repository at this point in the history
  • Loading branch information
arietrouw committed Jan 26, 2024
1 parent 0fe7537 commit 826d4c0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class BoundWitnessValidator<T extends BoundWitness<{ schema: string }> =

async signatures(): Promise<Error[]> {
return [
...validateArraysSameLength(this.obj.$meta?.signatures ?? [], this.obj.addresses ?? [], 'Length mismatch: address/_signature'),
...validateArraysSameLength(this.obj.$meta?.signatures ?? [], this.obj.addresses ?? [], 'Length mismatch: address/signature'),
...(
await Promise.all(
this.obj.addresses?.map<Promise<Error[]>>(async (address, index) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ export class PayloadBuilder<T extends Payload = Payload<AnyObject>> {
}

static async build<T extends Payload>(payload: T) {
const builder = new PayloadBuilder<T>({ schema: payload.schema })
builder.fields(payload)
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { schema, $hash, $meta, ...fields } = payload as WithMeta<T>
const builder = new PayloadBuilder<T>({ fields: fields as T, meta: $meta, schema: payload.schema })
return await builder.build()
}

Expand Down Expand Up @@ -117,8 +118,8 @@ export class PayloadBuilder<T extends Payload = Payload<AnyObject>> {
return result
}

$meta(fields?: JsonObject) {
this._$meta = fields
$meta(meta?: JsonObject) {
this._$meta = meta
return this
}

Expand Down

0 comments on commit 826d4c0

Please sign in to comment.