@xyo-network/erc1967-witness 2.84.1 → 2.84.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,12 +1,12 @@
1
1
  import { AbstractBlockchainWitness, BlockchainAddress, BlockchainWitnessConfig, BlockchainWitnessParams } from '@xyo-network/witness-blockchain-abstract';
2
2
  import { Erc1967Status } from './Payload';
3
- export declare const BlockchainErc1967WitnessConfigSchema = "network.xyo.blockchain.Erc1967.witness.config";
4
- export type BlockchainErc1967WitnessConfigSchema = typeof BlockchainErc1967WitnessConfigSchema;
5
- export type BlockchainErc1967WitnessConfig = BlockchainWitnessConfig<{
3
+ export declare const Erc1967WitnessConfigSchema = "network.xyo.erc1967.witness.config";
4
+ export type Erc1967WitnessConfigSchema = typeof Erc1967WitnessConfigSchema;
5
+ export type Erc1967WitnessConfig = BlockchainWitnessConfig<{
6
6
  address?: string;
7
- }, BlockchainErc1967WitnessConfigSchema>;
8
- export type BlockchainErc1967WitnessParams = BlockchainWitnessParams<BlockchainErc1967WitnessConfig>;
9
- export declare class BlockchainErc1967Witness<TParams extends BlockchainErc1967WitnessParams = BlockchainErc1967WitnessParams> extends AbstractBlockchainWitness<TParams, BlockchainAddress, Erc1967Status> {
7
+ }, Erc1967WitnessConfigSchema>;
8
+ export type Erc1967WitnessParams = BlockchainWitnessParams<Erc1967WitnessConfig>;
9
+ export declare class Erc1967Witness<TParams extends Erc1967WitnessParams = Erc1967WitnessParams> extends AbstractBlockchainWitness<TParams, BlockchainAddress, Erc1967Status> {
10
10
  static configSchemas: string[];
11
11
  protected observeHandler(inPayloads?: BlockchainAddress[]): Promise<Erc1967Status[]>;
12
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Witness.d.ts","sourceRoot":"","sources":["../../src/Witness.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,yBAAyB,EACzB,iBAAiB,EAEjB,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,0CAA0C,CAAA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;cAEnC,cAAc,CAAC,UAAU,GAAE,iBAAiB,EAAO,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;CAkCxG"}
@@ -1,12 +1,12 @@
1
1
  import { AbstractBlockchainWitness, BlockchainAddress, BlockchainWitnessConfig, BlockchainWitnessParams } from '@xyo-network/witness-blockchain-abstract';
2
2
  import { Erc1967Status } from './Payload';
3
- export declare const BlockchainErc1967WitnessConfigSchema = "network.xyo.blockchain.Erc1967.witness.config";
4
- export type BlockchainErc1967WitnessConfigSchema = typeof BlockchainErc1967WitnessConfigSchema;
5
- export type BlockchainErc1967WitnessConfig = BlockchainWitnessConfig<{
3
+ export declare const Erc1967WitnessConfigSchema = "network.xyo.erc1967.witness.config";
4
+ export type Erc1967WitnessConfigSchema = typeof Erc1967WitnessConfigSchema;
5
+ export type Erc1967WitnessConfig = BlockchainWitnessConfig<{
6
6
  address?: string;
7
- }, BlockchainErc1967WitnessConfigSchema>;
8
- export type BlockchainErc1967WitnessParams = BlockchainWitnessParams<BlockchainErc1967WitnessConfig>;
9
- export declare class BlockchainErc1967Witness<TParams extends BlockchainErc1967WitnessParams = BlockchainErc1967WitnessParams> extends AbstractBlockchainWitness<TParams, BlockchainAddress, Erc1967Status> {
7
+ }, Erc1967WitnessConfigSchema>;
8
+ export type Erc1967WitnessParams = BlockchainWitnessParams<Erc1967WitnessConfig>;
9
+ export declare class Erc1967Witness<TParams extends Erc1967WitnessParams = Erc1967WitnessParams> extends AbstractBlockchainWitness<TParams, BlockchainAddress, Erc1967Status> {
10
10
  static configSchemas: string[];
11
11
  protected observeHandler(inPayloads?: BlockchainAddress[]): Promise<Erc1967Status[]>;
12
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Witness.d.ts","sourceRoot":"","sources":["../../src/Witness.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,yBAAyB,EACzB,iBAAiB,EAEjB,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,0CAA0C,CAAA;AAGjD,OAAO,EAAE,aAA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U,GAAE,iBAAiB,EAAO,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;CAkCxG"}
@@ -1,12 +1,12 @@
1
1
  import { AbstractBlockchainWitness, BlockchainAddress, BlockchainWitnessConfig, BlockchainWitnessParams } from '@xyo-network/witness-blockchain-abstract';
2
2
  import { Erc1967Status } from './Payload';
3
- export declare const BlockchainErc1967WitnessConfigSchema = "network.xyo.blockchain.Erc1967.witness.config";
4
- export type BlockchainErc1967WitnessConfigSchema = typeof BlockchainErc1967WitnessConfigSchema;
5
- export type BlockchainErc1967WitnessConfig = BlockchainWitnessConfig<{
3
+ export declare const Erc1967WitnessConfigSchema = "network.xyo.erc1967.witness.config";
4
+ export type Erc1967WitnessConfigSchema = typeof Erc1967WitnessConfigSchema;
5
+ export type Erc1967WitnessConfig = BlockchainWitnessConfig<{
6
6
  address?: string;
7
- }, BlockchainErc1967WitnessConfigSchema>;
8
- export type BlockchainErc1967WitnessParams = BlockchainWitnessParams<BlockchainErc1967WitnessConfig>;
9
- export declare class BlockchainErc1967Witness<TParams extends BlockchainErc1967WitnessParams = BlockchainErc1967WitnessParams> extends AbstractBlockchainWitness<TParams, BlockchainAddress, Erc1967Status> {
7
+ }, Erc1967WitnessConfigSchema>;
8
+ export type Erc1967WitnessParams = BlockchainWitnessParams<Erc1967WitnessConfig>;
9
+ export declare class Erc1967Witness<TParams extends Erc1967WitnessParams = Erc1967WitnessParams> extends AbstractBlockchainWitness<TParams, BlockchainAddress, Erc1967Status> {
10
10
  static configSchemas: string[];
11
11
  protected observeHandler(inPayloads?: BlockchainAddress[]): Promise<Erc1967Status[]>;
12
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Witness.d.ts","sourceRoot":"","sources":["../../src/Witness.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,yBAAyB,EACzB,iBAAiB,EAEjB,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,0CAA0C,CAAA;AAGjD,OAAO,EAAE,aAAa,EAAuB,MAAM,WAAW,CA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AAG,OAAO,CAAC,aAAa,EAAE,CAAC;CAkCxG"}
@@ -20,13 +20,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var src_exports = {};
22
22
  __export(src_exports, {
23
- BlockchainErc1967Witness: () => BlockchainErc1967Witness,
24
- BlockchainErc1967WitnessConfigSchema: () => BlockchainErc1967WitnessConfigSchema,
25
23
  ERC1967_PROXY_ADMIN_STORAGE_SLOT: () => ERC1967_PROXY_ADMIN_STORAGE_SLOT,
26
24
  ERC1967_PROXY_BEACON_STORAGE_SLOT: () => ERC1967_PROXY_BEACON_STORAGE_SLOT,
27
25
  ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT: () => ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT,
28
26
  ERC1967_PROXY_ROLLBACK_STORAGE_SLOT: () => ERC1967_PROXY_ROLLBACK_STORAGE_SLOT,
29
27
  Erc1967StatusSchema: () => Erc1967StatusSchema,
28
+ Erc1967Witness: () => Erc1967Witness,
29
+ Erc1967WitnessConfigSchema: () => Erc1967WitnessConfigSchema,
30
30
  getErc1967SlotStatus: () => getErc1967SlotStatus
31
31
  });
32
32
  module.exports = __toCommonJS(src_exports);
@@ -86,16 +86,16 @@ var Erc1967StatusSchema = "network.xyo.erc1967.status";
86
86
  var import_assert = require("@xylabs/assert");
87
87
  var import_payload_model = require("@xyo-network/payload-model");
88
88
  var import_witness_blockchain_abstract = require("@xyo-network/witness-blockchain-abstract");
89
- var BlockchainErc1967WitnessConfigSchema = "network.xyo.blockchain.Erc1967.witness.config";
90
- var BlockchainErc1967Witness = class extends import_witness_blockchain_abstract.AbstractBlockchainWitness {
91
- static configSchemas = [BlockchainErc1967WitnessConfigSchema];
89
+ var Erc1967WitnessConfigSchema = "network.xyo.erc1967.witness.config";
90
+ var Erc1967Witness = class extends import_witness_blockchain_abstract.AbstractBlockchainWitness {
91
+ static configSchemas = [Erc1967WitnessConfigSchema];
92
92
  async observeHandler(inPayloads = []) {
93
93
  await this.started("throw");
94
94
  await this.getProviders();
95
95
  try {
96
96
  const observations = await Promise.all(
97
97
  inPayloads.filter((0, import_payload_model.isPayloadOfSchemaType)(import_witness_blockchain_abstract.BlockchainAddressSchema)).map(async ({ address }) => {
98
- const validatedAddress = (0, import_assert.assertEx)(address ?? this.config.address, "Missing address");
98
+ const validatedAddress = (0, import_assert.assertEx)(address ?? this.config.address, "Missing address").toLowerCase();
99
99
  const provider = await this.getProvider(true, true);
100
100
  const block = await provider.getBlockNumber();
101
101
  const { beacon, implementation, slots } = await getErc1967SlotStatus(provider, validatedAddress, block);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/lib/getErc1967SlotStatus.ts","../../src/Payload.ts","../../src/Witness.ts"],"sourcesContent":["export * from './lib'\nexport * from './Payload'\nexport * from './Witness'\n","import { Address, hexFromHexString, isHexZero } from '@xylabs/hex'\nimport { UpgradeableBeacon__factory } from '@xyo-network/open-zeppelin-typechain'\nimport { Provider } from 'ethers'\n\nexport const ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT = '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc'\nexport const ERC1967_PROXY_BEACON_STORAGE_SLOT = '0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50'\nexport const ERC1967_PROXY_ADMIN_STORAGE_SLOT = '0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103'\nexport const ERC1967_PROXY_ROLLBACK_STORAGE_SLOT = '0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143'\n\nexport interface Erc1967DataSlots {\n admin?: Address\n beacon?: Address\n implementation?: Address\n rollback?: Address\n}\n\nexport interface Erc1967SlotStatus {\n address: Address\n beacon?: {\n implementation?: Address\n }\n implementation: Address\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 hexFromHexString(slotValue, { prefix: true })\n } catch (ex) {\n return undefined\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')}`\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 } : {})\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 { Address } from '@xylabs/hex'\nimport { Payload } from '@xyo-network/payload-model'\n\nimport { Erc1967SlotStatus } from './lib'\n\nexport const Erc1967StatusSchema = 'network.xyo.erc1967.status'\nexport type Erc1967StatusSchema = typeof Erc1967StatusSchema\n\nexport type Erc1967Status = Payload<\n {\n address: Address\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 { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport {\n AbstractBlockchainWitness,\n BlockchainAddress,\n BlockchainAddressSchema,\n BlockchainWitnessConfig,\n BlockchainWitnessParams,\n} from '@xyo-network/witness-blockchain-abstract'\n\nimport { getErc1967SlotStatus } from './lib'\nimport { Erc1967Status, Erc1967StatusSchema } from './Payload'\n\nexport const BlockchainErc1967WitnessConfigSchema = 'network.xyo.blockchain.Erc1967.witness.config'\nexport type BlockchainErc1967WitnessConfigSchema = typeof BlockchainErc1967WitnessConfigSchema\n\nexport type BlockchainErc1967WitnessConfig = BlockchainWitnessConfig<{ address?: string }, BlockchainErc1967WitnessConfigSchema>\n\nexport type BlockchainErc1967WitnessParams = BlockchainWitnessParams<BlockchainErc1967WitnessConfig>\n\nexport class BlockchainErc1967Witness<\n TParams extends BlockchainErc1967WitnessParams = BlockchainErc1967WitnessParams,\n> extends AbstractBlockchainWitness<TParams, BlockchainAddress, Erc1967Status> {\n static override configSchemas = [BlockchainErc1967WitnessConfigSchema]\n\n protected override async observeHandler(inPayloads: BlockchainAddress[] = []): 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(BlockchainAddressSchema)).map(async ({ address }) => {\n const validatedAddress = assertEx(address ?? this.config.address, 'Missing address')\n\n const provider = await this.getProvider(true, true)\n\n const block = await provider.getBlockNumber()\n\n const { beacon, implementation, slots } = 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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iBAAqD;AACrD,qCAA2C;AAGpC,IAAM,4C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AAA,MACF,SAAS,IAAI;AACX,cAAM,QAAQ;AACd,gBAAQ,IAAI,MAAM,OAAO;AAAA,MAC3B;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;;;AChEO,IAAM,sBAAsB;;;ACLnC,oBAAyB;AACzB,2BAAsC;AACtC,yCAMO;AAKA,IAAM,uCAAuC;AAO7C,IAAM,2BAAN,cAEG,6DAAqE;AAAA,EAC7E,OAAgB,gBAAgB,CAAC,oCAAoC;AAAA,EAErE,MAAyB,eAAe,aAAkC,CAAC,GAA6B;AACtG,UAAM,KAAK,QAAQ,OAAO;AAE1B,UAAM,KAAK,aAAa;AACxB,QAAI;AACF,YAAM,eAAe,MAAM,QAAQ;AAAA,QACjC,WAAW,WAAO,4CAAsB,0DAAuB,CAAC,EAAE,IAAI,OAAO,EAAE,QAAQ,MAAM;AAC3F,gBAAM,uBAAmB,wBAAS,WAAW,KAAK,OAAO,SAAS,iBAAiB;AAEnF,gBAAM,WAAW,MAAM,KAAK,YAAY,MAAM,IAAI;AAElD,gBAAM,QAAQ,MAAM,SAAS,eAAe;AAE5C,gBAAM,EAAE,QAAQ,gBAAgB,MAAM,IAAI,MAAM,qBAAqB,UAAU,kBAAkB,KAAK;AAEtG,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/index.ts","../../src/lib/getErc1967SlotStatus.ts","../../src/Payload.ts","../../src/Witness.ts"],"sourcesContent":["export * from './lib'\nexport * from './Payload'\nexport * from './Witness'\n","import { Address, hexFromHexString, isHexZero } from '@xylabs/hex'\nimport { UpgradeableBeacon__factory } from '@xyo-network/open-zeppelin-typechain'\nimport { Provider } from 'ethers'\n\nexport const ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT = '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc'\nexport const ERC1967_PROXY_BEACON_STORAGE_SLOT = '0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50'\nexport const ERC1967_PROXY_ADMIN_STORAGE_SLOT = '0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103'\nexport const ERC1967_PROXY_ROLLBACK_STORAGE_SLOT = '0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143'\n\nexport interface Erc1967DataSlots {\n admin?: Address\n beacon?: Address\n implementation?: Address\n rollback?: Address\n}\n\nexport interface Erc1967SlotStatus {\n address: Address\n beacon?: {\n implementation?: Address\n }\n implementation: Address\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 hexFromHexString(slotValue, { prefix: true })\n } catch (ex) {\n return undefined\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')}`\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 } : {})\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 { Address } from '@xylabs/hex'\nimport { Payload } from '@xyo-network/payload-model'\n\nimport { Erc1967SlotStatus } from './lib'\n\nexport const Erc1967StatusSchema = 'network.xyo.erc1967.status'\nexport type Erc1967StatusSchema = typeof Erc1967StatusSchema\n\nexport type Erc1967Status = Payload<\n {\n address: Address\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 { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport {\n AbstractBlockchainWitness,\n BlockchainAddress,\n BlockchainAddressSchema,\n BlockchainWitnessConfig,\n BlockchainWitnessParams,\n} from '@xyo-network/witness-blockchain-abstract'\n\nimport { getErc1967SlotStatus } from './lib'\nimport { Erc1967Status, Erc1967StatusSchema } from './Payload'\n\nexport const Erc1967WitnessConfigSchema = 'network.xyo.erc1967.witness.config'\nexport type Erc1967WitnessConfigSchema = typeof Erc1967WitnessConfigSchema\n\nexport type Erc1967WitnessConfig = BlockchainWitnessConfig<{ address?: string }, Erc1967WitnessConfigSchema>\n\nexport type Erc1967WitnessParams = BlockchainWitnessParams<Erc1967WitnessConfig>\n\nexport class Erc1967Witness<TParams extends Erc1967WitnessParams = Erc1967WitnessParams> extends AbstractBlockchainWitness<\n TParams,\n BlockchainAddress,\n Erc1967Status\n> {\n static override configSchemas = [Erc1967WitnessConfigSchema]\n\n protected override async observeHandler(inPayloads: BlockchainAddress[] = []): 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<BlockchainAddress>(BlockchainAddressSchema)).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 { beacon, implementation, slots } = 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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iBAAqD;AACrD,qCAA2C;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,eAAO,6BAAiB,WAAW,EAAE,QAAQ,KAAK,CAAC;AAAA,EACrD,SAAS,IAAI;AACX,WAAO;AAAA,EACT;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,gB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AS,WAAW,KAAK,OAAO,SAAS,iBAAiB,EAAE,YAAY;AAEjG,gBAAM,WAAW,MAAM,KAAK,YAAY,MAAM,IAAI;AAElD,gBAAM,QAAQ,MAAM,SAAS,eAAe;AAE5C,gBAAM,EAAE,QAAQ,gBAAgB,MAAM,IAAI,MAAM,qBAAqB,UAAU,kBAAkB,KAAK;AAEtG,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":[]}
@@ -56,16 +56,16 @@ import {
56
56
  AbstractBlockchainWitness,
57
57
  BlockchainAddressSchema
58
58
  } from "@xyo-network/witness-blockchain-abstract";
59
- var BlockchainErc1967WitnessConfigSchema = "network.xyo.blockchain.Erc1967.witness.config";
60
- var BlockchainErc1967Witness = class extends AbstractBlockchainWitness {
61
- static configSchemas = [BlockchainErc1967WitnessConfigSchema];
59
+ var Erc1967WitnessConfigSchema = "network.xyo.erc1967.witness.config";
60
+ var Erc1967Witness = class extends AbstractBlockchainWitness {
61
+ static configSchemas = [Erc1967WitnessConfigSchema];
62
62
  async observeHandler(inPayloads = []) {
63
63
  await this.started("throw");
64
64
  await this.getProviders();
65
65
  try {
66
66
  const observations = await Promise.all(
67
67
  inPayloads.filter(isPayloadOfSchemaType(BlockchainAddressSchema)).map(async ({ address }) => {
68
- const validatedAddress = assertEx(address ?? this.config.address, "Missing address");
68
+ const validatedAddress = assertEx(address ?? this.config.address, "Missing address").toLowerCase();
69
69
  const provider = await this.getProvider(true, true);
70
70
  const block = await provider.getBlockNumber();
71
71
  const { beacon, implementation, slots } = await getErc1967SlotStatus(provider, validatedAddress, block);
@@ -90,13 +90,13 @@ var BlockchainErc1967Witness = class extends AbstractBlockchainWitness {
90
90
  }
91
91
  };
92
92
  export {
93
- BlockchainErc1967Witness,
94
- BlockchainErc1967WitnessConfigSchema,
95
93
  ERC1967_PROXY_ADMIN_STORAGE_SLOT,
96
94
  ERC1967_PROXY_BEACON_STORAGE_SLOT,
97
95
  ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT,
98
96
  ERC1967_PROXY_ROLLBACK_STORAGE_SLOT,
99
97
  Erc1967StatusSchema,
98
+ Erc1967Witness,
99
+ Erc1967WitnessConfigSchema,
100
100
  getErc1967SlotStatus
101
101
  };
102
102
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/getErc1967SlotStatus.ts","../../src/Payload.ts","../../src/Witness.ts"],"sourcesContent":["import { Address, hexFromHexString, isHexZero } from '@xylabs/hex'\nimport { UpgradeableBeacon__factory } from '@xyo-network/open-zeppelin-typechain'\nimport { Provider } from 'ethers'\n\nexport const ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT = '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc'\nexport const ERC1967_PROXY_BEACON_STORAGE_SLOT = '0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50'\nexport const ERC1967_PROXY_ADMIN_STORAGE_SLOT = '0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103'\nexport const ERC1967_PROXY_ROLLBACK_STORAGE_SLOT = '0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143'\n\nexport interface Erc1967DataSlots {\n admin?: Address\n beacon?: Address\n implementation?: Address\n rollback?: Address\n}\n\nexport interface Erc1967SlotStatus {\n address: Address\n beacon?: {\n implementation?: Address\n }\n implementation: Address\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 hexFromHexString(slotValue, { prefix: true })\n } catch (ex) {\n return undefined\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')}`\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 } : {})\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 { Address } from '@xylabs/hex'\nimport { Payload } from '@xyo-network/payload-model'\n\nimport { Erc1967SlotStatus } from './lib'\n\nexport const Erc1967StatusSchema = 'network.xyo.erc1967.status'\nexport type Erc1967StatusSchema = typeof Erc1967StatusSchema\n\nexport type Erc1967Status = Payload<\n {\n address: Address\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 { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport {\n AbstractBlockchainWitness,\n BlockchainAddress,\n BlockchainAddressSchema,\n BlockchainWitnessConfig,\n BlockchainWitnessParams,\n} from '@xyo-network/witness-blockchain-abstract'\n\nimport { getErc1967SlotStatus } from './lib'\nimport { Erc1967Status, Erc1967StatusSchema } from './Payload'\n\nexport const BlockchainErc1967WitnessConfigSchema = 'network.xyo.blockchain.Erc1967.witness.config'\nexport type BlockchainErc1967WitnessConfigSchema = typeof BlockchainErc1967WitnessConfigSchema\n\nexport type BlockchainErc1967WitnessConfig = BlockchainWitnessConfig<{ address?: string }, BlockchainErc1967WitnessConfigSchema>\n\nexport type BlockchainErc1967WitnessParams = BlockchainWitnessParams<BlockchainErc1967WitnessConfig>\n\nexport class BlockchainErc1967Witness<\n TParams extends BlockchainErc1967WitnessParams = BlockchainErc1967WitnessParams,\n> extends AbstractBlockchainWitness<TParams, BlockchainAddress, Erc1967Status> {\n static override configSchemas = [BlockchainErc1967WitnessConfigSchema]\n\n protected override async observeHandler(inPayloads: BlockchainAddress[] = []): 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(BlockchainAddressSchema)).map(async ({ address }) => {\n const validatedAddress = assertEx(address ?? this.config.address, 'Missing address')\n\n const provider = await this.getProvider(true, true)\n\n const block = await provider.getBlockNumber()\n\n const { beacon, implementation, slots } = 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":";AAAA,SAAkB,kBAAkB,iBAAiB;AACrD,SAAS,kCAAkC;AAGpC,IAAM,4CAA4C;AAClD,IAAM,oCAAoC;A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,QAAQ;AACd,gBAAQ,IAAI,MAAM,OAAO;AAAA,MAC3B;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;;;AChEO,IAAM,sBAAsB;;;ACLnC,SAAS,gBAAgB;AACzB,SAAS,6BAA6B;AACtC;AAAA,EACE;AAAA,EAEA;AAAA,OAGK;AAKA,IAAM,uCAAuC;AAO7C,IAAM,2BAAN,cAEG,0BAAqE;AAAA,EAC7E,OAAgB,gBAAgB,CAAC,oCAAoC;AAAA,EAErE,MAAyB,eAAe,aAAkC,CAAC,GAA6B;AACtG,UAAM,KAAK,QAAQ,OAAO;AAE1B,UAAM,KAAK,aAAa;AACxB,QAAI;AACF,YAAM,eAAe,MAAM,QAAQ;AAAA,QACjC,WAAW,OAAO,sBAAsB,uBAAuB,CAAC,EAAE,IAAI,OAAO,EAAE,QAAQ,MAAM;AAC3F,gBAAM,mBAAmB,SAAS,WAAW,KAAK,OAAO,SAAS,iBAAiB;AAEnF,gBAAM,WAAW,MAAM,KAAK,YAAY,MAAM,IAAI;AAElD,gBAAM,QAAQ,MAAM,SAAS,eAAe;AAE5C,gBAAM,EAAE,QAAQ,gBAAgB,MAAM,IAAI,MAAM,qBAAqB,UAAU,kBAAkB,KAAK;AAEtG,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 { Address, hexFromHexString, isHexZero } from '@xylabs/hex'\nimport { UpgradeableBeacon__factory } from '@xyo-network/open-zeppelin-typechain'\nimport { Provider } from 'ethers'\n\nexport const ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT = '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc'\nexport const ERC1967_PROXY_BEACON_STORAGE_SLOT = '0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50'\nexport const ERC1967_PROXY_ADMIN_STORAGE_SLOT = '0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103'\nexport const ERC1967_PROXY_ROLLBACK_STORAGE_SLOT = '0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143'\n\nexport interface Erc1967DataSlots {\n admin?: Address\n beacon?: Address\n implementation?: Address\n rollback?: Address\n}\n\nexport interface Erc1967SlotStatus {\n address: Address\n beacon?: {\n implementation?: Address\n }\n implementation: Address\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 hexFromHexString(slotValue, { prefix: true })\n } catch (ex) {\n return undefined\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')}`\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 } : {})\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 { Address } from '@xylabs/hex'\nimport { Payload } from '@xyo-network/payload-model'\n\nimport { Erc1967SlotStatus } from './lib'\n\nexport const Erc1967StatusSchema = 'network.xyo.erc1967.status'\nexport type Erc1967StatusSchema = typeof Erc1967StatusSchema\n\nexport type Erc1967Status = Payload<\n {\n address: Address\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 { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport {\n AbstractBlockchainWitness,\n BlockchainAddress,\n BlockchainAddressSchema,\n BlockchainWitnessConfig,\n BlockchainWitnessParams,\n} from '@xyo-network/witness-blockchain-abstract'\n\nimport { getErc1967SlotStatus } from './lib'\nimport { Erc1967Status, Erc1967StatusSchema } from './Payload'\n\nexport const Erc1967WitnessConfigSchema = 'network.xyo.erc1967.witness.config'\nexport type Erc1967WitnessConfigSchema = typeof Erc1967WitnessConfigSchema\n\nexport type Erc1967WitnessConfig = BlockchainWitnessConfig<{ address?: string }, Erc1967WitnessConfigSchema>\n\nexport type Erc1967WitnessParams = BlockchainWitnessParams<Erc1967WitnessConfig>\n\nexport class Erc1967Witness<TParams extends Erc1967WitnessParams = Erc1967WitnessParams> extends AbstractBlockchainWitness<\n TParams,\n BlockchainAddress,\n Erc1967Status\n> {\n static override configSchemas = [Erc1967WitnessConfigSchema]\n\n protected override async observeHandler(inPayloads: BlockchainAddress[] = []): 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<BlockchainAddress>(BlockchainAddressSchema)).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 { beacon, implementation, slots } = 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":";AAAA,SAAkB,kBAAkB,iBAAiB;AACrD,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,iBAAiB,WAAW,EAAE,QAAQ,KAAK,CAAC;AAAA,EACrD,SAAS,IAAI;AACX,WAAO;AAAA,EACT;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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AY,MAAM,IAAI;AAElD,gBAAM,QAAQ,MAAM,SAAS,eAAe;AAE5C,gBAAM,EAAE,QAAQ,gBAAgB,MAAM,IAAI,MAAM,qBAAqB,UAAU,kBAAkB,KAAK;AAEtG,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,12 +1,12 @@
1
1
  import { AbstractBlockchainWitness, BlockchainAddress, BlockchainWitnessConfig, BlockchainWitnessParams } from '@xyo-network/witness-blockchain-abstract';
2
2
  import { Erc1967Status } from './Payload';
3
- export declare const BlockchainErc1967WitnessConfigSchema = "network.xyo.blockchain.Erc1967.witness.config";
4
- export type BlockchainErc1967WitnessConfigSchema = typeof BlockchainErc1967WitnessConfigSchema;
5
- export type BlockchainErc1967WitnessConfig = BlockchainWitnessConfig<{
3
+ export declare const Erc1967WitnessConfigSchema = "network.xyo.erc1967.witness.config";
4
+ export type Erc1967WitnessConfigSchema = typeof Erc1967WitnessConfigSchema;
5
+ export type Erc1967WitnessConfig = BlockchainWitnessConfig<{
6
6
  address?: string;
7
- }, BlockchainErc1967WitnessConfigSchema>;
8
- export type BlockchainErc1967WitnessParams = BlockchainWitnessParams<BlockchainErc1967WitnessConfig>;
9
- export declare class BlockchainErc1967Witness<TParams extends BlockchainErc1967WitnessParams = BlockchainErc1967WitnessParams> extends AbstractBlockchainWitness<TParams, BlockchainAddress, Erc1967Status> {
7
+ }, Erc1967WitnessConfigSchema>;
8
+ export type Erc1967WitnessParams = BlockchainWitnessParams<Erc1967WitnessConfig>;
9
+ export declare class Erc1967Witness<TParams extends Erc1967WitnessParams = Erc1967WitnessParams> extends AbstractBlockchainWitness<TParams, BlockchainAddress, Erc1967Status> {
10
10
  static configSchemas: string[];
11
11
  protected observeHandler(inPayloads?: BlockchainAddress[]): Promise<Erc1967Status[]>;
12
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Witness.d.ts","sourceRoot":"","sources":["../../src/Witness.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,yBAAyB,EACzB,iBAAiB,EAEjB,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,0CAA0C,CAAA;AAGjD,OAAO,EAAE,aAAa,EAAuB,MAAM,WAAW,CAAA;AAE9D,eAAO,MAAM,oCAAoC,kDAAkD,CAAA;AACnG,MAAM,MAAM,oCAAoC,GAAG,OAAO,oCAAoC,CAAA;AAE9F,MAAM,MAAM,8BAA8B,GAAG,uBAAuB,CAAC;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,oCAAoC,CAAC,CAAA;AAEhI,MAAM,MAAM,8BAA8B,GAAG,uBAAuB,CAAC,8BAA8B,CAAC,CAAA;AAEpG,qBAAa,wBAAwB,CACnC,OAAO,SAAS,8BAA8B,GAAG,8BAA8B,CAC/E,SAAQ,yBAAyB,CAAC,OAAO,EAAE,iBAAiB,EAAE,aAAa,CAAC;IAC5E,OAAgB,aAAa,WAAyC;cAE7C,cAAc,CAAC,UAAU,GAAE,iBAAiB,EAAO,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;CAkCxG"}
1
+ {"version":3,"file":"Witness.d.ts","sourceRoot":"","sources":["../../src/Witness.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,yBAAyB,EACzB,iBAAiB,EAEjB,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,0CAA0C,CAAA;AAGjD,OAAO,EAAE,aAAa,EAAuB,MAAM,WAAW,CAAA;AAE9D,eAAO,MAAM,0BAA0B,uCAAuC,CAAA;AAC9E,MAAM,MAAM,0BAA0B,GAAG,OAAO,0BAA0B,CAAA;AAE1E,MAAM,MAAM,oBAAoB,GAAG,uBAAuB,CAAC;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,0BAA0B,CAAC,CAAA;AAE5G,MAAM,MAAM,oBAAoB,GAAG,uBAAuB,CAAC,oBAAoB,CAAC,CAAA;AAEhF,qBAAa,cAAc,CAAC,OAAO,SAAS,oBAAoB,GAAG,oBAAoB,CAAE,SAAQ,yBAAyB,CACxH,OAAO,EACP,iBAAiB,EACjB,aAAa,CACd;IACC,OAAgB,aAAa,WAA+B;cAEnC,cAAc,CAAC,UAAU,GAAE,iBAAiB,EAAO,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;CAkCxG"}
@@ -1,12 +1,12 @@
1
1
  import { AbstractBlockchainWitness, BlockchainAddress, BlockchainWitnessConfig, BlockchainWitnessParams } from '@xyo-network/witness-blockchain-abstract';
2
2
  import { Erc1967Status } from './Payload';
3
- export declare const BlockchainErc1967WitnessConfigSchema = "network.xyo.blockchain.Erc1967.witness.config";
4
- export type BlockchainErc1967WitnessConfigSchema = typeof BlockchainErc1967WitnessConfigSchema;
5
- export type BlockchainErc1967WitnessConfig = BlockchainWitnessConfig<{
3
+ export declare const Erc1967WitnessConfigSchema = "network.xyo.erc1967.witness.config";
4
+ export type Erc1967WitnessConfigSchema = typeof Erc1967WitnessConfigSchema;
5
+ export type Erc1967WitnessConfig = BlockchainWitnessConfig<{
6
6
  address?: string;
7
- }, BlockchainErc1967WitnessConfigSchema>;
8
- export type BlockchainErc1967WitnessParams = BlockchainWitnessParams<BlockchainErc1967WitnessConfig>;
9
- export declare class BlockchainErc1967Witness<TParams extends BlockchainErc1967WitnessParams = BlockchainErc1967WitnessParams> extends AbstractBlockchainWitness<TParams, BlockchainAddress, Erc1967Status> {
7
+ }, Erc1967WitnessConfigSchema>;
8
+ export type Erc1967WitnessParams = BlockchainWitnessParams<Erc1967WitnessConfig>;
9
+ export declare class Erc1967Witness<TParams extends Erc1967WitnessParams = Erc1967WitnessParams> extends AbstractBlockchainWitness<TParams, BlockchainAddress, Erc1967Status> {
10
10
  static configSchemas: string[];
11
11
  protected observeHandler(inPayloads?: BlockchainAddress[]): Promise<Erc1967Status[]>;
12
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Witness.d.ts","sourceRoot":"","sources":["../../src/Witness.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,yBAAyB,EACzB,iBAAiB,EAEjB,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,0CAA0C,CAAA;AAGjD,OAAO,EAAE,aAAa,EAAuB,MAAM,WAAW,CAAA;AAE9D,eAAO,MAAM,oCAAoC,kDAAkD,CAAA;AACnG,MAAM,MAAM,oCAAoC,GAAG,OAAO,oCAAoC,CAAA;AAE9F,MAAM,MAAM,8BAA8B,GAAG,uBAAuB,CAAC;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,oCAAoC,CAAC,CAAA;AAEhI,MAAM,MAAM,8BAA8B,GAAG,uBAAuB,CAAC,8BAA8B,CAAC,CAAA;AAEpG,qBAAa,wBAAwB,CACnC,OAAO,SAAS,8BAA8B,GAAG,8BAA8B,CAC/E,SAAQ,yBAAyB,CAAC,OAAO,EAAE,iBAAiB,EAAE,aAAa,CAAC;IAC5E,OAAgB,aAAa,WAAyC;cAE7C,cAAc,CAAC,UAAU,GAAE,iBAAiB,EAAO,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;CAkCxG"}
1
+ {"version":3,"file":"Witness.d.ts","sourceRoot":"","sources":["../../src/Witness.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,yBAAyB,EACzB,iBAAiB,EAEjB,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,0CAA0C,CAAA;AAGjD,OAAO,EAAE,aAAa,EAAuB,MAAM,WAAW,CAAA;AAE9D,eAAO,MAAM,0BAA0B,uCAAuC,CAAA;AAC9E,MAAM,MAAM,0BAA0B,GAAG,OAAO,0BAA0B,CAAA;AAE1E,MAAM,MAAM,oBAAoB,GAAG,uBAAuB,CAAC;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,0BAA0B,CAAC,CAAA;AAE5G,MAAM,MAAM,oBAAoB,GAAG,uBAAuB,CAAC,oBAAoB,CAAC,CAAA;AAEhF,qBAAa,cAAc,CAAC,OAAO,SAAS,oBAAoB,GAAG,oBAAoB,CAAE,SAAQ,yBAAyB,CACxH,OAAO,EACP,iBAAiB,EACjB,aAAa,CACd;IACC,OAAgB,aAAa,WAA+B;cAEnC,cAAc,CAAC,UAAU,GAAE,iBAAiB,EAAO,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;CAkCxG"}
@@ -1,12 +1,12 @@
1
1
  import { AbstractBlockchainWitness, BlockchainAddress, BlockchainWitnessConfig, BlockchainWitnessParams } from '@xyo-network/witness-blockchain-abstract';
2
2
  import { Erc1967Status } from './Payload';
3
- export declare const BlockchainErc1967WitnessConfigSchema = "network.xyo.blockchain.Erc1967.witness.config";
4
- export type BlockchainErc1967WitnessConfigSchema = typeof BlockchainErc1967WitnessConfigSchema;
5
- export type BlockchainErc1967WitnessConfig = BlockchainWitnessConfig<{
3
+ export declare const Erc1967WitnessConfigSchema = "network.xyo.erc1967.witness.config";
4
+ export type Erc1967WitnessConfigSchema = typeof Erc1967WitnessConfigSchema;
5
+ export type Erc1967WitnessConfig = BlockchainWitnessConfig<{
6
6
  address?: string;
7
- }, BlockchainErc1967WitnessConfigSchema>;
8
- export type BlockchainErc1967WitnessParams = BlockchainWitnessParams<BlockchainErc1967WitnessConfig>;
9
- export declare class BlockchainErc1967Witness<TParams extends BlockchainErc1967WitnessParams = BlockchainErc1967WitnessParams> extends AbstractBlockchainWitness<TParams, BlockchainAddress, Erc1967Status> {
7
+ }, Erc1967WitnessConfigSchema>;
8
+ export type Erc1967WitnessParams = BlockchainWitnessParams<Erc1967WitnessConfig>;
9
+ export declare class Erc1967Witness<TParams extends Erc1967WitnessParams = Erc1967WitnessParams> extends AbstractBlockchainWitness<TParams, BlockchainAddress, Erc1967Status> {
10
10
  static configSchemas: string[];
11
11
  protected observeHandler(inPayloads?: BlockchainAddress[]): Promise<Erc1967Status[]>;
12
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Witness.d.ts","sourceRoot":"","sources":["../../src/Witness.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,yBAAyB,EACzB,iBAAiB,EAEjB,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,0CAA0C,CAAA;AAGjD,OAAO,EAAE,aAAa,EAAuB,MAAM,WAAW,CAAA;AAE9D,eAAO,MAAM,oCAAoC,kDAAkD,CAAA;AACnG,MAAM,MAAM,oCAAoC,GAAG,OAAO,oCAAoC,CAAA;AAE9F,MAAM,MAAM,8BAA8B,GAAG,uBAAuB,CAAC;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,oCAAoC,CAAC,CAAA;AAEhI,MAAM,MAAM,8BAA8B,GAAG,uBAAuB,CAAC,8BAA8B,CAAC,CAAA;AAEpG,qBAAa,wBAAwB,CACnC,OAAO,SAAS,8BAA8B,GAAG,8BAA8B,CAC/E,SAAQ,yBAAyB,CAAC,OAAO,EAAE,iBAAiB,EAAE,aAAa,CAAC;IAC5E,OAAgB,aAAa,WAAyC;cAE7C,cAAc,CAAC,UAAU,GAAE,iBAAiB,EAAO,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;CAkCxG"}
1
+ {"version":3,"file":"Witness.d.ts","sourceRoot":"","sources":["../../src/Witness.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,yBAAyB,EACzB,iBAAiB,EAEjB,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,0CAA0C,CAAA;AAGjD,OAAO,EAAE,aAAa,EAAuB,MAAM,WAAW,CAAA;AAE9D,eAAO,MAAM,0BAA0B,uCAAuC,CAAA;AAC9E,MAAM,MAAM,0BAA0B,GAAG,OAAO,0BAA0B,CAAA;AAE1E,MAAM,MAAM,oBAAoB,GAAG,uBAAuB,CAAC;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,0BAA0B,CAAC,CAAA;AAE5G,MAAM,MAAM,oBAAoB,GAAG,uBAAuB,CAAC,oBAAoB,CAAC,CAAA;AAEhF,qBAAa,cAAc,CAAC,OAAO,SAAS,oBAAoB,GAAG,oBAAoB,CAAE,SAAQ,yBAAyB,CACxH,OAAO,EACP,iBAAiB,EACjB,aAAa,CACd;IACC,OAAgB,aAAa,WAA+B;cAEnC,cAAc,CAAC,UAAU,GAAE,iBAAiB,EAAO,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;CAkCxG"}
@@ -20,13 +20,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var src_exports = {};
22
22
  __export(src_exports, {
23
- BlockchainErc1967Witness: () => BlockchainErc1967Witness,
24
- BlockchainErc1967WitnessConfigSchema: () => BlockchainErc1967WitnessConfigSchema,
25
23
  ERC1967_PROXY_ADMIN_STORAGE_SLOT: () => ERC1967_PROXY_ADMIN_STORAGE_SLOT,
26
24
  ERC1967_PROXY_BEACON_STORAGE_SLOT: () => ERC1967_PROXY_BEACON_STORAGE_SLOT,
27
25
  ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT: () => ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT,
28
26
  ERC1967_PROXY_ROLLBACK_STORAGE_SLOT: () => ERC1967_PROXY_ROLLBACK_STORAGE_SLOT,
29
27
  Erc1967StatusSchema: () => Erc1967StatusSchema,
28
+ Erc1967Witness: () => Erc1967Witness,
29
+ Erc1967WitnessConfigSchema: () => Erc1967WitnessConfigSchema,
30
30
  getErc1967SlotStatus: () => getErc1967SlotStatus
31
31
  });
32
32
  module.exports = __toCommonJS(src_exports);
@@ -86,16 +86,16 @@ var Erc1967StatusSchema = "network.xyo.erc1967.status";
86
86
  var import_assert = require("@xylabs/assert");
87
87
  var import_payload_model = require("@xyo-network/payload-model");
88
88
  var import_witness_blockchain_abstract = require("@xyo-network/witness-blockchain-abstract");
89
- var BlockchainErc1967WitnessConfigSchema = "network.xyo.blockchain.Erc1967.witness.config";
90
- var BlockchainErc1967Witness = class extends import_witness_blockchain_abstract.AbstractBlockchainWitness {
91
- static configSchemas = [BlockchainErc1967WitnessConfigSchema];
89
+ var Erc1967WitnessConfigSchema = "network.xyo.erc1967.witness.config";
90
+ var Erc1967Witness = class extends import_witness_blockchain_abstract.AbstractBlockchainWitness {
91
+ static configSchemas = [Erc1967WitnessConfigSchema];
92
92
  async observeHandler(inPayloads = []) {
93
93
  await this.started("throw");
94
94
  await this.getProviders();
95
95
  try {
96
96
  const observations = await Promise.all(
97
97
  inPayloads.filter((0, import_payload_model.isPayloadOfSchemaType)(import_witness_blockchain_abstract.BlockchainAddressSchema)).map(async ({ address }) => {
98
- const validatedAddress = (0, import_assert.assertEx)(address ?? this.config.address, "Missing address");
98
+ const validatedAddress = (0, import_assert.assertEx)(address ?? this.config.address, "Missing address").toLowerCase();
99
99
  const provider = await this.getProvider(true, true);
100
100
  const block = await provider.getBlockNumber();
101
101
  const { beacon, implementation, slots } = await getErc1967SlotStatus(provider, validatedAddress, block);
@@ -121,13 +121,13 @@ var BlockchainErc1967Witness = class extends import_witness_blockchain_abstract.
121
121
  };
122
122
  // Annotate the CommonJS export names for ESM import in node:
123
123
  0 && (module.exports = {
124
- BlockchainErc1967Witness,
125
- BlockchainErc1967WitnessConfigSchema,
126
124
  ERC1967_PROXY_ADMIN_STORAGE_SLOT,
127
125
  ERC1967_PROXY_BEACON_STORAGE_SLOT,
128
126
  ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT,
129
127
  ERC1967_PROXY_ROLLBACK_STORAGE_SLOT,
130
128
  Erc1967StatusSchema,
129
+ Erc1967Witness,
130
+ Erc1967WitnessConfigSchema,
131
131
  getErc1967SlotStatus
132
132
  });
133
133
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/lib/getErc1967SlotStatus.ts","../../src/Payload.ts","../../src/Witness.ts"],"sourcesContent":["export * from './lib'\nexport * from './Payload'\nexport * from './Witness'\n","import { Address, hexFromHexString, isHexZero } from '@xylabs/hex'\nimport { UpgradeableBeacon__factory } from '@xyo-network/open-zeppelin-typechain'\nimport { Provider } from 'ethers'\n\nexport const ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT = '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc'\nexport const ERC1967_PROXY_BEACON_STORAGE_SLOT = '0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50'\nexport const ERC1967_PROXY_ADMIN_STORAGE_SLOT = '0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103'\nexport const ERC1967_PROXY_ROLLBACK_STORAGE_SLOT = '0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143'\n\nexport interface Erc1967DataSlots {\n admin?: Address\n beacon?: Address\n implementation?: Address\n rollback?: Address\n}\n\nexport interface Erc1967SlotStatus {\n address: Address\n beacon?: {\n implementation?: Address\n }\n implementation: Address\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 hexFromHexString(slotValue, { prefix: true })\n } catch (ex) {\n return undefined\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')}`\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 } : {})\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 { Address } from '@xylabs/hex'\nimport { Payload } from '@xyo-network/payload-model'\n\nimport { Erc1967SlotStatus } from './lib'\n\nexport const Erc1967StatusSchema = 'network.xyo.erc1967.status'\nexport type Erc1967StatusSchema = typeof Erc1967StatusSchema\n\nexport type Erc1967Status = Payload<\n {\n address: Address\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 { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport {\n AbstractBlockchainWitness,\n BlockchainAddress,\n BlockchainAddressSchema,\n BlockchainWitnessConfig,\n BlockchainWitnessParams,\n} from '@xyo-network/witness-blockchain-abstract'\n\nimport { getErc1967SlotStatus } from './lib'\nimport { Erc1967Status, Erc1967StatusSchema } from './Payload'\n\nexport const BlockchainErc1967WitnessConfigSchema = 'network.xyo.blockchain.Erc1967.witness.config'\nexport type BlockchainErc1967WitnessConfigSchema = typeof BlockchainErc1967WitnessConfigSchema\n\nexport type BlockchainErc1967WitnessConfig = BlockchainWitnessConfig<{ address?: string }, BlockchainErc1967WitnessConfigSchema>\n\nexport type BlockchainErc1967WitnessParams = BlockchainWitnessParams<BlockchainErc1967WitnessConfig>\n\nexport class BlockchainErc1967Witness<\n TParams extends BlockchainErc1967WitnessParams = BlockchainErc1967WitnessParams,\n> extends AbstractBlockchainWitness<TParams, BlockchainAddress, Erc1967Status> {\n static override configSchemas = [BlockchainErc1967WitnessConfigSchema]\n\n protected override async observeHandler(inPayloads: BlockchainAddress[] = []): 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(BlockchainAddressSchema)).map(async ({ address }) => {\n const validatedAddress = assertEx(address ?? this.config.address, 'Missing address')\n\n const provider = await this.getProvider(true, true)\n\n const block = await provider.getBlockNumber()\n\n const { beacon, implementation, slots } = 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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iBAAqD;AACrD,qCAA2C;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,eAAO,6BAAiB,WAAW,EAAE,QAAQ,KAAK,CAAC;AAAA,EACrD,SAAS,IAAI;AACX,WAAO;AAAA,EACT;AACF;AAEO,IAAM,uBAAuB,OAAO,UAAoB,SAAiB,UAA+C;AAC7H,QAAM,SAA4B;AAAA,IAChC;AAAA,I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KAAK,aAAa;AACxB,QAAI;AACF,YAAM,eAAe,MAAM,QAAQ;AAAA,QACjC,WAAW,WAAO,4CAAsB,0DAAuB,CAAC,EAAE,IAAI,OAAO,EAAE,QAAQ,MAAM;AAC3F,gBAAM,uBAAmB,wBAAS,WAAW,KAAK,OAAO,SAAS,iBAAiB;AAEnF,gBAAM,WAAW,MAAM,KAAK,YAAY,MAAM,IAAI;AAElD,gBAAM,QAAQ,MAAM,SAAS,eAAe;AAE5C,gBAAM,EAAE,QAAQ,gBAAgB,MAAM,IAAI,MAAM,qBAAqB,UAAU,kBAAkB,KAAK;AAEtG,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/index.ts","../../src/lib/getErc1967SlotStatus.ts","../../src/Payload.ts","../../src/Witness.ts"],"sourcesContent":["export * from './lib'\nexport * from './Payload'\nexport * from './Witness'\n","import { Address, hexFromHexString, isHexZero } from '@xylabs/hex'\nimport { UpgradeableBeacon__factory } from '@xyo-network/open-zeppelin-typechain'\nimport { Provider } from 'ethers'\n\nexport const ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT = '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc'\nexport const ERC1967_PROXY_BEACON_STORAGE_SLOT = '0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50'\nexport const ERC1967_PROXY_ADMIN_STORAGE_SLOT = '0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103'\nexport const ERC1967_PROXY_ROLLBACK_STORAGE_SLOT = '0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143'\n\nexport interface Erc1967DataSlots {\n admin?: Address\n beacon?: Address\n implementation?: Address\n rollback?: Address\n}\n\nexport interface Erc1967SlotStatus {\n address: Address\n beacon?: {\n implementation?: Address\n }\n implementation: Address\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 hexFromHexString(slotValue, { prefix: true })\n } catch (ex) {\n return undefined\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')}`\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 } : {})\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 { Address } from '@xylabs/hex'\nimport { Payload } from '@xyo-network/payload-model'\n\nimport { Erc1967SlotStatus } from './lib'\n\nexport const Erc1967StatusSchema = 'network.xyo.erc1967.status'\nexport type Erc1967StatusSchema = typeof Erc1967StatusSchema\n\nexport type Erc1967Status = Payload<\n {\n address: Address\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 { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport {\n AbstractBlockchainWitness,\n BlockchainAddress,\n BlockchainAddressSchema,\n BlockchainWitnessConfig,\n BlockchainWitnessParams,\n} from '@xyo-network/witness-blockchain-abstract'\n\nimport { getErc1967SlotStatus } from './lib'\nimport { Erc1967Status, Erc1967StatusSchema } from './Payload'\n\nexport const Erc1967WitnessConfigSchema = 'network.xyo.erc1967.witness.config'\nexport type Erc1967WitnessConfigSchema = typeof Erc1967WitnessConfigSchema\n\nexport type Erc1967WitnessConfig = BlockchainWitnessConfig<{ address?: string }, Erc1967WitnessConfigSchema>\n\nexport type Erc1967WitnessParams = BlockchainWitnessParams<Erc1967WitnessConfig>\n\nexport class Erc1967Witness<TParams extends Erc1967WitnessParams = Erc1967WitnessParams> extends AbstractBlockchainWitness<\n TParams,\n BlockchainAddress,\n Erc1967Status\n> {\n static override configSchemas = [Erc1967WitnessConfigSchema]\n\n protected override async observeHandler(inPayloads: BlockchainAddress[] = []): 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<BlockchainAddress>(BlockchainAddressSchema)).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 { beacon, implementation, slots } = 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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iBAAqD;AACrD,qCAA2C;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,eAAO,6BAAiB,WAAW,EAAE,QAAQ,KAAK,CAAC;AAAA,EACrD,SAAS,IAAI;AACX,WAAO;AAAA,EACT;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,KAAC,sBAAU,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,KAAC,sBAAU,OAAO,MAAM,MAAM,GA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A,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":[]}
@@ -56,16 +56,16 @@ import {
56
56
  AbstractBlockchainWitness,
57
57
  BlockchainAddressSchema
58
58
  } from "@xyo-network/witness-blockchain-abstract";
59
- var BlockchainErc1967WitnessConfigSchema = "network.xyo.blockchain.Erc1967.witness.config";
60
- var BlockchainErc1967Witness = class extends AbstractBlockchainWitness {
61
- static configSchemas = [BlockchainErc1967WitnessConfigSchema];
59
+ var Erc1967WitnessConfigSchema = "network.xyo.erc1967.witness.config";
60
+ var Erc1967Witness = class extends AbstractBlockchainWitness {
61
+ static configSchemas = [Erc1967WitnessConfigSchema];
62
62
  async observeHandler(inPayloads = []) {
63
63
  await this.started("throw");
64
64
  await this.getProviders();
65
65
  try {
66
66
  const observations = await Promise.all(
67
67
  inPayloads.filter(isPayloadOfSchemaType(BlockchainAddressSchema)).map(async ({ address }) => {
68
- const validatedAddress = assertEx(address ?? this.config.address, "Missing address");
68
+ const validatedAddress = assertEx(address ?? this.config.address, "Missing address").toLowerCase();
69
69
  const provider = await this.getProvider(true, true);
70
70
  const block = await provider.getBlockNumber();
71
71
  const { beacon, implementation, slots } = await getErc1967SlotStatus(provider, validatedAddress, block);
@@ -90,13 +90,13 @@ var BlockchainErc1967Witness = class extends AbstractBlockchainWitness {
90
90
  }
91
91
  };
92
92
  export {
93
- BlockchainErc1967Witness,
94
- BlockchainErc1967WitnessConfigSchema,
95
93
  ERC1967_PROXY_ADMIN_STORAGE_SLOT,
96
94
  ERC1967_PROXY_BEACON_STORAGE_SLOT,
97
95
  ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT,
98
96
  ERC1967_PROXY_ROLLBACK_STORAGE_SLOT,
99
97
  Erc1967StatusSchema,
98
+ Erc1967Witness,
99
+ Erc1967WitnessConfigSchema,
100
100
  getErc1967SlotStatus
101
101
  };
102
102
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/getErc1967SlotStatus.ts","../../src/Payload.ts","../../src/Witness.ts"],"sourcesContent":["import { Address, hexFromHexString, isHexZero } from '@xylabs/hex'\nimport { UpgradeableBeacon__factory } from '@xyo-network/open-zeppelin-typechain'\nimport { Provider } from 'ethers'\n\nexport const ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT = '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc'\nexport const ERC1967_PROXY_BEACON_STORAGE_SLOT = '0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50'\nexport const ERC1967_PROXY_ADMIN_STORAGE_SLOT = '0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103'\nexport const ERC1967_PROXY_ROLLBACK_STORAGE_SLOT = '0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143'\n\nexport interface Erc1967DataSlots {\n admin?: Address\n beacon?: Address\n implementation?: Address\n rollback?: Address\n}\n\nexport interface Erc1967SlotStatus {\n address: Address\n beacon?: {\n implementation?: Address\n }\n implementation: Address\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 hexFromHexString(slotValue, { prefix: true })\n } catch (ex) {\n return undefined\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')}`\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 } : {})\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 { Address } from '@xylabs/hex'\nimport { Payload } from '@xyo-network/payload-model'\n\nimport { Erc1967SlotStatus } from './lib'\n\nexport const Erc1967StatusSchema = 'network.xyo.erc1967.status'\nexport type Erc1967StatusSchema = typeof Erc1967StatusSchema\n\nexport type Erc1967Status = Payload<\n {\n address: Address\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 { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport {\n AbstractBlockchainWitness,\n BlockchainAddress,\n BlockchainAddressSchema,\n BlockchainWitnessConfig,\n BlockchainWitnessParams,\n} from '@xyo-network/witness-blockchain-abstract'\n\nimport { getErc1967SlotStatus } from './lib'\nimport { Erc1967Status, Erc1967StatusSchema } from './Payload'\n\nexport const BlockchainErc1967WitnessConfigSchema = 'network.xyo.blockchain.Erc1967.witness.config'\nexport type BlockchainErc1967WitnessConfigSchema = typeof BlockchainErc1967WitnessConfigSchema\n\nexport type BlockchainErc1967WitnessConfig = BlockchainWitnessConfig<{ address?: string }, BlockchainErc1967WitnessConfigSchema>\n\nexport type BlockchainErc1967WitnessParams = BlockchainWitnessParams<BlockchainErc1967WitnessConfig>\n\nexport class BlockchainErc1967Witness<\n TParams extends BlockchainErc1967WitnessParams = BlockchainErc1967WitnessParams,\n> extends AbstractBlockchainWitness<TParams, BlockchainAddress, Erc1967Status> {\n static override configSchemas = [BlockchainErc1967WitnessConfigSchema]\n\n protected override async observeHandler(inPayloads: BlockchainAddress[] = []): 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(BlockchainAddressSchema)).map(async ({ address }) => {\n const validatedAddress = assertEx(address ?? this.config.address, 'Missing address')\n\n const provider = await this.getProvider(true, true)\n\n const block = await provider.getBlockNumber()\n\n const { beacon, implementation, slots } = 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":";AAAA,SAAkB,kBAAkB,iBAAiB;AACrD,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,iBAAiB,WAAW,EAAE,QAAQ,KAAK,CAAC;AAAA,EACrD,SAAS,IAAI;AACX,WAAO;AAAA,EACT;AACF;AAEO,IAAM,uBAAuB,OAAO,UAAoB,SAAiB,UAA+C;AAC7H,QAAM,SAA4B;AAAA,IAChC;AAAA,IACA,gBAAgB;AAAA,IAChB,OAA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B,UAAM,KAAK,aAAa;AACxB,QAAI;AACF,YAAM,eAAe,MAAM,QAAQ;AAAA,QACjC,WAAW,OAAO,sBAAsB,uBAAuB,CAAC,EAAE,IAAI,OAAO,EAAE,QAAQ,MAAM;AAC3F,gBAAM,mBAAmB,SAAS,WAAW,KAAK,OAAO,SAAS,iBAAiB;AAEnF,gBAAM,WAAW,MAAM,KAAK,YAAY,MAAM,IAAI;AAElD,gBAAM,QAAQ,MAAM,SAAS,eAAe;AAE5C,gBAAM,EAAE,QAAQ,gBAAgB,MAAM,IAAI,MAAM,qBAAqB,UAAU,kBAAkB,KAAK;AAEtG,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 { Address, hexFromHexString, isHexZero } from '@xylabs/hex'\nimport { UpgradeableBeacon__factory } from '@xyo-network/open-zeppelin-typechain'\nimport { Provider } from 'ethers'\n\nexport const ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT = '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc'\nexport const ERC1967_PROXY_BEACON_STORAGE_SLOT = '0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50'\nexport const ERC1967_PROXY_ADMIN_STORAGE_SLOT = '0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103'\nexport const ERC1967_PROXY_ROLLBACK_STORAGE_SLOT = '0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143'\n\nexport interface Erc1967DataSlots {\n admin?: Address\n beacon?: Address\n implementation?: Address\n rollback?: Address\n}\n\nexport interface Erc1967SlotStatus {\n address: Address\n beacon?: {\n implementation?: Address\n }\n implementation: Address\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 hexFromHexString(slotValue, { prefix: true })\n } catch (ex) {\n return undefined\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')}`\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 } : {})\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 { Address } from '@xylabs/hex'\nimport { Payload } from '@xyo-network/payload-model'\n\nimport { Erc1967SlotStatus } from './lib'\n\nexport const Erc1967StatusSchema = 'network.xyo.erc1967.status'\nexport type Erc1967StatusSchema = typeof Erc1967StatusSchema\n\nexport type Erc1967Status = Payload<\n {\n address: Address\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 { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport {\n AbstractBlockchainWitness,\n BlockchainAddress,\n BlockchainAddressSchema,\n BlockchainWitnessConfig,\n BlockchainWitnessParams,\n} from '@xyo-network/witness-blockchain-abstract'\n\nimport { getErc1967SlotStatus } from './lib'\nimport { Erc1967Status, Erc1967StatusSchema } from './Payload'\n\nexport const Erc1967WitnessConfigSchema = 'network.xyo.erc1967.witness.config'\nexport type Erc1967WitnessConfigSchema = typeof Erc1967WitnessConfigSchema\n\nexport type Erc1967WitnessConfig = BlockchainWitnessConfig<{ address?: string }, Erc1967WitnessConfigSchema>\n\nexport type Erc1967WitnessParams = BlockchainWitnessParams<Erc1967WitnessConfig>\n\nexport class Erc1967Witness<TParams extends Erc1967WitnessParams = Erc1967WitnessParams> extends AbstractBlockchainWitness<\n TParams,\n BlockchainAddress,\n Erc1967Status\n> {\n static override configSchemas = [Erc1967WitnessConfigSchema]\n\n protected override async observeHandler(inPayloads: BlockchainAddress[] = []): 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<BlockchainAddress>(BlockchainAddressSchema)).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 { beacon, implementation, slots } = 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":";AAAA,SAAkB,kBAAkB,iBAAiB;AACrD,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,iBAAiB,WAAW,EAAE,QAAQ,KAAK,CAAC;AAAA,EACrD,SAAS,IAAI;AACX,WAAO;AAAA,EACT;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,iBAAiB,MAAM,OAAO,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X,YAAM,QAAQ;AACd,cAAQ,IAAI,UAAU,KAAK,OAAO,IAAI,MAAM,MAAM,OAAO,EAAE;AAC3D,YAAM;AAAA,IACR;AAAA,EACF;AACF;","names":[]}
package/package.json CHANGED
@@ -13,13 +13,13 @@
13
13
  "@xylabs/assert": "^2.13.20",
14
14
  "@xylabs/hex": "^2.13.20",
15
15
  "@xyo-network/open-zeppelin-typechain": "^3.0.5",
16
- "@xyo-network/payload-model": "^2.84.3",
17
- "@xyo-network/witness-blockchain-abstract": "^2.84.3"
16
+ "@xyo-network/payload-model": "^2.84.8",
17
+ "@xyo-network/witness-blockchain-abstract": "^2.84.8"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@xylabs/jest-helpers": "^2.13.20",
21
- "@xylabs/ts-scripts-yarn3": "^3.2.19",
22
- "@xylabs/tsconfig": "^3.2.19",
21
+ "@xylabs/ts-scripts-yarn3": "^3.2.24",
22
+ "@xylabs/tsconfig": "^3.2.24",
23
23
  "ethers": "^6.9.0",
24
24
  "jest": "^29.7.0",
25
25
  "typescript": "^5.3.3"
@@ -63,6 +63,6 @@
63
63
  "url": "https://github.com/XYOracleNetwork/plugins.git"
64
64
  },
65
65
  "sideEffects": false,
66
- "version": "2.84.1",
66
+ "version": "2.84.3",
67
67
  "type": "module"
68
68
  }
package/src/Witness.ts CHANGED
@@ -11,17 +11,19 @@ import {
11
11
  import { getErc1967SlotStatus } from './lib'
12
12
  import { Erc1967Status, Erc1967StatusSchema } from './Payload'
13
13
 
14
- export const BlockchainErc1967WitnessConfigSchema = 'network.xyo.blockchain.Erc1967.witness.config'
15
- export type BlockchainErc1967WitnessConfigSchema = typeof BlockchainErc1967WitnessConfigSchema
14
+ export const Erc1967WitnessConfigSchema = 'network.xyo.erc1967.witness.config'
15
+ export type Erc1967WitnessConfigSchema = typeof Erc1967WitnessConfigSchema
16
16
 
17
- export type BlockchainErc1967WitnessConfig = BlockchainWitnessConfig<{ address?: string }, BlockchainErc1967WitnessConfigSchema>
17
+ export type Erc1967WitnessConfig = BlockchainWitnessConfig<{ address?: string }, Erc1967WitnessConfigSchema>
18
18
 
19
- export type BlockchainErc1967WitnessParams = BlockchainWitnessParams<BlockchainErc1967WitnessConfig>
19
+ export type Erc1967WitnessParams = BlockchainWitnessParams<Erc1967WitnessConfig>
20
20
 
21
- export class BlockchainErc1967Witness<
22
- TParams extends BlockchainErc1967WitnessParams = BlockchainErc1967WitnessParams,
23
- > extends AbstractBlockchainWitness<TParams, BlockchainAddress, Erc1967Status> {
24
- static override configSchemas = [BlockchainErc1967WitnessConfigSchema]
21
+ export class Erc1967Witness<TParams extends Erc1967WitnessParams = Erc1967WitnessParams> extends AbstractBlockchainWitness<
22
+ TParams,
23
+ BlockchainAddress,
24
+ Erc1967Status
25
+ > {
26
+ static override configSchemas = [Erc1967WitnessConfigSchema]
25
27
 
26
28
  protected override async observeHandler(inPayloads: BlockchainAddress[] = []): Promise<Erc1967Status[]> {
27
29
  await this.started('throw')
@@ -29,8 +31,8 @@ export class BlockchainErc1967Witness<
29
31
  await this.getProviders()
30
32
  try {
31
33
  const observations = await Promise.all(
32
- inPayloads.filter(isPayloadOfSchemaType(BlockchainAddressSchema)).map(async ({ address }) => {
33
- const validatedAddress = assertEx(address ?? this.config.address, 'Missing address')
34
+ inPayloads.filter(isPayloadOfSchemaType<BlockchainAddress>(BlockchainAddressSchema)).map(async ({ address }) => {
35
+ const validatedAddress = assertEx(address ?? this.config.address, 'Missing address').toLowerCase()
34
36
 
35
37
  const provider = await this.getProvider(true, true)
36
38