@xyo-network/erc1967-witness 2.99.4 → 2.99.5
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/Payload.d.cts +1 -1
- package/dist/browser/Payload.d.mts +1 -1
- package/dist/browser/Payload.d.ts +1 -1
- package/dist/browser/Witness.d.cts +1 -1
- package/dist/browser/Witness.d.mts +1 -1
- package/dist/browser/Witness.d.ts +1 -1
- package/dist/browser/index.cjs +40 -27
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.d.cts +3 -3
- package/dist/browser/index.d.mts +3 -3
- package/dist/browser/index.d.ts +3 -3
- package/dist/browser/{index.js → index.mjs} +43 -28
- package/dist/browser/index.mjs.map +1 -0
- package/dist/browser/lib/index.d.cts +1 -1
- package/dist/browser/lib/index.d.mts +1 -1
- package/dist/browser/lib/index.d.ts +1 -1
- package/dist/neutral/Payload.d.cts +1 -1
- package/dist/neutral/Payload.d.mts +1 -1
- package/dist/neutral/Payload.d.ts +1 -1
- package/dist/neutral/Witness.d.cts +1 -1
- package/dist/neutral/Witness.d.mts +1 -1
- package/dist/neutral/Witness.d.ts +1 -1
- package/dist/neutral/index.cjs +40 -27
- package/dist/neutral/index.cjs.map +1 -1
- package/dist/neutral/index.d.cts +3 -3
- package/dist/neutral/index.d.mts +3 -3
- package/dist/neutral/index.d.ts +3 -3
- package/dist/{node/index.js → neutral/index.mjs} +43 -28
- package/dist/neutral/index.mjs.map +1 -0
- package/dist/neutral/lib/index.d.cts +1 -1
- package/dist/neutral/lib/index.d.mts +1 -1
- package/dist/neutral/lib/index.d.ts +1 -1
- package/dist/node/Payload.d.cts +1 -1
- package/dist/node/Payload.d.mts +1 -1
- package/dist/node/Payload.d.ts +1 -1
- package/dist/node/Witness.d.cts +1 -1
- package/dist/node/Witness.d.mts +1 -1
- package/dist/node/Witness.d.ts +1 -1
- package/dist/node/index.cjs +46 -29
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +3 -3
- package/dist/node/index.d.mts +3 -3
- package/dist/node/index.d.ts +3 -3
- package/dist/{neutral/index.js → node/index.mjs} +49 -30
- package/dist/node/index.mjs.map +1 -0
- package/dist/node/lib/index.d.cts +1 -1
- package/dist/node/lib/index.d.mts +1 -1
- package/dist/node/lib/index.d.ts +1 -1
- package/package.json +13 -13
- package/src/Payload.ts +1 -1
- package/src/Witness.ts +3 -3
- package/src/index.ts +3 -3
- package/src/lib/index.ts +1 -1
- package/dist/browser/index.js.map +0 -1
- package/dist/neutral/index.js.map +0 -1
- package/dist/node/index.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Payload } from '@xyo-network/payload-model';
|
|
2
|
-
import { Erc1967SlotStatus } from './lib/index.
|
|
2
|
+
import { Erc1967SlotStatus } from './lib/index.ts';
|
|
3
3
|
export declare const Erc1967StatusSchema = "network.xyo.erc1967.status";
|
|
4
4
|
export type Erc1967StatusSchema = typeof Erc1967StatusSchema;
|
|
5
5
|
export type Erc1967Status = Payload<{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Payload } from '@xyo-network/payload-model';
|
|
2
|
-
import { Erc1967SlotStatus } from './lib/index.
|
|
2
|
+
import { Erc1967SlotStatus } from './lib/index.ts';
|
|
3
3
|
export declare const Erc1967StatusSchema = "network.xyo.erc1967.status";
|
|
4
4
|
export type Erc1967StatusSchema = typeof Erc1967StatusSchema;
|
|
5
5
|
export type Erc1967Status = Payload<{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Payload } from '@xyo-network/payload-model';
|
|
2
|
-
import { Erc1967SlotStatus } from './lib/index.
|
|
2
|
+
import { Erc1967SlotStatus } from './lib/index.ts';
|
|
3
3
|
export declare const Erc1967StatusSchema = "network.xyo.erc1967.status";
|
|
4
4
|
export type Erc1967StatusSchema = typeof Erc1967StatusSchema;
|
|
5
5
|
export type Erc1967Status = Payload<{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Schema } from '@xyo-network/payload-model';
|
|
2
2
|
import { AbstractEvmWitness, EvmAddress, EvmWitnessConfig, EvmWitnessParams } from '@xyo-network/witness-evm-abstract';
|
|
3
|
-
import { Erc1967Status } from './Payload.
|
|
3
|
+
import { Erc1967Status } from './Payload.ts';
|
|
4
4
|
export declare const Erc1967WitnessConfigSchema = "network.xyo.erc1967.witness.config";
|
|
5
5
|
export type Erc1967WitnessConfigSchema = typeof Erc1967WitnessConfigSchema;
|
|
6
6
|
export type Erc1967WitnessConfig = EvmWitnessConfig<{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Schema } from '@xyo-network/payload-model';
|
|
2
2
|
import { AbstractEvmWitness, EvmAddress, EvmWitnessConfig, EvmWitnessParams } from '@xyo-network/witness-evm-abstract';
|
|
3
|
-
import { Erc1967Status } from './Payload.
|
|
3
|
+
import { Erc1967Status } from './Payload.ts';
|
|
4
4
|
export declare const Erc1967WitnessConfigSchema = "network.xyo.erc1967.witness.config";
|
|
5
5
|
export type Erc1967WitnessConfigSchema = typeof Erc1967WitnessConfigSchema;
|
|
6
6
|
export type Erc1967WitnessConfig = EvmWitnessConfig<{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Schema } from '@xyo-network/payload-model';
|
|
2
2
|
import { AbstractEvmWitness, EvmAddress, EvmWitnessConfig, EvmWitnessParams } from '@xyo-network/witness-evm-abstract';
|
|
3
|
-
import { Erc1967Status } from './Payload.
|
|
3
|
+
import { Erc1967Status } from './Payload.ts';
|
|
4
4
|
export declare const Erc1967WitnessConfigSchema = "network.xyo.erc1967.witness.config";
|
|
5
5
|
export type Erc1967WitnessConfigSchema = typeof Erc1967WitnessConfigSchema;
|
|
6
6
|
export type Erc1967WitnessConfig = EvmWitnessConfig<{
|
package/dist/browser/index.cjs
CHANGED
|
@@ -3,6 +3,7 @@ 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 });
|
|
6
7
|
var __export = (target, all) => {
|
|
7
8
|
for (var name in all)
|
|
8
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -38,15 +39,17 @@ var ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT = "0x360894a13ba1a3210667c828492db
|
|
|
38
39
|
var ERC1967_PROXY_BEACON_STORAGE_SLOT = "0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50";
|
|
39
40
|
var ERC1967_PROXY_ADMIN_STORAGE_SLOT = "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103";
|
|
40
41
|
var ERC1967_PROXY_ROLLBACK_STORAGE_SLOT = "0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143";
|
|
41
|
-
var readAddressFromSlot = async (provider, address, slot, block) => {
|
|
42
|
+
var readAddressFromSlot = /* @__PURE__ */ __name(async (provider, address, slot, block) => {
|
|
42
43
|
try {
|
|
43
44
|
const slotValue = await provider.getStorage(address, slot, block);
|
|
44
|
-
return (0, import_hex.hexFromHexString)(slotValue, {
|
|
45
|
+
return (0, import_hex.hexFromHexString)(slotValue, {
|
|
46
|
+
prefix: true
|
|
47
|
+
});
|
|
45
48
|
} catch {
|
|
46
49
|
return;
|
|
47
50
|
}
|
|
48
|
-
};
|
|
49
|
-
var getErc1967SlotStatus = async (provider, address, block) => {
|
|
51
|
+
}, "readAddressFromSlot");
|
|
52
|
+
var getErc1967SlotStatus = /* @__PURE__ */ __name(async (provider, address, block) => {
|
|
50
53
|
const status = {
|
|
51
54
|
address,
|
|
52
55
|
implementation: address,
|
|
@@ -61,11 +64,17 @@ var getErc1967SlotStatus = async (provider, address, block) => {
|
|
|
61
64
|
status.implementation = `0x${BigInt(status.slots.implementation).toString(16).padStart(40, "0")}`;
|
|
62
65
|
} else {
|
|
63
66
|
if (status.slots.beacon && !(0, import_hex.isHexZero)(status.slots.beacon)) {
|
|
64
|
-
const beacon = import_open_zeppelin_typechain.UpgradeableBeacon__factory.connect(status.slots.beacon, {
|
|
67
|
+
const beacon = import_open_zeppelin_typechain.UpgradeableBeacon__factory.connect(status.slots.beacon, {
|
|
68
|
+
provider
|
|
69
|
+
});
|
|
65
70
|
try {
|
|
66
|
-
const implementation = await beacon.implementation(block ? {
|
|
71
|
+
const implementation = await beacon.implementation(block ? {
|
|
72
|
+
blockTag: block
|
|
73
|
+
} : {});
|
|
67
74
|
if (implementation) {
|
|
68
|
-
status.beacon = {
|
|
75
|
+
status.beacon = {
|
|
76
|
+
implementation
|
|
77
|
+
};
|
|
69
78
|
if (!(0, import_hex.isHexZero)(implementation)) {
|
|
70
79
|
status.implementation = implementation;
|
|
71
80
|
}
|
|
@@ -77,7 +86,7 @@ var getErc1967SlotStatus = async (provider, address, block) => {
|
|
|
77
86
|
}
|
|
78
87
|
}
|
|
79
88
|
return status;
|
|
80
|
-
};
|
|
89
|
+
}, "getErc1967SlotStatus");
|
|
81
90
|
|
|
82
91
|
// src/Payload.ts
|
|
83
92
|
var Erc1967StatusSchema = "network.xyo.erc1967.status";
|
|
@@ -88,30 +97,34 @@ var import_payload_model = require("@xyo-network/payload-model");
|
|
|
88
97
|
var import_witness_evm_abstract = require("@xyo-network/witness-evm-abstract");
|
|
89
98
|
var Erc1967WitnessConfigSchema = "network.xyo.erc1967.witness.config";
|
|
90
99
|
var Erc1967Witness = class extends import_witness_evm_abstract.AbstractEvmWitness {
|
|
91
|
-
static
|
|
100
|
+
static {
|
|
101
|
+
__name(this, "Erc1967Witness");
|
|
102
|
+
}
|
|
103
|
+
static configSchemas = [
|
|
104
|
+
...super.configSchemas,
|
|
105
|
+
Erc1967WitnessConfigSchema
|
|
106
|
+
];
|
|
92
107
|
static defaultConfigSchema = Erc1967WitnessConfigSchema;
|
|
93
108
|
async observeHandler(inPayloads = []) {
|
|
94
109
|
await this.started("throw");
|
|
95
110
|
await this.getProviders();
|
|
96
111
|
try {
|
|
97
|
-
const observations = await Promise.all(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
})
|
|
114
|
-
);
|
|
112
|
+
const observations = await Promise.all(inPayloads.filter((0, import_payload_model.isPayloadOfSchemaType)(import_witness_evm_abstract.EvmAddressSchema)).map(async ({ address }) => {
|
|
113
|
+
const validatedAddress = (0, import_assert.assertEx)(address ?? this.config.address, () => "Missing address").toLowerCase();
|
|
114
|
+
const provider = await this.getProvider(true, true);
|
|
115
|
+
const block = await provider.getBlockNumber();
|
|
116
|
+
const { beacon, implementation, slots } = await getErc1967SlotStatus(provider, validatedAddress, block);
|
|
117
|
+
const observation = {
|
|
118
|
+
address: validatedAddress,
|
|
119
|
+
beacon,
|
|
120
|
+
block,
|
|
121
|
+
chainId: Number((await provider.getNetwork()).chainId),
|
|
122
|
+
implementation,
|
|
123
|
+
schema: Erc1967StatusSchema,
|
|
124
|
+
slots
|
|
125
|
+
};
|
|
126
|
+
return observation;
|
|
127
|
+
}));
|
|
115
128
|
return observations;
|
|
116
129
|
} catch (ex) {
|
|
117
130
|
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.
|
|
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;;;;;;;;;;;;;;ACAA,iBAAqD;AACrD,qCAA2C;AAGpC,IAAMA,4CAA4C;AAClD,IAAMC,oCAAoC;AAC1C,IAAMC,mCAAmC;AACzC,IAAMC,sCAAsC;AAkBnD,IAAMC,sBAAsB,8BAAOC,UAAoBC,SAAiBC,MAAcC,UAAAA;AACpF,MAAI;AACF,UAAMC,YAAY,MAAMJ,SAASK,WAAWJ,SAASC,MAAMC,KAAAA;AAC3D,eAAOG,6BAAiBF,WAAW;MAAEG,QAAQ;IAAK,CAAA;EACpD,QAAQ;AACN;EACF;AACF,GAP4B;AASrB,IAAMC,uBAAuB,8BAAOR,UAAoBC,SAAiBE,UAAAA;AAC9E,QAAMM,SAA4B;IAChCR;IACAS,gBAAgBT;IAChBU,OAAO;MACLC,OAAO,MAAMb,oBAAoBC,UAAUC,SAASJ,kCAAkCM,KAAAA;MACtFU,QAAQ,MAAMd,oBAAoBC,UAAUC,SAASL,mCAAmCO,KAAAA;MACxFO,gBAAgB,MAAMX,oBAAoBC,UAAUC,SAASN,2CAA2CQ,KAAAA;MACxGW,UAAU,MAAMf,oBAAoBC,UAAUC,SAAS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AAKG,OAAOH,SAAS,MAAM,iBAAA,EAAmBI,YAAW;AAEtG,cAAMC,WAAW,MAAM,KAAKC,YAAY,MAAM,IAAA;AAE9C,cAAMC,QAAQ,MAAMF,SAASG,eAAc;AAE3C,cAAM,EAAEC,QAAQC,gBAAgBC,MAAK,IAAK,MAAMC,qBAAqBP,UAAUJ,kBAAkBM,KAAAA;AAEjG,cAAMM,cAA6B;UACjCb,SAASC;UACTQ;UACAF;UACAO,SAASC,QAAQ,MAAMV,SAASW,WAAU,GAAIF,OAAO;UACrDJ;UACAO,QAAQC;UACRP;QACF;AACA,eAAOE;MACT,CAAA,CAAA;AAEF,aAAOpB;IACT,SAAS0B,IAAI;AACX,YAAMC,QAAQD;AACdE,cAAQC,IAAI,UAAU,KAAKnB,OAAOoB,IAAI,MAAMH,MAAMI,OAAO,EAAE;AAC3D,YAAMJ;IACR;EACF;AACF;","names":["ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT","ERC1967_PROXY_BEACON_STORAGE_SLOT","ERC1967_PROXY_ADMIN_STORAGE_SLOT","ERC1967_PROXY_ROLLBACK_STORAGE_SLOT","readAddressFromSlot","provider","address","slot","block","slotValue","getStorage","hexFromHexString","prefix","getErc1967SlotStatus","status","implementation","slots","admin","beacon","rollback","isHexZero","BigInt","toString","padStart","UpgradeableBeacon__factory","connect","blockTag","ex","error","console","log","message","Erc1967StatusSchema","Erc1967WitnessConfigSchema","Erc1967Witness","AbstractEvmWitness","configSchemas","defaultConfigSchema","observeHandler","inPayloads","started","getProviders","observations","Promise","all","filter","isPayloadOfSchemaType","EvmAddressSchema","map","address","validatedAddress","assertEx","config","toLowerCase","provider","getProvider","block","getBlockNumber","beacon","implementation","slots","getErc1967SlotStatus","observation","chainId","Number","getNetwork","schema","Erc1967StatusSchema","ex","error","console","log","name","message"]}
|
package/dist/browser/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './lib/index.
|
|
2
|
-
export * from './Payload.
|
|
3
|
-
export * from './Witness.
|
|
1
|
+
export * from './lib/index.ts';
|
|
2
|
+
export * from './Payload.ts';
|
|
3
|
+
export * from './Witness.ts';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/browser/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './lib/index.
|
|
2
|
-
export * from './Payload.
|
|
3
|
-
export * from './Witness.
|
|
1
|
+
export * from './lib/index.ts';
|
|
2
|
+
export * from './Payload.ts';
|
|
3
|
+
export * from './Witness.ts';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './lib/index.
|
|
2
|
-
export * from './Payload.
|
|
3
|
-
export * from './Witness.
|
|
1
|
+
export * from './lib/index.ts';
|
|
2
|
+
export * from './Payload.ts';
|
|
3
|
+
export * from './Witness.ts';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
1
4
|
// src/lib/getErc1967SlotStatus.ts
|
|
2
5
|
import { hexFromHexString, isHexZero } from "@xylabs/hex";
|
|
3
6
|
import { UpgradeableBeacon__factory } from "@xyo-network/open-zeppelin-typechain";
|
|
@@ -5,15 +8,17 @@ var ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT = "0x360894a13ba1a3210667c828492db
|
|
|
5
8
|
var ERC1967_PROXY_BEACON_STORAGE_SLOT = "0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50";
|
|
6
9
|
var ERC1967_PROXY_ADMIN_STORAGE_SLOT = "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103";
|
|
7
10
|
var ERC1967_PROXY_ROLLBACK_STORAGE_SLOT = "0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143";
|
|
8
|
-
var readAddressFromSlot = async (provider, address, slot, block) => {
|
|
11
|
+
var readAddressFromSlot = /* @__PURE__ */ __name(async (provider, address, slot, block) => {
|
|
9
12
|
try {
|
|
10
13
|
const slotValue = await provider.getStorage(address, slot, block);
|
|
11
|
-
return hexFromHexString(slotValue, {
|
|
14
|
+
return hexFromHexString(slotValue, {
|
|
15
|
+
prefix: true
|
|
16
|
+
});
|
|
12
17
|
} catch {
|
|
13
18
|
return;
|
|
14
19
|
}
|
|
15
|
-
};
|
|
16
|
-
var getErc1967SlotStatus = async (provider, address, block) => {
|
|
20
|
+
}, "readAddressFromSlot");
|
|
21
|
+
var getErc1967SlotStatus = /* @__PURE__ */ __name(async (provider, address, block) => {
|
|
17
22
|
const status = {
|
|
18
23
|
address,
|
|
19
24
|
implementation: address,
|
|
@@ -28,11 +33,17 @@ var getErc1967SlotStatus = async (provider, address, block) => {
|
|
|
28
33
|
status.implementation = `0x${BigInt(status.slots.implementation).toString(16).padStart(40, "0")}`;
|
|
29
34
|
} else {
|
|
30
35
|
if (status.slots.beacon && !isHexZero(status.slots.beacon)) {
|
|
31
|
-
const beacon = UpgradeableBeacon__factory.connect(status.slots.beacon, {
|
|
36
|
+
const beacon = UpgradeableBeacon__factory.connect(status.slots.beacon, {
|
|
37
|
+
provider
|
|
38
|
+
});
|
|
32
39
|
try {
|
|
33
|
-
const implementation = await beacon.implementation(block ? {
|
|
40
|
+
const implementation = await beacon.implementation(block ? {
|
|
41
|
+
blockTag: block
|
|
42
|
+
} : {});
|
|
34
43
|
if (implementation) {
|
|
35
|
-
status.beacon = {
|
|
44
|
+
status.beacon = {
|
|
45
|
+
implementation
|
|
46
|
+
};
|
|
36
47
|
if (!isHexZero(implementation)) {
|
|
37
48
|
status.implementation = implementation;
|
|
38
49
|
}
|
|
@@ -44,7 +55,7 @@ var getErc1967SlotStatus = async (provider, address, block) => {
|
|
|
44
55
|
}
|
|
45
56
|
}
|
|
46
57
|
return status;
|
|
47
|
-
};
|
|
58
|
+
}, "getErc1967SlotStatus");
|
|
48
59
|
|
|
49
60
|
// src/Payload.ts
|
|
50
61
|
var Erc1967StatusSchema = "network.xyo.erc1967.status";
|
|
@@ -55,30 +66,34 @@ import { isPayloadOfSchemaType } from "@xyo-network/payload-model";
|
|
|
55
66
|
import { AbstractEvmWitness, EvmAddressSchema } from "@xyo-network/witness-evm-abstract";
|
|
56
67
|
var Erc1967WitnessConfigSchema = "network.xyo.erc1967.witness.config";
|
|
57
68
|
var Erc1967Witness = class extends AbstractEvmWitness {
|
|
58
|
-
static
|
|
69
|
+
static {
|
|
70
|
+
__name(this, "Erc1967Witness");
|
|
71
|
+
}
|
|
72
|
+
static configSchemas = [
|
|
73
|
+
...super.configSchemas,
|
|
74
|
+
Erc1967WitnessConfigSchema
|
|
75
|
+
];
|
|
59
76
|
static defaultConfigSchema = Erc1967WitnessConfigSchema;
|
|
60
77
|
async observeHandler(inPayloads = []) {
|
|
61
78
|
await this.started("throw");
|
|
62
79
|
await this.getProviders();
|
|
63
80
|
try {
|
|
64
|
-
const observations = await Promise.all(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
})
|
|
81
|
-
);
|
|
81
|
+
const observations = await Promise.all(inPayloads.filter(isPayloadOfSchemaType(EvmAddressSchema)).map(async ({ address }) => {
|
|
82
|
+
const validatedAddress = assertEx(address ?? this.config.address, () => "Missing address").toLowerCase();
|
|
83
|
+
const provider = await this.getProvider(true, true);
|
|
84
|
+
const block = await provider.getBlockNumber();
|
|
85
|
+
const { beacon, implementation, slots } = await getErc1967SlotStatus(provider, validatedAddress, block);
|
|
86
|
+
const observation = {
|
|
87
|
+
address: validatedAddress,
|
|
88
|
+
beacon,
|
|
89
|
+
block,
|
|
90
|
+
chainId: Number((await provider.getNetwork()).chainId),
|
|
91
|
+
implementation,
|
|
92
|
+
schema: Erc1967StatusSchema,
|
|
93
|
+
slots
|
|
94
|
+
};
|
|
95
|
+
return observation;
|
|
96
|
+
}));
|
|
82
97
|
return observations;
|
|
83
98
|
} catch (ex) {
|
|
84
99
|
const error = ex;
|
|
@@ -97,4 +112,4 @@ export {
|
|
|
97
112
|
Erc1967WitnessConfigSchema,
|
|
98
113
|
getErc1967SlotStatus
|
|
99
114
|
};
|
|
100
|
-
//# sourceMappingURL=index.
|
|
115
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +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":";;;;AAAA,SAAkBA,kBAAkBC,iBAAiB;AACrD,SAASC,kCAAkC;AAGpC,IAAMC,4CAA4C;AAClD,IAAMC,oCAAoC;AAC1C,IAAMC,mCAAmC;AACzC,IAAMC,sCAAsC;AAkBnD,IAAMC,sBAAsB,8BAAOC,UAA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N_STORAGE_SLOT","ERC1967_PROXY_ROLLBACK_STORAGE_SLOT","readAddressFromSlot","provider","address","slot","block","slotValue","getStorage","hexFromHexString","prefix","getErc1967SlotStatus","status","implementation","slots","admin","beacon","rollback","isHexZero","BigInt","toString","padStart","UpgradeableBeacon__factory","connect","blockTag","ex","error","console","log","message","Erc1967StatusSchema","assertEx","isPayloadOfSchemaType","AbstractEvmWitness","EvmAddressSchema","Erc1967WitnessConfigSchema","Erc1967Witness","AbstractEvmWitness","configSchemas","defaultConfigSchema","observeHandler","inPayloads","started","getProviders","observations","Promise","all","filter","isPayloadOfSchemaType","EvmAddressSchema","map","address","validatedAddress","assertEx","config","toLowerCase","provider","getProvider","block","getBlockNumber","beacon","implementation","slots","getErc1967SlotStatus","observation","chainId","Number","getNetwork","schema","Erc1967StatusSchema","ex","error","console","log","name","message"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './getErc1967SlotStatus.
|
|
1
|
+
export * from './getErc1967SlotStatus.ts';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './getErc1967SlotStatus.
|
|
1
|
+
export * from './getErc1967SlotStatus.ts';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './getErc1967SlotStatus.
|
|
1
|
+
export * from './getErc1967SlotStatus.ts';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Payload } from '@xyo-network/payload-model';
|
|
2
|
-
import { Erc1967SlotStatus } from './lib/index.
|
|
2
|
+
import { Erc1967SlotStatus } from './lib/index.ts';
|
|
3
3
|
export declare const Erc1967StatusSchema = "network.xyo.erc1967.status";
|
|
4
4
|
export type Erc1967StatusSchema = typeof Erc1967StatusSchema;
|
|
5
5
|
export type Erc1967Status = Payload<{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Payload } from '@xyo-network/payload-model';
|
|
2
|
-
import { Erc1967SlotStatus } from './lib/index.
|
|
2
|
+
import { Erc1967SlotStatus } from './lib/index.ts';
|
|
3
3
|
export declare const Erc1967StatusSchema = "network.xyo.erc1967.status";
|
|
4
4
|
export type Erc1967StatusSchema = typeof Erc1967StatusSchema;
|
|
5
5
|
export type Erc1967Status = Payload<{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Payload } from '@xyo-network/payload-model';
|
|
2
|
-
import { Erc1967SlotStatus } from './lib/index.
|
|
2
|
+
import { Erc1967SlotStatus } from './lib/index.ts';
|
|
3
3
|
export declare const Erc1967StatusSchema = "network.xyo.erc1967.status";
|
|
4
4
|
export type Erc1967StatusSchema = typeof Erc1967StatusSchema;
|
|
5
5
|
export type Erc1967Status = Payload<{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Schema } from '@xyo-network/payload-model';
|
|
2
2
|
import { AbstractEvmWitness, EvmAddress, EvmWitnessConfig, EvmWitnessParams } from '@xyo-network/witness-evm-abstract';
|
|
3
|
-
import { Erc1967Status } from './Payload.
|
|
3
|
+
import { Erc1967Status } from './Payload.ts';
|
|
4
4
|
export declare const Erc1967WitnessConfigSchema = "network.xyo.erc1967.witness.config";
|
|
5
5
|
export type Erc1967WitnessConfigSchema = typeof Erc1967WitnessConfigSchema;
|
|
6
6
|
export type Erc1967WitnessConfig = EvmWitnessConfig<{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Schema } from '@xyo-network/payload-model';
|
|
2
2
|
import { AbstractEvmWitness, EvmAddress, EvmWitnessConfig, EvmWitnessParams } from '@xyo-network/witness-evm-abstract';
|
|
3
|
-
import { Erc1967Status } from './Payload.
|
|
3
|
+
import { Erc1967Status } from './Payload.ts';
|
|
4
4
|
export declare const Erc1967WitnessConfigSchema = "network.xyo.erc1967.witness.config";
|
|
5
5
|
export type Erc1967WitnessConfigSchema = typeof Erc1967WitnessConfigSchema;
|
|
6
6
|
export type Erc1967WitnessConfig = EvmWitnessConfig<{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Schema } from '@xyo-network/payload-model';
|
|
2
2
|
import { AbstractEvmWitness, EvmAddress, EvmWitnessConfig, EvmWitnessParams } from '@xyo-network/witness-evm-abstract';
|
|
3
|
-
import { Erc1967Status } from './Payload.
|
|
3
|
+
import { Erc1967Status } from './Payload.ts';
|
|
4
4
|
export declare const Erc1967WitnessConfigSchema = "network.xyo.erc1967.witness.config";
|
|
5
5
|
export type Erc1967WitnessConfigSchema = typeof Erc1967WitnessConfigSchema;
|
|
6
6
|
export type Erc1967WitnessConfig = EvmWitnessConfig<{
|
package/dist/neutral/index.cjs
CHANGED
|
@@ -3,6 +3,7 @@ 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 });
|
|
6
7
|
var __export = (target, all) => {
|
|
7
8
|
for (var name in all)
|
|
8
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -38,15 +39,17 @@ var ERC1967_PROXY_IMPLEMENTATION_STORAGE_SLOT = "0x360894a13ba1a3210667c828492db
|
|
|
38
39
|
var ERC1967_PROXY_BEACON_STORAGE_SLOT = "0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50";
|
|
39
40
|
var ERC1967_PROXY_ADMIN_STORAGE_SLOT = "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103";
|
|
40
41
|
var ERC1967_PROXY_ROLLBACK_STORAGE_SLOT = "0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143";
|
|
41
|
-
var readAddressFromSlot = async (provider, address, slot, block) => {
|
|
42
|
+
var readAddressFromSlot = /* @__PURE__ */ __name(async (provider, address, slot, block) => {
|
|
42
43
|
try {
|
|
43
44
|
const slotValue = await provider.getStorage(address, slot, block);
|
|
44
|
-
return (0, import_hex.hexFromHexString)(slotValue, {
|
|
45
|
+
return (0, import_hex.hexFromHexString)(slotValue, {
|
|
46
|
+
prefix: true
|
|
47
|
+
});
|
|
45
48
|
} catch {
|
|
46
49
|
return;
|
|
47
50
|
}
|
|
48
|
-
};
|
|
49
|
-
var getErc1967SlotStatus = async (provider, address, block) => {
|
|
51
|
+
}, "readAddressFromSlot");
|
|
52
|
+
var getErc1967SlotStatus = /* @__PURE__ */ __name(async (provider, address, block) => {
|
|
50
53
|
const status = {
|
|
51
54
|
address,
|
|
52
55
|
implementation: address,
|
|
@@ -61,11 +64,17 @@ var getErc1967SlotStatus = async (provider, address, block) => {
|
|
|
61
64
|
status.implementation = `0x${BigInt(status.slots.implementation).toString(16).padStart(40, "0")}`;
|
|
62
65
|
} else {
|
|
63
66
|
if (status.slots.beacon && !(0, import_hex.isHexZero)(status.slots.beacon)) {
|
|
64
|
-
const beacon = import_open_zeppelin_typechain.UpgradeableBeacon__factory.connect(status.slots.beacon, {
|
|
67
|
+
const beacon = import_open_zeppelin_typechain.UpgradeableBeacon__factory.connect(status.slots.beacon, {
|
|
68
|
+
provider
|
|
69
|
+
});
|
|
65
70
|
try {
|
|
66
|
-
const implementation = await beacon.implementation(block ? {
|
|
71
|
+
const implementation = await beacon.implementation(block ? {
|
|
72
|
+
blockTag: block
|
|
73
|
+
} : {});
|
|
67
74
|
if (implementation) {
|
|
68
|
-
status.beacon = {
|
|
75
|
+
status.beacon = {
|
|
76
|
+
implementation
|
|
77
|
+
};
|
|
69
78
|
if (!(0, import_hex.isHexZero)(implementation)) {
|
|
70
79
|
status.implementation = implementation;
|
|
71
80
|
}
|
|
@@ -77,7 +86,7 @@ var getErc1967SlotStatus = async (provider, address, block) => {
|
|
|
77
86
|
}
|
|
78
87
|
}
|
|
79
88
|
return status;
|
|
80
|
-
};
|
|
89
|
+
}, "getErc1967SlotStatus");
|
|
81
90
|
|
|
82
91
|
// src/Payload.ts
|
|
83
92
|
var Erc1967StatusSchema = "network.xyo.erc1967.status";
|
|
@@ -88,30 +97,34 @@ var import_payload_model = require("@xyo-network/payload-model");
|
|
|
88
97
|
var import_witness_evm_abstract = require("@xyo-network/witness-evm-abstract");
|
|
89
98
|
var Erc1967WitnessConfigSchema = "network.xyo.erc1967.witness.config";
|
|
90
99
|
var Erc1967Witness = class extends import_witness_evm_abstract.AbstractEvmWitness {
|
|
91
|
-
static
|
|
100
|
+
static {
|
|
101
|
+
__name(this, "Erc1967Witness");
|
|
102
|
+
}
|
|
103
|
+
static configSchemas = [
|
|
104
|
+
...super.configSchemas,
|
|
105
|
+
Erc1967WitnessConfigSchema
|
|
106
|
+
];
|
|
92
107
|
static defaultConfigSchema = Erc1967WitnessConfigSchema;
|
|
93
108
|
async observeHandler(inPayloads = []) {
|
|
94
109
|
await this.started("throw");
|
|
95
110
|
await this.getProviders();
|
|
96
111
|
try {
|
|
97
|
-
const observations = await Promise.all(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
})
|
|
114
|
-
);
|
|
112
|
+
const observations = await Promise.all(inPayloads.filter((0, import_payload_model.isPayloadOfSchemaType)(import_witness_evm_abstract.EvmAddressSchema)).map(async ({ address }) => {
|
|
113
|
+
const validatedAddress = (0, import_assert.assertEx)(address ?? this.config.address, () => "Missing address").toLowerCase();
|
|
114
|
+
const provider = await this.getProvider(true, true);
|
|
115
|
+
const block = await provider.getBlockNumber();
|
|
116
|
+
const { beacon, implementation, slots } = await getErc1967SlotStatus(provider, validatedAddress, block);
|
|
117
|
+
const observation = {
|
|
118
|
+
address: validatedAddress,
|
|
119
|
+
beacon,
|
|
120
|
+
block,
|
|
121
|
+
chainId: Number((await provider.getNetwork()).chainId),
|
|
122
|
+
implementation,
|
|
123
|
+
schema: Erc1967StatusSchema,
|
|
124
|
+
slots
|
|
125
|
+
};
|
|
126
|
+
return observation;
|
|
127
|
+
}));
|
|
115
128
|
return observations;
|
|
116
129
|
} catch (ex) {
|
|
117
130
|
const error = ex;
|