@stacks/rendezvous 0.9.0 → 0.10.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/dist/app.js +7 -19
- package/dist/citizen.js +47 -16
- package/dist/package.json +5 -5
- package/package.json +5 -5
package/dist/app.js
CHANGED
|
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
14
|
};
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.tryParseRemoteDataSettings = exports.getManifestFileName = exports.
|
|
16
|
+
exports.tryParseRemoteDataSettings = exports.getManifestFileName = exports.noRemoteData = void 0;
|
|
17
17
|
exports.main = main;
|
|
18
18
|
const path_1 = require("path");
|
|
19
19
|
const events_1 = require("events");
|
|
@@ -35,16 +35,7 @@ const logger = (log, logLevel = "log") => {
|
|
|
35
35
|
*/
|
|
36
36
|
exports.noRemoteData = {
|
|
37
37
|
enabled: false,
|
|
38
|
-
api_url: "",
|
|
39
|
-
initial_height: 1,
|
|
40
38
|
};
|
|
41
|
-
exports.invalidRemoteDataWarningMessage = `\nRemote data settings existing in Clarinet.toml, but remote data feature will not be used! To use remote data, please make sure the following fields are set:
|
|
42
|
-
|
|
43
|
-
- enabled = true
|
|
44
|
-
- api_url = <stacks-api-url>
|
|
45
|
-
- initial_height = <stacks-block-height-to-fork-from>
|
|
46
|
-
|
|
47
|
-
under the "repl.remote_data" section in the Clarinet.toml file.`;
|
|
48
39
|
/**
|
|
49
40
|
* Gets the manifest file name for a Clarinet project.
|
|
50
41
|
* If a custom manifest exists (`Clarinet-<contract-name>.toml`), it is used.
|
|
@@ -64,17 +55,14 @@ exports.getManifestFileName = getManifestFileName;
|
|
|
64
55
|
const tryParseRemoteDataSettings = (manifestPath, radio) => {
|
|
65
56
|
var _a, _b;
|
|
66
57
|
const clarinetToml = toml_1.default.parse((0, fs_1.readFileSync)((0, path_1.resolve)(manifestPath), "utf-8"));
|
|
67
|
-
const remoteDataUserSettings = (_b = (_a = clarinetToml.repl) === null || _a === void 0 ? void 0 : _a
|
|
68
|
-
|
|
69
|
-
!(remoteDataUserSettings === null || remoteDataUserSettings === void 0 ? void 0 : remoteDataUserSettings["enabled"]) ||
|
|
70
|
-
!(remoteDataUserSettings === null || remoteDataUserSettings === void 0 ? void 0 : remoteDataUserSettings["initial_height"]);
|
|
71
|
-
if (remoteDataUserSettings !== undefined && invalidRemoteDataSetup) {
|
|
72
|
-
radio.emit("logMessage", (0, ansicolor_1.yellow)(exports.invalidRemoteDataWarningMessage));
|
|
73
|
-
}
|
|
74
|
-
else if (remoteDataUserSettings) {
|
|
58
|
+
const remoteDataUserSettings = (_b = (_a = clarinetToml.repl) === null || _a === void 0 ? void 0 : _a.remote_data) !== null && _b !== void 0 ? _b : undefined;
|
|
59
|
+
if (remoteDataUserSettings && (remoteDataUserSettings === null || remoteDataUserSettings === void 0 ? void 0 : remoteDataUserSettings.enabled) === true) {
|
|
75
60
|
radio.emit("logMessage", (0, ansicolor_1.yellow)("\nUsing remote data. Setting up the environment can take up to a minute..."));
|
|
76
61
|
}
|
|
77
|
-
|
|
62
|
+
// If no remote data settings are provided, we still need to return an object
|
|
63
|
+
// with the `enabled` property set to `false`. That is what simnet expects
|
|
64
|
+
// at least in order to initialize an empty simnet session.
|
|
65
|
+
if (!remoteDataUserSettings) {
|
|
78
66
|
return exports.noRemoteData;
|
|
79
67
|
}
|
|
80
68
|
return remoteDataUserSettings;
|
package/dist/citizen.js
CHANGED
|
@@ -50,7 +50,9 @@ const issueFirstClassCitizenship = (manifestDir, manifestPath, remoteDataSetting
|
|
|
50
50
|
const balanceHex = simnet.runSnippet(`(stx-get-balance '${address})`);
|
|
51
51
|
return [address, (0, transactions_1.cvToValue)((0, transactions_1.hexToCV)(balanceHex))];
|
|
52
52
|
}));
|
|
53
|
-
|
|
53
|
+
// If the sbtc-token contract is included in the deployment plan, we need to
|
|
54
|
+
// restore the sBTC balances. Otherwise, use an empty map.
|
|
55
|
+
const sbtcBalancesMap = (0, exports.getSbtcBalancesFromSimnet)(simnet, deploymentPlan, remoteDataSettings);
|
|
54
56
|
yield simnet.initEmptySession(remoteDataSettings);
|
|
55
57
|
simnetAddresses.forEach((address) => {
|
|
56
58
|
simnet.mintSTX(address, stxBalancesMap.get(address));
|
|
@@ -323,30 +325,59 @@ function scheduleRendezvous(targetContractSource, tests) {
|
|
|
323
325
|
(ok (map-set context function-name {called: called})))`;
|
|
324
326
|
return `${targetContractSource}\n\n${context}\n\n${tests}`;
|
|
325
327
|
}
|
|
328
|
+
/**
|
|
329
|
+
* Checks if a contract can be found in the deployment plan.
|
|
330
|
+
* @param deploymentPlan The parsed deployment plan.
|
|
331
|
+
* @param contractAddress The address of the contract.
|
|
332
|
+
* @param contractName The name of the contract.
|
|
333
|
+
* @returns True if the contract can be found in the deployment plan, false
|
|
334
|
+
* otherwise.
|
|
335
|
+
*/
|
|
336
|
+
const isContractInDeploymentPlan = (deploymentPlan, contractAddress, contractName) => {
|
|
337
|
+
return deploymentPlan.plan.batches.some((batch) => batch.transactions.some((transaction) => {
|
|
338
|
+
var _a, _b;
|
|
339
|
+
return ((_a = transaction["emulated-contract-publish"]) === null || _a === void 0 ? void 0 : _a["contract-name"]) ===
|
|
340
|
+
contractName &&
|
|
341
|
+
((_b = transaction["emulated-contract-publish"]) === null || _b === void 0 ? void 0 : _b["emulated-sender"]) ===
|
|
342
|
+
contractAddress;
|
|
343
|
+
}));
|
|
344
|
+
};
|
|
326
345
|
/**
|
|
327
346
|
* Maps the simnet accounts to their sBTC balances. The function tries to call
|
|
328
347
|
* the `get-balance` function of the `sbtc-token` contract for each address. If
|
|
329
348
|
* the call fails, it returns a balance of 0 for that address. The call fails
|
|
330
349
|
* if the user is not working with sBTC.
|
|
331
350
|
* @param simnet The simnet instance.
|
|
351
|
+
* @param deploymentPlan The parsed deployment plan.
|
|
352
|
+
* @param remoteDataSettings The remote data settings.
|
|
332
353
|
* @returns A map of addresses to their sBTC balances.
|
|
333
354
|
*/
|
|
334
|
-
const getSbtcBalancesFromSimnet = (simnet
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
// represented as a string. We need to parse it to an integer.
|
|
343
|
-
const sbtcBalance = parseInt(sbtcBalanceJSON.value.value, 10);
|
|
344
|
-
return [address, sbtcBalance];
|
|
345
|
-
}
|
|
346
|
-
catch (e) {
|
|
347
|
-
return [address, 0];
|
|
355
|
+
const getSbtcBalancesFromSimnet = (simnet, deploymentPlan, remoteDataSettings) => {
|
|
356
|
+
// If the user is not using remote data and the deployment plan does not
|
|
357
|
+
// contain the `sbtc-token` contract, return a map with 0 balances for all
|
|
358
|
+
// addresses. When remote data is enabled, the sbtc-token contract will not
|
|
359
|
+
// necessarily be present in the deployment plan.
|
|
360
|
+
if (!remoteDataSettings.enabled &&
|
|
361
|
+
!isContractInDeploymentPlan(deploymentPlan, "SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4", "sbtc-token")) {
|
|
362
|
+
return new Map([...simnet.getAccounts().values()].map((address) => [address, 0]));
|
|
348
363
|
}
|
|
349
|
-
|
|
364
|
+
return new Map([...simnet.getAccounts().values()].map((address) => {
|
|
365
|
+
try {
|
|
366
|
+
const { result: getBalanceResult } = simnet.callReadOnlyFn("SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token", "get-balance", [transactions_1.Cl.principal(address)], address);
|
|
367
|
+
// If the previous read-only call works, the user is working with
|
|
368
|
+
// sBTC. This means we can proceed with restoring sBTC balances.
|
|
369
|
+
const sbtcBalanceJSON = (0, transactions_1.cvToJSON)(getBalanceResult);
|
|
370
|
+
// The `get-balance` function returns a response containing the uint
|
|
371
|
+
// balance of the address. In the JSON representation, the balance is
|
|
372
|
+
// represented as a string. We need to parse it to an integer.
|
|
373
|
+
const sbtcBalance = parseInt(sbtcBalanceJSON.value.value, 10);
|
|
374
|
+
return [address, sbtcBalance];
|
|
375
|
+
}
|
|
376
|
+
catch (e) {
|
|
377
|
+
return [address, 0];
|
|
378
|
+
}
|
|
379
|
+
}));
|
|
380
|
+
};
|
|
350
381
|
exports.getSbtcBalancesFromSimnet = getSbtcBalancesFromSimnet;
|
|
351
382
|
/**
|
|
352
383
|
* Utility function that restores the test wallets' initial sBTC balances in
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacks/rendezvous",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Meet your contract's vulnerabilities head-on.",
|
|
5
5
|
"main": "app.js",
|
|
6
6
|
"bin": {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"build": "npx -p typescript tsc --project tsconfig.json && node -e \"if (process.platform !== 'win32') require('fs').chmodSync('./dist/app.js', 0o755);\"",
|
|
11
|
-
"test": "npx jest",
|
|
11
|
+
"test": "npx jest --testTimeout=15000",
|
|
12
12
|
"test:coverage": "npx tsc --project tsconfig.json && npx jest --coverage"
|
|
13
13
|
},
|
|
14
14
|
"keywords": [
|
|
@@ -30,15 +30,15 @@
|
|
|
30
30
|
"url": "https://github.com/stacks-network/rendezvous.git"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@hirosystems/clarinet-sdk": "^3.0
|
|
34
|
-
"@stacks/transactions": "^7.0
|
|
33
|
+
"@hirosystems/clarinet-sdk": "^3.7.0",
|
|
34
|
+
"@stacks/transactions": "^7.2.0",
|
|
35
35
|
"ansicolor": "^2.0.3",
|
|
36
36
|
"fast-check": "^3.20.0",
|
|
37
37
|
"toml": "^3.0.0",
|
|
38
38
|
"yaml": "^2.6.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@hirosystems/clarinet-sdk-wasm": "^3.0
|
|
41
|
+
"@hirosystems/clarinet-sdk-wasm": "^3.7.0",
|
|
42
42
|
"@types/jest": "^29.5.12",
|
|
43
43
|
"jest": "^29.7.0",
|
|
44
44
|
"ts-jest": "^29.2.5",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacks/rendezvous",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Meet your contract's vulnerabilities head-on.",
|
|
5
5
|
"main": "app.js",
|
|
6
6
|
"bin": {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"build": "npx -p typescript tsc --project tsconfig.json && node -e \"if (process.platform !== 'win32') require('fs').chmodSync('./dist/app.js', 0o755);\"",
|
|
11
|
-
"test": "npx jest",
|
|
11
|
+
"test": "npx jest --testTimeout=15000",
|
|
12
12
|
"test:coverage": "npx tsc --project tsconfig.json && npx jest --coverage"
|
|
13
13
|
},
|
|
14
14
|
"keywords": [
|
|
@@ -30,15 +30,15 @@
|
|
|
30
30
|
"url": "https://github.com/stacks-network/rendezvous.git"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@hirosystems/clarinet-sdk": "^3.0
|
|
34
|
-
"@stacks/transactions": "^7.0
|
|
33
|
+
"@hirosystems/clarinet-sdk": "^3.7.0",
|
|
34
|
+
"@stacks/transactions": "^7.2.0",
|
|
35
35
|
"ansicolor": "^2.0.3",
|
|
36
36
|
"fast-check": "^3.20.0",
|
|
37
37
|
"toml": "^3.0.0",
|
|
38
38
|
"yaml": "^2.6.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@hirosystems/clarinet-sdk-wasm": "^3.0
|
|
41
|
+
"@hirosystems/clarinet-sdk-wasm": "^3.7.0",
|
|
42
42
|
"@types/jest": "^29.5.12",
|
|
43
43
|
"jest": "^29.7.0",
|
|
44
44
|
"ts-jest": "^29.2.5",
|