@xyo-network/boundwitness-model 3.10.3 → 3.10.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -36,7 +36,8 @@ var asOptionalBoundWitness = AsObjectFactory.createOptional(isBoundWitness);
36
36
  var isBoundWitnessWithStorageMeta = (value) => isPayloadOfSchemaType(BoundWitnessSchema)(value) && isStorageMeta(value);
37
37
  var asBoundWitnessWithStorageMeta = AsObjectFactory.createOptional(isBoundWitnessWithStorageMeta);
38
38
  var asOptionalBoundWitnessWithStorageMeta = AsObjectFactory.createOptional(isBoundWitnessWithStorageMeta);
39
- var isUnsignedBoundWitness = (value) => isPayloadOfSchemaType(BoundWitnessSchema)(value);
39
+ var isSigned = (value) => isBoundWitness(value) && value.$signatures.length === value.addresses.length && value.addresses.length > 0;
40
+ var isUnsigned = (value) => isBoundWitness(value) && !isSigned(value);
40
41
 
41
42
  // src/QueryBoundWitness.ts
42
43
  import { isStorageMeta as isStorageMeta2 } from "@xyo-network/payload-model";
@@ -55,7 +56,8 @@ export {
55
56
  isBoundWitnessWithStorageMeta,
56
57
  isQueryBoundWitness,
57
58
  isQueryBoundWitnessWithStorageMeta,
58
- isUnsignedBoundWitness,
59
+ isSigned,
60
+ isUnsigned,
59
61
  notBoundWitness
60
62
  };
