@xyo-network/erc1967-witness 4.1.0 → 4.2.0

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,50 +1,4 @@
1
- import { Address } from '@xylabs/hex';
2
- import { Provider } from 'ethers';
3
- import { Payload, Schema } from '@xyo-network/payload-model';
4
- import { EvmWitnessConfig, EvmWitnessParams, AbstractEvmWitness, EvmAddress } from '@xyo-network/witness-evm-abstract';
5
-
6
- declare const ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT = "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc";
7
- declare const ERC1967_PROXY_BEACON_STORAGE_SLOT = "0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50";
8
- declare const ERC1967_PROXY_ADMIN_STORAGE_SLOT = "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103";
9
- declare const ERC1967_PROXY_ROLLBACK_STORAGE_SLOT = "0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143";
10
- interface Erc1967DataSlots {
11
- admin?: Address;
12
- beacon?: Address;
13
- implementation?: Address;
14
- rollback?: Address;
15
- }
16
- interface Erc1967SlotStatus {
17
- address: string;
18
- beacon?: {
19
- implementation?: Address;
20
- };
21
- implementation: string;
22
- slots: Erc1967DataSlots;
23
- }
24
- declare const getErc1967SlotStatus: (provider: Provider, address: string, block?: number) => Promise<Erc1967SlotStatus>;
25
-
26
- declare const Erc1967StatusSchema = "network.xyo.erc1967.status";
27
- type Erc1967StatusSchema = typeof Erc1967StatusSchema;
28
- type Erc1967Status = Payload<{
29
- address: string;
30
- beacon?: Erc1967SlotStatus['beacon'];
31
- block: number;
32
- chainId: number;
33
- implementation?: Erc1967SlotStatus['implementation'];
34
- slots?: Erc1967SlotStatus['slots'];
35
- }, Erc1967StatusSchema>;
36
-
37
- declare const Erc1967WitnessConfigSchema = "network.xyo.erc1967.witness.config";
38
- type Erc1967WitnessConfigSchema = typeof Erc1967WitnessConfigSchema;
39
- type Erc1967WitnessConfig = EvmWitnessConfig<{
40
- address?: string;
41
- }, Erc1967WitnessConfigSchema>;
42
- type Erc1967WitnessParams = EvmWitnessParams<Erc1967WitnessConfig>;
43
- declare class Erc1967Witness<TParams extends Erc1967WitnessParams = Erc1967WitnessParams> extends AbstractEvmWitness<TParams, EvmAddress, Erc1967Status> {
44
- static readonly configSchemas: Schema[];
45
- static readonly defaultConfigSchema: Schema;
46
- protected observeHandler(inPayloads?: EvmAddress[]): Promise<Erc1967Status[]>;
47
- }
48
-
49
- export { ERC1967_PROXY_ADMIN_STORAGE_SLOT, ERC1967_PROXY_BEACON_STORAGE_SLOT, ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT, ERC1967_PROXY_ROLLBACK_STORAGE_SLOT, Erc1967StatusSchema, Erc1967Witness, Erc1967WitnessConfigSchema, getErc1967SlotStatus };
50
- export type { Erc1967DataSlots, Erc1967SlotStatus, Erc1967Status, Erc1967WitnessConfig, Erc1967WitnessParams };
1
+ export * from './lib/index.ts';
2
+ export * from './Payload.ts';
3
+ export * from './Witness.ts';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,9 @@
1
1
  // src/lib/getErc1967SlotStatus.ts
2
- import { hexFromHexString, isHexZero } from "@xylabs/hex";
2
+ import {
3
+ asEthAddress,
4
+ hexFromHexString,
5
+ isHexZero
6
+ } from "@xylabs/hex";
3
7
  import { UpgradeableBeacon__factory } from "@xyo-network/open-zeppelin-typechain";
4
8
  var ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT = "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc";
5
9
  var ERC1967_PROXY_BEACON_STORAGE_SLOT = "0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50";
