movehat 0.0.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +236 -0
- package/bin/movehat.js +21 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +93 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/compile.d.ts +2 -0
- package/dist/commands/compile.d.ts.map +1 -0
- package/dist/commands/compile.js +71 -0
- package/dist/commands/compile.js.map +1 -0
- package/dist/commands/fork/create.d.ts +11 -0
- package/dist/commands/fork/create.d.ts.map +1 -0
- package/dist/commands/fork/create.js +56 -0
- package/dist/commands/fork/create.js.map +1 -0
- package/dist/commands/fork/fund.d.ts +12 -0
- package/dist/commands/fork/fund.d.ts.map +1 -0
- package/dist/commands/fork/fund.js +42 -0
- package/dist/commands/fork/fund.js.map +1 -0
- package/dist/commands/fork/list.d.ts +5 -0
- package/dist/commands/fork/list.d.ts.map +1 -0
- package/dist/commands/fork/list.js +61 -0
- package/dist/commands/fork/list.js.map +1 -0
- package/dist/commands/fork/serve.d.ts +10 -0
- package/dist/commands/fork/serve.d.ts.map +1 -0
- package/dist/commands/fork/serve.js +64 -0
- package/dist/commands/fork/serve.js.map +1 -0
- package/dist/commands/fork/view-resource.d.ts +11 -0
- package/dist/commands/fork/view-resource.d.ts.map +1 -0
- package/dist/commands/fork/view-resource.js +34 -0
- package/dist/commands/fork/view-resource.js.map +1 -0
- package/dist/commands/init.d.ts +2 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +90 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/run.d.ts +2 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +51 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/commands/test.d.ts +2 -0
- package/dist/commands/test.d.ts.map +1 -0
- package/dist/commands/test.js +35 -0
- package/dist/commands/test.js.map +1 -0
- package/dist/core/config.d.ts +15 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +121 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/contract.d.ts +20 -0
- package/dist/core/contract.d.ts.map +1 -0
- package/dist/core/contract.js +59 -0
- package/dist/core/contract.js.map +1 -0
- package/dist/core/deployments.d.ts +32 -0
- package/dist/core/deployments.d.ts.map +1 -0
- package/dist/core/deployments.js +122 -0
- package/dist/core/deployments.js.map +1 -0
- package/dist/core/shell.d.ts +25 -0
- package/dist/core/shell.d.ts.map +1 -0
- package/dist/core/shell.js +56 -0
- package/dist/core/shell.js.map +1 -0
- package/dist/errors.d.ts +12 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +24 -0
- package/dist/errors.js.map +1 -0
- package/dist/fork/api.d.ts +33 -0
- package/dist/fork/api.d.ts.map +1 -0
- package/dist/fork/api.js +98 -0
- package/dist/fork/api.js.map +1 -0
- package/dist/fork/manager.d.ts +52 -0
- package/dist/fork/manager.d.ts.map +1 -0
- package/dist/fork/manager.js +221 -0
- package/dist/fork/manager.js.map +1 -0
- package/dist/fork/server.d.ts +55 -0
- package/dist/fork/server.d.ts.map +1 -0
- package/dist/fork/server.js +274 -0
- package/dist/fork/server.js.map +1 -0
- package/dist/fork/storage.d.ts +63 -0
- package/dist/fork/storage.d.ts.map +1 -0
- package/dist/fork/storage.js +183 -0
- package/dist/fork/storage.js.map +1 -0
- package/dist/fork/test.d.ts +75 -0
- package/dist/fork/test.d.ts.map +1 -0
- package/dist/fork/test.js +157 -0
- package/dist/fork/test.js.map +1 -0
- package/dist/helpers/assertions.d.ts +7 -0
- package/dist/helpers/assertions.d.ts.map +1 -0
- package/dist/helpers/assertions.js +17 -0
- package/dist/helpers/assertions.js.map +1 -0
- package/dist/helpers/banner.d.ts +3 -0
- package/dist/helpers/banner.d.ts.map +1 -0
- package/dist/helpers/banner.js +38 -0
- package/dist/helpers/banner.js.map +1 -0
- package/dist/helpers/index.d.ts +11 -0
- package/dist/helpers/index.d.ts.map +1 -0
- package/dist/helpers/index.js +7 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/helpers/setup.d.ts +10 -0
- package/dist/helpers/setup.d.ts.map +1 -0
- package/dist/helpers/setup.js +28 -0
- package/dist/helpers/setup.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime.d.ts +26 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +247 -0
- package/dist/runtime.js.map +1 -0
- package/dist/templates/.env.example +9 -0
- package/dist/templates/.mocharc.json +8 -0
- package/dist/templates/README.md +92 -0
- package/dist/templates/move/Counter.move +64 -0
- package/dist/templates/move/Move.toml +16 -0
- package/dist/templates/movehat.config.ts +37 -0
- package/dist/templates/package.json +24 -0
- package/dist/templates/scripts/deploy-counter.ts +48 -0
- package/dist/templates/tests/Counter.test.ts +75 -0
- package/dist/templates/tsconfig.json +15 -0
- package/dist/templates/types/movehat.d.ts +104 -0
- package/dist/types/config.d.ts +35 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +2 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/fork.d.ts +37 -0
- package/dist/types/fork.d.ts.map +1 -0
- package/dist/types/fork.js +5 -0
- package/dist/types/fork.js.map +1 -0
- package/dist/types/runtime.d.ts +28 -0
- package/dist/types/runtime.d.ts.map +1 -0
- package/dist/types/runtime.js +2 -0
- package/dist/types/runtime.js.map +1 -0
- package/package.json +66 -0
- package/src/cli.ts +106 -0
- package/src/commands/compile.ts +84 -0
- package/src/commands/fork/create.ts +70 -0
- package/src/commands/fork/fund.ts +57 -0
- package/src/commands/fork/list.ts +67 -0
- package/src/commands/fork/serve.ts +77 -0
- package/src/commands/fork/view-resource.ts +46 -0
- package/src/commands/init.ts +150 -0
- package/src/commands/run.ts +59 -0
- package/src/commands/test.ts +42 -0
- package/src/core/config.ts +151 -0
- package/src/core/contract.ts +97 -0
- package/src/core/deployments.ts +164 -0
- package/src/core/shell.ts +66 -0
- package/src/errors.ts +21 -0
- package/src/fork/api.ts +117 -0
- package/src/fork/manager.ts +264 -0
- package/src/fork/server.ts +311 -0
- package/src/fork/storage.ts +224 -0
- package/src/fork/test.ts +195 -0
- package/src/helpers/assertions.ts +29 -0
- package/src/helpers/banner.ts +47 -0
- package/src/helpers/index.ts +26 -0
- package/src/helpers/setup.ts +49 -0
- package/src/index.ts +17 -0
- package/src/runtime.ts +322 -0
- package/src/templates/.env.example +9 -0
- package/src/templates/.mocharc.json +8 -0
- package/src/templates/README.md +92 -0
- package/src/templates/move/Counter.move +64 -0
- package/src/templates/move/Move.toml +16 -0
- package/src/templates/movehat.config.ts +37 -0
- package/src/templates/package.json +24 -0
- package/src/templates/scripts/deploy-counter.ts +48 -0
- package/src/templates/tests/Counter.test.ts +75 -0
- package/src/templates/tsconfig.json +15 -0
- package/src/templates/types/movehat.d.ts +104 -0
- package/src/types/config.ts +36 -0
- package/src/types/fork.ts +41 -0
- package/src/types/runtime.ts +49 -0
package/README.md
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
# Movehat
|
|
2
|
+
|
|
3
|
+
> Hardhat-like development framework for Movement L1 and Aptos Move smart contracts
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/movehat)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- **Quick Start** - Scaffold new Move projects in seconds
|
|
11
|
+
- **TypeScript Testing** - Write integration tests with familiar tools (Mocha, Chai)
|
|
12
|
+
- **Built-in Helpers** - Interact with contracts easily
|
|
13
|
+
- **Movement CLI Integration** - Seamless compilation and deployment
|
|
14
|
+
- **Hot Reload** - Test changes instantly with watch mode
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install -g movehat
|
|
20
|
+
# or
|
|
21
|
+
pnpm add -g movehat
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Create a new project
|
|
28
|
+
npx movehat init my-move-project
|
|
29
|
+
|
|
30
|
+
# Navigate to project
|
|
31
|
+
cd my-move-project
|
|
32
|
+
|
|
33
|
+
# Install dependencies
|
|
34
|
+
npm install
|
|
35
|
+
|
|
36
|
+
# Compile contracts
|
|
37
|
+
npx movehat compile
|
|
38
|
+
|
|
39
|
+
# Deploy contracts
|
|
40
|
+
npx movehat deploy
|
|
41
|
+
|
|
42
|
+
# Run tests
|
|
43
|
+
npm test
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Project Structure
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
my-move-project/
|
|
50
|
+
āāā move/ # Move smart contracts
|
|
51
|
+
ā āāā sources/
|
|
52
|
+
ā ā āāā Counter.move
|
|
53
|
+
ā āāā Move.toml
|
|
54
|
+
āāā scripts/ # Deployment scripts
|
|
55
|
+
ā āāā deploy-counter.ts
|
|
56
|
+
āāā tests/ # Integration tests
|
|
57
|
+
ā āāā Counter.test.ts
|
|
58
|
+
āāā movehat.config.ts # Configuration
|
|
59
|
+
āāā .env # Environment variables
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Configuration
|
|
63
|
+
|
|
64
|
+
Edit `movehat.config.ts`:
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
export default {
|
|
68
|
+
network: "movement-testnet",
|
|
69
|
+
rpc: "https://testnet.movementnetwork.xyz/v1",
|
|
70
|
+
account: process.env.MH_ACCOUNT || "",
|
|
71
|
+
privateKey: process.env.MH_PRIVATE_KEY || "",
|
|
72
|
+
moveDir: "./move",
|
|
73
|
+
namedAddresses: {
|
|
74
|
+
counter: process.env.MH_ACCOUNT ?? "0x0",
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Set up your environment variables in `.env`:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
MH_PRIVATE_KEY=your_private_key_here
|
|
83
|
+
MH_ACCOUNT=your_account_address_here
|
|
84
|
+
MH_NETWORK=testnet
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Writing Tests
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
import { describe, it, before } from "mocha";
|
|
91
|
+
import { expect } from "chai";
|
|
92
|
+
import { setupTestEnvironment, getContract, assertTransactionSuccess } from "movehat/helpers";
|
|
93
|
+
import type { TestEnvironment, MoveContract } from "movehat/helpers";
|
|
94
|
+
|
|
95
|
+
describe("Counter Contract", () => {
|
|
96
|
+
let env: TestEnvironment;
|
|
97
|
+
let counter: MoveContract;
|
|
98
|
+
|
|
99
|
+
before(async function () {
|
|
100
|
+
this.timeout(30000);
|
|
101
|
+
env = await setupTestEnvironment();
|
|
102
|
+
counter = getContract(
|
|
103
|
+
env.aptos,
|
|
104
|
+
env.account.accountAddress.toString(),
|
|
105
|
+
"counter"
|
|
106
|
+
);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it("should increment counter", async function () {
|
|
110
|
+
this.timeout(30000);
|
|
111
|
+
|
|
112
|
+
const tx = await counter.call(env.account, "increment", []);
|
|
113
|
+
assertTransactionSuccess(tx);
|
|
114
|
+
|
|
115
|
+
const value = await counter.view<number>("get", [
|
|
116
|
+
env.account.accountAddress.toString()
|
|
117
|
+
]);
|
|
118
|
+
|
|
119
|
+
expect(value).to.be.greaterThan(0);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Writing Deployment Scripts
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
import { setupTestEnvironment, getContract } from "movehat/helpers";
|
|
128
|
+
|
|
129
|
+
async function main() {
|
|
130
|
+
console.log("Deploying Counter contract...\n");
|
|
131
|
+
|
|
132
|
+
const env = await setupTestEnvironment();
|
|
133
|
+
|
|
134
|
+
const counter = getContract(
|
|
135
|
+
env.aptos,
|
|
136
|
+
env.account.accountAddress.toString(),
|
|
137
|
+
"counter"
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
console.log(`Contract address: ${env.account.accountAddress.toString()}::counter`);
|
|
141
|
+
|
|
142
|
+
// Initialize the counter
|
|
143
|
+
console.log("\nInitializing counter...");
|
|
144
|
+
const txResult = await counter.call(env.account, "init", []);
|
|
145
|
+
|
|
146
|
+
console.log(`Transaction hash: ${txResult.hash}`);
|
|
147
|
+
console.log(`Counter initialized successfully!`);
|
|
148
|
+
|
|
149
|
+
// Verify
|
|
150
|
+
const value = await counter.view<number>("get", [
|
|
151
|
+
env.account.accountAddress.toString()
|
|
152
|
+
]);
|
|
153
|
+
|
|
154
|
+
console.log(`Initial counter value: ${value}`);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
main().catch((error) => {
|
|
158
|
+
console.error("Deployment failed:", error);
|
|
159
|
+
process.exit(1);
|
|
160
|
+
});
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## API Reference
|
|
164
|
+
|
|
165
|
+
### Helpers
|
|
166
|
+
|
|
167
|
+
#### `setupTestEnvironment()`
|
|
168
|
+
|
|
169
|
+
Sets up the test environment with Aptos client and account.
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
const env = await setupTestEnvironment();
|
|
173
|
+
// Returns: { aptos: Aptos, account: Account, config: MovehatConfig }
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
#### `getContract(aptos, moduleAddress, moduleName)`
|
|
177
|
+
|
|
178
|
+
Creates a contract wrapper for easy interaction.
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
const counter = getContract(aptos, accountAddress, "counter");
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
#### `contract.call(signer, functionName, args, typeArgs)`
|
|
185
|
+
|
|
186
|
+
Executes an entry function (transaction).
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
const tx = await counter.call(account, "increment", []);
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
#### `contract.view(functionName, args, typeArgs)`
|
|
193
|
+
|
|
194
|
+
Reads data from a view function (no transaction).
|
|
195
|
+
|
|
196
|
+
```typescript
|
|
197
|
+
const value = await counter.view<number>("get", [address]);
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
#### `assertTransactionSuccess(result)`
|
|
201
|
+
|
|
202
|
+
Asserts that a transaction was successful.
|
|
203
|
+
|
|
204
|
+
```typescript
|
|
205
|
+
assertTransactionSuccess(txResult);
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## Available Commands
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
npx movehat compile # Compile Move contracts
|
|
212
|
+
npx movehat deploy # Deploy contracts
|
|
213
|
+
npx movehat test # Run tests
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## Prerequisites
|
|
217
|
+
|
|
218
|
+
- Node.js v18+
|
|
219
|
+
- [Movement CLI](https://docs.movementnetwork.xyz/devs/movementCLI) installed and configured
|
|
220
|
+
|
|
221
|
+
## Documentation
|
|
222
|
+
|
|
223
|
+
Visit [GitHub Repository](https://github.com/gilbertsahumada/movehat) for full documentation and examples.
|
|
224
|
+
|
|
225
|
+
## Contributing
|
|
226
|
+
|
|
227
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
228
|
+
|
|
229
|
+
## License
|
|
230
|
+
|
|
231
|
+
MIT Ā©
|
|
232
|
+
## Links
|
|
233
|
+
|
|
234
|
+
- [Movement Network](https://movementnetwork.xyz)
|
|
235
|
+
- [Aptos Move Documentation](https://aptos.dev/move/move-on-aptos/)
|
|
236
|
+
- [GitHub Issues](https://github.com/gilbertsahumada/movehat/issues)
|
package/bin/movehat.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawn } from 'child_process';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
import { dirname, join } from 'path';
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = dirname(__filename);
|
|
9
|
+
|
|
10
|
+
// Get the path to the TypeScript CLI file
|
|
11
|
+
const cliPath = join(__dirname, '..', 'src', 'cli.ts');
|
|
12
|
+
|
|
13
|
+
// Execute the CLI with tsx
|
|
14
|
+
const child = spawn('tsx', [cliPath, ...process.argv.slice(2)], {
|
|
15
|
+
stdio: 'inherit',
|
|
16
|
+
shell: false,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
child.on('exit', (code) => {
|
|
20
|
+
process.exit(code || 0);
|
|
21
|
+
});
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command, InvalidOptionArgumentError } from 'commander';
|
|
3
|
+
import testCommand from './commands/test.js';
|
|
4
|
+
import compileCommand from './commands/compile.js';
|
|
5
|
+
import initCommand from './commands/init.js';
|
|
6
|
+
import runCommand from './commands/run.js';
|
|
7
|
+
import forkCreateCommand from './commands/fork/create.js';
|
|
8
|
+
import forkViewResourceCommand from './commands/fork/view-resource.js';
|
|
9
|
+
import forkFundCommand from './commands/fork/fund.js';
|
|
10
|
+
import forkListCommand from './commands/fork/list.js';
|
|
11
|
+
import forkServeCommand from './commands/fork/serve.js';
|
|
12
|
+
/**
|
|
13
|
+
* Parse and validate port number
|
|
14
|
+
*/
|
|
15
|
+
function parsePort(value) {
|
|
16
|
+
const port = Number.parseInt(value, 10);
|
|
17
|
+
if (isNaN(port) || port < 1 || port > 65535) {
|
|
18
|
+
throw new InvalidOptionArgumentError('Port must be an integer between 1 and 65535');
|
|
19
|
+
}
|
|
20
|
+
return port;
|
|
21
|
+
}
|
|
22
|
+
const program = new Command();
|
|
23
|
+
program
|
|
24
|
+
.name('movehat')
|
|
25
|
+
.description('A CLI tool for managing Move smart contracts')
|
|
26
|
+
.version('0.0.1')
|
|
27
|
+
.option('--network <name>', 'Network to use (testnet, mainnet, local, etc.)')
|
|
28
|
+
.option('--redeploy', 'Force redeploy even if already deployed')
|
|
29
|
+
.hook('preAction', (thisCommand) => {
|
|
30
|
+
// Store network option in environment for commands to access
|
|
31
|
+
const options = thisCommand.opts();
|
|
32
|
+
if (options.network) {
|
|
33
|
+
process.env.MH_CLI_NETWORK = options.network;
|
|
34
|
+
}
|
|
35
|
+
if (options.redeploy) {
|
|
36
|
+
process.env.MH_CLI_REDEPLOY = 'true';
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
program
|
|
40
|
+
.command('init [project-name]')
|
|
41
|
+
.description('Initialize a new Move project in the current directory')
|
|
42
|
+
.action((projectName) => {
|
|
43
|
+
initCommand(projectName);
|
|
44
|
+
});
|
|
45
|
+
program
|
|
46
|
+
.command('compile')
|
|
47
|
+
.description('Compile Move smart contracts using Movement CLI')
|
|
48
|
+
.action(compileCommand);
|
|
49
|
+
program
|
|
50
|
+
.command('run <script>')
|
|
51
|
+
.description('Run a TypeScript/JavaScript script (e.g., deployment script)')
|
|
52
|
+
.action(runCommand);
|
|
53
|
+
program
|
|
54
|
+
.command('test')
|
|
55
|
+
.description('Run TypeScript tests with Mocha')
|
|
56
|
+
.action(testCommand);
|
|
57
|
+
// Fork commands
|
|
58
|
+
const fork = program
|
|
59
|
+
.command('fork')
|
|
60
|
+
.description('Manage local forks of Movement/Aptos networks');
|
|
61
|
+
fork
|
|
62
|
+
.command('create')
|
|
63
|
+
.description('Create a new fork from a network')
|
|
64
|
+
.option('-n, --name <name>', 'Name for the fork')
|
|
65
|
+
.option('-p, --path <path>', 'Custom path for the fork')
|
|
66
|
+
.action((options) => forkCreateCommand(options));
|
|
67
|
+
fork
|
|
68
|
+
.command('view-resource')
|
|
69
|
+
.description('View a resource from the fork')
|
|
70
|
+
.option('-f, --fork <path>', 'Path to the fork')
|
|
71
|
+
.requiredOption('-a, --account <address>', 'Account address')
|
|
72
|
+
.requiredOption('-r, --resource <type>', 'Resource type')
|
|
73
|
+
.action((options) => forkViewResourceCommand(options));
|
|
74
|
+
fork
|
|
75
|
+
.command('fund')
|
|
76
|
+
.description('Fund an account in the fork')
|
|
77
|
+
.option('-f, --fork <path>', 'Path to the fork')
|
|
78
|
+
.requiredOption('-a, --account <address>', 'Account address')
|
|
79
|
+
.requiredOption('--amount <amount>', 'Amount to fund')
|
|
80
|
+
.option('--coin-type <type>', 'Coin type', '0x1::aptos_coin::AptosCoin')
|
|
81
|
+
.action((options) => forkFundCommand(options));
|
|
82
|
+
fork
|
|
83
|
+
.command('list')
|
|
84
|
+
.description('List all available forks')
|
|
85
|
+
.action(() => forkListCommand());
|
|
86
|
+
fork
|
|
87
|
+
.command('serve')
|
|
88
|
+
.description('Start a local RPC server serving the fork')
|
|
89
|
+
.option('-f, --fork <path>', 'Path to the fork')
|
|
90
|
+
.option('-p, --port <port>', 'Port to listen on (default: 8080)', parsePort, 8080)
|
|
91
|
+
.action((options) => forkServeCommand(options));
|
|
92
|
+
program.parse(process.argv);
|
|
93
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,WAAW,MAAM,oBAAoB,CAAC;AAC7C,OAAO,cAAc,MAAM,uBAAuB,CAAC;AACnD,OAAO,WAAW,MAAM,oBAAoB,CAAC;AAC7C,OAAO,UAAU,MAAM,mBAAmB,CAAC;AAC3C,OAAO,iBAAiB,MAAM,2BAA2B,CAAC;AAC1D,OAAO,uBAAuB,MAAM,kCAAkC,CAAC;AACvE,OAAO,eAAe,M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oB,EAAE,WAAW,EAAE,4BAA4B,CAAC;KACvE,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC;AAEnD,IAAI;KACC,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,0BAA0B,CAAC;KACvC,MAAM,CAAC,GAAG,EAAE,CAAC,eAAe,EAAE,CAAC,CAAC;AAErC,IAAI;KACC,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,2CAA2C,CAAC;KACxD,MAAM,CAAC,mBAAmB,EAAE,kBAAkB,CAAC;KAC/C,MAAM,CAAC,mBAAmB,EAAE,mCAAmC,EAAE,SAAS,EAAE,IAAI,CAAC;KACjF,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;AAEpD,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/commands/compile.ts"],"names":[],"mappings":"AAoBA,wBAA8B,cAAc,kBA+D3C"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { exec } from "child_process";
|
|
4
|
+
import { loadUserConfig } from "../core/config.js";
|
|
5
|
+
import { validateAndEscapePath, escapeShellArg } from "../core/shell.js";
|
|
6
|
+
function run(command, cwd) {
|
|
7
|
+
return new Promise((resolve, reject) => {
|
|
8
|
+
exec(command, { cwd }, (error, stdout, stderr) => {
|
|
9
|
+
if (stdout)
|
|
10
|
+
console.log(stdout.trim());
|
|
11
|
+
if (stderr)
|
|
12
|
+
console.error(stderr.trim());
|
|
13
|
+
if (error) {
|
|
14
|
+
reject(error);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
resolve();
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
export default async function compileCommand() {
|
|
22
|
+
try {
|
|
23
|
+
// Compile is network-independent - only uses global config
|
|
24
|
+
const userConfig = await loadUserConfig();
|
|
25
|
+
console.log("š¦ Compiling Move contracts (network-independent)...");
|
|
26
|
+
const moveDir = path.resolve(process.cwd(), userConfig.moveDir || "./move");
|
|
27
|
+
if (!fs.existsSync(moveDir)) {
|
|
28
|
+
console.error(`ā Move directory not found: ${moveDir}`);
|
|
29
|
+
console.error(` Update movehat.config.ts -> moveDir`);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
// Validate and escape to prevent command injection
|
|
33
|
+
const safeMoveDir = validateAndEscapePath(moveDir, "Move directory");
|
|
34
|
+
// Use global named addresses for compilation
|
|
35
|
+
const namedAddresses = userConfig.namedAddresses ?? {};
|
|
36
|
+
let namedAddressesArg = "";
|
|
37
|
+
if (Object.keys(namedAddresses).length > 0) {
|
|
38
|
+
// Validate and escape each address name and value
|
|
39
|
+
const escapedAddresses = Object.entries(namedAddresses)
|
|
40
|
+
.map(([k, v]) => {
|
|
41
|
+
// Validate address name (alphanumeric, underscore only)
|
|
42
|
+
if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(k)) {
|
|
43
|
+
throw new Error(`Invalid named address "${k}". ` +
|
|
44
|
+
`Names must start with a letter or underscore and contain only alphanumeric characters and underscores.`);
|
|
45
|
+
}
|
|
46
|
+
// Validate address value (should be hex address)
|
|
47
|
+
if (!/^0x[a-fA-F0-9]+$/.test(v)) {
|
|
48
|
+
throw new Error(`Invalid address value for "${k}": "${v}". ` +
|
|
49
|
+
`Address values must be hex strings starting with "0x".`);
|
|
50
|
+
}
|
|
51
|
+
// No need to escape since we validated the format
|
|
52
|
+
return `${k}=${v}`;
|
|
53
|
+
})
|
|
54
|
+
.join(",");
|
|
55
|
+
namedAddressesArg = `--named-addresses ${escapeShellArg(escapedAddresses)}`;
|
|
56
|
+
}
|
|
57
|
+
const command = `movement move build --package-dir ${safeMoveDir} ${namedAddressesArg}`.trim();
|
|
58
|
+
console.log(` Move directory: ${moveDir}`);
|
|
59
|
+
if (Object.keys(namedAddresses).length > 0) {
|
|
60
|
+
console.log(` Named addresses: ${Object.keys(namedAddresses).join(", ")}`);
|
|
61
|
+
}
|
|
62
|
+
console.log();
|
|
63
|
+
await run(command, moveDir);
|
|
64
|
+
console.log("ā
Compilation finished successfully.");
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
console.error("ā Compilation failed:", err.message ?? err);
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=compile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile.js","sourceRoot":"","sources":["../../src/commands/compile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEzE,SAAS,GAAG,CAAC,OAAe,EAAE,GAAW;IACvC,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC3C,IAAI,CAAC,OAAO,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;YAC/C,IAAI,MAAM;gBAAE,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;YACvC,IAAI,MAAM;gBAAE,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;YACzC,IAAI,KAAK,EAAE,CAAC;gBACV,MAAM,CAAC,KAAK,CAAC,CAAC;gBACd,OAAO;YACT,CAAC;YACD,OAAO,EAAE,CAA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,CAAC,CAAC,EAAE,CAAC;oBAChC,MAAM,IAAI,KAAK,CACb,8BAA8B,CAAC,OAAO,CAAC,KAAK;wBAC5C,wDAAwD,CACzD,CAAC;gBACJ,CAAC;gBAED,kDAAkD;gBAClD,OAAO,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACrB,CAAC,CAAC;iBACD,IAAI,CAAC,GAAG,CAAC,CAAC;YAEb,iBAAiB,GAAG,qBAAqB,cAAc,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAC9E,CAAC;QAED,MAAM,OAAO,GAAG,qCAAqC,WAAW,IAAI,iBAAiB,EAAE,CAAC,IAAI,EAAE,CAAC;QAE/F,OAAO,CAAC,GAAG,CAAC,sBAAsB,OAAO,EAAE,CAAC,CAAC;QAC7C,IAAI,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3C,OAAO,CAAC,GAAG,CAAC,uBAAuB,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC/E,CAAC;QACD,OAAO,CAAC,GAAG,EAAE,CAAC;QAEd,MAAM,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC5B,OAAO,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC;IACtD,CAAC;IAAC,OAAO,GAAQ,EAAE,CAAC;QAClB,OAAO,CAAC,KAAK,CAAC,uBAAuB,EAAE,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,CAAC;QAC3D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface ForkCreateOptions {
|
|
2
|
+
network?: string;
|
|
3
|
+
path?: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Fork create command: Create a local fork of a Movement/Aptos network
|
|
8
|
+
*/
|
|
9
|
+
export default function forkCreateCommand(options?: ForkCreateOptions): Promise<void>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=create.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/fork/create.ts"],"names":[],"mappings":"AAMA,UAAU,iBAAiB;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,wBAA8B,iBAAiB,CAAC,OAAO,GAAE,iBAAsB,iBAsD9E"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { join } from 'path';
|
|
2
|
+
import { existsSync } from 'fs';
|
|
3
|
+
import prompts from 'prompts';
|
|
4
|
+
import { loadUserConfig, resolveNetworkConfig } from '../../core/config.js';
|
|
5
|
+
import { ForkManager } from '../../fork/manager.js';
|
|
6
|
+
/**
|
|
7
|
+
* Fork create command: Create a local fork of a Movement/Aptos network
|
|
8
|
+
*/
|
|
9
|
+
export default async function forkCreateCommand(options = {}) {
|
|
10
|
+
try {
|
|
11
|
+
// Load MoveHat config
|
|
12
|
+
const userConfig = await loadUserConfig();
|
|
13
|
+
const networkName = options.network || process.env.MH_CLI_NETWORK || userConfig.defaultNetwork || 'testnet';
|
|
14
|
+
const networkConfig = await resolveNetworkConfig(userConfig, networkName);
|
|
15
|
+
// Determine fork name and path
|
|
16
|
+
const forkName = options.name || `${networkName}-fork`;
|
|
17
|
+
const forkPath = options.path || join(process.cwd(), '.movehat', 'forks', forkName);
|
|
18
|
+
console.log(`\nš¦ Creating fork of ${networkName}`);
|
|
19
|
+
console.log(` Network: ${networkConfig.rpc}`);
|
|
20
|
+
console.log(` Fork path: ${forkPath}`);
|
|
21
|
+
// Check if fork already exists
|
|
22
|
+
if (existsSync(forkPath)) {
|
|
23
|
+
const { overwrite } = await prompts({
|
|
24
|
+
type: 'confirm',
|
|
25
|
+
name: 'overwrite',
|
|
26
|
+
message: `Fork already exists at ${forkPath}. Overwrite?`,
|
|
27
|
+
initial: false,
|
|
28
|
+
});
|
|
29
|
+
if (!overwrite) {
|
|
30
|
+
console.log('ā Fork creation cancelled');
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// Create fork manager
|
|
35
|
+
const forkManager = new ForkManager(forkPath);
|
|
36
|
+
// Initialize fork
|
|
37
|
+
console.log(`\nāļø Initializing fork...`);
|
|
38
|
+
await forkManager.initialize(networkConfig.rpc, networkName);
|
|
39
|
+
const metadata = forkManager.getMetadata();
|
|
40
|
+
console.log(`\nā
Fork created successfully!\n`);
|
|
41
|
+
console.log(`Fork Details:`);
|
|
42
|
+
console.log(` Chain ID: ${metadata.chainId}`);
|
|
43
|
+
console.log(` Ledger Version: ${metadata.ledgerVersion}`);
|
|
44
|
+
console.log(` Block Height: ${metadata.blockHeight}`);
|
|
45
|
+
console.log(` Epoch: ${metadata.epoch}`);
|
|
46
|
+
console.log(`\nUsage:`);
|
|
47
|
+
console.log(` movehat fork view-resource --fork ${forkPath} --account <ADDRESS> --resource <TYPE>`);
|
|
48
|
+
console.log(` movehat fork fund --fork ${forkPath} --account <ADDRESS> --amount <AMOUNT>`);
|
|
49
|
+
console.log(` movehat fork list\n`);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
console.error(`\nā Error: ${error.message}\n`);
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/commands/fork/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,OAAO,MAAM,SAAS,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3
|
+
account: string;
|
|
4
|
+
amount: string;
|
|
5
|
+
coinType?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Fork fund command: Fund an account in the fork
|
|
9
|
+
*/
|
|
10
|
+
export default function forkFundCommand(options: ForkFundOptions): Promise<void>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=fund.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fund.d.ts","sourceRoot":"","sources":["../../../src/commands/fork/fund.ts"],"names":[],"mappings":"AAGA,UAAU,eAAe;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,wBAA8B,eAAe,CAAC,OAAO,EAAE,eAAe,iBA2CrE"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { join } from 'path';
|
|
2
|
+
import { ForkManager } from '../../fork/manager.js';
|
|
3
|
+
/**
|
|
4
|
+
* Fork fund command: Fund an account in the fork
|
|
5
|
+
*/
|
|
6
|
+
export default async function forkFundCommand(options) {
|
|
7
|
+
try {
|
|
8
|
+
if (!options.account) {
|
|
9
|
+
throw new Error('--account is required');
|
|
10
|
+
}
|
|
11
|
+
if (!options.amount) {
|
|
12
|
+
throw new Error('--amount is required');
|
|
13
|
+
}
|
|
14
|
+
const amount = parseInt(options.amount, 10);
|
|
15
|
+
if (isNaN(amount) || amount <= 0) {
|
|
16
|
+
throw new Error('--amount must be a positive number');
|
|
17
|
+
}
|
|
18
|
+
// Determine fork path
|
|
19
|
+
const forkPath = options.fork || join(process.cwd(), '.movehat', 'forks', 'testnet-fork');
|
|
20
|
+
const coinType = options.coinType || '0x1::aptos_coin::AptosCoin';
|
|
21
|
+
console.log(`\nš° Funding account in fork`);
|
|
22
|
+
console.log(` Fork: ${forkPath}`);
|
|
23
|
+
console.log(` Account: ${options.account}`);
|
|
24
|
+
console.log(` Amount: ${amount}`);
|
|
25
|
+
console.log(` Coin Type: ${coinType}\n`);
|
|
26
|
+
// Load fork
|
|
27
|
+
const forkManager = new ForkManager(forkPath);
|
|
28
|
+
forkManager.load();
|
|
29
|
+
// Fund account
|
|
30
|
+
await forkManager.fundAccount(options.account, amount, coinType);
|
|
31
|
+
// Verify
|
|
32
|
+
const resourceType = `0x1::coin::CoinStore<${coinType}>`;
|
|
33
|
+
const coinStore = await forkManager.getResource(options.account, resourceType);
|
|
34
|
+
console.log(`\nā
Account funded successfully!`);
|
|
35
|
+
console.log(` New balance: ${coinStore.coin.value}\n`);
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
console.error(`\nā Error: ${error.message}\n`);
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=fund.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fund.js","sourceRoot":"","sources":["../../../src/commands/fork/fund.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AASpD;;GAEG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,eAAe,CAAC,OAAwB;IACpE,IAAI,CAAC;QACH,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAC3C,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAC1C,CAAC;QAED,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAC5C,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,MAAM,IAAI,CAAC,EAAE,C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,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/fork/list.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAA8B,eAAe,kBA2D5C"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { join } from 'path';
|
|
2
|
+
import { existsSync, readdirSync, statSync } from 'fs';
|
|
3
|
+
import { ForkStorage } from '../../fork/storage.js';
|
|
4
|
+
/**
|
|
5
|
+
* Fork list command: List all available forks
|
|
6
|
+
*/
|
|
7
|
+
export default async function forkListCommand() {
|
|
8
|
+
try {
|
|
9
|
+
const forksDir = join(process.cwd(), '.movehat', 'forks');
|
|
10
|
+
if (!existsSync(forksDir)) {
|
|
11
|
+
console.log('\nš No forks found\n');
|
|
12
|
+
console.log('Create a fork with:');
|
|
13
|
+
console.log(' movehat fork create --network testnet\n');
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const entries = readdirSync(forksDir);
|
|
17
|
+
const forkDirs = entries.filter((entry) => {
|
|
18
|
+
const fullPath = join(forksDir, entry);
|
|
19
|
+
return statSync(fullPath).isDirectory();
|
|
20
|
+
});
|
|
21
|
+
if (forkDirs.length === 0) {
|
|
22
|
+
console.log('\nš No forks found\n');
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
console.log(`\nš Found ${forkDirs.length} fork(s):\n`);
|
|
26
|
+
for (const forkDir of forkDirs) {
|
|
27
|
+
const forkPath = join(forksDir, forkDir);
|
|
28
|
+
const storage = new ForkStorage(forkPath);
|
|
29
|
+
try {
|
|
30
|
+
if (storage.exists()) {
|
|
31
|
+
const metadata = storage.loadMetadata();
|
|
32
|
+
const accounts = storage.listAccounts();
|
|
33
|
+
console.log(` ${forkDir}`);
|
|
34
|
+
console.log(` Path: ${forkPath}`);
|
|
35
|
+
console.log(` Network: ${metadata.network}`);
|
|
36
|
+
console.log(` Chain ID: ${metadata.chainId}`);
|
|
37
|
+
console.log(` Ledger Version: ${metadata.ledgerVersion}`);
|
|
38
|
+
console.log(` Cached Accounts: ${accounts.length}`);
|
|
39
|
+
console.log(` Created: ${new Date(metadata.createdAt).toLocaleString()}`);
|
|
40
|
+
console.log('');
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
console.log(` ${forkDir} (invalid - missing metadata)`);
|
|
44
|
+
console.log('');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
console.log(` ${forkDir} (error reading metadata)`);
|
|
49
|
+
console.log('');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
console.log('Usage:');
|
|
53
|
+
console.log(' movehat fork view-resource --fork <PATH> --account <ADDR> --resource <TYPE>');
|
|
54
|
+
console.log(' movehat fork fund --fork <PATH> --account <ADDR> --amount <AMOUNT>\n');
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
console.error(`\nā Error: ${error.message}\n`);
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=list.js.map
|