61
63
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/BoundWitness/BoundWitness.ts","../../src/BoundWitness/BoundWitnessJsonSchema.ts","../../src/BoundWitness/BoundWitnessSchema.ts","../../src/isBoundWitness.ts","../../src/QueryBoundWitness.ts"],"sourcesContent":["import type {\n Address, Hash, Hex,\n} from '@xylabs/hex'\nimport type { EmptyObject, JsonObject } from '@xylabs/object'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\n\nimport type { BoundWitnessSchema } from './BoundWitnessSchema.ts'\n\nexport interface BoundWitnessRequiredFields {\n /** @field Array of signatures by the accounts that are listed in addresses */\n addresses: Address[]\n payload_hashes: Hash[]\n payload_schemas: Schema[]\n previous_hashes: (Hash | null)[]\n}\n\nexport interface BoundWitnessMeta {\n /**\n * @field The address to which the query is directed\n */\n $destination?: Address\n /**\n * @field The query that initiated the bound witness\n */\n $sourceQuery?: Hash\n}\n\nexport interface BoundWitnessBlockField {\n /** @field sequential number (if this boundwitness is part of a multi-party chain) */\n block: number\n}\n\nexport interface BoundWitnessChainField {\n /** @field unique id of a multi-party chain (usually staking contract address) */\n chain: Hex\n}\n\nexport interface BoundWitnessOptionalFields extends Partial<BoundWitnessBlockField>, Partial<BoundWitnessChainField> {\n root: Hash\n}\n\nexport interface BoundWitnessFields extends BoundWitnessRequiredFields, Partial<BoundWitnessOptionalFields> {}\n\nexport type UnsignedBoundWitness<T extends Payload | EmptyObject | void = void> = Payload<\n T extends void ? BoundWitnessFields : BoundWitnessFields & T,\n T extends void ? BoundWitnessSchema\n : T extends Payload ? T['schema']\n : BoundWitnessSchema\n> & BoundWitnessMeta\n\nexport type Signed<T> = T & {\n $signatures: Hex[]\n}\n\nexport type WithBlock = BoundWitness & BoundWitnessBlockField\n\nexport const hasBlock = (bw: BoundWitness): bw is WithBlock => bw.block !== undefined && typeof bw.block === 'string'\nexport const asBlock = (bw: BoundWitness): WithBlock => bw as WithBlock\n\nexport type BoundWitness<T extends Payload | EmptyObject | void = void> = Signed<UnsignedBoundWitness<T>>\n\nexport type AnyBoundWitness = BoundWitness<JsonObject>\n","// Should type as JSONSchemaType<BoundWitness> once ajv/eslint issue is fixed\n// https://github.com/microsoft/TypeScript/issues/44851\n\nexport const BoundWitnessJsonSchema = () => {\n return {\n $id: 'https://schemas.xyo.network/2.0/boundwitness',\n additionalProperties: false,\n properties: {\n addresses: { items: { type: 'string' }, type: 'array' },\n payload_hashes: { items: { type: 'string' }, type: 'array' },\n payload_schemas: { items: { type: 'string' }, type: 'array' },\n previous_hashes: { items: { nullable: true, type: 'string' }, type: 'array' },\n schema: { type: 'string' },\n },\n required: ['addresses', 'payload_hashes', 'payload_schemas', 'previous_hashes', 'schema'],\n type: 'object',\n }\n}\n","export const BoundWitnessSchema = 'network.xyo.boundwitness' as const\nexport type BoundWitnessSchema = typeof BoundWitnessSchema\n","import { AsObjectFactory } from '@xylabs/object'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport {\n isPayloadOfSchemaType, isStorageMeta, notPayloadOfSchemaType,\n} from '@xyo-network/payload-model'\n\nimport type { BoundWitness, UnsignedBoundWitness } from './BoundWitness/index.ts'\nimport { BoundWitnessSchema } from './BoundWitness/index.ts'\n\nexport const isBoundWitness = (value: unknown): value is BoundWitness => isPayloadOfSchemaType<BoundWitness>(BoundWitnessSchema)(value)\n\nexport const notBoundWitness = notPayloadOfSchemaType<BoundWitness>(BoundWitnessSchema)\n\n// TODO: Use AsObjectFactory here to match standard pattern\n// TODO: Other as identity functions throw if not valid, this one returns undefined with is more of a asOptional behavior\nexport const asBoundWitness = <T extends BoundWitness<{ schema: string }> = BoundWitness>(payload?: unknown) =>\n isBoundWitness(payload) ? (payload as T) : undefined\n\nexport const asOptionalBoundWitness = AsObjectFactory.createOptional<BoundWitness>(isBoundWitness)\n\nexport const isBoundWitnessWithStorageMeta = (value: unknown): value is WithStorageMeta<BoundWitness> =>\n isPayloadOfSchemaType<BoundWitness>(BoundWitnessSchema)(value) && isStorageMeta(value)\nexport const asBoundWitnessWithStorageMeta = AsObjectFactory.createOptional<WithStorageMeta<BoundWitness>>(isBoundWitnessWithStorageMeta)\nexport const asOptionalBoundWitnessWithStorageMeta = AsObjectFactory.createOptional<WithStorageMeta<BoundWitness>>(isBoundWitnessWithStorageMeta)\n\nexport const isUnsignedBoundWitness = (value: unknown): value is UnsignedBoundWitness =>\n isPayloadOfSchemaType<UnsignedBoundWitness>(BoundWitnessSchema)(value)\n","import type { Hash } from '@xylabs/hex'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport { isStorageMeta } from '@xyo-network/payload-model'\n\nimport type { BoundWitness } from './BoundWitness/index.ts'\nimport { isBoundWitness } from './isBoundWitness.ts'\n\nexport type QueryBoundWitnessFields = {\n error_hashes?: Hash[]\n query: Hash\n}\n\nexport type UnsignedQueryBoundWitness = BoundWitness<QueryBoundWitnessFields>\n\n// eslint-disable-next-line sonarjs/redundant-type-aliases\nexport type QueryBoundWitness = UnsignedQueryBoundWitness\n\nexport const isQueryBoundWitness = (x?: unknown): x is QueryBoundWitness => isBoundWitness(x) && (x as QueryBoundWitness)?.query !== undefined\nexport const isQueryBoundWitnessWithStorageMeta = (x?: unknown): x is WithStorageMeta<QueryBoundWitness> => isQueryBoundWitness(x) && isStorageMeta(x)\n"],"mappings":";AAwDO,IAAM,WAAW,CAAC,OAAsC,GAAG,UAAU,UAAa,OAAO,GAAG,UAAU;AACtG,IAAM,UAAU,CAAC,OAAgC;;;ACtDjD,IAAM,yBAAyB,MAAM;AAC1C,SAAO;AAAA,IACL,KAAK;AAAA,IACL,sBAAsB;AAAA,IACtB,YAAY;AAAA,MACV,WAAW,EAAE,OAAO,EAAE,MAAM,SAAS,GAAG,MAAM,QAAQ;AAAA,MACtD,gBAAgB,EAAE,OAAO,EAAE,MAAM,SAAS,GAAG,MAAM,QAAQ;AAAA,MAC3D,iBAAiB,EAAE,OAAO,EAAE,MAAM,SAAS,GAAG,MAAM,QAAQ;AAAA,MAC5D,iBAAiB,EAAE,OAAO,EAAE,UAAU,MAAM,MAAM,SAAS,GAAG,MAAM,QAAQ;AAAA,MAC5E,QAAQ,EAAE,MAAM,SAAS;AAAA,IAC3B;AAAA,IACA,UAAU,CAAC,aAAa,kBAAkB,mBAAmB,mBAAmB,QAAQ;AAAA,IACxF,MAAM;AAAA,EACR;AACF;;;ACjBO,IAAM,qBAAqB;;;ACAlC,SAAS,uBAAuB;AAEhC;AAAA,EACE;AAAA,EAAuB;AAAA,EAAe;AAAA,OACjC;AAKA,IAAM,iBAAiB,CAAC,UAA0C,sBAAoC,kBAAkB,EAAE,KAAK;AAE/H,IAAM,kBAAkB,uBAAqC,kBAAkB;AAI/E,IAAM,iBAAiB,CAA4D,YACxF,eAAe,OAAO,IAAK,UAAgB;AAEtC,IAAM,yBAAyB,gBAAgB,eAA6B,cAAc;AAE1F,IAAM,gCAAgC,CAAC,UAC5C,sBAAoC,kBAAkB,EAAE,KAAK,KAAK,cAAc,KAAK;AAChF,IAAM,gCAAgC,gBAAgB,eAA8C,6BAA6B;AACjI,IAAM,wCAAwC,gBAAgB,eAA8C,6BAA6B;AAEzI,IAAM,yBAAyB,CAAC,UACrC,sBAA4C,kBAAkB,EAAE,KAAK;;;ACxBvE,SAAS,iBAAAA,sBAAqB;AAevB,IAAM,sBAAsB,CAAC,MAAwC,eAAe,CAAC,KAAM,GAAyB,UAAU;AAC9H,IAAM,qCAAqC,CAAC,MAAyD,oBAAoB,CAAC,KAAKC,eAAc,CAAC;","names":["isStorageMeta","isStorageMeta"]}
1
+ {"version":3,"sources":["../../src/BoundWitness/BoundWitness.ts","../../src/BoundWitness/BoundWitnessJsonSchema.ts","../../src/BoundWitness/BoundWitnessSchema.ts","../../src/isBoundWitness.ts","../../src/QueryBoundWitness.ts"],"sourcesContent":["import type {\n Address, Hash, Hex,\n} from '@xylabs/hex'\nimport type { EmptyObject, JsonObject } from '@xylabs/object'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\n\nimport type { BoundWitnessSchema } from './BoundWitnessSchema.ts'\n\nexport interface BoundWitnessRequiredFields {\n /** @field Array of signatures by the accounts that are listed in addresses */\n addresses: Address[]\n payload_hashes: Hash[]\n payload_schemas: Schema[]\n previous_hashes: (Hash | null)[]\n}\n\nexport interface BoundWitnessMeta {\n /**\n * @field The address to which the query is directed\n */\n $destination?: Address\n /**\n * @field The query that initiated the bound witness\n */\n $sourceQuery?: Hash\n}\n\nexport interface BoundWitnessBlockField {\n /** @field sequential number (if this boundwitness is part of a multi-party chain) */\n block: number\n}\n\nexport interface BoundWitnessChainField {\n /** @field unique id of a multi-party chain (usually staking contract address) */\n chain: Hex\n}\n\nexport interface BoundWitnessOptionalFields extends Partial<BoundWitnessBlockField>, Partial<BoundWitnessChainField> {\n root: Hash\n}\n\nexport interface BoundWitnessFields extends BoundWitnessRequiredFields, Partial<BoundWitnessOptionalFields> {}\n\nexport type UnsignedBoundWitness<T extends EmptyObject | void = void> = Payload<\n T extends void ? BoundWitnessFields : BoundWitnessFields & T,\n BoundWitnessSchema\n> & BoundWitnessMeta\n\nexport type Signed<T extends UnsignedBoundWitness = UnsignedBoundWitness> = T & {\n $signatures: Hex[]\n}\n\nexport type SignedBoundWitness = Signed<UnsignedBoundWitness>\n\nexport type WithBlock = BoundWitness & BoundWitnessBlockField\n\nexport const hasBlock = (bw: BoundWitness): bw is WithBlock => bw.block !== undefined && typeof bw.block === 'string'\nexport const asBlock = (bw: BoundWitness): WithBlock => bw as WithBlock\n\nexport type BoundWitness<T extends Payload | EmptyObject | void = void> = Signed<UnsignedBoundWitness<T>>\n\nexport type AnyBoundWitness = BoundWitness<JsonObject>\n","// Should type as JSONSchemaType<BoundWitness> once ajv/eslint issue is fixed\n// https://github.com/microsoft/TypeScript/issues/44851\n\nexport const BoundWitnessJsonSchema = () => {\n return {\n $id: 'https://schemas.xyo.network/2.0/boundwitness',\n additionalProperties: false,\n properties: {\n addresses: { items: { type: 'string' }, type: 'array' },\n payload_hashes: { items: { type: 'string' }, type: 'array' },\n payload_schemas: { items: { type: 'string' }, type: 'array' },\n previous_hashes: { items: { nullable: true, type: 'string' }, type: 'array' },\n schema: { type: 'string' },\n },\n required: ['addresses', 'payload_hashes', 'payload_schemas', 'previous_hashes', 'schema'],\n type: 'object',\n }\n}\n","export const BoundWitnessSchema = 'network.xyo.boundwitness' as const\nexport type BoundWitnessSchema = typeof BoundWitnessSchema\n","import { AsObjectFactory } from '@xylabs/object'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport {\n isPayloadOfSchemaType, isStorageMeta, notPayloadOfSchemaType,\n} from '@xyo-network/payload-model'\n\nimport type {\n BoundWitness, Signed, UnsignedBoundWitness,\n} from './BoundWitness/index.ts'\nimport { BoundWitnessSchema } from './BoundWitness/index.ts'\n\nexport const isBoundWitness = (value: unknown): value is BoundWitness => isPayloadOfSchemaType<BoundWitness>(BoundWitnessSchema)(value)\n\nexport const notBoundWitness = notPayloadOfSchemaType<BoundWitness>(BoundWitnessSchema)\n\n// TODO: Use AsObjectFactory here to match standard pattern\n// TODO: Other as identity functions throw if not valid, this one returns undefined with is more of a asOptional behavior\nexport const asBoundWitness = <T extends BoundWitness<{ schema: string }> = BoundWitness>(payload?: unknown) =>\n isBoundWitness(payload) ? (payload as T) : undefined\n\nexport const asOptionalBoundWitness = AsObjectFactory.createOptional<BoundWitness>(isBoundWitness)\n\nexport const isBoundWitnessWithStorageMeta = (value: unknown): value is WithStorageMeta<BoundWitness> =>\n isPayloadOfSchemaType<BoundWitness>(BoundWitnessSchema)(value) && isStorageMeta(value)\nexport const asBoundWitnessWithStorageMeta = AsObjectFactory.createOptional<WithStorageMeta<BoundWitness>>(isBoundWitnessWithStorageMeta)\nexport const asOptionalBoundWitnessWithStorageMeta = AsObjectFactory.createOptional<WithStorageMeta<BoundWitness>>(isBoundWitnessWithStorageMeta)\n\nexport const isSigned = (value: unknown): value is Signed =>\n isBoundWitness(value)\n && value.$signatures.length === value.addresses.length\n && value.addresses.length > 0\n\nexport const isUnsigned = (value: unknown): value is UnsignedBoundWitness =>\n isBoundWitness(value) && !isSigned(value)\n","import type { Hash } from '@xylabs/hex'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport { isStorageMeta } from '@xyo-network/payload-model'\n\nimport type { BoundWitness } from './BoundWitness/index.ts'\nimport { isBoundWitness } from './isBoundWitness.ts'\n\nexport type QueryBoundWitnessFields = {\n error_hashes?: Hash[]\n query: Hash\n}\n\nexport type UnsignedQueryBoundWitness = BoundWitness<QueryBoundWitnessFields>\n\n// eslint-disable-next-line sonarjs/redundant-type-aliases\nexport type QueryBoundWitness = UnsignedQueryBoundWitness\n\nexport const isQueryBoundWitness = (x?: unknown): x is QueryBoundWitness => isBoundWitness(x) && (x as QueryBoundWitness)?.query !== undefined\nexport const isQueryBoundWitnessWithStorageMeta = (x?: unknown): x is WithStorageMeta<QueryBoundWitness> => isQueryBoundWitness(x) && isStorageMeta(x)\n"],"mappings":";AAwDO,IAAM,WAAW,CAAC,OAAsC,GAAG,UAAU,UAAa,OAAO,GAAG,UAAU;AACtG,IAAM,UAAU,CAAC,OAAgC;;;ACtDjD,IAAM,yBAAyB,MAAM;AAC1C,SAAO;AAAA,IACL,KAAK;AAAA,IACL,sBAAsB;AAAA,IACtB,YAAY;AAAA,MACV,WAAW,EAAE,OAAO,EAAE,MAAM,SAAS,GAAG,MAAM,QAAQ;AAAA,MACtD,gBAAgB,EAAE,OAAO,EAAE,MAAM,SAAS,GAAG,MAAM,QAAQ;AAAA,MAC3D,iBAAiB,EAAE,OAAO,EAAE,MAAM,SAAS,GAAG,MAAM,QAAQ;AAAA,MAC5D,iBAAiB,EAAE,OAAO,EAAE,UAAU,MAAM,MAAM,SAAS,GAAG,MAAM,QAAQ;AAAA,MAC5E,QAAQ,EAAE,MAAM,SAAS;AAAA,IAC3B;AAAA,IACA,UAAU,CAAC,aAAa,kBAAkB,mBAAmB,mBAAmB,QAAQ;AAAA,IACxF,MAAM;AAAA,EACR;AACF;;;ACjBO,IAAM,qBAAqB;;;ACAlC,SAAS,uBAAuB;AAEhC;AAAA,EACE;AAAA,EAAuB;AAAA,EAAe;AAAA,OACjC;AAOA,IAAM,iBAAiB,CAAC,UAA0C,sBAAoC,kBAAkB,EAAE,KAAK;AAE/H,IAAM,kBAAkB,uBAAqC,kBAAkB;AAI/E,IAAM,iBAAiB,CAA4D,YACxF,eAAe,OAAO,IAAK,UAAgB;AAEtC,IAAM,yBAAyB,gBAAgB,eAA6B,cAAc;AAE1F,IAAM,gCAAgC,CAAC,UAC5C,sBAAoC,kBAAkB,EAAE,KAAK,KAAK,cAAc,KAAK;AAChF,IAAM,gCAAgC,gBAAgB,eAA8C,6BAA6B;AACjI,IAAM,wCAAwC,gBAAgB,eAA8C,6BAA6B;AAEzI,IAAM,WAAW,CAAC,UACvB,eAAe,KAAK,KACjB,MAAM,YAAY,WAAW,MAAM,UAAU,UAC7C,MAAM,UAAU,SAAS;AAEvB,IAAM,aAAa,CAAC,UACzB,eAAe,KAAK,KAAK,CAAC,SAAS,KAAK;;;AC/B1C,SAAS,iBAAAA,sBAAqB;AAevB,IAAM,sBAAsB,CAAC,MAAwC,eAAe,CAAC,KAAM,GAAyB,UAAU;AAC9H,IAAM,qCAAqC,CAAC,MAAyD,oBAAoB,CAAC,KAAKC,eAAc,CAAC;","names":["isStorageMeta","isStorageMeta"]}
@@ -36,7 +36,8 @@ var asOptionalBoundWitness = AsObjectFactory.createOptional(isBoundWitness);
36
36
  var isBoundWitnessWithStorageMeta = (value) => isPayloadOfSchemaType(BoundWitnessSchema)(value) && isStorageMeta(value);
