mobilestacks 0.1.27 → 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 +7 -2
- package/dist/cli/init.js +1 -1
- package/dist/tasks/SetupSimnet.d.ts +2 -0
- package/dist/tasks/SetupSimnet.d.ts.map +1 -0
- package/dist/tasks/SetupSimnet.js +24 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# mobilestacks
|
|
2
2
|
|
|
3
3
|
[](https://badge.fury.io/js/mobilestacks)
|
|
4
|
+
[](https://www.npmjs.com/package/mobilestacks)
|
|
5
|
+
[](https://nodejs.org/)
|
|
4
6
|
[](https://opensource.org/licenses/MIT)
|
|
5
7
|
|
|
6
8
|
A Hardhat-style development framework for Stacks. Write, test, and deploy Clarity smart contracts with a task-based CLI, local Simnet testing, and a pluggable runtime.
|
|
@@ -65,6 +67,7 @@ Missing required params are prompted interactively. Run any task with `--help` f
|
|
|
65
67
|
| `callcontractfunction` | Call a read-only contract function |
|
|
66
68
|
| `getcontractinfo` | Fetch deployed contract metadata |
|
|
67
69
|
| `verifycontract` | Diff on-chain source against a local file |
|
|
70
|
+
| `setupsimnet` | Generate local Simnet/Devnet configuration and test accounts |
|
|
68
71
|
|
|
69
72
|
## Writing Tasks
|
|
70
73
|
|
|
@@ -113,6 +116,8 @@ extendEnvironment((env) => {
|
|
|
113
116
|
|
|
114
117
|
## Testing with Simnet
|
|
115
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
|
+
|
|
116
121
|
Test contracts locally using the Clarinet SDK. No devnet is needed:
|
|
117
122
|
|
|
118
123
|
```ts
|
|
@@ -137,10 +142,10 @@ describe('My Contract', () => {
|
|
|
137
142
|
|
|
138
143
|
### Setup
|
|
139
144
|
|
|
140
|
-
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:
|
|
141
146
|
|
|
142
147
|
```bash
|
|
143
|
-
|
|
148
|
+
npx mobilestacks setupsimnet
|
|
144
149
|
```
|
|
145
150
|
|
|
146
151
|
Then run tests:
|
package/dist/cli/init.js
CHANGED
|
@@ -82,7 +82,7 @@ STACKS_TESTNET_URL=${answers.testnetUrl}
|
|
|
82
82
|
writeFileIfMissing(sampleContractPath, '(define-public (hello-world)\n (ok "Hello, Stacks!"))\n');
|
|
83
83
|
if (!fs_1.default.existsSync(tasksDir))
|
|
84
84
|
fs_1.default.mkdirSync(tasksDir, { recursive: true });
|
|
85
|
-
writeFileIfMissing(exampleTaskPath, "import { task } from 'mobilestacks';\n\ntask('example', 'An example user task for onboarding')\n .addParam('name', 'Your name', { type: 'string', required: false, defaultValue: 'World' })\n .setAction((args) => {\n return `Hello, ${args.name}! Welcome to mobilestacks.`;\n });\n");
|
|
85
|
+
writeFileIfMissing(exampleTaskPath, "import { task } from 'mobilestacks';\n\ntask('example', 'An example user task for onboarding')\n .addParam('name', 'Your name', { type: 'string', required: false, defaultValue: 'World' })\n .setAction((args: any) => {\n return `Hello, ${args.name}! Welcome to mobilestacks.`;\n });\n");
|
|
86
86
|
console.log('\nCreated:');
|
|
87
87
|
console.log(' - mobilestacks.config.ts (reads secrets from env vars)');
|
|
88
88
|
console.log(' - .env (store your secrets here)');
|
|
@@ -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
|
+
});
|