@xyo-network/erc1822-witness 5.3.1 → 5.3.3

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 +1 @@
1
- {"version":3,"file":"Witness.d.ts","sourceRoot":"","sources":["../../src/Witness.ts"],"names":[],"mappings":"AAEA,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;;CAAuD,CAAA;AAC9F,MAAM,MAAM,0BAA0B,GAAG,OAAO,0BAA0B,CAAA;AAE1E,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,CAAC;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,0BAA0B,CAAC,CAAA;AAErG,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,CAAC,oBAAoB,CAAC,CAAA;AAEzE,qBAAa,cAAc,CAAC,OAAO,SAAS,oBAAoB,GAAG,oBAAoB,CAAE,SAAQ,kBAAkB,CACjH,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;CAiCjG"}
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;;CAAuD,CAAA;AAC9F,MAAM,MAAM,0BAA0B,GAAG,OAAO,0BAA0B,CAAA;AAE1E,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,CAAC;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,0BAA0B,CAAC,CAAA;AAErG,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,CAAC,oBAAoB,CAAC,CAAA;AAEzE,qBAAa,cAAc,CAAC,OAAO,SAAS,oBAAoB,GAAG,oBAAoB,CAAE,SAAQ,kBAAkB,CACjH,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;CAiCjG"}
@@ -3,7 +3,7 @@ import {
3
3
  asEthAddress,
4
4
  hexFromHexString,
5
5
  isHexZero
6
- } from "@xylabs/hex";
6
+ } from "@xylabs/sdk-js";
7
7
  var ERC1822_PROXY_LOGIC_SLOT = "0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7";
