movehat 0.0.6-alpha.0 → 0.0.8-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 +70 -27
- package/dist/commands/compile.d.ts.map +1 -1
- package/dist/commands/compile.js +79 -8
- package/dist/commands/compile.js.map +1 -1
- package/dist/commands/init.js +7 -7
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/test.js +4 -4
- package/dist/commands/test.js.map +1 -1
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +50 -8
- package/dist/core/config.js.map +1 -1
- package/dist/templates/README.md +55 -26
- package/dist/templates/move/Move.toml +2 -0
- package/dist/templates/movehat.config.ts +10 -0
- package/dist/templates/package.json +1 -1
- package/dist/templates/tests/Counter.test.ts +47 -50
- package/package.json +1 -1
- package/src/commands/compile.ts +93 -8
- package/src/commands/init.ts +7 -7
- package/src/commands/test.ts +4 -4
- package/src/core/config.ts +54 -10
- package/src/templates/README.md +55 -26
- package/src/templates/move/Move.toml +2 -0
- package/src/templates/movehat.config.ts +10 -0
- package/src/templates/package.json +1 -1
- package/src/templates/tests/Counter.test.ts +47 -50
- /package/dist/templates/move/{Counter.move → sources/Counter.move} +0 -0
- /package/src/templates/move/{Counter.move → sources/Counter.move} +0 -0
|
@@ -1,75 +1,72 @@
|
|
|
1
|
-
|
|
1
|
+
// @ts-nocheck - This is a template file, dependencies are installed in user projects
|
|
2
|
+
import { describe, it, before } from "mocha";
|
|
2
3
|
import { expect } from "chai";
|
|
3
4
|
import { getMovehat, type MovehatRuntime } from "movehat";
|
|
4
|
-
import type { MoveContract } from "movehat/helpers";
|
|
5
|
-
import { assertTransactionSuccess, snapshot } from "movehat/helpers";
|
|
6
5
|
|
|
7
6
|
describe("Counter Contract", () => {
|
|
8
7
|
let mh: MovehatRuntime;
|
|
9
|
-
let
|
|
8
|
+
let contractAddress: string;
|
|
10
9
|
|
|
11
10
|
before(async function () {
|
|
12
11
|
this.timeout(30000);
|
|
13
12
|
|
|
14
13
|
// Initialize Movehat Runtime Environment
|
|
14
|
+
// Uses testnet by default - no local setup required
|
|
15
15
|
mh = await getMovehat();
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
console.log(` Account: ${mh.account.accountAddress.toString()}\n`);
|
|
17
|
+
contractAddress = mh.account.accountAddress.toString();
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
mh.account.accountAddress.toString(),
|
|
23
|
-
"counter"
|
|
24
|
-
);
|
|
19
|
+
console.log(`\nTesting on ${mh.network.name}`);
|
|
20
|
+
console.log(`Account: ${contractAddress}\n`);
|
|
25
21
|
});
|
|
26
22
|
|
|
27
23
|
describe("Counter functionality", () => {
|
|
28
|
-
it("should initialize counter", async function () {
|
|
24
|
+
it("should initialize counter using simulation", async function () {
|
|
29
25
|
this.timeout(30000);
|
|
30
26
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
27
|
+
// Build transaction
|
|
28
|
+
const transaction = await mh.aptos.transaction.build.simple({
|
|
29
|
+
sender: mh.account.accountAddress,
|
|
30
|
+
data: {
|
|
31
|
+
function: `${contractAddress}::counter::init`,
|
|
32
|
+
functionArguments: []
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// Simulate transaction (no gas cost, instant)
|
|
37
|
+
const [simulation] = await mh.aptos.transaction.simulate.simple({
|
|
38
|
+
signerPublicKey: mh.account.publicKey,
|
|
39
|
+
transaction
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// Verify simulation succeeded
|
|
43
|
+
expect(simulation.success).to.be.true;
|
|
44
|
+
console.log(`Counter init simulated successfully`);
|
|
45
|
+
console.log(`Gas used: ${simulation.gas_used}`);
|
|
40
46
|
});
|
|
41
47
|
|
|
42
|
-
it("should increment counter", async function () {
|
|
48
|
+
it("should increment counter using simulation", async function () {
|
|
43
49
|
this.timeout(30000);
|
|
44
50
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
// Build increment transaction
|
|
52
|
+
const transaction = await mh.aptos.transaction.build.simple({
|
|
53
|
+
sender: mh.account.accountAddress,
|
|
54
|
+
data: {
|
|
55
|
+
function: `${contractAddress}::counter::increment`,
|
|
56
|
+
functionArguments: []
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// Simulate transaction
|
|
61
|
+
const [simulation] = await mh.aptos.transaction.simulate.simple({
|
|
62
|
+
signerPublicKey: mh.account.publicKey,
|
|
63
|
+
transaction
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// Verify simulation succeeded
|
|
67
|
+
expect(simulation.success).to.be.true;
|
|
68
|
+
console.log(`Counter increment simulated successfully`);
|
|
69
|
+
console.log(`Gas used: ${simulation.gas_used}`);
|
|
58
70
|
});
|
|
59
71
|
});
|
|
60
|
-
|
|
61
|
-
// Optional: Create a snapshot after tests for debugging
|
|
62
|
-
// Uncomment to enable
|
|
63
|
-
/*
|
|
64
|
-
after(async function () {
|
|
65
|
-
this.timeout(30000);
|
|
66
|
-
|
|
67
|
-
const snapshotPath = await snapshot({
|
|
68
|
-
name: 'counter-test-final'
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
console.log(`\n📸 Snapshot created: ${snapshotPath}`);
|
|
72
|
-
console.log(` Use 'aptos move sim view-resource --session ${snapshotPath}' to inspect state\n`);
|
|
73
|
-
});
|
|
74
|
-
*/
|
|
75
72
|
});
|
|
File without changes
|
|
File without changes
|