UNPKG

@layerzerolabs/hardhat-deploy

Version:

Hardhat Plugin For Replicable Deployments And Tests

67 lines 2.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.strip0x = exports.ensure0x = exports.Time = exports.TronTransactionFailedError = exports.TronWebGetTransactionError = exports.TronWebError = exports.isArrayofBytes = void 0; const isArrayofBytes = (data) => { return (Buffer.isBuffer(data) || (Array.isArray(data) && data.every((num) => typeof num === 'number' && num >= 0 && num <= 255))); }; exports.isArrayofBytes = isArrayofBytes; class TronWebError extends Error { constructor({ code, message, txid }) { // need to convert the message to utf-8 message = Buffer.from(message, 'hex').toString(); super(message); this.code = code; this.name = this.constructor.name; this.hash = txid; } } exports.TronWebError = TronWebError; class TronWebGetTransactionError extends Error { constructor({ Error }) { super(Error); this.name = this.constructor.name; } } exports.TronWebGetTransactionError = TronWebGetTransactionError; class TronTransactionFailedError extends Error { constructor(receipt) { super(`failed execution\n${JSON.stringify(receipt, null, 2)}`); this.receipt = receipt; this.name = this.constructor.name; } } exports.TronTransactionFailedError = TronTransactionFailedError; // Base unit in milliseconds const MILLISECOND = 1; const SECOND = 1000 * MILLISECOND; const MINUTE = 60 * SECOND; const HOUR = 60 * MINUTE; const DAY = 24 * HOUR; exports.Time = { MILLISECOND, SECOND, MINUTE, HOUR, DAY, get NOW() { return Date.now(); }, sleep(ms) { return new Promise((res) => setTimeout(res, ms)); }, }; const ensure0x = (str) => { if (str.startsWith('0x')) return str; return '0x' + str; }; exports.ensure0x = ensure0x; const strip0x = (str) => { if (str.startsWith('0x')) return str.slice(2); return str; }; exports.strip0x = strip0x; //# sourceMappingURL=utils.js.map