@diamondslab/diamonds 1.3.2 → 1.4.1
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/CHANGELOG.md +43 -0
- package/LICENSE +21 -0
- package/README.md +214 -369
- package/dist/cli/diamond-abi-cli.d.ts +3 -0
- package/dist/cli/diamond-abi-cli.d.ts.map +1 -0
- package/dist/cli/diamond-abi-cli.js +377 -0
- package/dist/cli/diamond-abi-cli.js.map +1 -0
- package/dist/resolution/index.d.ts +2 -0
- package/dist/resolution/index.d.ts.map +1 -0
- package/dist/resolution/index.js +18 -0
- package/dist/resolution/index.js.map +1 -0
- package/dist/resolution/selectorResolution.d.ts +65 -0
- package/dist/resolution/selectorResolution.d.ts.map +1 -0
- package/dist/resolution/selectorResolution.js +170 -0
- package/dist/resolution/selectorResolution.js.map +1 -0
- package/dist/strategies/BaseDeploymentStrategy.d.ts.map +1 -1
- package/dist/strategies/BaseDeploymentStrategy.js +15 -156
- package/dist/strategies/BaseDeploymentStrategy.js.map +1 -1
- package/dist/strategies/OZDefenderDeploymentStrategy.d.ts +2 -2
- package/dist/strategies/OZDefenderDeploymentStrategy.d.ts.map +1 -1
- package/dist/strategies/OZDefenderDeploymentStrategy.js +12 -2
- package/dist/strategies/OZDefenderDeploymentStrategy.js.map +1 -1
- package/dist/utils/common.d.ts +1 -1
- package/dist/utils/common.d.ts.map +1 -1
- package/dist/utils/common.js.map +1 -1
- package/dist/utils/defenderClients.d.ts +2 -4
- package/dist/utils/defenderClients.d.ts.map +1 -1
- package/dist/utils/defenderClients.js +36 -15
- package/dist/utils/defenderClients.js.map +1 -1
- package/dist/utils/signer.d.ts.map +1 -1
- package/dist/utils/signer.js +11 -2
- package/dist/utils/signer.js.map +1 -1
- package/package.json +15 -9
package/dist/utils/common.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "@nomicfoundation/hardhat-ethers";
|
|
2
2
|
import { Interface } from "ethers";
|
|
3
|
-
import { CreateProposalRequest } from "@openzeppelin/defender-sdk-proposal-client";
|
|
3
|
+
import type { CreateProposalRequest } from "@openzeppelin/defender-sdk-proposal-client";
|
|
4
4
|
import { DeployedDiamondData } from "../schemas";
|
|
5
5
|
declare global {
|
|
6
6
|
export var debuglog: debug.Debugger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/utils/common.ts"],"names":[],"mappings":"AACA,OAAO,iCAAiC,CAAC;AAEzC,OAAO,EAAsB,SAAS,EAAoD,MAAM,QAAQ,CAAC;AACzG,OAAO,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/utils/common.ts"],"names":[],"mappings":"AACA,OAAO,iCAAiC,CAAC;AAEzC,OAAO,EAAsB,SAAS,EAAoD,MAAM,QAAQ,CAAC;AACzG,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AAGxF,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,CAAC,MAAM,CAAC;IACb,MAAM,CAAC,IAAI,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC;CACrC;AAKD,eAAO,MAAM,QAAQ,0BAAkB,CAAC;AAExC,eAAO,MAAM,IAAI,GAAI,OAAO,MAAM,GAAG,MAAM,GAAG,MAAM,WAAkB,CAAC;AACvE,eAAO,MAAM,aAAa,QAAU,CAAC;AACrC,eAAO,MAAM,aAAa,QAAmB,CAAC;AAE9C,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAEpD;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAClC,OAAO,EAAE,qBAAqB,CAAC,SAAS,C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mB,EAAE,WAAmB,EAAE,OAAe;IAC9E,MAAM,GAAG,GAAG,GAAG,WAAW,CAAC,WAAW,EAAE,IAAI,WAAW,IAAI,OAAO,EAAE,CAAC;IACrE,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAgB,0BAA0B,CAAC,YAAiC;IAC1E,MAAM,UAAU,GAAgB,EAAE,CAAC;IAEnC,KAAK,MAAM,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,cAAc,IAAI,EAAE,CAAC,EAAE,CAAC;QACvE,IAAI,CAAC;YACH,MAAM,QAAQ,GAAa,iBAAG,CAAC,SAAS,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;YACrE,UAAU,CAAC,IAAI,CAAC,IAAI,kBAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;QAC/C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,IAAI,CAAC,wCAAwC,SAAS,GAAG,EAAG,GAAa,CAAC,OAAO,CAAC,CAAC;QAC7F,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["import hre from 'hardhat';\nimport \"@nomicfoundation/hardhat-ethers\";\nimport { debug } from 'debug';\nimport { TransactionReceipt, Interface, Fragment, ContractInterface, ContractTransaction } from \"ethers\";\nimport { CreateProposalRequest } from \"@openzeppelin/defender-sdk-proposal-client\";\nimport chalk from 'chalk';\nimport { Artifact } from \"hardhat/types\";\nimport { DeployedDiamondData } from \"../schemas\";\n\ndeclare global {\n export var debuglog: debug.Debugger;\n}\n\nglobal.debuglog = debug('UnitTest:log');\nglobal.debuglog.color = '158';\n\nexport const debuglog = global.debuglog;\n\nexport const toBN = (value: string | number | bigint) => BigInt(value);\nexport const GNUS_TOKEN_ID = toBN(0);\nexport const XMPL_TOKEN_ID = toBN(1234567890);\n\nexport function toWei(value: number | string): bigint {\n return hre.ethers.parseEther(value.toString());\n}\n\nexport function getSighash(funcSig: string): string {\n return new Interface([`function ${funcSig}`]).getFunction(funcSig.split('(')[0])?.selector || '';\n}\n\nexport interface IDefenderViaInfo {\n via: CreateProposalRequest['via'],\n viaType: CreateProposalRequest['viaType'];\n}\n\nexport function cutKey(diamondName: string, networkName: string, chainId: string): string {\n const key = `${diamondName.toLowerCase()}-${networkName}-${chainId}`;\n return key;\n}\n\nexport function getDeployedFacetInterfaces(deployedInfo: DeployedDiamondData): Interface[] {\n const interfaces: Interface[] = [];\n\n for (const facetName of Object.keys(deployedInfo.DeployedFacets || {})) {\n try {\n const artifact: Artifact = hre.artifacts.readArtifactSync(facetName);\n interfaces.push(new Interface(artifact.abi));\n } catch (err) {\n console.warn(`⚠️ Could not load artifact for facet ${facetName}:`, (err as Error).message);\n }\n }\n\n return interfaces;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/utils/common.ts"],"names":[],"mappings":";;;;;;AAsBA,sBAEC;AAED,gCAEC;AAOD,wBAGC;AAED,gEAaC;AArDD,sDAA0B;AAC1B,2CAAyC;AACzC,iCAA8B;AAC9B,mCAAyG;AAUzG,MAAM,CAAC,QAAQ,GAAG,IAAA,aAAK,EAAC,cAAc,CAAC,CAAC;AACxC,MAAM,CAAC,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAC;AAEjB,QAAA,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;AAEjC,MAAM,IAAI,GAAG,CAAC,KAA+B,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAA1D,QAAA,IAAI,QAAsD;AAC1D,QAAA,aAAa,GAAG,IAAA,YAAI,EAAC,CAAC,CAAC,CAAC;AACxB,QAAA,aAAa,GAAG,IAAA,YAAI,EAAC,UAAU,CAAC,CAAC;AAE9C,SAAgB,KAAK,CAAC,KAAsB;IAC1C,OAAO,iBAAG,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;AACjD,CAAC;AAED,SAAgB,UAAU,CAAC,OAAe;IACxC,OAAO,IAAI,kBAAS,CAAC,CAAC,YAAY,OAAO,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,IAAI,EAAE,CAAC;AACnG,CAAC;AAOD,SAAgB,MAAM,CAAC,WAAmB,EAAE,WAAmB,EAAE,OAAe;IAC9E,MAAM,GAAG,GAAG,GAAG,WAAW,CAAC,WAAW,EAAE,IAAI,WAAW,IAAI,OAAO,EAAE,CAAC;IACrE,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAgB,0BAA0B,CAAC,YAAiC;IAC1E,MAAM,UAAU,GAAgB,EAAE,CAAC;IAEnC,KAAK,MAAM,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,cAAc,IAAI,EAAE,CAAC,EAAE,CAAC;QACvE,IAAI,CAAC;YACH,MAAM,QAAQ,GAAa,iBAAG,CAAC,SAAS,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;YACrE,UAAU,CAAC,IAAI,CAAC,IAAI,kBAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;QAC/C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,IAAI,CAAC,wCAAwC,SAAS,GAAG,EAAG,GAAa,CAAC,OAAO,CAAC,CAAC;QAC7F,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["import hre from 'hardhat';\nimport \"@nomicfoundation/hardhat-ethers\";\nimport { debug } from 'debug';\nimport { TransactionReceipt, Interface, Fragment, ContractInterface, ContractTransaction } from \"ethers\";\nimport type { CreateProposalRequest } from \"@openzeppelin/defender-sdk-proposal-client\";\nimport chalk from 'chalk';\nimport { Artifact } from \"hardhat/types\";\nimport { DeployedDiamondData } from \"../schemas\";\n\ndeclare global {\n export var debuglog: debug.Debugger;\n}\n\nglobal.debuglog = debug('UnitTest:log');\nglobal.debuglog.color = '158';\n\nexport const debuglog = global.debuglog;\n\nexport const toBN = (value: string | number | bigint) => BigInt(value);\nexport const GNUS_TOKEN_ID = toBN(0);\nexport const XMPL_TOKEN_ID = toBN(1234567890);\n\nexport function toWei(value: number | string): bigint {\n return hre.ethers.parseEther(value.toString());\n}\n\nexport function getSighash(funcSig: string): string {\n return new Interface([`function ${funcSig}`]).getFunction(funcSig.split('(')[0])?.selector || '';\n}\n\nexport interface IDefenderViaInfo {\n via: CreateProposalRequest['via'],\n viaType: CreateProposalRequest['viaType'];\n}\n\nexport function cutKey(diamondName: string, networkName: string, chainId: string): string {\n const key = `${diamondName.toLowerCase()}-${networkName}-${chainId}`;\n return key;\n}\n\nexport function getDeployedFacetInterfaces(deployedInfo: DeployedDiamondData): Interface[] {\n const interfaces: Interface[] = [];\n\n for (const facetName of Object.keys(deployedInfo.DeployedFacets || {})) {\n try {\n const artifact: Artifact = hre.artifacts.readArtifactSync(facetName);\n interfaces.push(new Interface(artifact.abi));\n } catch (err) {\n console.warn(`⚠️ Could not load artifact for facet ${facetName}:`, (err as Error).message);\n }\n }\n\n return interfaces;\n}\n"]}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare const adminClient: Defender | null;
|
|
4
|
-
export declare const deployClient: DeployClient | null;
|
|
1
|
+
declare const adminClient: unknown, deployClient: unknown;
|
|
2
|
+
export { adminClient, deployClient };
|
|
5
3
|
//# sourceMappingURL=defenderClients.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defenderClients.d.ts","sourceRoot":"","sources":["../../src/utils/defenderClients.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"defenderClients.d.ts","sourceRoot":"","sources":["../../src/utils/defenderClients.ts"],"names":[],"mappings":"AAwCA,QAAA,MAAQ,WAAW,WAAE,YAAY,SAA4B,CAAC;AAE9D,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -1,21 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// src/utils/defenderClients.ts
|
|
3
|
+
//
|
|
4
|
+
// Client singletons for the (deprecated) OpenZeppelin Defender deployment path.
|
|
5
|
+
// This module is re-exported by the package barrel (utils/index), so importing ANY
|
|
6
|
+
// part of @diamondslab/diamonds loads it. It must therefore never crash a consumer
|
|
7
|
+
// that doesn't use Defender:
|
|
8
|
+
// - the .env load is guarded (a consumer need not have a .env file), and
|
|
9
|
+
// - the @openzeppelin/defender-sdk packages are lazily required only when Defender
|
|
10
|
+
// credentials are actually present (they are optional/dev-only, not a hard
|
|
11
|
+
// runtime dependency of this package).
|
|
12
|
+
// Without credentials the clients are null, exactly as before.
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
14
|
exports.deployClient = exports.adminClient = void 0;
|
|
4
|
-
//
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
15
|
+
// Optional: load environment variables from a local .env if one exists. Never throw.
|
|
16
|
+
try {
|
|
17
|
+
process.loadEnvFile('.env');
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
/* .env is optional — absent in library consumers and CI */
|
|
21
|
+
}
|
|
9
22
|
const { DEFENDER_API_KEY, DEFENDER_API_SECRET } = process.env;
|
|
10
|
-
|
|
11
|
-
|
|
23
|
+
function createDefenderClients() {
|
|
24
|
+
if (!DEFENDER_API_KEY || !DEFENDER_API_SECRET) {
|
|
25
|
+
console.warn('Warning: Missing Defender credentials in environment. Some functionality will be limited.');
|
|
26
|
+
return { adminClient: null, deployClient: null };
|
|
27
|
+
}
|
|
28
|
+
// Lazily require the deprecated Defender SDK so it is not a hard dependency for
|
|
29
|
+
// consumers that never use the OZDefender strategy.
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
31
|
+
const { Defender } = require('@openzeppelin/defender-sdk');
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
33
|
+
const { DeployClient } = require('@openzeppelin/defender-sdk-deploy-client');
|
|
34
|
+
return {
|
|
35
|
+
adminClient: new Defender({ apiKey: DEFENDER_API_KEY, apiSecret: DEFENDER_API_SECRET }),
|
|
36
|
+
deployClient: new DeployClient({ apiKey: DEFENDER_API_KEY, apiSecret: DEFENDER_API_SECRET }),
|
|
37
|
+
};
|
|
12
38
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}) : null;
|
|
17
|
-
exports.deployClient = DEFENDER_API_KEY && DEFENDER_API_SECRET ? new defender_sdk_deploy_client_1.DeployClient({
|
|
18
|
-
apiKey: DEFENDER_API_KEY,
|
|
19
|
-
apiSecret: DEFENDER_API_SECRET,
|
|
20
|
-
}) : null;
|
|
39
|
+
const { adminClient, deployClient } = createDefenderClients();
|
|
40
|
+
exports.adminClient = adminClient;
|
|
41
|
+
exports.deployClient = deployClient;
|
|
21
42
|
//# sourceMappingURL=defenderClients.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defenderClients.js","sourceRoot":"","sources":["../../src/utils/defenderClients.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"defenderClients.js","sourceRoot":"","sources":["../../src/utils/defenderClients.ts"],"names":[],"mappings":";AAAA,+BAA+B;AAC/B,EAAE;AACF,gFAAgF;AAChF,mFAAmF;AACnF,mFAAmF;AACnF,6BAA6B;AAC7B,2EAA2E;AAC3E,qFAAqF;AACrF,+EAA+E;AAC/E,2CAA2C;AAC3C,+DAA+D;;;AAE/D,qFAAqF;AACrF,IAAI,CAAC;IACH,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;AAC9B,CAAC;AAAC,MAAM,CAAC;IACP,2DAA2D;AAC7D,CAAC;AAED,MAAM,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AAE9D,SAAS,qBAAqB;IAC5B,IAAI,CAAC,gBAAgB,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAC9C,OAAO,CAAC,IAAI,CACV,2FAA2F,CAC5F,CAAC;QACF,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;IACnD,CAAC;IACD,gFAAgF;IAChF,oDAAoD;IACpD,8DAA8D;IAC9D,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;IAC3D,8DAA8D;IAC9D,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,0CAA0C,CAAC,CAAC;IAC7E,OAAO;QACL,WAAW,EAAE,IAAI,QAAQ,CAAC,EAAE,MAAM,EAAE,gBAAgB,EAAE,SAAS,EAAE,mBAAmB,EAAE,CAAC;QACvF,YAAY,EAAE,IAAI,YAAY,CAAC,EAAE,MAAM,EAAE,gBAAgB,EAAE,SAAS,EAAE,mBAAmB,EAAE,CAAC;KAC7F,CAAC;AACJ,CAAC;AAED,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,GAAG,qBAAqB,EAAE,CAAC;AAErD,kCAAW;AAAE,oCAAY","sourcesContent":["// src/utils/defenderClients.ts\n//\n// Client singletons for the (deprecated) OpenZeppelin Defender deployment path.\n// This module is re-exported by the package barrel (utils/index), so importing ANY\n// part of @diamondslab/diamonds loads it. It must therefore never crash a consumer\n// that doesn't use Defender:\n// - the .env load is guarded (a consumer need not have a .env file), and\n// - the @openzeppelin/defender-sdk packages are lazily required only when Defender\n// credentials are actually present (they are optional/dev-only, not a hard\n// runtime dependency of this package).\n// Without credentials the clients are null, exactly as before.\n\n// Optional: load environment variables from a local .env if one exists. Never throw.\ntry {\n process.loadEnvFile('.env');\n} catch {\n /* .env is optional — absent in library consumers and CI */\n}\n\nconst { DEFENDER_API_KEY, DEFENDER_API_SECRET } = process.env;\n\nfunction createDefenderClients(): { adminClient: unknown; deployClient: unknown } {\n if (!DEFENDER_API_KEY || !DEFENDER_API_SECRET) {\n console.warn(\n 'Warning: Missing Defender credentials in environment. Some functionality will be limited.',\n );\n return { adminClient: null, deployClient: null };\n }\n // Lazily require the deprecated Defender SDK so it is not a hard dependency for\n // consumers that never use the OZDefender strategy.\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { Defender } = require('@openzeppelin/defender-sdk');\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { DeployClient } = require('@openzeppelin/defender-sdk-deploy-client');\n return {\n adminClient: new Defender({ apiKey: DEFENDER_API_KEY, apiSecret: DEFENDER_API_SECRET }),\n deployClient: new DeployClient({ apiKey: DEFENDER_API_KEY, apiSecret: DEFENDER_API_SECRET }),\n };\n}\n\nconst { adminClient, deployClient } = createDefenderClients();\n\nexport { adminClient, deployClient };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../src/utils/signer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../src/utils/signer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAiB,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChE,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,CAOzG;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,CAsB1I;AAGD;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAAU,aAAa,MAAM,EAAE,UAAU,eAAe,iBA0BtF,CAAC"}
|
package/dist/utils/signer.js
CHANGED
|
@@ -9,6 +9,7 @@ exports.setEtherBalance = setEtherBalance;
|
|
|
9
9
|
exports.impersonateAndFundSigner = impersonateAndFundSigner;
|
|
10
10
|
const hardhat_1 = __importDefault(require("hardhat"));
|
|
11
11
|
const common_1 = require("./common");
|
|
12
|
+
const ethers_1 = require("ethers");
|
|
12
13
|
require("@nomicfoundation/hardhat-ethers");
|
|
13
14
|
/**
|
|
14
15
|
* Impersonates a signer account. This is primarily used in Hardhat's testing environment
|
|
@@ -20,7 +21,10 @@ require("@nomicfoundation/hardhat-ethers");
|
|
|
20
21
|
async function impersonateSigner(signerAddress, provider) {
|
|
21
22
|
// Request Hardhat to impersonate the account at the specified address
|
|
22
23
|
await provider.send("hardhat_impersonateAccount", [signerAddress]);
|
|
23
|
-
|
|
24
|
+
// Construct the signer directly. ethers v6 `provider.getSigner(addr)` validates the
|
|
25
|
+
// address against `eth_accounts` and throws "invalid account" for impersonated accounts
|
|
26
|
+
// (impersonation does NOT add the account to `eth_accounts`).
|
|
27
|
+
return new ethers_1.JsonRpcSigner(provider, signerAddress); // Return the impersonated signer
|
|
24
28
|
}
|
|
25
29
|
/**
|
|
26
30
|
* Sets the Ether balance for a specified address in the Hardhat testing environment.
|
|
@@ -45,7 +49,12 @@ async function setEtherBalance(address, amount, provider) {
|
|
|
45
49
|
async function impersonateAndFundSigner(deployerAddress, provider) {
|
|
46
50
|
try {
|
|
47
51
|
await provider.send('hardhat_impersonateAccount', [deployerAddress]);
|
|
48
|
-
|
|
52
|
+
// For an ethers JsonRpcProvider, construct the signer directly: ethers v6
|
|
53
|
+
// `getSigner(addr)` validates against `eth_accounts` and throws "invalid account"
|
|
54
|
+
// for impersonated accounts. HardhatEthersProvider has no such issue, so keep its path.
|
|
55
|
+
const signer = provider instanceof ethers_1.JsonRpcProvider
|
|
56
|
+
? new ethers_1.JsonRpcSigner(provider, deployerAddress)
|
|
57
|
+
: await provider.getSigner(deployerAddress);
|
|
49
58
|
// Fund the account
|
|
50
59
|
await provider.send('hardhat_setBalance', [deployerAddress, '0x56BC75E2D63100000']);
|
|
51
60
|
return signer;
|
package/dist/utils/signer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signer.js","sourceRoot":"","sources":["../../src/utils/signer.ts"],"names":[],"mappings":";;;;;;AAaA,
|
|
1
|
+
{"version":3,"file":"signer.js","sourceRoot":"","sources":["../../src/utils/signer.ts"],"names":[],"mappings":";;;;;;AAaA,8CAOC;AASD,0CAKC;AASD,4DAsBC;AAjED,sDAA0B;AAC1B,qCAAiC;AACjC,mCAAgE;AAChE,2CAAyC;AAGzC;;;;;;GAMG;AACI,KAAK,UAAU,iBAAiB,CAAC,aAAqB,EAAE,QAAyB;IACtF,sEAAsE;IACtE,MAAM,QAAQ,CAAC,IAAI,CAAC,4BAA4B,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IACnE,oFAAoF;IACpF,wFAAwF;IACxF,8DAA8D;IAC9D,OAAO,IAAI,sBAAa,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,iCAAiC;AACtF,CAAC;AAED;;;;;;GAMG;AACI,KAAK,UAAU,eAAe,CAAC,OAAe,EAAE,MAAc,EAAE,QAAyB;IAC9F,MAAM,QAAQ,CAAC,IAAI,CAAC,oBAAoB,EAAE;QACxC,OAAO,EAAE,mCAAmC;QAC5C,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,2CAA2C;KACxE,CAAC,CAAC;AACL,CAAC;AAED;;;;;;GAMG;AACI,KAAK,UAAU,wBAAwB,CAAC,eAAuB,EAAE,QAAiD;IACvH,IAAI,CAAC;QACH,MAAM,QAAQ,CAAC,IAAI,CAAC,4BAA4B,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC;QACrE,0EAA0E;QAC1E,kFAA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CAAC;QACzC,QAAQ,CAAC,+BAA+B,eAAe,EAAE,CAAC,CAAC;QAE3D,0EAA0E;QAC1E,MAAM,eAAe,CAAC,eAAe,EAAE,IAAA,cAAK,EAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC;QAE5D,MAAO,SAAiB,CAAC,OAAO,CAAC,MAAM,QAAQ,CAAC,CAAC,iBAAiB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACrF,MAAO,SAAiB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,iBAAiB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACjF,CAAC;IAED,sCAAsC;IACtC,OAAO,eAAe,CAAC;AACzB,CAAC,CAAC;AA1BW,QAAA,kBAAkB,sBA0B7B","sourcesContent":["import hre from 'hardhat';\nimport { toWei } from './common';\nimport { JsonRpcProvider, JsonRpcSigner, Signer } from 'ethers';\nimport '@nomicfoundation/hardhat-ethers';\nimport { HardhatEthersProvider } from '@nomicfoundation/hardhat-ethers/internal/hardhat-ethers-provider';\n\n/**\n * Impersonates a signer account. This is primarily used in Hardhat's testing environment\n * to simulate actions from accounts that are not part of the default test accounts.\n *\n * @param signerAddress - The address of the account to impersonate.\n * @returns The impersonated signer object.\n */\nexport async function impersonateSigner(signerAddress: string, provider: JsonRpcProvider): Promise<Signer> {\n // Request Hardhat to impersonate the account at the specified address\n await provider.send(\"hardhat_impersonateAccount\", [signerAddress]);\n // Construct the signer directly. ethers v6 `provider.getSigner(addr)` validates the\n // address against `eth_accounts` and throws \"invalid account\" for impersonated accounts\n // (impersonation does NOT add the account to `eth_accounts`).\n return new JsonRpcSigner(provider, signerAddress); // Return the impersonated signer\n}\n\n/**\n * Sets the Ether balance for a specified address in the Hardhat testing environment.\n * This is useful for ensuring test accounts have sufficient funds for transactions.\n *\n * @param address - The address to set the Ether balance for.\n * @param amount - The desired balance as a `BigNumber`.\n */\nexport async function setEtherBalance(address: string, amount: bigint, provider: JsonRpcProvider) {\n await provider.send('hardhat_setBalance', [\n address, // Address to modify the balance of\n '0x' + amount.toString(16), // Amount to set, formatted as a hex string\n ]);\n}\n\n/** \n * Impersonates the deployer account and funds it to a balance that is rounded to the next highest 100 ETH.\n * \n * @param provider - The ethers provider instance.\n * @param deployerAddress - The address of the deployer account.\n * @param balance - The balance to set for the deployer account (in hex format).\n */\nexport async function impersonateAndFundSigner(deployerAddress: string, provider: JsonRpcProvider | HardhatEthersProvider): Promise<Signer> {\n try {\n await provider.send('hardhat_impersonateAccount', [deployerAddress]);\n // For an ethers JsonRpcProvider, construct the signer directly: ethers v6\n // `getSigner(addr)` validates against `eth_accounts` and throws \"invalid account\"\n // for impersonated accounts. HardhatEthersProvider has no such issue, so keep its path.\n const signer =\n provider instanceof JsonRpcProvider\n ? new JsonRpcSigner(provider, deployerAddress)\n : await provider.getSigner(deployerAddress);\n\n // Fund the account\n await provider.send('hardhat_setBalance', [deployerAddress, '0x56BC75E2D63100000']);\n return signer;\n } catch (error) {\n if (error instanceof Error) {\n console.error(`Impersonation and funding failed for ${deployerAddress}: ${error.message}`);\n } else {\n console.error(`Impersonation and funding failed for ${deployerAddress}: ${String(error)}`);\n }\n throw error;\n }\n}\n\n\n/**\n * Updates the owner of the contract at the specified root address for testing purposes.\n * This involves transferring ownership from the current owner to the default signer in the Hardhat environment.\n *\n * @param rootAddress - The address of the root contract (e.g., GeniusOwnershipFacet).\n * @returns The address of the old owner.\n */\nexport const updateOwnerForTest = async (rootAddress: string, provider: JsonRpcProvider) => {\n // Retrieve the current signer in the Hardhat environment\n const curOwner = (await hre.ethers.getSigners())[0];\n\n // Get a reference to the GeniusOwnershipFacet contract at the specified root address\n const ownership = await hre.ethers.getContractAt('GeniusOwnershipFacet', rootAddress);\n\n // Retrieve the current owner of the contract\n const oldOwnerAddress = await ownership.owner();\n\n // Impersonate the old owner\n const oldOwner = await impersonateSigner(oldOwnerAddress, provider);\n\n // If the old owner is not the current signer, transfer ownership to the current signer\n if (oldOwnerAddress !== curOwner.address) {\n debuglog(`Transferring ownership from ${oldOwnerAddress}`);\n\n // Ensure the old owner has enough Ether to perform the ownership transfer\n await setEtherBalance(oldOwnerAddress, toWei(10), provider);\n\n await (ownership as any).connect(await oldOwner).transferOwnership(curOwner.address);\n await (ownership as any).connect(oldOwner).transferOwnership(curOwner.address);\n }\n\n // Return the address of the old owner\n return oldOwnerAddress;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diamondslab/diamonds",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "Tools for deploying and interfacing with ERC-2535 Diamond Proxies",
|
|
5
5
|
"repository": "github:diamondslab/diamonds",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"module": "dist/index.js",
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public",
|
|
11
|
+
"registry": "https://registry.npmjs.org"
|
|
12
|
+
},
|
|
9
13
|
"exports": {
|
|
10
14
|
".": {
|
|
11
15
|
"types": "./dist/index.d.ts",
|
|
@@ -29,7 +33,9 @@
|
|
|
29
33
|
"diamond",
|
|
30
34
|
"diamond-proxy",
|
|
31
35
|
"diamond-upgradeable",
|
|
32
|
-
"blockchain"
|
|
36
|
+
"blockchain",
|
|
37
|
+
"erc-2535",
|
|
38
|
+
"eip-2535"
|
|
33
39
|
],
|
|
34
40
|
"bugs": {
|
|
35
41
|
"url": "https://github.com/diamondslab/diamonds/issues"
|
|
@@ -40,7 +46,7 @@
|
|
|
40
46
|
"test:integration": "hardhat test test/integration/**/*.test.ts --config hardhat.config.ts",
|
|
41
47
|
"test:coverage": "hardhat coverage --config hardhat.config.ts",
|
|
42
48
|
"test:performance": "hardhat test test/integration/performance/**/*.test.ts --config hardhat.config.ts",
|
|
43
|
-
"build": "
|
|
49
|
+
"build": "rimraf dist tsconfig.tsbuildinfo && tsc",
|
|
44
50
|
"clean": "rimraf artifacts/* cache/* diamond-abi/* typechain-types/* diamond-typechain-types/*",
|
|
45
51
|
"compile": "npx hardhat compile --config hardhat.config.ts && yarn diamond:generate-abi-typechain",
|
|
46
52
|
"clean-compile": "yarn clean && yarn compile",
|
|
@@ -124,7 +130,7 @@
|
|
|
124
130
|
"perf:compare": "bash scripts/devops/devcontainer-performance-benchmark.sh compare"
|
|
125
131
|
},
|
|
126
132
|
"bin": {
|
|
127
|
-
"diamond-abi": "dist/
|
|
133
|
+
"diamond-abi": "dist/cli/diamond-abi-cli.js"
|
|
128
134
|
},
|
|
129
135
|
"files": [
|
|
130
136
|
"dist/",
|
|
@@ -134,13 +140,13 @@
|
|
|
134
140
|
"devDependencies": {
|
|
135
141
|
"@commitlint/cli": "^19.8.1",
|
|
136
142
|
"@commitlint/config-conventional": "^19.8.1",
|
|
137
|
-
"@diamondslab/hardhat-diamonds": "^1.
|
|
143
|
+
"@diamondslab/hardhat-diamonds": "^1.2.0",
|
|
138
144
|
"@ethersproject/abi": "^5.8.0",
|
|
139
145
|
"@ethersproject/bytes": "^5.8.0",
|
|
140
146
|
"@ethersproject/providers": "^5.8.0",
|
|
141
147
|
"@gnus.ai/contracts-upgradeable-diamond": "=4.5.0",
|
|
142
148
|
"@nomicfoundation/hardhat-chai-matchers": "^2.0.0",
|
|
143
|
-
"@nomicfoundation/hardhat-ethers": "
|
|
149
|
+
"@nomicfoundation/hardhat-ethers": "^3.1.2",
|
|
144
150
|
"@nomicfoundation/hardhat-ignition": "^0.15.0",
|
|
145
151
|
"@nomicfoundation/hardhat-ignition-ethers": "^0.15.0",
|
|
146
152
|
"@nomicfoundation/hardhat-network-helpers": "^1.0.0",
|
|
@@ -208,8 +214,7 @@
|
|
|
208
214
|
"web3": "^4.16.0",
|
|
209
215
|
"web3-core": "^4.7.1",
|
|
210
216
|
"web3-utils": "^4.3.3",
|
|
211
|
-
"winston": "^3.17.0"
|
|
212
|
-
"zod": "^4.0.2"
|
|
217
|
+
"winston": "^3.17.0"
|
|
213
218
|
},
|
|
214
219
|
"peerDependencies": {
|
|
215
220
|
"ethers": "^6.0.0",
|
|
@@ -223,6 +228,7 @@
|
|
|
223
228
|
"axios": "^1.12.0",
|
|
224
229
|
"debug": "^4.4.1",
|
|
225
230
|
"fs-extra": "^11.3.0",
|
|
226
|
-
"lodash": "^4.17.21"
|
|
231
|
+
"lodash": "^4.17.21",
|
|
232
|
+
"zod": "^4.0.2"
|
|
227
233
|
}
|
|
228
234
|
}
|