8
8
  var readAddressFromSlot = async (provider, address, slot, block) => {
9
9
  try {
@@ -30,8 +30,7 @@ import { asSchema } from "@xyo-network/payload-model";
30
30
  var Erc1822StatusSchema = asSchema("network.xyo.erc1822.status", true);
31
31
 
32
32
  // src/Witness.ts
33
- import { assertEx } from "@xylabs/assert";
34
- import { asEthAddress as asEthAddress2 } from "@xylabs/hex";
33
+ import { asEthAddress as asEthAddress2, assertEx } from "@xylabs/sdk-js";
35
34
  import { asSchema as asSchema2, isPayloadOfSchemaType } from "@xyo-network/payload-model";
36
35
  import { AbstractEvmWitness, EvmAddressSchema } from "@xyo-network/witness-evm-abstract";
37
36
  var Erc1822WitnessConfigSchema = asSchema2("network.xyo.erc1822.witness.config", true);
@@ -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 { asSchema, type Payload } from '@xyo-network/payload-model'\n\nimport type { Erc1822SlotStatus } from './lib/index.ts'\n\nexport const Erc1822StatusSchema = asSchema('network.xyo.erc1822.status', true)\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 { 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 { getErc1822SlotStatus } from './lib/index.ts'\nimport type { Erc1822Status } from './Payload.ts'\nimport { Erc1822StatusSchema } from './Payload.ts'\n\nexport const Erc1822WitnessConfigSchema = asSchema('network.xyo.erc1822.witness.config', true)\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;AAEA,SAAO;AACT;;;ACvCA,SAAS,gBAA8B;AAIhC,IAAM,sBAAsB,SAAS,8BAA8B,IAAI;;;ACJ9E,SAAS,gBAAgB;AACzB,SAAS,gBAAAA,qBAAoB;AAE7B,SAAS,YAAAC,WAAU,6BAA6B;AAKhD,SAAS,oBAAoB,wBAAwB;AAM9C,IAAM,6BAA6BC,UAAS,sCAAsC,IAAI;AAOtF,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,aAAa,OAAO;AAE/B,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","asSchema","asSchema","asEthAddress"]}
1
+ {"version":3,"sources":["../../src/lib/getErc1822SlotStatus.ts","../../src/Payload.ts","../../src/Witness.ts"],"sourcesContent":["import type { EthAddress } from '@xylabs/sdk-js'\nimport {\n asEthAddress, hexFromHexString, isHexZero,\n} from '@xylabs/sdk-js'\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 { asSchema, type Payload } from '@xyo-network/payload-model'\n\nimport type { Erc1822SlotStatus } from './lib/index.ts'\n\nexport const Erc1822StatusSchema = asSchema('network.xyo.erc1822.status', true)\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 { asEthAddress, assertEx } from '@xylabs/sdk-js'\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 { getErc1822SlotStatus } from './lib/index.ts'\nimport type { Erc1822Status } from './Payload.ts'\nimport { Erc1822StatusSchema } from './Payload.ts'\n\nexport const Erc1822WitnessConfigSchema = asSchema('network.xyo.erc1822.witness.config', true)\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;AAEA,SAAO;AACT;;;ACvCA,SAAS,gBAA8B;AAIhC,IAAM,sBAAsB,SAAS,8BAA8B,IAAI;;;ACJ9E,SAAS,gBAAAA,eAAc,gBAAgB;AAEvC,SAAS,YAAAC,WAAU,6BAA6B;AAKhD,SAAS,oBAAoB,wBAAwB;AAM9C,IAAM,6BAA6BC,UAAS,sCAAsC,IAAI;AAOtF,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,aAAa,OAAO;AAE/B,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","asSchema","asSchema","asEthAddress"]}
@@ -1,4 +1,4 @@
1
- import type { EthAddress } from '@xylabs/hex';
1
+ import type { EthAddress } from '@xylabs/sdk-js';
2
2
  import type { Provider } from 'ethers';
3
3
  export declare const ERC1822_PROXY_LOGIC_SLOT = "0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7";
4
4
  export interface Erc1822DataSlots {
@@ -1 +1 @@
1
- {"version":3,"file":"getErc1822SlotStatus.d.ts","sourceRoot":"","sources":["../../../src/lib/getErc1822SlotStatus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAI7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAEtC,eAAO,MAAM,wBAAwB,uEAAuE,CAAA;AAE5G,MAAM,WAAW,gBAAgB;IAC/B,cAAc,CAAC,EAAE,UAAU,CAAA;CAC5B;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,UAAU,CAAA;IACnB,cAAc,EAAE,UAAU,CAAA;IAC1B,KAAK,EAAE,gBAAgB,CAAA;CACxB;AAWD,eAAO,MAAM,oBAAoB,GAAU,UAAU,QAAQ,EAAE,SAAS,UAAU,EAAE,QAAQ,MAAM,KAAG,OAAO,CAAC,iBAAiB,CAY7H,CAAA"}
1
+ {"version":3,"file":"getErc1822SlotStatus.d.ts","sourceRoot":"","sources":["../../../src/lib/getErc1822SlotStatus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAIhD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAEtC,eAAO,MAAM,wBAAwB,uEAAuE,CAAA;AAE5G,MAAM,WAAW,gBAAgB;IAC/B,cAAc,CAAC,EAAE,UAAU,CAAA;CAC5B;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,UAAU,CAAA;IACnB,cAAc,EAAE,UAAU,CAAA;IAC1B,KAAK,EAAE,gBAAgB,CAAA;CACxB;AAWD,eAAO,MAAM,oBAAoB,GAAU,UAAU,QAAQ,EAAE,SAAS,UAAU,EAAE,QAAQ,MAAM,KAAG,OAAO,CAAC,iBAAiB,CAY7H,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/erc1822-witness",
3
- "version": "5.3.1",
3
+ "version": "5.3.3",
4
4
  "description": "Typescript/Javascript Plugins for XYO Platform",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -30,24 +30,27 @@
30
30
  "types": "dist/neutral/index.d.ts",
31
31
  "files": [
32
32
  "dist",
33
- "src",
34
- "!**/*.bench.*",
35
- "!**/*.spec.*",
36
- "!**/*.test.*"
33
+ "README.md"
37
34
  ],
38
- "dependencies": {
39
- "@xylabs/assert": "~5.0.64",
40
- "@xylabs/hex": "~5.0.64",
41
- "@xyo-network/payload-model": "~5.3.2",
42
- "@xyo-network/witness-evm-abstract": "~5.3.2",
43
- "ethers": "^6.16.0"
44
- },
45
35
  "devDependencies": {
46
- "@xylabs/ts-scripts-yarn3": "~7.3.2",
47
- "@xylabs/tsconfig": "~7.3.2",
48
- "@xylabs/vitest-extended": "~5.0.64",
36
+ "@xylabs/sdk-js": "^5.0.90",
37
+ "@xylabs/ts-scripts-common": "~7.5.10",
38
+ "@xylabs/ts-scripts-yarn3": "~7.5.10",
39
+ "@xylabs/tsconfig": "~7.5.10",
40
+ "@xylabs/vitest-extended": "~5.0.90",
41
+ "@xyo-network/payload-model": "~5.3.5",
42
+ "@xyo-network/witness-evm-abstract": "~5.3.5",
43
+ "ethers": "^6.16.0",
49
44
  "typescript": "~5.9.3",
50
- "vitest": "~4.0.18"
45
+ "vitest": "~4.1.2",
46
+ "zod": "^4.3.6"
47
+ },
48
+ "peerDependencies": {
49
+ "@xylabs/sdk-js": "^5",
50
+ "@xyo-network/payload-model": "^5",
51
+ "@xyo-network/witness-evm-abstract": "^5",
52
+ "ethers": "^6",
53
+ "zod": "^4"
51
54
  },
52
55
  "publishConfig": {
53
56
  "access": "public"
package/src/Payload.ts DELETED
@@ -1,17 +0,0 @@
1
- import { asSchema, type Payload } from '@xyo-network/payload-model'
2
-
3
- import type { Erc1822SlotStatus } from './lib/index.ts'
4
-
5
- export const Erc1822StatusSchema = asSchema('network.xyo.erc1822.status', true)
6
- export type Erc1822StatusSchema = typeof Erc1822StatusSchema
7
-
8
- export type Erc1822Status = Payload<
9
- {
10
- address: string
11
- block: number
12
- chainId: number
13
- implementation?: Erc1822SlotStatus['implementation']
14
- slots?: Erc1822SlotStatus['slots']
15
- },
16
- Erc1822StatusSchema
17
- >
package/src/Witness.ts DELETED
@@ -1,63 +0,0 @@
1
- import { assertEx } from '@xylabs/assert'
2
- import { asEthAddress } from '@xylabs/hex'
3
- import type { Schema } from '@xyo-network/payload-model'
4
- import { asSchema, isPayloadOfSchemaType } from '@xyo-network/payload-model'
5
- import type {
6
- EvmAddress,
7
- EvmWitnessConfig, EvmWitnessParams,
8
- } from '@xyo-network/witness-evm-abstract'
9
- import { AbstractEvmWitness, EvmAddressSchema } from '@xyo-network/witness-evm-abstract'
10
-
11
- import { getErc1822SlotStatus } from './lib/index.ts'
12
- import type { Erc1822Status } from './Payload.ts'
13
- import { Erc1822StatusSchema } from './Payload.ts'
14
-
15
- export const Erc1822WitnessConfigSchema = asSchema('network.xyo.erc1822.witness.config', true)
16
- export type Erc1822WitnessConfigSchema = typeof Erc1822WitnessConfigSchema
17
-
18
- export type Erc1822WitnessConfig = EvmWitnessConfig<{ address?: string }, Erc1822WitnessConfigSchema>
19
-
20
- export type Erc1822WitnessParams = EvmWitnessParams<Erc1822WitnessConfig>
21
-
22
- export class Erc1822Witness<TParams extends Erc1822WitnessParams = Erc1822WitnessParams> extends AbstractEvmWitness<
23
- TParams,
24
- EvmAddress,
25
- Erc1822Status
26
- > {
27
- static override readonly configSchemas: Schema[] = [...super.configSchemas, Erc1822WitnessConfigSchema]
28
- static override readonly defaultConfigSchema: Schema = Erc1822WitnessConfigSchema
29
-
30
- protected override async observeHandler(inPayloads: EvmAddress[] = []): Promise<Erc1822Status[]> {
31
- await this.startedAsync('throw')
32
- // calling it here to make sure we rests the cache
33
- await this.getProviders()
34
- try {
35
- const observations = await Promise.all(
36
- inPayloads.filter(isPayloadOfSchemaType<EvmAddress>(EvmAddressSchema)).map(async ({ address }) => {
37
- const validatedAddress = asEthAddress(assertEx(address ?? this.config.address, () => 'Missing address'), true)
38
-
39
- const provider = await this.getProvider(true, true)
40
-
41
- const block = await provider.getBlockNumber()
42
-
43
- const { implementation, slots } = await getErc1822SlotStatus(provider, validatedAddress, block)
44
-
45
- const observation: Erc1822Status = {
46
- address: validatedAddress,
47
- block,
48
- chainId: Number((await provider.getNetwork()).chainId),
49
- implementation,
50
- schema: Erc1822StatusSchema,
51
- slots,
52
- }
53
- return observation
54
- }),
55
- )
56
- return observations
57
- } catch (ex) {
58
- const error = ex as Error
59
- console.log(`Error [${this.config.name}]: ${error.message}`)
60
- throw error
61
- }
62
- }
63
- }
package/src/index.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from './lib/index.ts'
2
- export * from './Payload.ts'
3
- export * from './Witness.ts'
@@ -1,40 +0,0 @@
1
- import type { EthAddress } from '@xylabs/hex'
2
- import {
3
- asEthAddress, hexFromHexString, isHexZero,
4
- } from '@xylabs/hex'
5
- import type { Provider } from 'ethers'
6
-
7
- export const ERC1822_PROXY_LOGIC_SLOT = '0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7'
8
-
9
- export interface Erc1822DataSlots {
10
- implementation?: EthAddress
11
- }
12
-
13
- export interface Erc1822SlotStatus {
14
- address: EthAddress
15
- implementation: EthAddress
16
- slots: Erc1822DataSlots
17
- }
18
-
19
- const readAddressFromSlot = async (provider: Provider, address: string, slot: string, block?: number) => {
20
- try {
21
- const slotValue = await provider.getStorage(address, slot, block)
22
- return asEthAddress(hexFromHexString(slotValue, { prefix: true }))
23
- } catch {
24
- return
25
- }
26
- }
27
-
28
- export const getErc1822SlotStatus = async (provider: Provider, address: EthAddress, block?: number): Promise<Erc1822SlotStatus> => {
29
- const status: Erc1822SlotStatus = {
30
- address,
31
- implementation: address,
32
- slots: { implementation: await readAddressFromSlot(provider, address, ERC1822_PROXY_LOGIC_SLOT, block) },
33
- }
34
-
35
- if (status.slots.implementation && !isHexZero(status.slots.implementation)) {
36
- status.implementation = status.slots.implementation
37
- }
38
-
39
- return status
40
- }
package/src/lib/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from './getErc1822SlotStatus.ts'