37
37
  var asBoundWitnessWithStorageMeta = AsObjectFactory.createOptional(isBoundWitnessWithStorageMeta);
38
38
  var asOptionalBoundWitnessWithStorageMeta = AsObjectFactory.createOptional(isBoundWitnessWithStorageMeta);
39
- var isUnsignedBoundWitness = (value) => isPayloadOfSchemaType(BoundWitnessSchema)(value);
39
+ var isSigned = (value) => isBoundWitness(value) && value.$signatures.length === value.addresses.length && value.addresses.length > 0;
40
+ var isUnsigned = (value) => isBoundWitness(value) && !isSigned(value);
40
41
 
41
42
  // src/QueryBoundWitness.ts
42
43
  import { isStorageMeta as isStorageMeta2 } from "@xyo-network/payload-model";
@@ -55,7 +56,8 @@ export {
55
56
  isBoundWitnessWithStorageMeta,
56
57
  isQueryBoundWitness,
57
58
  isQueryBoundWitnessWithStorageMeta,
58
- isUnsignedBoundWitness,
59
+ isSigned,
60
+ isUnsigned,
59
61
  notBoundWitness
60
62
  };
61
63
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/BoundWitness/BoundWitness.ts","../../src/BoundWitness/BoundWitnessJsonSchema.ts","../../src/BoundWitness/BoundWitnessSchema.ts","../../src/isBoundWitness.ts","../../src/QueryBoundWitness.ts"],"sourcesContent":["import type {\n Address, Hash, Hex,\n} from '@xylabs/hex'\nimport type { EmptyObject, JsonObject } from '@xylabs/object'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\n\nimport type { BoundWitnessSchema } from './BoundWitnessSchema.ts'\n\nexport interface BoundWitnessRequiredFields {\n /** @field Array of signatures by the accounts that are listed in addresses */\n addresses: Address[]\n payload_hashes: Hash[]\n payload_schemas: Schema[]\n previous_hashes: (Hash | null)[]\n}\n\nexport interface BoundWitnessMeta {\n /**\n * @field The address to which the query is directed\n */\n $destination?: Address\n /**\n * @field The query that initiated the bound witness\n */\n $sourceQuery?: Hash\n}\n\nexport interface BoundWitnessBlockField {\n /** @field sequential number (if this boundwitness is part of a multi-party chain) */\n block: number\n}\n\nexport interface BoundWitnessChainField {\n /** @field unique id of a multi-party chain (usually staking contract address) */\n chain: Hex\n}\n\nexport interface BoundWitnessOptionalFields extends Partial<BoundWitnessBlockField>, Partial<BoundWitnessChainField> {\n root: Hash\n}\n\nexport interface BoundWitnessFields extends BoundWitnessRequiredFields, Partial<BoundWitnessOptionalFields> {}\n\nexport type UnsignedBoundWitness<T extends Payload | EmptyObject | void = void> = Payload<\n T extends void ? BoundWitnessFields : BoundWitnessFields & T,\n T extends void ? BoundWitnessSchema\n : T extends Payload ? T['schema']\n : BoundWitnessSchema\n> & BoundWitnessMeta\n\nexport type Signed<T> = T & {\n $signatures: Hex[]\n}\n\nexport type WithBlock = BoundWitness & BoundWitnessBlockField\n\nexport const hasBlock = (bw: BoundWitness): bw is WithBlock => bw.block !== undefined && typeof bw.block === 'string'\nexport const asBlock = (bw: BoundWitness): WithBlock => bw as WithBlock\n\nexport type BoundWitness<T extends Payload | EmptyObject | void = void> = Signed<UnsignedBoundWitness<T>>\n\nexport type AnyBoundWitness = BoundWitness<JsonObject>\n","// Should type as JSONSchemaType<BoundWitness> once ajv/eslint issue is fixed\n// https://github.com/microsoft/TypeScript/issues/44851\n\nexport const BoundWitnessJsonSchema = () => {\n return {\n $id: 'https://schemas.xyo.network/2.0/boundwitness',\n additionalProperties: false,\n properties: {\n addresses: { items: { type: 'string' }, type: 'array' },\n payload_hashes: { items: { type: 'string' }, type: 'array' },\n payload_schemas: { items: { type: 'string' }, type: 'array' },\n previous_hashes: { items: { nullable: true, type: 'string' }, type: 'array' },\n schema: { type: 'string' },\n },\n required: ['addresses', 'payload_hashes', 'payload_schemas', 'previous_hashes', 'schema'],\n type: 'object',\n }\n}\n","export const BoundWitnessSchema = 'network.xyo.boundwitness' as const\nexport type BoundWitnessSchema = typeof BoundWitnessSchema\n","import { AsObjectFactory } from '@xylabs/object'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport {\n isPayloadOfSchemaType, isStorageMeta, notPayloadOfSchemaType,\n} from '@xyo-network/payload-model'\n\nimport type { BoundWitness, UnsignedBoundWitness } from './BoundWitness/index.ts'\nimport { BoundWitnessSchema } from './BoundWitness/index.ts'\n\nexport const isBoundWitness = (value: unknown): value is BoundWitness => isPayloadOfSchemaType<BoundWitness>(BoundWitnessSchema)(value)\n\nexport const notBoundWitness = notPayloadOfSchemaType<BoundWitness>(BoundWitnessSchema)\n\n// TODO: Use AsObjectFactory here to match standard pattern\n// TODO: Other as identity functions throw if not valid, this one returns undefined with is more of a asOptional behavior\nexport const asBoundWitness = <T extends BoundWitness<{ schema: string }> = BoundWitness>(payload?: unknown) =>\n isBoundWitness(payload) ? (payload as T) : undefined\n\nexport const asOptionalBoundWitness = AsObjectFactory.createOptional<BoundWitness>(isBoundWitness)\n\nexport const isBoundWitnessWithStorageMeta = (value: unknown): value is WithStorageMeta<BoundWitness> =>\n isPayloadOfSchemaType<BoundWitness>(BoundWitnessSchema)(value) && isStorageMeta(value)\nexport const asBoundWitnessWithStorageMeta = AsObjectFactory.createOptional<WithStorageMeta<BoundWitness>>(isBoundWitnessWithStorageMeta)\nexport const asOptionalBoundWitnessWithStorageMeta = AsObjectFactory.createOptional<WithStorageMeta<BoundWitness>>(isBoundWitnessWithStorageMeta)\n\nexport const isUnsignedBoundWitness = (value: unknown): value is UnsignedBoundWitness =>\n isPayloadOfSchemaType<UnsignedBoundWitness>(BoundWitnessSchema)(value)\n","import type { Hash } from '@xylabs/hex'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport { isStorageMeta } from '@xyo-network/payload-model'\n\nimport type { BoundWitness } from './BoundWitness/index.ts'\nimport { isBoundWitness } from './isBoundWitness.ts'\n\nexport type QueryBoundWitnessFields = {\n error_hashes?: Hash[]\n query: Hash\n}\n\nexport type UnsignedQueryBoundWitness = BoundWitness<QueryBoundWitnessFields>\n\n// eslint-disable-next-line sonarjs/redundant-type-aliases\nexport type QueryBoundWitness = UnsignedQueryBoundWitness\n\nexport const isQueryBoundWitness = (x?: unknown): x is QueryBoundWitness => isBoundWitness(x) && (x as QueryBoundWitness)?.query !== undefined\nexport const isQueryBoundWitnessWithStorageMeta = (x?: unknown): x is WithStorageMeta<QueryBoundWitness> => isQueryBoundWitness(x) && isStorageMeta(x)\n"],"mappings":";AAwDO,IAAM,WAAW,CAAC,OAAsC,GAAG,UAAU,UAAa,OAAO,GAAG,UAAU;AACtG,IAAM,UAAU,CAAC,OAAgC;;;ACtDjD,IAAM,yBAAyB,MAAM;AAC1C,SAAO;AAAA,IACL,KAAK;AAAA,IACL,sBAAsB;AAAA,IACtB,YAAY;AAAA,MACV,WAAW,EAAE,OAAO,EAAE,MAAM,SAAS,GAAG,MAAM,QAAQ;AAAA,MACtD,gBAAgB,EAAE,OAAO,EAAE,MAAM,SAAS,GAAG,MAAM,QAAQ;AAAA,MAC3D,iBAAiB,EAAE,OAAO,EAAE,MAAM,SAAS,GAAG,MAAM,QAAQ;AAAA,MAC5D,iBAAiB,EAAE,OAAO,EAAE,UAAU,MAAM,MAAM,SAAS,GAAG,MAAM,QAAQ;AAAA,MAC5E,QAAQ,EAAE,MAAM,SAAS;AAAA,IAC3B;AAAA,IACA,UAAU,CAAC,aAAa,kBAAkB,mBAAmB,mBAAmB,QAAQ;AAAA,IACxF,MAAM;AAAA,EACR;AACF;;;ACjBO,IAAM,qBAAqB;;;ACAlC,SAAS,uBAAuB;AAEhC;AAAA,EACE;AAAA,EAAuB;AAAA,EAAe;AAAA,OACjC;AAKA,IAAM,iBAAiB,CAAC,UAA0C,sBAAoC,kBAAkB,EAAE,KAAK;AAE/H,IAAM,kBAAkB,uBAAqC,kBAAkB;AAI/E,IAAM,iBAAiB,CAA4D,YACxF,eAAe,OAAO,IAAK,UAAgB;AAEtC,IAAM,yBAAyB,gBAAgB,eAA6B,cAAc;AAE1F,IAAM,gCAAgC,CAAC,UAC5C,sBAAoC,kBAAkB,EAAE,KAAK,KAAK,cAAc,KAAK;AAChF,IAAM,gCAAgC,gBAAgB,eAA8C,6BAA6B;AACjI,IAAM,wCAAwC,gBAAgB,eAA8C,6BAA6B;AAEzI,IAAM,yBAAyB,CAAC,UACrC,sBAA4C,kBAAkB,EAAE,KAAK;;;ACxBvE,SAAS,iBAAAA,sBAAqB;AAevB,IAAM,sBAAsB,CAAC,MAAwC,eAAe,CAAC,KAAM,GAAyB,UAAU;AAC9H,IAAM,qCAAqC,CAAC,MAAyD,oBAAoB,CAAC,KAAKC,eAAc,CAAC;","names":["isStorageMeta","isStorageMeta"]}
1
+ {"version":3,"sources":["../../src/BoundWitness/BoundWitness.ts","../../src/BoundWitness/BoundWitnessJsonSchema.ts","../../src/BoundWitness/BoundWitnessSchema.ts","../../src/isBoundWitness.ts","../../src/QueryBoundWitness.ts"],"sourcesContent":["import type {\n Address, Hash, Hex,\n} from '@xylabs/hex'\nimport type { EmptyObject, JsonObject } from '@xylabs/object'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\n\nimport type { BoundWitnessSchema } from './BoundWitnessSchema.ts'\n\nexport interface BoundWitnessRequiredFields {\n /** @field Array of signatures by the accounts that are listed in addresses */\n addresses: Address[]\n payload_hashes: Hash[]\n payload_schemas: Schema[]\n previous_hashes: (Hash | null)[]\n}\n\nexport interface BoundWitnessMeta {\n /**\n * @field The address to which the query is directed\n */\n $destination?: Address\n /**\n * @field The query that initiated the bound witness\n */\n $sourceQuery?: Hash\n}\n\nexport interface BoundWitnessBlockField {\n /** @field sequential number (if this boundwitness is part of a multi-party chain) */\n block: number\n}\n\nexport interface BoundWitnessChainField {\n /** @field unique id of a multi-party chain (usually staking contract address) */\n chain: Hex\n}\n\nexport interface BoundWitnessOptionalFields extends Partial<BoundWitnessBlockField>, Partial<BoundWitnessChainField> {\n root: Hash\n}\n\nexport interface BoundWitnessFields extends BoundWitnessRequiredFields, Partial<BoundWitnessOptionalFields> {}\n\nexport type UnsignedBoundWitness<T extends EmptyObject | void = void> = Payload<\n T extends void ? BoundWitnessFields : BoundWitnessFields & T,\n BoundWitnessSchema\n> & BoundWitnessMeta\n\nexport type Signed<T extends UnsignedBoundWitness = UnsignedBoundWitness> = T & {\n $signatures: Hex[]\n}\n\nexport type SignedBoundWitness = Signed<UnsignedBoundWitness>\n\nexport type WithBlock = BoundWitness & BoundWitnessBlockField\n\nexport const hasBlock = (bw: BoundWitness): bw is WithBlock => bw.block !== undefined && typeof bw.block === 'string'\nexport const asBlock = (bw: BoundWitness): WithBlock => bw as WithBlock\n\nexport type BoundWitness<T extends Payload | EmptyObject | void = void> = Signed<UnsignedBoundWitness<T>>\n\nexport type AnyBoundWitness = BoundWitness<JsonObject>\n","// Should type as JSONSchemaType<BoundWitness> once ajv/eslint issue is fixed\n// https://github.com/microsoft/TypeScript/issues/44851\n\nexport const BoundWitnessJsonSchema = () => {\n return {\n $id: 'https://schemas.xyo.network/2.0/boundwitness',\n additionalProperties: false,\n properties: {\n addresses: { items: { type: 'string' }, type: 'array' },\n payload_hashes: { items: { type: 'string' }, type: 'array' },\n payload_schemas: { items: { type: 'string' }, type: 'array' },\n previous_hashes: { items: { nullable: true, type: 'string' }, type: 'array' },\n schema: { type: 'string' },\n },\n required: ['addresses', 'payload_hashes', 'payload_schemas', 'previous_hashes', 'schema'],\n type: 'object',\n }\n}\n","export const BoundWitnessSchema = 'network.xyo.boundwitness' as const\nexport type BoundWitnessSchema = typeof BoundWitnessSchema\n","import { AsObjectFactory } from '@xylabs/object'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport {\n isPayloadOfSchemaType, isStorageMeta, notPayloadOfSchemaType,\n} from '@xyo-network/payload-model'\n\nimport type {\n BoundWitness, Signed, UnsignedBoundWitness,\n} from './BoundWitness/index.ts'\nimport { BoundWitnessSchema } from './BoundWitness/index.ts'\n\nexport const isBoundWitness = (value: unknown): value is BoundWitness => isPayloadOfSchemaType<BoundWitness>(BoundWitnessSchema)(value)\n\nexport const notBoundWitness = notPayloadOfSchemaType<BoundWitness>(BoundWitnessSchema)\n\n// TODO: Use AsObjectFactory here to match standard pattern\n// TODO: Other as identity functions throw if not valid, this one returns undefined with is more of a asOptional behavior\nexport const asBoundWitness = <T extends BoundWitness<{ schema: string }> = BoundWitness>(payload?: unknown) =>\n isBoundWitness(payload) ? (payload as T) : undefined\n\nexport const asOptionalBoundWitness = AsObjectFactory.createOptional<BoundWitness>(isBoundWitness)\n\nexport const isBoundWitnessWithStorageMeta = (value: unknown): value is WithStorageMeta<BoundWitness> =>\n isPayloadOfSchemaType<BoundWitness>(BoundWitnessSchema)(value) && isStorageMeta(value)\nexport const asBoundWitnessWithStorageMeta = AsObjectFactory.createOptional<WithStorageMeta<BoundWitness>>(isBoundWitnessWithStorageMeta)\nexport const asOptionalBoundWitnessWithStorageMeta = AsObjectFactory.createOptional<WithStorageMeta<BoundWitness>>(isBoundWitnessWithStorageMeta)\n\nexport const isSigned = (value: unknown): value is Signed =>\n isBoundWitness(value)\n && value.$signatures.length === value.addresses.length\n && value.addresses.length > 0\n\nexport const isUnsigned = (value: unknown): value is UnsignedBoundWitness =>\n isBoundWitness(value) && !isSigned(value)\n","import type { Hash } from '@xylabs/hex'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport { isStorageMeta } from '@xyo-network/payload-model'\n\nimport type { BoundWitness } from './BoundWitness/index.ts'\nimport { isBoundWitness } from './isBoundWitness.ts'\n\nexport type QueryBoundWitnessFields = {\n error_hashes?: Hash[]\n query: Hash\n}\n\nexport type UnsignedQueryBoundWitness = BoundWitness<QueryBoundWitnessFields>\n\n// eslint-disable-next-line sonarjs/redundant-type-aliases\nexport type QueryBoundWitness = UnsignedQueryBoundWitness\n\nexport const isQueryBoundWitness = (x?: unknown): x is QueryBoundWitness => isBoundWitness(x) && (x as QueryBoundWitness)?.query !== undefined\nexport const isQueryBoundWitnessWithStorageMeta = (x?: unknown): x is WithStorageMeta<QueryBoundWitness> => isQueryBoundWitness(x) && isStorageMeta(x)\n"],"mappings":";AAwDO,IAAM,WAAW,CAAC,OAAsC,GAAG,UAAU,UAAa,OAAO,GAAG,UAAU;AACtG,IAAM,UAAU,CAAC,OAAgC;;;ACtDjD,IAAM,yBAAyB,MAAM;AAC1C,SAAO;AAAA,IACL,KAAK;AAAA,IACL,sBAAsB;AAAA,IACtB,YAAY;AAAA,MACV,WAAW,EAAE,OAAO,EAAE,MAAM,SAAS,GAAG,MAAM,QAAQ;AAAA,MACtD,gBAAgB,EAAE,OAAO,EAAE,MAAM,SAAS,GAAG,MAAM,QAAQ;AAAA,MAC3D,iBAAiB,EAAE,OAAO,EAAE,MAAM,SAAS,GAAG,MAAM,QAAQ;AAAA,MAC5D,iBAAiB,EAAE,OAAO,EAAE,UAAU,MAAM,MAAM,SAAS,GAAG,MAAM,QAAQ;AAAA,MAC5E,QAAQ,EAAE,MAAM,SAAS;AAAA,IAC3B;AAAA,IACA,UAAU,CAAC,aAAa,kBAAkB,mBAAmB,mBAAmB,QAAQ;AAAA,IACxF,MAAM;AAAA,EACR;AACF;;;ACjBO,IAAM,qBAAqB;;;ACAlC,SAAS,uBAAuB;AAEhC;AAAA,EACE;AAAA,EAAuB;AAAA,EAAe;AAAA,OACjC;AAOA,IAAM,iBAAiB,CAAC,UAA0C,sBAAoC,kBAAkB,EAAE,KAAK;AAE/H,IAAM,kBAAkB,uBAAqC,kBAAkB;AAI/E,IAAM,iBAAiB,CAA4D,YACxF,eAAe,OAAO,IAAK,UAAgB;AAEtC,IAAM,yBAAyB,gBAAgB,eAA6B,cAAc;AAE1F,IAAM,gCAAgC,CAAC,UAC5C,sBAAoC,kBAAkB,EAAE,KAAK,KAAK,cAAc,KAAK;AAChF,IAAM,gCAAgC,gBAAgB,eAA8C,6BAA6B;AACjI,IAAM,wCAAwC,gBAAgB,eAA8C,6BAA6B;AAEzI,IAAM,WAAW,CAAC,UACvB,eAAe,KAAK,KACjB,MAAM,YAAY,WAAW,MAAM,UAAU,UAC7C,MAAM,UAAU,SAAS;AAEvB,IAAM,aAAa,CAAC,UACzB,eAAe,KAAK,KAAK,CAAC,SAAS,KAAK;;;AC/B1C,SAAS,iBAAAA,sBAAqB;AAevB,IAAM,sBAAsB,CAAC,MAAwC,eAAe,CAAC,KAAM,GAAyB,UAAU;AAC9H,IAAM,qCAAqC,CAAC,MAAyD,oBAAoB,CAAC,KAAKC,eAAc,CAAC;","names":["isStorageMeta","isStorageMeta"]}
@@ -36,7 +36,8 @@ var asOptionalBoundWitness = AsObjectFactory.createOptional(isBoundWitness);
36
36
  var isBoundWitnessWithStorageMeta = (value) => isPayloadOfSchemaType(BoundWitnessSchema)(value) && isStorageMeta(value);
