@xyo-network/erc1822-witness 5.3.2 → 5.3.4

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.
@@ -0,0 +1,14 @@
1
+ import { type Payload } from '@xyo-network/payload-model';
2
+ import type { Erc1822SlotStatus } from './lib/index.ts';
3
+ export declare const Erc1822StatusSchema: "network.xyo.erc1822.status" & {
4
+ readonly __schema: true;
5
+ };
6
+ export type Erc1822StatusSchema = typeof Erc1822StatusSchema;
7
+ export type Erc1822Status = Payload<{
8
+ address: string;
9
+ block: number;
10
+ chainId: number;
11
+ implementation?: Erc1822SlotStatus['implementation'];
12
+ slots?: Erc1822SlotStatus['slots'];
13
+ }, Erc1822StatusSchema>;
14
+ //# sourceMappingURL=Payload.d.ts.map
@@ -0,0 +1 @@
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,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"}
@@ -0,0 +1,18 @@
1
+ import type { Schema } from '@xyo-network/payload-model';
2
+ import type { EvmAddress, EvmWitnessConfig, EvmWitnessParams } from '@xyo-network/witness-evm-abstract';
3
+ import { AbstractEvmWitness } from '@xyo-network/witness-evm-abstract';
4
+ import type { Erc1822Status } from './Payload.ts';
5
+ export declare const Erc1822WitnessConfigSchema: "network.xyo.erc1822.witness.config" & {
6
+ readonly __schema: true;
7
+ };
8
+ export type Erc1822WitnessConfigSchema = typeof Erc1822WitnessConfigSchema;
9
+ export type Erc1822WitnessConfig = EvmWitnessConfig<{
10
+ address?: string;
11
+ }, Erc1822WitnessConfigSchema>;
12
+ export type Erc1822WitnessParams = EvmWitnessParams<Erc1822WitnessConfig>;
13
+ export declare class Erc1822Witness<TParams extends Erc1822WitnessParams = Erc1822WitnessParams> extends AbstractEvmWitness<TParams, EvmAddress, Erc1822Status> {
14
+ static readonly configSchemas: Schema[];
15
+ static readonly defaultConfigSchema: Schema;
16
+ protected observeHandler(inPayloads?: EvmAddress[]): Promise<Erc1822Status[]>;
17
+ }
18
+ //# sourceMappingURL=Witness.d.ts.map
@@ -0,0 +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;;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"}
@@ -0,0 +1,4 @@
1
+ export * from './lib/index.ts';
2
+ export * from './Payload.ts';
3
+ export * from './Witness.ts';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA"}
@@ -0,0 +1,76 @@
1
+ // src/lib/getErc1822SlotStatus.ts
2
+ import {
3
+ asEthAddress,
4
+ hexFromHexString,
5
+ isHexZero
6
+ } from "@xylabs/sdk-js";
7
+ var ERC1822_PROXY_LOGIC_SLOT = "0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7";
8
+ var readAddressFromSlot = async (provider, address, slot, block) => {
9
+ try {
10
+ const slotValue = await provider.getStorage(address, slot, block);
11
+ return asEthAddress(hexFromHexString(slotValue, { prefix: true }));
12
+ } catch {
13
+ return;
14
+ }
15
+ };
16
+ var getErc1822SlotStatus = async (provider, address, block) => {
17
+ const status = {
18
+ address,
19
+ implementation: address,
20
+ slots: { implementation: await readAddressFromSlot(provider, address, ERC1822_PROXY_LOGIC_SLOT, block) }
21
+ };
22
+ if (status.slots.implementation && !isHexZero(status.slots.implementation)) {
23
+ status.implementation = status.slots.implementation;
24
+ }
25
+ return status;
26
+ };
27
+
28
+ // src/Payload.ts
29
+ import { asSchema } from "@xyo-network/payload-model";
30
+ var Erc1822StatusSchema = asSchema("network.xyo.erc1822.status", true);
31
+
32
+ // src/Witness.ts
33
+ import { asEthAddress as asEthAddress2, assertEx } from "@xylabs/sdk-js";
34
+ import { asSchema as asSchema2, isPayloadOfSchemaType } from "@xyo-network/payload-model";
35
+ import { AbstractEvmWitness, EvmAddressSchema } from "@xyo-network/witness-evm-abstract";
36
+ var Erc1822WitnessConfigSchema = asSchema2("network.xyo.erc1822.witness.config", true);
37
+ var Erc1822Witness = class extends AbstractEvmWitness {
38
+ static configSchemas = [...super.configSchemas, Erc1822WitnessConfigSchema];
39
+ static defaultConfigSchema = Erc1822WitnessConfigSchema;
40
+ async observeHandler(inPayloads = []) {
41
+ await this.startedAsync("throw");
42
+ await this.getProviders();
43
+ try {
44
+ const observations = await Promise.all(
45
+ inPayloads.filter(isPayloadOfSchemaType(EvmAddressSchema)).map(async ({ address }) => {
46
+ const validatedAddress = asEthAddress2(assertEx(address ?? this.config.address, () => "Missing address"), true);
47
+ const provider = await this.getProvider(true, true);
48
+ const block = await provider.getBlockNumber();
49
+ const { implementation, slots } = await getErc1822SlotStatus(provider, validatedAddress, block);
50
+ const observation = {
51
+ address: validatedAddress,
52
+ block,
53
+ chainId: Number((await provider.getNetwork()).chainId),
54
+ implementation,
55
+ schema: Erc1822StatusSchema,
56
+ slots
57
+ };
58
+ return observation;
59
+ })
60
+ );
61
+ return observations;
62
+ } catch (ex) {
63
+ const error = ex;
64
+ console.log(`Error [${this.config.name}]: ${error.message}`);
65
+ throw error;
66
+ }
67
+ }
68
+ };
69
+ export {
70
+ ERC1822_PROXY_LOGIC_SLOT,
71
+ Erc1822StatusSchema,
72
+ Erc1822Witness,
73
+ Erc1822WitnessConfigSchema,
74
+ getErc1822SlotStatus
75
+ };
76
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
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"]}
@@ -0,0 +1,13 @@
1
+ import type { EthAddress } from '@xylabs/sdk-js';
2
+ import type { Provider } from 'ethers';
3
+ export declare const ERC1822_PROXY_LOGIC_SLOT = "0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7";
4
+ export interface Erc1822DataSlots {
5
+ implementation?: EthAddress;
6
+ }
7
+ export interface Erc1822SlotStatus {
8
+ address: EthAddress;
9
+ implementation: EthAddress;
10
+ slots: Erc1822DataSlots;
11
+ }
12
+ export declare const getErc1822SlotStatus: (provider: Provider, address: EthAddress, block?: number) => Promise<Erc1822SlotStatus>;
13
+ //# sourceMappingURL=getErc1822SlotStatus.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,2 @@
1
+ export * from './getErc1822SlotStatus.ts';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/erc1822-witness",
3
- "version": "5.3.2",
3
+ "version": "5.3.4",
4
4
  "description": "Typescript/Javascript Plugins for XYO Platform",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -30,13 +30,11 @@
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
35
  "devDependencies": {
39
36
  "@xylabs/sdk-js": "^5.0.90",
37
+ "@xylabs/ts-scripts-common": "~7.5.10",
40
38
  "@xylabs/ts-scripts-yarn3": "~7.5.10",
41
39
  "@xylabs/tsconfig": "~7.5.10",
42
40
  "@xylabs/vitest-extended": "~5.0.90",
@@ -49,6 +47,8 @@
49
47
  },
