movehat 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +0 -1
- package/dist/commands/compile.d.ts +0 -1
- package/dist/commands/compile.js +0 -1
- package/dist/commands/fork/create.d.ts +1 -1
- package/dist/commands/fork/create.js +18 -3
- package/dist/commands/fork/fund.d.ts +0 -1
- package/dist/commands/fork/fund.js +0 -1
- package/dist/commands/fork/list.d.ts +0 -1
- package/dist/commands/fork/list.js +0 -1
- package/dist/commands/fork/serve.d.ts +0 -1
- package/dist/commands/fork/serve.js +0 -1
- package/dist/commands/fork/view-resource.d.ts +0 -1
- package/dist/commands/fork/view-resource.js +0 -1
- package/dist/commands/init.d.ts +0 -1
- package/dist/commands/init.js +0 -1
- package/dist/commands/run.d.ts +0 -1
- package/dist/commands/run.js +0 -1
- package/dist/commands/test-move.d.ts +0 -1
- package/dist/commands/test-move.js +0 -1
- package/dist/commands/test.d.ts +0 -1
- package/dist/commands/test.js +8 -1
- package/dist/commands/update.d.ts +0 -1
- package/dist/commands/update.js +0 -1
- package/dist/core/AccountManager.d.ts +15 -2
- package/dist/core/AccountManager.js +32 -20
- package/dist/core/Publisher.d.ts +0 -1
- package/dist/core/Publisher.js +0 -1
- package/dist/core/config.d.ts +0 -1
- package/dist/core/config.js +0 -1
- package/dist/core/contract.d.ts +0 -1
- package/dist/core/contract.js +0 -1
- package/dist/core/deployments.d.ts +0 -1
- package/dist/core/deployments.js +0 -1
- package/dist/core/movementProfile.d.ts +0 -1
- package/dist/core/movementProfile.js +0 -1
- package/dist/core/shell.d.ts +0 -1
- package/dist/core/shell.js +0 -1
- package/dist/errors.d.ts +0 -1
- package/dist/errors.js +0 -1
- package/dist/fork/api.d.ts +24 -1
- package/dist/fork/api.js +95 -1
- package/dist/fork/manager.d.ts +14 -1
- package/dist/fork/manager.js +19 -1
- package/dist/fork/server.d.ts +19 -1
- package/dist/fork/server.js +188 -8
- package/dist/fork/storage.d.ts +0 -1
- package/dist/fork/storage.js +50 -32
- package/dist/fork/test.d.ts +0 -1
- package/dist/fork/test.js +0 -1
- package/dist/harness/Harness.d.ts +0 -1
- package/dist/harness/Harness.js +6 -2
- package/dist/harness/codeObject.d.ts +0 -1
- package/dist/harness/codeObject.js +0 -1
- package/dist/harness/errors.d.ts +0 -1
- package/dist/harness/errors.js +0 -1
- package/dist/harness/index.d.ts +0 -1
- package/dist/harness/index.js +0 -1
- package/dist/harness/proxy.d.ts +12 -1
- package/dist/harness/proxy.js +23 -1
- package/dist/harness/script.d.ts +0 -1
- package/dist/harness/script.js +0 -1
- package/dist/harness/view.d.ts +0 -1
- package/dist/harness/view.js +0 -1
- package/dist/helpers/assertions.d.ts +0 -1
- package/dist/helpers/assertions.js +0 -1
- package/dist/helpers/banner.d.ts +0 -1
- package/dist/helpers/banner.js +0 -1
- package/dist/helpers/index.d.ts +0 -1
- package/dist/helpers/index.js +0 -1
- package/dist/helpers/move-tests.d.ts +0 -1
- package/dist/helpers/move-tests.js +0 -1
- package/dist/helpers/npm-registry.d.ts +0 -1
- package/dist/helpers/npm-registry.js +0 -1
- package/dist/helpers/semver-utils.d.ts +0 -1
- package/dist/helpers/semver-utils.js +0 -1
- package/dist/helpers/setup.d.ts +0 -1
- package/dist/helpers/setup.js +0 -1
- package/dist/helpers/setupLocalTesting.d.ts +2 -5
- package/dist/helpers/setupLocalTesting.js +0 -1
- package/dist/helpers/testFixtures.d.ts +0 -1
- package/dist/helpers/testFixtures.js +0 -1
- package/dist/helpers/version-check.d.ts +0 -1
- package/dist/helpers/version-check.js +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/node/LocalNodeManager.d.ts +0 -1
- package/dist/node/LocalNodeManager.js +4 -2
- package/dist/runtime.d.ts +0 -1
- package/dist/runtime.js +0 -1
- package/dist/types/config.d.ts +0 -1
- package/dist/types/config.js +0 -1
- package/dist/types/fork.d.ts +0 -1
- package/dist/types/fork.js +0 -1
- package/dist/types/harness.d.ts +0 -1
- package/dist/types/harness.js +0 -1
- package/dist/types/runtime.d.ts +0 -1
- package/dist/types/runtime.js +0 -1
- package/dist/ui/colors.d.ts +0 -1
- package/dist/ui/colors.js +0 -1
- package/dist/ui/formatters.d.ts +0 -1
- package/dist/ui/formatters.js +0 -1
- package/dist/ui/index.d.ts +0 -1
- package/dist/ui/index.js +0 -1
- package/dist/ui/logger.d.ts +0 -1
- package/dist/ui/logger.js +0 -1
- package/dist/ui/spinner.d.ts +0 -1
- package/dist/ui/spinner.js +0 -1
- package/dist/ui/symbols.d.ts +0 -1
- package/dist/ui/symbols.js +0 -1
- package/dist/ui/table.d.ts +0 -1
- package/dist/ui/table.js +0 -1
- package/dist/utils/address.d.ts +0 -1
- package/dist/utils/address.js +0 -1
- package/dist/utils/childProcessAdapter.d.ts +0 -1
- package/dist/utils/childProcessAdapter.js +46 -20
- package/dist/utils/movementCli.d.ts +5 -0
- package/dist/utils/movementCli.js +91 -0
- package/dist/utils/parseCliOutput.d.ts +0 -1
- package/dist/utils/parseCliOutput.js +0 -1
- package/dist/utils/redact.d.ts +3 -3
- package/dist/utils/redact.js +6 -5
- package/dist/utils/runCli.d.ts +0 -1
- package/dist/utils/runCli.js +10 -2
- package/package.json +4 -4
- package/dist/__tests__/deployContract.test.d.ts +0 -2
- package/dist/__tests__/deployContract.test.d.ts.map +0 -1
- package/dist/__tests__/deployContract.test.js +0 -377
- package/dist/__tests__/deployContract.test.js.map +0 -1
- package/dist/__tests__/errors.test.d.ts +0 -2
- package/dist/__tests__/errors.test.d.ts.map +0 -1
- package/dist/__tests__/errors.test.js +0 -46
- package/dist/__tests__/errors.test.js.map +0 -1
- package/dist/__tests__/exports.test.d.ts +0 -2
- package/dist/__tests__/exports.test.d.ts.map +0 -1
- package/dist/__tests__/exports.test.js +0 -30
- package/dist/__tests__/exports.test.js.map +0 -1
- package/dist/__tests__/fixtures/sigint-deploy-harness.d.ts +0 -25
- package/dist/__tests__/fixtures/sigint-deploy-harness.d.ts.map +0 -1
- package/dist/__tests__/fixtures/sigint-deploy-harness.js +0 -83
- package/dist/__tests__/fixtures/sigint-deploy-harness.js.map +0 -1
- package/dist/__tests__/fork/api.test.d.ts +0 -2
- package/dist/__tests__/fork/api.test.d.ts.map +0 -1
- package/dist/__tests__/fork/api.test.js +0 -115
- package/dist/__tests__/fork/api.test.js.map +0 -1
- package/dist/__tests__/fork/api.timeout.test.d.ts +0 -2
- package/dist/__tests__/fork/api.timeout.test.d.ts.map +0 -1
- package/dist/__tests__/fork/api.timeout.test.js +0 -98
- package/dist/__tests__/fork/api.timeout.test.js.map +0 -1
- package/dist/__tests__/harness/Harness.createLive.test.d.ts +0 -2
- package/dist/__tests__/harness/Harness.createLive.test.d.ts.map +0 -1
- package/dist/__tests__/harness/Harness.createLive.test.js +0 -53
- package/dist/__tests__/harness/Harness.createLive.test.js.map +0 -1
- package/dist/__tests__/harness/Harness.proxy.test.d.ts +0 -2
- package/dist/__tests__/harness/Harness.proxy.test.d.ts.map +0 -1
- package/dist/__tests__/harness/Harness.proxy.test.js +0 -89
- package/dist/__tests__/harness/Harness.proxy.test.js.map +0 -1
- package/dist/__tests__/harness/_fixture.d.ts +0 -54
- package/dist/__tests__/harness/_fixture.d.ts.map +0 -1
- package/dist/__tests__/harness/_fixture.js +0 -69
- package/dist/__tests__/harness/_fixture.js.map +0 -1
- package/dist/__tests__/harness/codeObject.deploy.test.d.ts +0 -2
- package/dist/__tests__/harness/codeObject.deploy.test.d.ts.map +0 -1
- package/dist/__tests__/harness/codeObject.deploy.test.js +0 -288
- package/dist/__tests__/harness/codeObject.deploy.test.js.map +0 -1
- package/dist/__tests__/harness/codeObject.upgrade.test.d.ts +0 -2
- package/dist/__tests__/harness/codeObject.upgrade.test.d.ts.map +0 -1
- package/dist/__tests__/harness/codeObject.upgrade.test.js +0 -138
- package/dist/__tests__/harness/codeObject.upgrade.test.js.map +0 -1
- package/dist/__tests__/harness/script.test.d.ts +0 -2
- package/dist/__tests__/harness/script.test.d.ts.map +0 -1
- package/dist/__tests__/harness/script.test.js +0 -219
- package/dist/__tests__/harness/script.test.js.map +0 -1
- package/dist/__tests__/harness/view.test.d.ts +0 -2
- package/dist/__tests__/harness/view.test.d.ts.map +0 -1
- package/dist/__tests__/harness/view.test.js +0 -92
- package/dist/__tests__/harness/view.test.js.map +0 -1
- package/dist/__tests__/runtime.test.d.ts +0 -2
- package/dist/__tests__/runtime.test.d.ts.map +0 -1
- package/dist/__tests__/runtime.test.js +0 -141
- package/dist/__tests__/runtime.test.js.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/commands/__tests__/compile.test.d.ts +0 -2
- package/dist/commands/__tests__/compile.test.d.ts.map +0 -1
- package/dist/commands/__tests__/compile.test.js +0 -351
- package/dist/commands/__tests__/compile.test.js.map +0 -1
- package/dist/commands/__tests__/compile.toml-mutation.test.d.ts +0 -2
- package/dist/commands/__tests__/compile.toml-mutation.test.d.ts.map +0 -1
- package/dist/commands/__tests__/compile.toml-mutation.test.js +0 -69
- package/dist/commands/__tests__/compile.toml-mutation.test.js.map +0 -1
- package/dist/commands/__tests__/init.test.d.ts +0 -2
- package/dist/commands/__tests__/init.test.d.ts.map +0 -1
- package/dist/commands/__tests__/init.test.js +0 -163
- package/dist/commands/__tests__/init.test.js.map +0 -1
- package/dist/commands/__tests__/run.test.d.ts +0 -2
- package/dist/commands/__tests__/run.test.d.ts.map +0 -1
- package/dist/commands/__tests__/run.test.js +0 -166
- package/dist/commands/__tests__/run.test.js.map +0 -1
- package/dist/commands/__tests__/test-move.test.d.ts +0 -2
- package/dist/commands/__tests__/test-move.test.d.ts.map +0 -1
- package/dist/commands/__tests__/test-move.test.js +0 -59
- package/dist/commands/__tests__/test-move.test.js.map +0 -1
- package/dist/commands/__tests__/test.test.d.ts +0 -2
- package/dist/commands/__tests__/test.test.d.ts.map +0 -1
- package/dist/commands/__tests__/test.test.js +0 -168
- package/dist/commands/__tests__/test.test.js.map +0 -1
- package/dist/commands/__tests__/update.test.d.ts +0 -2
- package/dist/commands/__tests__/update.test.d.ts.map +0 -1
- package/dist/commands/__tests__/update.test.js +0 -176
- package/dist/commands/__tests__/update.test.js.map +0 -1
- package/dist/commands/compile.d.ts.map +0 -1
- package/dist/commands/compile.js.map +0 -1
- package/dist/commands/fork/__tests__/create.test.d.ts +0 -2
- package/dist/commands/fork/__tests__/create.test.d.ts.map +0 -1
- package/dist/commands/fork/__tests__/create.test.js +0 -108
- package/dist/commands/fork/__tests__/create.test.js.map +0 -1
- package/dist/commands/fork/__tests__/fund.test.d.ts +0 -2
- package/dist/commands/fork/__tests__/fund.test.d.ts.map +0 -1
- package/dist/commands/fork/__tests__/fund.test.js +0 -72
- package/dist/commands/fork/__tests__/fund.test.js.map +0 -1
- package/dist/commands/fork/__tests__/list.test.d.ts +0 -2
- package/dist/commands/fork/__tests__/list.test.d.ts.map +0 -1
- package/dist/commands/fork/__tests__/list.test.js +0 -119
- package/dist/commands/fork/__tests__/list.test.js.map +0 -1
- package/dist/commands/fork/__tests__/serve.test.d.ts +0 -2
- package/dist/commands/fork/__tests__/serve.test.d.ts.map +0 -1
- package/dist/commands/fork/__tests__/serve.test.js +0 -97
- package/dist/commands/fork/__tests__/serve.test.js.map +0 -1
- package/dist/commands/fork/__tests__/view-resource.test.d.ts +0 -2
- package/dist/commands/fork/__tests__/view-resource.test.d.ts.map +0 -1
- package/dist/commands/fork/__tests__/view-resource.test.js +0 -77
- package/dist/commands/fork/__tests__/view-resource.test.js.map +0 -1
- package/dist/commands/fork/create.d.ts.map +0 -1
- package/dist/commands/fork/create.js.map +0 -1
- package/dist/commands/fork/fund.d.ts.map +0 -1
- package/dist/commands/fork/fund.js.map +0 -1
- package/dist/commands/fork/list.d.ts.map +0 -1
- package/dist/commands/fork/list.js.map +0 -1
- package/dist/commands/fork/serve.d.ts.map +0 -1
- package/dist/commands/fork/serve.js.map +0 -1
- package/dist/commands/fork/view-resource.d.ts.map +0 -1
- package/dist/commands/fork/view-resource.js.map +0 -1
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/run.d.ts.map +0 -1
- package/dist/commands/run.js.map +0 -1
- package/dist/commands/test-move.d.ts.map +0 -1
- package/dist/commands/test-move.js.map +0 -1
- package/dist/commands/test.d.ts.map +0 -1
- package/dist/commands/test.js.map +0 -1
- package/dist/commands/update.d.ts.map +0 -1
- package/dist/commands/update.js.map +0 -1
- package/dist/core/AccountManager.d.ts.map +0 -1
- package/dist/core/AccountManager.js.map +0 -1
- package/dist/core/Publisher.d.ts.map +0 -1
- package/dist/core/Publisher.js.map +0 -1
- package/dist/core/__tests__/AccountManager.global-state.test.d.ts +0 -2
- package/dist/core/__tests__/AccountManager.global-state.test.d.ts.map +0 -1
- package/dist/core/__tests__/AccountManager.global-state.test.js +0 -69
- package/dist/core/__tests__/AccountManager.global-state.test.js.map +0 -1
- package/dist/core/__tests__/AccountManager.test.d.ts +0 -2
- package/dist/core/__tests__/AccountManager.test.d.ts.map +0 -1
- package/dist/core/__tests__/AccountManager.test.js +0 -239
- package/dist/core/__tests__/AccountManager.test.js.map +0 -1
- package/dist/core/__tests__/config.test.d.ts +0 -2
- package/dist/core/__tests__/config.test.d.ts.map +0 -1
- package/dist/core/__tests__/config.test.js +0 -311
- package/dist/core/__tests__/config.test.js.map +0 -1
- package/dist/core/__tests__/deployments.test.d.ts +0 -2
- package/dist/core/__tests__/deployments.test.d.ts.map +0 -1
- package/dist/core/__tests__/deployments.test.js +0 -201
- package/dist/core/__tests__/deployments.test.js.map +0 -1
- package/dist/core/__tests__/movementProfile.test.d.ts +0 -2
- package/dist/core/__tests__/movementProfile.test.d.ts.map +0 -1
- package/dist/core/__tests__/movementProfile.test.js +0 -112
- package/dist/core/__tests__/movementProfile.test.js.map +0 -1
- package/dist/core/__tests__/shell.test.d.ts +0 -2
- package/dist/core/__tests__/shell.test.d.ts.map +0 -1
- package/dist/core/__tests__/shell.test.js +0 -107
- package/dist/core/__tests__/shell.test.js.map +0 -1
- package/dist/core/config.d.ts.map +0 -1
- package/dist/core/config.js.map +0 -1
- package/dist/core/contract.d.ts.map +0 -1
- package/dist/core/contract.js.map +0 -1
- package/dist/core/deployments.d.ts.map +0 -1
- package/dist/core/deployments.js.map +0 -1
- package/dist/core/movementProfile.d.ts.map +0 -1
- package/dist/core/movementProfile.js.map +0 -1
- package/dist/core/shell.d.ts.map +0 -1
- package/dist/core/shell.js.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js.map +0 -1
- package/dist/fork/__tests__/manager.test.d.ts +0 -2
- package/dist/fork/__tests__/manager.test.d.ts.map +0 -1
- package/dist/fork/__tests__/manager.test.js +0 -309
- package/dist/fork/__tests__/manager.test.js.map +0 -1
- package/dist/fork/__tests__/server.cors.test.d.ts +0 -2
- package/dist/fork/__tests__/server.cors.test.d.ts.map +0 -1
- package/dist/fork/__tests__/server.cors.test.js +0 -79
- package/dist/fork/__tests__/server.cors.test.js.map +0 -1
- package/dist/fork/__tests__/server.test.d.ts +0 -2
- package/dist/fork/__tests__/server.test.d.ts.map +0 -1
- package/dist/fork/__tests__/server.test.js +0 -54
- package/dist/fork/__tests__/server.test.js.map +0 -1
- package/dist/fork/__tests__/storage.test.d.ts +0 -2
- package/dist/fork/__tests__/storage.test.d.ts.map +0 -1
- package/dist/fork/__tests__/storage.test.js +0 -222
- package/dist/fork/__tests__/storage.test.js.map +0 -1
- package/dist/fork/__tests__/test.test.d.ts +0 -2
- package/dist/fork/__tests__/test.test.d.ts.map +0 -1
- package/dist/fork/__tests__/test.test.js +0 -81
- package/dist/fork/__tests__/test.test.js.map +0 -1
- package/dist/fork/api.d.ts.map +0 -1
- package/dist/fork/api.js.map +0 -1
- package/dist/fork/manager.d.ts.map +0 -1
- package/dist/fork/manager.js.map +0 -1
- package/dist/fork/server.d.ts.map +0 -1
- package/dist/fork/server.js.map +0 -1
- package/dist/fork/storage.d.ts.map +0 -1
- package/dist/fork/storage.js.map +0 -1
- package/dist/fork/test.d.ts.map +0 -1
- package/dist/fork/test.js.map +0 -1
- package/dist/harness/Harness.d.ts.map +0 -1
- package/dist/harness/Harness.js.map +0 -1
- package/dist/harness/codeObject.d.ts.map +0 -1
- package/dist/harness/codeObject.js.map +0 -1
- package/dist/harness/errors.d.ts.map +0 -1
- package/dist/harness/errors.js.map +0 -1
- package/dist/harness/index.d.ts.map +0 -1
- package/dist/harness/index.js.map +0 -1
- package/dist/harness/proxy.d.ts.map +0 -1
- package/dist/harness/proxy.js.map +0 -1
- package/dist/harness/script.d.ts.map +0 -1
- package/dist/harness/script.js.map +0 -1
- package/dist/harness/view.d.ts.map +0 -1
- package/dist/harness/view.js.map +0 -1
- package/dist/helpers/__tests__/semver-utils.test.d.ts +0 -2
- package/dist/helpers/__tests__/semver-utils.test.d.ts.map +0 -1
- package/dist/helpers/__tests__/semver-utils.test.js +0 -103
- package/dist/helpers/__tests__/semver-utils.test.js.map +0 -1
- package/dist/helpers/__tests__/setupLocalTesting.fork-network.test.d.ts +0 -2
- package/dist/helpers/__tests__/setupLocalTesting.fork-network.test.d.ts.map +0 -1
- package/dist/helpers/__tests__/setupLocalTesting.fork-network.test.js +0 -172
- package/dist/helpers/__tests__/setupLocalTesting.fork-network.test.js.map +0 -1
- package/dist/helpers/assertions.d.ts.map +0 -1
- package/dist/helpers/assertions.js.map +0 -1
- package/dist/helpers/banner.d.ts.map +0 -1
- package/dist/helpers/banner.js.map +0 -1
- package/dist/helpers/index.d.ts.map +0 -1
- package/dist/helpers/index.js.map +0 -1
- package/dist/helpers/move-tests.d.ts.map +0 -1
- package/dist/helpers/move-tests.js.map +0 -1
- package/dist/helpers/npm-registry.d.ts.map +0 -1
- package/dist/helpers/npm-registry.js.map +0 -1
- package/dist/helpers/semver-utils.d.ts.map +0 -1
- package/dist/helpers/semver-utils.js.map +0 -1
- package/dist/helpers/setup.d.ts.map +0 -1
- package/dist/helpers/setup.js.map +0 -1
- package/dist/helpers/setupLocalTesting.d.ts.map +0 -1
- package/dist/helpers/setupLocalTesting.js.map +0 -1
- package/dist/helpers/testFixtures.d.ts.map +0 -1
- package/dist/helpers/testFixtures.js.map +0 -1
- package/dist/helpers/version-check.d.ts.map +0 -1
- package/dist/helpers/version-check.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/node/LocalNodeManager.d.ts.map +0 -1
- package/dist/node/LocalNodeManager.js.map +0 -1
- package/dist/node/__tests__/LocalNodeManager.api-port.test.d.ts +0 -2
- package/dist/node/__tests__/LocalNodeManager.api-port.test.d.ts.map +0 -1
- package/dist/node/__tests__/LocalNodeManager.api-port.test.js +0 -55
- package/dist/node/__tests__/LocalNodeManager.api-port.test.js.map +0 -1
- package/dist/node/__tests__/LocalNodeManager.test.d.ts +0 -2
- package/dist/node/__tests__/LocalNodeManager.test.d.ts.map +0 -1
- package/dist/node/__tests__/LocalNodeManager.test.js +0 -449
- package/dist/node/__tests__/LocalNodeManager.test.js.map +0 -1
- package/dist/runtime.d.ts.map +0 -1
- package/dist/runtime.js.map +0 -1
- package/dist/types/config.d.ts.map +0 -1
- package/dist/types/config.js.map +0 -1
- package/dist/types/fork.d.ts.map +0 -1
- package/dist/types/fork.js.map +0 -1
- package/dist/types/harness.d.ts.map +0 -1
- package/dist/types/harness.js.map +0 -1
- package/dist/types/runtime.d.ts.map +0 -1
- package/dist/types/runtime.js.map +0 -1
- package/dist/ui/__tests__/colors.test.d.ts +0 -2
- package/dist/ui/__tests__/colors.test.d.ts.map +0 -1
- package/dist/ui/__tests__/colors.test.js +0 -127
- package/dist/ui/__tests__/colors.test.js.map +0 -1
- package/dist/ui/__tests__/logger.test.d.ts +0 -2
- package/dist/ui/__tests__/logger.test.d.ts.map +0 -1
- package/dist/ui/__tests__/logger.test.js +0 -75
- package/dist/ui/__tests__/logger.test.js.map +0 -1
- package/dist/ui/colors.d.ts.map +0 -1
- package/dist/ui/colors.js.map +0 -1
- package/dist/ui/formatters.d.ts.map +0 -1
- package/dist/ui/formatters.js.map +0 -1
- package/dist/ui/index.d.ts.map +0 -1
- package/dist/ui/index.js.map +0 -1
- package/dist/ui/logger.d.ts.map +0 -1
- package/dist/ui/logger.js.map +0 -1
- package/dist/ui/spinner.d.ts.map +0 -1
- package/dist/ui/spinner.js.map +0 -1
- package/dist/ui/symbols.d.ts.map +0 -1
- package/dist/ui/symbols.js.map +0 -1
- package/dist/ui/table.d.ts.map +0 -1
- package/dist/ui/table.js.map +0 -1
- package/dist/utils/__tests__/address.test.d.ts +0 -2
- package/dist/utils/__tests__/address.test.d.ts.map +0 -1
- package/dist/utils/__tests__/address.test.js +0 -70
- package/dist/utils/__tests__/address.test.js.map +0 -1
- package/dist/utils/__tests__/childProcessAdapter.maxBuffer.test.d.ts +0 -2
- package/dist/utils/__tests__/childProcessAdapter.maxBuffer.test.d.ts.map +0 -1
- package/dist/utils/__tests__/childProcessAdapter.maxBuffer.test.js +0 -43
- package/dist/utils/__tests__/childProcessAdapter.maxBuffer.test.js.map +0 -1
- package/dist/utils/__tests__/childProcessAdapter.test.d.ts +0 -2
- package/dist/utils/__tests__/childProcessAdapter.test.d.ts.map +0 -1
- package/dist/utils/__tests__/childProcessAdapter.test.js +0 -217
- package/dist/utils/__tests__/childProcessAdapter.test.js.map +0 -1
- package/dist/utils/__tests__/runCli.test.d.ts +0 -2
- package/dist/utils/__tests__/runCli.test.d.ts.map +0 -1
- package/dist/utils/__tests__/runCli.test.js +0 -187
- package/dist/utils/__tests__/runCli.test.js.map +0 -1
- package/dist/utils/address.d.ts.map +0 -1
- package/dist/utils/address.js.map +0 -1
- package/dist/utils/childProcessAdapter.d.ts.map +0 -1
- package/dist/utils/childProcessAdapter.js.map +0 -1
- package/dist/utils/parseCliOutput.d.ts.map +0 -1
- package/dist/utils/parseCliOutput.js.map +0 -1
- package/dist/utils/redact.d.ts.map +0 -1
- package/dist/utils/redact.js.map +0 -1
- package/dist/utils/runCli.d.ts.map +0 -1
- package/dist/utils/runCli.js.map +0 -1
- package/src/__tests__/deployContract.test.ts +0 -438
- package/src/__tests__/errors.test.ts +0 -84
- package/src/__tests__/exports.test.ts +0 -32
- package/src/__tests__/fixtures/sigint-deploy-harness.ts +0 -96
- package/src/__tests__/fork/api.test.ts +0 -148
- package/src/__tests__/fork/api.timeout.test.ts +0 -150
- package/src/__tests__/harness/Harness.createLive.test.ts +0 -57
- package/src/__tests__/harness/Harness.proxy.test.ts +0 -111
- package/src/__tests__/harness/_fixture.ts +0 -131
- package/src/__tests__/harness/codeObject.deploy.test.ts +0 -319
- package/src/__tests__/harness/codeObject.upgrade.test.ts +0 -156
- package/src/__tests__/harness/script.test.ts +0 -245
- package/src/__tests__/harness/view.test.ts +0 -104
- package/src/__tests__/runtime.test.ts +0 -182
- package/src/cli.ts +0 -164
- package/src/commands/__tests__/compile.test.ts +0 -407
- package/src/commands/__tests__/compile.toml-mutation.test.ts +0 -77
- package/src/commands/__tests__/init.test.ts +0 -210
- package/src/commands/__tests__/run.test.ts +0 -192
- package/src/commands/__tests__/test-move.test.ts +0 -81
- package/src/commands/__tests__/test.test.ts +0 -204
- package/src/commands/__tests__/update.test.ts +0 -223
- package/src/commands/compile.ts +0 -339
- package/src/commands/fork/__tests__/create.test.ts +0 -132
- package/src/commands/fork/__tests__/fund.test.ts +0 -104
- package/src/commands/fork/__tests__/list.test.ts +0 -139
- package/src/commands/fork/__tests__/serve.test.ts +0 -121
- package/src/commands/fork/__tests__/view-resource.test.ts +0 -101
- package/src/commands/fork/create.ts +0 -110
- package/src/commands/fork/fund.ts +0 -64
- package/src/commands/fork/list.ts +0 -98
- package/src/commands/fork/serve.ts +0 -80
- package/src/commands/fork/view-resource.ts +0 -51
- package/src/commands/init.ts +0 -264
- package/src/commands/run.ts +0 -125
- package/src/commands/test-move.ts +0 -27
- package/src/commands/test.ts +0 -255
- package/src/commands/update.ts +0 -201
- package/src/core/AccountManager.ts +0 -457
- package/src/core/Publisher.ts +0 -310
- package/src/core/__tests__/AccountManager.global-state.test.ts +0 -83
- package/src/core/__tests__/AccountManager.test.ts +0 -290
- package/src/core/__tests__/config.test.ts +0 -377
- package/src/core/__tests__/deployments.test.ts +0 -247
- package/src/core/__tests__/movementProfile.test.ts +0 -131
- package/src/core/__tests__/shell.test.ts +0 -138
- package/src/core/config.ts +0 -286
- package/src/core/contract.ts +0 -103
- package/src/core/deployments.ts +0 -155
- package/src/core/movementProfile.ts +0 -127
- package/src/core/shell.ts +0 -86
- package/src/errors.ts +0 -81
- package/src/fork/__tests__/manager.test.ts +0 -385
- package/src/fork/__tests__/server.cors.test.ts +0 -101
- package/src/fork/__tests__/server.test.ts +0 -65
- package/src/fork/__tests__/storage.test.ts +0 -281
- package/src/fork/__tests__/test.test.ts +0 -97
- package/src/fork/api.ts +0 -190
- package/src/fork/manager.ts +0 -343
- package/src/fork/server.ts +0 -380
- package/src/fork/storage.ts +0 -253
- package/src/fork/test.ts +0 -221
- package/src/harness/Harness.ts +0 -231
- package/src/harness/codeObject.ts +0 -381
- package/src/harness/errors.ts +0 -22
- package/src/harness/index.ts +0 -3
- package/src/harness/proxy.ts +0 -40
- package/src/harness/script.ts +0 -200
- package/src/harness/view.ts +0 -34
- package/src/helpers/__tests__/semver-utils.test.ts +0 -121
- package/src/helpers/__tests__/setupLocalTesting.fork-network.test.ts +0 -212
- package/src/helpers/assertions.ts +0 -29
- package/src/helpers/banner.ts +0 -63
- package/src/helpers/index.ts +0 -37
- package/src/helpers/move-tests.ts +0 -72
- package/src/helpers/npm-registry.ts +0 -72
- package/src/helpers/semver-utils.ts +0 -54
- package/src/helpers/setup.ts +0 -54
- package/src/helpers/setupLocalTesting.ts +0 -387
- package/src/helpers/testFixtures.ts +0 -210
- package/src/helpers/version-check.ts +0 -114
- package/src/index.ts +0 -30
- package/src/node/LocalNodeManager.ts +0 -383
- package/src/node/__tests__/LocalNodeManager.api-port.test.ts +0 -62
- package/src/node/__tests__/LocalNodeManager.test.ts +0 -579
- package/src/runtime.ts +0 -157
- package/src/templates/.env.example +0 -9
- package/src/templates/.mocharc.json +0 -8
- package/src/templates/.vscode/settings.json +0 -11
- package/src/templates/README.md +0 -146
- package/src/templates/gitignore +0 -22
- package/src/templates/move/Move.toml +0 -19
- package/src/templates/move/sources/Counter.move +0 -96
- package/src/templates/movehat.config.ts +0 -57
- package/src/templates/package.json +0 -27
- package/src/templates/scripts/deploy-counter.ts +0 -66
- package/src/templates/tests/Counter.test.ts +0 -113
- package/src/templates/tsconfig.json +0 -15
- package/src/templates/types/movehat.d.ts +0 -101
- package/src/types/config.ts +0 -83
- package/src/types/fork.ts +0 -47
- package/src/types/harness.ts +0 -182
- package/src/types/runtime.ts +0 -57
- package/src/ui/__tests__/colors.test.ts +0 -156
- package/src/ui/__tests__/logger.test.ts +0 -89
- package/src/ui/colors.ts +0 -144
- package/src/ui/formatters.ts +0 -246
- package/src/ui/index.ts +0 -62
- package/src/ui/logger.ts +0 -310
- package/src/ui/spinner.ts +0 -218
- package/src/ui/symbols.ts +0 -80
- package/src/ui/table.ts +0 -191
- package/src/utils/__tests__/address.test.ts +0 -93
- package/src/utils/__tests__/childProcessAdapter.maxBuffer.test.ts +0 -51
- package/src/utils/__tests__/childProcessAdapter.test.ts +0 -266
- package/src/utils/__tests__/runCli.test.ts +0 -240
- package/src/utils/address.ts +0 -52
- package/src/utils/childProcessAdapter.ts +0 -244
- package/src/utils/parseCliOutput.ts +0 -27
- package/src/utils/redact.ts +0 -24
- package/src/utils/runCli.ts +0 -64
package/src/fork/server.ts
DELETED
|
@@ -1,380 +0,0 @@
|
|
|
1
|
-
import http from 'http';
|
|
2
|
-
import { URL } from 'url';
|
|
3
|
-
import { ForkManager } from './manager.js';
|
|
4
|
-
import { logger } from '../ui/index.js';
|
|
5
|
-
|
|
6
|
-
export interface ForkServerOptions {
|
|
7
|
-
/**
|
|
8
|
-
* Origins allowed to make cross-origin requests. When unset (default),
|
|
9
|
-
* no `Access-Control-Allow-Origin` header is emitted — any browser
|
|
10
|
-
* cross-origin read is rejected by the user agent. Setting this to a
|
|
11
|
-
* non-empty list opts into echoing matching `Origin` request headers
|
|
12
|
-
* back. Wildcard `'*'` is intentionally NOT supported: cached fork
|
|
13
|
-
* state may include resources that should not be readable by every
|
|
14
|
-
* page in the dev's browser.
|
|
15
|
-
*/
|
|
16
|
-
corsAllowOrigins?: readonly string[];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Fork Server - Serves fork data via Movement L1 RPC API
|
|
21
|
-
* Emulates a Movement L1 node using local fork storage
|
|
22
|
-
*/
|
|
23
|
-
export class ForkServer {
|
|
24
|
-
private server: http.Server | null = null;
|
|
25
|
-
private forkManager: ForkManager;
|
|
26
|
-
private port: number;
|
|
27
|
-
private host: string;
|
|
28
|
-
private readonly corsAllowOrigins: ReadonlySet<string>;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* @param host Interface to bind. Defaults to `127.0.0.1` so cached fork
|
|
32
|
-
* state (which may include sensitive resources) is not exposed on the LAN.
|
|
33
|
-
* Pass `'0.0.0.0'` only if you intentionally need to expose the server.
|
|
34
|
-
* @param options Optional CORS allowlist (see {@link ForkServerOptions}).
|
|
35
|
-
*/
|
|
36
|
-
constructor(
|
|
37
|
-
forkPath: string,
|
|
38
|
-
port: number = 8080,
|
|
39
|
-
host: string = '127.0.0.1',
|
|
40
|
-
options: ForkServerOptions = {}
|
|
41
|
-
) {
|
|
42
|
-
this.forkManager = new ForkManager(forkPath);
|
|
43
|
-
this.port = port;
|
|
44
|
-
this.host = host;
|
|
45
|
-
this.corsAllowOrigins = new Set(options.corsAllowOrigins ?? []);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Set CORS headers for a request when the request's `Origin` is in
|
|
50
|
-
* the allowlist. No-op otherwise.
|
|
51
|
-
*/
|
|
52
|
-
private applyCors(req: http.IncomingMessage, res: http.ServerResponse): void {
|
|
53
|
-
const origin = req.headers.origin;
|
|
54
|
-
if (typeof origin === 'string' && this.corsAllowOrigins.has(origin)) {
|
|
55
|
-
res.setHeader('Access-Control-Allow-Origin', origin);
|
|
56
|
-
res.setHeader('Vary', 'Origin');
|
|
57
|
-
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
|
|
58
|
-
res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Start the fork server
|
|
64
|
-
*/
|
|
65
|
-
async start(): Promise<void> {
|
|
66
|
-
// Load fork metadata
|
|
67
|
-
this.forkManager.load();
|
|
68
|
-
const metadata = this.forkManager.getMetadata();
|
|
69
|
-
|
|
70
|
-
logger.newline();
|
|
71
|
-
logger.phase("Fork Server");
|
|
72
|
-
logger.kv("Network", metadata.network, 2);
|
|
73
|
-
logger.kv("Chain ID", String(metadata.chainId), 2);
|
|
74
|
-
logger.kv("Ledger Version", String(metadata.ledgerVersion), 2);
|
|
75
|
-
logger.kv("Forked at", metadata.createdAt, 2);
|
|
76
|
-
|
|
77
|
-
this.server = http.createServer((req, res) => {
|
|
78
|
-
this.handleRequest(req, res).catch((error) => {
|
|
79
|
-
// Log full error server-side for diagnostics
|
|
80
|
-
logger.error(`Error handling request: ${error instanceof Error ? error.message : String(error)}`);
|
|
81
|
-
|
|
82
|
-
// Only send response if headers haven't been sent yet
|
|
83
|
-
if (!res.headersSent) {
|
|
84
|
-
this.applyCors(req, res);
|
|
85
|
-
|
|
86
|
-
// Send generic error response (no internal details exposed)
|
|
87
|
-
this.sendJSON(res, 500, {
|
|
88
|
-
message: 'Internal server error',
|
|
89
|
-
error_code: 'internal_error',
|
|
90
|
-
vm_error_code: null
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
// Capture the just-assigned server into a non-null local so we don't
|
|
97
|
-
// have to repeatedly assert `this.server!` (which TS forces because
|
|
98
|
-
// `http.createServer` returns an unrelated narrow that the field
|
|
99
|
-
// declaration doesn't track).
|
|
100
|
-
const server = this.server;
|
|
101
|
-
|
|
102
|
-
return new Promise((resolve, reject) => {
|
|
103
|
-
// Handle server errors (port in use, permission denied, etc.)
|
|
104
|
-
const onError = (error: NodeJS.ErrnoException) => {
|
|
105
|
-
if (error.code === 'EADDRINUSE') {
|
|
106
|
-
reject(new Error(`Port ${this.port} is already in use. Please use a different port with --port <number>`));
|
|
107
|
-
} else if (error.code === 'EACCES') {
|
|
108
|
-
reject(new Error(`Permission denied to bind to port ${this.port}. Try using a port above 1024 or run with appropriate permissions.`));
|
|
109
|
-
} else {
|
|
110
|
-
reject(new Error(`Failed to start server: ${error.message}`));
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
// Listen for errors during startup
|
|
115
|
-
server.once('error', onError);
|
|
116
|
-
|
|
117
|
-
server.listen(this.port, this.host, () => {
|
|
118
|
-
// Remove error listener after successful start
|
|
119
|
-
server.removeListener('error', onError);
|
|
120
|
-
|
|
121
|
-
// IPv6 literals must be wrapped in brackets in URLs (RFC 3986).
|
|
122
|
-
const isIpv6 = this.host.includes(':');
|
|
123
|
-
const displayHost =
|
|
124
|
-
this.host === '0.0.0.0'
|
|
125
|
-
? 'localhost'
|
|
126
|
-
: isIpv6
|
|
127
|
-
? `[${this.host}]`
|
|
128
|
-
: this.host;
|
|
129
|
-
logger.newline();
|
|
130
|
-
logger.success(`Fork Server listening on http://${displayHost}:${this.port}`);
|
|
131
|
-
logger.kv("Bound interface", this.host, 2);
|
|
132
|
-
logger.kv("Ledger Info", `http://${displayHost}:${this.port}/v1/`, 2);
|
|
133
|
-
if (this.host === '0.0.0.0') {
|
|
134
|
-
logger.warning("Server is bound to 0.0.0.0 — fork state is reachable from the LAN.", 2);
|
|
135
|
-
}
|
|
136
|
-
logger.newline();
|
|
137
|
-
logger.info("Press Ctrl+C to stop");
|
|
138
|
-
resolve();
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Stop the fork server
|
|
145
|
-
*/
|
|
146
|
-
stop(): Promise<void> {
|
|
147
|
-
return new Promise((resolve) => {
|
|
148
|
-
if (this.server) {
|
|
149
|
-
this.server.close(() => {
|
|
150
|
-
logger.newline();
|
|
151
|
-
logger.success("Fork Server stopped");
|
|
152
|
-
resolve();
|
|
153
|
-
});
|
|
154
|
-
} else {
|
|
155
|
-
resolve();
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Sanitize pathname for error messages to prevent log injection
|
|
162
|
-
*/
|
|
163
|
-
private sanitizePathname(pathname: string): string {
|
|
164
|
-
// Remove control characters and newlines
|
|
165
|
-
const sanitized = pathname.replace(/[\x00-\x1F\x7F]/g, '');
|
|
166
|
-
// Truncate to reasonable length
|
|
167
|
-
return sanitized.length > 100 ? sanitized.substring(0, 100) + '...' : sanitized;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Handle incoming HTTP requests
|
|
172
|
-
*/
|
|
173
|
-
private async handleRequest(
|
|
174
|
-
req: http.IncomingMessage,
|
|
175
|
-
res: http.ServerResponse
|
|
176
|
-
): Promise<void> {
|
|
177
|
-
const url = new URL(req.url || '/', `http://localhost:${this.port}`);
|
|
178
|
-
const pathname = url.pathname;
|
|
179
|
-
|
|
180
|
-
// Log request — plain so the fork-server access log retains its
|
|
181
|
-
// grep-friendly line shape (timestamp + method + path, no symbol).
|
|
182
|
-
logger.plain(`[${new Date().toISOString()}] ${req.method} ${pathname}`);
|
|
183
|
-
|
|
184
|
-
this.applyCors(req, res);
|
|
185
|
-
|
|
186
|
-
// Handle OPTIONS for CORS preflight
|
|
187
|
-
if (req.method === 'OPTIONS') {
|
|
188
|
-
res.writeHead(200);
|
|
189
|
-
res.end();
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
try {
|
|
194
|
-
// Route requests
|
|
195
|
-
if (pathname === '/v1' || pathname === '/v1/') {
|
|
196
|
-
await this.handleLedgerInfo(res);
|
|
197
|
-
} else if (pathname.match(/^\/v1\/accounts\/0x[a-fA-F0-9]{1,64}$/)) {
|
|
198
|
-
const address = pathname.split('/').pop()!;
|
|
199
|
-
await this.handleGetAccount(address, res);
|
|
200
|
-
} else if (pathname.match(/^\/v1\/accounts\/0x[a-fA-F0-9]{1,64}\/resource\/.+$/)) {
|
|
201
|
-
const parts = pathname.split('/');
|
|
202
|
-
const accountIndex = parts.indexOf('accounts') + 1;
|
|
203
|
-
const resourceIndex = parts.indexOf('resource') + 1;
|
|
204
|
-
const address = parts[accountIndex];
|
|
205
|
-
const resourceType = decodeURIComponent(parts.slice(resourceIndex).join('/'));
|
|
206
|
-
if (!address) {
|
|
207
|
-
this.send404(res, 'Malformed resource path', 'malformed_path');
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
await this.handleGetResource(address, resourceType, res);
|
|
211
|
-
} else {
|
|
212
|
-
// Use regex capture for resources endpoint
|
|
213
|
-
const resourcesMatch = pathname.match(/^\/v1\/accounts\/(0x[a-fA-F0-9]{1,64})\/resources$/);
|
|
214
|
-
if (resourcesMatch && resourcesMatch[1]) {
|
|
215
|
-
const address = resourcesMatch[1];
|
|
216
|
-
await this.handleGetResources(address, res);
|
|
217
|
-
} else {
|
|
218
|
-
// Sanitize pathname to prevent log injection
|
|
219
|
-
const safePath = this.sanitizePathname(pathname);
|
|
220
|
-
this.send404(res, `Endpoint not found: ${safePath}`, 'endpoint_not_found');
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
} catch (error) {
|
|
224
|
-
// Log full error server-side for diagnostics
|
|
225
|
-
logger.error(`Error handling request: ${error instanceof Error ? error.message : String(error)}`);
|
|
226
|
-
|
|
227
|
-
// Send generic error to client (don't expose internal details)
|
|
228
|
-
this.sendError(res, 500, 'Internal server error');
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* Handle GET /v1/ - Ledger info
|
|
234
|
-
*/
|
|
235
|
-
private async handleLedgerInfo(res: http.ServerResponse): Promise<void> {
|
|
236
|
-
const metadata = this.forkManager.getMetadata();
|
|
237
|
-
|
|
238
|
-
const ledgerInfo = {
|
|
239
|
-
chain_id: metadata.chainId,
|
|
240
|
-
epoch: metadata.epoch,
|
|
241
|
-
ledger_version: metadata.ledgerVersion,
|
|
242
|
-
oldest_ledger_version: "0",
|
|
243
|
-
ledger_timestamp: metadata.timestamp,
|
|
244
|
-
node_role: "full_node",
|
|
245
|
-
oldest_block_height: "0",
|
|
246
|
-
block_height: metadata.blockHeight,
|
|
247
|
-
git_hash: "movehat-fork"
|
|
248
|
-
};
|
|
249
|
-
|
|
250
|
-
this.sendJSON(res, 200, ledgerInfo, {
|
|
251
|
-
'x-aptos-chain-id': String(metadata.chainId),
|
|
252
|
-
'x-aptos-ledger-version': metadata.ledgerVersion,
|
|
253
|
-
'x-aptos-ledger-oldest-version': '0',
|
|
254
|
-
'x-aptos-ledger-timestampusec': metadata.timestamp,
|
|
255
|
-
'x-aptos-epoch': metadata.epoch,
|
|
256
|
-
'x-aptos-block-height': metadata.blockHeight,
|
|
257
|
-
'x-aptos-oldest-block-height': '0'
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* Handle GET /v1/accounts/:address
|
|
263
|
-
*/
|
|
264
|
-
private async handleGetAccount(
|
|
265
|
-
address: string,
|
|
266
|
-
res: http.ServerResponse
|
|
267
|
-
): Promise<void> {
|
|
268
|
-
try {
|
|
269
|
-
const account = await this.forkManager.getAccount(address);
|
|
270
|
-
|
|
271
|
-
this.sendJSON(res, 200, {
|
|
272
|
-
sequence_number: account.sequenceNumber,
|
|
273
|
-
authentication_key: account.authenticationKey
|
|
274
|
-
});
|
|
275
|
-
} catch (error) {
|
|
276
|
-
const msg = error instanceof Error ? error.message : String(error);
|
|
277
|
-
if (msg.includes('not found')) {
|
|
278
|
-
this.send404(res, `Account not found: ${address}`);
|
|
279
|
-
} else {
|
|
280
|
-
throw error;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* Handle GET /v1/accounts/:address/resource/:resourceType
|
|
287
|
-
*/
|
|
288
|
-
private async handleGetResource(
|
|
289
|
-
address: string,
|
|
290
|
-
resourceType: string,
|
|
291
|
-
res: http.ServerResponse
|
|
292
|
-
): Promise<void> {
|
|
293
|
-
try {
|
|
294
|
-
const resource = await this.forkManager.getResource(address, resourceType);
|
|
295
|
-
|
|
296
|
-
this.sendJSON(res, 200, {
|
|
297
|
-
type: resourceType,
|
|
298
|
-
data: resource
|
|
299
|
-
});
|
|
300
|
-
} catch (error) {
|
|
301
|
-
const msg = error instanceof Error ? error.message : String(error);
|
|
302
|
-
if (msg.includes('not found')) {
|
|
303
|
-
this.send404(res, `Resource not found: ${resourceType}`, 'resource_not_found');
|
|
304
|
-
} else {
|
|
305
|
-
throw error;
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
/**
|
|
311
|
-
* Handle GET /v1/accounts/:address/resources
|
|
312
|
-
*/
|
|
313
|
-
private async handleGetResources(
|
|
314
|
-
address: string,
|
|
315
|
-
res: http.ServerResponse
|
|
316
|
-
): Promise<void> {
|
|
317
|
-
try {
|
|
318
|
-
const resources = await this.forkManager.getAllResources(address);
|
|
319
|
-
|
|
320
|
-
// Convert to array format expected by the Movement L1 API
|
|
321
|
-
const resourcesArray = Object.entries(resources).map(([type, data]) => ({
|
|
322
|
-
type,
|
|
323
|
-
data
|
|
324
|
-
}));
|
|
325
|
-
|
|
326
|
-
this.sendJSON(res, 200, resourcesArray);
|
|
327
|
-
} catch (error) {
|
|
328
|
-
const msg = error instanceof Error ? error.message : String(error);
|
|
329
|
-
if (msg.includes('not found')) {
|
|
330
|
-
this.send404(res, `Account not found: ${address}`);
|
|
331
|
-
} else {
|
|
332
|
-
throw error;
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
/**
|
|
338
|
-
* Send JSON response.
|
|
339
|
-
* unknown: arbitrary JSON-serializable payload; structural shape varies by
|
|
340
|
-
* endpoint (account metadata, resource arrays, error envelopes).
|
|
341
|
-
*/
|
|
342
|
-
private sendJSON(
|
|
343
|
-
res: http.ServerResponse,
|
|
344
|
-
status: number,
|
|
345
|
-
data: unknown,
|
|
346
|
-
extraHeaders: Record<string, string> = {}
|
|
347
|
-
): void {
|
|
348
|
-
const body = JSON.stringify(data, null, 2);
|
|
349
|
-
|
|
350
|
-
res.writeHead(status, {
|
|
351
|
-
'Content-Type': 'application/json',
|
|
352
|
-
'Content-Length': Buffer.byteLength(body),
|
|
353
|
-
...extraHeaders
|
|
354
|
-
});
|
|
355
|
-
|
|
356
|
-
res.end(body);
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
/**
|
|
360
|
-
* Send 404 error
|
|
361
|
-
*/
|
|
362
|
-
private send404(res: http.ServerResponse, message: string, errorCode: string = 'account_not_found'): void {
|
|
363
|
-
this.sendJSON(res, 404, {
|
|
364
|
-
message,
|
|
365
|
-
error_code: errorCode,
|
|
366
|
-
vm_error_code: null
|
|
367
|
-
});
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
/**
|
|
371
|
-
* Send error response
|
|
372
|
-
*/
|
|
373
|
-
private sendError(res: http.ServerResponse, status: number, message: string): void {
|
|
374
|
-
this.sendJSON(res, status, {
|
|
375
|
-
message,
|
|
376
|
-
error_code: 'internal_error',
|
|
377
|
-
vm_error_code: null
|
|
378
|
-
});
|
|
379
|
-
}
|
|
380
|
-
}
|
package/src/fork/storage.ts
DELETED
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync, readdirSync, unlinkSync } from 'fs';
|
|
2
|
-
import { join } from 'path';
|
|
3
|
-
import type { ForkMetadata, AccountState } from '../types/fork.js';
|
|
4
|
-
import { isHexAddress } from '../utils/address.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Sanitize address to create a safe filename. Validates the address through
|
|
8
|
-
* the shared `isHexAddress` helper (length 1–64 hex chars, optional `0x`),
|
|
9
|
-
* then rebuilds a canonical `0x…` form. The trailing path-separator check is
|
|
10
|
-
* defense-in-depth: unreachable after `isHexAddress`, but cheap to keep.
|
|
11
|
-
*/
|
|
12
|
-
function sanitizeAddressForFilename(address: string): string {
|
|
13
|
-
if (!isHexAddress(address)) {
|
|
14
|
-
throw new Error(`Invalid address format: ${address}. Expected hexadecimal string.`);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const normalized = address.toLowerCase().replace(/^0x/, '');
|
|
18
|
-
const safe = `0x${normalized}`;
|
|
19
|
-
|
|
20
|
-
if (safe.includes('/') || safe.includes('\\') || safe.includes('..')) {
|
|
21
|
-
throw new Error(`Address contains invalid characters: ${address}`);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return safe;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Storage system for fork state
|
|
29
|
-
* Manages the file structure and I/O for fork data
|
|
30
|
-
*/
|
|
31
|
-
export class ForkStorage {
|
|
32
|
-
private forkPath: string;
|
|
33
|
-
|
|
34
|
-
constructor(forkPath: string) {
|
|
35
|
-
this.forkPath = forkPath;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Get safe resource file path for an address
|
|
40
|
-
* Prevents path traversal attacks
|
|
41
|
-
*/
|
|
42
|
-
private getResourceFilePath(address: string): string {
|
|
43
|
-
const safeFilename = sanitizeAddressForFilename(address);
|
|
44
|
-
return join(this.forkPath, 'resources', `${safeFilename}.json`);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Initialize fork directory structure
|
|
49
|
-
*/
|
|
50
|
-
initialize(): void {
|
|
51
|
-
// Create main fork directory
|
|
52
|
-
if (!existsSync(this.forkPath)) {
|
|
53
|
-
mkdirSync(this.forkPath, { recursive: true });
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Create subdirectories
|
|
57
|
-
const resourcesDir = join(this.forkPath, 'resources');
|
|
58
|
-
if (!existsSync(resourcesDir)) {
|
|
59
|
-
mkdirSync(resourcesDir, { recursive: true });
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const cacheDir = join(this.forkPath, 'cache');
|
|
63
|
-
if (!existsSync(cacheDir)) {
|
|
64
|
-
mkdirSync(cacheDir, { recursive: true });
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// Create .gitignore for cache
|
|
68
|
-
const gitignorePath = join(cacheDir, '.gitignore');
|
|
69
|
-
if (!existsSync(gitignorePath)) {
|
|
70
|
-
writeFileSync(gitignorePath, '*\n!.gitignore\n');
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Initialize accounts.json if it doesn't exist
|
|
74
|
-
const accountsPath = join(this.forkPath, 'accounts.json');
|
|
75
|
-
if (!existsSync(accountsPath)) {
|
|
76
|
-
writeFileSync(accountsPath, JSON.stringify({}, null, 2));
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Check if fork exists
|
|
82
|
-
*/
|
|
83
|
-
exists(): boolean {
|
|
84
|
-
return existsSync(this.forkPath) && existsSync(join(this.forkPath, 'metadata.json'));
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Save fork metadata
|
|
89
|
-
*/
|
|
90
|
-
saveMetadata(metadata: ForkMetadata): void {
|
|
91
|
-
const metadataPath = join(this.forkPath, 'metadata.json');
|
|
92
|
-
writeFileSync(metadataPath, JSON.stringify(metadata, null, 2));
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Load fork metadata
|
|
97
|
-
*/
|
|
98
|
-
loadMetadata(): ForkMetadata {
|
|
99
|
-
const metadataPath = join(this.forkPath, 'metadata.json');
|
|
100
|
-
|
|
101
|
-
if (!existsSync(metadataPath)) {
|
|
102
|
-
throw new Error(`Fork metadata not found at ${metadataPath}`);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const data = readFileSync(metadataPath, 'utf-8');
|
|
106
|
-
return JSON.parse(data);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Get account state
|
|
111
|
-
*/
|
|
112
|
-
getAccount(address: string): AccountState | null {
|
|
113
|
-
const accountsPath = join(this.forkPath, 'accounts.json');
|
|
114
|
-
|
|
115
|
-
if (!existsSync(accountsPath)) {
|
|
116
|
-
return null;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
const accounts = JSON.parse(readFileSync(accountsPath, 'utf-8'));
|
|
120
|
-
return accounts[address] || null;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Save account state
|
|
125
|
-
*/
|
|
126
|
-
saveAccount(address: string, state: AccountState): void {
|
|
127
|
-
const accountsPath = join(this.forkPath, 'accounts.json');
|
|
128
|
-
|
|
129
|
-
let accounts: Record<string, AccountState> = {};
|
|
130
|
-
if (existsSync(accountsPath)) {
|
|
131
|
-
accounts = JSON.parse(readFileSync(accountsPath, 'utf-8'));
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
accounts[address] = state;
|
|
135
|
-
writeFileSync(accountsPath, JSON.stringify(accounts, null, 2));
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Get resource for an account
|
|
140
|
-
*/
|
|
141
|
-
getResource(address: string, resourceType: string): unknown | null {
|
|
142
|
-
const resourceFilePath = this.getResourceFilePath(address);
|
|
143
|
-
|
|
144
|
-
if (!existsSync(resourceFilePath)) {
|
|
145
|
-
return null;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
const resources = JSON.parse(readFileSync(resourceFilePath, 'utf-8'));
|
|
149
|
-
return resources[resourceType] || null;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Get all resources for an account
|
|
154
|
-
*/
|
|
155
|
-
getAllResources(address: string): Record<string, unknown> {
|
|
156
|
-
const resourceFilePath = this.getResourceFilePath(address);
|
|
157
|
-
|
|
158
|
-
if (!existsSync(resourceFilePath)) {
|
|
159
|
-
return {};
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
return JSON.parse(readFileSync(resourceFilePath, 'utf-8'));
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Save resource for an account
|
|
167
|
-
*/
|
|
168
|
-
saveResource(address: string, resourceType: string, data: unknown): void {
|
|
169
|
-
const resourceFilePath = this.getResourceFilePath(address);
|
|
170
|
-
|
|
171
|
-
// Ensure resources directory exists
|
|
172
|
-
const resourcesDir = join(this.forkPath, 'resources');
|
|
173
|
-
if (!existsSync(resourcesDir)) {
|
|
174
|
-
mkdirSync(resourcesDir, { recursive: true });
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
let resources: Record<string, unknown> = {};
|
|
178
|
-
if (existsSync(resourceFilePath)) {
|
|
179
|
-
resources = JSON.parse(readFileSync(resourceFilePath, 'utf-8'));
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
resources[resourceType] = data;
|
|
183
|
-
writeFileSync(resourceFilePath, JSON.stringify(resources, null, 2));
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Save all resources for an account
|
|
188
|
-
*/
|
|
189
|
-
saveAllResources(address: string, resources: Record<string, unknown>): void {
|
|
190
|
-
const resourceFilePath = this.getResourceFilePath(address);
|
|
191
|
-
|
|
192
|
-
// Ensure resources directory exists
|
|
193
|
-
const resourcesDir = join(this.forkPath, 'resources');
|
|
194
|
-
if (!existsSync(resourcesDir)) {
|
|
195
|
-
mkdirSync(resourcesDir, { recursive: true });
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
writeFileSync(resourceFilePath, JSON.stringify(resources, null, 2));
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Check if resource is cached
|
|
203
|
-
*/
|
|
204
|
-
hasResource(address: string, resourceType: string): boolean {
|
|
205
|
-
return this.getResource(address, resourceType) !== null;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* List all accounts in the fork
|
|
210
|
-
*/
|
|
211
|
-
listAccounts(): string[] {
|
|
212
|
-
const accountsPath = join(this.forkPath, 'accounts.json');
|
|
213
|
-
|
|
214
|
-
if (!existsSync(accountsPath)) {
|
|
215
|
-
return [];
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
const accounts = JSON.parse(readFileSync(accountsPath, 'utf-8'));
|
|
219
|
-
return Object.keys(accounts);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Clear all cached accounts
|
|
224
|
-
* Resets accounts.json to empty object
|
|
225
|
-
*/
|
|
226
|
-
clearAccounts(): void {
|
|
227
|
-
const accountsPath = join(this.forkPath, 'accounts.json');
|
|
228
|
-
writeFileSync(accountsPath, JSON.stringify({}, null, 2));
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Clear all cached resources
|
|
233
|
-
* Deletes all resource files from the resources directory
|
|
234
|
-
*/
|
|
235
|
-
clearResources(): void {
|
|
236
|
-
const resourcesDir = join(this.forkPath, 'resources');
|
|
237
|
-
|
|
238
|
-
if (!existsSync(resourcesDir)) {
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
// Read all files in resources directory
|
|
243
|
-
const files = readdirSync(resourcesDir);
|
|
244
|
-
|
|
245
|
-
// Delete each resource file
|
|
246
|
-
for (const file of files) {
|
|
247
|
-
if (file.endsWith('.json')) {
|
|
248
|
-
const filePath = join(resourcesDir, file);
|
|
249
|
-
unlinkSync(filePath);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}
|