@j0nnyboi/amman
Version:
A modern mandatory toolbelt to help test solana SDK libraries and apps on a locally running validator.
57 lines • 2.11 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.safeJsonStringify = exports.tmpLedgerDir = exports.createHash = exports.sleep = void 0;
const crypto_1 = __importDefault(require("crypto"));
const os_1 = require("os");
const path_1 = __importDefault(require("path"));
__exportStar(require("./guards"), exports);
__exportStar(require("./log"), exports);
/**
* @private
*/
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
exports.sleep = sleep;
/**
* @private
*/
function createHash(s) {
return crypto_1.default.createHash('sha256').update(s).digest('hex');
}
exports.createHash = createHash;
/**
* Gets the path to a temporary directory in which to store the test
* validator ledger.
*
* @param testLabel label used to name that directory
* @category utils
*/
function tmpLedgerDir(testLabel = 'amman-ledger') {
return path_1.default.join((0, os_1.tmpdir)(), testLabel);
}
exports.tmpLedgerDir = tmpLedgerDir;
/**
* Custom JSON.stringify which avoids failing on bigint values
* @category utils
*/
function safeJsonStringify(obj) {
return JSON.stringify(obj, (_, value) => typeof value === 'bigint' ? value.toString() : value);
}
exports.safeJsonStringify = safeJsonStringify;
//# sourceMappingURL=index.js.map