37
37
  var asBoundWitnessWithStorageMeta = AsObjectFactory.createOptional(isBoundWitnessWithStorageMeta);
38
38
  var asOptionalBoundWitnessWithStorageMeta = AsObjectFactory.createOptional(isBoundWitnessWithStorageMeta);
39
- var isUnsignedBoundWitness = (value) => isPayloadOfSchemaType(BoundWitnessSchema)(value);
39
+ var isSigned = (value) => isBoundWitness(value) && value.$signatures.length === value.addresses.length && value.addresses.length > 0;
40
+ var isUnsigned = (value) => isBoundWitness(value) && !isSigned(value);
40
41
 
41
42
  // src/QueryBoundWitness.ts
42
43
  import { isStorageMeta as isStorageMeta2 } from "@xyo-network/payload-model";
@@ -55,7 +56,8 @@ export {
55
56
  isBoundWitnessWithStorageMeta,
56
57
  isQueryBoundWitness,
57
58
  isQueryBoundWitnessWithStorageMeta,
58
- isUnsignedBoundWitness,
59
+ isSigned,
60
+ isUnsigned,
59
61
  notBoundWitness
60
62
  };
61
63
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/BoundWitness/BoundWitness.ts","../../src/BoundWitness/BoundWitnessJsonSchema.ts","../../src/BoundWitness/BoundWitnessSchema.ts","../../src/isBoundWitness.ts","../../src/QueryBoundWitness.ts"],"sourcesContent":["import type {\n Address, Hash, Hex,\n} from '@xylabs/hex'\nimport type { EmptyObject, JsonObject } from '@xylabs/object'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\n\nimport type { BoundWitnessSchema } from './BoundWitnessSchema.ts'\n\nexport interface BoundWitnessRequiredFields {\n /** @field Array of signatures by the accounts that are listed in addresses */\n addresses: Address[]\n payload_hashes: Hash[]\n payload_schemas: Schema[]\n previous_hashes: (Hash | null)[]\n}\n\nexport interface BoundWitnessMeta {\n /**\n * @field The address to which the query is directed\n */\n $destination?: Address\n /**\n * @field The query that initiated the bound witness\n */\n $sourceQuery?: Hash\n}\n\nexport interface BoundWitnessBlockField {\n /** @field sequential number (if this boundwitness is part of a multi-party chain) */\n block: number\n}\n\nexport interface BoundWitnessChainField {\n /** @field unique id of a multi-party chain (usually staking contract address) */\n chain: Hex\n}\n\nexport interface BoundWitnessOptionalFields extends Partial<BoundWitnessBlockField>, Partial<BoundWitnessChainField> {\n root: Hash\n}\n\nexport interface BoundWitnessFields extends BoundWitnessRequiredFields, Partial<BoundWitnessOptionalFields> {}\n\nexport type UnsignedBoundWitness<T extends Payload | EmptyObject | void = void> = Payload<\n T extends void ? BoundWitnessFields : BoundWitnessFields & T,\n T extends void ? BoundWitnessSchema\n : T extends Payload ? T['schema']\n : BoundWitnessSchema\n> & BoundWitnessMeta\n\nexport type Signed<T> = T & {\n $signatures: Hex[]\n}\n\nexport type WithBlock = BoundWitness & BoundWitnessBlockField\n\nexport const hasBlock = (bw: BoundWitness): bw is WithBlock => bw.block !== undefined && typeof bw.block === 'string'\nexport const asBlock = (bw: BoundWitness): WithBlock => bw as WithBlock\n\nexport type BoundWitness<T extends Payload | EmptyObject | void = void> = Signed<UnsignedBoundWitness<T>>\n\nexport type AnyBoundWitness = BoundWitness<JsonObject>\n","// Should type as JSONSchemaType<BoundWitness> once ajv/eslint issue is fixed\n// https://github.com/microsoft/TypeScript/issues/44851\n\nexport const BoundWitnessJsonSchema = () => {\n return {\n $id: 'https://schemas.xyo.network/2.0/boundwitness',\n additionalProperties: false,\n properties: {\n addresses: { items: { type: 'string' }, type: 'array' },\n payload_hashes: { items: { type: 'string' }, type: 'array' },\n payload_schemas: { items: { type: 'string' }, type: 'array' },\n previous_hashes: { items: { nullable: true, type: 'string' }, type: 'array' },\n schema: { type: 'string' },\n },\n required: ['addresses', 'payload_hashes', 'payload_schemas', 'previous_hashes', 'schema'],\n type: 'object',\n }\n}\n","export const BoundWitnessSchema = 'network.xyo.boundwitness' as const\nexport type BoundWitnessSchema = typeof BoundWitnessSchema\n","import { AsObjectFactory } from '@xylabs/object'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport {\n isPayloadOfSchemaType, isStorageMeta, notPayloadOfSchemaType,\n} from '@xyo-network/payload-model'\n\nimport type { BoundWitness, UnsignedBoundWitness } from './BoundWitness/index.ts'\nimport { BoundWitnessSchema } from './BoundWitness/index.ts'\n\nexport const isBoundWitness = (value: unknown): value is BoundWitness => isPayloadOfSchemaType<BoundWitness>(BoundWitnessSchema)(value)\n\nexport const notBoundWitness = notPayloadOfSchemaType<BoundWitness>(BoundWitnessSchema)\n\n// TODO: Use AsObjectFactory here to match standard pattern\n// TODO: Other as identity functions throw if not valid, this one returns undefined with is more of a asOptional behavior\nexport const asBoundWitness = <T extends BoundWitness<{ schema: string }> = BoundWitness>(payload?: unknown) =>\n isBoundWitness(payload) ? (payload as T) : undefined\n\nexport const asOptionalBoundWitness = AsObjectFactory.createOptional<BoundWitness>(isBoundWitness)\n\nexport const isBoundWitnessWithStorageMeta = (value: unknown): value is WithStorageMeta<BoundWitness> =>\n isPayloadOfSchemaType<BoundWitness>(BoundWitnessSchema)(value) && isStorageMeta(value)\nexport const asBoundWitnessWithStorageMeta = AsObjectFactory.createOptional<WithStorageMeta<BoundWitness>>(isBoundWitnessWithStorageMeta)\nexport const asOptionalBoundWitnessWithStorageMeta = AsObjectFactory.createOptional<WithStorageMeta<BoundWitness>>(isBoundWitnessWithStorageMeta)\n\nexport const isUnsignedBoundWitness = (value: unknown): value is UnsignedBoundWitness =>\n isPayloadOfSchemaType<UnsignedBoundWitness>(BoundWitnessSchema)(value)\n","import type { Hash } from '@xylabs/hex'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport { isStorageMeta } from '@xyo-network/payload-model'\n\nimport type { BoundWitness } from './BoundWitness/index.ts'\nimport { isBoundWitness } from './isBoundWitness.ts'\n\nexport type QueryBoundWitnessFields = {\n error_hashes?: Hash[]\n query: Hash\n}\n\nexport type UnsignedQueryBoundWitness = BoundWitness<QueryBoundWitnessFields>\n\n// eslint-disable-next-line sonarjs/redundant-type-aliases\nexport type QueryBoundWitness = UnsignedQueryBoundWitness\n\nexport const isQueryBoundWitness = (x?: unknown): x is QueryBoundWitness => isBoundWitness(x) && (x as QueryBoundWitness)?.query !== undefined\nexport const isQueryBoundWitnessWithStorageMeta = (x?: unknown): x is WithStorageMeta<QueryBoundWitness> => isQueryBoundWitness(x) && isStorageMeta(x)\n"],"mappings":";AAwDO,IAAM,WAAW,CAAC,OAAsC,GAAG,UAAU,UAAa,OAAO,GAAG,UAAU;AACtG,IAAM,UAAU,CAAC,OAAgC;;;ACtDjD,IAAM,yBAAyB,MAAM;AAC1C,SAAO;AAAA,IACL,KAAK;AAAA,IACL,sBAAsB;AAAA,IACtB,YAAY;AAAA,MACV,WAAW,EAAE,OAAO,EAAE,MAAM,SAAS,GAAG,MAAM,QAAQ;AAAA,MACtD,gBAAgB,EAAE,OAAO,EAAE,MAAM,SAAS,GAAG,MAAM,QAAQ;AAAA,MAC3D,iBAAiB,EAAE,OAAO,EAAE,MAAM,SAAS,GAAG,MAAM,QAAQ;AAAA,MAC5D,iBAAiB,EAAE,OAAO,EAAE,UAAU,MAAM,MAAM,SAAS,GAAG,MAAM,QAAQ;AAAA,MAC5E,QAAQ,EAAE,MAAM,SAAS;AAAA,IAC3B;AAAA,IACA,UAAU,CAAC,aAAa,kBAAkB,mBAAmB,mBAAmB,QAAQ;AAAA,IACxF,MAAM;AAAA,EACR;AACF;;;ACjBO,IAAM,qBAAqB;;;ACAlC,SAAS,uBAAuB;AAEhC;AAAA,EACE;AAAA,EAAuB;AAAA,EAAe;AAAA,OACjC;AAKA,IAAM,iBAAiB,CAAC,UAA0C,sBAAoC,kBAAkB,EAAE,KAAK;AAE/H,IAAM,kBAAkB,uBAAqC,kBAAkB;AAI/E,IAAM,iBAAiB,CAA4D,YACxF,eAAe,OAAO,IAAK,UAAgB;AAEtC,IAAM,yBAAyB,gBAAgB,eAA6B,cAAc;AAE1F,IAAM,gCAAgC,CAAC,UAC5C,sBAAoC,kBAAkB,EAAE,KAAK,KAAK,cAAc,KAAK;AAChF,IAAM,gCAAgC,gBAAgB,eAA8C,6BAA6B;AACjI,IAAM,wCAAwC,gBAAgB,eAA8C,6BAA6B;AAEzI,IAAM,yBAAyB,CAAC,UACrC,sBAA4C,kBAAkB,EAAE,KAAK;;;ACxBvE,SAAS,iBAAAA,sBAAqB;AAevB,IAAM,sBAAsB,CAAC,MAAwC,eAAe,CAAC,KAAM,GAAyB,UAAU;AAC9H,IAAM,qCAAqC,CAAC,MAAyD,oBAAoB,CAAC,KAAKC,eAAc,CAAC;","names":["isStorageMeta","isStorageMeta"]}
1
+ {"version":3,"sources":["../../src/BoundWitness/BoundWitness.ts","../../src/BoundWitness/BoundWitnessJsonSchema.ts","../../src/BoundWitness/BoundWitnessSchema.ts","../../src/isBoundWitness.ts","../../src/QueryBoundWitness.ts"],"sourcesContent":["import type {\n Address, Hash, Hex,\n} from '@xylabs/hex'\nimport type { EmptyObject, JsonObject } from '@xylabs/object'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\n\nimport type { BoundWitnessSchema } from './BoundWitnessSchema.ts'\n\nexport interface BoundWitnessRequiredFields {\n /** @field Array of signatures by the accounts that are listed in addresses */\n addresses: Address[]\n payload_hashes: Hash[]\n payload_schemas: Schema[]\n previous_hashes: (Hash | null)[]\n}\n\nexport interface BoundWitnessMeta {\n /**\n * @field The address to which the query is directed\n */\n $destination?: Address\n /**\n * @field The query that initiated the bound witness\n */\n $sourceQuery?: Hash\n}\n\nexport interface BoundWitnessBlockField {\n /** @field sequential number (if this boundwitness is part of a multi-party chain) */\n block: number\n}\n\nexport interface BoundWitnessChainField {\n /** @field unique id of a multi-party chain (usually staking contract address) */\n chain: Hex\n}\n\nexport interface BoundWitnessOptionalFields extends Partial<BoundWitnessBlockField>, Partial<BoundWitnessChainField> {\n root: Hash\n}\n\nexport interface BoundWitnessFields extends BoundWitnessRequiredFields, Partial<BoundWitnessOptionalFields> {}\n\nexport type UnsignedBoundWitness<T extends EmptyObject | void = void> = Payload<\n T extends void ? BoundWitnessFields : BoundWitnessFields & T,\n BoundWitnessSchema\n> & BoundWitnessMeta\n\nexport type Signed<T extends UnsignedBoundWitness = UnsignedBoundWitness> = T & {\n $signatures: Hex[]\n}\n\nexport type SignedBoundWitness = Signed<UnsignedBoundWitness>\n\nexport type WithBlock = BoundWitness & BoundWitnessBlockField\n\nexport const hasBlock = (bw: BoundWitness): bw is WithBlock => bw.block !== undefined && typeof bw.block === 'string'\nexport const asBlock = (bw: BoundWitness): WithBlock => bw as WithBlock\n\nexport type BoundWitness<T extends Payload | EmptyObject | void = void> = Signed<UnsignedBoundWitness<T>>\n\nexport type AnyBoundWitness = BoundWitness<JsonObject>\n","// Should type as JSONSchemaType<BoundWitness> once ajv/eslint issue is fixed\n// https://github.com/microsoft/TypeScript/issues/44851\n\nexport const BoundWitnessJsonSchema = () => {\n return {\n $id: 'https://schemas.xyo.network/2.0/boundwitness',\n additionalProperties: false,\n properties: {\n addresses: { items: { type: 'string' }, type: 'array' },\n payload_hashes: { items: { type: 'string' }, type: 'array' },\n payload_schemas: { items: { type: 'string' }, type: 'array' },\n previous_hashes: { items: { nullable: true, type: 'string' }, type: 'array' },\n schema: { type: 'string' },\n },\n required: ['addresses', 'payload_hashes', 'payload_schemas', 'previous_hashes', 'schema'],\n type: 'object',\n }\n}\n","export const BoundWitnessSchema = 'network.xyo.boundwitness' as const\nexport type BoundWitnessSchema = typeof BoundWitnessSchema\n","import { AsObjectFactory } from '@xylabs/object'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport {\n isPayloadOfSchemaType, isStorageMeta, notPayloadOfSchemaType,\n} from '@xyo-network/payload-model'\n\nimport type {\n BoundWitness, Signed, UnsignedBoundWitness,\n} from './BoundWitness/index.ts'\nimport { BoundWitnessSchema } from './BoundWitness/index.ts'\n\nexport const isBoundWitness = (value: unknown): value is BoundWitness => isPayloadOfSchemaType<BoundWitness>(BoundWitnessSchema)(value)\n\nexport const notBoundWitness = notPayloadOfSchemaType<BoundWitness>(BoundWitnessSchema)\n\n// TODO: Use AsObjectFactory here to match standard pattern\n// TODO: Other as identity functions throw if not valid, this one returns undefined with is more of a asOptional behavior\nexport const asBoundWitness = <T extends BoundWitness<{ schema: string }> = BoundWitness>(payload?: unknown) =>\n isBoundWitness(payload) ? (payload as T) : undefined\n\nexport const asOptionalBoundWitness = AsObjectFactory.createOptional<BoundWitness>(isBoundWitness)\n\nexport const isBoundWitnessWithStorageMeta = (value: unknown): value is WithStorageMeta<BoundWitness> =>\n isPayloadOfSchemaType<BoundWitness>(BoundWitnessSchema)(value) && isStorageMeta(value)\nexport const asBoundWitnessWithStorageMeta = AsObjectFactory.createOptional<WithStorageMeta<BoundWitness>>(isBoundWitnessWithStorageMeta)\nexport const asOptionalBoundWitnessWithStorageMeta = AsObjectFactory.createOptional<WithStorageMeta<BoundWitness>>(isBoundWitnessWithStorageMeta)\n\nexport const isSigned = (value: unknown): value is Signed =>\n isBoundWitness(value)\n && value.$signatures.length === value.addresses.length\n && value.addresses.length > 0\n\nexport const isUnsigned = (value: unknown): value is UnsignedBoundWitness =>\n isBoundWitness(value) && !isSigned(value)\n","import type { Hash } from '@xylabs/hex'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport { isStorageMeta } from '@xyo-network/payload-model'\n\nimport type { BoundWitness } from './BoundWitness/index.ts'\nimport { isBoundWitness } from './isBoundWitness.ts'\n\nexport type QueryBoundWitnessFields = {\n error_hashes?: Hash[]\n query: Hash\n}\n\nexport type UnsignedQueryBoundWitness = BoundWitness<QueryBoundWitnessFields>\n\n// eslint-disable-next-line sonarjs/redundant-type-aliases\nexport type QueryBoundWitness = UnsignedQueryBoundWitness\n\nexport const isQueryBoundWitness = (x?: unknown): x is QueryBoundWitness => isBoundWitness(x) && (x as QueryBoundWitness)?.query !== undefined\nexport const isQueryBoundWitnessWithStorageMeta = (x?: unknown): x is WithStorageMeta<QueryBoundWitness> => isQueryBoundWitness(x) && isStorageMeta(x)\n"],"mappings":";AAwDO,IAAM,WAAW,CAAC,OAAsC,GAAG,UAAU,UAAa,OAAO,GAAG,UAAU;AACtG,IAAM,UAAU,CAAC,OAAgC;;;ACtDjD,IAAM,yBAAyB,MAAM;AAC1C,SAAO;AAAA,IACL,KAAK;AAAA,IACL,sBAAsB;AAAA,IACtB,YAAY;AAAA,MACV,WAAW,EAAE,OAAO,EAAE,MAAM,SAAS,GAAG,MAAM,QAAQ;AAAA,MACtD,gBAAgB,EAAE,OAAO,EAAE,MAAM,SAAS,GAAG,MAAM,QAAQ;AAAA,MAC3D,iBAAiB,EAAE,OAAO,EAAE,MAAM,SAAS,GAAG,MAAM,QAAQ;AAAA,MAC5D,iBAAiB,EAAE,OAAO,EAAE,UAAU,MAAM,MAAM,SAAS,GAAG,MAAM,QAAQ;AAAA,MAC5E,QAAQ,EAAE,MAAM,SAAS;AAAA,IAC3B;AAAA,IACA,UAAU,CAAC,aAAa,kBAAkB,mBAAmB,mBAAmB,QAAQ;AAAA,IACxF,MAAM;AAAA,EACR;AACF;;;ACjBO,IAAM,qBAAqB;;;ACAlC,SAAS,uBAAuB;AAEhC;AAAA,EACE;AAAA,EAAuB;AAAA,EAAe;AAAA,OACjC;AAOA,IAAM,iBAAiB,CAAC,UAA0C,sBAAoC,kBAAkB,EAAE,KAAK;AAE/H,IAAM,kBAAkB,uBAAqC,kBAAkB;AAI/E,IAAM,iBAAiB,CAA4D,YACxF,eAAe,OAAO,IAAK,UAAgB;AAEtC,IAAM,yBAAyB,gBAAgB,eAA6B,cAAc;AAE1F,IAAM,gCAAgC,CAAC,UAC5C,sBAAoC,kBAAkB,EAAE,KAAK,KAAK,cAAc,KAAK;AAChF,IAAM,gCAAgC,gBAAgB,eAA8C,6BAA6B;AACjI,IAAM,wCAAwC,gBAAgB,eAA8C,6BAA6B;AAEzI,IAAM,WAAW,CAAC,UACvB,eAAe,KAAK,KACjB,MAAM,YAAY,WAAW,MAAM,UAAU,UAC7C,MAAM,UAAU,SAAS;AAEvB,IAAM,aAAa,CAAC,UACzB,eAAe,KAAK,KAAK,CAAC,SAAS,KAAK;;;AC/B1C,SAAS,iBAAAA,sBAAqB;AAevB,IAAM,sBAAsB,CAAC,MAAwC,eAAe,CAAC,KAAM,GAAyB,UAAU;AAC9H,IAAM,qCAAqC,CAAC,MAAyD,oBAAoB,CAAC,KAAKC,eAAc,CAAC;","names":["isStorageMeta","isStorageMeta"]}
@@ -32,10 +32,11 @@ export interface BoundWitnessOptionalFields extends Partial<BoundWitnessBlockFie
32
32
  }
