@xyo-network/erc1967-witness 2.99.5 → 2.99.6
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.
- package/dist/browser/index.cjs +27 -40
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.mjs +27 -42
- package/dist/browser/index.mjs.map +1 -1
- package/dist/neutral/index.cjs +27 -40
- package/dist/neutral/index.cjs.map +1 -1
- package/dist/neutral/index.mjs +27 -42
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/node/index.cjs +29 -46
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +29 -48
- package/dist/node/index.mjs.map +1 -1
- package/package.json +10 -10
package/dist/browser/index.cjs
CHANGED
|
@@ -3,7 +3,6 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
6
|
var __export = (target, all) => {
|
|
8
7
|
for (var name in all)
|
|
9
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -39,17 +38,15 @@ var ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT = "0x360894a13ba1a3210667c828492db
|
|
|
39
38
|
var ERC1967_PROXY_BEACON_STORAGE_SLOT = "0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50";
|
|
40
39
|
var ERC1967_PROXY_ADMIN_STORAGE_SLOT = "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103";
|
|
41
40
|
var ERC1967_PROXY_ROLLBACK_STORAGE_SLOT = "0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143";
|
|
42
|
-
var readAddressFromSlot =
|
|
41
|
+
var readAddressFromSlot = async (provider, address, slot, block) => {
|
|
43
42
|
try {
|
|
44
43
|
const slotValue = await provider.getStorage(address, slot, block);
|
|
45
|
-
return (0, import_hex.hexFromHexString)(slotValue, {
|
|
46
|
-
prefix: true
|
|
47
|
-
});
|
|
44
|
+
return (0, import_hex.hexFromHexString)(slotValue, { prefix: true });
|
|
48
45
|
} catch {
|
|
49
46
|
return;
|
|
50
47
|
}
|
|
51
|
-
}
|
|
52
|
-
var getErc1967SlotStatus =
|
|
48
|
+
};
|
|
49
|
+
var getErc1967SlotStatus = async (provider, address, block) => {
|
|
53
50
|
const status = {
|
|
54
51
|
address,
|
|
55
52
|
implementation: address,
|
|
@@ -64,17 +61,11 @@ var getErc1967SlotStatus = /* @__PURE__ */ __name(async (provider, address, bloc
|
|
|
64
61
|
status.implementation = `0x${BigInt(status.slots.implementation).toString(16).padStart(40, "0")}`;
|
|
65
62
|
} else {
|
|
66
63
|
if (status.slots.beacon && !(0, import_hex.isHexZero)(status.slots.beacon)) {
|
|
67
|
-
const beacon = import_open_zeppelin_typechain.UpgradeableBeacon__factory.connect(status.slots.beacon, {
|
|
68
|
-
provider
|
|
69
|
-
});
|
|
64
|
+
const beacon = import_open_zeppelin_typechain.UpgradeableBeacon__factory.connect(status.slots.beacon, { provider });
|
|
70
65
|
try {
|
|
71
|
-
const implementation = await beacon.implementation(block ? {
|
|
72
|
-
blockTag: block
|
|
73
|
-
} : {});
|
|
66
|
+
const implementation = await beacon.implementation(block ? { blockTag: block } : {});
|
|
74
67
|
if (implementation) {
|
|
75
|
-
status.beacon = {
|
|
76
|
-
implementation
|
|
77
|
-
};
|
|
68
|
+
status.beacon = { implementation };
|
|
78
69
|
if (!(0, import_hex.isHexZero)(implementation)) {
|
|
79
70
|
status.implementation = implementation;
|
|
80
71
|
}
|
|
@@ -86,7 +77,7 @@ var getErc1967SlotStatus = /* @__PURE__ */ __name(async (provider, address, bloc
|
|
|
86
77
|
}
|
|
87
78
|
}
|
|
88
79
|
return status;
|
|
89
|
-
}
|
|
80
|
+
};
|
|
90
81
|
|
|
91
82
|
// src/Payload.ts
|
|
92
83
|
var Erc1967StatusSchema = "network.xyo.erc1967.status";
|
|
@@ -97,34 +88,30 @@ var import_payload_model = require("@xyo-network/payload-model");
|
|
|
97
88
|
var import_witness_evm_abstract = require("@xyo-network/witness-evm-abstract");
|
|
98
89
|
var Erc1967WitnessConfigSchema = "network.xyo.erc1967.witness.config";
|
|
99
90
|
var Erc1967Witness = class extends import_witness_evm_abstract.AbstractEvmWitness {
|
|
100
|
-
static
|
|
101
|
-
__name(this, "Erc1967Witness");
|
|
102
|
-
}
|
|
103
|
-
static configSchemas = [
|
|
104
|
-
...super.configSchemas,
|
|
105
|
-
Erc1967WitnessConfigSchema
|
|
106
|
-
];
|
|
91
|
+
static configSchemas = [...super.configSchemas, Erc1967WitnessConfigSchema];
|
|
107
92
|
static defaultConfigSchema = Erc1967WitnessConfigSchema;
|
|
108
93
|
async observeHandler(inPayloads = []) {
|
|
109
94
|
await this.started("throw");
|
|
110
95
|
await this.getProviders();
|
|
111
96
|
try {
|
|
112
|
-
const observations = await Promise.all(
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
97
|
+
const observations = await Promise.all(
|
|
98
|
+
inPayloads.filter((0, import_payload_model.isPayloadOfSchemaType)(import_witness_evm_abstract.EvmAddressSchema)).map(async ({ address }) => {
|
|
99
|
+
const validatedAddress = (0, import_assert.assertEx)(address ?? this.config.address, () => "Missing address").toLowerCase();
|
|
100
|
+
const provider = await this.getProvider(true, true);
|
|
101
|
+
const block = await provider.getBlockNumber();
|
|
102
|
+
const { beacon, implementation, slots } = await getErc1967SlotStatus(provider, validatedAddress, block);
|
|
103
|
+
const observation = {
|
|
104
|
+
address: validatedAddress,
|
|
105
|
+
beacon,
|
|
106
|
+
block,
|
|
107
|
+
chainId: Number((await provider.getNetwork()).chainId),
|
|
108
|
+
implementation,
|
|
109
|
+
schema: Erc1967StatusSchema,
|
|
110
|
+
slots
|
|
111
|
+
};
|
|
112
|
+
return observation;
|
|
113
|
+
})
|
|
114
|
+
);
|
|
128
115
|
return observations;
|
|
129
116
|
} catch (ex) {
|
|
130
117
|
const error = ex;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/lib/getErc1967SlotStatus.ts","../../src/Payload.ts","../../src/Witness.ts"],"sourcesContent":["export * from './lib/index.ts'\nexport * from './Payload.ts'\nexport * from './Witness.ts'\n","import { Address, 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 { Payload } from '@xyo-network/payload-model'\n\nimport { 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 { isPayloadOfSchemaType, Schema } from '@xyo-network/payload-model'\nimport { AbstractEvmWitness, EvmAddress, EvmAddressSchema, EvmWitnessConfig, EvmWitnessParams } from '@xyo-network/witness-evm-abstract'\n\nimport { getErc1967SlotStatus } from './lib/index.ts'\nimport { Erc1967Status, 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 { 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":"
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/lib/getErc1967SlotStatus.ts","../../src/Payload.ts","../../src/Witness.ts"],"sourcesContent":["export * from './lib/index.ts'\nexport * from './Payload.ts'\nexport * from './Witness.ts'\n","import { Address, 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 { Payload } from '@xyo-network/payload-model'\n\nimport { 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 { isPayloadOfSchemaType, Schema } from '@xyo-network/payload-model'\nimport { AbstractEvmWitness, EvmAddress, EvmAddressSchema, EvmWitnessConfig, EvmWitnessParams } from '@xyo-network/witness-evm-abstract'\n\nimport { getErc1967SlotStatus } from './lib/index.ts'\nimport { Erc1967Status, 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 { 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,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,oBAAoB,UAAU,SAAS,2CAA2C,KAAK;AAAA,MAC7G,UAAU,MAAM,oBAAoB,UAAU,SAAS,qCAAqC,KAAK;AAAA,IACnG;AAAA,EACF;AAEA,MA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AAY,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":[]}
|
package/dist/browser/index.mjs
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
1
|
// src/lib/getErc1967SlotStatus.ts
|
|
5
2
|
import { hexFromHexString, isHexZero } from "@xylabs/hex";
|
|
6
3
|
import { UpgradeableBeacon__factory } from "@xyo-network/open-zeppelin-typechain";
|
|
@@ -8,17 +5,15 @@ var ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT = "0x360894a13ba1a3210667c828492db
|
|
|
8
5
|
var ERC1967_PROXY_BEACON_STORAGE_SLOT = "0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50";
|
|
9
6
|
var ERC1967_PROXY_ADMIN_STORAGE_SLOT = "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103";
|
|
10
7
|
var ERC1967_PROXY_ROLLBACK_STORAGE_SLOT = "0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143";
|
|
11
|
-
var readAddressFromSlot =
|
|
8
|
+
var readAddressFromSlot = async (provider, address, slot, block) => {
|
|
12
9
|
try {
|
|
13
10
|
const slotValue = await provider.getStorage(address, slot, block);
|
|
14
|
-
return hexFromHexString(slotValue, {
|
|
15
|
-
prefix: true
|
|
16
|
-
});
|
|
11
|
+
return hexFromHexString(slotValue, { prefix: true });
|
|
17
12
|
} catch {
|
|
18
13
|
return;
|
|
19
14
|
}
|
|
20
|
-
}
|
|
21
|
-
var getErc1967SlotStatus =
|
|
15
|
+
};
|
|
16
|
+
var getErc1967SlotStatus = async (provider, address, block) => {
|
|
22
17
|
const status = {
|
|
23
18
|
address,
|
|
24
19
|
implementation: address,
|
|
@@ -33,17 +28,11 @@ var getErc1967SlotStatus = /* @__PURE__ */ __name(async (provider, address, bloc
|
|
|
33
28
|
status.implementation = `0x${BigInt(status.slots.implementation).toString(16).padStart(40, "0")}`;
|
|
34
29
|
} else {
|
|
35
30
|
if (status.slots.beacon && !isHexZero(status.slots.beacon)) {
|
|
36
|
-
const beacon = UpgradeableBeacon__factory.connect(status.slots.beacon, {
|
|
37
|
-
provider
|
|
38
|
-
});
|
|
31
|
+
const beacon = UpgradeableBeacon__factory.connect(status.slots.beacon, { provider });
|
|
39
32
|
try {
|
|
40
|
-
const implementation = await beacon.implementation(block ? {
|
|
41
|
-
blockTag: block
|
|
42
|
-
} : {});
|
|
33
|
+
const implementation = await beacon.implementation(block ? { blockTag: block } : {});
|
|
43
34
|
if (implementation) {
|
|
44
|
-
status.beacon = {
|
|
45
|
-
implementation
|
|
46
|
-
};
|
|
35
|
+
status.beacon = { implementation };
|
|
47
36
|
if (!isHexZero(implementation)) {
|
|
48
37
|
status.implementation = implementation;
|
|
49
38
|
}
|
|
@@ -55,7 +44,7 @@ var getErc1967SlotStatus = /* @__PURE__ */ __name(async (provider, address, bloc
|
|
|
55
44
|
}
|
|
56
45
|
}
|
|
57
46
|
return status;
|
|
58
|
-
}
|
|
47
|
+
};
|
|
59
48
|
|
|
60
49
|
// src/Payload.ts
|
|
61
50
|
var Erc1967StatusSchema = "network.xyo.erc1967.status";
|
|
@@ -66,34 +55,30 @@ import { isPayloadOfSchemaType } from "@xyo-network/payload-model";
|
|
|
66
55
|
import { AbstractEvmWitness, EvmAddressSchema } from "@xyo-network/witness-evm-abstract";
|
|
67
56
|
var Erc1967WitnessConfigSchema = "network.xyo.erc1967.witness.config";
|
|
68
57
|
var Erc1967Witness = class extends AbstractEvmWitness {
|
|
69
|
-
static
|
|
70
|
-
__name(this, "Erc1967Witness");
|
|
71
|
-
}
|
|
72
|
-
static configSchemas = [
|
|
73
|
-
...super.configSchemas,
|
|
74
|
-
Erc1967WitnessConfigSchema
|
|
75
|
-
];
|
|
58
|
+
static configSchemas = [...super.configSchemas, Erc1967WitnessConfigSchema];
|
|
76
59
|
static defaultConfigSchema = Erc1967WitnessConfigSchema;
|
|
77
60
|
async observeHandler(inPayloads = []) {
|
|
78
61
|
await this.started("throw");
|
|
79
62
|
await this.getProviders();
|
|
80
63
|
try {
|
|
81
|
-
const observations = await Promise.all(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
64
|
+
const observations = await Promise.all(
|
|
65
|
+
inPayloads.filter(isPayloadOfSchemaType(EvmAddressSchema)).map(async ({ address }) => {
|
|
66
|
+
const validatedAddress = assertEx(address ?? this.config.address, () => "Missing address").toLowerCase();
|
|
67
|
+
const provider = await this.getProvider(true, true);
|
|
68
|
+
const block = await provider.getBlockNumber();
|
|
69
|
+
const { beacon, implementation, slots } = await getErc1967SlotStatus(provider, validatedAddress, block);
|
|
70
|
+
const observation = {
|
|
71
|
+
address: validatedAddress,
|
|
72
|
+
beacon,
|
|
73
|
+
block,
|
|
74
|
+
chainId: Number((await provider.getNetwork()).chainId),
|
|
75
|
+
implementation,
|
|
76
|
+
schema: Erc1967StatusSchema,
|
|
77
|
+
slots
|
|
78
|
+
};
|
|
79
|
+
return observation;
|
|
80
|
+
})
|
|
81
|
+
);
|
|
97
82
|
return observations;
|
|
98
83
|
} catch (ex) {
|
|
99
84
|
const error = ex;
|
|
@@ -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 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 { Payload } from '@xyo-network/payload-model'\n\nimport { 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 { isPayloadOfSchemaType, Schema } from '@xyo-network/payload-model'\nimport { AbstractEvmWitness, EvmAddress, EvmAddressSchema, EvmWitnessConfig, EvmWitnessParams } from '@xyo-network/witness-evm-abstract'\n\nimport { getErc1967SlotStatus } from './lib/index.ts'\nimport { Erc1967Status, 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 { 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":"
|
|
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 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 { Payload } from '@xyo-network/payload-model'\n\nimport { 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 { isPayloadOfSchemaType, Schema } from '@xyo-network/payload-model'\nimport { AbstractEvmWitness, EvmAddress, EvmAddressSchema, EvmWitnessConfig, EvmWitnessParams } from '@xyo-network/witness-evm-abstract'\n\nimport { getErc1967SlotStatus } from './lib/index.ts'\nimport { Erc1967Status, 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 { 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,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,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,Q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A,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":[]}
|
package/dist/neutral/index.cjs
CHANGED
|
@@ -3,7 +3,6 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
6
|
var __export = (target, all) => {
|
|
8
7
|
for (var name in all)
|
|
9
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -39,17 +38,15 @@ var ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT = "0x360894a13ba1a3210667c828492db
|
|
|
39
38
|
var ERC1967_PROXY_BEACON_STORAGE_SLOT = "0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50";
|
|
40
39
|
var ERC1967_PROXY_ADMIN_STORAGE_SLOT = "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103";
|
|
41
40
|
var ERC1967_PROXY_ROLLBACK_STORAGE_SLOT = "0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143";
|
|
42
|
-
var readAddressFromSlot =
|
|
41
|
+
var readAddressFromSlot = async (provider, address, slot, block) => {
|
|
43
42
|
try {
|
|
44
43
|
const slotValue = await provider.getStorage(address, slot, block);
|
|
45
|
-
return (0, import_hex.hexFromHexString)(slotValue, {
|
|
46
|
-
prefix: true
|
|
47
|
-
});
|
|
44
|
+
return (0, import_hex.hexFromHexString)(slotValue, { prefix: true });
|
|
48
45
|
} catch {
|
|
49
46
|
return;
|
|
50
47
|
}
|
|
51
|
-
}
|
|
52
|
-
var getErc1967SlotStatus =
|
|
48
|
+
};
|
|
49
|
+
var getErc1967SlotStatus = async (provider, address, block) => {
|
|
53
50
|
const status = {
|
|
54
51
|
address,
|
|
55
52
|
implementation: address,
|
|
@@ -64,17 +61,11 @@ var getErc1967SlotStatus = /* @__PURE__ */ __name(async (provider, address, bloc
|
|
|
64
61
|
status.implementation = `0x${BigInt(status.slots.implementation).toString(16).padStart(40, "0")}`;
|
|
65
62
|
} else {
|
|
66
63
|
if (status.slots.beacon && !(0, import_hex.isHexZero)(status.slots.beacon)) {
|
|
67
|
-
const beacon = import_open_zeppelin_typechain.UpgradeableBeacon__factory.connect(status.slots.beacon, {
|
|
68
|
-
provider
|
|
69
|
-
});
|
|
64
|
+
const beacon = import_open_zeppelin_typechain.UpgradeableBeacon__factory.connect(status.slots.beacon, { provider });
|
|
70
65
|
try {
|
|
71
|
-
const implementation = await beacon.implementation(block ? {
|
|
72
|
-
blockTag: block
|
|
73
|
-
} : {});
|
|
66
|
+
const implementation = await beacon.implementation(block ? { blockTag: block } : {});
|
|
74
67
|
if (implementation) {
|
|
75
|
-
status.beacon = {
|
|
76
|
-
implementation
|
|
77
|
-
};
|
|
68
|
+
status.beacon = { implementation };
|
|
78
69
|
if (!(0, import_hex.isHexZero)(implementation)) {
|
|
79
70
|
status.implementation = implementation;
|
|
80
71
|
}
|
|
@@ -86,7 +77,7 @@ var getErc1967SlotStatus = /* @__PURE__ */ __name(async (provider, address, bloc
|
|
|
86
77
|
}
|
|
87
78
|
}
|
|
88
79
|
return status;
|
|
89
|
-
}
|
|
80
|
+
};
|
|
90
81
|
|
|
91
82
|
// src/Payload.ts
|
|
92
83
|
var Erc1967StatusSchema = "network.xyo.erc1967.status";
|
|
@@ -97,34 +88,30 @@ var import_payload_model = require("@xyo-network/payload-model");
|
|
|
97
88
|
var import_witness_evm_abstract = require("@xyo-network/witness-evm-abstract");
|
|
98
89
|
var Erc1967WitnessConfigSchema = "network.xyo.erc1967.witness.config";
|
|
99
90
|
var Erc1967Witness = class extends import_witness_evm_abstract.AbstractEvmWitness {
|
|
100
|
-
static
|
|
101
|
-
__name(this, "Erc1967Witness");
|
|
102
|
-
}
|
|
103
|
-
static configSchemas = [
|
|
104
|
-
...super.configSchemas,
|
|
105
|
-
Erc1967WitnessConfigSchema
|
|
106
|
-
];
|
|
91
|
+
static configSchemas = [...super.configSchemas, Erc1967WitnessConfigSchema];
|
|
107
92
|
static defaultConfigSchema = Erc1967WitnessConfigSchema;
|
|
108
93
|
async observeHandler(inPayloads = []) {
|
|
109
94
|
await this.started("throw");
|
|
110
95
|
await this.getProviders();
|
|
111
96
|
try {
|
|
112
|
-
const observations = await Promise.all(
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
97
|
+
const observations = await Promise.all(
|
|
98
|
+
inPayloads.filter((0, import_payload_model.isPayloadOfSchemaType)(import_witness_evm_abstract.EvmAddressSchema)).map(async ({ address }) => {
|
|
99
|
+
const validatedAddress = (0, import_assert.assertEx)(address ?? this.config.address, () => "Missing address").toLowerCase();
|
|
100
|
+
const provider = await this.getProvider(true, true);
|
|
101
|
+
const block = await provider.getBlockNumber();
|
|
102
|
+
const { beacon, implementation, slots } = await getErc1967SlotStatus(provider, validatedAddress, block);
|
|
103
|
+
const observation = {
|
|
104
|
+
address: validatedAddress,
|
|
105
|
+
beacon,
|
|
106
|
+
block,
|
|
107
|
+
chainId: Number((await provider.getNetwork()).chainId),
|
|
108
|
+
implementation,
|
|
109
|
+
schema: Erc1967StatusSchema,
|
|
110
|
+
slots
|
|
111
|
+
};
|
|
112
|
+
return observation;
|
|
113
|
+
})
|
|
114
|
+
);
|
|
128
115
|
return observations;
|
|
129
116
|
} catch (ex) {
|
|
130
117
|
const error = ex;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/lib/getErc1967SlotStatus.ts","../../src/Payload.ts","../../src/Witness.ts"],"sourcesContent":["export * from './lib/index.ts'\nexport * from './Payload.ts'\nexport * from './Witness.ts'\n","import { Address, 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 { Payload } from '@xyo-network/payload-model'\n\nimport { 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 { isPayloadOfSchemaType, Schema } from '@xyo-network/payload-model'\nimport { AbstractEvmWitness, EvmAddress, EvmAddressSchema, EvmWitnessConfig, EvmWitnessParams } from '@xyo-network/witness-evm-abstract'\n\nimport { getErc1967SlotStatus } from './lib/index.ts'\nimport { Erc1967Status, 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 { 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":"
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/lib/getErc1967SlotStatus.ts","../../src/Payload.ts","../../src/Witness.ts"],"sourcesContent":["export * from './lib/index.ts'\nexport * from './Payload.ts'\nexport * from './Witness.ts'\n","import { Address, 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 { Payload } from '@xyo-network/payload-model'\n\nimport { 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 { isPayloadOfSchemaType, Schema } from '@xyo-network/payload-model'\nimport { AbstractEvmWitness, EvmAddress, EvmAddressSchema, EvmWitnessConfig, EvmWitnessParams } from '@xyo-network/witness-evm-abstract'\n\nimport { getErc1967SlotStatus } from './lib/index.ts'\nimport { Erc1967Status, 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 { 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,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,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,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AAA,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":[]}
|
package/dist/neutral/index.mjs
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
1
|
// src/lib/getErc1967SlotStatus.ts
|
|
5
2
|
import { hexFromHexString, isHexZero } from "@xylabs/hex";
|
|
6
3
|
import { UpgradeableBeacon__factory } from "@xyo-network/open-zeppelin-typechain";
|
|
@@ -8,17 +5,15 @@ var ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT = "0x360894a13ba1a3210667c828492db
|
|
|
8
5
|
var ERC1967_PROXY_BEACON_STORAGE_SLOT = "0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50";
|
|
9
6
|
var ERC1967_PROXY_ADMIN_STORAGE_SLOT = "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103";
|
|
10
7
|
var ERC1967_PROXY_ROLLBACK_STORAGE_SLOT = "0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143";
|
|
11
|
-
var readAddressFromSlot =
|
|
8
|
+
var readAddressFromSlot = async (provider, address, slot, block) => {
|
|
12
9
|
try {
|
|
13
10
|
const slotValue = await provider.getStorage(address, slot, block);
|
|
14
|
-
return hexFromHexString(slotValue, {
|
|
15
|
-
prefix: true
|
|
16
|
-
});
|
|
11
|
+
return hexFromHexString(slotValue, { prefix: true });
|
|
17
12
|
} catch {
|
|
18
13
|
return;
|
|
19
14
|
}
|
|
20
|
-
}
|
|
21
|
-
var getErc1967SlotStatus =
|
|
15
|
+
};
|
|
16
|
+
var getErc1967SlotStatus = async (provider, address, block) => {
|
|
22
17
|
const status = {
|
|
23
18
|
address,
|
|
24
19
|
implementation: address,
|
|
@@ -33,17 +28,11 @@ var getErc1967SlotStatus = /* @__PURE__ */ __name(async (provider, address, bloc
|
|
|
33
28
|
status.implementation = `0x${BigInt(status.slots.implementation).toString(16).padStart(40, "0")}`;
|
|
34
29
|
} else {
|
|
35
30
|
if (status.slots.beacon && !isHexZero(status.slots.beacon)) {
|
|
36
|
-
const beacon = UpgradeableBeacon__factory.connect(status.slots.beacon, {
|
|
37
|
-
provider
|
|
38
|
-
});
|
|
31
|
+
const beacon = UpgradeableBeacon__factory.connect(status.slots.beacon, { provider });
|
|
39
32
|
try {
|
|
40
|
-
const implementation = await beacon.implementation(block ? {
|
|
41
|
-
blockTag: block
|
|
42
|
-
} : {});
|
|
33
|
+
const implementation = await beacon.implementation(block ? { blockTag: block } : {});
|
|
43
34
|
if (implementation) {
|
|
44
|
-
status.beacon = {
|
|
45
|
-
implementation
|
|
46
|
-
};
|
|
35
|
+
status.beacon = { implementation };
|
|
47
36
|
if (!isHexZero(implementation)) {
|
|
48
37
|
status.implementation = implementation;
|
|
49
38
|
}
|
|
@@ -55,7 +44,7 @@ var getErc1967SlotStatus = /* @__PURE__ */ __name(async (provider, address, bloc
|
|
|
55
44
|
}
|
|
56
45
|
}
|
|
57
46
|
return status;
|
|
58
|
-
}
|
|
47
|
+
};
|
|
59
48
|
|
|
60
49
|
// src/Payload.ts
|
|
61
50
|
var Erc1967StatusSchema = "network.xyo.erc1967.status";
|
|
@@ -66,34 +55,30 @@ import { isPayloadOfSchemaType } from "@xyo-network/payload-model";
|
|
|
66
55
|
import { AbstractEvmWitness, EvmAddressSchema } from "@xyo-network/witness-evm-abstract";
|
|
67
56
|
var Erc1967WitnessConfigSchema = "network.xyo.erc1967.witness.config";
|
|
68
57
|
var Erc1967Witness = class extends AbstractEvmWitness {
|
|
69
|
-
static
|
|
70
|
-
__name(this, "Erc1967Witness");
|
|
71
|
-
}
|
|
72
|
-
static configSchemas = [
|
|
73
|
-
...super.configSchemas,
|
|
74
|
-
Erc1967WitnessConfigSchema
|
|
75
|
-
];
|
|
58
|
+
static configSchemas = [...super.configSchemas, Erc1967WitnessConfigSchema];
|
|
76
59
|
static defaultConfigSchema = Erc1967WitnessConfigSchema;
|
|
77
60
|
async observeHandler(inPayloads = []) {
|
|
78
61
|
await this.started("throw");
|
|
79
62
|
await this.getProviders();
|
|
80
63
|
try {
|
|
81
|
-
const observations = await Promise.all(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
64
|
+
const observations = await Promise.all(
|
|
65
|
+
inPayloads.filter(isPayloadOfSchemaType(EvmAddressSchema)).map(async ({ address }) => {
|
|
66
|
+
const validatedAddress = assertEx(address ?? this.config.address, () => "Missing address").toLowerCase();
|
|
67
|
+
const provider = await this.getProvider(true, true);
|
|
68
|
+
const block = await provider.getBlockNumber();
|
|
69
|
+
const { beacon, implementation, slots } = await getErc1967SlotStatus(provider, validatedAddress, block);
|
|
70
|
+
const observation = {
|
|
71
|
+
address: validatedAddress,
|
|
72
|
+
beacon,
|
|
73
|
+
block,
|
|
74
|
+
chainId: Number((await provider.getNetwork()).chainId),
|
|
75
|
+
implementation,
|
|
76
|
+
schema: Erc1967StatusSchema,
|
|
77
|
+
slots
|
|
78
|
+
};
|
|
79
|
+
return observation;
|
|
80
|
+
})
|
|
81
|
+
);
|
|
97
82
|
return observations;
|
|
98
83
|
} catch (ex) {
|
|
99
84
|
const error = ex;
|
|
@@ -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 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 { Payload } from '@xyo-network/payload-model'\n\nimport { 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 { isPayloadOfSchemaType, Schema } from '@xyo-network/payload-model'\nimport { AbstractEvmWitness, EvmAddress, EvmAddressSchema, EvmWitnessConfig, EvmWitnessParams } from '@xyo-network/witness-evm-abstract'\n\nimport { getErc1967SlotStatus } from './lib/index.ts'\nimport { Erc1967Status, 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 { 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":"
|
|
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 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 { Payload } from '@xyo-network/payload-model'\n\nimport { 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 { isPayloadOfSchemaType, Schema } from '@xyo-network/payload-model'\nimport { AbstractEvmWitness, EvmAddress, EvmAddressSchema, EvmWitnessConfig, EvmWitnessParams } from '@xyo-network/witness-evm-abstract'\n\nimport { getErc1967SlotStatus } from './lib/index.ts'\nimport { Erc1967Status, 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 { 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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AAE;AAC3D,YAAM;AAAA,IACR;AAAA,EACF;AACF;","names":[]}
|
package/dist/node/index.cjs
CHANGED
|
@@ -2,11 +2,7 @@
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __reflectGet = Reflect.get;
|
|
8
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
6
|
var __export = (target, all) => {
|
|
11
7
|
for (var name in all)
|
|
12
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -20,8 +16,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
20
16
|
return to;
|
|
21
17
|
};
|
|
22
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
24
|
-
var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
|
|
25
19
|
|
|
26
20
|
// src/index.ts
|
|
27
21
|
var src_exports = {};
|
|
@@ -44,17 +38,15 @@ var ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT = "0x360894a13ba1a3210667c828492db
|
|
|
44
38
|
var ERC1967_PROXY_BEACON_STORAGE_SLOT = "0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50";
|
|
45
39
|
var ERC1967_PROXY_ADMIN_STORAGE_SLOT = "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103";
|
|
46
40
|
var ERC1967_PROXY_ROLLBACK_STORAGE_SLOT = "0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143";
|
|
47
|
-
var readAddressFromSlot =
|
|
41
|
+
var readAddressFromSlot = async (provider, address, slot, block) => {
|
|
48
42
|
try {
|
|
49
43
|
const slotValue = await provider.getStorage(address, slot, block);
|
|
50
|
-
return (0, import_hex.hexFromHexString)(slotValue, {
|
|
51
|
-
prefix: true
|
|
52
|
-
});
|
|
44
|
+
return (0, import_hex.hexFromHexString)(slotValue, { prefix: true });
|
|
53
45
|
} catch {
|
|
54
46
|
return;
|
|
55
47
|
}
|
|
56
|
-
}
|
|
57
|
-
var getErc1967SlotStatus =
|
|
48
|
+
};
|
|
49
|
+
var getErc1967SlotStatus = async (provider, address, block) => {
|
|
58
50
|
const status = {
|
|
59
51
|
address,
|
|
60
52
|
implementation: address,
|
|
@@ -69,17 +61,11 @@ var getErc1967SlotStatus = /* @__PURE__ */ __name(async (provider, address, bloc
|
|
|
69
61
|
status.implementation = `0x${BigInt(status.slots.implementation).toString(16).padStart(40, "0")}`;
|
|
70
62
|
} else {
|
|
71
63
|
if (status.slots.beacon && !(0, import_hex.isHexZero)(status.slots.beacon)) {
|
|
72
|
-
const beacon = import_open_zeppelin_typechain.UpgradeableBeacon__factory.connect(status.slots.beacon, {
|
|
73
|
-
provider
|
|
74
|
-
});
|
|
64
|
+
const beacon = import_open_zeppelin_typechain.UpgradeableBeacon__factory.connect(status.slots.beacon, { provider });
|
|
75
65
|
try {
|
|
76
|
-
const implementation = await beacon.implementation(block ? {
|
|
77
|
-
blockTag: block
|
|
78
|
-
} : {});
|
|
66
|
+
const implementation = await beacon.implementation(block ? { blockTag: block } : {});
|
|
79
67
|
if (implementation) {
|
|
80
|
-
status.beacon = {
|
|
81
|
-
implementation
|
|
82
|
-
};
|
|
68
|
+
status.beacon = { implementation };
|
|
83
69
|
if (!(0, import_hex.isHexZero)(implementation)) {
|
|
84
70
|
status.implementation = implementation;
|
|
85
71
|
}
|
|
@@ -91,7 +77,7 @@ var getErc1967SlotStatus = /* @__PURE__ */ __name(async (provider, address, bloc
|
|
|
91
77
|
}
|
|
92
78
|
}
|
|
93
79
|
return status;
|
|
94
|
-
}
|
|
80
|
+
};
|
|
95
81
|
|
|
96
82
|
// src/Payload.ts
|
|
97
83
|
var Erc1967StatusSchema = "network.xyo.erc1967.status";
|
|
@@ -101,27 +87,31 @@ var import_assert = require("@xylabs/assert");
|
|
|
101
87
|
var import_payload_model = require("@xyo-network/payload-model");
|
|
102
88
|
var import_witness_evm_abstract = require("@xyo-network/witness-evm-abstract");
|
|
103
89
|
var Erc1967WitnessConfigSchema = "network.xyo.erc1967.witness.config";
|
|
104
|
-
var
|
|
90
|
+
var Erc1967Witness = class extends import_witness_evm_abstract.AbstractEvmWitness {
|
|
91
|
+
static configSchemas = [...super.configSchemas, Erc1967WitnessConfigSchema];
|
|
92
|
+
static defaultConfigSchema = Erc1967WitnessConfigSchema;
|
|
105
93
|
async observeHandler(inPayloads = []) {
|
|
106
94
|
await this.started("throw");
|
|
107
95
|
await this.getProviders();
|
|
108
96
|
try {
|
|
109
|
-
const observations = await Promise.all(
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
97
|
+
const observations = await Promise.all(
|
|
98
|
+
inPayloads.filter((0, import_payload_model.isPayloadOfSchemaType)(import_witness_evm_abstract.EvmAddressSchema)).map(async ({ address }) => {
|
|
99
|
+
const validatedAddress = (0, import_assert.assertEx)(address ?? this.config.address, () => "Missing address").toLowerCase();
|
|
100
|
+
const provider = await this.getProvider(true, true);
|
|
101
|
+
const block = await provider.getBlockNumber();
|
|
102
|
+
const { beacon, implementation, slots } = await getErc1967SlotStatus(provider, validatedAddress, block);
|
|
103
|
+
const observation = {
|
|
104
|
+
address: validatedAddress,
|
|
105
|
+
beacon,
|
|
106
|
+
block,
|
|
107
|
+
chainId: Number((await provider.getNetwork()).chainId),
|
|
108
|
+
implementation,
|
|
109
|
+
schema: Erc1967StatusSchema,
|
|
110
|
+
slots
|
|
111
|
+
};
|
|
112
|
+
return observation;
|
|
113
|
+
})
|
|
114
|
+
);
|
|
125
115
|
return observations;
|
|
126
116
|
} catch (ex) {
|
|
127
117
|
const error = ex;
|
|
@@ -130,13 +120,6 @@ var _Erc1967Witness = class _Erc1967Witness extends import_witness_evm_abstract.
|
|
|
130
120
|
}
|
|
131
121
|
}
|
|
132
122
|
};
|
|
133
|
-
__name(_Erc1967Witness, "Erc1967Witness");
|
|
134
|
-
__publicField(_Erc1967Witness, "configSchemas", [
|
|
135
|
-
...__superGet(_Erc1967Witness, _Erc1967Witness, "configSchemas"),
|
|
136
|
-
Erc1967WitnessConfigSchema
|
|
137
|
-
]);
|
|
138
|
-
__publicField(_Erc1967Witness, "defaultConfigSchema", Erc1967WitnessConfigSchema);
|
|
139
|
-
var Erc1967Witness = _Erc1967Witness;
|
|
140
123
|
// Annotate the CommonJS export names for ESM import in node:
|
|
141
124
|
0 && (module.exports = {
|
|
142
125
|
ERC1967_PROXY_ADMIN_STORAGE_SLOT,
|
package/dist/node/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/lib/getErc1967SlotStatus.ts","../../src/Payload.ts","../../src/Witness.ts"],"sourcesContent":["export * from './lib/index.ts'\nexport * from './Payload.ts'\nexport * from './Witness.ts'\n","import { Address, 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 { Payload } from '@xyo-network/payload-model'\n\nimport { 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 { isPayloadOfSchemaType, Schema } from '@xyo-network/payload-model'\nimport { AbstractEvmWitness, EvmAddress, EvmAddressSchema, EvmWitnessConfig, EvmWitnessParams } from '@xyo-network/witness-evm-abstract'\n\nimport { getErc1967SlotStatus } from './lib/index.ts'\nimport { Erc1967Status, 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 { 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":"
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/lib/getErc1967SlotStatus.ts","../../src/Payload.ts","../../src/Witness.ts"],"sourcesContent":["export * from './lib/index.ts'\nexport * from './Payload.ts'\nexport * from './Witness.ts'\n","import { Address, 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 { Payload } from '@xyo-network/payload-model'\n\nimport { 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 { isPayloadOfSchemaType, Schema } from '@xyo-network/payload-model'\nimport { AbstractEvmWitness, EvmAddress, EvmAddressSchema, EvmWitnessConfig, EvmWitnessParams } from '@xyo-network/witness-evm-abstract'\n\nimport { getErc1967SlotStatus } from './lib/index.ts'\nimport { Erc1967Status, 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 { 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,U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O,IAAM,sBAAsB;;;ACJnC,oBAAyB;AACzB,2BAA8C;AAC9C,kCAAqG;AAK9F,IAAM,6BAA6B;AAOnC,IAAM,iBAAN,cAA0F,+CAI/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,WAAO,4CAAkC,4CAAgB,CAAC,EAAE,IAAI,OAAO,EAAE,QAAQ,MAAM;AAChG,gBAAM,uBAAmB,wBAAS,WAAW,KAAK,OAAO,SAAS,MAAM,iBAAiB,EAAE,YAAY;AAEvG,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":[]}
|
package/dist/node/index.mjs
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
3
|
-
var __reflectGet = Reflect.get;
|
|
4
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
|
-
var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
|
|
8
|
-
|
|
9
1
|
// src/lib/getErc1967SlotStatus.ts
|
|
10
2
|
import { hexFromHexString, isHexZero } from "@xylabs/hex";
|
|
11
3
|
import { UpgradeableBeacon__factory } from "@xyo-network/open-zeppelin-typechain";
|
|
@@ -13,17 +5,15 @@ var ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT = "0x360894a13ba1a3210667c828492db
|
|
|
13
5
|
var ERC1967_PROXY_BEACON_STORAGE_SLOT = "0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50";
|
|
14
6
|
var ERC1967_PROXY_ADMIN_STORAGE_SLOT = "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103";
|
|
15
7
|
var ERC1967_PROXY_ROLLBACK_STORAGE_SLOT = "0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143";
|
|
16
|
-
var readAddressFromSlot =
|
|
8
|
+
var readAddressFromSlot = async (provider, address, slot, block) => {
|
|
17
9
|
try {
|
|
18
10
|
const slotValue = await provider.getStorage(address, slot, block);
|
|
19
|
-
return hexFromHexString(slotValue, {
|
|
20
|
-
prefix: true
|
|
21
|
-
});
|
|
11
|
+
return hexFromHexString(slotValue, { prefix: true });
|
|
22
12
|
} catch {
|
|
23
13
|
return;
|
|
24
14
|
}
|
|
25
|
-
}
|
|
26
|
-
var getErc1967SlotStatus =
|
|
15
|
+
};
|
|
16
|
+
var getErc1967SlotStatus = async (provider, address, block) => {
|
|
27
17
|
const status = {
|
|
28
18
|
address,
|
|
29
19
|
implementation: address,
|
|
@@ -38,17 +28,11 @@ var getErc1967SlotStatus = /* @__PURE__ */ __name(async (provider, address, bloc
|
|
|
38
28
|
status.implementation = `0x${BigInt(status.slots.implementation).toString(16).padStart(40, "0")}`;
|
|
39
29
|
} else {
|
|
40
30
|
if (status.slots.beacon && !isHexZero(status.slots.beacon)) {
|
|
41
|
-
const beacon = UpgradeableBeacon__factory.connect(status.slots.beacon, {
|
|
42
|
-
provider
|
|
43
|
-
});
|
|
31
|
+
const beacon = UpgradeableBeacon__factory.connect(status.slots.beacon, { provider });
|
|
44
32
|
try {
|
|
45
|
-
const implementation = await beacon.implementation(block ? {
|
|
46
|
-
blockTag: block
|
|
47
|
-
} : {});
|
|
33
|
+
const implementation = await beacon.implementation(block ? { blockTag: block } : {});
|
|
48
34
|
if (implementation) {
|
|
49
|
-
status.beacon = {
|
|
50
|
-
implementation
|
|
51
|
-
};
|
|
35
|
+
status.beacon = { implementation };
|
|
52
36
|
if (!isHexZero(implementation)) {
|
|
53
37
|
status.implementation = implementation;
|
|
54
38
|
}
|
|
@@ -60,7 +44,7 @@ var getErc1967SlotStatus = /* @__PURE__ */ __name(async (provider, address, bloc
|
|
|
60
44
|
}
|
|
61
45
|
}
|
|
62
46
|
return status;
|
|
63
|
-
}
|
|
47
|
+
};
|
|
64
48
|
|
|
65
49
|
// src/Payload.ts
|
|
66
50
|
var Erc1967StatusSchema = "network.xyo.erc1967.status";
|
|
@@ -70,27 +54,31 @@ import { assertEx } from "@xylabs/assert";
|
|
|
70
54
|
import { isPayloadOfSchemaType } from "@xyo-network/payload-model";
|
|
71
55
|
import { AbstractEvmWitness, EvmAddressSchema } from "@xyo-network/witness-evm-abstract";
|
|
72
56
|
var Erc1967WitnessConfigSchema = "network.xyo.erc1967.witness.config";
|
|
73
|
-
var
|
|
57
|
+
var Erc1967Witness = class extends AbstractEvmWitness {
|
|
58
|
+
static configSchemas = [...super.configSchemas, Erc1967WitnessConfigSchema];
|
|
59
|
+
static defaultConfigSchema = Erc1967WitnessConfigSchema;
|
|
74
60
|
async observeHandler(inPayloads = []) {
|
|
75
61
|
await this.started("throw");
|
|
76
62
|
await this.getProviders();
|
|
77
63
|
try {
|
|
78
|
-
const observations = await Promise.all(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
64
|
+
const observations = await Promise.all(
|
|
65
|
+
inPayloads.filter(isPayloadOfSchemaType(EvmAddressSchema)).map(async ({ address }) => {
|
|
66
|
+
const validatedAddress = assertEx(address ?? this.config.address, () => "Missing address").toLowerCase();
|
|
67
|
+
const provider = await this.getProvider(true, true);
|
|
68
|
+
const block = await provider.getBlockNumber();
|
|
69
|
+
const { beacon, implementation, slots } = await getErc1967SlotStatus(provider, validatedAddress, block);
|
|
70
|
+
const observation = {
|
|
71
|
+
address: validatedAddress,
|
|
72
|
+
beacon,
|
|
73
|
+
block,
|
|
74
|
+
chainId: Number((await provider.getNetwork()).chainId),
|
|
75
|
+
implementation,
|
|
76
|
+
schema: Erc1967StatusSchema,
|
|
77
|
+
slots
|
|
78
|
+
};
|
|
79
|
+
return observation;
|
|
80
|
+
})
|
|
81
|
+
);
|
|
94
82
|
return observations;
|
|
95
83
|
} catch (ex) {
|
|
96
84
|
const error = ex;
|
|
@@ -99,13 +87,6 @@ var _Erc1967Witness = class _Erc1967Witness extends AbstractEvmWitness {
|
|
|
99
87
|
}
|
|
100
88
|
}
|
|
101
89
|
};
|
|
102
|
-
__name(_Erc1967Witness, "Erc1967Witness");
|
|
103
|
-
__publicField(_Erc1967Witness, "configSchemas", [
|
|
104
|
-
...__superGet(_Erc1967Witness, _Erc1967Witness, "configSchemas"),
|
|
105
|
-
Erc1967WitnessConfigSchema
|
|
106
|
-
]);
|
|
107
|
-
__publicField(_Erc1967Witness, "defaultConfigSchema", Erc1967WitnessConfigSchema);
|
|
108
|
-
var Erc1967Witness = _Erc1967Witness;
|
|
109
90
|
export {
|
|
110
91
|
ERC1967_PROXY_ADMIN_STORAGE_SLOT,
|
|
111
92
|
ERC1967_PROXY_BEACON_STORAGE_SLOT,
|
package/dist/node/index.mjs.map
CHANGED
|
@@ -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 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 { Payload } from '@xyo-network/payload-model'\n\nimport { 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 { isPayloadOfSchemaType, Schema } from '@xyo-network/payload-model'\nimport { AbstractEvmWitness, EvmAddress, EvmAddressSchema, EvmWitnessConfig, EvmWitnessParams } from '@xyo-network/witness-evm-abstract'\n\nimport { getErc1967SlotStatus } from './lib/index.ts'\nimport { Erc1967Status, 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 { 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":"
|
|
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 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 { Payload } from '@xyo-network/payload-model'\n\nimport { 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 { isPayloadOfSchemaType, Schema } from '@xyo-network/payload-model'\nimport { AbstractEvmWitness, EvmAddress, EvmAddressSchema, EvmWitnessConfig, EvmWitnessParams } from '@xyo-network/witness-evm-abstract'\n\nimport { getErc1967SlotStatus } from './lib/index.ts'\nimport { Erc1967Status, 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 { 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,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,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,YA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AAS,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":[]}
|
package/package.json
CHANGED
|
@@ -10,17 +10,17 @@
|
|
|
10
10
|
"url": "https://github.com/XYOracleNetwork/plugins/issues"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@xylabs/assert": "^3.6.
|
|
14
|
-
"@xylabs/hex": "^3.6.
|
|
15
|
-
"@xyo-network/open-zeppelin-typechain": "^3.0
|
|
16
|
-
"@xyo-network/payload-model": "^2.111.
|
|
17
|
-
"@xyo-network/witness-evm-abstract": "^2.111.
|
|
13
|
+
"@xylabs/assert": "^3.6.12",
|
|
14
|
+
"@xylabs/hex": "^3.6.12",
|
|
15
|
+
"@xyo-network/open-zeppelin-typechain": "^3.1.0",
|
|
16
|
+
"@xyo-network/payload-model": "^2.111.3",
|
|
17
|
+
"@xyo-network/witness-evm-abstract": "^2.111.3",
|
|
18
|
+
"ethers": "^6.13.2"
|
|
18
19
|
},
|
|
19
20
|
"devDependencies": {
|
|
20
|
-
"@xylabs/jest-helpers": "^3.6.
|
|
21
|
-
"@xylabs/ts-scripts-yarn3": "^3.15.
|
|
22
|
-
"@xylabs/tsconfig": "^3.15.
|
|
23
|
-
"ethers": "^6.13.2",
|
|
21
|
+
"@xylabs/jest-helpers": "^3.6.12",
|
|
22
|
+
"@xylabs/ts-scripts-yarn3": "^3.15.14",
|
|
23
|
+
"@xylabs/tsconfig": "^3.15.14",
|
|
24
24
|
"jest": "^29.7.0",
|
|
25
25
|
"typescript": "^5.5.4"
|
|
26
26
|
},
|
|
@@ -63,6 +63,6 @@
|
|
|
63
63
|
"url": "https://github.com/XYOracleNetwork/plugins.git"
|
|
64
64
|
},
|
|
65
65
|
"sideEffects": false,
|
|
66
|
-
"version": "2.99.
|
|
66
|
+
"version": "2.99.6",
|
|
67
67
|
"type": "module"
|
|
68
68
|
}
|