movehat 0.2.4 → 0.2.6
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 +17 -1
- package/dist/commands/run.js +46 -33
- 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 +109 -28
- 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 +6 -4
- package/dist/utils/parseCliOutput.js +10 -6
- 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
|
@@ -1,457 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Account,
|
|
3
|
-
Ed25519PrivateKey,
|
|
4
|
-
PrivateKey,
|
|
5
|
-
PrivateKeyVariants,
|
|
6
|
-
} from "@aptos-labs/ts-sdk";
|
|
7
|
-
import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
8
|
-
import { join } from "path";
|
|
9
|
-
import { MovehatConfig } from "../types/config.js";
|
|
10
|
-
|
|
11
|
-
export interface StoredAccount {
|
|
12
|
-
label?: string | undefined;
|
|
13
|
-
privateKey: string;
|
|
14
|
-
address: string;
|
|
15
|
-
createdAt: number;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
interface AccountPool {
|
|
19
|
-
accounts: StoredAccount[];
|
|
20
|
-
labelMap: Record<string, string>; // label → address
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Centralized Account Manager for movehat
|
|
25
|
-
*
|
|
26
|
-
* Manages all account creation, loading, and lifecycle operations.
|
|
27
|
-
* Provides a pool of reusable test accounts with labels for better test readability.
|
|
28
|
-
*/
|
|
29
|
-
export class AccountManager {
|
|
30
|
-
// Class-static maps: shared across every consumer in the same Node
|
|
31
|
-
// process (e.g. two Harness instances). Re-using a label across
|
|
32
|
-
// "sessions" overwrites the labelMap entry. Documented + fixed by
|
|
33
|
-
// contract in `AccountManager.global-state.test.ts` (audit F8).
|
|
34
|
-
private static pool: Map<string, Account> = new Map(); // address → Account
|
|
35
|
-
private static privateKeys: Map<string, string> = new Map(); // address → privateKey hex
|
|
36
|
-
private static labelMap: Map<string, string> = new Map(); // label → address
|
|
37
|
-
private static poolLoaded = false;
|
|
38
|
-
// `defaultPoolPath` is captured ONCE at module-import time. A later
|
|
39
|
-
// `process.chdir(...)` does NOT redirect the save destination — pass
|
|
40
|
-
// an explicit `poolPath` to `saveAccountPool`/`loadAccountPool` when
|
|
41
|
-
// per-test isolation matters. See audit finding F8.
|
|
42
|
-
private static defaultPoolPath = join(process.cwd(), ".movehat", "accounts");
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Get a test account from the pool. If label is provided and exists, returns that account.
|
|
46
|
-
* Otherwise creates a new account with the optional label.
|
|
47
|
-
*
|
|
48
|
-
* @param label Optional label for the account (e.g., "alice", "bob", "deployer")
|
|
49
|
-
* @returns An Account instance
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
* const alice = AccountManager.getTestAccount("alice");
|
|
53
|
-
* const randomAccount = AccountManager.getTestAccount();
|
|
54
|
-
*/
|
|
55
|
-
static getTestAccount(label?: string): Account {
|
|
56
|
-
if (label) {
|
|
57
|
-
const existingAccount = this.getAccountByLabel(label);
|
|
58
|
-
if (existingAccount) {
|
|
59
|
-
return existingAccount;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return this.createAccount(label, false);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Create a new account and optionally add it to the pool with a label
|
|
68
|
-
*
|
|
69
|
-
* @param label Optional label for the account
|
|
70
|
-
* @param fund Whether to fund the account (handled externally)
|
|
71
|
-
* @returns A new Account instance
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* const deployer = AccountManager.createAccount("deployer");
|
|
75
|
-
* const bob = AccountManager.createAccount("bob", true);
|
|
76
|
-
*/
|
|
77
|
-
static createAccount(label?: string, fund: boolean = false): Account {
|
|
78
|
-
const account = Account.generate();
|
|
79
|
-
const address = account.accountAddress.toString();
|
|
80
|
-
|
|
81
|
-
this.pool.set(address, account);
|
|
82
|
-
this.privateKeys.set(address, account.privateKey.toString());
|
|
83
|
-
|
|
84
|
-
if (label) {
|
|
85
|
-
this.labelMap.set(label, address);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return account;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Get an account by its label
|
|
93
|
-
*
|
|
94
|
-
* @param label The label to look up
|
|
95
|
-
* @returns The Account if found, undefined otherwise
|
|
96
|
-
*
|
|
97
|
-
* @example
|
|
98
|
-
* const alice = AccountManager.getAccountByLabel("alice");
|
|
99
|
-
* if (alice) {
|
|
100
|
-
* console.log(`Alice's address: ${alice.accountAddress.toString()}`);
|
|
101
|
-
* }
|
|
102
|
-
*/
|
|
103
|
-
static getAccountByLabel(label: string): Account | undefined {
|
|
104
|
-
const address = this.labelMap.get(label);
|
|
105
|
-
if (!address) {
|
|
106
|
-
return undefined;
|
|
107
|
-
}
|
|
108
|
-
return this.pool.get(address);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Load account from environment variable
|
|
113
|
-
*
|
|
114
|
-
* @param envVar The environment variable name (defaults to "PRIVATE_KEY")
|
|
115
|
-
* @returns Account instance
|
|
116
|
-
* @throws Error if environment variable is not set
|
|
117
|
-
*
|
|
118
|
-
* @example
|
|
119
|
-
* const account = AccountManager.loadAccountFromEnv("MH_PRIVATE_KEY");
|
|
120
|
-
*/
|
|
121
|
-
static loadAccountFromEnv(envVar: string = "PRIVATE_KEY"): Account {
|
|
122
|
-
const privateKeyHex = process.env[envVar];
|
|
123
|
-
|
|
124
|
-
if (!privateKeyHex) {
|
|
125
|
-
throw new Error(
|
|
126
|
-
`Environment variable ${envVar} not found. ` +
|
|
127
|
-
`Set it in your .env file or environment.`
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return this.loadAccountFromPrivateKey(privateKeyHex);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Load account from a private key hex string
|
|
136
|
-
*
|
|
137
|
-
* @param privateKeyHex The private key as a hex string (with or without 0x prefix)
|
|
138
|
-
* @returns Account instance
|
|
139
|
-
*
|
|
140
|
-
* @example
|
|
141
|
-
* const account = AccountManager.loadAccountFromPrivateKey("0xabc123...");
|
|
142
|
-
*/
|
|
143
|
-
static loadAccountFromPrivateKey(privateKeyHex: string): Account {
|
|
144
|
-
// Format into AIP-80 shape (`ed25519-priv-0x…`) before constructing
|
|
145
|
-
// the SDK type. Without this, raw-hex inputs trigger a noisy
|
|
146
|
-
// deprecation warning from `@aptos-labs/ts-sdk` on every call.
|
|
147
|
-
const formatted = PrivateKey.formatPrivateKey(
|
|
148
|
-
privateKeyHex,
|
|
149
|
-
PrivateKeyVariants.Ed25519,
|
|
150
|
-
);
|
|
151
|
-
const privateKey = new Ed25519PrivateKey(formatted);
|
|
152
|
-
const account = Account.fromPrivateKey({ privateKey });
|
|
153
|
-
const address = account.accountAddress.toString();
|
|
154
|
-
|
|
155
|
-
// Add to pool for tracking
|
|
156
|
-
this.pool.set(address, account);
|
|
157
|
-
|
|
158
|
-
// Store private key
|
|
159
|
-
this.privateKeys.set(address, privateKeyHex);
|
|
160
|
-
|
|
161
|
-
return account;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Load all accounts from movehat config
|
|
166
|
-
*
|
|
167
|
-
* @param config The resolved MovehatConfig
|
|
168
|
-
* @returns Array of Account instances
|
|
169
|
-
*
|
|
170
|
-
* @example
|
|
171
|
-
* const config = await resolveNetworkConfig(userConfig);
|
|
172
|
-
* const accounts = AccountManager.loadAccountsFromConfig(config);
|
|
173
|
-
*/
|
|
174
|
-
static loadAccountsFromConfig(config: MovehatConfig): Account[] {
|
|
175
|
-
const accounts: Account[] = [];
|
|
176
|
-
|
|
177
|
-
for (const privateKeyHex of config.allAccounts) {
|
|
178
|
-
try {
|
|
179
|
-
const account = this.loadAccountFromPrivateKey(privateKeyHex);
|
|
180
|
-
accounts.push(account);
|
|
181
|
-
} catch (error) {
|
|
182
|
-
const msg = error instanceof Error ? error.message : String(error);
|
|
183
|
-
console.warn(
|
|
184
|
-
`Warning: Failed to load account from config: ${msg}`
|
|
185
|
-
);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
return accounts;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Get all labeled accounts in the pool
|
|
194
|
-
*
|
|
195
|
-
* @returns Record of label to Account mappings
|
|
196
|
-
*
|
|
197
|
-
* @example
|
|
198
|
-
* const labeled = AccountManager.getLabeledAccounts();
|
|
199
|
-
* console.log(`Deployer: ${labeled.deployer?.accountAddress.toString()}`);
|
|
200
|
-
*/
|
|
201
|
-
static getLabeledAccounts(): Record<string, Account> {
|
|
202
|
-
const result: Record<string, Account> = {};
|
|
203
|
-
|
|
204
|
-
for (const [label, address] of this.labelMap.entries()) {
|
|
205
|
-
const account = this.pool.get(address);
|
|
206
|
-
if (account) {
|
|
207
|
-
result[label] = account;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
return result;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Save the current account pool to disk for persistence
|
|
216
|
-
*
|
|
217
|
-
* @param poolPath Optional custom path (defaults to .movehat/accounts)
|
|
218
|
-
*
|
|
219
|
-
* @example
|
|
220
|
-
* AccountManager.saveAccountPool();
|
|
221
|
-
*/
|
|
222
|
-
static saveAccountPool(poolPath?: string): void {
|
|
223
|
-
const basePath = poolPath || this.defaultPoolPath;
|
|
224
|
-
|
|
225
|
-
// Ensure directory exists with restrictive perms (the pool file holds
|
|
226
|
-
// plaintext private keys, so the directory must not be world-readable).
|
|
227
|
-
// Note: mkdirSync's mode is masked by the process umask, so we chmod
|
|
228
|
-
// explicitly afterwards to guarantee 0o700 regardless of umask.
|
|
229
|
-
if (!existsSync(basePath)) {
|
|
230
|
-
mkdirSync(basePath, { recursive: true, mode: 0o700 });
|
|
231
|
-
}
|
|
232
|
-
chmodSync(basePath, 0o700);
|
|
233
|
-
|
|
234
|
-
// Build stored accounts array
|
|
235
|
-
const storedAccounts: StoredAccount[] = [];
|
|
236
|
-
const labelMapObject: Record<string, string> = {};
|
|
237
|
-
|
|
238
|
-
for (const [address, account] of this.pool.entries()) {
|
|
239
|
-
// Find label for this address (if any)
|
|
240
|
-
let label: string | undefined;
|
|
241
|
-
for (const [lbl, addr] of this.labelMap.entries()) {
|
|
242
|
-
if (addr === address) {
|
|
243
|
-
label = lbl;
|
|
244
|
-
labelMapObject[lbl] = address;
|
|
245
|
-
break;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
const privateKey = this.privateKeys.get(address);
|
|
250
|
-
if (!privateKey) {
|
|
251
|
-
console.warn(`Warning: No private key found for account ${address}, skipping`);
|
|
252
|
-
continue;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
storedAccounts.push({
|
|
256
|
-
label,
|
|
257
|
-
privateKey,
|
|
258
|
-
address,
|
|
259
|
-
createdAt: Date.now(),
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
const poolData: AccountPool = {
|
|
264
|
-
accounts: storedAccounts,
|
|
265
|
-
labelMap: labelMapObject,
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
// Write to file with owner-only permissions — file contains plaintext
|
|
269
|
-
// private keys for test accounts. writeFileSync's mode is masked by
|
|
270
|
-
// the process umask, so we chmod explicitly afterwards to guarantee
|
|
271
|
-
// 0o600 regardless of umask.
|
|
272
|
-
const poolFilePath = join(basePath, "test-pool.json");
|
|
273
|
-
writeFileSync(poolFilePath, JSON.stringify(poolData, null, 2), {
|
|
274
|
-
encoding: "utf-8",
|
|
275
|
-
mode: 0o600,
|
|
276
|
-
});
|
|
277
|
-
chmodSync(poolFilePath, 0o600);
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* Load account pool from disk
|
|
282
|
-
*
|
|
283
|
-
* @param poolPath Optional custom path (defaults to .movehat/accounts)
|
|
284
|
-
* @returns true if pool was loaded, false if file doesn't exist
|
|
285
|
-
*
|
|
286
|
-
* @example
|
|
287
|
-
* if (AccountManager.loadAccountPool()) {
|
|
288
|
-
* console.log("Pool loaded successfully");
|
|
289
|
-
* }
|
|
290
|
-
*/
|
|
291
|
-
static loadAccountPool(poolPath?: string): boolean {
|
|
292
|
-
if (this.poolLoaded) {
|
|
293
|
-
return true; // Already loaded
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
const basePath = poolPath || this.defaultPoolPath;
|
|
297
|
-
const poolFilePath = join(basePath, "test-pool.json");
|
|
298
|
-
|
|
299
|
-
if (!existsSync(poolFilePath)) {
|
|
300
|
-
return false;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
try {
|
|
304
|
-
const poolData: AccountPool = JSON.parse(
|
|
305
|
-
readFileSync(poolFilePath, "utf-8")
|
|
306
|
-
);
|
|
307
|
-
|
|
308
|
-
// Clear existing pool
|
|
309
|
-
this.pool.clear();
|
|
310
|
-
this.labelMap.clear();
|
|
311
|
-
|
|
312
|
-
// Restore accounts
|
|
313
|
-
for (const stored of poolData.accounts) {
|
|
314
|
-
const account = this.loadAccountFromPrivateKey(stored.privateKey);
|
|
315
|
-
this.pool.set(stored.address, account);
|
|
316
|
-
|
|
317
|
-
if (stored.label) {
|
|
318
|
-
this.labelMap.set(stored.label, stored.address);
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
// Restore label map (in case there are orphaned labels)
|
|
323
|
-
for (const [label, address] of Object.entries(poolData.labelMap)) {
|
|
324
|
-
if (!this.labelMap.has(label)) {
|
|
325
|
-
this.labelMap.set(label, address);
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
this.poolLoaded = true;
|
|
330
|
-
return true;
|
|
331
|
-
} catch (error) {
|
|
332
|
-
const msg = error instanceof Error ? error.message : String(error);
|
|
333
|
-
console.warn(
|
|
334
|
-
`Warning: Failed to load account pool: ${msg}`
|
|
335
|
-
);
|
|
336
|
-
return false;
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
/**
|
|
341
|
-
* Clear the entire account pool
|
|
342
|
-
* Useful for test isolation
|
|
343
|
-
*
|
|
344
|
-
* @example
|
|
345
|
-
* after(() => {
|
|
346
|
-
* AccountManager.clearPool();
|
|
347
|
-
* });
|
|
348
|
-
*/
|
|
349
|
-
static clearPool(): void {
|
|
350
|
-
this.pool.clear();
|
|
351
|
-
this.privateKeys.clear();
|
|
352
|
-
this.labelMap.clear();
|
|
353
|
-
this.poolLoaded = false;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
/**
|
|
357
|
-
* Get the current size of the account pool
|
|
358
|
-
*
|
|
359
|
-
* @returns Number of accounts in the pool
|
|
360
|
-
*/
|
|
361
|
-
static getPoolSize(): number {
|
|
362
|
-
return this.pool.size;
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
/**
|
|
366
|
-
* Get all accounts in the pool
|
|
367
|
-
*
|
|
368
|
-
* @returns Array of all Account instances
|
|
369
|
-
*/
|
|
370
|
-
static getAllAccounts(): Account[] {
|
|
371
|
-
return Array.from(this.pool.values());
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* Check if a label is already in use
|
|
376
|
-
*
|
|
377
|
-
* @param label The label to check
|
|
378
|
-
* @returns true if label exists, false otherwise
|
|
379
|
-
*/
|
|
380
|
-
static hasLabel(label: string): boolean {
|
|
381
|
-
return this.labelMap.has(label);
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
/**
|
|
385
|
-
* Get or create an account with a specific label
|
|
386
|
-
* If the label exists, returns the existing account
|
|
387
|
-
* Otherwise creates a new account with that label
|
|
388
|
-
*
|
|
389
|
-
* @param label The label for the account
|
|
390
|
-
* @returns Account instance
|
|
391
|
-
*
|
|
392
|
-
* @example
|
|
393
|
-
* const alice = AccountManager.getOrCreateLabeled("alice");
|
|
394
|
-
* const aliceAgain = AccountManager.getOrCreateLabeled("alice"); // Same account
|
|
395
|
-
*/
|
|
396
|
-
static getOrCreateLabeled(label: string): Account {
|
|
397
|
-
const existing = this.getAccountByLabel(label);
|
|
398
|
-
if (existing) {
|
|
399
|
-
return existing;
|
|
400
|
-
}
|
|
401
|
-
return this.createAccount(label, false);
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
/**
|
|
405
|
-
* Batch create multiple labeled accounts
|
|
406
|
-
*
|
|
407
|
-
* @param labels Array of labels to create
|
|
408
|
-
* @returns Record of label to Account mappings
|
|
409
|
-
*
|
|
410
|
-
* @example
|
|
411
|
-
* const accounts = AccountManager.createBatch(["alice", "bob", "charlie"]);
|
|
412
|
-
* console.log(accounts.alice.accountAddress.toString());
|
|
413
|
-
*/
|
|
414
|
-
static createBatch(labels: readonly string[]): Record<string, Account> {
|
|
415
|
-
const result: Record<string, Account> = {};
|
|
416
|
-
|
|
417
|
-
for (const label of labels) {
|
|
418
|
-
result[label] = this.getOrCreateLabeled(label);
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
return result;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
/**
|
|
425
|
-
* Export account private keys for backup/sharing
|
|
426
|
-
* WARNING: Only use this for test accounts, never production keys
|
|
427
|
-
*
|
|
428
|
-
* @param labels Optional array of labels to export (exports all if not provided)
|
|
429
|
-
* @returns Record of label/address to private key hex string
|
|
430
|
-
*/
|
|
431
|
-
static exportPrivateKeys(labels?: string[]): Record<string, string> {
|
|
432
|
-
const result: Record<string, string> = {};
|
|
433
|
-
|
|
434
|
-
if (labels) {
|
|
435
|
-
// Export specific labels
|
|
436
|
-
for (const label of labels) {
|
|
437
|
-
const address = this.labelMap.get(label);
|
|
438
|
-
if (address) {
|
|
439
|
-
const privateKey = this.privateKeys.get(address);
|
|
440
|
-
if (privateKey) {
|
|
441
|
-
result[label] = privateKey;
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
} else {
|
|
446
|
-
// Export all labeled accounts
|
|
447
|
-
for (const [label, address] of this.labelMap.entries()) {
|
|
448
|
-
const privateKey = this.privateKeys.get(address);
|
|
449
|
-
if (privateKey) {
|
|
450
|
-
result[label] = privateKey;
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
return result;
|
|
456
|
-
}
|
|
457
|
-
}
|