@xyo-network/erc1967-witness 5.2.3 → 5.3.1

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.
@@ -1,6 +1,8 @@
1
- import type { Payload } from '@xyo-network/payload-model';
1
+ import { type Payload } from '@xyo-network/payload-model';
2
2
  import type { Erc1967SlotStatus } from './lib/index.ts';
3
- export declare const Erc1967StatusSchema = "network.xyo.erc1967.status";
3
+ export declare const Erc1967StatusSchema: "network.xyo.erc1967.status" & {
4
+ readonly __schema: true;
5
+ };
4
6
  export type Erc1967StatusSchema = typeof Erc1967StatusSchema;
5
7
  export type Erc1967Status = Payload<{
6
8
  address: string;
@@ -1 +1 @@
1
- {"version":3,"file":"Payload.d.ts","sourceRoot":"","sources":["../../src/Payload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAEzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAEvD,eAAO,MAAM,mBAAmB,+BAA+B,CAAA;AAC/D,MAAM,MAAM,mBAAmB,GAAG,OAAO,mBAAmB,CAAA;AAE5D,MAAM,MAAM,aAAa,GAAG,OAAO,CACjC;IACE,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,iBAAiB,CAAC,QAAQ,CAAC,CAAA;IACpC,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,cAAc,CAAC,EAAE,iBAAiB,CAAC,gBAAgB,CAAC,CAAA;IACpD,KAAK,CAAC,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAA;CACnC,EACD,mBAAmB,CACpB,CAAA"}
1
+ {"version":3,"file":"Payload.d.ts","sourceRoot":"","sources":["../../src/Payload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAEnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAEvD,eAAO,MAAM,mBAAmB;;CAA+C,CAAA;AAC/E,MAAM,MAAM,mBAAmB,GAAG,OAAO,mBAAmB,CAAA;AAE5D,MAAM,MAAM,aAAa,GAAG,OAAO,CACjC;IACE,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,iBAAiB,CAAC,QAAQ,CAAC,CAAA;IACpC,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,cAAc,CAAC,EAAE,iBAAiB,CAAC,gBAAgB,CAAC,CAAA;IACpD,KAAK,CAAC,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAA;CACnC,EACD,mBAAmB,CACpB,CAAA"}
@@ -2,7 +2,9 @@ import type { Schema } from '@xyo-network/payload-model';
2
2
  import type { EvmAddress, EvmWitnessConfig, EvmWitnessParams } from '@xyo-network/witness-evm-abstract';
3
3
  import { AbstractEvmWitness } from '@xyo-network/witness-evm-abstract';
4
4
  import type { Erc1967Status } from './Payload.ts';
5
- export declare const Erc1967WitnessConfigSchema = "network.xyo.erc1967.witness.config";
5
+ export declare const Erc1967WitnessConfigSchema: "network.xyo.erc1967.witness.config" & {
6
+ readonly __schema: true;
7
+ };
6
8
  export type Erc1967WitnessConfigSchema = typeof Erc1967WitnessConfigSchema;
7
9
  export type Erc1967WitnessConfig = EvmWitnessConfig<{
8
10
  address?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"Witness.d.ts","sourceRoot":"","sources":["../../src/Witness.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAExD,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAAE,gBAAgB,EACnC,MAAM,mCAAmC,CAAA;AAC1C,OAAO,EAAE,kBAAkB,EAAoB,MAAM,mCAAmC,CAAA;AAGxF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAGjD,eAAO,MAAM,0BAA0B,uCAA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H,OAAO,EACP,UAAU,EACV,aAAa,CACd;IACC,gBAAyB,aAAa,EAAE,MAAM,EAAE,CAAuD;IACvG,gBAAyB,mBAAmB,EAAE,MAAM,CAA6B;cAExD,cAAc,CAAC,UAAU,GAAE,UAAU,EAAO,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;CAoCjG"}
@@ -51,13 +51,14 @@ var getErc1967SlotStatus = async (provider, address, block) => {
51
51
  };
52
52
 
53
53
  // src/Payload.ts
54
- var Erc1967StatusSchema = "network.xyo.erc1967.status";
54
+ import { asSchema } from "@xyo-network/payload-model";
55
+ var Erc1967StatusSchema = asSchema("network.xyo.erc1967.status", true);
55
56
 
56
57
  // src/Witness.ts
57
58
  import { assertEx } from "@xylabs/assert";
58
- import { isPayloadOfSchemaType } from "@xyo-network/payload-model";
59
+ import { asSchema as asSchema2, isPayloadOfSchemaType } from "@xyo-network/payload-model";
59
60
  import { AbstractEvmWitness, EvmAddressSchema } from "@xyo-network/witness-evm-abstract";
60
- var Erc1967WitnessConfigSchema = "network.xyo.erc1967.witness.config";
61
+ var Erc1967WitnessConfigSchema = asSchema2("network.xyo.erc1967.witness.config", true);
61
62
  var Erc1967Witness = class extends AbstractEvmWitness {
62
63
  static configSchemas = [...super.configSchemas, Erc1967WitnessConfigSchema];
63
64
  static defaultConfigSchema = Erc1967WitnessConfigSchema;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/getErc1967SlotStatus.ts","../../src/Payload.ts","../../src/Witness.ts"],"sourcesContent":["import type { Address, EthAddress } from '@xylabs/hex'\nimport {\n asEthAddress, hexFromHexString, isHexZero,\n} from '@xylabs/hex'\nimport { UpgradeableBeacon__factory } from '@xyo-network/open-zeppelin-typechain'\nimport type { Provider } from 'ethers'\n\nexport const ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT = '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc' as EthAddress\nexport const ERC1967_PROXY_BEACON_STORAGE_SLOT = '0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50' as EthAddress\nexport const ERC1967_PROXY_ADMIN_STORAGE_SLOT = '0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103' as EthAddress\nexport const ERC1967_PROXY_ROLLBACK_STORAGE_SLOT = '0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143' as EthAddress\n\nexport interface Erc1967DataSlots {\n admin?: EthAddress\n beacon?: EthAddress\n implementation?: EthAddress\n rollback?: EthAddress\n}\n\nexport interface Erc1967SlotStatus {\n address: string\n beacon?: {\n implementation?: Address\n }\n implementation: string\n slots: Erc1967DataSlots\n}\n\nconst readAddressFromSlot = async (provider: Provider, address: string, slot: string, block?: number) => {\n try {\n const slotValue = await provider.getStorage(address, slot, block)\n return asEthAddress(hexFromHexString(slotValue, { prefix: true }))\n } catch {\n return\n }\n}\n\nexport const getErc1967SlotStatus = async (provider: Provider, address: string, block?: number): Promise<Erc1967SlotStatus> => {\n const status: Erc1967SlotStatus = {\n address,\n implementation: address,\n slots: {\n admin: await readAddressFromSlot(provider, address, ERC1967_PROXY_ADMIN_STORAGE_SLOT, block),\n beacon: await readAddressFromSlot(provider, address, ERC1967_PROXY_BEACON_STORAGE_SLOT, block),\n implementation: await readAddressFromSlot(provider, address, ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT, block),\n rollback: await readAddressFromSlot(provider, address, ERC1967_PROXY_ROLLBACK_STORAGE_SLOT, block),\n },\n }\n\n if (status.slots.implementation && !isHexZero(status.slots.implementation)) {\n status.implementation = `0x${BigInt(status.slots.implementation as string)\n .toString(16)\n .padStart(40, '0')}` as Address\n } else {\n if (status.slots.beacon && !isHexZero(status.slots.beacon)) {\n const beacon = UpgradeableBeacon__factory.connect(status.slots.beacon as string, { provider })\n try {\n const implementation = (await beacon.implementation(block ? { blockTag: block } : {})) as Address\n if (implementation) {\n status.beacon = { implementation }\n if (!isHexZero(implementation)) {\n status.implementation = implementation\n }\n }\n } catch (ex) {\n const error = ex as Error\n console.log(error.message)\n }\n }\n }\n\n return status\n}\n","import type { Payload } from '@xyo-network/payload-model'\n\nimport type { Erc1967SlotStatus } from './lib/index.ts'\n\nexport const Erc1967StatusSchema = 'network.xyo.erc1967.status'\nexport type Erc1967StatusSchema = typeof Erc1967StatusSchema\n\nexport type Erc1967Status = Payload<\n {\n address: string\n beacon?: Erc1967SlotStatus['beacon']\n block: number\n chainId: number\n implementation?: Erc1967SlotStatus['implementation']\n slots?: Erc1967SlotStatus['slots']\n },\n Erc1967StatusSchema\n>\n","import { assertEx } from '@xylabs/assert'\nimport type { Schema } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport type {\n EvmAddress,\n EvmWitnessConfig, EvmWitnessParams,\n} from '@xyo-network/witness-evm-abstract'\nimport { AbstractEvmWitness, EvmAddressSchema } from '@xyo-network/witness-evm-abstract'\n\nimport { getErc1967SlotStatus } from './lib/index.ts'\nimport type { Erc1967Status } from './Payload.ts'\nimport { Erc1967StatusSchema } from './Payload.ts'\n\nexport const Erc1967WitnessConfigSchema = 'network.xyo.erc1967.witness.config'\nexport type Erc1967WitnessConfigSchema = typeof Erc1967WitnessConfigSchema\n\nexport type Erc1967WitnessConfig = EvmWitnessConfig<{ address?: string }, Erc1967WitnessConfigSchema>\n\nexport type Erc1967WitnessParams = EvmWitnessParams<Erc1967WitnessConfig>\n\nexport class Erc1967Witness<TParams extends Erc1967WitnessParams = Erc1967WitnessParams> extends AbstractEvmWitness<\n TParams,\n EvmAddress,\n Erc1967Status\n> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, Erc1967WitnessConfigSchema]\n static override readonly defaultConfigSchema: Schema = Erc1967WitnessConfigSchema\n\n protected override async observeHandler(inPayloads: EvmAddress[] = []): Promise<Erc1967Status[]> {\n await this.started('throw')\n // calling it here to make sure we rests the cache\n await this.getProviders()\n try {\n const observations = await Promise.all(\n inPayloads.filter(isPayloadOfSchemaType<EvmAddress>(EvmAddressSchema)).map(async ({ address }) => {\n const validatedAddress = assertEx(address ?? this.config.address, () => 'Missing address').toLowerCase()\n\n const provider = await this.getProvider(true, true)\n\n const block = await provider.getBlockNumber()\n\n const {\n beacon, implementation, slots,\n } = await getErc1967SlotStatus(provider, validatedAddress, block)\n\n const observation: Erc1967Status = {\n address: validatedAddress,\n beacon,\n block,\n chainId: Number((await provider.getNetwork()).chainId),\n implementation,\n schema: Erc1967StatusSchema,\n slots,\n }\n return observation\n }),\n )\n return observations\n } catch (ex) {\n const error = ex as Error\n console.log(`Error [${this.config.name}]: ${error.message}`)\n throw error\n }\n }\n}\n"],"mappings":";AACA;AAAA,EACE;AAAA,EAAc;AAAA,EAAkB;AAAA,OAC3B;AACP,SAAS,kCAAkC;AAGpC,IAAM,4CAA4C;AAClD,IAAM,oCAAoC;AAC1C,IAAM,mCAAmC;AACzC,IAAM,sCAAsC;AAkBnD,IAAM,sBAAsB,OAAO,UAAoB,SAAiB,MAAc,UAAmB;AACvG,MAAI;AACF,UAAM,YAAY,MAAM,SAAS,WAAW,SAAS,MAAM,KAAK;AAChE,WAAO,aAAa,iBAAiB,WAAW,EAAE,QAAQ,KAAK,CAAC,CAAC;AAAA,EACnE,QAAQ;AACN;AAAA,EACF;AACF;AAEO,IAAM,uBAAuB,OAAO,UAAoB,SAAiB,UAA+C;AAC7H,QAAM,SAA4B;AAAA,IAChC;AAAA,IACA,gBAAgB;AAAA,IAChB,OAAO;AAAA,MACL,OAAO,MAAM,oBAAoB,UAAU,SAAS,kCAAkC,KAAK;AAAA,MAC3F,QAAQ,MAAM,oBAAoB,UAAU,SAAS,mCAAmC,KAAK;AAAA,MAC7F,gBAAgB,MAAM,oBAAoB,UAAU,SAAS,2CAA2C,KAAK;AAAA,MAC7G,UAAU,MAAM,oBAAoB,UAAU,SAAS,qCAAqC,KAAK;AAAA,IACnG;AAAA,EACF;AAEA,MAAI,OAAO,MAAM,kBAAkB,CAAC,UAAU,O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I;AAElD,gBAAM,QAAQ,MAAM,SAAS,eAAe;AAE5C,gBAAM;AAAA,YACJ;AAAA,YAAQ;AAAA,YAAgB;AAAA,UAC1B,IAAI,MAAM,qBAAqB,UAAU,kBAAkB,KAAK;AAEhE,gBAAM,cAA6B;AAAA,YACjC,SAAS;AAAA,YACT;AAAA,YACA;AAAA,YACA,SAAS,QAAQ,MAAM,SAAS,WAAW,GAAG,OAAO;AAAA,YACrD;AAAA,YACA,QAAQ;AAAA,YACR;AAAA,UACF;AACA,iBAAO;AAAA,QACT,CAAC;AAAA,MACH;AACA,aAAO;AAAA,IACT,SAAS,IAAI;AACX,YAAM,QAAQ;AACd,cAAQ,IAAI,UAAU,KAAK,OAAO,IAAI,MAAM,MAAM,OAAO,EAAE;AAC3D,YAAM;AAAA,IACR;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/lib/getErc1967SlotStatus.ts","../../src/Payload.ts","../../src/Witness.ts"],"sourcesContent":["import type { Address, EthAddress } from '@xylabs/hex'\nimport {\n asEthAddress, hexFromHexString, isHexZero,\n} from '@xylabs/hex'\nimport { UpgradeableBeacon__factory } from '@xyo-network/open-zeppelin-typechain'\nimport type { Provider } from 'ethers'\n\nexport const ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT = '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc' as EthAddress\nexport const ERC1967_PROXY_BEACON_STORAGE_SLOT = '0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50' as EthAddress\nexport const ERC1967_PROXY_ADMIN_STORAGE_SLOT = '0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103' as EthAddress\nexport const ERC1967_PROXY_ROLLBACK_STORAGE_SLOT = '0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143' as EthAddress\n\nexport interface Erc1967DataSlots {\n admin?: EthAddress\n beacon?: EthAddress\n implementation?: EthAddress\n rollback?: EthAddress\n}\n\nexport interface Erc1967SlotStatus {\n address: string\n beacon?: {\n implementation?: Address\n }\n implementation: string\n slots: Erc1967DataSlots\n}\n\nconst readAddressFromSlot = async (provider: Provider, address: string, slot: string, block?: number) => {\n try {\n const slotValue = await provider.getStorage(address, slot, block)\n return asEthAddress(hexFromHexString(slotValue, { prefix: true }))\n } catch {\n return\n }\n}\n\nexport const getErc1967SlotStatus = async (provider: Provider, address: string, block?: number): Promise<Erc1967SlotStatus> => {\n const status: Erc1967SlotStatus = {\n address,\n implementation: address,\n slots: {\n admin: await readAddressFromSlot(provider, address, ERC1967_PROXY_ADMIN_STORAGE_SLOT, block),\n beacon: await readAddressFromSlot(provider, address, ERC1967_PROXY_BEACON_STORAGE_SLOT, block),\n implementation: await readAddressFromSlot(provider, address, ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT, block),\n rollback: await readAddressFromSlot(provider, address, ERC1967_PROXY_ROLLBACK_STORAGE_SLOT, block),\n },\n }\n\n if (status.slots.implementation && !isHexZero(status.slots.implementation)) {\n status.implementation = `0x${BigInt(status.slots.implementation as string)\n .toString(16)\n .padStart(40, '0')}` as Address\n } else {\n if (status.slots.beacon && !isHexZero(status.slots.beacon)) {\n const beacon = UpgradeableBeacon__factory.connect(status.slots.beacon as string, { provider })\n try {\n const implementation = (await beacon.implementation(block ? { blockTag: block } : {})) as Address\n if (implementation) {\n status.beacon = { implementation }\n if (!isHexZero(implementation)) {\n status.implementation = implementation\n }\n }\n } catch (ex) {\n const error = ex as Error\n console.log(error.message)\n }\n }\n }\n\n return status\n}\n","import { asSchema, type Payload } from '@xyo-network/payload-model'\n\nimport type { Erc1967SlotStatus } from './lib/index.ts'\n\nexport const Erc1967StatusSchema = asSchema('network.xyo.erc1967.status', true)\nexport type Erc1967StatusSchema = typeof Erc1967StatusSchema\n\nexport type Erc1967Status = Payload<\n {\n address: string\n beacon?: Erc1967SlotStatus['beacon']\n block: number\n chainId: number\n implementation?: Erc1967SlotStatus['implementation']\n slots?: Erc1967SlotStatus['slots']\n },\n Erc1967StatusSchema\n>\n","import { assertEx } from '@xylabs/assert'\nimport type { Schema } from '@xyo-network/payload-model'\nimport { asSchema, isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport type {\n EvmAddress,\n EvmWitnessConfig, EvmWitnessParams,\n} from '@xyo-network/witness-evm-abstract'\nimport { AbstractEvmWitness, EvmAddressSchema } from '@xyo-network/witness-evm-abstract'\n\nimport { getErc1967SlotStatus } from './lib/index.ts'\nimport type { Erc1967Status } from './Payload.ts'\nimport { Erc1967StatusSchema } from './Payload.ts'\n\nexport const Erc1967WitnessConfigSchema = asSchema('network.xyo.erc1967.witness.config', true)\nexport type Erc1967WitnessConfigSchema = typeof Erc1967WitnessConfigSchema\n\nexport type Erc1967WitnessConfig = EvmWitnessConfig<{ address?: string }, Erc1967WitnessConfigSchema>\n\nexport type Erc1967WitnessParams = EvmWitnessParams<Erc1967WitnessConfig>\n\nexport class Erc1967Witness<TParams extends Erc1967WitnessParams = Erc1967WitnessParams> extends AbstractEvmWitness<\n TParams,\n EvmAddress,\n Erc1967Status\n> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, Erc1967WitnessConfigSchema]\n static override readonly defaultConfigSchema: Schema = Erc1967WitnessConfigSchema\n\n protected override async observeHandler(inPayloads: EvmAddress[] = []): Promise<Erc1967Status[]> {\n await this.started('throw')\n // calling it here to make sure we rests the cache\n await this.getProviders()\n try {\n const observations = await Promise.all(\n inPayloads.filter(isPayloadOfSchemaType<EvmAddress>(EvmAddressSchema)).map(async ({ address }) => {\n const validatedAddress = assertEx(address ?? this.config.address, () => 'Missing address').toLowerCase()\n\n const provider = await this.getProvider(true, true)\n\n const block = await provider.getBlockNumber()\n\n const {\n beacon, implementation, slots,\n } = await getErc1967SlotStatus(provider, validatedAddress, block)\n\n const observation: Erc1967Status = {\n address: validatedAddress,\n beacon,\n block,\n chainId: Number((await provider.getNetwork()).chainId),\n implementation,\n schema: Erc1967StatusSchema,\n slots,\n }\n return observation\n }),\n )\n return observations\n } catch (ex) {\n const error = ex as Error\n console.log(`Error [${this.config.name}]: ${error.message}`)\n throw error\n }\n }\n}\n"],"mappings":";AACA;AAAA,EACE;AAAA,EAAc;AAAA,EAAkB;AAAA,OAC3B;AACP,SAAS,kCAAkC;AAGpC,IAAM,4CAA4C;AAClD,IAAM,oCAAoC;AAC1C,IAAM,mCAAmC;AACzC,IAAM,sCAAsC;AAkBnD,IAAM,sBAAsB,OAAO,UAAoB,SAAiB,MAAc,UAAmB;AACvG,MAAI;AACF,UAAM,YAAY,MAAM,SAAS,WAAW,SAAS,MAAM,KAAK;AAChE,WAAO,aAAa,iBAAiB,WAAW,EAAE,QAAQ,KAAK,CAAC,CAAC;AAAA,EACnE,QAAQ;AACN;AAAA,EACF;AACF;AAEO,IAAM,uBAAuB,OAAO,UAAoB,SAAiB,UAA+C;AAC7H,QAAM,SAA4B;AAAA,IAChC;AAAA,IACA,gBAAgB;AAAA,IAChB,OAAO;AAAA,MACL,OAAO,MAAM,oBAAoB,UAAU,SAAS,kCAAkC,KAAK;AAAA,MAC3F,QAAQ,MAAM,oBAAoB,UAAU,SAAS,mCAAmC,KAAK;AAAA,MAC7F,gBAAgB,MAAM,oBAAoB,UAAU,SAAS,2CAA2C,KAAK;AAAA,MAC7G,UAAU,MAAM,oBAAoB,UAAU,SAAS,qCAAqC,KAAK;AAAA,IACnG;AAAA,EACF;AAEA,MAAI,OAAO,MAAM,kBAAkB,CAAC,UAAU,OAAO,MAAM,cAAc,GAAG;AAC1E,WAAO,iBAAiB,KAAK,OAAO,OAAO,MAAM,cAAwB,EACtE,SAAS,EAAE,EACX,SAAS,IAAI,GAAG,CAAC;AAAA,EACtB,OAAO;AACL,QAAI,OAAO,MAAM,UAAU,CAAC,UAAU,OAAO,MAAM,MAAM,GAAG;AAC1D,YAAM,SAAS,2BAA2B,QAAQ,OAAO,MAAM,QAAkB,EAAE,SAAS,CAAC;AAC7F,UAAI;AACF,cAAM,iBA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AAQ,MAAM,SAAS,WAAW,GAAG,OAAO;AAAA,YACrD;AAAA,YACA,QAAQ;AAAA,YACR;AAAA,UACF;AACA,iBAAO;AAAA,QACT,CAAC;AAAA,MACH;AACA,aAAO;AAAA,IACT,SAAS,IAAI;AACX,YAAM,QAAQ;AACd,cAAQ,IAAI,UAAU,KAAK,OAAO,IAAI,MAAM,MAAM,OAAO,EAAE;AAC3D,YAAM;AAAA,IACR;AAAA,EACF;AACF;","names":["asSchema","asSchema"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/erc1967-witness",
3
- "version": "5.2.3",
3
+ "version": "5.3.1",
4
4
  "description": "Typescript/Javascript Plugins for XYO Platform",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -36,21 +36,21 @@
36
36
  "!**/*.test.*"
37
37
  ],
38
38
  "dependencies": {
39
- "@xylabs/assert": "~5.0.49",
40
- "@xylabs/hex": "~5.0.49",
41
- "@xyo-network/open-zeppelin-typechain": "~4.0.11",
42
- "@xyo-network/payload-model": "~5.2.14",
43
- "@xyo-network/witness-evm-abstract": "~5.2.14",
44
- "ethers": "~6.16.0"
39
+ "@xylabs/assert": "~5.0.64",
40
+ "@xylabs/hex": "~5.0.64",
41
+ "@xyo-network/open-zeppelin-typechain": "~4.1.1",
42
+ "@xyo-network/payload-model": "~5.3.2",
43
+ "@xyo-network/witness-evm-abstract": "~5.3.2",
44
+ "ethers": "^6.16.0"
45
45
  },
46
46
  "devDependencies": {
47
- "@xylabs/ts-scripts-yarn3": "~7.2.8",
48
- "@xylabs/tsconfig": "~7.2.8",
49
- "@xylabs/vitest-extended": "~5.0.49",
47
+ "@xylabs/ts-scripts-yarn3": "~7.3.2",
48
+ "@xylabs/tsconfig": "~7.3.2",
49
+ "@xylabs/vitest-extended": "~5.0.64",
50
50
  "typescript": "~5.9.3",
51
- "vitest": "~4.0.15"
51
+ "vitest": "~4.0.18"
52
52
  },
53
53
  "publishConfig": {
54
54
  "access": "public"
55
55
  }
56
- }
56
+ }
package/src/Payload.ts CHANGED
@@ -1,8 +1,8 @@
1
- import type { Payload } from '@xyo-network/payload-model'
1
+ import { asSchema, type Payload } from '@xyo-network/payload-model'
2
2
 
3
3
  import type { Erc1967SlotStatus } from './lib/index.ts'
4
4
 
5
- export const Erc1967StatusSchema = 'network.xyo.erc1967.status'
5
+ export const Erc1967StatusSchema = asSchema('network.xyo.erc1967.status', true)
6
6
  export type Erc1967StatusSchema = typeof Erc1967StatusSchema
7
7
 
8
8
  export type Erc1967Status = Payload<
package/src/Witness.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { assertEx } from '@xylabs/assert'
2
2
  import type { Schema } from '@xyo-network/payload-model'
3
- import { isPayloadOfSchemaType } from '@xyo-network/payload-model'
3
+ import { asSchema, isPayloadOfSchemaType } from '@xyo-network/payload-model'
4
4
  import type {
5
5
  EvmAddress,
6
6
  EvmWitnessConfig, EvmWitnessParams,
@@ -11,7 +11,7 @@ import { getErc1967SlotStatus } from './lib/index.ts'
11
11
  import type { Erc1967Status } from './Payload.ts'
12
12
  import { Erc1967StatusSchema } from './Payload.ts'
13
13
 
14
- export const Erc1967WitnessConfigSchema = 'network.xyo.erc1967.witness.config'
14
+ export const Erc1967WitnessConfigSchema = asSchema('network.xyo.erc1967.witness.config', true)
15
15
  export type Erc1967WitnessConfigSchema = typeof Erc1967WitnessConfigSchema
16
16
 
17
17
  export type Erc1967WitnessConfig = EvmWitnessConfig<{ address?: string }, Erc1967WitnessConfigSchema>