gnoman 0.1.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/.eslintrc.cjs +24 -0
- package/.gnoman/contracts.json +4094 -0
- package/.gnoman/exec_package/runtime-debug.jsonl +45 -0
- package/.gnoman/holds.sqlite +0 -0
- package/.gnoman/license.json +7 -0
- package/.gnoman/safes.json +37 -0
- package/.gnoman/vanity-jobs.json +67 -0
- package/.gnoman/wallets.db +0 -0
- package/.prettierrc.json +6 -0
- package/CODex_TASKS.md +124 -0
- package/LICENSE.md +164 -0
- package/README.md +95 -0
- package/assets/GnoLogo.jpg +0 -0
- package/assets/self.png +0 -0
- package/backend/controllers/contractController.ts +49 -0
- package/backend/controllers/devToolsController.ts +76 -0
- package/backend/controllers/etherscanController.ts +59 -0
- package/backend/controllers/historyController.ts +7 -0
- package/backend/controllers/keyringController.ts +134 -0
- package/backend/controllers/robinhoodController.ts +80 -0
- package/backend/controllers/safeController.ts +167 -0
- package/backend/controllers/sandboxController.ts +63 -0
- package/backend/controllers/settingsController.ts +38 -0
- package/backend/controllers/walletController.ts +151 -0
- package/backend/index.ts +133 -0
- package/backend/licenses/license_public.pem +3 -0
- package/backend/licenses/verify_license.py +43 -0
- package/backend/routes/contractRoutes.ts +11 -0
- package/backend/routes/devToolsRoutes.ts +11 -0
- package/backend/routes/etherscanRoutes.ts +11 -0
- package/backend/routes/historyRoutes.ts +8 -0
- package/backend/routes/keyringRoutes.ts +25 -0
- package/backend/routes/licenseRoutes.ts +35 -0
- package/backend/routes/robinhoodRoutes.ts +22 -0
- package/backend/routes/runtimeRoutes.ts +29 -0
- package/backend/routes/safeRoutes.ts +28 -0
- package/backend/routes/sandboxRoutes.ts +17 -0
- package/backend/routes/settingsRoutes.ts +14 -0
- package/backend/routes/walletRoutes.ts +21 -0
- package/backend/services/chainlinkService.ts +65 -0
- package/backend/services/contractRegistryService.ts +205 -0
- package/backend/services/devToolsService.ts +251 -0
- package/backend/services/diagnosticsService.ts +350 -0
- package/backend/services/etherscanService.ts +152 -0
- package/backend/services/historyService.ts +89 -0
- package/backend/services/keyringAccessor.ts +4 -0
- package/backend/services/licenseService.ts +163 -0
- package/backend/services/onchain/abiRegistry.ts +57 -0
- package/backend/services/onchain/chainlinkClient.ts +56 -0
- package/backend/services/onchain/errors.ts +16 -0
- package/backend/services/onchain/etherscanClient.ts +94 -0
- package/backend/services/onchain/index.ts +76 -0
- package/backend/services/onchain/tenderlyRpcClient.ts +74 -0
- package/backend/services/onchain/types.ts +33 -0
- package/backend/services/onchainAutomationService.ts +424 -0
- package/backend/services/robinhood/auth.ts +42 -0
- package/backend/services/robinhood/client.ts +123 -0
- package/backend/services/robinhood/integrationService.ts +140 -0
- package/backend/services/robinhood/provider.ts +22 -0
- package/backend/services/robinhood/unofficialClient.ts +66 -0
- package/backend/services/rpcService.ts +44 -0
- package/backend/services/runtimeTelemetryService.ts +158 -0
- package/backend/services/safeConfigRepository.ts +205 -0
- package/backend/services/safeService.ts +588 -0
- package/backend/services/sandboxService.ts +157 -0
- package/backend/services/secureSettingsService.ts +45 -0
- package/backend/services/transactionHoldService.ts +223 -0
- package/backend/services/vanityService.ts +293 -0
- package/backend/services/walletService.ts +290 -0
- package/backend/services/walletStore.ts +179 -0
- package/backend/types/express-async-handler.d.ts +13 -0
- package/backend/types/keyring.d.ts +19 -0
- package/backend/utils/abiResolver.ts +208 -0
- package/backend/utils/http.ts +6 -0
- package/backend/utils/secretsResolver.ts +150 -0
- package/backend/utils/signer.ts +11 -0
- package/backend/workers/vanityWorker.ts +76 -0
- package/capacitor.config.ts +13 -0
- package/cli/gnoman.ts +424 -0
- package/contracts/OracleConsumer.sol +20 -0
- package/contracts/PriceFeedConsumer.sol +22 -0
- package/dist/backend/backend/controllers/contractController.js +41 -0
- package/dist/backend/backend/controllers/contractController.js.map +1 -0
- package/dist/backend/backend/controllers/devToolsController.js +63 -0
- package/dist/backend/backend/controllers/devToolsController.js.map +1 -0
- package/dist/backend/backend/controllers/etherscanController.js +53 -0
- package/dist/backend/backend/controllers/etherscanController.js.map +1 -0
- package/dist/backend/backend/controllers/historyController.js +12 -0
- package/dist/backend/backend/controllers/historyController.js.map +1 -0
- package/dist/backend/backend/controllers/keyringController.js +126 -0
- package/dist/backend/backend/controllers/keyringController.js.map +1 -0
- package/dist/backend/backend/controllers/robinhoodController.js +69 -0
- package/dist/backend/backend/controllers/robinhoodController.js.map +1 -0
- package/dist/backend/backend/controllers/safeController.js +137 -0
- package/dist/backend/backend/controllers/safeController.js.map +1 -0
- package/dist/backend/backend/controllers/sandboxController.js +48 -0
- package/dist/backend/backend/controllers/sandboxController.js.map +1 -0
- package/dist/backend/backend/controllers/settingsController.js +34 -0
- package/dist/backend/backend/controllers/settingsController.js.map +1 -0
- package/dist/backend/backend/controllers/walletController.js +140 -0
- package/dist/backend/backend/controllers/walletController.js.map +1 -0
- package/dist/backend/backend/index.js +119 -0
- package/dist/backend/backend/index.js.map +1 -0
- package/dist/backend/backend/routes/contractRoutes.js +44 -0
- package/dist/backend/backend/routes/contractRoutes.js.map +1 -0
- package/dist/backend/backend/routes/devToolsRoutes.js +44 -0
- package/dist/backend/backend/routes/devToolsRoutes.js.map +1 -0
- package/dist/backend/backend/routes/etherscanRoutes.js +44 -0
- package/dist/backend/backend/routes/etherscanRoutes.js.map +1 -0
- package/dist/backend/backend/routes/historyRoutes.js +41 -0
- package/dist/backend/backend/routes/historyRoutes.js.map +1 -0
- package/dist/backend/backend/routes/keyringRoutes.js +18 -0
- package/dist/backend/backend/routes/keyringRoutes.js.map +1 -0
- package/dist/backend/backend/routes/licenseRoutes.js +30 -0
- package/dist/backend/backend/routes/licenseRoutes.js.map +1 -0
- package/dist/backend/backend/routes/robinhoodRoutes.js +14 -0
- package/dist/backend/backend/routes/robinhoodRoutes.js.map +1 -0
- package/dist/backend/backend/routes/runtimeRoutes.js +26 -0
- package/dist/backend/backend/routes/runtimeRoutes.js.map +1 -0
- package/dist/backend/backend/routes/safeRoutes.js +61 -0
- package/dist/backend/backend/routes/safeRoutes.js.map +1 -0
- package/dist/backend/backend/routes/sandboxRoutes.js +50 -0
- package/dist/backend/backend/routes/sandboxRoutes.js.map +1 -0
- package/dist/backend/backend/routes/settingsRoutes.js +10 -0
- package/dist/backend/backend/routes/settingsRoutes.js.map +1 -0
- package/dist/backend/backend/routes/walletRoutes.js +54 -0
- package/dist/backend/backend/routes/walletRoutes.js.map +1 -0
- package/dist/backend/backend/services/chainlinkService.js +48 -0
- package/dist/backend/backend/services/chainlinkService.js.map +1 -0
- package/dist/backend/backend/services/contractRegistryService.js +138 -0
- package/dist/backend/backend/services/contractRegistryService.js.map +1 -0
- package/dist/backend/backend/services/devToolsService.js +213 -0
- package/dist/backend/backend/services/devToolsService.js.map +1 -0
- package/dist/backend/backend/services/diagnosticsService.js +286 -0
- package/dist/backend/backend/services/diagnosticsService.js.map +1 -0
- package/dist/backend/backend/services/etherscanService.js +125 -0
- package/dist/backend/backend/services/etherscanService.js.map +1 -0
- package/dist/backend/backend/services/historyService.js +75 -0
- package/dist/backend/backend/services/historyService.js.map +1 -0
- package/dist/backend/backend/services/keyringAccessor.js +40 -0
- package/dist/backend/backend/services/keyringAccessor.js.map +1 -0
- package/dist/backend/backend/services/licenseService.js +130 -0
- package/dist/backend/backend/services/licenseService.js.map +1 -0
- package/dist/backend/backend/services/onchain/abiRegistry.js +47 -0
- package/dist/backend/backend/services/onchain/abiRegistry.js.map +1 -0
- package/dist/backend/backend/services/onchain/chainlinkClient.js +43 -0
- package/dist/backend/backend/services/onchain/chainlinkClient.js.map +1 -0
- package/dist/backend/backend/services/onchain/errors.js +13 -0
- package/dist/backend/backend/services/onchain/errors.js.map +1 -0
- package/dist/backend/backend/services/onchain/etherscanClient.js +82 -0
- package/dist/backend/backend/services/onchain/etherscanClient.js.map +1 -0
- package/dist/backend/backend/services/onchain/index.js +79 -0
- package/dist/backend/backend/services/onchain/index.js.map +1 -0
- package/dist/backend/backend/services/onchain/tenderlyRpcClient.js +60 -0
- package/dist/backend/backend/services/onchain/tenderlyRpcClient.js.map +1 -0
- package/dist/backend/backend/services/onchain/types.js +14 -0
- package/dist/backend/backend/services/onchain/types.js.map +1 -0
- package/dist/backend/backend/services/onchainAutomationService.js +316 -0
- package/dist/backend/backend/services/onchainAutomationService.js.map +1 -0
- package/dist/backend/backend/services/robinhood/auth.js +26 -0
- package/dist/backend/backend/services/robinhood/auth.js.map +1 -0
- package/dist/backend/backend/services/robinhood/client.js +73 -0
- package/dist/backend/backend/services/robinhood/client.js.map +1 -0
- package/dist/backend/backend/services/robinhood/integrationService.js +119 -0
- package/dist/backend/backend/services/robinhood/integrationService.js.map +1 -0
- package/dist/backend/backend/services/robinhood/provider.js +17 -0
- package/dist/backend/backend/services/robinhood/provider.js.map +1 -0
- package/dist/backend/backend/services/robinhood/unofficialClient.js +61 -0
- package/dist/backend/backend/services/robinhood/unofficialClient.js.map +1 -0
- package/dist/backend/backend/services/rpcService.js +48 -0
- package/dist/backend/backend/services/rpcService.js.map +1 -0
- package/dist/backend/backend/services/runtimeTelemetryService.js +96 -0
- package/dist/backend/backend/services/runtimeTelemetryService.js.map +1 -0
- package/dist/backend/backend/services/safeConfigRepository.js +147 -0
- package/dist/backend/backend/services/safeConfigRepository.js.map +1 -0
- package/dist/backend/backend/services/safeService.js +527 -0
- package/dist/backend/backend/services/safeService.js.map +1 -0
- package/dist/backend/backend/services/sandboxService.js +135 -0
- package/dist/backend/backend/services/sandboxService.js.map +1 -0
- package/dist/backend/backend/services/secureSettingsService.js +50 -0
- package/dist/backend/backend/services/secureSettingsService.js.map +1 -0
- package/dist/backend/backend/services/transactionHoldService.js +184 -0
- package/dist/backend/backend/services/transactionHoldService.js.map +1 -0
- package/dist/backend/backend/services/vanityService.js +235 -0
- package/dist/backend/backend/services/vanityService.js.map +1 -0
- package/dist/backend/backend/services/walletService.js +202 -0
- package/dist/backend/backend/services/walletService.js.map +1 -0
- package/dist/backend/backend/services/walletStore.js +132 -0
- package/dist/backend/backend/services/walletStore.js.map +1 -0
- package/dist/backend/backend/utils/abiResolver.js +182 -0
- package/dist/backend/backend/utils/abiResolver.js.map +1 -0
- package/dist/backend/backend/utils/http.js +12 -0
- package/dist/backend/backend/utils/http.js.map +1 -0
- package/dist/backend/backend/utils/secretsResolver.js +137 -0
- package/dist/backend/backend/utils/secretsResolver.js.map +1 -0
- package/dist/backend/backend/utils/signer.js +15 -0
- package/dist/backend/backend/utils/signer.js.map +1 -0
- package/dist/backend/backend/workers/vanityWorker.js +63 -0
- package/dist/backend/backend/workers/vanityWorker.js.map +1 -0
- package/dist/backend/cli/gnoman.js +387 -0
- package/dist/backend/cli/gnoman.js.map +1 -0
- package/dist/backend/modules/sandbox/abiLoader.js +78 -0
- package/dist/backend/modules/sandbox/abiLoader.js.map +1 -0
- package/dist/backend/modules/sandbox/contractSimulator.js +205 -0
- package/dist/backend/modules/sandbox/contractSimulator.js.map +1 -0
- package/dist/backend/modules/sandbox/formBuilder.js +14 -0
- package/dist/backend/modules/sandbox/formBuilder.js.map +1 -0
- package/dist/backend/modules/sandbox/index.js +24 -0
- package/dist/backend/modules/sandbox/index.js.map +1 -0
- package/dist/backend/modules/sandbox/localFork.js +103 -0
- package/dist/backend/modules/sandbox/localFork.js.map +1 -0
- package/dist/backend/modules/sandbox/sandboxManager.js +130 -0
- package/dist/backend/modules/sandbox/sandboxManager.js.map +1 -0
- package/dist/backend/modules/sandbox/types.js +3 -0
- package/dist/backend/modules/sandbox/types.js.map +1 -0
- package/dist/backend/src/core/backends/fileBackend.js +136 -0
- package/dist/backend/src/core/backends/fileBackend.js.map +1 -0
- package/dist/backend/src/core/backends/memoryBackend.js +26 -0
- package/dist/backend/src/core/backends/memoryBackend.js.map +1 -0
- package/dist/backend/src/core/backends/systemBackend.js +86 -0
- package/dist/backend/src/core/backends/systemBackend.js.map +1 -0
- package/dist/backend/src/core/backends/types.js +12 -0
- package/dist/backend/src/core/backends/types.js.map +1 -0
- package/dist/backend/src/core/keyringManager.js +178 -0
- package/dist/backend/src/core/keyringManager.js.map +1 -0
- package/dist/backend/src/utils/abiResolver.js +180 -0
- package/dist/backend/src/utils/abiResolver.js.map +1 -0
- package/dist/backend/src/utils/runtimeObservability.js +78 -0
- package/dist/backend/src/utils/runtimeObservability.js.map +1 -0
- package/dist/backend/src/utils/secretsResolver.js +138 -0
- package/dist/backend/src/utils/secretsResolver.js.map +1 -0
- package/dist/cli/backend/services/diagnosticsService.js +286 -0
- package/dist/cli/backend/services/diagnosticsService.js.map +1 -0
- package/dist/cli/backend/services/keyringAccessor.js +40 -0
- package/dist/cli/backend/services/keyringAccessor.js.map +1 -0
- package/dist/cli/backend/services/rpcService.js +48 -0
- package/dist/cli/backend/services/rpcService.js.map +1 -0
- package/dist/cli/backend/services/runtimeTelemetryService.js +96 -0
- package/dist/cli/backend/services/runtimeTelemetryService.js.map +1 -0
- package/dist/cli/backend/services/walletService.js +202 -0
- package/dist/cli/backend/services/walletService.js.map +1 -0
- package/dist/cli/backend/services/walletStore.js +132 -0
- package/dist/cli/backend/services/walletStore.js.map +1 -0
- package/dist/cli/backend/utils/http.js +12 -0
- package/dist/cli/backend/utils/http.js.map +1 -0
- package/dist/cli/backend/utils/secretsResolver.js +137 -0
- package/dist/cli/backend/utils/secretsResolver.js.map +1 -0
- package/dist/cli/cli/gnoman.js +387 -0
- package/dist/cli/cli/gnoman.js.map +1 -0
- package/dist/cli/src/core/backends/fileBackend.js +136 -0
- package/dist/cli/src/core/backends/fileBackend.js.map +1 -0
- package/dist/cli/src/core/backends/memoryBackend.js +26 -0
- package/dist/cli/src/core/backends/memoryBackend.js.map +1 -0
- package/dist/cli/src/core/backends/systemBackend.js +86 -0
- package/dist/cli/src/core/backends/systemBackend.js.map +1 -0
- package/dist/cli/src/core/backends/types.js +12 -0
- package/dist/cli/src/core/backends/types.js.map +1 -0
- package/dist/cli/src/core/keyringManager.js +178 -0
- package/dist/cli/src/core/keyringManager.js.map +1 -0
- package/dist/cli/src/utils/abiResolver.js +180 -0
- package/dist/cli/src/utils/abiResolver.js.map +1 -0
- package/dist/cli/src/utils/runtimeObservability.js +78 -0
- package/dist/cli/src/utils/runtimeObservability.js.map +1 -0
- package/dist/cli/src/utils/secretsResolver.js +138 -0
- package/dist/cli/src/utils/secretsResolver.js.map +1 -0
- package/dist/main/backend/services/keyringAccessor.js +40 -0
- package/dist/main/backend/services/keyringAccessor.js.map +1 -0
- package/dist/main/backend/utils/http.js +12 -0
- package/dist/main/backend/utils/http.js.map +1 -0
- package/dist/main/main/ipcHandlers/index.js +26 -0
- package/dist/main/main/ipcHandlers/index.js.map +1 -0
- package/dist/main/main/keyring/keyringmanager.js +101 -0
- package/dist/main/main/keyring/keyringmanager.js.map +1 -0
- package/dist/main/main/main.js +224 -0
- package/dist/main/main/main.js.map +1 -0
- package/dist/main/main/preload/index.js +19 -0
- package/dist/main/main/preload/index.js.map +1 -0
- package/dist/main/main/preload/licenseBridge.js +105 -0
- package/dist/main/main/preload/licenseBridge.js.map +1 -0
- package/dist/main/src/core/backends/fileBackend.js +136 -0
- package/dist/main/src/core/backends/fileBackend.js.map +1 -0
- package/dist/main/src/core/backends/memoryBackend.js +26 -0
- package/dist/main/src/core/backends/memoryBackend.js.map +1 -0
- package/dist/main/src/core/backends/systemBackend.js +86 -0
- package/dist/main/src/core/backends/systemBackend.js.map +1 -0
- package/dist/main/src/core/backends/types.js +12 -0
- package/dist/main/src/core/backends/types.js.map +1 -0
- package/dist/main/src/core/keyringManager.js +178 -0
- package/dist/main/src/core/keyringManager.js.map +1 -0
- package/dist/main/src/utils/abiResolver.js +180 -0
- package/dist/main/src/utils/abiResolver.js.map +1 -0
- package/dist/main/src/utils/runtimeObservability.js +78 -0
- package/dist/main/src/utils/runtimeObservability.js.map +1 -0
- package/dist/main/src/utils/secretsResolver.js +138 -0
- package/dist/main/src/utils/secretsResolver.js.map +1 -0
- package/docs/development-guide.md +203 -0
- package/docs/etherscan-chainlink-integration.md +44 -0
- package/docs/gnoman-20-user-manual-STANDARD-PRINT-READY.pdf +0 -0
- package/docs/gnoman-20-user-manual-STANDARD.pdf +0 -0
- package/docs/license-dev-guide.md +106 -0
- package/docs/robinhood-integration.md +30 -0
- package/docs/system-audit-gpt-guide.md +208 -0
- package/docs/system-robustness-audit.md +50 -0
- package/docs/user-guide.md +73 -0
- package/docs/wiki/development-guide.md +203 -0
- package/docs/wiki/license-dev-guide.md +106 -0
- package/docs/wiki/user-guide.md +73 -0
- package/eslint.config.js +85 -0
- package/gnoman2.0/.eslintrc.cjs +24 -0
- package/gnoman2.0/.prettierrc.json +6 -0
- package/gnoman2.0/CODex_TASKS.md +124 -0
- package/gnoman2.0/LICENSE.md +164 -0
- package/gnoman2.0/README.md +95 -0
- package/gnoman2.0/assets/GnoLogo.jpg +0 -0
- package/gnoman2.0/assets/self.png +0 -0
- package/gnoman2.0/backend/controllers/contractController.ts +49 -0
- package/gnoman2.0/backend/controllers/devToolsController.ts +76 -0
- package/gnoman2.0/backend/controllers/etherscanController.ts +59 -0
- package/gnoman2.0/backend/controllers/historyController.ts +7 -0
- package/gnoman2.0/backend/controllers/keyringController.ts +134 -0
- package/gnoman2.0/backend/controllers/robinhoodController.ts +80 -0
- package/gnoman2.0/backend/controllers/safeController.ts +167 -0
- package/gnoman2.0/backend/controllers/sandboxController.ts +63 -0
- package/gnoman2.0/backend/controllers/settingsController.ts +38 -0
- package/gnoman2.0/backend/controllers/walletController.ts +151 -0
- package/gnoman2.0/backend/index.ts +133 -0
- package/gnoman2.0/backend/licenses/license_public.pem +3 -0
- package/gnoman2.0/backend/licenses/verify_license.py +43 -0
- package/gnoman2.0/backend/routes/contractRoutes.ts +11 -0
- package/gnoman2.0/backend/routes/devToolsRoutes.ts +11 -0
- package/gnoman2.0/backend/routes/etherscanRoutes.ts +11 -0
- package/gnoman2.0/backend/routes/historyRoutes.ts +8 -0
- package/gnoman2.0/backend/routes/keyringRoutes.ts +25 -0
- package/gnoman2.0/backend/routes/licenseRoutes.ts +35 -0
- package/gnoman2.0/backend/routes/robinhoodRoutes.ts +22 -0
- package/gnoman2.0/backend/routes/runtimeRoutes.ts +29 -0
- package/gnoman2.0/backend/routes/safeRoutes.ts +28 -0
- package/gnoman2.0/backend/routes/sandboxRoutes.ts +17 -0
- package/gnoman2.0/backend/routes/settingsRoutes.ts +14 -0
- package/gnoman2.0/backend/routes/walletRoutes.ts +21 -0
- package/gnoman2.0/backend/services/chainlinkService.ts +65 -0
- package/gnoman2.0/backend/services/contractRegistryService.ts +205 -0
- package/gnoman2.0/backend/services/devToolsService.ts +251 -0
- package/gnoman2.0/backend/services/diagnosticsService.ts +350 -0
- package/gnoman2.0/backend/services/etherscanService.ts +152 -0
- package/gnoman2.0/backend/services/historyService.ts +89 -0
- package/gnoman2.0/backend/services/keyringAccessor.ts +4 -0
- package/gnoman2.0/backend/services/licenseService.ts +163 -0
- package/gnoman2.0/backend/services/onchain/abiRegistry.ts +57 -0
- package/gnoman2.0/backend/services/onchain/chainlinkClient.ts +56 -0
- package/gnoman2.0/backend/services/onchain/errors.ts +16 -0
- package/gnoman2.0/backend/services/onchain/etherscanClient.ts +94 -0
- package/gnoman2.0/backend/services/onchain/index.ts +76 -0
- package/gnoman2.0/backend/services/onchain/tenderlyRpcClient.ts +74 -0
- package/gnoman2.0/backend/services/onchain/types.ts +33 -0
- package/gnoman2.0/backend/services/onchainAutomationService.ts +424 -0
- package/gnoman2.0/backend/services/robinhood/auth.ts +42 -0
- package/gnoman2.0/backend/services/robinhood/client.ts +123 -0
- package/gnoman2.0/backend/services/robinhood/integrationService.ts +140 -0
- package/gnoman2.0/backend/services/robinhood/provider.ts +22 -0
- package/gnoman2.0/backend/services/robinhood/unofficialClient.ts +66 -0
- package/gnoman2.0/backend/services/rpcService.ts +44 -0
- package/gnoman2.0/backend/services/runtimeTelemetryService.ts +158 -0
- package/gnoman2.0/backend/services/safeConfigRepository.ts +205 -0
- package/gnoman2.0/backend/services/safeService.ts +588 -0
- package/gnoman2.0/backend/services/sandboxService.ts +157 -0
- package/gnoman2.0/backend/services/secureSettingsService.ts +45 -0
- package/gnoman2.0/backend/services/transactionHoldService.ts +223 -0
- package/gnoman2.0/backend/services/vanityService.ts +293 -0
- package/gnoman2.0/backend/services/walletService.ts +290 -0
- package/gnoman2.0/backend/services/walletStore.ts +179 -0
- package/gnoman2.0/backend/types/express-async-handler.d.ts +13 -0
- package/gnoman2.0/backend/types/keyring.d.ts +19 -0
- package/gnoman2.0/backend/utils/abiResolver.ts +208 -0
- package/gnoman2.0/backend/utils/http.ts +6 -0
- package/gnoman2.0/backend/utils/secretsResolver.ts +150 -0
- package/gnoman2.0/backend/utils/signer.ts +11 -0
- package/gnoman2.0/backend/workers/vanityWorker.ts +76 -0
- package/gnoman2.0/capacitor.config.ts +13 -0
- package/gnoman2.0/cli/gnoman.ts +424 -0
- package/gnoman2.0/contracts/OracleConsumer.sol +20 -0
- package/gnoman2.0/contracts/PriceFeedConsumer.sol +22 -0
- package/gnoman2.0/docs/development-guide.md +203 -0
- package/gnoman2.0/docs/etherscan-chainlink-integration.md +44 -0
- package/gnoman2.0/docs/gnoman-20-user-manual-STANDARD-PRINT-READY.pdf +0 -0
- package/gnoman2.0/docs/gnoman-20-user-manual-STANDARD.pdf +0 -0
- package/gnoman2.0/docs/license-dev-guide.md +106 -0
- package/gnoman2.0/docs/robinhood-integration.md +30 -0
- package/gnoman2.0/docs/system-audit-gpt-guide.md +208 -0
- package/gnoman2.0/docs/system-robustness-audit.md +50 -0
- package/gnoman2.0/docs/user-guide.md +73 -0
- package/gnoman2.0/docs/wiki/development-guide.md +203 -0
- package/gnoman2.0/docs/wiki/license-dev-guide.md +106 -0
- package/gnoman2.0/docs/wiki/user-guide.md +73 -0
- package/gnoman2.0/eslint.config.js +85 -0
- package/gnoman2.0/gnomon/__init__.py +0 -0
- package/gnoman2.0/gnomon/api/__init__.py +0 -0
- package/gnoman2.0/gnomon/api/etherscan_tracker.py +72 -0
- package/gnoman2.0/gnomon/core/__init__.py +0 -0
- package/gnoman2.0/gnomon/core/safe_manager.py +111 -0
- package/gnoman2.0/gnomon/tests/test_abi_resolver.py +181 -0
- package/gnoman2.0/gnomon/tests/test_safe_persistence_and_etherscan.py +97 -0
- package/gnoman2.0/gnomon/utils/__init__.py +5 -0
- package/gnoman2.0/gnomon/utils/abi_resolver.py +255 -0
- package/gnoman2.0/ios/ExportOptions.plist +16 -0
- package/gnoman2.0/ios/README.md +33 -0
- package/gnoman2.0/jest.config.ts +18 -0
- package/gnoman2.0/keyring/__init__.py +17 -0
- package/gnoman2.0/licensingServer/package.json +23 -0
- package/gnoman2.0/licensingServer/src/config/keys.ts +84 -0
- package/gnoman2.0/licensingServer/src/index.ts +30 -0
- package/gnoman2.0/licensingServer/src/lib/canonicalize.ts +5 -0
- package/gnoman2.0/licensingServer/src/lib/crypto.ts +25 -0
- package/gnoman2.0/licensingServer/src/lib/validate.ts +62 -0
- package/gnoman2.0/licensingServer/src/middleware/auth.ts +20 -0
- package/gnoman2.0/licensingServer/src/routes/licenses.ts +110 -0
- package/gnoman2.0/licensingServer/tsconfig.json +12 -0
- package/gnoman2.0/main/ipcHandlers/index.ts +23 -0
- package/gnoman2.0/main/keyring/keyringmanager.ts +154 -0
- package/gnoman2.0/main/main.ts +234 -0
- package/gnoman2.0/main/preload/index.ts +31 -0
- package/gnoman2.0/main/preload/licenseBridge.ts +73 -0
- package/gnoman2.0/modules/sandbox/abiLoader.ts +78 -0
- package/gnoman2.0/modules/sandbox/contractSimulator.ts +241 -0
- package/gnoman2.0/modules/sandbox/formBuilder.ts +16 -0
- package/gnoman2.0/modules/sandbox/index.ts +6 -0
- package/gnoman2.0/modules/sandbox/localFork.ts +129 -0
- package/gnoman2.0/modules/sandbox/safe.abi.json +82 -0
- package/gnoman2.0/modules/sandbox/sandboxManager.ts +154 -0
- package/gnoman2.0/modules/sandbox/types.ts +84 -0
- package/gnoman2.0/modules/sandbox/ui/LogViewer.tsx +30 -0
- package/gnoman2.0/modules/sandbox/ui/ParameterForm.tsx +49 -0
- package/gnoman2.0/modules/sandbox/ui/SandboxPanel.tsx +568 -0
- package/gnoman2.0/package-lock.json +10904 -0
- package/gnoman2.0/package.json +82 -0
- package/gnoman2.0/renderer/components/LicenseScreen.tsx +134 -0
- package/gnoman2.0/renderer/index.html +12 -0
- package/gnoman2.0/renderer/package-lock.json +4104 -0
- package/gnoman2.0/renderer/package.json +35 -0
- package/gnoman2.0/renderer/postcss.config.cjs +6 -0
- package/gnoman2.0/renderer/src/App.tsx +229 -0
- package/gnoman2.0/renderer/src/context/KeyringContext.tsx +217 -0
- package/gnoman2.0/renderer/src/context/SafeContext.tsx +49 -0
- package/gnoman2.0/renderer/src/context/ThemeContext.tsx +60 -0
- package/gnoman2.0/renderer/src/context/WalletContext.tsx +50 -0
- package/gnoman2.0/renderer/src/context/main.tsx +18 -0
- package/gnoman2.0/renderer/src/main.tsx +18 -0
- package/gnoman2.0/renderer/src/pages/Contracts.tsx +482 -0
- package/gnoman2.0/renderer/src/pages/Dashboard.tsx +653 -0
- package/gnoman2.0/renderer/src/pages/DeveloperTools.tsx +270 -0
- package/gnoman2.0/renderer/src/pages/History.tsx +149 -0
- package/gnoman2.0/renderer/src/pages/Keyring.tsx +449 -0
- package/gnoman2.0/renderer/src/pages/Safes.tsx +1089 -0
- package/gnoman2.0/renderer/src/pages/Sandbox.tsx +146 -0
- package/gnoman2.0/renderer/src/pages/Settings.tsx +871 -0
- package/gnoman2.0/renderer/src/pages/Wallets.tsx +752 -0
- package/gnoman2.0/renderer/src/pages/WikiGuide.tsx +75 -0
- package/gnoman2.0/renderer/src/styles.css +32 -0
- package/gnoman2.0/renderer/src/types/gnoman.d.ts +9 -0
- package/gnoman2.0/renderer/src/types/license.ts +8 -0
- package/gnoman2.0/renderer/src/types/safevault.d.ts +17 -0
- package/gnoman2.0/renderer/src/utils/backend.ts +88 -0
- package/gnoman2.0/renderer/tailwind.config.cjs +8 -0
- package/gnoman2.0/renderer/tsconfig.json +13 -0
- package/gnoman2.0/renderer/tsconfig.node.json +9 -0
- package/gnoman2.0/renderer/vite.config.ts +19 -0
- package/gnoman2.0/requests/__init__.py +35 -0
- package/gnoman2.0/scripts/build-ios.sh +30 -0
- package/gnoman2.0/scripts/copyBackendAssets.js +24 -0
- package/gnoman2.0/scripts/copyRenderer.js +87 -0
- package/gnoman2.0/scripts/launchElectron.js +51 -0
- package/gnoman2.0/src/core/backends/fileBackend.ts +154 -0
- package/gnoman2.0/src/core/backends/memoryBackend.ts +27 -0
- package/gnoman2.0/src/core/backends/systemBackend.ts +66 -0
- package/gnoman2.0/src/core/backends/types.ts +17 -0
- package/gnoman2.0/src/core/keyringManager.ts +208 -0
- package/gnoman2.0/src/utils/abiCache/.gitkeep +0 -0
- package/gnoman2.0/src/utils/abiResolver.ts +200 -0
- package/gnoman2.0/src/utils/runtimeObservability.ts +110 -0
- package/gnoman2.0/src/utils/secretsResolver.ts +144 -0
- package/gnoman2.0/tests/chainlinkService.test.ts +32 -0
- package/gnoman2.0/tests/diagnosticsService.test.ts +68 -0
- package/gnoman2.0/tests/etherscanController.test.ts +99 -0
- package/gnoman2.0/tests/etherscanService.test.ts +116 -0
- package/gnoman2.0/tests/keyringManager.test.ts +135 -0
- package/gnoman2.0/tests/onchainToolkit.test.ts +71 -0
- package/gnoman2.0/tests/robinhoodClient.test.ts +54 -0
- package/gnoman2.0/tests/robinhoodController.test.ts +81 -0
- package/gnoman2.0/tests/robinhoodIntegrationService.test.ts +50 -0
- package/gnoman2.0/tests/safeServicePersistence.test.ts +81 -0
- package/gnoman2.0/tests/test_contract_sandbox/sandbox.test.js +407 -0
- package/gnoman2.0/tests/walletController.test.ts +57 -0
- package/gnoman2.0/tsconfig.backend.json +7 -0
- package/gnoman2.0/tsconfig.cli.json +7 -0
- package/gnoman2.0/tsconfig.json +18 -0
- package/gnoman2.0/tsconfig.main.json +7 -0
- package/gnomon/__init__.py +0 -0
- package/gnomon/__pycache__/__init__.cpython-310.pyc +0 -0
- package/gnomon/api/__init__.py +0 -0
- package/gnomon/api/__pycache__/__init__.cpython-310.pyc +0 -0
- package/gnomon/api/__pycache__/etherscan_tracker.cpython-310.pyc +0 -0
- package/gnomon/api/etherscan_tracker.py +72 -0
- package/gnomon/core/__init__.py +0 -0
- package/gnomon/core/safe_manager.py +111 -0
- package/gnomon/tests/__pycache__/test_safe_persistence_and_etherscan.cpython-310-pytest-8.3.3.pyc +0 -0
- package/gnomon/tests/test_abi_resolver.py +181 -0
- package/gnomon/tests/test_safe_persistence_and_etherscan.py +97 -0
- package/gnomon/utils/__init__.py +5 -0
- package/gnomon/utils/abi_resolver.py +255 -0
- package/ios/ExportOptions.plist +16 -0
- package/ios/README.md +33 -0
- package/jest.config.ts +18 -0
- package/keyring/__init__.py +17 -0
- package/launcher.sh +57 -0
- package/license.env +2 -0
- package/licensingServer/package.json +23 -0
- package/licensingServer/src/config/keys.ts +84 -0
- package/licensingServer/src/index.ts +30 -0
- package/licensingServer/src/lib/canonicalize.ts +5 -0
- package/licensingServer/src/lib/crypto.ts +25 -0
- package/licensingServer/src/lib/validate.ts +62 -0
- package/licensingServer/src/middleware/auth.ts +20 -0
- package/licensingServer/src/routes/licenses.ts +110 -0
- package/licensingServer/tsconfig.json +12 -0
- package/main/ipcHandlers/index.ts +23 -0
- package/main/keyring/keyringmanager.ts +154 -0
- package/main/main.ts +234 -0
- package/main/preload/index.ts +31 -0
- package/main/preload/licenseBridge.ts +73 -0
- package/modules/sandbox/abiLoader.ts +78 -0
- package/modules/sandbox/contractSimulator.ts +241 -0
- package/modules/sandbox/formBuilder.ts +16 -0
- package/modules/sandbox/index.ts +6 -0
- package/modules/sandbox/localFork.ts +129 -0
- package/modules/sandbox/safe.abi.json +82 -0
- package/modules/sandbox/sandboxManager.ts +154 -0
- package/modules/sandbox/types.ts +84 -0
- package/modules/sandbox/ui/LogViewer.tsx +30 -0
- package/modules/sandbox/ui/ParameterForm.tsx +49 -0
- package/modules/sandbox/ui/SandboxPanel.tsx +568 -0
- package/package.json +82 -0
- package/renderer/components/LicenseScreen.tsx +134 -0
- package/renderer/index.html +12 -0
- package/renderer/package-lock.json +4104 -0
- package/renderer/package.json +35 -0
- package/renderer/postcss.config.cjs +6 -0
- package/renderer/src/App.tsx +229 -0
- package/renderer/src/context/KeyringContext.tsx +217 -0
- package/renderer/src/context/SafeContext.tsx +49 -0
- package/renderer/src/context/ThemeContext.tsx +60 -0
- package/renderer/src/context/WalletContext.tsx +50 -0
- package/renderer/src/context/main.tsx +18 -0
- package/renderer/src/main.tsx +18 -0
- package/renderer/src/pages/Contracts.tsx +482 -0
- package/renderer/src/pages/Dashboard.tsx +653 -0
- package/renderer/src/pages/DeveloperTools.tsx +270 -0
- package/renderer/src/pages/History.tsx +149 -0
- package/renderer/src/pages/Keyring.tsx +449 -0
- package/renderer/src/pages/Safes.tsx +1089 -0
- package/renderer/src/pages/Sandbox.tsx +146 -0
- package/renderer/src/pages/Settings.tsx +871 -0
- package/renderer/src/pages/Wallets.tsx +752 -0
- package/renderer/src/pages/WikiGuide.tsx +75 -0
- package/renderer/src/styles.css +32 -0
- package/renderer/src/types/gnoman.d.ts +9 -0
- package/renderer/src/types/license.ts +8 -0
- package/renderer/src/types/safevault.d.ts +17 -0
- package/renderer/src/utils/backend.ts +88 -0
- package/renderer/tailwind.config.cjs +8 -0
- package/renderer/tsconfig.json +13 -0
- package/renderer/tsconfig.node.json +9 -0
- package/renderer/vite.config.ts +19 -0
- package/requests/__init__.py +35 -0
- package/requests/__pycache__/__init__.cpython-310.pyc +0 -0
- package/scripts/build-ios.sh +30 -0
- package/scripts/copyBackendAssets.js +24 -0
- package/scripts/copyRenderer.js +87 -0
- package/scripts/deployBackend.sh +24 -0
- package/scripts/launchElectron.js +51 -0
- package/src/core/backends/fileBackend.ts +154 -0
- package/src/core/backends/memoryBackend.ts +27 -0
- package/src/core/backends/systemBackend.ts +66 -0
- package/src/core/backends/types.ts +17 -0
- package/src/core/keyringManager.ts +208 -0
- package/src/utils/abiCache/.gitkeep +0 -0
- package/src/utils/abiResolver.ts +200 -0
- package/src/utils/runtimeObservability.ts +110 -0
- package/src/utils/secretsResolver.ts +144 -0
- package/tests/chainlinkService.test.ts +32 -0
- package/tests/diagnosticsService.test.ts +68 -0
- package/tests/etherscanController.test.ts +99 -0
- package/tests/etherscanService.test.ts +116 -0
- package/tests/keyringManager.test.ts +135 -0
- package/tests/onchainToolkit.test.ts +71 -0
- package/tests/robinhoodClient.test.ts +54 -0
- package/tests/robinhoodController.test.ts +81 -0
- package/tests/robinhoodIntegrationService.test.ts +50 -0
- package/tests/safeServicePersistence.test.ts +81 -0
- package/tests/test_contract_sandbox/sandbox.test.js +407 -0
- package/tests/walletController.test.ts +57 -0
- package/touch +14 -0
- package/tsconfig.backend.json +7 -0
- package/tsconfig.cli.json +7 -0
- package/tsconfig.json +18 -0
- package/tsconfig.main.json +7 -0
- package/webhook-shim.js +50 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { FileBackend } from '../core/backends/fileBackend';
|
|
4
|
+
import keyringAccessor from '../../backend/services/keyringAccessor';
|
|
5
|
+
import { runtimeObservability, type SecretAuditRecord } from './runtimeObservability';
|
|
6
|
+
|
|
7
|
+
export type SecretSource = 'env' | 'dotenv' | 'file' | 'keyring' | 'missing';
|
|
8
|
+
|
|
9
|
+
const bootEnvKeys = new Set(Object.keys(process.env));
|
|
10
|
+
let dotenvLoaded = false;
|
|
11
|
+
let fileBackend: FileBackend | null = null;
|
|
12
|
+
let fileSecrets = new Map<string, string>();
|
|
13
|
+
|
|
14
|
+
const GUI_KEYRING_ALLOWED = Boolean(process.env.DISPLAY && process.env.DBUS_SESSION_BUS_ADDRESS);
|
|
15
|
+
|
|
16
|
+
const redact = (value: string | undefined) => {
|
|
17
|
+
if (!value) {
|
|
18
|
+
return 'MISSING';
|
|
19
|
+
}
|
|
20
|
+
const trimmed = value.trim();
|
|
21
|
+
if (trimmed.length <= 4) {
|
|
22
|
+
return '****';
|
|
23
|
+
}
|
|
24
|
+
return `****${trimmed.slice(-4)}`;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const loadDotenvFile = () => {
|
|
28
|
+
const envPath = path.join(process.cwd(), '.env');
|
|
29
|
+
if (!fs.existsSync(envPath)) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const raw = fs.readFileSync(envPath, 'utf8');
|
|
33
|
+
for (const line of raw.split(/\r?\n/)) {
|
|
34
|
+
const trimmed = line.trim();
|
|
35
|
+
if (!trimmed || trimmed.startsWith('#')) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
const eq = trimmed.indexOf('=');
|
|
39
|
+
if (eq === -1) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
const key = trimmed.slice(0, eq).trim();
|
|
43
|
+
const value = trimmed.slice(eq + 1).trim().replace(/^['"]|['"]$/g, '');
|
|
44
|
+
if (!(key in process.env)) {
|
|
45
|
+
process.env[key] = value;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const ensureDotenvLoaded = () => {
|
|
51
|
+
if (dotenvLoaded) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
loadDotenvFile();
|
|
55
|
+
dotenvLoaded = true;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const ensureFileSecretsLoaded = async () => {
|
|
59
|
+
if (fileBackend) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const filePath = process.env.GNOMAN_KEYRING_FILE ?? path.join(process.cwd(), '.gnoman', 'secrets.enc');
|
|
63
|
+
fileBackend = new FileBackend(filePath);
|
|
64
|
+
try {
|
|
65
|
+
await fileBackend.initialize();
|
|
66
|
+
const listed = await fileBackend.list();
|
|
67
|
+
fileSecrets = new Map(Object.entries(listed));
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.error(JSON.stringify({ event: 'FILE_SECRET_BACKEND_ERROR', message: String(error) }));
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const detectEnvSource = (key: string): SecretSource | null => {
|
|
74
|
+
const value = process.env[key];
|
|
75
|
+
if (!value?.trim()) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
return bootEnvKeys.has(key) ? 'env' : 'dotenv';
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const resolveSecret = async (key: string, required = false) => {
|
|
82
|
+
ensureDotenvLoaded();
|
|
83
|
+
await ensureFileSecretsLoaded();
|
|
84
|
+
const checkedSources = ['env', 'dotenv', 'file'];
|
|
85
|
+
|
|
86
|
+
const envSource = detectEnvSource(key);
|
|
87
|
+
if (envSource) {
|
|
88
|
+
return { value: process.env[key]!.trim(), source: envSource, checkedSources };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const fileValue = fileSecrets.get(key)?.trim();
|
|
92
|
+
if (fileValue) {
|
|
93
|
+
return { value: fileValue, source: 'file' as const, checkedSources };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (GUI_KEYRING_ALLOWED) {
|
|
97
|
+
checkedSources.push('keyring');
|
|
98
|
+
try {
|
|
99
|
+
const keyringValue = await keyringAccessor.get(key);
|
|
100
|
+
if (keyringValue?.trim()) {
|
|
101
|
+
return { value: keyringValue.trim(), source: 'keyring' as const, checkedSources };
|
|
102
|
+
}
|
|
103
|
+
} catch (error) {
|
|
104
|
+
console.warn(`Unable to resolve ${key} from keyring`, error);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const missing = { event: 'MISSING_SECRET', key, checkedSources };
|
|
109
|
+
console.error(JSON.stringify(missing));
|
|
110
|
+
if (required) {
|
|
111
|
+
throw new Error(`${key} is required for this run mode.`);
|
|
112
|
+
}
|
|
113
|
+
return { value: undefined, source: 'missing' as const, checkedSources };
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export const auditSecretsAtBoot = async (keys: Array<{ key: string; required: boolean }>) => {
|
|
117
|
+
ensureDotenvLoaded();
|
|
118
|
+
await ensureFileSecretsLoaded();
|
|
119
|
+
const records: SecretAuditRecord[] = [];
|
|
120
|
+
for (const { key, required } of keys) {
|
|
121
|
+
const resolved = await resolveSecret(key, false);
|
|
122
|
+
records.push({
|
|
123
|
+
key,
|
|
124
|
+
required,
|
|
125
|
+
present: Boolean(resolved.value),
|
|
126
|
+
source: resolved.source,
|
|
127
|
+
redacted: redact(resolved.value),
|
|
128
|
+
checkedSources: resolved.checkedSources
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
runtimeObservability.setSecretAudit(records);
|
|
132
|
+
console.info(
|
|
133
|
+
JSON.stringify({
|
|
134
|
+
event: 'SECRETS_AUDIT',
|
|
135
|
+
secrets: records.map((r) => ({
|
|
136
|
+
key: r.key,
|
|
137
|
+
required: r.required,
|
|
138
|
+
present: r.present,
|
|
139
|
+
source: r.source,
|
|
140
|
+
value: r.redacted
|
|
141
|
+
}))
|
|
142
|
+
})
|
|
143
|
+
);
|
|
144
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { getChainlinkRuntimeConfig } from '../backend/services/chainlinkService';
|
|
2
|
+
|
|
3
|
+
describe('chainlinkService config validation', () => {
|
|
4
|
+
const env = { ...process.env };
|
|
5
|
+
|
|
6
|
+
afterEach(() => {
|
|
7
|
+
process.env = { ...env };
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('validates required chainlink runtime config', () => {
|
|
11
|
+
process.env.CHAINLINK_NODE_URL = 'https://node.example';
|
|
12
|
+
process.env.CHAINLINK_JOB_ID = 'job-123';
|
|
13
|
+
process.env.CHAINLINK_OPERATOR_ADDRESS = '0x1111111111111111111111111111111111111111';
|
|
14
|
+
process.env.CHAINLINK_LINK_TOKEN = '0x2222222222222222222222222222222222222222';
|
|
15
|
+
|
|
16
|
+
const config = getChainlinkRuntimeConfig();
|
|
17
|
+
|
|
18
|
+
expect(config.nodeUrl).toBe('https://node.example');
|
|
19
|
+
expect(config.jobId).toBe('job-123');
|
|
20
|
+
expect(config.operatorAddress).toBe('0x1111111111111111111111111111111111111111');
|
|
21
|
+
expect(config.linkToken).toBe('0x2222222222222222222222222222222222222222');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('throws on invalid operator address', () => {
|
|
25
|
+
process.env.CHAINLINK_NODE_URL = 'https://node.example';
|
|
26
|
+
process.env.CHAINLINK_JOB_ID = 'job-123';
|
|
27
|
+
process.env.CHAINLINK_OPERATOR_ADDRESS = 'not-an-address';
|
|
28
|
+
process.env.CHAINLINK_LINK_TOKEN = '0x2222222222222222222222222222222222222222';
|
|
29
|
+
|
|
30
|
+
expect(() => getChainlinkRuntimeConfig()).toThrow('CHAINLINK_OPERATOR_ADDRESS is not a valid Ethereum address');
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { runSystemDiagnostics } from '../backend/services/diagnosticsService';
|
|
4
|
+
|
|
5
|
+
describe('runSystemDiagnostics', () => {
|
|
6
|
+
const logsPath = path.join(process.cwd(), 'logs');
|
|
7
|
+
const safevaultPath = path.join(process.cwd(), '.safevault');
|
|
8
|
+
let removeLogs = false;
|
|
9
|
+
let removeSafevault = false;
|
|
10
|
+
|
|
11
|
+
beforeAll(async () => {
|
|
12
|
+
removeLogs = await fs
|
|
13
|
+
.access(logsPath)
|
|
14
|
+
.then(() => false)
|
|
15
|
+
.catch(() => true);
|
|
16
|
+
removeSafevault = await fs
|
|
17
|
+
.access(safevaultPath)
|
|
18
|
+
.then(() => false)
|
|
19
|
+
.catch(() => true);
|
|
20
|
+
if (removeLogs) {
|
|
21
|
+
await fs.rm(logsPath, { recursive: true, force: true });
|
|
22
|
+
}
|
|
23
|
+
if (removeSafevault) {
|
|
24
|
+
await fs.rm(safevaultPath, { recursive: true, force: true });
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
afterAll(async () => {
|
|
29
|
+
if (removeLogs) {
|
|
30
|
+
await fs.rm(logsPath, { recursive: true, force: true });
|
|
31
|
+
}
|
|
32
|
+
if (removeSafevault) {
|
|
33
|
+
await fs.rm(safevaultPath, { recursive: true, force: true });
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('produces a consistent report snapshot', async () => {
|
|
38
|
+
const report = await runSystemDiagnostics({ skipGpg: true });
|
|
39
|
+
expect(report.generatedAt).toEqual(expect.any(String));
|
|
40
|
+
expect(report.environment.cwd).toBe(process.cwd());
|
|
41
|
+
expect(report.summary.total).toBe(report.checks.length);
|
|
42
|
+
|
|
43
|
+
const nodeCheck = report.checks.find((check) => check.id === 'node-version');
|
|
44
|
+
expect(nodeCheck).toBeDefined();
|
|
45
|
+
expect(nodeCheck?.metadata).toEqual(
|
|
46
|
+
expect.objectContaining({ current: process.version })
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
const walletCheck = report.checks.find((check) => check.id === 'wallet-inventory');
|
|
50
|
+
expect(walletCheck).toBeDefined();
|
|
51
|
+
expect(walletCheck?.metadata).toEqual(
|
|
52
|
+
expect.objectContaining({ count: expect.any(Number) })
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
const keyringChecks = report.checks.filter((check) => check.id.startsWith('keyring-'));
|
|
56
|
+
expect(keyringChecks.map((check) => check.id)).toEqual(
|
|
57
|
+
expect.arrayContaining(['keyring-system', 'keyring-file', 'keyring-memory'])
|
|
58
|
+
);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('auto-fix mode creates the logs directory', async () => {
|
|
62
|
+
await fs.rm(logsPath, { recursive: true, force: true });
|
|
63
|
+
const report = await runSystemDiagnostics({ autoFix: true, skipGpg: true });
|
|
64
|
+
const logsCheck = report.checks.find((check) => check.id === 'logs-dir');
|
|
65
|
+
expect(logsCheck?.status).toBe('ok');
|
|
66
|
+
await expect(fs.stat(logsPath)).resolves.toBeDefined();
|
|
67
|
+
});
|
|
68
|
+
});
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { Request, Response } from 'express';
|
|
2
|
+
|
|
3
|
+
jest.mock('../backend/services/etherscanService', () => ({
|
|
4
|
+
resolveAbiByAddress: jest.fn(async () => [{ type: 'function', name: 'transfer' }]),
|
|
5
|
+
resolveAbiFileForAddress: jest.fn(async () => '/tmp/abi/address/1/0xabc.json'),
|
|
6
|
+
getTxHistory: jest.fn(async () => ({ status: '1', result: [{ hash: '0x1' }] })),
|
|
7
|
+
getGasOracle: jest.fn(async () => ({ status: '1', result: { SafeGasPrice: '10' } }))
|
|
8
|
+
}));
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
getAddressTxHistory,
|
|
12
|
+
getCurrentGasOracle,
|
|
13
|
+
resolveContractAbi,
|
|
14
|
+
resolveContractAbiFile
|
|
15
|
+
} from '../backend/controllers/etherscanController';
|
|
16
|
+
import {
|
|
17
|
+
getGasOracle,
|
|
18
|
+
getTxHistory,
|
|
19
|
+
resolveAbiByAddress,
|
|
20
|
+
resolveAbiFileForAddress
|
|
21
|
+
} from '../backend/services/etherscanService';
|
|
22
|
+
|
|
23
|
+
const mockedResolveAbiByAddress = resolveAbiByAddress as jest.MockedFunction<typeof resolveAbiByAddress>;
|
|
24
|
+
const mockedResolveAbiFileForAddress =
|
|
25
|
+
resolveAbiFileForAddress as jest.MockedFunction<typeof resolveAbiFileForAddress>;
|
|
26
|
+
const mockedGetTxHistory = getTxHistory as jest.MockedFunction<typeof getTxHistory>;
|
|
27
|
+
const mockedGetGasOracle = getGasOracle as jest.MockedFunction<typeof getGasOracle>;
|
|
28
|
+
|
|
29
|
+
describe('etherscanController', () => {
|
|
30
|
+
afterEach(() => {
|
|
31
|
+
mockedResolveAbiByAddress.mockClear();
|
|
32
|
+
mockedResolveAbiFileForAddress.mockClear();
|
|
33
|
+
mockedGetTxHistory.mockClear();
|
|
34
|
+
mockedGetGasOracle.mockClear();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('resolves contract ABI from body params', async () => {
|
|
38
|
+
const req = {
|
|
39
|
+
body: { address: '0x1111111111111111111111111111111111111111', chainId: '8453', abiNameHint: 'ERC20' }
|
|
40
|
+
} as Request;
|
|
41
|
+
const json = jest.fn();
|
|
42
|
+
const status = jest.fn(() => ({ json }));
|
|
43
|
+
const res = { json, status } as unknown as Response;
|
|
44
|
+
|
|
45
|
+
await resolveContractAbi(req, res, jest.fn());
|
|
46
|
+
|
|
47
|
+
expect(mockedResolveAbiByAddress).toHaveBeenCalledWith(
|
|
48
|
+
8453,
|
|
49
|
+
'0x1111111111111111111111111111111111111111',
|
|
50
|
+
'ERC20'
|
|
51
|
+
);
|
|
52
|
+
expect(json).toHaveBeenCalledWith(expect.objectContaining({ itemCount: 1, chainId: 8453 }));
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('returns 400 when ABI resolve request has no address', async () => {
|
|
56
|
+
const req = { body: {} } as Request;
|
|
57
|
+
const json = jest.fn();
|
|
58
|
+
const status = jest.fn(() => ({ json }));
|
|
59
|
+
const res = { json, status } as unknown as Response;
|
|
60
|
+
|
|
61
|
+
await resolveContractAbi(req, res, jest.fn());
|
|
62
|
+
|
|
63
|
+
expect(status).toHaveBeenCalledWith(400);
|
|
64
|
+
expect(mockedResolveAbiByAddress).not.toHaveBeenCalled();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('resolves ABI file path via query params', async () => {
|
|
68
|
+
const req = {
|
|
69
|
+
params: { address: '0x1111111111111111111111111111111111111111' },
|
|
70
|
+
query: { chainId: '10', abiNameHint: 'Proxy' }
|
|
71
|
+
} as unknown as Request;
|
|
72
|
+
const json = jest.fn();
|
|
73
|
+
const res = { json } as unknown as Response;
|
|
74
|
+
|
|
75
|
+
await resolveContractAbiFile(req, res, jest.fn());
|
|
76
|
+
|
|
77
|
+
expect(mockedResolveAbiFileForAddress).toHaveBeenCalledWith(
|
|
78
|
+
10,
|
|
79
|
+
'0x1111111111111111111111111111111111111111',
|
|
80
|
+
'Proxy'
|
|
81
|
+
);
|
|
82
|
+
expect(json).toHaveBeenCalledWith(expect.objectContaining({ chainId: 10 }));
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('proxies tx history and gas oracle calls', async () => {
|
|
86
|
+
const txReq = { params: { address: '0x1111111111111111111111111111111111111111' }, query: { chainId: '1' } } as unknown as Request;
|
|
87
|
+
const gasReq = { query: { chainId: '137' } } as unknown as Request;
|
|
88
|
+
const txJson = jest.fn();
|
|
89
|
+
const gasJson = jest.fn();
|
|
90
|
+
|
|
91
|
+
await getAddressTxHistory(txReq, { json: txJson } as unknown as Response, jest.fn());
|
|
92
|
+
await getCurrentGasOracle(gasReq, { json: gasJson } as unknown as Response, jest.fn());
|
|
93
|
+
|
|
94
|
+
expect(mockedGetTxHistory).toHaveBeenCalledWith('0x1111111111111111111111111111111111111111', 1);
|
|
95
|
+
expect(mockedGetGasOracle).toHaveBeenCalledWith(137);
|
|
96
|
+
expect(txJson).toHaveBeenCalled();
|
|
97
|
+
expect(gasJson).toHaveBeenCalled();
|
|
98
|
+
});
|
|
99
|
+
});
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import os from 'os';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { http } from '../backend/utils/http';
|
|
5
|
+
import {
|
|
6
|
+
resolveAbiByAddress,
|
|
7
|
+
resolveAbiFileForAddress,
|
|
8
|
+
_internal as etherscanInternal
|
|
9
|
+
} from '../backend/services/etherscanService';
|
|
10
|
+
|
|
11
|
+
describe('etherscanService ABI resolver', () => {
|
|
12
|
+
const originalCwd = process.cwd();
|
|
13
|
+
let workspace: string;
|
|
14
|
+
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
workspace = fs.mkdtempSync(path.join(os.tmpdir(), 'gnoman-abi-'));
|
|
17
|
+
process.chdir(workspace);
|
|
18
|
+
delete process.env.ETHERSCAN_API_KEY;
|
|
19
|
+
delete process.env.ETHERSCAN_CHAIN_ID;
|
|
20
|
+
etherscanInternal.clearCaches();
|
|
21
|
+
jest.restoreAllMocks();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
afterEach(() => {
|
|
25
|
+
process.chdir(originalCwd);
|
|
26
|
+
fs.rmSync(workspace, { recursive: true, force: true });
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('returns cached ABI without network call', async () => {
|
|
30
|
+
const address = '0x1111111111111111111111111111111111111111';
|
|
31
|
+
const cachePath = path.join(workspace, 'abi', 'address', '1', `${address}.json`);
|
|
32
|
+
fs.mkdirSync(path.dirname(cachePath), { recursive: true });
|
|
33
|
+
fs.writeFileSync(cachePath, JSON.stringify({ abi: [{ type: 'function', name: 'transfer' }] }));
|
|
34
|
+
|
|
35
|
+
const requestSpy = jest.spyOn(http, 'get');
|
|
36
|
+
|
|
37
|
+
const abi = await resolveAbiByAddress(1, address);
|
|
38
|
+
|
|
39
|
+
expect(requestSpy).not.toHaveBeenCalled();
|
|
40
|
+
expect(abi[0]).toEqual(expect.objectContaining({ name: 'transfer' }));
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('detects proxy implementation and caches under original address', async () => {
|
|
44
|
+
process.env.ETHERSCAN_API_KEY = 'test-key';
|
|
45
|
+
const original = '0x2222222222222222222222222222222222222222';
|
|
46
|
+
const implementation = '0x3333333333333333333333333333333333333333';
|
|
47
|
+
|
|
48
|
+
const requestSpy = jest.spyOn(http, 'get').mockImplementation(async (_url, config) => {
|
|
49
|
+
const action = (config?.params as { action?: string }).action;
|
|
50
|
+
if (action === 'getsourcecode') {
|
|
51
|
+
return {
|
|
52
|
+
data: { status: '1', message: 'OK', result: [{ Implementation: implementation }] }
|
|
53
|
+
} as never;
|
|
54
|
+
}
|
|
55
|
+
if (action === 'getabi') {
|
|
56
|
+
expect((config?.params as { address?: string }).address).toBe(implementation.toLowerCase());
|
|
57
|
+
return {
|
|
58
|
+
data: {
|
|
59
|
+
status: '1',
|
|
60
|
+
message: 'OK',
|
|
61
|
+
result: JSON.stringify([{ type: 'function', name: 'balanceOf' }])
|
|
62
|
+
}
|
|
63
|
+
} as never;
|
|
64
|
+
}
|
|
65
|
+
throw new Error(`Unexpected action: ${String(action)}`);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const resolvedPath = await resolveAbiFileForAddress(1, original, 'ERC20');
|
|
69
|
+
|
|
70
|
+
expect(requestSpy).toHaveBeenCalledTimes(2);
|
|
71
|
+
expect(resolvedPath).toContain(path.join('abi', 'address', '1', `${original.toLowerCase()}.json`));
|
|
72
|
+
const metaPath = resolvedPath.replace(/\.json$/, '.meta.json');
|
|
73
|
+
const meta = JSON.parse(fs.readFileSync(metaPath, 'utf8')) as Record<string, unknown>;
|
|
74
|
+
expect(meta).toEqual(
|
|
75
|
+
expect.objectContaining({
|
|
76
|
+
chainId: 1,
|
|
77
|
+
address: original.toLowerCase(),
|
|
78
|
+
abiTargetAddress: implementation.toLowerCase(),
|
|
79
|
+
isProxy: true,
|
|
80
|
+
abiNameHint: 'ERC20',
|
|
81
|
+
source: 'etherscan'
|
|
82
|
+
})
|
|
83
|
+
);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
it('rate limits to <= 3 calls/sec under repeated resolves', async () => {
|
|
88
|
+
process.env.ETHERSCAN_API_KEY = 'test-key';
|
|
89
|
+
const calls: number[] = [];
|
|
90
|
+
|
|
91
|
+
jest.spyOn(http, 'get').mockImplementation(async (_url, config) => {
|
|
92
|
+
calls.push(Date.now());
|
|
93
|
+
const action = (config?.params as { action?: string }).action;
|
|
94
|
+
if (action === 'getsourcecode') {
|
|
95
|
+
return { data: { status: '1', message: 'OK', result: [{ Implementation: '' }] } } as never;
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
data: { status: '1', message: 'OK', result: JSON.stringify([{ type: 'function', name: 'foo' }]) }
|
|
99
|
+
} as never;
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
const start = Date.now();
|
|
103
|
+
await resolveAbiByAddress(1, '0x5555555555555555555555555555555555555555');
|
|
104
|
+
await resolveAbiByAddress(1, '0x6666666666666666666666666666666666666666');
|
|
105
|
+
const elapsed = Date.now() - start;
|
|
106
|
+
|
|
107
|
+
expect(calls.length).toBe(4);
|
|
108
|
+
expect(elapsed).toBeGreaterThanOrEqual(900);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('fails clearly when API key is missing and no local ABI exists', async () => {
|
|
112
|
+
await expect(resolveAbiByAddress(1, '0x4444444444444444444444444444444444444444')).rejects.toThrow(
|
|
113
|
+
'Missing ABI and no ETHERSCAN_API_KEY configured'
|
|
114
|
+
);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import fsPromises from 'fs/promises';
|
|
3
|
+
import os from 'os';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { KeyringManager } from '../src/core/keyringManager';
|
|
6
|
+
import { MemoryBackend } from '../src/core/backends/memoryBackend';
|
|
7
|
+
import { FileBackend } from '../src/core/backends/fileBackend';
|
|
8
|
+
import { BackendUnavailableError, KeyringBackend } from '../src/core/backends/types';
|
|
9
|
+
|
|
10
|
+
class StubBackend implements KeyringBackend {
|
|
11
|
+
constructor(private state: Record<string, string>) {}
|
|
12
|
+
|
|
13
|
+
async initialize(): Promise<void> {
|
|
14
|
+
// no-op
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async get(key: string): Promise<string | null> {
|
|
18
|
+
return this.state[key] ?? null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async set(key: string, value: string): Promise<void> {
|
|
22
|
+
this.state[key] = value;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async delete(key: string): Promise<void> {
|
|
26
|
+
delete this.state[key];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async list(): Promise<Record<string, string>> {
|
|
30
|
+
return { ...this.state };
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
describe('KeyringManager', () => {
|
|
35
|
+
const createTempPath = (fileName: string) => {
|
|
36
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'gnoman-keyring-test-'));
|
|
37
|
+
return path.join(dir, fileName);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
it('switchBackend reloads secrets from the requested backend', async () => {
|
|
41
|
+
const manager = new KeyringManager({
|
|
42
|
+
backendFactories: {
|
|
43
|
+
system: () => new StubBackend({ RPC_URL: 'https://system' }),
|
|
44
|
+
file: () => new StubBackend({ FILE_ONLY: 'present' }),
|
|
45
|
+
memory: () => new MemoryBackend()
|
|
46
|
+
},
|
|
47
|
+
auditLogPath: createTempPath('audit.log')
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
await manager.switchBackend('system');
|
|
51
|
+
expect(await manager.get('RPC_URL')).toBe('https://system');
|
|
52
|
+
|
|
53
|
+
await manager.switchBackend('file');
|
|
54
|
+
const snapshot = await manager.list();
|
|
55
|
+
expect(snapshot).toEqual({ FILE_ONLY: 'present' });
|
|
56
|
+
expect(await manager.get('FILE_ONLY')).toBe('present');
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('round-trips secrets between persistent backends', async () => {
|
|
60
|
+
const filePath = createTempPath('secrets.enc');
|
|
61
|
+
const manager = new KeyringManager({
|
|
62
|
+
backendFactories: {
|
|
63
|
+
system: () => new FileBackend(filePath),
|
|
64
|
+
file: () => new FileBackend(filePath),
|
|
65
|
+
memory: () => new MemoryBackend()
|
|
66
|
+
},
|
|
67
|
+
auditLogPath: createTempPath('audit.log')
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
await manager.switchBackend('system');
|
|
71
|
+
await manager.set('API_TOKEN', 'system-token');
|
|
72
|
+
expect(await manager.get('API_TOKEN')).toBe('system-token');
|
|
73
|
+
|
|
74
|
+
await manager.switchBackend('file');
|
|
75
|
+
expect(await manager.get('API_TOKEN')).toBe('system-token');
|
|
76
|
+
|
|
77
|
+
await manager.set('API_TOKEN', 'file-token');
|
|
78
|
+
expect(await manager.get('API_TOKEN')).toBe('file-token');
|
|
79
|
+
|
|
80
|
+
await manager.switchBackend('system');
|
|
81
|
+
expect(await manager.get('API_TOKEN')).toBe('file-token');
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('encrypts secrets on disk for the file backend', async () => {
|
|
85
|
+
const filePath = createTempPath('secrets.enc');
|
|
86
|
+
const manager = new KeyringManager({
|
|
87
|
+
backendFactories: {
|
|
88
|
+
system: () => new FileBackend(filePath),
|
|
89
|
+
file: () => new FileBackend(filePath),
|
|
90
|
+
memory: () => new MemoryBackend()
|
|
91
|
+
},
|
|
92
|
+
auditLogPath: createTempPath('audit.log')
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
await manager.switchBackend('file');
|
|
96
|
+
await manager.set('PRIVATE_KEY', 'super-secret-value');
|
|
97
|
+
|
|
98
|
+
const raw = await fsPromises.readFile(filePath, 'utf8');
|
|
99
|
+
expect(raw).not.toContain('super-secret-value');
|
|
100
|
+
expect(() => JSON.parse(raw)).not.toThrow();
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('falls back when the system backend is unavailable', async () => {
|
|
104
|
+
class FailingBackend implements KeyringBackend {
|
|
105
|
+
async initialize(): Promise<void> {
|
|
106
|
+
throw new BackendUnavailableError('Unavailable', 'system');
|
|
107
|
+
}
|
|
108
|
+
async get(): Promise<string | null> {
|
|
109
|
+
throw new Error('unreachable');
|
|
110
|
+
}
|
|
111
|
+
async set(): Promise<void> {
|
|
112
|
+
throw new Error('unreachable');
|
|
113
|
+
}
|
|
114
|
+
async delete(): Promise<void> {
|
|
115
|
+
throw new Error('unreachable');
|
|
116
|
+
}
|
|
117
|
+
async list(): Promise<Record<string, string>> {
|
|
118
|
+
throw new Error('unreachable');
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const manager = new KeyringManager({
|
|
123
|
+
backendFactories: {
|
|
124
|
+
system: () => new FailingBackend(),
|
|
125
|
+
file: () => new MemoryBackend(),
|
|
126
|
+
memory: () => new MemoryBackend()
|
|
127
|
+
},
|
|
128
|
+
auditLogPath: createTempPath('audit.log')
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
const secrets = await manager.list();
|
|
132
|
+
expect(secrets).toEqual({});
|
|
133
|
+
expect(['file', 'memory']).toContain(manager.currentBackend());
|
|
134
|
+
});
|
|
135
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { AbiRegistry } from '../backend/services/onchain/abiRegistry';
|
|
2
|
+
import { EtherscanClient } from '../backend/services/onchain/etherscanClient';
|
|
3
|
+
import { OnchainClientError } from '../backend/services/onchain/errors';
|
|
4
|
+
import { createOnchainToolkit } from '../backend/services/onchain';
|
|
5
|
+
|
|
6
|
+
describe('AbiRegistry', () => {
|
|
7
|
+
it('resolves ABI from etherscan client and caches by chainId + address', async () => {
|
|
8
|
+
const resolver = {
|
|
9
|
+
getContractAbi: jest.fn(async () => [{ type: 'function', name: 'balanceOf' }])
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const registry = new AbiRegistry({ etherscanClients: { 1: resolver } });
|
|
13
|
+
|
|
14
|
+
const abi1 = await registry.getAbi('0x1111111111111111111111111111111111111111', 1);
|
|
15
|
+
const abi2 = await registry.getAbi('0x1111111111111111111111111111111111111111', 1);
|
|
16
|
+
|
|
17
|
+
expect(abi1).toEqual(abi2);
|
|
18
|
+
expect(resolver.getContractAbi).toHaveBeenCalledTimes(1);
|
|
19
|
+
expect(registry.getCacheSize()).toBe(1);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('throws a typed error when chain is not configured', async () => {
|
|
23
|
+
const registry = new AbiRegistry({ etherscanClients: {} });
|
|
24
|
+
await expect(registry.getAbi('0x1111111111111111111111111111111111111111', 10)).rejects.toMatchObject({
|
|
25
|
+
code: 'ABI_RESOLUTION_FAILED'
|
|
26
|
+
} satisfies Partial<OnchainClientError>);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
describe('EtherscanClient', () => {
|
|
31
|
+
it('retries rate limited responses and returns parsed ABI', async () => {
|
|
32
|
+
const client = new EtherscanClient('key');
|
|
33
|
+
const responses = [
|
|
34
|
+
{ data: { status: '0', message: 'NOTOK', result: 'Max rate limit reached' } },
|
|
35
|
+
{ data: { status: '1', message: 'OK', result: JSON.stringify([{ type: 'function', name: 'foo' }]) } }
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
(client as unknown as { client: { get: jest.Mock } }).client = {
|
|
39
|
+
get: jest.fn(async () => responses.shift())
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const abi = await client.getContractAbi('0x1111111111111111111111111111111111111111');
|
|
43
|
+
|
|
44
|
+
expect(Array.isArray(abi)).toBe(true);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
describe('createOnchainToolkit', () => {
|
|
49
|
+
it('creates swappable per-network clients', () => {
|
|
50
|
+
const toolkit = createOnchainToolkit({
|
|
51
|
+
defaultChainId: 1,
|
|
52
|
+
networks: {
|
|
53
|
+
1: {
|
|
54
|
+
chainId: 1,
|
|
55
|
+
rpcUrl: 'https://rpc-mainnet.example',
|
|
56
|
+
etherscan: { apiKey: 'mainnet-key' },
|
|
57
|
+
tenderly: { rpcUrl: 'https://rpc.tenderly.co/fork/mainnet' }
|
|
58
|
+
},
|
|
59
|
+
11155111: {
|
|
60
|
+
chainId: 11155111,
|
|
61
|
+
rpcUrl: 'https://rpc-sepolia.example',
|
|
62
|
+
etherscan: { apiKey: 'sepolia-key', baseUrl: 'https://api-sepolia.etherscan.io/api' }
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
expect(toolkit.getEtherscanClient(11155111)).toBeInstanceOf(EtherscanClient);
|
|
68
|
+
expect(toolkit.getChainlinkClient(1)).toBeDefined();
|
|
69
|
+
expect(toolkit.getTenderlyRpcClient(1)).toBeDefined();
|
|
70
|
+
});
|
|
71
|
+
});
|