50
48
  "peerDependencies": {
51
49
  "@xylabs/sdk-js": "^5",
50
+ "@xyo-network/payload-model": "^5",
51
+ "@xyo-network/witness-evm-abstract": "^5",
52
52
  "ethers": "^6",
53
53
  "zod": "^4"
54
54
  },
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,62 +0,0 @@
1
- import { asEthAddress, assertEx } from '@xylabs/sdk-js'
2
- import type { Schema } from '@xyo-network/payload-model'
3
- import { asSchema, isPayloadOfSchemaType } from '@xyo-network/payload-model'
4
- import type {
5
- EvmAddress,
6
- EvmWitnessConfig, EvmWitnessParams,
7
- } from '@xyo-network/witness-evm-abstract'
8
- import { AbstractEvmWitness, EvmAddressSchema } from '@xyo-network/witness-evm-abstract'
9
-
10
- import { getErc1822SlotStatus } from './lib/index.ts'
11
- import type { Erc1822Status } from './Payload.ts'
12
- import { Erc1822StatusSchema } from './Payload.ts'
13
-
14
- export const Erc1822WitnessConfigSchema = asSchema('network.xyo.erc1822.witness.config', true)
15
- export type Erc1822WitnessConfigSchema = typeof Erc1822WitnessConfigSchema
16
-
17
- export type Erc1822WitnessConfig = EvmWitnessConfig<{ address?: string }, Erc1822WitnessConfigSchema>
18
-
19
- export type Erc1822WitnessParams = EvmWitnessParams<Erc1822WitnessConfig>
20
-
21
- export class Erc1822Witness<TParams extends Erc1822WitnessParams = Erc1822WitnessParams> extends AbstractEvmWitness<
22
- TParams,
23
- EvmAddress,
24
- Erc1822Status
25
- > {
26
- static override readonly configSchemas: Schema[] = [...super.configSchemas, Erc1822WitnessConfigSchema]
27
- static override readonly defaultConfigSchema: Schema = Erc1822WitnessConfigSchema
28
-
29
- protected override async observeHandler(inPayloads: EvmAddress[] = []): Promise<Erc1822Status[]> {
30
- await this.startedAsync('throw')
31
- // calling it here to make sure we rests the cache
32
- await this.getProviders()
33
- try {
34
- const observations = await Promise.all(
35
- inPayloads.filter(isPayloadOfSchemaType<EvmAddress>(EvmAddressSchema)).map(async ({ address }) => {
36
- const validatedAddress = asEthAddress(assertEx(address ?? this.config.address, () => 'Missing address'), true)
37
-
38
- const provider = await this.getProvider(true, true)
39
-
40
- const block = await provider.getBlockNumber()
41
-
42
- const { implementation, slots } = await getErc1822SlotStatus(provider, validatedAddress, block)
43
-
44
- const observation: Erc1822Status = {
45
- address: validatedAddress,
46
- block,
47
- chainId: Number((await provider.getNetwork()).chainId),
48
- implementation,
49
- schema: Erc1822StatusSchema,
50
- slots,
51
- }
52
- return observation
53
- }),
54
- )
55
- return observations
56
- } catch (ex) {
57
- const error = ex as Error
58
- console.log(`Error [${this.config.name}]: ${error.message}`)
59
- throw error
60
- }
61
- }
62
- }
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/sdk-js'
2
- import {
3
- asEthAddress, hexFromHexString, isHexZero,
4
- } from '@xylabs/sdk-js'
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'