mobilestacks 0.1.29 → 0.1.30
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
CHANGED
|
@@ -67,6 +67,7 @@ Missing required params are prompted interactively. Run any task with `--help` f
|
|
|
67
67
|
| `callcontractfunction` | Call a read-only contract function |
|
|
68
68
|
| `getcontractinfo` | Fetch deployed contract metadata |
|
|
69
69
|
| `verifycontract` | Diff on-chain source against a local file |
|
|
70
|
+
| `setupsimnet` | Generate local Simnet/Devnet configuration and test accounts |
|
|
70
71
|
|
|
71
72
|
## Writing Tasks
|
|
72
73
|
|
|
@@ -115,6 +116,8 @@ extendEnvironment((env) => {
|
|
|
115
116
|
|
|
116
117
|
## Testing with Simnet
|
|
117
118
|
|
|
119
|
+
**Simnet** (simulated network) is a local, offline simulation of the Stacks provided by Clarinet. It is used to test smart contracts rapidly and deterministically without needing to run a full node, use a public testnet, or wait for real block times.
|
|
120
|
+
|
|
118
121
|
Test contracts locally using the Clarinet SDK. No devnet is needed:
|
|
119
122
|
|
|
120
123
|
```ts
|
|
@@ -139,10 +142,10 @@ describe('My Contract', () => {
|
|
|
139
142
|
|
|
140
143
|
### Setup
|
|
141
144
|
|
|
142
|
-
Contract tests need a `Clarinet.toml` and test accounts. Run the setup
|
|
145
|
+
Contract tests need a `Clarinet.toml` and test accounts. Run the setup task once:
|
|
143
146
|
|
|
144
147
|
```bash
|
|
145
|
-
|
|
148
|
+
npx mobilestacks setupsimnet
|
|
146
149
|
```
|
|
147
150
|
|
|
148
151
|
Then run tests:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SetupSimnet.d.ts","sourceRoot":"","sources":["../../src/tasks/SetupSimnet.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const dsl_1 = require("../core/dsl");
|
|
7
|
+
const wallet_sdk_1 = require("@stacks/wallet-sdk");
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
(0, dsl_1.task)('setupsimnet', 'Generates Simnet.toml and Devnet.toml with test accounts')
|
|
11
|
+
.setAction(async () => {
|
|
12
|
+
const dir = path_1.default.resolve(process.cwd(), 'settings');
|
|
13
|
+
if (!fs_1.default.existsSync(dir))
|
|
14
|
+
fs_1.default.mkdirSync(dir, { recursive: true });
|
|
15
|
+
const accounts = ['deployer', 'wallet_1', 'wallet_2'];
|
|
16
|
+
const sections = accounts.map((name) => {
|
|
17
|
+
const mnemonic = (0, wallet_sdk_1.generateSecretKey)();
|
|
18
|
+
return `[accounts.${name}]\nmnemonic = "${mnemonic}"\nbalance = 100_000_000_000_000`;
|
|
19
|
+
});
|
|
20
|
+
const toml = `[network]\nname = "simnet"\n\n${sections.join('\n\n')}\n`;
|
|
21
|
+
fs_1.default.writeFileSync(path_1.default.join(dir, 'Simnet.toml'), toml, 'utf-8');
|
|
22
|
+
fs_1.default.writeFileSync(path_1.default.join(dir, 'Devnet.toml'), toml.replace(/simnet/g, 'devnet'), 'utf-8');
|
|
23
|
+
return 'Generated settings/Simnet.toml and settings/Devnet.toml with test accounts';
|
|
24
|
+
});
|