@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
package/package.json
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@diamondslab/diamonds",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Tools for deploying and interfacing with ERC-2535 Diamond Proxies",
|
|
5
|
+
"repository": "github:diamondslab/diamonds",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"module": "dist/index.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"authors": [
|
|
16
|
+
"Am0rfu5",
|
|
17
|
+
"SuperGenius"
|
|
18
|
+
],
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"keywords": [
|
|
21
|
+
"ethereum",
|
|
22
|
+
"smart-contracts",
|
|
23
|
+
"hardhat",
|
|
24
|
+
"hardhat-plugin",
|
|
25
|
+
"diamond",
|
|
26
|
+
"diamond-proxy",
|
|
27
|
+
"diamond-upgradeable",
|
|
28
|
+
"blockchain"
|
|
29
|
+
],
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/diamondslab/diamonds/issues"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"test": "hardhat test --config hardhat.config.ts",
|
|
35
|
+
"test:unit": "hardhat test test/unit/**/*.test.ts --config hardhat.config.ts",
|
|
36
|
+
"test:integration": "hardhat test test/integration/**/*.test.ts --config hardhat.config.ts",
|
|
37
|
+
"test:coverage": "hardhat coverage --config hardhat.config.ts",
|
|
38
|
+
"test:performance": "hardhat test test/integration/performance/**/*.test.ts --config hardhat.config.ts",
|
|
39
|
+
"build": "yarn clean-compile && npx tsc",
|
|
40
|
+
"clean": "rimraf artifacts/* cache/* diamond-abi/* typechain-types/* diamond-typechain-types/*",
|
|
41
|
+
"compile": "npx hardhat compile --config hardhat.config.ts && yarn diamond:generate-abi-typechain",
|
|
42
|
+
"clean-compile": "yarn clean && yarn compile",
|
|
43
|
+
"lint:fix": "prettier --write 'src/**/*.{js,ts}' 'test/**/*.{js,ts}' && tslint --fix --config tslint.json --project tsconfig.dev.json",
|
|
44
|
+
"lint": "tslint --config tslint.json --project tsconfig.dev.json",
|
|
45
|
+
"build:dev": "tsc --project tsconfig.dev.json --noEmit",
|
|
46
|
+
"watch": "tsc --project tsconfig.json -w",
|
|
47
|
+
"prepublishOnly": "yarn build",
|
|
48
|
+
"defender:deploy": "ts-node scripts/defender-cli.ts deploy",
|
|
49
|
+
"defender:upgrade": "ts-node scripts/defender-cli.ts upgrade",
|
|
50
|
+
"defender:status": "ts-node scripts/defender-cli.ts status",
|
|
51
|
+
"defender:verify": "ts-node scripts/defender-cli.ts verify",
|
|
52
|
+
"defender:init": "ts-node scripts/defender-cli.ts init",
|
|
53
|
+
"rpc:deploy": "ts-node scripts/deploy-rpc.ts deploy",
|
|
54
|
+
"rpc:deploy-quick": "ts-node scripts/deploy-rpc.ts quick",
|
|
55
|
+
"rpc:upgrade": "ts-node scripts/upgrade-rpc.ts upgrade",
|
|
56
|
+
"rpc:upgrade-quick": "ts-node scripts/upgrade-rpc.ts quick",
|
|
57
|
+
"rpc:status": "ts-node scripts/status-rpc.ts check",
|
|
58
|
+
"rpc:status-quick": "ts-node scripts/status-rpc.ts quick",
|
|
59
|
+
"rpc:verify": "ts-node scripts/verify-rpc.ts verify",
|
|
60
|
+
"rpc:verify-full": "ts-node scripts/verify-rpc.ts full",
|
|
61
|
+
"rpc:deploy-manual": "ts-node scripts/deploy-rpc-manual.ts deploy",
|
|
62
|
+
"rpc:deploy-interactive": "ts-node scripts/deploy-rpc-manual.ts interactive",
|
|
63
|
+
"diamonds-clean": "rm -rf diamond-typechain-types diamond-abi && npx hardhat clean",
|
|
64
|
+
"coverage": "npx hardhat coverage",
|
|
65
|
+
"diamond:generate-abi": "npx hardhat diamond:generate-abi --diamond-name Diamond",
|
|
66
|
+
"diamond:generate-abi-typechain": "npx hardhat diamond:generate-abi-typechain --diamond-name Diamond",
|
|
67
|
+
"format": "prettier --write \"**/*.{ts,js,json,md,sol}\"",
|
|
68
|
+
"install:frozen": "yarn install --frozen-lockfile",
|
|
69
|
+
"precommit": ".husky/pre-commit",
|
|
70
|
+
"prepush": ".husky/pre-push",
|
|
71
|
+
"pc": "yarn precommit",
|
|
72
|
+
"pp": "yarn prepush",
|
|
73
|
+
"ls": "lint-staged",
|
|
74
|
+
"commitlint": "commitlint --edit",
|
|
75
|
+
"lint-staged": "npx lint-staged",
|
|
76
|
+
"audit": "yarn npm audit --severity moderate",
|
|
77
|
+
"depcheck": "yarn dlx depcheck",
|
|
78
|
+
"snyk:test": "snyk test --all-projects --exclude=yarn.lock --severity-threshold=medium",
|
|
79
|
+
"socket:scan": "SOCKET_CLI_API_TOKEN=$(grep SOCKET_CLI_API_TOKEN .env | cut -d'=' -f2) npx socket ci",
|
|
80
|
+
"osv:scan": "osv-scanner --lockfile=yarn.lock --format=json",
|
|
81
|
+
"semgrep:scan": "semgrep scan --config .semgrep.yml --exclude-rule weak-encryption --error",
|
|
82
|
+
"slither:scan": "slither . --config-file slither.config.json --ignore-compile",
|
|
83
|
+
"slither:check": "slither . --config-file slither.config.json --checklist",
|
|
84
|
+
"git-secrets:scan": "git secrets --scan",
|
|
85
|
+
"perf-monitor": "npx ts-node scripts/devops/perf-monitor.ts",
|
|
86
|
+
"ci-perf-monitor": "node scripts/devops/ci-perf-monitor.js",
|
|
87
|
+
"sign-artifacts": "npx ts-node scripts/devops/sign-artifacts.ts",
|
|
88
|
+
"emergency-bypass": "npx ts-node scripts/devops/emergency-bypass.ts",
|
|
89
|
+
"security-check": "yarn audit && yarn snyk:test && yarn socket:scan && yarn osv:scan && yarn semgrep:scan && yarn slither:scan && yarn git-secrets:scan",
|
|
90
|
+
"security-tool-update": "npx ts-node scripts/devops/security-tool-updater.ts",
|
|
91
|
+
"provenance-check": "npx ts-node scripts/devops/provenance-validator.ts",
|
|
92
|
+
"slsa-attest": "npx ts-node scripts/devops/slsa-attestation.ts generate",
|
|
93
|
+
"sigstore-sign": "npx ts-node scripts/devops/sigstore-integration.ts sign-all",
|
|
94
|
+
"sigstore-verify": "npx ts-node scripts/devops/sigstore-integration.ts verify-all",
|
|
95
|
+
"supply-chain-assess": "npx ts-node scripts/devops/supply-chain-risk-assessment.ts assess",
|
|
96
|
+
"supply-chain-quick": "npx ts-node scripts/devops/supply-chain-risk-assessment.ts quick",
|
|
97
|
+
"security-webhook": "npx ts-node scripts/devops/security-monitoring-webhook.ts",
|
|
98
|
+
"security-alerting": "npx ts-node scripts/devops/security-alerting.ts",
|
|
99
|
+
"security-metrics": "npx ts-node scripts/devops/security-metrics-dashboard.ts",
|
|
100
|
+
"ci-performance-dashboard": "node scripts/devops/ci-performance-dashboard.js",
|
|
101
|
+
"cost-analyzer": "npx ts-node scripts/devops/cost-analyzer.ts",
|
|
102
|
+
"test-sharding": "npx ts-node scripts/devops/test-sharding.ts",
|
|
103
|
+
"smart-trigger": "npx ts-node scripts/devops/smart-trigger.ts",
|
|
104
|
+
"health-check": "npx ts-node scripts/devops/health-check.ts",
|
|
105
|
+
"maintenance-automation": "npx ts-node scripts/devops/maintenance-automation.ts",
|
|
106
|
+
"incident-response": "npx ts-node scripts/devops/incident-response.ts",
|
|
107
|
+
"security-health-checks": "npx ts-node scripts/devops/security-health-checks.ts",
|
|
108
|
+
"security-commit-check": "npx ts-node scripts/devops/security-commit-check.ts",
|
|
109
|
+
"prepare": "husky",
|
|
110
|
+
"container:build": "node scripts/devops/container-registry-manager.sh build",
|
|
111
|
+
"container:push": "node scripts/devops/container-registry-manager.sh push",
|
|
112
|
+
"container:pull": "node scripts/devops/container-registry-manager.sh pull",
|
|
113
|
+
"container:exists": "node scripts/devops/container-registry-manager.sh exists",
|
|
114
|
+
"container:validate": "bash scripts/devops/devcontainer-setup-validation.sh",
|
|
115
|
+
"container:cleanup": "node scripts/devops/container-registry-manager.sh cleanup",
|
|
116
|
+
"container:report": "node scripts/devops/container-registry-manager.sh report",
|
|
117
|
+
"env:parity": "bash scripts/devops/environment-parity-validation.sh",
|
|
118
|
+
"perf:benchmark": "bash scripts/devops/devcontainer-performance-benchmark.sh all --environment native",
|
|
119
|
+
"perf:benchmark:container": "bash scripts/devops/devcontainer-performance-benchmark.sh all --environment container",
|
|
120
|
+
"perf:compare": "bash scripts/devops/devcontainer-performance-benchmark.sh compare"
|
|
121
|
+
},
|
|
122
|
+
"bin": {
|
|
123
|
+
"diamond-abi": "dist/scripts/diamond-abi-cli.js"
|
|
124
|
+
},
|
|
125
|
+
"files": [
|
|
126
|
+
"dist/",
|
|
127
|
+
"src/",
|
|
128
|
+
"docs/",
|
|
129
|
+
"examples/",
|
|
130
|
+
"LICENSE",
|
|
131
|
+
"README.md",
|
|
132
|
+
"package.json"
|
|
133
|
+
],
|
|
134
|
+
"devDependencies": {
|
|
135
|
+
"@commitlint/cli": "^19.8.1",
|
|
136
|
+
"@commitlint/config-conventional": "^19.8.1",
|
|
137
|
+
"@ethersproject/abi": "^5.8.0",
|
|
138
|
+
"@ethersproject/bytes": "^5.8.0",
|
|
139
|
+
"@ethersproject/providers": "^5.8.0",
|
|
140
|
+
"@gnus.ai/contracts-upgradeable-diamond": "=4.5.0",
|
|
141
|
+
"@nomicfoundation/hardhat-chai-matchers": "^2.0.0",
|
|
142
|
+
"@nomicfoundation/hardhat-ethers": "^3.0.0",
|
|
143
|
+
"@nomicfoundation/hardhat-ignition": "^0.15.0",
|
|
144
|
+
"@nomicfoundation/hardhat-ignition-ethers": "^0.15.0",
|
|
145
|
+
"@nomicfoundation/hardhat-network-helpers": "^1.0.0",
|
|
146
|
+
"@nomicfoundation/hardhat-toolbox": "^5.0.0",
|
|
147
|
+
"@nomicfoundation/hardhat-verify": "^2.0.0",
|
|
148
|
+
"@nomicfoundation/hardhat-web3-v4": "^1.0.0",
|
|
149
|
+
"@nomicfoundation/ignition-core": "^0.15.9",
|
|
150
|
+
"@openzeppelin/defender-sdk": "^2.6.0",
|
|
151
|
+
"@openzeppelin/defender-sdk-base-client": "^2.6.0",
|
|
152
|
+
"@openzeppelin/defender-sdk-deploy-client": "^2.6.0",
|
|
153
|
+
"@openzeppelin/defender-sdk-proposal-client": "^2.6.0",
|
|
154
|
+
"@socketsecurity/cli": "^1.0.0",
|
|
155
|
+
"@typechain/ethers-v6": "^0.5.1",
|
|
156
|
+
"@typechain/hardhat": "^9.1.0",
|
|
157
|
+
"@types/chai": "^4.2.0",
|
|
158
|
+
"@types/chai-as-promised": "^8.0.1",
|
|
159
|
+
"@types/debug": "^4.1.12",
|
|
160
|
+
"@types/fs-extra": "^5.0.4",
|
|
161
|
+
"@types/glob": "^8.1.0",
|
|
162
|
+
"@types/jest": "^29.5.14",
|
|
163
|
+
"@types/lodash": "^4",
|
|
164
|
+
"@types/mocha": "^10.0.10",
|
|
165
|
+
"@types/node": "^24.0.12",
|
|
166
|
+
"@types/sinon-chai": "^4.0.0",
|
|
167
|
+
"@types/uint32": "^0.2.0",
|
|
168
|
+
"@typescript-eslint/eslint-plugin": "^8.18.1",
|
|
169
|
+
"@typescript-eslint/parser": "^8.18.10",
|
|
170
|
+
"abi2oas": "^0.1.4",
|
|
171
|
+
"chai": "^4.2.0",
|
|
172
|
+
"chai-as-promised": "^7.1.1",
|
|
173
|
+
"chalk": "^4.1.2",
|
|
174
|
+
"commander": "^9.4.1",
|
|
175
|
+
"concurrently": "^8.2.2",
|
|
176
|
+
"contracts-starter": "git+https://github.com/mudgen/diamond-2-hardhat.git",
|
|
177
|
+
"dotenv": "^10.0.0",
|
|
178
|
+
"eslint": "^9.17.0",
|
|
179
|
+
"eslint-config-prettier": "^9.1.0",
|
|
180
|
+
"eslint-plugin-n": "^17.15.0",
|
|
181
|
+
"eslint-plugin-node": "^11.1.0",
|
|
182
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
183
|
+
"eslint-plugin-promise": "^7.2.1",
|
|
184
|
+
"eslint-plugin-security": "^3.0.0",
|
|
185
|
+
"ethers": "^6.4.0",
|
|
186
|
+
"globals": "^15.14.0",
|
|
187
|
+
"hardhat": "^2.26.0",
|
|
188
|
+
"hardhat-diamonds": "git+https://github.com/diamondslab/hardhat-diamonds.git#develop",
|
|
189
|
+
"hardhat-gas-reporter": "^1.0.8",
|
|
190
|
+
"husky": "^9.1.7",
|
|
191
|
+
"jest": "^30.0.4",
|
|
192
|
+
"jest-mock": "^29.7.0",
|
|
193
|
+
"lint-staged": "^15.2.0",
|
|
194
|
+
"mocha": "^9.2.2",
|
|
195
|
+
"prettier": "^3.4.2",
|
|
196
|
+
"prettier-plugin-solidity": "^1.4.1",
|
|
197
|
+
"rimraf": "^6.0.1",
|
|
198
|
+
"semgrep": "^1.0.0",
|
|
199
|
+
"sinon": "^21.0.0",
|
|
200
|
+
"snyk": "^1.1294.0",
|
|
201
|
+
"solhint": "^3.3.7",
|
|
202
|
+
"solidity-coverage": "^0.8.16",
|
|
203
|
+
"ts-jest": "^29.4.0",
|
|
204
|
+
"ts-node": "^10.4.0",
|
|
205
|
+
"typechain": "^8.3.2",
|
|
206
|
+
"typescript": "^5.9.3",
|
|
207
|
+
"uint32": "^0.2.1",
|
|
208
|
+
"web3": "^4.16.0",
|
|
209
|
+
"web3-core": "^4.7.1",
|
|
210
|
+
"web3-utils": "^4.3.3",
|
|
211
|
+
"winston": "^3.17.0",
|
|
212
|
+
"zod": "^4.0.2"
|
|
213
|
+
},
|
|
214
|
+
"peerDependencies": {
|
|
215
|
+
"ethers": "^6.0.0",
|
|
216
|
+
"hardhat": "^2.0.0",
|
|
217
|
+
"ts-node": "^10.0.0",
|
|
218
|
+
"typescript": "^5.0.0"
|
|
219
|
+
},
|
|
220
|
+
"packageManager": "yarn@4.10.3",
|
|
221
|
+
"dependencies": {
|
|
222
|
+
"@ethersproject/abstract-signer": "^5.8.0",
|
|
223
|
+
"axios": "^1.12.0",
|
|
224
|
+
"debug": "^4.4.1",
|
|
225
|
+
"fs-extra": "^11.3.0",
|
|
226
|
+
"lodash": "^4.17.21"
|
|
227
|
+
}
|
|
228
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import * as fs from "fs-extra";
|
|
2
|
+
import { resolve, join } from "path";
|
|
3
|
+
import { CallbackArgs } from "../types";
|
|
4
|
+
|
|
5
|
+
export class CallbackManager {
|
|
6
|
+
private static instances: Map<string, CallbackManager> = new Map();
|
|
7
|
+
|
|
8
|
+
private callbacks: Record<string, Record<string, (args: CallbackArgs) => Promise<void>>> = {};
|
|
9
|
+
|
|
10
|
+
private constructor(private callbacksPath: string) {
|
|
11
|
+
this.loadCallbacks();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public static getInstance(diamondName: string, deploymentsPath: string): CallbackManager {
|
|
15
|
+
if (!this.instances.has(diamondName)) {
|
|
16
|
+
const callbacksPath = join(deploymentsPath, diamondName, "callbacks");
|
|
17
|
+
this.instances.set(diamondName, new CallbackManager(callbacksPath));
|
|
18
|
+
}
|
|
19
|
+
return this.instances.get(diamondName)!;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public static clearInstances(): void {
|
|
23
|
+
this.instances.clear();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public static clearInstance(diamondName: string): void {
|
|
27
|
+
this.instances.delete(diamondName);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private loadCallbacks(): void {
|
|
31
|
+
if (!fs.existsSync(this.callbacksPath)) {
|
|
32
|
+
console.error(`Facet callbacks path "${this.callbacksPath}" does not exist.`);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const files = fs.readdirSync(this.callbacksPath);
|
|
37
|
+
|
|
38
|
+
files.forEach(file => {
|
|
39
|
+
if (!file.endsWith(".ts") && !file.endsWith(".js")) return;
|
|
40
|
+
|
|
41
|
+
const facetName = file.split(".")[0];
|
|
42
|
+
const filePath = resolve(this.callbacksPath, file);
|
|
43
|
+
const module = require(filePath);
|
|
44
|
+
|
|
45
|
+
this.callbacks[facetName] = {};
|
|
46
|
+
|
|
47
|
+
Object.entries(module).forEach(([callbackName, callbackFn]) => {
|
|
48
|
+
if (typeof callbackFn === 'function') {
|
|
49
|
+
this.callbacks[facetName][callbackName] = callbackFn as (args: CallbackArgs) => Promise<void>;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public async executeCallback(facetName: string, callbacks: string[], args: CallbackArgs): Promise<void> {
|
|
56
|
+
const registeredCallbacks = this.callbacks[facetName];
|
|
57
|
+
for (const callbackName of callbacks) {
|
|
58
|
+
if (!registeredCallbacks) {
|
|
59
|
+
throw new Error(`Callbacks for facet "${facetName}" not found.`);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const callback = registeredCallbacks[callbackName];
|
|
63
|
+
if (!callback) {
|
|
64
|
+
throw new Error(`Callback "${callbackName}" for facet "${facetName}" not found.`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
await callback(args);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { DeploymentStrategy } from "../strategies/DeploymentStrategy";
|
|
2
|
+
import { Diamond } from "./Diamond";
|
|
3
|
+
|
|
4
|
+
export class DeploymentManager {
|
|
5
|
+
private diamond: Diamond;
|
|
6
|
+
private strategy: DeploymentStrategy;
|
|
7
|
+
|
|
8
|
+
constructor(diamond: Diamond, strategy: DeploymentStrategy) {
|
|
9
|
+
this.diamond = diamond;
|
|
10
|
+
this.strategy = strategy;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async deploy(): Promise<void> {
|
|
14
|
+
console.log(`🚀 Starting deployment for Diamond: ${this.diamond.diamondName}`);
|
|
15
|
+
this.diamond.newDeployment = true;
|
|
16
|
+
|
|
17
|
+
await this.strategy.preDeployDiamond(this.diamond);
|
|
18
|
+
await this.strategy.deployDiamond(this.diamond);
|
|
19
|
+
await this.strategy.postDeployDiamond(this.diamond);
|
|
20
|
+
|
|
21
|
+
await this.strategy.preDeployFacets(this.diamond);
|
|
22
|
+
await this.strategy.deployFacets(this.diamond);
|
|
23
|
+
await this.strategy.postDeployFacets(this.diamond);
|
|
24
|
+
|
|
25
|
+
await this.strategy.preUpdateFunctionSelectorRegistry(this.diamond);
|
|
26
|
+
await this.strategy.updateFunctionSelectorRegistry(this.diamond);
|
|
27
|
+
await this.strategy.postUpdateFunctionSelectorRegistry(this.diamond);
|
|
28
|
+
|
|
29
|
+
await this.strategy.prePerformDiamondCut(this.diamond);
|
|
30
|
+
await this.strategy.performDiamondCut(this.diamond);
|
|
31
|
+
await this.strategy.postPerformDiamondCut(this.diamond);
|
|
32
|
+
|
|
33
|
+
await this.strategy.preRunPostDeployCallbacks(this.diamond);
|
|
34
|
+
await this.strategy.runPostDeployCallbacks(this.diamond);
|
|
35
|
+
await this.strategy.postRunPostDeployCallbacks(this.diamond);
|
|
36
|
+
|
|
37
|
+
console.log(`✅ Deployment completed successfully.`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async upgrade(): Promise<void> {
|
|
41
|
+
console.log(`♻️ Starting upgrade for Diamond: ${this.diamond.diamondName}`);
|
|
42
|
+
|
|
43
|
+
this.diamond.newDeployment = false;
|
|
44
|
+
|
|
45
|
+
await this.strategy.preDeployFacets(this.diamond);
|
|
46
|
+
await this.strategy.deployFacets(this.diamond);
|
|
47
|
+
await this.strategy.postDeployFacets(this.diamond);
|
|
48
|
+
|
|
49
|
+
await this.strategy.preUpdateFunctionSelectorRegistry(this.diamond);
|
|
50
|
+
await this.strategy.updateFunctionSelectorRegistry(this.diamond);
|
|
51
|
+
await this.strategy.postUpdateFunctionSelectorRegistry(this.diamond);
|
|
52
|
+
|
|
53
|
+
await this.strategy.prePerformDiamondCut(this.diamond);
|
|
54
|
+
await this.strategy.performDiamondCut(this.diamond);
|
|
55
|
+
await this.strategy.postPerformDiamondCut(this.diamond);
|
|
56
|
+
|
|
57
|
+
await this.strategy.preRunPostDeployCallbacks(this.diamond);
|
|
58
|
+
await this.strategy.runPostDeployCallbacks(this.diamond);
|
|
59
|
+
await this.strategy.postRunPostDeployCallbacks(this.diamond);
|
|
60
|
+
|
|
61
|
+
console.log(`✅ Upgrade completed successfully.`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { join } from "path";
|
|
2
|
+
import {
|
|
3
|
+
DeployedDiamondData,
|
|
4
|
+
DeployedFacets,
|
|
5
|
+
DeployedFacet,
|
|
6
|
+
DeployConfig,
|
|
7
|
+
FacetsConfig
|
|
8
|
+
} from "../schemas";
|
|
9
|
+
import { CallbackManager } from "./CallbackManager";
|
|
10
|
+
import { JsonRpcProvider, Provider } from "@ethersproject/providers";
|
|
11
|
+
import { Signer } from "ethers";
|
|
12
|
+
import { DeploymentRepository } from "../repositories/DeploymentRepository";
|
|
13
|
+
import {
|
|
14
|
+
DiamondConfig,
|
|
15
|
+
RegistryFacetCutAction,
|
|
16
|
+
FunctionSelectorRegistryEntry,
|
|
17
|
+
NewDeployedFacets,
|
|
18
|
+
NewDeployedFacet
|
|
19
|
+
} from "../types";
|
|
20
|
+
import { ethers } from "ethers";
|
|
21
|
+
import { HardhatEthersProvider } from "@nomicfoundation/hardhat-ethers/internal/hardhat-ethers-provider";
|
|
22
|
+
|
|
23
|
+
export class Diamond {
|
|
24
|
+
private static instances: Map<string, Diamond> = new Map();
|
|
25
|
+
|
|
26
|
+
public diamondName: string;
|
|
27
|
+
public networkName: string;
|
|
28
|
+
public chainId: number | bigint;
|
|
29
|
+
public deploymentsPath: string;
|
|
30
|
+
public contractsPath: string;
|
|
31
|
+
public diamondAbiPath: string;
|
|
32
|
+
public diamondAbiFileName: string;
|
|
33
|
+
public deploymentId: string;
|
|
34
|
+
public facetSelectors: string[] = [];
|
|
35
|
+
public callbackManager: CallbackManager;
|
|
36
|
+
private deployedDiamondData: DeployedDiamondData;
|
|
37
|
+
private config: DiamondConfig;
|
|
38
|
+
private facetsConfig: FacetsConfig;
|
|
39
|
+
private repository: DeploymentRepository;
|
|
40
|
+
public signer: Signer | undefined;
|
|
41
|
+
public provider: JsonRpcProvider | Provider | HardhatEthersProvider | undefined;
|
|
42
|
+
public deployConfig: DeployConfig;
|
|
43
|
+
public newDeployment: boolean = true;
|
|
44
|
+
public initAddress: string | undefined;
|
|
45
|
+
|
|
46
|
+
constructor(config: DiamondConfig, repository: DeploymentRepository) {
|
|
47
|
+
this.config = config;
|
|
48
|
+
this.diamondName = config.diamondName;
|
|
49
|
+
this.networkName = config.networkName || "hardhat";
|
|
50
|
+
this.chainId = config.chainId || 31337;
|
|
51
|
+
this.deploymentsPath = config.deploymentsPath || "diamonds";
|
|
52
|
+
this.contractsPath = config.contractsPath || "contracts";
|
|
53
|
+
this.diamondAbiFileName = config.diamondAbiFileName || config.diamondName;
|
|
54
|
+
|
|
55
|
+
// Set diamond ABI path - default to diamond-abi subdirectory of configFilePath directory
|
|
56
|
+
if (config.diamondAbiPath) {
|
|
57
|
+
this.diamondAbiPath = config.diamondAbiPath;
|
|
58
|
+
} else {
|
|
59
|
+
const configDir = config.configFilePath
|
|
60
|
+
? config.configFilePath.replace(/\/[^\/]*$/, '') // Remove filename from path
|
|
61
|
+
: join(this.deploymentsPath, config.diamondName);
|
|
62
|
+
this.diamondAbiPath = join(configDir, 'diamond-abi');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
this.repository = repository;
|
|
66
|
+
this.deploymentId = repository.getDeploymentId();
|
|
67
|
+
|
|
68
|
+
// Load existing deployment info
|
|
69
|
+
this.deployedDiamondData = this.repository.loadDeployedDiamondData();
|
|
70
|
+
this.deployConfig = this.repository.loadDeployConfig();
|
|
71
|
+
|
|
72
|
+
this.facetsConfig = this.deployConfig.facets;
|
|
73
|
+
|
|
74
|
+
this.callbackManager = CallbackManager.getInstance(
|
|
75
|
+
this.diamondName, this.deploymentsPath);
|
|
76
|
+
|
|
77
|
+
this._initializeFunctionSelectorRegistry(this);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
public functionSelectorRegistry = new Map<string, FunctionSelectorRegistryEntry>();
|
|
81
|
+
|
|
82
|
+
private _initializeFunctionSelectorRegistry(
|
|
83
|
+
diamond: Diamond
|
|
84
|
+
) {
|
|
85
|
+
const diamondConfig: DiamondConfig = diamond.getDiamondConfig();
|
|
86
|
+
const deployedDiamondData: DeployedDiamondData = diamond.getDeployedDiamondData();
|
|
87
|
+
const deployedFacets: DeployedFacets = deployedDiamondData.DeployedFacets || {};
|
|
88
|
+
|
|
89
|
+
for (const [facetName, { address: contractAddress, funcSelectors: selectors }] of Object.entries(deployedFacets)) {
|
|
90
|
+
console.log(facetName);
|
|
91
|
+
for (const selector of selectors!) {
|
|
92
|
+
this.functionSelectorRegistry.set(selector, {
|
|
93
|
+
facetName,
|
|
94
|
+
priority: this.facetsConfig[facetName]?.priority! || 1000,
|
|
95
|
+
address: contractAddress!,
|
|
96
|
+
action: RegistryFacetCutAction.Deployed,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
public registerFunctionSelectors(selectors: Record<string, Omit<FunctionSelectorRegistryEntry, "selector">>): void {
|
|
103
|
+
Object.entries(selectors).forEach(([selector, entry]) => {
|
|
104
|
+
this.functionSelectorRegistry.set(selector, entry);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
public updateFunctionSelectorRegistry(selector: string, entry: FunctionSelectorRegistryEntry): void {
|
|
109
|
+
this.functionSelectorRegistry.set(selector, entry);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
public isFunctionSelectorRegistered(selector: string): boolean {
|
|
113
|
+
return this.functionSelectorRegistry.has(selector);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
public newDeployedFacets: NewDeployedFacets = {};
|
|
117
|
+
|
|
118
|
+
public getNewDeployedFacets(): NewDeployedFacets {
|
|
119
|
+
return this.newDeployedFacets || {};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
public updateNewDeployedFacets(facetName: string, facet: NewDeployedFacet): void {
|
|
123
|
+
this.newDeployedFacets[facetName] = facet;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
getDeployedDiamondData(): DeployedDiamondData {
|
|
127
|
+
return this.deployedDiamondData;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
setDeployedDiamondData(data: DeployedDiamondData) {
|
|
131
|
+
this.deployedDiamondData = data;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
updateDeployedDiamondData(data: DeployedDiamondData): void {
|
|
135
|
+
this.deployedDiamondData = data;
|
|
136
|
+
this.repository.saveDeployedDiamondData(data);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
public getDiamondConfig(): DiamondConfig {
|
|
140
|
+
return this.config;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
public getDeployConfig(): DeployConfig {
|
|
144
|
+
return this.deployConfig;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
public getFacetsConfig(): FacetsConfig {
|
|
148
|
+
return this.facetsConfig;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
public setProvider(provider: JsonRpcProvider | Provider | HardhatEthersProvider): void {
|
|
152
|
+
this.provider = provider;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
public getProvider(): JsonRpcProvider | Provider | HardhatEthersProvider | undefined {
|
|
156
|
+
return this.provider;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
public setSigner(signer: Signer): void {
|
|
160
|
+
this.signer = signer;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
public getSigner(): Signer | undefined {
|
|
164
|
+
return this.signer;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
public isUpgradeDeployment(): boolean {
|
|
168
|
+
return !!this.deployedDiamondData.DiamondAddress;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
public initializerRegistry: Map<string, string> = new Map();
|
|
172
|
+
|
|
173
|
+
public registerInitializers(facetName: string, initFunction: string): void {
|
|
174
|
+
this.initializerRegistry.set(facetName, initFunction);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
public setInitAddress(initAddress: string): void {
|
|
178
|
+
this.initAddress = initAddress;
|
|
179
|
+
}
|
|
180
|
+
public getInitAddress(): string | undefined {
|
|
181
|
+
return this.initAddress;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
public getDiamondAbiPath(): string {
|
|
185
|
+
return this.diamondAbiPath;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
public getDiamondAbiFileName(): string {
|
|
189
|
+
return this.diamondAbiFileName;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
public getDiamondAbiFilePath(): string {
|
|
193
|
+
return join(this.diamondAbiPath, `${this.diamondAbiFileName}.json`);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export default Diamond;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Diamond } from './Diamond';
|
|
2
|
+
import { DeploymentManager } from './DeploymentManager';
|
|
3
|
+
import { DeploymentStrategy } from '../strategies';
|
|
4
|
+
import { DeployedDiamondData } from '../schemas';
|
|
5
|
+
|
|
6
|
+
export class DiamondDeployer {
|
|
7
|
+
// private provider: JsonRpcProvider;
|
|
8
|
+
private diamond: Diamond;
|
|
9
|
+
private strategy: DeploymentStrategy;
|
|
10
|
+
|
|
11
|
+
constructor(
|
|
12
|
+
diamond: Diamond,
|
|
13
|
+
strategy: DeploymentStrategy
|
|
14
|
+
) {
|
|
15
|
+
this.diamond = diamond;
|
|
16
|
+
this.strategy = strategy;;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async deployDiamond(): Promise<void> {
|
|
20
|
+
const manager = new DeploymentManager(this.diamond, this.strategy);
|
|
21
|
+
let deployedDiamondData: DeployedDiamondData;
|
|
22
|
+
const deployedData = this.diamond.getDeployedDiamondData();
|
|
23
|
+
if (deployedData && deployedData.DiamondAddress) {
|
|
24
|
+
deployedDiamondData = deployedData;
|
|
25
|
+
console.log(`Diamond already deployed at ${deployedDiamondData.DiamondAddress}. Performing upgrade...`);
|
|
26
|
+
await manager.upgrade();
|
|
27
|
+
} else {
|
|
28
|
+
console.log(`Diamond not previously deployed. Performing initial deployment...`);
|
|
29
|
+
await manager.deploy();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public getDiamond(): Diamond {
|
|
34
|
+
return this.diamond;
|
|
35
|
+
}
|
|
36
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// import {
|
|
2
|
+
// readDeployedDiamondData,
|
|
3
|
+
// saveDeploymentInfo,
|
|
4
|
+
// getDeployConfigData
|
|
5
|
+
// } from './databaseHandler';
|
|
6
|
+
|
|
7
|
+
// import { DeploymentRepository } from './DeploymentRepository';
|
|
8
|
+
// import { DeployedDiamondData, DeployConfig } from '../schemas';
|
|
9
|
+
|
|
10
|
+
// export class DbDeploymentRepository implements DeploymentRepository {
|
|
11
|
+
// async loadDeployInfo(key: { network: string; diamond: string }): Promise<DeployedDiamondData> {
|
|
12
|
+
// return await readDeployedDiamondData(key.network, key.diamond);
|
|
13
|
+
// }
|
|
14
|
+
|
|
15
|
+
// async saveDeployInfo(key: { network: string; diamond: string }, info: DeployedDiamondData): Promise<void> {
|
|
16
|
+
// await saveDeploymentInfo(key.network, key.diamond, info);
|
|
17
|
+
// }
|
|
18
|
+
|
|
19
|
+
// async loadDeployConfig(key: { projectId: string }): Promise<DeployConfig> {
|
|
20
|
+
// return await getDeployConfigData(key.projectId);
|
|
21
|
+
// }
|
|
22
|
+
// }
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// DeploymentRepository.ts
|
|
2
|
+
import { DeployedDiamondData, DeployConfig } from "../schemas";
|
|
3
|
+
|
|
4
|
+
export abstract class DeploymentRepository {
|
|
5
|
+
abstract loadDeployedDiamondData(): DeployedDiamondData;
|
|
6
|
+
|
|
7
|
+
abstract saveDeployedDiamondData(info: DeployedDiamondData): void;
|
|
8
|
+
|
|
9
|
+
abstract loadDeployConfig(): DeployConfig;
|
|
10
|
+
|
|
11
|
+
abstract getDeploymentId(): string;
|
|
12
|
+
}
|