@xyo-network/erc1822-witness 5.2.0 → 5.2.2

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.
@@ -38,7 +38,7 @@ var Erc1822Witness = class extends AbstractEvmWitness {
38
38
  static configSchemas = [...super.configSchemas, Erc1822WitnessConfigSchema];
39
39
  static defaultConfigSchema = Erc1822WitnessConfigSchema;
40
40
  async observeHandler(inPayloads = []) {
41
- await this.started("throw");
41
+ await this.startedAsync("throw");
42
42
  await this.getProviders();
43
43
  try {
44
44
  const observations = await Promise.all(
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/getErc1822SlotStatus.ts","../../src/Payload.ts","../../src/Witness.ts"],"sourcesContent":["import type { EthAddress } from '@xylabs/hex'\nimport {\n asEthAddress, hexFromHexString, isHexZero,\n} from '@xylabs/hex'\nimport type { Provider } from 'ethers'\n\nexport const ERC1822_PROXY_LOGIC_SLOT = '0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7'\n\nexport interface Erc1822DataSlots {\n implementation?: EthAddress\n}\n\nexport interface Erc1822SlotStatus {\n address: EthAddress\n implementation: EthAddress\n slots: Erc1822DataSlots\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 getErc1822SlotStatus = async (provider: Provider, address: EthAddress, block?: number): Promise<Erc1822SlotStatus> => {\n const status: Erc1822SlotStatus = {\n address,\n implementation: address,\n slots: { implementation: await readAddressFromSlot(provider, address, ERC1822_PROXY_LOGIC_SLOT, block) },\n }\n\n if (status.slots.implementation && !isHexZero(status.slots.implementation)) {\n status.implementation = status.slots.implementation\n }\n\n return status\n}\n","import type { Payload } from '@xyo-network/payload-model'\n\nimport type { Erc1822SlotStatus } from './lib/index.ts'\n\nexport const Erc1822StatusSchema = 'network.xyo.erc1822.status'\nexport type Erc1822StatusSchema = typeof Erc1822StatusSchema\n\nexport type Erc1822Status = Payload<\n {\n address: string\n block: number\n chainId: number\n implementation?: Erc1822SlotStatus['implementation']\n slots?: Erc1822SlotStatus['slots']\n },\n Erc1822StatusSchema\n>\n","import { assertEx } from '@xylabs/assert'\nimport { asEthAddress } from '@xylabs/hex'\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 { getErc1822SlotStatus } from './lib/index.ts'\nimport type { Erc1822Status } from './Payload.ts'\nimport { Erc1822StatusSchema } from './Payload.ts'\n\nexport const Erc1822WitnessConfigSchema = 'network.xyo.erc1822.witness.config'\nexport type Erc1822WitnessConfigSchema = typeof Erc1822WitnessConfigSchema\n\nexport type Erc1822WitnessConfig = EvmWitnessConfig<{ address?: string }, Erc1822WitnessConfigSchema>\n\nexport type Erc1822WitnessParams = EvmWitnessParams<Erc1822WitnessConfig>\n\nexport class Erc1822Witness<TParams extends Erc1822WitnessParams = Erc1822WitnessParams> extends AbstractEvmWitness<\n TParams,\n EvmAddress,\n Erc1822Status\n> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, Erc1822WitnessConfigSchema]\n static override readonly defaultConfigSchema: Schema = Erc1822WitnessConfigSchema\n\n protected override async observeHandler(inPayloads: EvmAddress[] = []): Promise<Erc1822Status[]> {\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 = asEthAddress(assertEx(address ?? this.config.address, () => 'Missing address'), true)\n\n const provider = await this.getProvider(true, true)\n\n const block = await provider.getBlockNumber()\n\n const { implementation, slots } = await getErc1822SlotStatus(provider, validatedAddress, block)\n\n const observation: Erc1822Status = {\n address: validatedAddress,\n block,\n chainId: Number((await provider.getNetwork()).chainId),\n implementation,\n schema: Erc1822StatusSchema,\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;AAGA,IAAM,2BAA2B;AAYxC,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,SAAqB,UAA+C;AACjI,QAAM,SAA4B;AAAA,IAChC;AAAA,IACA,gBAAgB;AAAA,IAChB,OAAO,EAAE,gBAAgB,MAAM,oBAAoB,UAAU,SAAS,0BAA0B,KAAK,EAAE;AAAA,EACzG;AAEA,MAAI,OAAO,MAAM,kBAAkB,CAAC,UAAU,OAAO,MAAM,cAAc,GAAG;AAC1E,WAAO,iBAAiB,OAAO,MAAM;AAAA,EACvC;AAEA,SAAO;AACT;;;ACnCO,IAAM,sBAAsB;;;ACJnC,SAAS,gBAAgB;AACzB,SAAS,gBAAAA,qBAAoB;AAE7B,SAAS,6BAA6B;AAKtC,SAAS,oBAAoB,wBAAwB;AAM9C,IAAM,6BAA6B;AAOnC,IAAM,iBAAN,cAA0F,mBAI/F;AAAA,EACA,OAAyB,gBAA0B,CAAC,GAAG,MAAM,eAAe,0BAA0B;AAAA,EACtG,OAAyB,sBAA8B;AAAA,EAEvD,MAAyB,eAAe,aAA2B,CAAC,GAA6B;AAC/F,UAAM,KAAK,QAAQ,OAAO;AAE1B,UAAM,KAAK,aAAa;AACxB,QAAI;AACF,YAAM,eAAe,MAAM,QAAQ;AAAA,QACjC,WAAW,OAAO,sBAAkC,gBAAgB,CAAC,EAAE,IAAI,OAAO,EAAE,QAAQ,MAAM;AAChG,gBAAM,mBAAmBC,cAAa,SAAS,WAAW,KAAK,OAAO,SAAS,MAAM,iBAAiB,GAAG,IAAI;AAE7G,gBAAM,WAAW,MAAM,KAAK,YAAY,MAAM,IAAI;AAElD,gBAAM,QAAQ,MAAM,SAAS,eAAe;AAE5C,gBAAM,EAAE,gBAAgB,MAAM,IAAI,MAAM,qBAAqB,UAAU,kBAAkB,KAAK;AAE9F,gBAAM,cAA6B;AAAA,YACjC,SAAS;AAAA,YACT;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":["asEthAddress","asEthAddress"]}
1
+ {"version":3,"sources":["../../src/lib/getErc1822SlotStatus.ts","../../src/Payload.ts","../../src/Witness.ts"],"sourcesContent":["import type { EthAddress } from '@xylabs/hex'\nimport {\n asEthAddress, hexFromHexString, isHexZero,\n} from '@xylabs/hex'\nimport type { Provider } from 'ethers'\n\nexport const ERC1822_PROXY_LOGIC_SLOT = '0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7'\n\nexport interface Erc1822DataSlots {\n implementation?: EthAddress\n}\n\nexport interface Erc1822SlotStatus {\n address: EthAddress\n implementation: EthAddress\n slots: Erc1822DataSlots\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 getErc1822SlotStatus = async (provider: Provider, address: EthAddress, block?: number): Promise<Erc1822SlotStatus> => {\n const status: Erc1822SlotStatus = {\n address,\n implementation: address,\n slots: { implementation: await readAddressFromSlot(provider, address, ERC1822_PROXY_LOGIC_SLOT, block) },\n }\n\n if (status.slots.implementation && !isHexZero(status.slots.implementation)) {\n status.implementation = status.slots.implementation\n }\n\n return status\n}\n","import type { Payload } from '@xyo-network/payload-model'\n\nimport type { Erc1822SlotStatus } from './lib/index.ts'\n\nexport const Erc1822StatusSchema = 'network.xyo.erc1822.status'\nexport type Erc1822StatusSchema = typeof Erc1822StatusSchema\n\nexport type Erc1822Status = Payload<\n {\n address: string\n block: number\n chainId: number\n implementation?: Erc1822SlotStatus['implementation']\n slots?: Erc1822SlotStatus['slots']\n },\n Erc1822StatusSchema\n>\n","import { assertEx } from '@xylabs/assert'\nimport { asEthAddress } from '@xylabs/hex'\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 { getErc1822SlotStatus } from './lib/index.ts'\nimport type { Erc1822Status } from './Payload.ts'\nimport { Erc1822StatusSchema } from './Payload.ts'\n\nexport const Erc1822WitnessConfigSchema = 'network.xyo.erc1822.witness.config'\nexport type Erc1822WitnessConfigSchema = typeof Erc1822WitnessConfigSchema\n\nexport type Erc1822WitnessConfig = EvmWitnessConfig<{ address?: string }, Erc1822WitnessConfigSchema>\n\nexport type Erc1822WitnessParams = EvmWitnessParams<Erc1822WitnessConfig>\n\nexport class Erc1822Witness<TParams extends Erc1822WitnessParams = Erc1822WitnessParams> extends AbstractEvmWitness<\n TParams,\n EvmAddress,\n Erc1822Status\n> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, Erc1822WitnessConfigSchema]\n static override readonly defaultConfigSchema: Schema = Erc1822WitnessConfigSchema\n\n protected override async observeHandler(inPayloads: EvmAddress[] = []): Promise<Erc1822Status[]> {\n await this.startedAsync('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 = asEthAddress(assertEx(address ?? this.config.address, () => 'Missing address'), true)\n\n const provider = await this.getProvider(true, true)\n\n const block = await provider.getBlockNumber()\n\n const { implementation, slots } = await getErc1822SlotStatus(provider, validatedAddress, block)\n\n const observation: Erc1822Status = {\n address: validatedAddress,\n block,\n chainId: Number((await provider.getNetwork()).chainId),\n implementation,\n schema: Erc1822StatusSchema,\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;AAGA,IAAM,2BAA2B;AAYxC,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,SAAqB,UAA+C;AACjI,QAAM,SAA4B;AAAA,IAChC;AAAA,IACA,gBAAgB;AAAA,IAChB,OAAO,EAAE,gBAAgB,MAAM,oBAAoB,UAAU,SAAS,0BAA0B,KAAK,EAAE;AAAA,EACzG;AAEA,MAAI,OAAO,MAAM,kBAAkB,CAAC,UAAU,OAAO,MAAM,cAAc,GAAG;AAC1E,WAAO,iBAAiB,OAAO,MAAM;AAAA,EACvC;AA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",
3
+ "version": "5.2.2",
4
4
  "description": "Typescript/Javascript Plugins for XYO Platform",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -36,18 +36,18 @@
36
36
  "!**/*.test.*"
37
37
  ],
38
38
  "dependencies": {
39
- "@xylabs/assert": "~5.0.39",
40
- "@xylabs/hex": "~5.0.39",
41
- "@xyo-network/payload-model": "~5.2.1",
42
- "@xyo-network/witness-evm-abstract": "~5.2.1",
43
- "ethers": "~6.15.0"
39
+ "@xylabs/assert": "~5.0.49",
40
+ "@xylabs/hex": "~5.0.49",
41
+ "@xyo-network/payload-model": "~5.2.14",
42
+ "@xyo-network/witness-evm-abstract": "~5.2.14",
43
+ "ethers": "~6.16.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@xylabs/ts-scripts-yarn3": "~7.2.8",
47
47
  "@xylabs/tsconfig": "~7.2.8",
48
- "@xylabs/vitest-extended": "~5.0.39",
48
+ "@xylabs/vitest-extended": "~5.0.49",
49
49
  "typescript": "~5.9.3",
50
- "vitest": "~4.0.10"
50
+ "vitest": "~4.0.15"
51
51
  },
52
52
  "publishConfig": {
53
53
  "access": "public"
package/src/Witness.ts CHANGED
@@ -28,7 +28,7 @@ export class Erc1822Witness<TParams extends Erc1822WitnessParams = Erc1822Witnes
28
28
  static override readonly defaultConfigSchema: Schema = Erc1822WitnessConfigSchema
29
29
 
30
30
  protected override async observeHandler(inPayloads: EvmAddress[] = []): Promise<Erc1822Status[]> {
31
- await this.started('throw')
31
+ await this.startedAsync('throw')
32
32
  // calling it here to make sure we rests the cache
33
33
  await this.getProviders()
34
34
  try {