33
33
  export interface BoundWitnessFields extends BoundWitnessRequiredFields, Partial<BoundWitnessOptionalFields> {
34
34
  }
35
- export type UnsignedBoundWitness<T extends Payload | EmptyObject | void = void> = Payload<T extends void ? BoundWitnessFields : BoundWitnessFields & T, T extends void ? BoundWitnessSchema : T extends Payload ? T['schema'] : BoundWitnessSchema> & BoundWitnessMeta;
36
- export type Signed<T> = T & {
35
+ export type UnsignedBoundWitness<T extends EmptyObject | void = void> = Payload<T extends void ? BoundWitnessFields : BoundWitnessFields & T, BoundWitnessSchema> & BoundWitnessMeta;
36
+ export type Signed<T extends UnsignedBoundWitness = UnsignedBoundWitness> = T & {
37
37
  $signatures: Hex[];
38
38
  };
39
+ export type SignedBoundWitness = Signed<UnsignedBoundWitness>;
39
40
  export type WithBlock = BoundWitness & BoundWitnessBlockField;
40
41
  export declare const hasBlock: (bw: BoundWitness) => bw is WithBlock;
41
42
  export declare const asBlock: (bw: BoundWitness) => WithBlock;
@@ -1 +1 @@
1
- {"version":3,"file":"BoundWitness.d.ts","sourceRoot":"","sources":["../../../src/BoundWitness/BoundWitness.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAAE,IAAI,EAAE,GAAG,EACnB,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAEjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAEjE,MAAM,WAAW,0BAA0B;IACzC,8EAA8E;IAC9E,SAAS,EAAE,OAAO,EAAE,CAAA;IACpB,cAAc,EAAE,IAAI,EAAE,CAAA;IACtB,eAAe,EAAE,MAAM,EAAE,CAAA;IACzB,eAAe,EAAE,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,CAAA;CACjC;AAED,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;;OAEG;IACH,YAAY,CAAC,EAAE,IAAI,CAAA;CACpB;AAED,MAAM,WAAW,sBAAsB;IACrC,qFAAqF;IACrF,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,sBAAsB;IACrC,iFAAiF;IACjF,KAAK,EAAE,GAAG,CAAA;CACX;AAED,MAAM,WAAW,0BAA2B,SAAQ,OAAO,CAAC,sBAAsB,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC;IAClH,IAAI,EAAE,IAAI,CAAA;CACX;AAED,MAAM,WAAW,kBAAmB,SAAQ,0BAA0B,EAAE,OAAO,CAAC,0BAA0B,CAAC;CAAG;AAE9G,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,OAAO,GAAG,WAAW,GAAG,IAAI,GAAG,IAAI,IAAI,OAAO,CACvF,CAAC,SAAS,IAAI,GAAG,kBAAkB,GAAG,kBAAkB,GAAG,CAAC,EAC5D,CAAC,SAAS,IAAI,GAAG,kBAAkB,GAC/B,CAAC,SAAS,OAAO,GAAG,CAAC,CAAC,QAAQ,CAAC,GAC7B,kBAAkB,CACzB,GAAG,gBAAgB,CAAA;AAEpB,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG;IAC1B,WAAW,EAAE,GAAG,EAAE,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,SAAS,GAAG,YAAY,GAAG,sBAAsB,CAAA;AAE7D,eAAO,MAAM,QAAQ,GAAI,IAAI,YAAY,KAAG,EAAE,IAAI,SAAmE,CAAA;AACrH,eAAO,MAAM,OAAO,GAAI,IAAI,YAAY,KAAG,SAA4B,CAAA;AAEvE,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,OAAO,GAAG,WAAW,GAAG,IAAI,GAAG,IAAI,IAAI,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAA;AAEzG,MAAM,MAAM,eAAe,GAAG,YAAY,CAAC,UAAU,CAAC,CAAA"}
1
+ {"version":3,"file":"BoundWitness.d.ts","sourceRoot":"","sources":["../../../src/BoundWitness/BoundWitness.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAAE,IAAI,EAAE,GAAG,EACnB,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAEjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAEjE,MAAM,WAAW,0BAA0B;IACzC,8EAA8E;IAC9E,SAAS,EAAE,OAAO,EAAE,CAAA;IACpB,cAAc,EAAE,IAAI,EAAE,CAAA;IACtB,eAAe,EAAE,MAAM,EAAE,CAAA;IACzB,eAAe,EAAE,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,CAAA;CACjC;AAED,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;;OAEG;IACH,YAAY,CAAC,EAAE,IAAI,CAAA;CACpB;AAED,MAAM,WAAW,sBAAsB;IACrC,qFAAqF;IACrF,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,sBAAsB;IACrC,iFAAiF;IACjF,KAAK,EAAE,GAAG,CAAA;CACX;AAED,MAAM,WAAW,0BAA2B,SAAQ,OAAO,CAAC,sBAAsB,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC;IAClH,IAAI,EAAE,IAAI,CAAA;CACX;AAED,MAAM,WAAW,kBAAmB,SAAQ,0BAA0B,EAAE,OAAO,CAAC,0BAA0B,CAAC;CAAG;AAE9G,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,WAAW,GAAG,IAAI,GAAG,IAAI,IAAI,OAAO,CAC7E,CAAC,SAAS,IAAI,GAAG,kBAAkB,GAAG,kBAAkB,GAAG,CAAC,EAC5D,kBAAkB,CACnB,GAAG,gBAAgB,CAAA;AAEpB,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,oBAAoB,GAAG,oBAAoB,IAAI,CAAC,GAAG;IAC9E,WAAW,EAAE,GAAG,EAAE,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAA;AAE7D,MAAM,MAAM,SAAS,GAAG,YAAY,GAAG,sBAAsB,CAAA;AAE7D,eAAO,MAAM,QAAQ,GAAI,IAAI,YAAY,KAAG,EAAE,IAAI,SAAmE,CAAA;AACrH,eAAO,MAAM,OAAO,GAAI,IAAI,YAAY,KAAG,SAA4B,CAAA;AAEvE,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,OAAO,GAAG,WAAW,GAAG,IAAI,GAAG,IAAI,IAAI,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAA;AAEzG,MAAM,MAAM,eAAe,GAAG,YAAY,CAAC,UAAU,CAAC,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import type { WithStorageMeta } from '@xyo-network/payload-model';
2
- import type { BoundWitness, UnsignedBoundWitness } from './BoundWitness/index.ts';
2
+ import type { BoundWitness, Signed, UnsignedBoundWitness } from './BoundWitness/index.ts';
3
3
  export declare const isBoundWitness: (value: unknown) => value is BoundWitness;
4
4
  export declare const notBoundWitness: (x?: unknown | null) => x is BoundWitness;
5
5
  export declare const asBoundWitness: <T extends BoundWitness<{
@@ -9,5 +9,6 @@ export declare const asOptionalBoundWitness: <TType extends BoundWitness>(value:
9
9
  export declare const isBoundWitnessWithStorageMeta: (value: unknown) => value is WithStorageMeta<BoundWitness>;
10
10
  export declare const asBoundWitnessWithStorageMeta: <TType extends WithStorageMeta<BoundWitness>>(value: import(".store/@xylabs-promise-npm-4.7.11-d5881fcf85/package").AnyNonPromise) => TType | undefined;
11
11
  export declare const asOptionalBoundWitnessWithStorageMeta: <TType extends WithStorageMeta<BoundWitness>>(value: import(".store/@xylabs-promise-npm-4.7.11-d5881fcf85/package").AnyNonPromise) => TType | undefined;
12
- export declare const isUnsignedBoundWitness: (value: unknown) => value is UnsignedBoundWitness;
12
+ export declare const isSigned: (value: unknown) => value is Signed;
13
+ export declare const isUnsigned: (value: unknown) => value is UnsignedBoundWitness;
13
14
  //# sourceMappingURL=isBoundWitness.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"isBoundWitness.d.ts","sourceRoot":"","sources":["../../src/isBoundWitness.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAKjE,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAGjF,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,YAA8E,CAAA;AAEvI,eAAO,MAAM,eAAe,2CAA2D,CAAA;AAIvF,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,YAAY,CAAC;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,YAAY,EAAE,UAAU,OAAO,kBACrD,CAAA;AAEtD,eAAO,MAAM,sBAAsB,6CAJpB,sDAAiB,qCAIkE,CAAA;AAElG,eAAO,MAAM,6BAA6B,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,eAAe,CAAC,YAAY,CACZ,CAAA;AACxF,eAAO,MAAM,6BAA6B,8DAR3B,sDAAiB,qCAQyG,CAAA;AACzI,eAAO,MAAM,qCAAqC,8DATnC,sDAAiB,qCASiH,CAAA;AAEjJ,eAAO,MAAM,sBAAsB,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,oBACO,CAAA"}
1
+ {"version":3,"file":"isBoundWitness.d.ts","sourceRoot":"","sources":["../../src/isBoundWitness.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAKjE,OAAO,KAAK,EACV,YAAY,EAAE,MAAM,EAAE,oBAAoB,EAC3C,MAAM,yBAAyB,CAAA;AAGhC,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,YAA8E,CAAA;AAEvI,eAAO,MAAM,eAAe,2CAA2D,CAAA;AAIvF,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,YAAY,CAAC;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,YAAY,EAAE,UAAU,OAAO,kBACrD,CAAA;AAEtD,eAAO,MAAM,sBAAsB,6CAJ/B,sDAAiB,qCAI6E,CAAA;AAElG,eAAO,MAAM,6BAA6B,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,eAAe,CAAC,YAAY,CACZ,CAAA;AACxF,eAAO,MAAM,6BAA6B,8DARtC,sDAAiB,qCAQoH,CAAA;AACzI,eAAO,MAAM,qCAAqC,8DAT9C,sDAAiB,qCAS4H,CAAA;AAEjJ,eAAO,MAAM,QAAQ,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MAGpB,CAAA;AAE/B,eAAO,MAAM,UAAU,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,oBACV,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/boundwitness-model",
3
- "version": "3.10.3",
3
+ "version": "3.10.5",
4
4
  "description": "Primary SDK for using XYO Protocol 2.0",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -31,12 +31,12 @@
31
31
  "dependencies": {
32
32
  "@xylabs/hex": "^4.7.11",
33
33
  "@xylabs/object": "^4.7.11",
34
- "@xyo-network/payload-model": "^3.10.3"
34
+ "@xyo-network/payload-model": "^3.10.5"
35
35
  },
36
36
  "devDependencies": {
37
- "@types/node": "^22.13.11",
38
- "@xylabs/ts-scripts-yarn3": "^6.1.4",
39
- "@xylabs/tsconfig": "^6.1.4",
37
+ "@types/node": "^22.13.13",
38
+ "@xylabs/ts-scripts-yarn3": "^6.1.5",
39
+ "@xylabs/tsconfig": "^6.1.5",
40
40
  "typescript": "^5.8.2"
41
41
  },
42
42
  "publishConfig": {
@@ -41,17 +41,17 @@ export interface BoundWitnessOptionalFields extends Partial<BoundWitnessBlockFie
41
41
 
42
42
  export interface BoundWitnessFields extends BoundWitnessRequiredFields, Partial<BoundWitnessOptionalFields> {}
43
43
 
44
- export type UnsignedBoundWitness<T extends Payload | EmptyObject | void = void> = Payload<
44
+ export type UnsignedBoundWitness<T extends EmptyObject | void = void> = Payload<
45
45
  T extends void ? BoundWitnessFields : BoundWitnessFields & T,
46
- T extends void ? BoundWitnessSchema
47
- : T extends Payload ? T['schema']
48
- : BoundWitnessSchema
46
+ BoundWitnessSchema
49
47
  > & BoundWitnessMeta
50
48
 
51
- export type Signed<T> = T & {
49
+ export type Signed<T extends UnsignedBoundWitness = UnsignedBoundWitness> = T & {
52
50
  $signatures: Hex[]
53
51
  }
54
52
 
53
+ export type SignedBoundWitness = Signed<UnsignedBoundWitness>
54
+
55
55
  export type WithBlock = BoundWitness & BoundWitnessBlockField
56
56
 
57
57
  export const hasBlock = (bw: BoundWitness): bw is WithBlock => bw.block !== undefined && typeof bw.block === 'string'
@@ -4,7 +4,9 @@ import {
4
4
  isPayloadOfSchemaType, isStorageMeta, notPayloadOfSchemaType,
5
5
  } from '@xyo-network/payload-model'
6
6
 
7
- import type { BoundWitness, UnsignedBoundWitness } from './BoundWitness/index.ts'
7
+ import type {
8
+ BoundWitness, Signed, UnsignedBoundWitness,
9
+ } from './BoundWitness/index.ts'
8
10
  import { BoundWitnessSchema } from './BoundWitness/index.ts'
9
11
 
10
12
  export const isBoundWitness = (value: unknown): value is BoundWitness => isPayloadOfSchemaType<BoundWitness>(BoundWitnessSchema)(value)
@@ -23,5 +25,10 @@ export const isBoundWitnessWithStorageMeta = (value: unknown): value is WithStor
23
25
  export const asBoundWitnessWithStorageMeta = AsObjectFactory.createOptional<WithStorageMeta<BoundWitness>>(isBoundWitnessWithStorageMeta)
24
26
  export const asOptionalBoundWitnessWithStorageMeta = AsObjectFactory.createOptional<WithStorageMeta<BoundWitness>>(isBoundWitnessWithStorageMeta)
25
27
 
26
- export const isUnsignedBoundWitness = (value: unknown): value is UnsignedBoundWitness =>
27
- isPayloadOfSchemaType<UnsignedBoundWitness>(BoundWitnessSchema)(value)
28
+ export const isSigned = (value: unknown): value is Signed =>
29
+ isBoundWitness(value)
30
+ && value.$signatures.length === value.addresses.length
31
+ && value.addresses.length > 0
32
+
33
+ export const isUnsigned = (value: unknown): value is UnsignedBoundWitness =>
34
+ isBoundWitness(value) && !isSigned(value)