@diamondslab/diamonds 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +618 -0
- package/diamonds/README.md +3 -0
- package/dist/core/CallbackManager.d.ts +13 -0
- package/dist/core/CallbackManager.d.ts.map +1 -0
- package/dist/core/CallbackManager.js +95 -0
- package/dist/core/CallbackManager.js.map +1 -0
- package/dist/core/DeploymentManager.d.ts +10 -0
- package/dist/core/DeploymentManager.d.ts.map +1 -0
- package/dist/core/DeploymentManager.js +50 -0
- package/dist/core/DeploymentManager.js.map +1 -0
- package/dist/core/Diamond.d.ts +58 -0
- package/dist/core/Diamond.d.ts.map +1 -0
- package/dist/core/Diamond.js +146 -0
- package/dist/core/Diamond.js.map +1 -0
- package/dist/core/DiamondDeployer.d.ts +10 -0
- package/dist/core/DiamondDeployer.d.ts.map +1 -0
- package/dist/core/DiamondDeployer.js +33 -0
- package/dist/core/DiamondDeployer.js.map +1 -0
- package/dist/core/index.d.ts +5 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +12 -0
- package/dist/core/index.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/repositories/DBDeploymentRepository.d.ts +1 -0
- package/dist/repositories/DBDeploymentRepository.d.ts.map +1 -0
- package/dist/repositories/DBDeploymentRepository.js +20 -0
- package/dist/repositories/DBDeploymentRepository.js.map +1 -0
- package/dist/repositories/DeploymentRepository.d.ts +8 -0
- package/dist/repositories/DeploymentRepository.d.ts.map +1 -0
- package/dist/repositories/DeploymentRepository.js +7 -0
- package/dist/repositories/DeploymentRepository.js.map +1 -0
- package/dist/repositories/FileDeploymentRepository.d.ts +18 -0
- package/dist/repositories/FileDeploymentRepository.d.ts.map +1 -0
- package/dist/repositories/FileDeploymentRepository.js +58 -0
- package/dist/repositories/FileDeploymentRepository.js.map +1 -0
- package/dist/repositories/databaseHandler.d.ts +1 -0
- package/dist/repositories/databaseHandler.d.ts.map +1 -0
- package/dist/repositories/databaseHandler.js +13 -0
- package/dist/repositories/databaseHandler.js.map +1 -0
- package/dist/repositories/index.d.ts +4 -0
- package/dist/repositories/index.d.ts.map +1 -0
- package/dist/repositories/index.js +20 -0
- package/dist/repositories/index.js.map +1 -0
- package/dist/repositories/jsonFileHandler.d.ts +81 -0
- package/dist/repositories/jsonFileHandler.d.ts.map +1 -0
- package/dist/repositories/jsonFileHandler.js +223 -0
- package/dist/repositories/jsonFileHandler.js.map +1 -0
- package/dist/repositories/prismaDBHandler.d.ts +1 -0
- package/dist/repositories/prismaDBHandler.d.ts.map +1 -0
- package/dist/repositories/prismaDBHandler.js +11 -0
- package/dist/repositories/prismaDBHandler.js.map +1 -0
- package/dist/schemas/DeploymentSchema.d.ts +309 -0
- package/dist/schemas/DeploymentSchema.d.ts.map +1 -0
- package/dist/schemas/DeploymentSchema.js +56 -0
- package/dist/schemas/DeploymentSchema.js.map +1 -0
- package/dist/schemas/index.d.ts +2 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +18 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/strategies/BaseDeploymentStrategy.d.ts +41 -0
- package/dist/strategies/BaseDeploymentStrategy.d.ts.map +1 -0
- package/dist/strategies/BaseDeploymentStrategy.js +545 -0
- package/dist/strategies/BaseDeploymentStrategy.js.map +1 -0
- package/dist/strategies/DeploymentStrategy.d.ts +19 -0
- package/dist/strategies/DeploymentStrategy.d.ts.map +1 -0
- package/dist/strategies/DeploymentStrategy.js +3 -0
- package/dist/strategies/DeploymentStrategy.js.map +1 -0
- package/dist/strategies/LocalDeploymentStrategy.d.ts +4 -0
- package/dist/strategies/LocalDeploymentStrategy.d.ts.map +1 -0
- package/dist/strategies/LocalDeploymentStrategy.js +8 -0
- package/dist/strategies/LocalDeploymentStrategy.js.map +1 -0
- package/dist/strategies/OZDefenderDeploymentStrategy.d.ts +62 -0
- package/dist/strategies/OZDefenderDeploymentStrategy.d.ts.map +1 -0
- package/dist/strategies/OZDefenderDeploymentStrategy.js +757 -0
- package/dist/strategies/OZDefenderDeploymentStrategy.js.map +1 -0
- package/dist/strategies/RPCDeploymentStrategy.d.ts +139 -0
- package/dist/strategies/RPCDeploymentStrategy.d.ts.map +1 -0
- package/dist/strategies/RPCDeploymentStrategy.js +710 -0
- package/dist/strategies/RPCDeploymentStrategy.js.map +1 -0
- package/dist/strategies/index.d.ts +6 -0
- package/dist/strategies/index.d.ts.map +1 -0
- package/dist/strategies/index.js +12 -0
- package/dist/strategies/index.js.map +1 -0
- package/dist/types/config.d.ts +26 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +3 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/defender.d.ts +22 -0
- package/dist/types/defender.d.ts.map +1 -0
- package/dist/types/defender.js +3 -0
- package/dist/types/defender.js.map +1 -0
- package/dist/types/deployments.d.ts +71 -0
- package/dist/types/deployments.d.ts.map +1 -0
- package/dist/types/deployments.js +20 -0
- package/dist/types/deployments.js.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +21 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/rpc.d.ts +35 -0
- package/dist/types/rpc.d.ts.map +1 -0
- package/dist/types/rpc.js +3 -0
- package/dist/types/rpc.js.map +1 -0
- package/dist/utils/common.d.ts +20 -0
- package/dist/utils/common.d.ts.map +1 -0
- package/dist/utils/common.js +45 -0
- package/dist/utils/common.js.map +1 -0
- package/dist/utils/configurationResolver.d.ts +30 -0
- package/dist/utils/configurationResolver.d.ts.map +1 -0
- package/dist/utils/configurationResolver.js +151 -0
- package/dist/utils/configurationResolver.js.map +1 -0
- package/dist/utils/contractMapping.d.ts +29 -0
- package/dist/utils/contractMapping.d.ts.map +1 -0
- package/dist/utils/contractMapping.js +224 -0
- package/dist/utils/contractMapping.js.map +1 -0
- package/dist/utils/defenderClients.d.ts +5 -0
- package/dist/utils/defenderClients.d.ts.map +1 -0
- package/dist/utils/defenderClients.js +21 -0
- package/dist/utils/defenderClients.js.map +1 -0
- package/dist/utils/defenderStore.d.ts +14 -0
- package/dist/utils/defenderStore.d.ts.map +1 -0
- package/dist/utils/defenderStore.js +92 -0
- package/dist/utils/defenderStore.js.map +1 -0
- package/dist/utils/diamondAbiGenerator.d.ts +113 -0
- package/dist/utils/diamondAbiGenerator.d.ts.map +1 -0
- package/dist/utils/diamondAbiGenerator.js +415 -0
- package/dist/utils/diamondAbiGenerator.js.map +1 -0
- package/dist/utils/diffDeployedFacets.d.ts +26 -0
- package/dist/utils/diffDeployedFacets.d.ts.map +1 -0
- package/dist/utils/diffDeployedFacets.js +106 -0
- package/dist/utils/diffDeployedFacets.js.map +1 -0
- package/dist/utils/index.d.ts +16 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +35 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/loupe.d.ts +44 -0
- package/dist/utils/loupe.d.ts.map +1 -0
- package/dist/utils/loupe.js +128 -0
- package/dist/utils/loupe.js.map +1 -0
- package/dist/utils/rpcStore.d.ts +36 -0
- package/dist/utils/rpcStore.d.ts.map +1 -0
- package/dist/utils/rpcStore.js +166 -0
- package/dist/utils/rpcStore.js.map +1 -0
- package/dist/utils/signer.d.ts +36 -0
- package/dist/utils/signer.d.ts.map +1 -0
- package/dist/utils/signer.js +91 -0
- package/dist/utils/signer.js.map +1 -0
- package/dist/utils/txlogging.d.ts +13 -0
- package/dist/utils/txlogging.d.ts.map +1 -0
- package/dist/utils/txlogging.js +87 -0
- package/dist/utils/txlogging.js.map +1 -0
- package/dist/utils/workspaceSetup.d.ts +32 -0
- package/dist/utils/workspaceSetup.d.ts.map +1 -0
- package/dist/utils/workspaceSetup.js +311 -0
- package/dist/utils/workspaceSetup.js.map +1 -0
- package/docs/DIAMOND_ABI_CONFIGURATION_SUMMARY.md +40 -0
- package/docs/DIAMOND_ABI_GENERATION.md +220 -0
- package/docs/DIAMOND_ABI_GENERATOR_EXAMPLES.md +1204 -0
- package/docs/DIAMOND_ABI_GENERATOR_IMPLEMENTATION.md +947 -0
- package/docs/DIAMOND_ABI_GENERATOR_QUICK_REFERENCE.md +336 -0
- package/docs/README-DEFENDER.md +394 -0
- package/docs/README_DIAMOND_ABI_GENERATOR.md +303 -0
- package/docs/ROADMAP.md +250 -0
- package/docs/assets/image.png +0 -0
- package/docs/defender-integration.md +451 -0
- package/docs/diamond_module-BaseStrategy_design-v2.uxf +247 -0
- package/docs/diamond_module-BaseStrategy_design.uxf +272 -0
- package/docs/monitoring-troubleshooting.md +556 -0
- package/docs/testing-guide.md +713 -0
- package/examples/Diamond_Config_and_Deployment_examples/diamonds/ProxyDiamond/callbacks/ERC20ProxyFacet.ts +31 -0
- package/examples/Diamond_Config_and_Deployment_examples/diamonds/ProxyDiamond/proxydiamond.config.json +27 -0
- package/examples/Local_Hardhat_Deployer_Script_example/LocalDiamondDeployer.ts +180 -0
- package/examples/OZ_Defender_Deployer_Script_example/OZDiamondDeployer.ts +107 -0
- package/examples/OZ_Defender_Deployer_Script_example/run-oz-deploy.ts +17 -0
- package/examples/Test_examples/ProxyDiamondDeployment.test.ts +202 -0
- package/examples/defender-deployment/.env.example +35 -0
- package/examples/defender-deployment/README.md +415 -0
- package/examples/defender-deployment/contracts/ExampleDiamond.sol +41 -0
- package/examples/defender-deployment/contracts/ExampleFacet1.sol +84 -0
- package/examples/defender-deployment/contracts/ExampleFacet2.sol +104 -0
- package/examples/defender-deployment/contracts/UpgradeFacet.sol +92 -0
- package/examples/defender-deployment/deploy-script.ts +170 -0
- package/examples/defender-deployment/diamond-config.json +36 -0
- package/examples/defender-deployment/upgrade-script.ts +237 -0
- package/examples/hardhat-diamonds-config.example.ts +41 -0
- package/package.json +228 -0
- package/src/core/CallbackManager.ts +70 -0
- package/src/core/DeploymentManager.ts +64 -0
- package/src/core/Diamond.ts +197 -0
- package/src/core/DiamondDeployer.ts +36 -0
- package/src/core/index.ts +4 -0
- package/src/index.ts +5 -0
- package/src/repositories/DBDeploymentRepository.ts +22 -0
- package/src/repositories/DeploymentRepository.ts +12 -0
- package/src/repositories/FileDeploymentRepository.ts +67 -0
- package/src/repositories/databaseHandler.ts +14 -0
- package/src/repositories/index.ts +4 -0
- package/src/repositories/jsonFileHandler.ts +252 -0
- package/src/repositories/prismaDBHandler.ts +10 -0
- package/src/schemas/DeploymentSchema.ts +71 -0
- package/src/schemas/index.ts +1 -0
- package/src/strategies/BaseDeploymentStrategy.ts +649 -0
- package/src/strategies/DeploymentStrategy.ts +25 -0
- package/src/strategies/LocalDeploymentStrategy.ts +5 -0
- package/src/strategies/OZDefenderDeploymentStrategy.ts +849 -0
- package/src/strategies/RPCDeploymentStrategy.ts +881 -0
- package/src/strategies/index.ts +5 -0
- package/src/types/config.ts +34 -0
- package/src/types/defender.ts +24 -0
- package/src/types/deployments.ts +102 -0
- package/src/types/index.ts +4 -0
- package/src/types/rpc.ts +37 -0
- package/src/utils/common.ts +54 -0
- package/src/utils/configurationResolver.ts +141 -0
- package/src/utils/contractMapping.ts +220 -0
- package/src/utils/defenderClients.ts +22 -0
- package/src/utils/defenderStore.ts +62 -0
- package/src/utils/diamondAbiGenerator.ts +523 -0
- package/src/utils/diffDeployedFacets.ts +131 -0
- package/src/utils/index.ts +15 -0
- package/src/utils/loupe.ts +159 -0
- package/src/utils/rpcStore.ts +152 -0
- package/src/utils/signer.ts +93 -0
- package/src/utils/txlogging.ts +97 -0
- package/src/utils/workspaceSetup.ts +315 -0
- package/test/README.md +136 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import '@nomicfoundation/hardhat-ethers';
|
|
2
|
+
import { ContractTransactionResponse, Interface, InterfaceAbi, Provider, Signer, TransactionReceipt } from "ethers";
|
|
3
|
+
/** Optional convenience type for TS consumers (no TypeChain) */
|
|
4
|
+
export interface FacetStruct {
|
|
5
|
+
facetAddress: string;
|
|
6
|
+
functionSelectors: string[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* logDiamondLoupe
|
|
10
|
+
* • pretty‑prints the transaction receipt
|
|
11
|
+
* • decodes the logs emitted by the DiamondLoupeFacet
|
|
12
|
+
* • decodes the logs emitted by the facets that were passed in
|
|
13
|
+
* (e.g. the facets that were added/removed)
|
|
14
|
+
* • prints the decoded events to the console
|
|
15
|
+
* • returns the transaction receipt
|
|
16
|
+
* @param tx The awaited transaction object (e.g. from `contract.fn()`)
|
|
17
|
+
* @param diamondLoupe Address of the diamond proxy
|
|
18
|
+
* @param facetABIs One or more `ethers.Interface` (or plain ABIs) used to decode
|
|
19
|
+
* the `receipt.logs`. Pass the primary contract interface first;
|
|
20
|
+
* additional ABIs (e.g. library or facet events) can follow.
|
|
21
|
+
* Pass an empty array if you don’t want to decode any facet events.
|
|
22
|
+
* (e.g. `[]`)
|
|
23
|
+
* (NB: this is not the same as the diamondLoupe address)
|
|
24
|
+
* @returns The transaction receipt
|
|
25
|
+
*/
|
|
26
|
+
export declare function logDiamondLoupe(tx: ContractTransactionResponse, diamondLoupe: string, facetABIs?: readonly (InterfaceAbi | Interface)[]): Promise<TransactionReceipt>;
|
|
27
|
+
/**
|
|
28
|
+
* Fetch the list of deployed facets from a diamond without relying on
|
|
29
|
+
* TypeChain’s IDiamondLoupe typings.
|
|
30
|
+
* getDeployedFacets – convenience wrapper around DiamondLoupe.facets()
|
|
31
|
+
* • fetches the facet list
|
|
32
|
+
* • pretty‑prints it
|
|
33
|
+
* • (optionally) calls logDiamondLoupe if you pass a receipt
|
|
34
|
+
*
|
|
35
|
+
* @param diamondAddress Address of the diamond proxy
|
|
36
|
+
* @param signerOrProvider Signer (for tx) or provider (for read‑only)
|
|
37
|
+
* @param receiptToDecode Optional transaction receipt to decode
|
|
38
|
+
* (e.g. from a diamondCut() transaction)
|
|
39
|
+
* @returns Array of FacetStruct objects
|
|
40
|
+
* (address + functionSelectors)
|
|
41
|
+
* (see DiamondLoupeFacet.sol)
|
|
42
|
+
*/
|
|
43
|
+
export declare function getDeployedFacets(diamondAddress: string, signerOrProvider?: Signer | Provider, receiptToDecode?: TransactionReceipt, logDeployedFacets?: boolean): Promise<FacetStruct[]>;
|
|
44
|
+
//# sourceMappingURL=loupe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loupe.d.ts","sourceRoot":"","sources":["../../src/utils/loupe.ts"],"names":[],"mappings":"AAAA,OAAO,iCAAiC,CAAC;AAEzC,OAAO,EAAY,2BAA2B,EAAE,SAAS,EAAE,YAAY,EAAuB,QAAQ,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAcnJ,gEAAgE;AAChE,MAAM,WAAW,WAAW;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,EAAE,CAAC;CAC7B;AAKD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,eAAe,CACnC,EAAE,EAAE,2BAA2B,EAC/B,YAAY,EAAE,MAAM,EACpB,SAAS,GAAE,SAAS,CAAC,YAAY,GAAG,SAAS,CAAC,EAAO,GACpD,OAAO,CAAC,kBAAkB,CAAC,CAoD7B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,iBAAiB,CACrC,cAAc,EAAE,MAAM,EACtB,gBAAgB,GAAE,MAAM,GAAG,QAA8B,EACzD,eAAe,CAAC,EAAE,kBAAkB,EACpC,iBAAiB,CAAC,EAAE,OAAO,GAC1B,OAAO,CAAC,WAAW,EAAE,CAAC,CAoCxB"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.logDiamondLoupe = logDiamondLoupe;
|
|
7
|
+
exports.getDeployedFacets = getDeployedFacets;
|
|
8
|
+
require("@nomicfoundation/hardhat-ethers");
|
|
9
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
+
const ethers_1 = require("ethers");
|
|
11
|
+
const hardhat_1 = __importDefault(require("hardhat"));
|
|
12
|
+
const txlogging_1 = require("./txlogging");
|
|
13
|
+
/** ----------------------------------------------------------------
|
|
14
|
+
* Minimal ABI for DiamondLoupeFacet.facets()
|
|
15
|
+
* (tuple[] is encoded exactly the same as the struct array returned
|
|
16
|
+
* by the real contract, so we can decode it safely.)
|
|
17
|
+
* ----------------------------------------------------------------
|
|
18
|
+
*/
|
|
19
|
+
const DIAMOND_LOUPE_ABI = new ethers_1.Interface([
|
|
20
|
+
"function facets() view returns (tuple(address facetAddress, bytes4[] functionSelectors)[])"
|
|
21
|
+
]);
|
|
22
|
+
// -----------------------------------------------------------------------------
|
|
23
|
+
// logDiamondLoupe – decodes *events* that were emitted during a diamondCut()
|
|
24
|
+
// -----------------------------------------------------------------------------
|
|
25
|
+
/**
|
|
26
|
+
* logDiamondLoupe
|
|
27
|
+
* • pretty‑prints the transaction receipt
|
|
28
|
+
* • decodes the logs emitted by the DiamondLoupeFacet
|
|
29
|
+
* • decodes the logs emitted by the facets that were passed in
|
|
30
|
+
* (e.g. the facets that were added/removed)
|
|
31
|
+
* • prints the decoded events to the console
|
|
32
|
+
* • returns the transaction receipt
|
|
33
|
+
* @param tx The awaited transaction object (e.g. from `contract.fn()`)
|
|
34
|
+
* @param diamondLoupe Address of the diamond proxy
|
|
35
|
+
* @param facetABIs One or more `ethers.Interface` (or plain ABIs) used to decode
|
|
36
|
+
* the `receipt.logs`. Pass the primary contract interface first;
|
|
37
|
+
* additional ABIs (e.g. library or facet events) can follow.
|
|
38
|
+
* Pass an empty array if you don’t want to decode any facet events.
|
|
39
|
+
* (e.g. `[]`)
|
|
40
|
+
* (NB: this is not the same as the diamondLoupe address)
|
|
41
|
+
* @returns The transaction receipt
|
|
42
|
+
*/
|
|
43
|
+
async function logDiamondLoupe(tx, diamondLoupe, facetABIs = []) {
|
|
44
|
+
const receipt = await (0, txlogging_1.logTx)(tx, `DiamondLoupe (${diamondLoupe})`, facetABIs.map(abi => abi instanceof ethers_1.Interface ? abi : new ethers_1.Interface(abi)));
|
|
45
|
+
const iface = Array.isArray(facetABIs) && facetABIs.length
|
|
46
|
+
? new ethers_1.Interface(facetABIs.map(i => (i instanceof ethers_1.Interface ? i.fragments : i)).reduce((acc, val) => acc.concat(val), []))
|
|
47
|
+
: undefined;
|
|
48
|
+
console.log(chalk_1.default.cyan("\n📜 Decoded Loupe logs:"));
|
|
49
|
+
if (receipt && receipt.logs) {
|
|
50
|
+
receipt.logs.forEach((log, idx) => {
|
|
51
|
+
if (!iface) {
|
|
52
|
+
console.log(chalk_1.default.dim(` Event[${idx}] – no ABI supplied`));
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
let parsed;
|
|
56
|
+
try {
|
|
57
|
+
const result = iface.parseLog(log);
|
|
58
|
+
if (result !== null) {
|
|
59
|
+
parsed = result;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
/* swallow – this log wasn’t emitted by any of the supplied facets */
|
|
64
|
+
}
|
|
65
|
+
if (parsed) {
|
|
66
|
+
const argsPretty = parsed.args
|
|
67
|
+
.map((arg, i) => `${parsed?.fragment.inputs[i].name}: ${arg}`)
|
|
68
|
+
.join(", ");
|
|
69
|
+
console.log(chalk_1.default.yellowBright(` Event[${idx}]`) +
|
|
70
|
+
chalk_1.default.bold(` ${parsed.name}`) +
|
|
71
|
+
` → ${argsPretty}`);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
console.log(chalk_1.default.dim(` Event[${idx}]`) + ` – unable to decode (topic0 = ${log.topics[0]})`);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
return receipt;
|
|
78
|
+
}
|
|
79
|
+
// Always return the receipt, even if logs are missing
|
|
80
|
+
if (!receipt) {
|
|
81
|
+
throw new Error("Transaction receipt is null");
|
|
82
|
+
}
|
|
83
|
+
return receipt;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Fetch the list of deployed facets from a diamond without relying on
|
|
87
|
+
* TypeChain’s IDiamondLoupe typings.
|
|
88
|
+
* getDeployedFacets – convenience wrapper around DiamondLoupe.facets()
|
|
89
|
+
* • fetches the facet list
|
|
90
|
+
* • pretty‑prints it
|
|
91
|
+
* • (optionally) calls logDiamondLoupe if you pass a receipt
|
|
92
|
+
*
|
|
93
|
+
* @param diamondAddress Address of the diamond proxy
|
|
94
|
+
* @param signerOrProvider Signer (for tx) or provider (for read‑only)
|
|
95
|
+
* @param receiptToDecode Optional transaction receipt to decode
|
|
96
|
+
* (e.g. from a diamondCut() transaction)
|
|
97
|
+
* @returns Array of FacetStruct objects
|
|
98
|
+
* (address + functionSelectors)
|
|
99
|
+
* (see DiamondLoupeFacet.sol)
|
|
100
|
+
*/
|
|
101
|
+
async function getDeployedFacets(diamondAddress, signerOrProvider = hardhat_1.default.ethers.provider, receiptToDecode, logDeployedFacets) {
|
|
102
|
+
// Generic ethers.Contract instance built only from the tiny ABI above
|
|
103
|
+
const loupe = new ethers_1.Contract(diamondAddress, DIAMOND_LOUPE_ABI, signerOrProvider);
|
|
104
|
+
// NB: cast is just to help TS‑users downstream; at runtime this is the raw array
|
|
105
|
+
const facets = (await loupe.facets());
|
|
106
|
+
if (logDeployedFacets === true) {
|
|
107
|
+
console.log(chalk_1.default.magentaBright("\n🔍 Currently deployed facets (via DiamondLoupe):"));
|
|
108
|
+
facets.forEach((f, i) => {
|
|
109
|
+
console.log(chalk_1.default.blueBright(` [${i.toString().padStart(2, "0")}] ${chalk_1.default.bold(f.facetAddress)} – ${f.functionSelectors.length} selector${f.functionSelectors.length === 1 ? "" : "s"}`));
|
|
110
|
+
f.functionSelectors.forEach((s, j) => {
|
|
111
|
+
console.log(` ${j.toString().padStart(2, "0")}: ${s}`);
|
|
112
|
+
});
|
|
113
|
+
console.log();
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
// If the caller supplied a receipt from a recent diamondCut, decode it too
|
|
117
|
+
if (receiptToDecode) {
|
|
118
|
+
await logDiamondLoupe(
|
|
119
|
+
// fabricate a ContractTransaction‑like object so logDiamondLoupe
|
|
120
|
+
// can stay reception‑agnostic
|
|
121
|
+
{
|
|
122
|
+
...receiptToDecode,
|
|
123
|
+
wait: async () => receiptToDecode,
|
|
124
|
+
}, diamondAddress, [loupe.interface]);
|
|
125
|
+
}
|
|
126
|
+
return facets;
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=loupe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loupe.js","sourceRoot":"","sources":["../../src/utils/loupe.ts"],"names":[],"mappings":";;;;;AA2CA,0CAwDC;AAkBD,8CAyCC;AA9JD,2CAAyC;AACzC,kDAA0B;AAC1B,mCAAmJ;AACnJ,sDAA0B;AAC1B,2CAAoC;AAEpC;;;;;GAKG;AACH,MAAM,iBAAiB,GAAG,IAAI,kBAAS,CAAC;IACtC,4FAA4F;CAC7F,CAAC,CAAC;AAQH,gFAAgF;AAChF,8EAA8E;AAC9E,gFAAgF;AAChF;;;;;;;;;;;;;;;;;GAiBG;AACI,KAAK,UAAU,eAAe,CACnC,EAA+B,EAC/B,YAAoB,EACpB,YAAmD,EAAE;IAErD,MAAM,OAAO,GAAG,MAAM,IAAA,iBAAK,EAAC,EAAE,EAAE,iBAAiB,YAAY,GAAG,EAAE,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,YAAY,kBAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,kBAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAE7I,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,MAAM;QACxD,CAAC,CAAC,IAAI,kBAAS,CACb,SAAS,C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AAQ,CAAC,CAAC,iBAAiB,CAAC,MAC/F,YAAY,CAAC,CAAC,iBAAiB,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAC1D,CAAC,CAAC;YACH,CAAC,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE;gBACnD,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YAC7D,CAAC,CAAC,CAAC;YACH,OAAO,CAAC,GAAG,EAAE,CAAC;QAChB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,2EAA2E;IAC3E,IAAI,eAAe,EAAE,CAAC;QACpB,MAAM,eAAe;QACnB,iEAAiE;QACjE,8BAA8B;QAC9B;YACE,GAAG,eAAe;YAClB,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,eAAe;SACQ,EAC3C,cAAc,EACd,CAAC,KAAK,CAAC,SAAS,CAAC,CAClB,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { RPCDeploymentRegistry, RPCStepStatus, RPCStepRecord } from '../types/rpc';
|
|
2
|
+
/**
|
|
3
|
+
* Step-by-step deployment store for RPC-based deployments
|
|
4
|
+
* Similar to DefenderDeploymentStore but for RPC deployments
|
|
5
|
+
*/
|
|
6
|
+
export declare class RPCDeploymentStore {
|
|
7
|
+
private readonly filePath;
|
|
8
|
+
private readonly diamondName;
|
|
9
|
+
private readonly deploymentId;
|
|
10
|
+
constructor(diamondName: string, deploymentId: string, baseDir?: string);
|
|
11
|
+
private loadRegistry;
|
|
12
|
+
private saveRegistry;
|
|
13
|
+
initializeDeployment(network: string, chainId: number, rpcUrl: string, deployerAddress: string): void;
|
|
14
|
+
saveStep(step: RPCStepRecord): void;
|
|
15
|
+
getStep(stepName: string): RPCStepRecord | undefined;
|
|
16
|
+
updateStatus(stepName: string, status: RPCStepStatus, txHash?: string, contractAddress?: string, error?: string): void;
|
|
17
|
+
list(): RPCStepRecord[];
|
|
18
|
+
getRegistry(): RPCDeploymentRegistry;
|
|
19
|
+
isStepCompleted(stepName: string): boolean;
|
|
20
|
+
isStepFailed(stepName: string): boolean;
|
|
21
|
+
getCompletedSteps(): RPCStepRecord[];
|
|
22
|
+
getFailedSteps(): RPCStepRecord[];
|
|
23
|
+
getPendingSteps(): RPCStepRecord[];
|
|
24
|
+
markDeploymentComplete(): void;
|
|
25
|
+
markDeploymentFailed(error: string): void;
|
|
26
|
+
clearFailedSteps(): void;
|
|
27
|
+
getDeploymentSummary(): {
|
|
28
|
+
total: number;
|
|
29
|
+
completed: number;
|
|
30
|
+
failed: number;
|
|
31
|
+
pending: number;
|
|
32
|
+
isComplete: boolean;
|
|
33
|
+
hasFailed: boolean;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=rpcStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpcStore.d.ts","sourceRoot":"","sources":["../../src/utils/rpcStore.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAEnF;;;GAGG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;gBAE1B,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,GAAE,MAAmB;IAQnF,OAAO,CAAC,YAAY;IAiBpB,OAAO,CAAC,YAAY;IAKb,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,IAAI;IASrG,QAAQ,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI;IAWnC,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAIpD,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI;IAatH,IAAI,IAAI,aAAa,EAAE;IAIvB,WAAW,IAAI,qBAAqB;IAIpC,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAK1C,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAKvC,iBAAiB,IAAI,aAAa,EAAE;IAIpC,cAAc,IAAI,aAAa,EAAE;IAIjC,eAAe,IAAI,aAAa,EAAE;IAIlC,sBAAsB,IAAI,IAAI;IAM9B,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAOzC,gBAAgB,IAAI,IAAI;IAMxB,oBAAoB,IAAI;QAC7B,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,OAAO,CAAC;QACpB,SAAS,EAAE,OAAO,CAAC;KACpB;CAeF"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.RPCDeploymentStore = void 0;
|
|
37
|
+
const path_1 = require("path");
|
|
38
|
+
const fs = __importStar(require("fs-extra"));
|
|
39
|
+
/**
|
|
40
|
+
* Step-by-step deployment store for RPC-based deployments
|
|
41
|
+
* Similar to DefenderDeploymentStore but for RPC deployments
|
|
42
|
+
*/
|
|
43
|
+
class RPCDeploymentStore {
|
|
44
|
+
filePath;
|
|
45
|
+
diamondName;
|
|
46
|
+
deploymentId;
|
|
47
|
+
constructor(diamondName, deploymentId, baseDir = 'diamonds') {
|
|
48
|
+
this.diamondName = diamondName;
|
|
49
|
+
this.deploymentId = deploymentId;
|
|
50
|
+
const registryDir = (0, path_1.join)(baseDir, diamondName, 'deployments', 'rpc');
|
|
51
|
+
fs.ensureDirSync(registryDir);
|
|
52
|
+
this.filePath = (0, path_1.join)(registryDir, `${deploymentId}.json`);
|
|
53
|
+
}
|
|
54
|
+
loadRegistry() {
|
|
55
|
+
if (!fs.existsSync(this.filePath)) {
|
|
56
|
+
return {
|
|
57
|
+
diamondName: this.diamondName,
|
|
58
|
+
deploymentId: this.deploymentId,
|
|
59
|
+
network: '',
|
|
60
|
+
chainId: 0,
|
|
61
|
+
rpcUrl: '',
|
|
62
|
+
deployerAddress: '',
|
|
63
|
+
steps: [],
|
|
64
|
+
startedAt: Date.now(),
|
|
65
|
+
lastUpdated: Date.now()
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return fs.readJSONSync(this.filePath);
|
|
69
|
+
}
|
|
70
|
+
saveRegistry(registry) {
|
|
71
|
+
registry.lastUpdated = Date.now();
|
|
72
|
+
fs.writeJSONSync(this.filePath, registry, { spaces: 2 });
|
|
73
|
+
}
|
|
74
|
+
initializeDeployment(network, chainId, rpcUrl, deployerAddress) {
|
|
75
|
+
const registry = this.loadRegistry();
|
|
76
|
+
registry.network = network;
|
|
77
|
+
registry.chainId = chainId;
|
|
78
|
+
registry.rpcUrl = rpcUrl;
|
|
79
|
+
registry.deployerAddress = deployerAddress;
|
|
80
|
+
this.saveRegistry(registry);
|
|
81
|
+
}
|
|
82
|
+
saveStep(step) {
|
|
83
|
+
const registry = this.loadRegistry();
|
|
84
|
+
const existing = registry.steps.find(s => s.stepName === step.stepName);
|
|
85
|
+
if (existing) {
|
|
86
|
+
Object.assign(existing, step);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
registry.steps.push(step);
|
|
90
|
+
}
|
|
91
|
+
this.saveRegistry(registry);
|
|
92
|
+
}
|
|
93
|
+
getStep(stepName) {
|
|
94
|
+
return this.loadRegistry().steps.find(s => s.stepName === stepName);
|
|
95
|
+
}
|
|
96
|
+
updateStatus(stepName, status, txHash, contractAddress, error) {
|
|
97
|
+
const registry = this.loadRegistry();
|
|
98
|
+
const step = registry.steps.find(s => s.stepName === stepName);
|
|
99
|
+
if (step) {
|
|
100
|
+
step.status = status;
|
|
101
|
+
step.timestamp = Date.now();
|
|
102
|
+
if (txHash)
|
|
103
|
+
step.txHash = txHash;
|
|
104
|
+
if (contractAddress)
|
|
105
|
+
step.contractAddress = contractAddress;
|
|
106
|
+
if (error)
|
|
107
|
+
step.error = error;
|
|
108
|
+
this.saveRegistry(registry);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
list() {
|
|
112
|
+
return this.loadRegistry().steps;
|
|
113
|
+
}
|
|
114
|
+
getRegistry() {
|
|
115
|
+
return this.loadRegistry();
|
|
116
|
+
}
|
|
117
|
+
isStepCompleted(stepName) {
|
|
118
|
+
const step = this.getStep(stepName);
|
|
119
|
+
return step?.status === 'completed';
|
|
120
|
+
}
|
|
121
|
+
isStepFailed(stepName) {
|
|
122
|
+
const step = this.getStep(stepName);
|
|
123
|
+
return step?.status === 'failed';
|
|
124
|
+
}
|
|
125
|
+
getCompletedSteps() {
|
|
126
|
+
return this.list().filter(s => s.status === 'completed');
|
|
127
|
+
}
|
|
128
|
+
getFailedSteps() {
|
|
129
|
+
return this.list().filter(s => s.status === 'failed');
|
|
130
|
+
}
|
|
131
|
+
getPendingSteps() {
|
|
132
|
+
return this.list().filter(s => s.status === 'pending' || s.status === 'in_progress');
|
|
133
|
+
}
|
|
134
|
+
markDeploymentComplete() {
|
|
135
|
+
const registry = this.loadRegistry();
|
|
136
|
+
registry.completedAt = Date.now();
|
|
137
|
+
this.saveRegistry(registry);
|
|
138
|
+
}
|
|
139
|
+
markDeploymentFailed(error) {
|
|
140
|
+
const registry = this.loadRegistry();
|
|
141
|
+
registry.failedAt = Date.now();
|
|
142
|
+
registry.lastError = error;
|
|
143
|
+
this.saveRegistry(registry);
|
|
144
|
+
}
|
|
145
|
+
clearFailedSteps() {
|
|
146
|
+
const registry = this.loadRegistry();
|
|
147
|
+
registry.steps = registry.steps.filter(s => s.status !== 'failed');
|
|
148
|
+
this.saveRegistry(registry);
|
|
149
|
+
}
|
|
150
|
+
getDeploymentSummary() {
|
|
151
|
+
const steps = this.list();
|
|
152
|
+
const completed = steps.filter(s => s.status === 'completed').length;
|
|
153
|
+
const failed = steps.filter(s => s.status === 'failed').length;
|
|
154
|
+
const pending = steps.filter(s => s.status === 'pending' || s.status === 'in_progress').length;
|
|
155
|
+
return {
|
|
156
|
+
total: steps.length,
|
|
157
|
+
completed,
|
|
158
|
+
failed,
|
|
159
|
+
pending,
|
|
160
|
+
isComplete: failed === 0 && pending === 0 && completed > 0,
|
|
161
|
+
hasFailed: failed > 0
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
exports.RPCDeploymentStore = RPCDeploymentStore;
|
|
166
|
+
//# sourceMappingURL=rpcStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpcStore.js","sourceRoot":"","sources":["../../src/utils/rpcStore.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA4B;AAC5B,6CAA+B;AAG/B;;;GAGG;AACH,MAAa,kBAAkB;IACZ,QAAQ,CAAS;IACjB,WAAW,CAAS;IACpB,YAAY,CAAS;IAEtC,YAAY,WAAmB,EAAE,YAAoB,EAAE,UAAkB,UAAU;QACjF,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,MAAM,WAAW,GAAG,IAAA,WAAI,EAAC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,KAAK,CAAC,CAAC;QACrE,EAAE,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;QAC9B,IAAI,CAAC,QAAQ,GAAG,IAAA,WAAI,EAAC,WAAW,EAAE,GAAG,YAAY,OAAO,CAAC,CAAC;IAC5D,CAAC;IAEO,YA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AQ,CAAC,CAAC;IAC9B,CAAC;IAEM,gBAAgB;QACrB,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QACrC,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC;QACnE,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC;IAEM,oBAAoB;QAQzB,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAC1B,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,MAAM,CAAC;QACrE,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,MAAM,CAAC;QAC/D,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,SAAS,IAAI,CAAC,CAAC,MAAM,KAAK,aAAa,CAAC,CAAC,MAAM,CAAC;QAE/F,OAAO;YACL,KAAK,EAAE,KAAK,CAAC,MAAM;YACnB,SAAS;YACT,MAAM;YACN,OAAO;YACP,UAAU,EAAE,MAAM,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,IAAI,SAAS,GAAG,CAAC;YAC1D,SAAS,EAAE,MAAM,GAAG,CAAC;SACtB,CAAC;IACJ,CAAC;CACF;AA/ID,gDA+IC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { JsonRpcProvider, Signer } from 'ethers';
|
|
2
|
+
import '@nomicfoundation/hardhat-ethers';
|
|
3
|
+
import { HardhatEthersProvider } from '@nomicfoundation/hardhat-ethers/internal/hardhat-ethers-provider';
|
|
4
|
+
/**
|
|
5
|
+
* Impersonates a signer account. This is primarily used in Hardhat's testing environment
|
|
6
|
+
* to simulate actions from accounts that are not part of the default test accounts.
|
|
7
|
+
*
|
|
8
|
+
* @param signerAddress - The address of the account to impersonate.
|
|
9
|
+
* @returns The impersonated signer object.
|
|
10
|
+
*/
|
|
11
|
+
export declare function impersonateSigner(signerAddress: string, provider: JsonRpcProvider): Promise<Signer>;
|
|
12
|
+
/**
|
|
13
|
+
* Sets the Ether balance for a specified address in the Hardhat testing environment.
|
|
14
|
+
* This is useful for ensuring test accounts have sufficient funds for transactions.
|
|
15
|
+
*
|
|
16
|
+
* @param address - The address to set the Ether balance for.
|
|
17
|
+
* @param amount - The desired balance as a `BigNumber`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function setEtherBalance(address: string, amount: bigint, provider: JsonRpcProvider): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Impersonates the deployer account and funds it to a balance that is rounded to the next highest 100 ETH.
|
|
22
|
+
*
|
|
23
|
+
* @param provider - The ethers provider instance.
|
|
24
|
+
* @param deployerAddress - The address of the deployer account.
|
|
25
|
+
* @param balance - The balance to set for the deployer account (in hex format).
|
|
26
|
+
*/
|
|
27
|
+
export declare function impersonateAndFundSigner(deployerAddress: string, provider: JsonRpcProvider | HardhatEthersProvider): Promise<Signer>;
|
|
28
|
+
/**
|
|
29
|
+
* Updates the owner of the contract at the specified root address for testing purposes.
|
|
30
|
+
* This involves transferring ownership from the current owner to the default signer in the Hardhat environment.
|
|
31
|
+
*
|
|
32
|
+
* @param rootAddress - The address of the root contract (e.g., GeniusOwnershipFacet).
|
|
33
|
+
* @returns The address of the old owner.
|
|
34
|
+
*/
|
|
35
|
+
export declare const updateOwnerForTest: (rootAddress: string, provider: JsonRpcProvider) => Promise<any>;
|
|
36
|
+
//# sourceMappingURL=signer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../src/utils/signer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,iCAAiC,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,kEAAkE,CAAC;AAEzG;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAIzG;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,iBAK/F;AAED;;;;;;GAMG;AACH,wBAAsB,wBAAwB,CAAC,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,GAAG,qBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC,CAgB1I;AAGD;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAAU,aAAa,MAAM,EAAE,UAAU,eAAe,iBA0BtF,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.updateOwnerForTest = void 0;
|
|
7
|
+
exports.impersonateSigner = impersonateSigner;
|
|
8
|
+
exports.setEtherBalance = setEtherBalance;
|
|
9
|
+
exports.impersonateAndFundSigner = impersonateAndFundSigner;
|
|
10
|
+
const hardhat_1 = __importDefault(require("hardhat"));
|
|
11
|
+
const common_1 = require("./common");
|
|
12
|
+
require("@nomicfoundation/hardhat-ethers");
|
|
13
|
+
/**
|
|
14
|
+
* Impersonates a signer account. This is primarily used in Hardhat's testing environment
|
|
15
|
+
* to simulate actions from accounts that are not part of the default test accounts.
|
|
16
|
+
*
|
|
17
|
+
* @param signerAddress - The address of the account to impersonate.
|
|
18
|
+
* @returns The impersonated signer object.
|
|
19
|
+
*/
|
|
20
|
+
async function impersonateSigner(signerAddress, provider) {
|
|
21
|
+
// Request Hardhat to impersonate the account at the specified address
|
|
22
|
+
await provider.send("hardhat_impersonateAccount", [signerAddress]);
|
|
23
|
+
return provider.getSigner(signerAddress); // Return the impersonated signer
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Sets the Ether balance for a specified address in the Hardhat testing environment.
|
|
27
|
+
* This is useful for ensuring test accounts have sufficient funds for transactions.
|
|
28
|
+
*
|
|
29
|
+
* @param address - The address to set the Ether balance for.
|
|
30
|
+
* @param amount - The desired balance as a `BigNumber`.
|
|
31
|
+
*/
|
|
32
|
+
async function setEtherBalance(address, amount, provider) {
|
|
33
|
+
await provider.send('hardhat_setBalance', [
|
|
34
|
+
address, // Address to modify the balance of
|
|
35
|
+
'0x' + amount.toString(16), // Amount to set, formatted as a hex string
|
|
36
|
+
]);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Impersonates the deployer account and funds it to a balance that is rounded to the next highest 100 ETH.
|
|
40
|
+
*
|
|
41
|
+
* @param provider - The ethers provider instance.
|
|
42
|
+
* @param deployerAddress - The address of the deployer account.
|
|
43
|
+
* @param balance - The balance to set for the deployer account (in hex format).
|
|
44
|
+
*/
|
|
45
|
+
async function impersonateAndFundSigner(deployerAddress, provider) {
|
|
46
|
+
try {
|
|
47
|
+
await provider.send('hardhat_impersonateAccount', [deployerAddress]);
|
|
48
|
+
const signer = provider.getSigner(deployerAddress);
|
|
49
|
+
// Fund the account
|
|
50
|
+
await provider.send('hardhat_setBalance', [deployerAddress, '0x56BC75E2D63100000']);
|
|
51
|
+
return signer;
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
if (error instanceof Error) {
|
|
55
|
+
console.error(`Impersonation and funding failed for ${deployerAddress}: ${error.message}`);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
console.error(`Impersonation and funding failed for ${deployerAddress}: ${String(error)}`);
|
|
59
|
+
}
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Updates the owner of the contract at the specified root address for testing purposes.
|
|
65
|
+
* This involves transferring ownership from the current owner to the default signer in the Hardhat environment.
|
|
66
|
+
*
|
|
67
|
+
* @param rootAddress - The address of the root contract (e.g., GeniusOwnershipFacet).
|
|
68
|
+
* @returns The address of the old owner.
|
|
69
|
+
*/
|
|
70
|
+
const updateOwnerForTest = async (rootAddress, provider) => {
|
|
71
|
+
// Retrieve the current signer in the Hardhat environment
|
|
72
|
+
const curOwner = (await hardhat_1.default.ethers.getSigners())[0];
|
|
73
|
+
// Get a reference to the GeniusOwnershipFacet contract at the specified root address
|
|
74
|
+
const ownership = await hardhat_1.default.ethers.getContractAt('GeniusOwnershipFacet', rootAddress);
|
|
75
|
+
// Retrieve the current owner of the contract
|
|
76
|
+
const oldOwnerAddress = await ownership.owner();
|
|
77
|
+
// Impersonate the old owner
|
|
78
|
+
const oldOwner = await impersonateSigner(oldOwnerAddress, provider);
|
|
79
|
+
// If the old owner is not the current signer, transfer ownership to the current signer
|
|
80
|
+
if (oldOwnerAddress !== curOwner.address) {
|
|
81
|
+
debuglog(`Transferring ownership from ${oldOwnerAddress}`);
|
|
82
|
+
// Ensure the old owner has enough Ether to perform the ownership transfer
|
|
83
|
+
await setEtherBalance(oldOwnerAddress, (0, common_1.toWei)(10), provider);
|
|
84
|
+
await ownership.connect(await oldOwner).transferOwnership(curOwner.address);
|
|
85
|
+
await ownership.connect(oldOwner).transferOwnership(curOwner.address);
|
|
86
|
+
}
|
|
87
|
+
// Return the address of the old owner
|
|
88
|
+
return oldOwnerAddress;
|
|
89
|
+
};
|
|
90
|
+
exports.updateOwnerForTest = updateOwnerForTest;
|
|
91
|
+
//# sourceMappingURL=signer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signer.js","sourceRoot":"","sources":["../../src/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ponse, Interface, InterfaceAbi, TransactionReceipt } from "ethers";
|
|
3
|
+
/**
|
|
4
|
+
* Pretty‑prints a transaction receipt **and** decodes its logs.
|
|
5
|
+
*
|
|
6
|
+
* @param tx The awaited transaction object (e.g. from `contract.fn()`)
|
|
7
|
+
* @param description Optional label that will be shown in the console header.
|
|
8
|
+
* @param interfaces One or more `ethers.Interface` (or plain ABIs) used to decode
|
|
9
|
+
* the `receipt.logs`. Pass the primary contract interface first;
|
|
10
|
+
* additional ABIs (e.g. library or facet events) can follow.
|
|
11
|
+
*/
|
|
12
|
+
export declare function logTx(tx: ContractTransactionResponse, description?: string, interfaces?: (Interface | InterfaceAbi)[]): Promise<TransactionReceipt>;
|
|
13
|
+
//# sourceMappingURL=txlogging.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"txlogging.d.ts","sourceRoot":"","sources":["../../src/utils/txlogging.ts"],"names":[],"mappings":"AAIA,OAAO,iCAAiC,CAAC;AAEzC,OAAO,EAAE,2BAA2B,EAAE,SAAS,EAAE,YAAY,EAAuB,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAIvH;;;;;;;;GAQG;AACH,wBAAsB,KAAK,CACzB,EAAE,EAAE,2BAA2B,EAC/B,WAAW,SAAK,EAChB,UAAU,GAAE,CAAC,SAAS,GAAG,YAAY,CAAC,EAAO,GAE5C,OAAO,CAAC,kBAAkB,CAAC,CAwE7B"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.logTx = logTx;
|
|
7
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
8
|
+
// txLogging.ts
|
|
9
|
+
// Extra helpers for inspecting diamond‑cut transactions
|
|
10
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
11
|
+
require("@nomicfoundation/hardhat-ethers");
|
|
12
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
13
|
+
const ethers_1 = require("ethers");
|
|
14
|
+
const hardhat_1 = __importDefault(require("hardhat"));
|
|
15
|
+
/**
|
|
16
|
+
* Pretty‑prints a transaction receipt **and** decodes its logs.
|
|
17
|
+
*
|
|
18
|
+
* @param tx The awaited transaction object (e.g. from `contract.fn()`)
|
|
19
|
+
* @param description Optional label that will be shown in the console header.
|
|
20
|
+
* @param interfaces One or more `ethers.Interface` (or plain ABIs) used to decode
|
|
21
|
+
* the `receipt.logs`. Pass the primary contract interface first;
|
|
22
|
+
* additional ABIs (e.g. library or facet events) can follow.
|
|
23
|
+
*/
|
|
24
|
+
async function logTx(tx, description = "", interfaces = []) {
|
|
25
|
+
// normalise incoming interfaces => ethers.Interface
|
|
26
|
+
const decoders = interfaces.map((i) => i instanceof ethers_1.Interface ? i : new ethers_1.Interface(i));
|
|
27
|
+
const receipt = await tx.wait();
|
|
28
|
+
if (!receipt) {
|
|
29
|
+
throw new Error("Transaction receipt is null");
|
|
30
|
+
}
|
|
31
|
+
/* --------------------------- basic tx statistics -------------------------- */
|
|
32
|
+
console.log(chalk_1.default.green(`\n⛓️ Transaction Details${description ? ` – ${description}` : ""}`));
|
|
33
|
+
console.table({
|
|
34
|
+
Hash: tx.hash,
|
|
35
|
+
Status: receipt.status === 1 ? "Success" : "Failed",
|
|
36
|
+
Block: receipt.blockNumber,
|
|
37
|
+
From: receipt.from,
|
|
38
|
+
To: receipt.to,
|
|
39
|
+
"Tx Index": receipt.transactionIndex ?? receipt.index ?? "N/A",
|
|
40
|
+
"Gas Used": receipt.gasUsed.toString(),
|
|
41
|
+
"Cumulative Gas": receipt.cumulativeGasUsed.toString(),
|
|
42
|
+
"Gas Price": receipt.gasPrice?.toString() ?? "N/A",
|
|
43
|
+
"Block Hash": receipt.blockHash,
|
|
44
|
+
"Confirmations": receipt.confirmations,
|
|
45
|
+
"Timestamp": receipt.blockNumber
|
|
46
|
+
? new Date(((await tx.wait().then(() => hardhat_1.default.ethers.provider.getBlock(receipt.blockNumber))) ?? { timestamp: 0 }).timestamp * 1000).toLocaleString()
|
|
47
|
+
: "N/A",
|
|
48
|
+
"Created Contract": receipt.contractAddress ?? "N/A",
|
|
49
|
+
"Created By": receipt.from,
|
|
50
|
+
Events: receipt.logs.length,
|
|
51
|
+
});
|
|
52
|
+
/* ----------------------------- decode events ------------------------------ */
|
|
53
|
+
if (receipt.logs.length === 0)
|
|
54
|
+
return receipt;
|
|
55
|
+
console.log(chalk_1.default.cyan("\n📜 Decoded events:"));
|
|
56
|
+
receipt.logs.forEach((log, idx) => {
|
|
57
|
+
let parsed;
|
|
58
|
+
for (const iface of decoders) {
|
|
59
|
+
try {
|
|
60
|
+
const result = iface.parseLog(log);
|
|
61
|
+
if (result !== null) {
|
|
62
|
+
parsed = result;
|
|
63
|
+
break; // stop at first successful decoder
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
catch (_) {
|
|
67
|
+
/* ignore and try next */
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (parsed) {
|
|
71
|
+
const argsPretty = parsed.args
|
|
72
|
+
.map((arg, i) => {
|
|
73
|
+
const key = parsed?.fragment.inputs[i].name;
|
|
74
|
+
return `${key ? key + ": " : ""}${arg}`;
|
|
75
|
+
})
|
|
76
|
+
.join(", ");
|
|
77
|
+
console.log(chalk_1.default.yellowBright(` Event[${idx}]`) +
|
|
78
|
+
chalk_1.default.bold(` ${parsed.name}`) +
|
|
79
|
+
` → ${argsPretty}`);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
console.log(chalk_1.default.dim(` Event[${idx}]`) + ` – unable to decode (topic0 = ${log.topics[0]})`);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
return receipt;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=txlogging.js.map
|