@@ -8,7 +12,7 @@ var ERC1967_PROXY_ROLLBACK_STORAGE_SLOT = "0x4910fdfa16fed3260ed0e7147f7cc6da11a
8
12
  var readAddressFromSlot = async (provider, address, slot, block) => {
9
13
  try {
10
14
  const slotValue = await provider.getStorage(address, slot, block);
11
- return hexFromHexString(slotValue, { prefix: true });
15
+ return asEthAddress(hexFromHexString(slotValue, { prefix: true }));
12
16
  } catch {
13
17
  return;
14
18
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/getErc1967SlotStatus.ts","../../src/Payload.ts","../../src/Witness.ts"],"sourcesContent":["import type { Address } from '@xylabs/hex'\nimport { hexFromHexString, isHexZero } from '@xylabs/hex'\nimport { UpgradeableBeacon__factory } from '@xyo-network/open-zeppelin-typechain'\nimport type { Provider } from 'ethers'\n\nexport const ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT = '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc'\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: string\n beacon?: {\n implementation?: Address\n }\n implementation: string\n slots: Erc1967DataSlots\n}\n\nconst readAddressFromSlot = async (provider: Provider, address: string, slot: string, block?: number) => {\n try {\n const slotValue = await provider.getStorage(address, slot, block)\n return hexFromHexString(slotValue, { prefix: true })\n } catch {\n return\n }\n}\n\nexport const getErc1967SlotStatus = async (provider: Provider, address: string, block?: number): Promise<Erc1967SlotStatus> => {\n const status: Erc1967SlotStatus = {\n address,\n implementation: address,\n slots: {\n admin: await readAddressFromSlot(provider, address, ERC1967_PROXY_ADMIN_STORAGE_SLOT, block),\n beacon: await readAddressFromSlot(provider, address, ERC1967_PROXY_BEACON_STORAGE_SLOT, block),\n implementation: await readAddressFromSlot(provider, address, ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT, block),\n rollback: await readAddressFromSlot(provider, address, ERC1967_PROXY_ROLLBACK_STORAGE_SLOT, block),\n },\n }\n\n if (status.slots.implementation && !isHexZero(status.slots.implementation)) {\n status.implementation = `0x${BigInt(status.slots.implementation as string)\n .toString(16)\n .padStart(40, '0')}` as Address\n } else {\n if (status.slots.beacon && !isHexZero(status.slots.beacon)) {\n const beacon = UpgradeableBeacon__factory.connect(status.slots.beacon as string, { provider })\n try {\n const implementation = (await beacon.implementation(block ? { blockTag: block } : {})) as Address\n if (implementation) {\n status.beacon = { implementation }\n if (!isHexZero(implementation)) {\n status.implementation = implementation\n }\n }\n } catch (ex) {\n const error = ex as Error\n console.log(error.message)\n }\n }\n }\n\n return status\n}\n","import type { Payload } from '@xyo-network/payload-model'\n\nimport type { Erc1967SlotStatus } from './lib/index.ts'\n\nexport const Erc1967StatusSchema = 'network.xyo.erc1967.status'\nexport type Erc1967StatusSchema = typeof Erc1967StatusSchema\n\nexport type Erc1967Status = Payload<\n {\n address: string\n beacon?: Erc1967SlotStatus['beacon']\n block: number\n chainId: number\n implementation?: Erc1967SlotStatus['implementation']\n slots?: Erc1967SlotStatus['slots']\n },\n Erc1967StatusSchema\n>\n","import { assertEx } from '@xylabs/assert'\nimport type { Schema } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport type {\n EvmAddress,\n EvmWitnessConfig, EvmWitnessParams,\n} from '@xyo-network/witness-evm-abstract'\nimport { AbstractEvmWitness, EvmAddressSchema } from '@xyo-network/witness-evm-abstract'\n\nimport { getErc1967SlotStatus } from './lib/index.ts'\nimport type { Erc1967Status } from './Payload.ts'\nimport { Erc1967StatusSchema } from './Payload.ts'\n\nexport const Erc1967WitnessConfigSchema = 'network.xyo.erc1967.witness.config'\nexport type Erc1967WitnessConfigSchema = typeof Erc1967WitnessConfigSchema\n\nexport type Erc1967WitnessConfig = EvmWitnessConfig<{ address?: string }, Erc1967WitnessConfigSchema>\n\nexport type Erc1967WitnessParams = EvmWitnessParams<Erc1967WitnessConfig>\n\nexport class Erc1967Witness<TParams extends Erc1967WitnessParams = Erc1967WitnessParams> extends AbstractEvmWitness<\n TParams,\n EvmAddress,\n Erc1967Status\n> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, Erc1967WitnessConfigSchema]\n static override readonly defaultConfigSchema: Schema = Erc1967WitnessConfigSchema\n\n protected override async observeHandler(inPayloads: EvmAddress[] = []): Promise<Erc1967Status[]> {\n await this.started('throw')\n // calling it here to make sure we rests the cache\n await this.getProviders()\n try {\n const observations = await Promise.all(\n inPayloads.filter(isPayloadOfSchemaType<EvmAddress>(EvmAddressSchema)).map(async ({ address }) => {\n const validatedAddress = assertEx(address ?? this.config.address, () => 'Missing address').toLowerCase()\n\n const provider = await this.getProvider(true, true)\n\n const block = await provider.getBlockNumber()\n\n const {\n beacon, implementation, slots,\n } = await getErc1967SlotStatus(provider, validatedAddress, block)\n\n const observation: Erc1967Status = {\n address: validatedAddress,\n beacon,\n block,\n chainId: Number((await provider.getNetwork()).chainId),\n implementation,\n schema: Erc1967StatusSchema,\n slots,\n }\n return observation\n }),\n )\n return observations\n } catch (ex) {\n const error = ex as Error\n console.log(`Error [${this.config.name}]: ${error.message}`)\n throw error\n }\n }\n}\n"],"mappings":";AACA,SAAS,kBAAkB,iBAAiB;AAC5C,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,WAA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IAAM,6BAA6B;AAOnC,IAAM,iBAAN,cAA0F,mBAI/F;AAAA,EACA,OAAyB,gBAA0B,CAAC,GAAG,MAAM,eAAe,0BAA0B;AAAA,EACtG,OAAyB,sBAA8B;AAAA,EAEvD,MAAyB,eAAe,aAA2B,CAAC,GAA6B;AAC/F,UAAM,KAAK,QAAQ,OAAO;AAE1B,UAAM,KAAK,aAAa;AACxB,QAAI;AACF,YAAM,eAAe,MAAM,QAAQ;AAAA,QACjC,WAAW,OAAO,sBAAkC,gBAAgB,CAAC,EAAE,IAAI,OAAO,EAAE,QAAQ,MAAM;AAChG,gBAAM,mBAAmB,SAAS,WAAW,KAAK,OAAO,SAAS,MAAM,iBAAiB,EAAE,YAAY;AAEvG,gBAAM,WAAW,MAAM,KAAK,YAAY,MAAM,IAAI;AAElD,gBAAM,QAAQ,MAAM,SAAS,eAAe;AAE5C,gBAAM;AAAA,YACJ;AAAA,YAAQ;AAAA,YAAgB;AAAA,UAC1B,IAAI,MAAM,qBAAqB,UAAU,kBAAkB,KAAK;AAEhE,gBAAM,cAA6B;AAAA,YACjC,SAAS;AAAA,YACT;AAAA,YACA;AAAA,YACA,SAAS,QAAQ,MAAM,SAAS,WAAW,GAAG,OAAO;AAAA,YACrD;AAAA,YACA,QAAQ;AAAA,YACR;AAAA,UACF;AACA,iBAAO;AAAA,QACT,CAAC;AAAA,MACH;AACA,aAAO;AAAA,IACT,SAAS,IAAI;AACX,YAAM,QAAQ;AACd,cAAQ,IAAI,UAAU,KAAK,OAAO,IAAI,MAAM,MAAM,OAAO,EAAE;AAC3D,YAAM;AAAA,IACR;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/lib/getErc1967SlotStatus.ts","../../src/Payload.ts","../../src/Witness.ts"],"sourcesContent":["import type { Address, EthAddress } from '@xylabs/hex'\nimport {\n asEthAddress, hexFromHexString, isHexZero,\n} from '@xylabs/hex'\nimport { UpgradeableBeacon__factory } from '@xyo-network/open-zeppelin-typechain'\nimport type { Provider } from 'ethers'\n\nexport const ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT = '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc' as EthAddress\nexport const ERC1967_PROXY_BEACON_STORAGE_SLOT = '0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50' as EthAddress\nexport const ERC1967_PROXY_ADMIN_STORAGE_SLOT = '0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103' as EthAddress\nexport const ERC1967_PROXY_ROLLBACK_STORAGE_SLOT = '0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143' as EthAddress\n\nexport interface Erc1967DataSlots {\n admin?: EthAddress\n beacon?: EthAddress\n implementation?: EthAddress\n rollback?: EthAddress\n}\n\nexport interface Erc1967SlotStatus {\n address: string\n beacon?: {\n implementation?: Address\n }\n implementation: string\n slots: Erc1967DataSlots\n}\n\nconst readAddressFromSlot = async (provider: Provider, address: string, slot: string, block?: number) => {\n try {\n const slotValue = await provider.getStorage(address, slot, block)\n return asEthAddress(hexFromHexString(slotValue, { prefix: true }))\n } catch {\n return\n }\n}\n\nexport const getErc1967SlotStatus = async (provider: Provider, address: string, block?: number): Promise<Erc1967SlotStatus> => {\n const status: Erc1967SlotStatus = {\n address,\n implementation: address,\n slots: {\n admin: await readAddressFromSlot(provider, address, ERC1967_PROXY_ADMIN_STORAGE_SLOT, block),\n beacon: await readAddressFromSlot(provider, address, ERC1967_PROXY_BEACON_STORAGE_SLOT, block),\n implementation: await readAddressFromSlot(provider, address, ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT, block),\n rollback: await readAddressFromSlot(provider, address, ERC1967_PROXY_ROLLBACK_STORAGE_SLOT, block),\n },\n }\n\n if (status.slots.implementation && !isHexZero(status.slots.implementation)) {\n status.implementation = `0x${BigInt(status.slots.implementation as string)\n .toString(16)\n .padStart(40, '0')}` as Address\n } else {\n if (status.slots.beacon && !isHexZero(status.slots.beacon)) {\n const beacon = UpgradeableBeacon__factory.connect(status.slots.beacon as string, { provider })\n try {\n const implementation = (await beacon.implementation(block ? { blockTag: block } : {})) as Address\n if (implementation) {\n status.beacon = { implementation }\n if (!isHexZero(implementation)) {\n status.implementation = implementation\n }\n }\n } catch (ex) {\n const error = ex as Error\n console.log(error.message)\n }\n }\n }\n\n return status\n}\n","import type { Payload } from '@xyo-network/payload-model'\n\nimport type { Erc1967SlotStatus } from './lib/index.ts'\n\nexport const Erc1967StatusSchema = 'network.xyo.erc1967.status'\nexport type Erc1967StatusSchema = typeof Erc1967StatusSchema\n\nexport type Erc1967Status = Payload<\n {\n address: string\n beacon?: Erc1967SlotStatus['beacon']\n block: number\n chainId: number\n implementation?: Erc1967SlotStatus['implementation']\n slots?: Erc1967SlotStatus['slots']\n },\n Erc1967StatusSchema\n>\n","import { assertEx } from '@xylabs/assert'\nimport type { Schema } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport type {\n EvmAddress,\n EvmWitnessConfig, EvmWitnessParams,\n} from '@xyo-network/witness-evm-abstract'\nimport { AbstractEvmWitness, EvmAddressSchema } from '@xyo-network/witness-evm-abstract'\n\nimport { getErc1967SlotStatus } from './lib/index.ts'\nimport type { Erc1967Status } from './Payload.ts'\nimport { Erc1967StatusSchema } from './Payload.ts'\n\nexport const Erc1967WitnessConfigSchema = 'network.xyo.erc1967.witness.config'\nexport type Erc1967WitnessConfigSchema = typeof Erc1967WitnessConfigSchema\n\nexport type Erc1967WitnessConfig = EvmWitnessConfig<{ address?: string }, Erc1967WitnessConfigSchema>\n\nexport type Erc1967WitnessParams = EvmWitnessParams<Erc1967WitnessConfig>\n\nexport class Erc1967Witness<TParams extends Erc1967WitnessParams = Erc1967WitnessParams> extends AbstractEvmWitness<\n TParams,\n EvmAddress,\n Erc1967Status\n> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, Erc1967WitnessConfigSchema]\n static override readonly defaultConfigSchema: Schema = Erc1967WitnessConfigSchema\n\n protected override async observeHandler(inPayloads: EvmAddress[] = []): Promise<Erc1967Status[]> {\n await this.started('throw')\n // calling it here to make sure we rests the cache\n await this.getProviders()\n try {\n const observations = await Promise.all(\n inPayloads.filter(isPayloadOfSchemaType<EvmAddress>(EvmAddressSchema)).map(async ({ address }) => {\n const validatedAddress = assertEx(address ?? this.config.address, () => 'Missing address').toLowerCase()\n\n const provider = await this.getProvider(true, true)\n\n const block = await provider.getBlockNumber()\n\n const {\n beacon, implementation, slots,\n } = await getErc1967SlotStatus(provider, validatedAddress, block)\n\n const observation: Erc1967Status = {\n address: validatedAddress,\n beacon,\n block,\n chainId: Number((await provider.getNetwork()).chainId),\n implementation,\n schema: Erc1967StatusSchema,\n slots,\n }\n return observation\n }),\n )\n return observations\n } catch (ex) {\n const error = ex as Error\n console.log(`Error [${this.config.name}]: ${error.message}`)\n throw error\n }\n }\n}\n"],"mappings":";AACA;AAAA,EACE;AAAA,EAAc;AAAA,EAAkB;AAAA,OAC3B;AACP,SAAS,kCAAkC;AAGpC,IAAM,4CAA4C;AAClD,IAAM,oCAAoC;AAC1C,IAAM,mCAAmC;AACzC,IAAM,sCAAsC;AAkBnD,IAAM,sBAAsB,OAAO,UAAoB,SAAiB,MAAc,UAAmB;AACvG,MAAI;AACF,UAAM,YAAY,MAAM,SAAS,WAAW,SAAS,MAAM,KAAK;AAChE,WAAO,aAAa,iBAAiB,WAAW,EAAE,QAAQ,KAAK,CAAC,CAAC;AAAA,EACnE,QAAQ;AACN;AAAA,EACF;AACF;AAEO,IAAM,uBAAuB,OAAO,UAAoB,SAAiB,UAA+C;AAC7H,QAAM,SAA4B;AAAA,IAChC;AAAA,IACA,gBAAgB;AAAA,IAChB,OAAO;AAAA,MACL,OAAO,MAAM,oBAAoB,UAAU,SAAS,kCAAkC,KAAK;AAAA,MAC3F,QAAQ,MAAM,oBAAoB,UAAU,SAAS,mCAAmC,KAAK;AAAA,MAC7F,gBAAgB,MAAM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,EAAE,IAAI,OAAO,EAAE,QAAQ,MAAM;AAChG,gBAAM,mBAAmB,SAAS,WAAW,KAAK,OAAO,SAAS,MAAM,iBAAiB,EAAE,YAAY;AAEvG,gBAAM,WAAW,MAAM,KAAK,YAAY,MAAM,IAAI;AAElD,gBAAM,QAAQ,MAAM,SAAS,eAAe;AAE5C,gBAAM;AAAA,YACJ;AAAA,YAAQ;AAAA,YAAgB;AAAA,UAC1B,IAAI,MAAM,qBAAqB,UAAU,kBAAkB,KAAK;AAEhE,gBAAM,cAA6B;AAAA,YACjC,SAAS;AAAA,YACT;AAAA,YACA;AAAA,YACA,SAAS,QAAQ,MAAM,SAAS,WAAW,GAAG,OAAO;AAAA,YACrD;AAAA,YACA,QAAQ;AAAA,YACR;AAAA,UACF;AACA,iBAAO;AAAA,QACT,CAAC;AAAA,MACH;AACA,aAAO;AAAA,IACT,SAAS,IAAI;AACX,YAAM,QAAQ;AACd,cAAQ,IAAI,UAAU,KAAK,OAAO,IAAI,MAAM,MAAM,OAAO,EAAE;AAC3D,YAAM;AAAA,IACR;AAAA,EACF;AACF;","names":[]}
@@ -1,14 +1,14 @@
1
- import type { Address } from '@xylabs/hex';
1
+ import type { Address, EthAddress } from '@xylabs/hex';
2
2
  import type { Provider } from 'ethers';
3
- export declare const ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT = "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc";
4
- export declare const ERC1967_PROXY_BEACON_STORAGE_SLOT = "0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50";
5
- export declare const ERC1967_PROXY_ADMIN_STORAGE_SLOT = "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103";
6
- export declare const ERC1967_PROXY_ROLLBACK_STORAGE_SLOT = "0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143";
3
+ export declare const ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT: EthAddress;
4
+ export declare const ERC1967_PROXY_BEACON_STORAGE_SLOT: EthAddress;
5
+ export declare const ERC1967_PROXY_ADMIN_STORAGE_SLOT: EthAddress;
6
+ export declare const ERC1967_PROXY_ROLLBACK_STORAGE_SLOT: EthAddress;
7
7
  export interface Erc1967DataSlots {
8
- admin?: Address;
9
- beacon?: Address;
10
- implementation?: Address;
11
- rollback?: Address;
8
+ admin?: EthAddress;
9
+ beacon?: EthAddress;
10
+ implementation?: EthAddress;
11
+ rollback?: EthAddress;
12
12
  }
13
13
  export interface Erc1967SlotStatus {
14
14
  address: string;
@@ -1 +1 @@
1
- {"version":3,"file":"getErc1967SlotStatus.d.ts","sourceRoot":"","sources":["../../../src/lib/getErc1967SlotStatus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAG1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAEtC,eAAO,MAAM,yCAAyC,uEAAuE,CAAA;AAC7H,eAAO,MAAM,iCAAiC,uEAAuE,CAAA;AACrH,eAAO,MAAM,gCAAgC,uEAAuE,CAAA;AACpH,eAAO,MAAM,mCAAmC,uEAAuE,CAAA;AAEvH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE;QACP,cAAc,CAAC,EAAE,OAAO,CAAA;KACzB,CAAA;IACD,cAAc,EAAE,MAAM,CAAA;IACtB,KAAK,EAAE,gBAAgB,CAAA;CACxB;AAWD,eAAO,MAAM,oBAAoB,GAAU,UAAU,QAAQ,EAAE,SAAS,MAAM,EAAE,QAAQ,MAAM,KAAG,OAAO,CAAC,iBAAiB,CAmCzH,CAAA"}
1
+ {"version":3,"file":"getErc1967SlotStatus.d.ts","sourceRoot":"","sources":["../../../src/lib/getErc1967SlotStatus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAKtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAEtC,eAAO,MAAM,yCAAyC,EAA2E,UAAU,CAAA;AAC3I,eAAO,MAAM,iCAAiC,EAA2E,UAAU,CAAA;AACnI,eAAO,MAAM,gCAAgC,EAA2E,UAAU,CAAA;AAClI,eAAO,MAAM,mCAAmC,EAA2E,UAAU,CAAA;AAErI,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,UAAU,CAAA;IAClB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,cAAc,CAAC,EAAE,UAAU,CAAA;IAC3B,QAAQ,CAAC,EAAE,UAAU,CAAA;CACtB;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE;QACP,cAAc,CAAC,EAAE,OAAO,CAAA;KACzB,CAAA;IACD,cAAc,EAAE,MAAM,CAAA;IACtB,KAAK,EAAE,gBAAgB,CAAA;CACxB;AAWD,eAAO,MAAM,oBAAoB,GAAU,UAAU,QAAQ,EAAE,SAAS,MAAM,EAAE,QAAQ,MAAM,KAAG,OAAO,CAAC,iBAAiB,CAmCzH,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/erc1967-witness",
3
- "version": "4.1.0",
3
+ "version": "4.2.0",
4
4
  "description": "Typescript/Javascript Plugins for XYO Platform",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -29,18 +29,17 @@
29
29
  "module": "dist/neutral/index.mjs",
30
30
  "types": "dist/neutral/index.d.ts",
31
31
  "dependencies": {
32
- "@xylabs/assert": "^4.13.15",
33
- "@xylabs/hex": "^4.13.15",
32
+ "@xylabs/assert": "^4.15.1",
33
+ "@xylabs/hex": "^4.15.1",
34
34
  "@xyo-network/open-zeppelin-typechain": "^3.5.4",
35
- "@xyo-network/payload-model": "^4.1.1",
36
- "@xyo-network/witness-evm-abstract": "^4.1.1",
35
+ "@xyo-network/payload-model": "^4.3.0",
36
+ "@xyo-network/witness-evm-abstract": "^4.3.0",
37
37
  "ethers": "^6.15.0"
38
38
  },
39
39
  "devDependencies": {
40
- "@xylabs/ts-scripts-yarn3": "^7.0.0-rc.24",
41
- "@xylabs/tsconfig": "^7.0.0-rc.24",
42
- "@xylabs/vitest-extended": "^4.13.15",
43
- "knip": "^5.61.3",
40
+ "@xylabs/ts-scripts-yarn3": "^7.0.1",
41
+ "@xylabs/tsconfig": "^7.0.1",
42
+ "@xylabs/vitest-extended": "^4.15.1",
44
43
  "typescript": "^5.8.3",
45
44
  "vitest": "^3.2.4"
46
45
  },
@@ -1,18 +1,20 @@
1
- import type { Address } from '@xylabs/hex'
2
- import { hexFromHexString, isHexZero } from '@xylabs/hex'
1
+ import type { Address, EthAddress } from '@xylabs/hex'
2
+ import {
3
+ asEthAddress, hexFromHexString, isHexZero,
4
+ } from '@xylabs/hex'
3
5
  import { UpgradeableBeacon__factory } from '@xyo-network/open-zeppelin-typechain'
4
6
  import type { Provider } from 'ethers'
5
7
 
6
- export const ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT = '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc'
7
- export const ERC1967_PROXY_BEACON_STORAGE_SLOT = '0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50'
8
- export const ERC1967_PROXY_ADMIN_STORAGE_SLOT = '0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103'
9
- export const ERC1967_PROXY_ROLLBACK_STORAGE_SLOT = '0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143'
8
+ export const ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT = '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc' as EthAddress
9
+ export const ERC1967_PROXY_BEACON_STORAGE_SLOT = '0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50' as EthAddress
10
+ export const ERC1967_PROXY_ADMIN_STORAGE_SLOT = '0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103' as EthAddress
11
+ export const ERC1967_PROXY_ROLLBACK_STORAGE_SLOT = '0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143' as EthAddress
10
12
 
11
13
  export interface Erc1967DataSlots {
12
- admin?: Address
13
- beacon?: Address
14
- implementation?: Address
15
- rollback?: Address
14
+ admin?: EthAddress
15
+ beacon?: EthAddress
16
+ implementation?: EthAddress
17
+ rollback?: EthAddress
16
18
  }
17
19
 
18
20
  export interface Erc1967SlotStatus {
@@ -27,7 +29,7 @@ export interface Erc1967SlotStatus {
27
29
  const readAddressFromSlot = async (provider: Provider, address: string, slot: string, block?: number) => {
28
30
  try {
29
31
  const slotValue = await provider.getStorage(address, slot, block)
30
- return hexFromHexString(slotValue, { prefix: true })
32
+ return asEthAddress(hexFromHexString(slotValue, { prefix: true }))
31
33
  } catch {
32
34
  return
33
35
  }