@taqueria/plugin-tezbox 0.73.0 → 0.73.9
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/docker.ts +1 -1
- package/index.js +2 -2
- package/index.js.map +1 -1
- package/index.mjs +2 -2
- package/index.mjs.map +1 -1
- package/package.json +3 -3
- package/proxy.ts +1 -1
package/docker.ts
CHANGED
|
@@ -3,6 +3,6 @@ import { Opts } from './types';
|
|
|
3
3
|
|
|
4
4
|
export const TAQ_TEZBOX_IMAGE_ENV_VAR = 'TAQ_TEZBOX_IMAGE';
|
|
5
5
|
|
|
6
|
-
export const getDefaultDockerImage = (opts: Opts) => `ghcr.io/tez-capital/tezbox:tezos-
|
|
6
|
+
export const getDefaultDockerImage = (opts: Opts) => `ghcr.io/tez-capital/tezbox:tezos-v23.0-rc2`;
|
|
7
7
|
|
|
8
8
|
export const getImage = (opts: Opts) => getDockerImage(getDefaultDockerImage(opts), TAQ_TEZBOX_IMAGE_ENV_VAR);
|
package/index.js
CHANGED
|
@@ -37,7 +37,7 @@ var path = __toESM(require("path"));
|
|
|
37
37
|
|
|
38
38
|
// docker.ts
|
|
39
39
|
var import_node_sdk = require("@taqueria/node-sdk");
|
|
40
|
-
var getDefaultDockerImage = (opts) => `ghcr.io/tez-capital/tezbox:tezos-
|
|
40
|
+
var getDefaultDockerImage = (opts) => `ghcr.io/tez-capital/tezbox:tezos-v23.0-rc2`;
|
|
41
41
|
|
|
42
42
|
// proxy.ts
|
|
43
43
|
var logger = {
|
|
@@ -331,7 +331,7 @@ function constructDockerRunCommand(params) {
|
|
|
331
331
|
`--name ${containerName}`,
|
|
332
332
|
`-v "${configDir}:/tezbox/overrides"`,
|
|
333
333
|
image,
|
|
334
|
-
"
|
|
334
|
+
"S"
|
|
335
335
|
];
|
|
336
336
|
return dockerOptions.join(" ");
|
|
337
337
|
}
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts","proxy.ts","docker.ts"],"sourcesContent":["import { Option, Plugin, PositionalArg, Task } from '@taqueria/node-sdk';\nimport proxy from './proxy';\n\nPlugin.create(_i18n => ({\n\talias: 'tezbox',\n\tschema: '1.0',\n\tversion: '0.1',\n\ttasks: [\n\t\tTask.create({\n\t\t\ttask: 'start sandbox',\n\t\t\tcommand: 'start sandbox',\n\t\t\taliases: ['start tezbox'],\n\t\t\tdescription: 'Starts a TezBox sandbox',\n\t\t\toptions: [],\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'none',\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'stop sandbox',\n\t\t\tcommand: 'stop sandbox',\n\t\t\taliases: ['stop tezbox'],\n\t\t\tdescription: 'Stops a TezBox sandbox',\n\t\t\toptions: [],\n\t\t\thandler: 'proxy',\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'restart sandbox',\n\t\t\tcommand: 'restart sandbox',\n\t\t\taliases: ['restart tezbox'],\n\t\t\tdescription: 'Restarts a TezBox sandbox',\n\t\t\toptions: [],\n\t\t\thandler: 'proxy',\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'list accounts',\n\t\t\tcommand: 'list accounts',\n\t\t\taliases: [],\n\t\t\tdescription: 'List the balances of all sandbox accounts',\n\t\t\toptions: [],\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'json',\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'bake',\n\t\t\tcommand: 'bake',\n\t\t\taliases: ['b'],\n\t\t\tdescription: 'Manually bake a block. Use when the \"baking\" setting of a TezBox sandbox is set to \"disabled\".',\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'watch',\n\t\t\t\t\tshortFlag: 'w',\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'Watch for operations as they are injected into the mempool and bake them as immediate as possible.',\n\t\t\t\t\tboolean: true,\n\t\t\t\t}),\n\t\t\t],\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'none',\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'show protocols',\n\t\t\tcommand: 'show protocols',\n\t\t\taliases: ['list protocols'],\n\t\t\tdescription: 'List protocols understood by this version of TezBox',\n\t\t\toptions: [],\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'json',\n\t\t}),\n\t],\n\tproxy: proxy,\n}), process.argv);\n","import {\n\texecCmd,\n\tgetArch,\n\tgetDockerImage,\n\tSandboxAccountConfig,\n\tSandboxConfig,\n\tsendAsyncErr,\n\tsendAsyncJsonRes,\n\tsendAsyncRes,\n} from '@taqueria/node-sdk';\nimport { generateSecretKey, InMemorySigner } from '@taquito/signer';\nimport BigNumber from 'bignumber.js';\nimport * as bip39 from 'bip39';\nimport { createHash } from 'crypto';\nimport { create } from 'domain';\nimport * as fs from 'fs';\nimport * as hjson from 'hjson';\nimport * as path from 'path';\nimport { getDefaultDockerImage } from './docker';\nimport { Opts } from './types';\n\ntype ConfigV1Environment = {\n\tsandboxes?: string[];\n};\n\ntype Mutez = string | number; // Represents balance in mutez\n\ntype InstantiatedAccount = Omit<SandboxAccountConfig, 'encryptedKey'> & {\n\tencryptedKey?: string;\n};\n\ninterface TezboxAccount {\n\tpkh: string;\n\tpk: string;\n\tsk: string;\n\tbalance: string;\n}\n\ntype SandboxConfigV1 = SandboxConfig;\n\ninterface ProtocolMapping {\n\tid: string; // e.g., \"Proxford\"\n\thash: string; // e.g., \"PsDELPH1...\"\n}\n\ninterface DockerRunParams {\n\tplatform: string;\n\timage: string;\n\tcontainerName: string;\n\tconfigDir: string;\n\tdataDir: string;\n\tport: number;\n}\n\nenum BakingOption {\n\tENABLED = 'enabled',\n\tDISABLED = 'disabled',\n}\n\n/**\n * Logger utility for standardized logging.\n */\nconst logger = {\n\tinfo: (message: string) => console.log(message),\n\twarn: (message: string) => console.warn(message),\n\terror: (message: string) => console.error(message),\n};\n\n/**\n * Extracts error message from unknown error type and prepends a prefix.\n/**\n * Extracts error message from unknown error type and optionally prepends a prefix.\n */\nfunction getErrorMessage(prefix: string, error: unknown): string {\n\tif (prefix === '') {\n\t\treturn error instanceof Error ? error.message : String(error);\n\t}\n\tif (typeof error === 'boolean') {\n\t\treturn `${prefix}:`;\n\t}\n\tconst errorString = error instanceof Error ? error.message : String(error);\n\treturn `${prefix}: ${errorString}`;\n}\n\n/**\n * Creates a command runner with optional logging capability\n */\nfunction createCommandRunner(enableLogging: boolean = false) {\n\tconst logFile = path.join(process.cwd(), 'tezbox-commands.log');\n\n\tasync function logExecution(sections: Record<string, string>): Promise<void> {\n\t\tif (!enableLogging) return;\n\n\t\tconst logEntry = Object.entries(sections)\n\t\t\t.map(([header, content]) =>\n\t\t\t\t[\n\t\t\t\t\t`\\n=== ${header} ===`,\n\t\t\t\t\tcontent || '[no content]',\n\t\t\t\t].join('\\n')\n\t\t\t)\n\t\t\t.join('\\n');\n\n\t\tawait fs.promises.appendFile(logFile, logEntry + '\\n\\n');\n\t}\n\n\t/**\n\t * Executes a shell command and standardizes error handling.\n\t */\n\treturn async function runCommand(\n\t\tcmd: string,\n\t\tstderrHandler?: (stderr: string) => void | Promise<void>,\n\t): Promise<{ stdout: string }> {\n\t\tawait logExecution({ COMMAND: cmd });\n\n\t\ttry {\n\t\t\tconst { stdout, stderr } = await execCmd(cmd);\n\n\t\t\tawait logExecution({\n\t\t\t\tSTDOUT: stdout,\n\t\t\t\tSTDERR: stderr.trim(),\n\t\t\t});\n\n\t\t\tif (stderr.trim()) {\n\t\t\t\tif (stderrHandler) {\n\t\t\t\t\tawait stderrHandler(stderr.trim());\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(stderr.trim());\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn { stdout };\n\t\t} catch (error) {\n\t\t\tawait logExecution({\n\t\t\t\tERROR: error instanceof Error ? error.message : String(error),\n\t\t\t});\n\n\t\t\tthrow new Error(getErrorMessage(`Command failed`, error));\n\t\t}\n\t};\n}\n\n// Create the runCommand function with logging enabled or disabled\n// const runCommand = createCommandRunner(true); // Set to false to disable logging\n\n/**\n * Executes a shell command and standardizes error handling.\n */\nasync function runCommand(\n\tcmd: string,\n\tstderrHandler?: (stderr: string) => void | Promise<void>,\n): Promise<{ stdout: string }> {\n\ttry {\n\t\tconst { stdout, stderr } = await execCmd(cmd);\n\t\tif (stderr.trim()) {\n\t\t\tif (stderrHandler) {\n\t\t\t\tawait stderrHandler(stderr.trim());\n\t\t\t} else {\n\t\t\t\tthrow new Error(stderr.trim());\n\t\t\t}\n\t\t}\n\t\treturn { stdout };\n\t} catch (error) {\n\t\tthrow new Error(getErrorMessage(`Command failed`, error));\n\t}\n}\n\n/**\n * Checks if the given environment is configured for TezBox.\n */\nfunction isTezBoxEnvironment(taskArgs: Opts): boolean {\n\tconst environment = taskArgs.config.environment[taskArgs.env];\n\tif (!environment || typeof environment !== 'object') return false;\n\n\tconst sandboxes = (environment as ConfigV1Environment).sandboxes;\n\tif (!Array.isArray(sandboxes) || sandboxes.length === 0) return false;\n\n\t// Currently, we don't have a way to tell if a sandbox is TezBox-provided\n\treturn true;\n}\n\n/**\n * Creates a Tezos account with the specified name and balance.\n */\nasync function instantiateDeclaredAccount(\n\tdeclaredAccountName: string,\n\tbalanceInMutez: BigNumber,\n): Promise<InstantiatedAccount> {\n\t// Generate a new account using BIP39 and Tezos key derivation\n\tconst account = await createNewAccount();\n\n\t// Return the instantiated account with real credentials\n\treturn {\n\t\tencryptedKey: `unencrypted:${account.pk}`,\n\t\tpublicKeyHash: account.pkh,\n\t\tsecretKey: account.sk,\n\t};\n}\n\n/**\n * Throws warning indicating function is not implemented yet.\n */\nasync function getInstantiatedAccounts(taskArgs: Opts): Promise<Record<string, InstantiatedAccount>> {\n\tconst sandboxConfig = getSandboxConfig(taskArgs);\n\tif (!sandboxConfig.accounts) {\n\t\tthrow new Error('No instantiated accounts found in sandbox config.');\n\t}\n\tconst accounts = sandboxConfig.accounts as Record<string, InstantiatedAccount>;\n\treturn Object.entries(accounts)\n\t\t.filter(([key]) => key !== 'default')\n\t\t.reduce((acc, [key, value]) => {\n\t\t\tacc[key] = value;\n\t\t\treturn acc;\n\t\t}, {} as Record<string, InstantiatedAccount>);\n}\n\n/**\n * Gets the sandbox configuration for the given environment.\n */\nfunction getSandboxConfig(taskArgs: Opts): SandboxConfigV1 {\n\tif (!isTezBoxEnvironment(taskArgs)) {\n\t\tthrow new Error(\n\t\t\t`This configuration doesn't appear to be configured to use TezBox environments. Check the ${taskArgs.env} environment in your .taq/config.json.`,\n\t\t);\n\t}\n\n\tconst environment = taskArgs.config.environment[taskArgs.env] as ConfigV1Environment;\n\tconst sandboxName = environment.sandboxes?.[0];\n\tif (sandboxName) {\n\t\tconst sandboxConfig = taskArgs.config.sandbox?.[sandboxName];\n\t\tif (sandboxConfig) {\n\t\t\tconst retval: SandboxConfigV1 = {\n\t\t\t\tblockTime: 1,\n\t\t\t\tbaking: BakingOption.ENABLED,\n\t\t\t\t...sandboxConfig,\n\t\t\t\t...sandboxConfig.annotations,\n\t\t\t};\n\n\t\t\treturn retval;\n\t\t}\n\t}\n\tthrow new Error(`No sandbox configuration found for ${taskArgs.env} environment.`);\n}\n\n/**\n * Gets or creates instantiated accounts.\n */\nasync function getOrCreateInstantiatedAccounts(\n\ttaskArgs: Opts,\n): Promise<Record<string, InstantiatedAccount>> {\n\tlet instantiatedAccounts: Record<string, InstantiatedAccount>;\n\n\ttry {\n\t\t// Attempt to get instantiated accounts\n\t\tinstantiatedAccounts = await getInstantiatedAccounts(taskArgs);\n\t} catch (error) {\n\t\t// No instantiated accounts available, so we need to instantiate them\n\t\tinstantiatedAccounts = {};\n\t\tconst declaredAccounts = taskArgs.config.accounts as Record<string, Mutez>;\n\n\t\tfor (const [accountName, balanceInMutez] of Object.entries(declaredAccounts)) {\n\t\t\t// Convert balance to BigNumber, removing any underscores used for formatting\n\t\t\tconst balanceInMutezBN = new BigNumber(balanceInMutez.toString().replace(/_/g, ''));\n\n\t\t\t// Instantiate the declared account\n\t\t\tconst instantiatedAccount = await instantiateDeclaredAccount(accountName, balanceInMutezBN);\n\n\t\t\t// Store the instantiated account\n\t\t\tinstantiatedAccounts[accountName] = instantiatedAccount;\n\t\t}\n\n\t\t// Optionally, save the instantiated accounts to persist them for future runs\n\t\tawait saveInstantiatedAccounts(instantiatedAccounts, taskArgs.projectDir, taskArgs.env);\n\t}\n\n\treturn instantiatedAccounts;\n}\n\n/**\n * Saves instantiated accounts to the local configuration file.\n * @param accounts Record of instantiated accounts\n * @param projectDir Project directory path\n * @param env Environment name\n */\nasync function saveInstantiatedAccounts(\n\taccounts: Record<string, InstantiatedAccount>,\n\tprojectDir: string,\n\tenv: string,\n): Promise<void> {\n\tconst configPath = path.join(projectDir, `.taq/config.local.${env}.json`);\n\n\ttry {\n\t\t// Read existing config or use an empty object if file doesn't exist\n\t\tlet config: Record<string, any> = {};\n\t\ttry {\n\t\t\tconst configContent = await fs.promises.readFile(configPath, 'utf8');\n\t\t\tconfig = JSON.parse(configContent);\n\t\t} catch (error) {\n\t\t\t// If file doesn't exist or there's an error reading it, we'll use an empty object\n\t\t}\n\n\t\t// Convert InstantiatedAccount to SandboxAccountConfig, omitting encryptedKey\n\t\tconst sandboxAccounts: Record<string, Omit<SandboxAccountConfig, 'encryptedKey'>> = {};\n\t\tfor (const [name, account] of Object.entries(accounts)) {\n\t\t\tsandboxAccounts[name] = {\n\t\t\t\tpublicKeyHash: account.publicKeyHash,\n\t\t\t\tsecretKey: account.secretKey,\n\t\t\t};\n\t\t}\n\n\t\t// Update only the accounts property in the config\n\t\tconfig.accounts = sandboxAccounts;\n\n\t\t// Ensure the directory exists\n\t\tawait fs.promises.mkdir(path.dirname(configPath), { recursive: true });\n\n\t\t// Write the updated config back to the file\n\t\tawait fs.promises.writeFile(configPath, JSON.stringify(config, null, 2), 'utf8');\n\t} catch (error) {\n\t\tthrow new Error(getErrorMessage('Failed to save instantiated accounts', error));\n\t}\n}\n\n/**\n * Generates a mnemonic phrase using BIP39.\n * @param strength The entropy bit length, defaults to 128 (resulting in a 12-word mnemonic).\n * @returns A promise that resolves to the generated mnemonic phrase.\n */\nasync function generateMnemonic(strength: number = 128): Promise<string> {\n\ttry {\n\t\tconst mnemonic = bip39.generateMnemonic(strength);\n\t\treturn mnemonic;\n\t} catch (error) {\n\t\tconsole.error('Error generating mnemonic:', error);\n\t\tthrow new Error('Failed to generate mnemonic');\n\t}\n}\n\n// Function to generate a new implicit account\nasync function createNewAccount() {\n\tconst mnemonic = await generateMnemonic();\n\n\t// Generate the BIP39 seed from the mnemonic\n\tconst seed = await bip39.mnemonicToSeed(mnemonic);\n\n\t// Convert the seed (Buffer) to a UInt8Array\n\tconst seedUInt8Array = new Uint8Array(seed);\n\n\t// Generate the secret key\n\tconst secretKey = generateSecretKey(seedUInt8Array, \"m/44'/1729'/0'/0'\", 'ed25519');\n\n\t// Derive the public key and public key hash from the secret key\n\tconst signer = new InMemorySigner(secretKey);\n\tconst publicKey = await signer.publicKey();\n\tconst publicKeyHash = await signer.publicKeyHash();\n\n\t// Return the object with pk, pkh, sk, and balance\n\treturn {\n\t\tpk: publicKey,\n\t\tpkh: publicKeyHash,\n\t\tsk: `unencrypted:${secretKey}`,\n\t};\n}\n\nfunction createFunderAccount() {\n\treturn createNewAccount().then(account => ({\n\t\tpublicKeyHash: account.pkh,\n\t\tsecretKey: account.sk,\n\t}));\n}\n\nasync function getPublicKeyFromSecretKey(secretKey: string) {\n\t// Initialize the signer with the secret key\n\tconst signer = await InMemorySigner.fromSecretKey(secretKey.replace('unencrypted:', ''));\n\n\t// Get the public key\n\tconst publicKey = await signer.publicKey();\n\n\treturn publicKey;\n}\n\n/**\n * Prepares TezBox accounts configuration.\n */\n/**\n * Prepares TezBox accounts configuration.\n */\nasync function prepareTezBoxAccounts(\n\tinstantiatedAccounts: Record<string, InstantiatedAccount>,\n\tdeclaredAccounts: Record<string, Mutez>,\n): Promise<Record<string, TezboxAccount>> {\n\t// Add funder account to instantiatedAccounts\n\t// instantiatedAccounts['funder'] = await createFunderAccount();\n\n\tconst tezboxAccounts: Record<string, TezboxAccount> = {};\n\n\tfor (const [accountName, accountData] of Object.entries(instantiatedAccounts)) {\n\t\tif (accountName === 'default') continue;\n\n\t\tconst secretKey = accountData.secretKey;\n\t\ttezboxAccounts[accountName] = {\n\t\t\tpkh: accountData.publicKeyHash,\n\t\t\tpk: await getPublicKeyFromSecretKey(secretKey),\n\t\t\tsk: secretKey,\n\t\t\tbalance: accountName === 'funder'\n\t\t\t\t? new BigNumber(100000000000000).toString()\n\t\t\t\t: new BigNumber(declaredAccounts[accountName].toString()).toString(),\n\t\t};\n\t}\n\n\treturn tezboxAccounts;\n}\n\n/**\n * Writes accounts.hjson file.\n */\nasync function writeAccountsHjson(\n\ttezboxAccounts: Record<string, TezboxAccount>,\n\ttezBoxConfigDir: string,\n): Promise<void> {\n\t// TODO: Remove for debugging\n\tawait Promise.resolve();\n\n\t// // Rearrange accounts record so that funder is first\n\t// const funderAccount = tezboxAccounts['funder'];\n\t// delete tezboxAccounts['funder'];\n\t// tezboxAccounts = { funder: funderAccount, ...tezboxAccounts };\n\n\t// Convert the accounts object to HJSON format\n\tconst hjsonContent = hjson.stringify(tezboxAccounts, {\n\t\tquotes: 'min',\n\t\tbracesSameLine: true,\n\t\tseparator: false,\n\t});\n\n\t// Remove quotes around sk values and ensure proper indentation\n\tconst fixedHjsonContent = hjsonContent.replaceAll('\"', '');\n\n\t// Write the accounts.hjson file\n\tconst accountsHjsonPath = path.join(tezBoxConfigDir, 'accounts.hjson');\n\tawait fs.promises.writeFile(accountsHjsonPath, fixedHjsonContent, 'utf8');\n}\n\n/**\n * Gets the declared accounts from the task arguments and removes underscores from Mutez values.\n */\nfunction getDeclaredAccounts(taskArgs: Opts): Record<string, Mutez> {\n\tconst declaredAccounts = taskArgs.config.accounts as Record<string, Mutez>;\n\treturn Object.entries(declaredAccounts).reduce((acc, [key, value]) => {\n\t\tacc[key] = value.toString().replace(/_/g, '');\n\t\treturn acc;\n\t}, {} as Record<string, Mutez>);\n}\n\n/**\n * Prepares accounts.hjson for TezBox.\n */\nasync function prepareAccountsHjson(taskArgs: Opts, tezBoxConfigDir: string): Promise<void> {\n\ttry {\n\t\t// Get or create instantiated accounts\n\t\tconst instantiatedAccounts = await getOrCreateInstantiatedAccounts(taskArgs);\n\n\t\t// Retrieve declared accounts\n\t\tconst declaredAccounts = getDeclaredAccounts(taskArgs);\n\n\t\t// Prepare tezbox accounts\n\t\tconst tezboxAccounts = await prepareTezBoxAccounts(instantiatedAccounts, declaredAccounts);\n\n\t\t// Write the accounts.hjson file\n\t\tawait writeAccountsHjson(tezboxAccounts, tezBoxConfigDir);\n\t} catch (error) {\n\t\tthrow new Error(getErrorMessage(`Failed to prepare accounts`, error));\n\t}\n}\n\n/**\n * Prepares bakers.hjson for TezBox.\n */\nasync function prepareBakersHjson(taskArgs: Opts, tezBoxConfigDir: string): Promise<void> {\n\ttry {\n\t\t// Get declared accounts\n\t\tconst declaredAccounts = getDeclaredAccounts(taskArgs);\n\n\t\t// Calculate total balance\n\t\tconst totalBalance = Object.values(declaredAccounts).reduce(\n\t\t\t(sum, balance) => BigNumber.sum(sum, balance),\n\t\t\tnew BigNumber(0),\n\t\t).toString();\n\n\t\t// Prepare bakers object\n\t\tconst bakers = {\n\t\t\tbaker1: {\n\t\t\t\tpkh: 'tz1faswCTDciRzE4oJ9jn2Vm2dvjeyA9fUzU',\n\t\t\t\tpk: 'edpkuTXkJDGcFd5nh6VvMz8phXxU3Bi7h6hqgywNFi1vZTfQNnS1RV',\n\t\t\t\tsk: 'unencrypted:edsk4ArLQgBTLWG5FJmnGnT689VKoqhXwmDPBuGx3z4cvwU9MmrPZZ',\n\t\t\t\tbalance: totalBalance,\n\t\t\t},\n\t\t\tbaker2: {\n\t\t\t\tpkh: 'tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN',\n\t\t\t\tpk: 'edpktzNbDAUjUk697W7gYg2CRuBQjyPxbEg8dLccYYwKSKvkPvjtV9',\n\t\t\t\tsk: 'unencrypted:edsk39qAm1fiMjgmPkw1EgQYkMzkJezLNewd7PLNHTkr6w9XA2zdfo',\n\t\t\t\tbalance: totalBalance,\n\t\t\t},\n\t\t\tbaker3: {\n\t\t\t\tpkh: 'tz1b7tUupMgCNw2cCLpKTkSD1NZzB5TkP2sv',\n\t\t\t\tpk: 'edpkuFrRoDSEbJYgxRtLx2ps82UdaYc1WwfS9sE11yhauZt5DgCHbU',\n\t\t\t\tsk: 'unencrypted:edsk2uqQB9AY4FvioK2YMdfmyMrer5R8mGFyuaLLFfSRo8EoyNdht3',\n\t\t\t\tbalance: totalBalance,\n\t\t\t},\n\t\t};\n\n\t\t// Convert the bakers object to HJSON format\n\t\tconst hjsonContent = hjson.stringify(bakers, {\n\t\t\tquotes: 'min',\n\t\t\tbracesSameLine: true,\n\t\t\tseparator: false,\n\t\t});\n\n\t\t// Remove quotes around sk values and ensure proper indentation\n\t\tconst fixedHjsonContent = hjsonContent.replaceAll('\"', '');\n\n\t\t// Write the bakers.hjson file\n\t\tconst bakersHjsonPath = path.join(tezBoxConfigDir, 'bakers.hjson');\n\t\tawait fs.promises.writeFile(bakersHjsonPath, fixedHjsonContent, 'utf8');\n\t} catch (error) {\n\t\tthrow new Error(getErrorMessage(`Failed to prepare bakers`, error));\n\t}\n}\n\n/**\n * Generates a project ID based on the project directory.\n */\nfunction getProjectId(taskArgs: Opts): string {\n\treturn createHash('sha256').update(taskArgs.projectDir).digest('hex');\n}\n\n/**\n * Gets the docker container name for the sandbox.\n */\nfunction getDockerContainerName(taskArgs: Opts): string {\n\tconst projectId = getProjectId(taskArgs);\n\treturn `taq-${taskArgs.env}-${projectId}`;\n}\n\n/**\n * Gets the TezBox configuration directory.\n */\nfunction getTezBoxConfigDir(taskArgs: Opts): string {\n\tconst containerName = getDockerContainerName(taskArgs);\n\treturn path.join(taskArgs.projectDir, `.taq/.${containerName}/config`);\n}\n\n/**\n * Gets the TezBox data directory.\n */\nfunction getTezBoxDataDir(taskArgs: Opts): string {\n\tconst containerName = getDockerContainerName(taskArgs);\n\treturn path.join(taskArgs.projectDir, `.taq/.${containerName}/data`);\n}\n\n/**\n * Gets the docker image for TezBox.\n */\nfunction getImage(taskArgs: Opts): string {\n\treturn getDockerImage(getDefaultDockerImage(taskArgs), 'TAQ_TEZBOX_IMAGE');\n}\n\n/**\n * Checks if the sandbox is running.\n */\nasync function isSandboxRunning(taskArgs: Opts): Promise<boolean> {\n\tconst containerName = getDockerContainerName(taskArgs);\n\tconst cmd = `docker ps --filter \"name=${containerName}\" --format \"{{.ID}}\"`;\n\tconst { stdout } = await runCommand(cmd);\n\treturn stdout.trim() !== '';\n}\n\n/**\n * Checks if the sandbox is already running.\n */\nasync function checkSandboxRunning(taskArgs: Opts): Promise<boolean> {\n\tconst running = await isSandboxRunning(taskArgs);\n\tif (running) {\n\t\tawait sendAsyncRes('Sandbox is already running.');\n\t}\n\treturn running;\n}\n\nfunction getPortNumber(taskArgs: Opts) {\n\tconst rpcUrl = getSandboxConfig(taskArgs).rpcUrl;\n\tconst match = rpcUrl.match(/:(\\d+)/);\n\treturn match ? parseInt(match[1], 10) : 80;\n}\n\nfunction getContainerPort(taskArgs: Opts) {\n\treturn getPortNumber(taskArgs) + 1;\n}\n\n/**\n * Gets the docker run parameters.\n */\nasync function getDockerRunParams(taskArgs: Opts): Promise<DockerRunParams> {\n\tconst image = getImage(taskArgs);\n\tconst containerName = getDockerContainerName(taskArgs);\n\tconst platform = await getArch();\n\tconst configDir = getTezBoxConfigDir(taskArgs);\n\tconst dataDir = getTezBoxDataDir(taskArgs);\n\tconst port = getContainerPort(taskArgs);\n\n\treturn { platform, image, containerName, configDir, dataDir, port };\n}\n\n/**\n * Ensures directories exist.\n */\nasync function ensureDirectoriesExist(directories: string[]): Promise<void> {\n\tawait Promise.all(\n\t\tdirectories.map(dir => fs.promises.mkdir(dir, { recursive: true })),\n\t);\n}\n\n/**\n * Constructs the docker run command.\n */\nfunction constructDockerRunCommand(params: DockerRunParams): string {\n\tconst { platform, image, containerName, configDir, port } = params;\n\n\tconst dockerOptions = [\n\t\t'docker run',\n\t\t'-d',\n\t\t`--platform ${platform}`,\n\t\t'-p 8732:8732',\n\t\t`-p ${port}:20000`,\n\t\t`--name ${containerName}`,\n\t\t`-v \"${configDir}:/tezbox/overrides\"`,\n\t\timage,\n\t\t'riobox',\n\t];\n\n\treturn dockerOptions.join(' ');\n}\n\n/**\n * Validates the block time in the sandbox configuration.\n */\nfunction validateBlockTime(taskArgs: Opts): number | null {\n\tconst sandboxConfig = getSandboxConfig(taskArgs);\n\tconst blockTime = sandboxConfig.blockTime;\n\tif (blockTime === undefined || blockTime === null) {\n\t\tlogger.warn('Block time is not specified; skipping block_time override.');\n\t\treturn null;\n\t}\n\treturn blockTime;\n}\n\n/**\n * Writes sandbox parameters for a single protocol.\n */\nasync function writeSandboxParameters(\n\tprotocolId: string,\n\tparameters: Record<string, string | number>,\n\ttezBoxConfigDir: string,\n): Promise<void> {\n\tconst protocolsDir = path.join(tezBoxConfigDir, 'protocols', protocolId);\n\tawait fs.promises.mkdir(protocolsDir, { recursive: true });\n\n\tconst hjsonContent = hjson.stringify(parameters, {\n\t\tquotes: 'min',\n\t\tbracesSameLine: true,\n\t\tseparator: false,\n\t});\n\n\tconst sandboxParamsPath = path.join(protocolsDir, 'sandbox-parameters.hjson');\n\tawait fs.promises.writeFile(sandboxParamsPath, hjsonContent, 'utf8');\n\n\t// Ensure the file has write permissions\n\ttry {\n\t\tawait fs.promises.chmod(sandboxParamsPath, 0o644);\n\t} catch (error) {\n\t\tlogger.warn(getErrorMessage(`Failed to set file permissions for ${sandboxParamsPath}`, error));\n\t}\n}\n\n/**\n * Applies block time override to a single protocol.\n */\nasync function applyBlockTimeOverrideToProtocol(\n\tprotocolId: string,\n\tblockTime: number,\n\ttezBoxConfigDir: string,\n): Promise<void> {\n\tconst nonce_revelation_threshold = 16;\n\tconst minimal_block_delay = blockTime;\n\n\tconst parameters = {\n\t\tminimal_block_delay: minimal_block_delay.toString(),\n\t};\n\tawait writeSandboxParameters(protocolId, parameters, tezBoxConfigDir);\n}\n\n/**\n * Applies block time override to multiple protocols.\n */\nasync function applyBlockTimeOverrideToProtocols(\n\tprotocolIds: string[],\n\tblockTime: number,\n\ttezBoxConfigDir: string,\n): Promise<void> {\n\tawait Promise.all(\n\t\tprotocolIds.map(async protocolId => {\n\t\t\t// Skip alpha protocol as it's a placeholder\n\t\t\tif (/^alpha$/i.test(protocolId)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait applyBlockTimeOverrideToProtocol(protocolId, blockTime, tezBoxConfigDir);\n\t\t}),\n\t);\n}\n\n/**\n * Gets protocol identifiers from TezBox configuration.\n */\nasync function getProtocolIds(taskArgs: Opts): Promise<string[]> {\n\tconst image = getImage(taskArgs);\n\n\t// List the protocol directories inside the TezBox image\n\tconst cmd = `docker run --rm --entrypoint ls ${image} /tezbox/configuration/protocols`;\n\tconst { stdout } = await runCommand(cmd);\n\n\tconst protocolIds = stdout\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.map(line => line.trim())\n\t\t.filter(line => line !== '');\n\n\treturn protocolIds;\n}\n\n/**\n * Reads and parses protocol.hjson for a given protocolId.\n */\nasync function readProtocolJson(image: string, protocolId: string): Promise<ProtocolMapping | null> {\n\tconst cmd = `docker run --rm --entrypoint cat ${image} /tezbox/configuration/protocols/${protocolId}/protocol.hjson`;\n\n\ttry {\n\t\tconst { stdout } = await runCommand(cmd);\n\n\t\tif (!stdout.trim()) {\n\t\t\tlogger.warn(`protocol.hjson not found or empty for protocolId ${protocolId}; skipping this protocol.`);\n\t\t\treturn null;\n\t\t}\n\n\t\t// Parse the HJSON content\n\t\tconst protocolData = hjson.parse(stdout);\n\t\tconst protocolHash: string = protocolData.hash;\n\t\tif (protocolHash) {\n\t\t\treturn { id: protocolId, hash: protocolHash };\n\t\t} else {\n\t\t\tlogger.warn(`Protocol hash not found in protocol.hjson for protocolId ${protocolId}; skipping.`);\n\t\t\treturn null;\n\t\t}\n\t} catch (error) {\n\t\tlogger.warn(getErrorMessage(`Failed to read protocol.hjson for protocolId ${protocolId}`, error));\n\t\treturn null;\n\t}\n}\n\n/**\n * Gets protocol mappings.\n */\nasync function getProtocolMappings(taskArgs: Opts): Promise<ProtocolMapping[]> {\n\tconst image = getImage(taskArgs);\n\tconst protocolIds = await getProtocolIds(taskArgs);\n\n\tconst protocolMappingsPromises = protocolIds.map(async protocolId => {\n\t\tconst mapping = await readProtocolJson(image, protocolId);\n\t\treturn mapping;\n\t});\n\n\tconst protocolMappings = await Promise.all(protocolMappingsPromises);\n\treturn protocolMappings.filter((mapping): mapping is ProtocolMapping => mapping !== null);\n}\n\n/**\n * Gets protocol hashes from octez-client.\n */\nasync function getOctezClientProtocols(taskArgs: Opts): Promise<string[]> {\n\tconst image = getImage(taskArgs);\n\tconst cmd = `docker run --rm --entrypoint octez-client ${image} list mockup protocols`;\n\tconst { stdout } = await runCommand(cmd, stderr => {\n\t\tconst ignorableError = [\n\t\t\t'Base directory /tezbox/data/.tezos-client does not exist.',\n\t\t\t'Unable to connect to the node: \"Unix.Unix_error(Unix.ECONNREFUSED, \"connect\", \"\")\"',\n\t\t];\n\n\t\tif (stderr.trim() !== '' && !ignorableError.some(err => stderr.includes(err))) {\n\t\t\tthrow new Error(`Failed to list protocols: ${stderr.trim()}`);\n\t\t}\n\t});\n\n\tconst protocols = stdout\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.filter(line => line.trim() !== '');\n\n\treturn protocols;\n}\n\n/**\n * Prepares sandbox-parameters.hjson for block_time override.\n */\nasync function prepareSandboxParametersHjson(taskArgs: Opts, tezBoxConfigDir: string): Promise<void> {\n\ttry {\n\t\t// Validate block time\n\t\tconst blockTime = validateBlockTime(taskArgs);\n\t\tif (blockTime === null) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Get the protocol mappings from TezBox\n\t\tconst protocolMappings = await getProtocolMappings(taskArgs);\n\t\tconst hashToIdMap: Record<string, string> = {};\n\t\tfor (const mapping of protocolMappings) {\n\t\t\thashToIdMap[mapping.hash] = mapping.id;\n\t\t}\n\n\t\t// Get the list of protocol hashes supported by octez-client\n\t\tconst protocolHashes = await getOctezClientProtocols(taskArgs);\n\n\t\t// Map protocol hashes to TezBox protocol IDs\n\t\tconst protocolIdsToOverride = protocolHashes\n\t\t\t.map(hash => hashToIdMap[hash])\n\t\t\t.filter((id): id is string => id !== undefined);\n\n\t\tif (protocolIdsToOverride.length === 0) {\n\t\t\tlogger.warn('No matching protocol IDs found; cannot set block_time override.');\n\t\t\treturn;\n\t\t}\n\n\t\t// Debug: Log the protocol IDs to override\n\t\t// logger.info(`Protocol IDs to override: ${protocolIdsToOverride.join(', ')}`);\n\n\t\t// Apply block time override to each protocol ID\n\t\tawait applyBlockTimeOverrideToProtocols(protocolIdsToOverride, blockTime, tezBoxConfigDir);\n\t} catch (error) {\n\t\tconst errorMessage = getErrorMessage(`Failed to prepare sandbox parameters:`, error);\n\t\tthrow new Error(errorMessage);\n\t}\n}\n\n/**\n * Prepares baker.hjson if baking is disabled.\n */\nasync function prepareBakerHjson(tezBoxConfigDir: string): Promise<void> {\n\tconst servicesDir = path.join(tezBoxConfigDir, 'services');\n\ttry {\n\t\tawait fs.promises.mkdir(servicesDir, { recursive: true });\n\n\t\tconst bakerConfig = {\n\t\t\tautostart: false,\n\t\t};\n\n\t\tconst hjsonContent = hjson.stringify(bakerConfig, {\n\t\t\tquotes: 'all',\n\t\t\tbracesSameLine: true,\n\t\t\tseparator: true,\n\t\t});\n\n\t\tconst bakerConfigPath = path.join(servicesDir, 'baker.hjson');\n\t\tawait fs.promises.writeFile(bakerConfigPath, hjsonContent, 'utf8');\n\t} catch (error) {\n\t\tthrow new Error(getErrorMessage(`Failed to prepare baker.hjson`, error));\n\t}\n}\n\n/**\n * Prepares TezBox configuration overrides.\n */\nasync function prepareTezBoxOverrides(taskArgs: Opts): Promise<void> {\n\tconst tezBoxConfigDir = getTezBoxConfigDir(taskArgs);\n\n\ttry {\n\t\t// Get sandbox configuration\n\t\tconst sandboxConfig = getSandboxConfig(taskArgs);\n\n\t\t// Ensure the configuration directory exists\n\t\tawait fs.promises.mkdir(tezBoxConfigDir, { recursive: true });\n\n\t\t// Prepare tasks\n\t\tconst tasks: Promise<void>[] = [];\n\n\t\t// Prepare bakers.hjson\n\t\ttasks.push(prepareBakersHjson(taskArgs, tezBoxConfigDir));\n\n\t\t// Prepare accounts.hjson\n\t\tif (taskArgs.config.accounts) {\n\t\t\ttasks.push(prepareAccountsHjson(taskArgs, tezBoxConfigDir));\n\t\t}\n\n\t\t// Prepare sandbox-parameters.hjson for block_time\n\t\tif (sandboxConfig.blockTime) {\n\t\t\ttasks.push(prepareSandboxParametersHjson(taskArgs, tezBoxConfigDir));\n\t\t}\n\n\t\t// Prepare baker.hjson if baking is disabled\n\t\tif (sandboxConfig.baking === BakingOption.DISABLED) {\n\t\t\ttasks.push(prepareBakerHjson(tezBoxConfigDir));\n\t\t}\n\n\t\t// Run all preparations in parallel\n\t\tawait Promise.all(tasks);\n\t} catch (error) {\n\t\tthrow new Error(getErrorMessage(`Failed to prepare TezBox overrides`, error));\n\t}\n}\n\nfunction getProxyContainerName(taskArgs: Opts) {\n\treturn `${getDockerContainerName(taskArgs)}-proxy`;\n}\n\nasync function startProxyServer(taskArgs: Opts): Promise<void> {\n\tconst containerPort = getContainerPort(taskArgs);\n\tconst proxyPort = getPortNumber(taskArgs);\n\tconst proxyContainerName = getProxyContainerName(taskArgs);\n\n\tconst proxyCmd = `docker run -d --name ${proxyContainerName} \\\n --network host \\\n caddy:2-alpine \\\n caddy reverse-proxy \\\n --from http://:${proxyPort} \\\n --to http://127.0.0.1:${containerPort} \\\n --access-log`;\n\n\ttry {\n\t\tawait runCommand(proxyCmd);\n\t} catch (error) {\n\t\tthrow new Error(getErrorMessage(`Failed to start Caddy reverse proxy`, error));\n\t}\n}\n\nasync function stopProxyServer(taskArgs: Opts): Promise<void> {\n\tconst proxyContainerName = getProxyContainerName(taskArgs);\n\tconst cmd = `docker rm -f ${proxyContainerName}`;\n\tawait runCommand(cmd);\n}\n\n/**\n * Starts the sandbox.\n */\nasync function startSandbox(taskArgs: Opts): Promise<void> {\n\ttry {\n\t\t// Check for Docker availability\n\t\tawait checkDockerAvailability();\n\n\t\t// Check if the sandbox is already running\n\t\tif (await checkSandboxRunning(taskArgs)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Get Docker run parameters\n\t\tconst params = await getDockerRunParams(taskArgs);\n\n\t\t// Ensure necessary directories exist\n\t\tawait ensureDirectoriesExist([params.dataDir, params.configDir]);\n\n\t\t// Prepare TezBox configuration overrides\n\t\tawait prepareTezBoxOverrides(taskArgs);\n\n\t\t// Construct the Docker run command\n\t\tconst cmd = constructDockerRunCommand(params);\n\t\t// logger.info(`Starting sandbox with command: ${cmd}`);\n\n\t\t// Execute the Docker run command\n\t\tawait runCommand(cmd);\n\n\t\t// Start the proxy server\n\t\tawait startProxyServer(taskArgs);\n\n\t\t// Send a success response\n\t\tawait sendAsyncRes('Sandbox started successfully.');\n\t} catch (error) {\n\t\tawait sendAsyncErr(getErrorMessage(`Failed to start sandbox`, error));\n\t}\n}\n\n/**\n * Checks for Docker availability.\n */\nasync function checkDockerAvailability(): Promise<void> {\n\ttry {\n\t\tawait runCommand('docker --version');\n\t} catch (error) {\n\t\tthrow new Error('Docker is not installed or not running. Please install and start Docker.');\n\t}\n}\n\n/**\n * Removes the sandbox container.\n */\nasync function removeSandboxContainer(taskArgs: Opts): Promise<void> {\n\tconst containerName = getDockerContainerName(taskArgs);\n\tconst cmd = `docker rm -f ${containerName}`;\n\n\ttry {\n\t\tawait runCommand(cmd);\n\t} catch (error) {\n\t\tconst errorMessage = getErrorMessage('', error);\n\t\tif (errorMessage.includes('No such container')) {\n\t\t\t// Container does not exist\n\t\t\tawait sendAsyncRes('Sandbox is not running or already stopped.');\n\t\t} else {\n\t\t\tthrow new Error(errorMessage);\n\t\t}\n\t}\n\n\t// Stop the proxy server\n\tawait stopProxyServer(taskArgs);\n}\n\n/**\n * Stops the sandbox.\n */\nasync function stopSandbox(taskArgs: Opts): Promise<void> {\n\ttry {\n\t\t// Attempt to stop and remove the sandbox container\n\t\tawait removeSandboxContainer(taskArgs);\n\n\t\t// Optionally, clean up configuration directory if needed\n\t\tconst configDir = getTezBoxConfigDir(taskArgs);\n\t\tawait fs.promises.rm(configDir, { recursive: true, force: true });\n\n\t\t// Send a success response\n\t\tawait sendAsyncRes('Sandbox stopped and cleaned up.');\n\t} catch (error) {\n\t\tawait sendAsyncErr(getErrorMessage(`Failed to stop sandbox`, error));\n\t}\n}\n\n/**\n * Restarts the sandbox.\n */\nasync function restartSandbox(taskArgs: Opts): Promise<void> {\n\ttry {\n\t\t// Stop the sandbox if it's running\n\t\tawait removeSandboxContainer(taskArgs);\n\n\t\t// Start the sandbox\n\t\tawait startSandbox(taskArgs);\n\n\t\t// Send a success response\n\t\tawait sendAsyncRes('Sandbox restarted successfully.');\n\t} catch (error) {\n\t\tawait sendAsyncErr(getErrorMessage(`Failed to restart sandbox`, error));\n\t}\n}\n\n/**\n * Lists protocols.\n */\nasync function listProtocols(taskArgs: Opts): Promise<void> {\n\ttry {\n\t\tconst protocolHashes = await getOctezClientProtocols(taskArgs);\n\t\tconst protocolObjects = protocolHashes.map(protocol => ({ protocol }));\n\t\tawait sendAsyncJsonRes(protocolObjects);\n\t} catch (error) {\n\t\tawait sendAsyncErr(getErrorMessage(`Failed to list protocols`, error));\n\t}\n}\n\n/**\n * Lists accounts.\n */\nasync function listAccounts(taskArgs: Opts): Promise<void> {\n\ttry {\n\t\tif (await isSandboxRunning(taskArgs)) {\n\t\t\t// List accounts from the sandbox\n\t\t\tconst containerName = getDockerContainerName(taskArgs);\n\t\t\tconst cmd = `docker exec ${containerName} octez-client list known addresses`;\n\t\t\tconst { stdout } = await runCommand(cmd);\n\n\t\t\tif (!stdout.trim()) {\n\t\t\t\tawait sendAsyncRes('No accounts found.');\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst accounts = stdout\n\t\t\t\t.trim()\n\t\t\t\t.split('\\n')\n\t\t\t\t.filter(line => line.trim() !== '')\n\t\t\t\t.map(line => {\n\t\t\t\t\tconst [name, rest] = line.split(':');\n\t\t\t\t\tconst address = rest ? rest.trim().split(' ')[0] : '';\n\t\t\t\t\treturn { name: name.trim(), address };\n\t\t\t\t});\n\n\t\t\tawait sendAsyncJsonRes(accounts);\n\t\t} else {\n\t\t\tawait sendAsyncErr(`Sandbox is not running. Please start the sandbox before attempting to list accounts.`);\n\t\t}\n\t} catch (error) {\n\t\tawait sendAsyncErr(getErrorMessage(`Failed to list accounts`, error));\n\t}\n}\n\n/**\n * Bakes a block in the sandbox.\n */\nasync function bakeBlock(taskArgs: Opts): Promise<void> {\n\ttry {\n\t\tif (await isSandboxRunning(taskArgs)) {\n\t\t\tconst containerName = getDockerContainerName(taskArgs);\n\t\t\tconst cmd = `docker exec ${containerName} octez-client bake for baker1`;\n\n\t\t\tif (taskArgs.watch) {\n\t\t\t\tconsole.log('Baking on demand as operations are injected.');\n\t\t\t\tconsole.log('Press CTRL-C to stop and exit.');\n\t\t\t\tconsole.log();\n\n\t\t\t\twhile (true) {\n\t\t\t\t\tconsole.log('Waiting for operations to be injected...');\n\t\t\t\t\twhile (true) {\n\t\t\t\t\t\tconst { stdout } = await runCommand(\n\t\t\t\t\t\t\t`docker exec ${containerName} octez-client rpc get /chains/main/mempool/pending_operations`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst ops = JSON.parse(stdout);\n\t\t\t\t\t\tif (Array.isArray(ops.applied) && ops.applied.length > 0) break;\n\t\t\t\t\t\tawait new Promise(resolve => setTimeout(resolve, 1000)); // Wait for 1 second before checking again\n\t\t\t\t\t}\n\n\t\t\t\t\tawait runCommand(cmd);\n\t\t\t\t\tconsole.log('Block baked.');\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tawait runCommand(cmd);\n\t\t\t\tawait sendAsyncRes('Block baked successfully.');\n\t\t\t}\n\t\t} else {\n\t\t\ttry {\n\t\t\t\tawait sendAsyncErr('Sandbox is not running. Please start the sandbox before attempting to bake a block.');\n\t\t\t} catch {\n\t\t\t\t// Nothing to see here.\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\tawait sendAsyncErr(getErrorMessage(`Failed to bake block`, error));\n\t}\n}\n\n/**\n * Main proxy function to handle tasks.\n */\nexport const proxy = async (taskArgs: Opts): Promise<void> => {\n\tif (!isTezBoxEnvironment(taskArgs)) {\n\t\tawait sendAsyncErr(\n\t\t\t`This configuration doesn't appear to be configured to use TezBox environments. Check the ${taskArgs.env} environment in your .taq/config.json.`,\n\t\t);\n\t\treturn;\n\t}\n\n\tconst taskName = taskArgs.task?.toLowerCase().trim();\n\n\tconst taskHandlers: Record<string, (args: Opts) => Promise<void>> = {\n\t\t'start sandbox': startSandbox,\n\t\t'stop sandbox': stopSandbox,\n\t\t'restart sandbox': restartSandbox,\n\t\t'list protocols': listProtocols,\n\t\t'list-protocols': listProtocols,\n\t\t'show protocols': listProtocols,\n\t\t'show-protocols': listProtocols,\n\t\t'list accounts': listAccounts,\n\t\t'list-accounts': listAccounts,\n\t\t'show accounts': listAccounts,\n\t\t'show-accounts': listAccounts,\n\t\t'bake': bakeBlock,\n\t\t'bake block': bakeBlock,\n\t};\n\n\tconst handler = taskName ? taskHandlers[taskName] : undefined;\n\n\tif (handler) {\n\t\ttry {\n\t\t\tawait handler(taskArgs);\n\t\t} catch (error) {\n\t\t\tawait sendAsyncErr(getErrorMessage(`Error executing task '${taskArgs.task}'`, error));\n\t\t}\n\t} else {\n\t\tawait sendAsyncErr(taskArgs.task ? `Unknown task: ${taskArgs.task}` : 'No task provided');\n\t}\n};\n\nexport default proxy;\n","import { getDockerImage } from '@taqueria/node-sdk';\nimport { Opts } from './types';\n\nexport const TAQ_TEZBOX_IMAGE_ENV_VAR = 'TAQ_TEZBOX_IMAGE';\n\nexport const getDefaultDockerImage = (opts: Opts) => `ghcr.io/tez-capital/tezbox:tezos-v22.0`;\n\nexport const getImage = (opts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AAAA,MACb,SAAS;AAAA,QACR,wBAAO,OAAO;AAAA,UACb,MAAM;AAAA,UACN,WAAW;AAAA,UACX,aACC;AAAA,UACD,SAAS;AAAA,QACV,CAAC;AAAA,MACF;AAAA,MACA,SAAS;AAAA,MACT,UAAU;AAAA,IACX,CAAC;AAAA,IACD,sBAAK,OAAO;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,SAAS,CAAC,gBAAgB;AAAA,MAC1B,aAAa;AAAA,MACb,SAAS,CAAC;AAAA,MACV,SAAS;AAAA,MACT,UAAU;AAAA,IACX,CAAC;AAAA,EACF;AAAA,EACA,OAAO;AACR,IAAI,QAAQ,IAAI;","names":["import_node_sdk","import_node_sdk","BigNumber","generateMnemonic","BigNumber"]}
|
|
1
|
+
{"version":3,"sources":["index.ts","proxy.ts","docker.ts"],"sourcesContent":["import { Option, Plugin, PositionalArg, Task } from '@taqueria/node-sdk';\nimport proxy from './proxy';\n\nPlugin.create(_i18n => ({\n\talias: 'tezbox',\n\tschema: '1.0',\n\tversion: '0.1',\n\ttasks: [\n\t\tTask.create({\n\t\t\ttask: 'start sandbox',\n\t\t\tcommand: 'start sandbox',\n\t\t\taliases: ['start tezbox'],\n\t\t\tdescription: 'Starts a TezBox sandbox',\n\t\t\toptions: [],\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'none',\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'stop sandbox',\n\t\t\tcommand: 'stop sandbox',\n\t\t\taliases: ['stop tezbox'],\n\t\t\tdescription: 'Stops a TezBox sandbox',\n\t\t\toptions: [],\n\t\t\thandler: 'proxy',\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'restart sandbox',\n\t\t\tcommand: 'restart sandbox',\n\t\t\taliases: ['restart tezbox'],\n\t\t\tdescription: 'Restarts a TezBox sandbox',\n\t\t\toptions: [],\n\t\t\thandler: 'proxy',\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'list accounts',\n\t\t\tcommand: 'list accounts',\n\t\t\taliases: [],\n\t\t\tdescription: 'List the balances of all sandbox accounts',\n\t\t\toptions: [],\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'json',\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'bake',\n\t\t\tcommand: 'bake',\n\t\t\taliases: ['b'],\n\t\t\tdescription: 'Manually bake a block. Use when the \"baking\" setting of a TezBox sandbox is set to \"disabled\".',\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'watch',\n\t\t\t\t\tshortFlag: 'w',\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'Watch for operations as they are injected into the mempool and bake them as immediate as possible.',\n\t\t\t\t\tboolean: true,\n\t\t\t\t}),\n\t\t\t],\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'none',\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'show protocols',\n\t\t\tcommand: 'show protocols',\n\t\t\taliases: ['list protocols'],\n\t\t\tdescription: 'List protocols understood by this version of TezBox',\n\t\t\toptions: [],\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'json',\n\t\t}),\n\t],\n\tproxy: proxy,\n}), process.argv);\n","import {\n\texecCmd,\n\tgetArch,\n\tgetDockerImage,\n\tSandboxAccountConfig,\n\tSandboxConfig,\n\tsendAsyncErr,\n\tsendAsyncJsonRes,\n\tsendAsyncRes,\n} from '@taqueria/node-sdk';\nimport { generateSecretKey, InMemorySigner } from '@taquito/signer';\nimport BigNumber from 'bignumber.js';\nimport * as bip39 from 'bip39';\nimport { createHash } from 'crypto';\nimport { create } from 'domain';\nimport * as fs from 'fs';\nimport * as hjson from 'hjson';\nimport * as path from 'path';\nimport { getDefaultDockerImage } from './docker';\nimport { Opts } from './types';\n\ntype ConfigV1Environment = {\n\tsandboxes?: string[];\n};\n\ntype Mutez = string | number; // Represents balance in mutez\n\ntype InstantiatedAccount = Omit<SandboxAccountConfig, 'encryptedKey'> & {\n\tencryptedKey?: string;\n};\n\ninterface TezboxAccount {\n\tpkh: string;\n\tpk: string;\n\tsk: string;\n\tbalance: string;\n}\n\ntype SandboxConfigV1 = SandboxConfig;\n\ninterface ProtocolMapping {\n\tid: string; // e.g., \"Proxford\"\n\thash: string; // e.g., \"PsDELPH1...\"\n}\n\ninterface DockerRunParams {\n\tplatform: string;\n\timage: string;\n\tcontainerName: string;\n\tconfigDir: string;\n\tdataDir: string;\n\tport: number;\n}\n\nenum BakingOption {\n\tENABLED = 'enabled',\n\tDISABLED = 'disabled',\n}\n\n/**\n * Logger utility for standardized logging.\n */\nconst logger = {\n\tinfo: (message: string) => console.log(message),\n\twarn: (message: string) => console.warn(message),\n\terror: (message: string) => console.error(message),\n};\n\n/**\n * Extracts error message from unknown error type and prepends a prefix.\n/**\n * Extracts error message from unknown error type and optionally prepends a prefix.\n */\nfunction getErrorMessage(prefix: string, error: unknown): string {\n\tif (prefix === '') {\n\t\treturn error instanceof Error ? error.message : String(error);\n\t}\n\tif (typeof error === 'boolean') {\n\t\treturn `${prefix}:`;\n\t}\n\tconst errorString = error instanceof Error ? error.message : String(error);\n\treturn `${prefix}: ${errorString}`;\n}\n\n/**\n * Creates a command runner with optional logging capability\n */\nfunction createCommandRunner(enableLogging: boolean = false) {\n\tconst logFile = path.join(process.cwd(), 'tezbox-commands.log');\n\n\tasync function logExecution(sections: Record<string, string>): Promise<void> {\n\t\tif (!enableLogging) return;\n\n\t\tconst logEntry = Object.entries(sections)\n\t\t\t.map(([header, content]) =>\n\t\t\t\t[\n\t\t\t\t\t`\\n=== ${header} ===`,\n\t\t\t\t\tcontent || '[no content]',\n\t\t\t\t].join('\\n')\n\t\t\t)\n\t\t\t.join('\\n');\n\n\t\tawait fs.promises.appendFile(logFile, logEntry + '\\n\\n');\n\t}\n\n\t/**\n\t * Executes a shell command and standardizes error handling.\n\t */\n\treturn async function runCommand(\n\t\tcmd: string,\n\t\tstderrHandler?: (stderr: string) => void | Promise<void>,\n\t): Promise<{ stdout: string }> {\n\t\tawait logExecution({ COMMAND: cmd });\n\n\t\ttry {\n\t\t\tconst { stdout, stderr } = await execCmd(cmd);\n\n\t\t\tawait logExecution({\n\t\t\t\tSTDOUT: stdout,\n\t\t\t\tSTDERR: stderr.trim(),\n\t\t\t});\n\n\t\t\tif (stderr.trim()) {\n\t\t\t\tif (stderrHandler) {\n\t\t\t\t\tawait stderrHandler(stderr.trim());\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(stderr.trim());\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn { stdout };\n\t\t} catch (error) {\n\t\t\tawait logExecution({\n\t\t\t\tERROR: error instanceof Error ? error.message : String(error),\n\t\t\t});\n\n\t\t\tthrow new Error(getErrorMessage(`Command failed`, error));\n\t\t}\n\t};\n}\n\n// Create the runCommand function with logging enabled or disabled\n// const runCommand = createCommandRunner(true); // Set to false to disable logging\n\n/**\n * Executes a shell command and standardizes error handling.\n */\nasync function runCommand(\n\tcmd: string,\n\tstderrHandler?: (stderr: string) => void | Promise<void>,\n): Promise<{ stdout: string }> {\n\ttry {\n\t\tconst { stdout, stderr } = await execCmd(cmd);\n\t\tif (stderr.trim()) {\n\t\t\tif (stderrHandler) {\n\t\t\t\tawait stderrHandler(stderr.trim());\n\t\t\t} else {\n\t\t\t\tthrow new Error(stderr.trim());\n\t\t\t}\n\t\t}\n\t\treturn { stdout };\n\t} catch (error) {\n\t\tthrow new Error(getErrorMessage(`Command failed`, error));\n\t}\n}\n\n/**\n * Checks if the given environment is configured for TezBox.\n */\nfunction isTezBoxEnvironment(taskArgs: Opts): boolean {\n\tconst environment = taskArgs.config.environment[taskArgs.env];\n\tif (!environment || typeof environment !== 'object') return false;\n\n\tconst sandboxes = (environment as ConfigV1Environment).sandboxes;\n\tif (!Array.isArray(sandboxes) || sandboxes.length === 0) return false;\n\n\t// Currently, we don't have a way to tell if a sandbox is TezBox-provided\n\treturn true;\n}\n\n/**\n * Creates a Tezos account with the specified name and balance.\n */\nasync function instantiateDeclaredAccount(\n\tdeclaredAccountName: string,\n\tbalanceInMutez: BigNumber,\n): Promise<InstantiatedAccount> {\n\t// Generate a new account using BIP39 and Tezos key derivation\n\tconst account = await createNewAccount();\n\n\t// Return the instantiated account with real credentials\n\treturn {\n\t\tencryptedKey: `unencrypted:${account.pk}`,\n\t\tpublicKeyHash: account.pkh,\n\t\tsecretKey: account.sk,\n\t};\n}\n\n/**\n * Throws warning indicating function is not implemented yet.\n */\nasync function getInstantiatedAccounts(taskArgs: Opts): Promise<Record<string, InstantiatedAccount>> {\n\tconst sandboxConfig = getSandboxConfig(taskArgs);\n\tif (!sandboxConfig.accounts) {\n\t\tthrow new Error('No instantiated accounts found in sandbox config.');\n\t}\n\tconst accounts = sandboxConfig.accounts as Record<string, InstantiatedAccount>;\n\treturn Object.entries(accounts)\n\t\t.filter(([key]) => key !== 'default')\n\t\t.reduce((acc, [key, value]) => {\n\t\t\tacc[key] = value;\n\t\t\treturn acc;\n\t\t}, {} as Record<string, InstantiatedAccount>);\n}\n\n/**\n * Gets the sandbox configuration for the given environment.\n */\nfunction getSandboxConfig(taskArgs: Opts): SandboxConfigV1 {\n\tif (!isTezBoxEnvironment(taskArgs)) {\n\t\tthrow new Error(\n\t\t\t`This configuration doesn't appear to be configured to use TezBox environments. Check the ${taskArgs.env} environment in your .taq/config.json.`,\n\t\t);\n\t}\n\n\tconst environment = taskArgs.config.environment[taskArgs.env] as ConfigV1Environment;\n\tconst sandboxName = environment.sandboxes?.[0];\n\tif (sandboxName) {\n\t\tconst sandboxConfig = taskArgs.config.sandbox?.[sandboxName];\n\t\tif (sandboxConfig) {\n\t\t\tconst retval: SandboxConfigV1 = {\n\t\t\t\tblockTime: 1,\n\t\t\t\tbaking: BakingOption.ENABLED,\n\t\t\t\t...sandboxConfig,\n\t\t\t\t...sandboxConfig.annotations,\n\t\t\t};\n\n\t\t\treturn retval;\n\t\t}\n\t}\n\tthrow new Error(`No sandbox configuration found for ${taskArgs.env} environment.`);\n}\n\n/**\n * Gets or creates instantiated accounts.\n */\nasync function getOrCreateInstantiatedAccounts(\n\ttaskArgs: Opts,\n): Promise<Record<string, InstantiatedAccount>> {\n\tlet instantiatedAccounts: Record<string, InstantiatedAccount>;\n\n\ttry {\n\t\t// Attempt to get instantiated accounts\n\t\tinstantiatedAccounts = await getInstantiatedAccounts(taskArgs);\n\t} catch (error) {\n\t\t// No instantiated accounts available, so we need to instantiate them\n\t\tinstantiatedAccounts = {};\n\t\tconst declaredAccounts = taskArgs.config.accounts as Record<string, Mutez>;\n\n\t\tfor (const [accountName, balanceInMutez] of Object.entries(declaredAccounts)) {\n\t\t\t// Convert balance to BigNumber, removing any underscores used for formatting\n\t\t\tconst balanceInMutezBN = new BigNumber(balanceInMutez.toString().replace(/_/g, ''));\n\n\t\t\t// Instantiate the declared account\n\t\t\tconst instantiatedAccount = await instantiateDeclaredAccount(accountName, balanceInMutezBN);\n\n\t\t\t// Store the instantiated account\n\t\t\tinstantiatedAccounts[accountName] = instantiatedAccount;\n\t\t}\n\n\t\t// Optionally, save the instantiated accounts to persist them for future runs\n\t\tawait saveInstantiatedAccounts(instantiatedAccounts, taskArgs.projectDir, taskArgs.env);\n\t}\n\n\treturn instantiatedAccounts;\n}\n\n/**\n * Saves instantiated accounts to the local configuration file.\n * @param accounts Record of instantiated accounts\n * @param projectDir Project directory path\n * @param env Environment name\n */\nasync function saveInstantiatedAccounts(\n\taccounts: Record<string, InstantiatedAccount>,\n\tprojectDir: string,\n\tenv: string,\n): Promise<void> {\n\tconst configPath = path.join(projectDir, `.taq/config.local.${env}.json`);\n\n\ttry {\n\t\t// Read existing config or use an empty object if file doesn't exist\n\t\tlet config: Record<string, any> = {};\n\t\ttry {\n\t\t\tconst configContent = await fs.promises.readFile(configPath, 'utf8');\n\t\t\tconfig = JSON.parse(configContent);\n\t\t} catch (error) {\n\t\t\t// If file doesn't exist or there's an error reading it, we'll use an empty object\n\t\t}\n\n\t\t// Convert InstantiatedAccount to SandboxAccountConfig, omitting encryptedKey\n\t\tconst sandboxAccounts: Record<string, Omit<SandboxAccountConfig, 'encryptedKey'>> = {};\n\t\tfor (const [name, account] of Object.entries(accounts)) {\n\t\t\tsandboxAccounts[name] = {\n\t\t\t\tpublicKeyHash: account.publicKeyHash,\n\t\t\t\tsecretKey: account.secretKey,\n\t\t\t};\n\t\t}\n\n\t\t// Update only the accounts property in the config\n\t\tconfig.accounts = sandboxAccounts;\n\n\t\t// Ensure the directory exists\n\t\tawait fs.promises.mkdir(path.dirname(configPath), { recursive: true });\n\n\t\t// Write the updated config back to the file\n\t\tawait fs.promises.writeFile(configPath, JSON.stringify(config, null, 2), 'utf8');\n\t} catch (error) {\n\t\tthrow new Error(getErrorMessage('Failed to save instantiated accounts', error));\n\t}\n}\n\n/**\n * Generates a mnemonic phrase using BIP39.\n * @param strength The entropy bit length, defaults to 128 (resulting in a 12-word mnemonic).\n * @returns A promise that resolves to the generated mnemonic phrase.\n */\nasync function generateMnemonic(strength: number = 128): Promise<string> {\n\ttry {\n\t\tconst mnemonic = bip39.generateMnemonic(strength);\n\t\treturn mnemonic;\n\t} catch (error) {\n\t\tconsole.error('Error generating mnemonic:', error);\n\t\tthrow new Error('Failed to generate mnemonic');\n\t}\n}\n\n// Function to generate a new implicit account\nasync function createNewAccount() {\n\tconst mnemonic = await generateMnemonic();\n\n\t// Generate the BIP39 seed from the mnemonic\n\tconst seed = await bip39.mnemonicToSeed(mnemonic);\n\n\t// Convert the seed (Buffer) to a UInt8Array\n\tconst seedUInt8Array = new Uint8Array(seed);\n\n\t// Generate the secret key\n\tconst secretKey = generateSecretKey(seedUInt8Array, \"m/44'/1729'/0'/0'\", 'ed25519');\n\n\t// Derive the public key and public key hash from the secret key\n\tconst signer = new InMemorySigner(secretKey);\n\tconst publicKey = await signer.publicKey();\n\tconst publicKeyHash = await signer.publicKeyHash();\n\n\t// Return the object with pk, pkh, sk, and balance\n\treturn {\n\t\tpk: publicKey,\n\t\tpkh: publicKeyHash,\n\t\tsk: `unencrypted:${secretKey}`,\n\t};\n}\n\nfunction createFunderAccount() {\n\treturn createNewAccount().then(account => ({\n\t\tpublicKeyHash: account.pkh,\n\t\tsecretKey: account.sk,\n\t}));\n}\n\nasync function getPublicKeyFromSecretKey(secretKey: string) {\n\t// Initialize the signer with the secret key\n\tconst signer = await InMemorySigner.fromSecretKey(secretKey.replace('unencrypted:', ''));\n\n\t// Get the public key\n\tconst publicKey = await signer.publicKey();\n\n\treturn publicKey;\n}\n\n/**\n * Prepares TezBox accounts configuration.\n */\n/**\n * Prepares TezBox accounts configuration.\n */\nasync function prepareTezBoxAccounts(\n\tinstantiatedAccounts: Record<string, InstantiatedAccount>,\n\tdeclaredAccounts: Record<string, Mutez>,\n): Promise<Record<string, TezboxAccount>> {\n\t// Add funder account to instantiatedAccounts\n\t// instantiatedAccounts['funder'] = await createFunderAccount();\n\n\tconst tezboxAccounts: Record<string, TezboxAccount> = {};\n\n\tfor (const [accountName, accountData] of Object.entries(instantiatedAccounts)) {\n\t\tif (accountName === 'default') continue;\n\n\t\tconst secretKey = accountData.secretKey;\n\t\ttezboxAccounts[accountName] = {\n\t\t\tpkh: accountData.publicKeyHash,\n\t\t\tpk: await getPublicKeyFromSecretKey(secretKey),\n\t\t\tsk: secretKey,\n\t\t\tbalance: accountName === 'funder'\n\t\t\t\t? new BigNumber(100000000000000).toString()\n\t\t\t\t: new BigNumber(declaredAccounts[accountName].toString()).toString(),\n\t\t};\n\t}\n\n\treturn tezboxAccounts;\n}\n\n/**\n * Writes accounts.hjson file.\n */\nasync function writeAccountsHjson(\n\ttezboxAccounts: Record<string, TezboxAccount>,\n\ttezBoxConfigDir: string,\n): Promise<void> {\n\t// TODO: Remove for debugging\n\tawait Promise.resolve();\n\n\t// // Rearrange accounts record so that funder is first\n\t// const funderAccount = tezboxAccounts['funder'];\n\t// delete tezboxAccounts['funder'];\n\t// tezboxAccounts = { funder: funderAccount, ...tezboxAccounts };\n\n\t// Convert the accounts object to HJSON format\n\tconst hjsonContent = hjson.stringify(tezboxAccounts, {\n\t\tquotes: 'min',\n\t\tbracesSameLine: true,\n\t\tseparator: false,\n\t});\n\n\t// Remove quotes around sk values and ensure proper indentation\n\tconst fixedHjsonContent = hjsonContent.replaceAll('\"', '');\n\n\t// Write the accounts.hjson file\n\tconst accountsHjsonPath = path.join(tezBoxConfigDir, 'accounts.hjson');\n\tawait fs.promises.writeFile(accountsHjsonPath, fixedHjsonContent, 'utf8');\n}\n\n/**\n * Gets the declared accounts from the task arguments and removes underscores from Mutez values.\n */\nfunction getDeclaredAccounts(taskArgs: Opts): Record<string, Mutez> {\n\tconst declaredAccounts = taskArgs.config.accounts as Record<string, Mutez>;\n\treturn Object.entries(declaredAccounts).reduce((acc, [key, value]) => {\n\t\tacc[key] = value.toString().replace(/_/g, '');\n\t\treturn acc;\n\t}, {} as Record<string, Mutez>);\n}\n\n/**\n * Prepares accounts.hjson for TezBox.\n */\nasync function prepareAccountsHjson(taskArgs: Opts, tezBoxConfigDir: string): Promise<void> {\n\ttry {\n\t\t// Get or create instantiated accounts\n\t\tconst instantiatedAccounts = await getOrCreateInstantiatedAccounts(taskArgs);\n\n\t\t// Retrieve declared accounts\n\t\tconst declaredAccounts = getDeclaredAccounts(taskArgs);\n\n\t\t// Prepare tezbox accounts\n\t\tconst tezboxAccounts = await prepareTezBoxAccounts(instantiatedAccounts, declaredAccounts);\n\n\t\t// Write the accounts.hjson file\n\t\tawait writeAccountsHjson(tezboxAccounts, tezBoxConfigDir);\n\t} catch (error) {\n\t\tthrow new Error(getErrorMessage(`Failed to prepare accounts`, error));\n\t}\n}\n\n/**\n * Prepares bakers.hjson for TezBox.\n */\nasync function prepareBakersHjson(taskArgs: Opts, tezBoxConfigDir: string): Promise<void> {\n\ttry {\n\t\t// Get declared accounts\n\t\tconst declaredAccounts = getDeclaredAccounts(taskArgs);\n\n\t\t// Calculate total balance\n\t\tconst totalBalance = Object.values(declaredAccounts).reduce(\n\t\t\t(sum, balance) => BigNumber.sum(sum, balance),\n\t\t\tnew BigNumber(0),\n\t\t).toString();\n\n\t\t// Prepare bakers object\n\t\tconst bakers = {\n\t\t\tbaker1: {\n\t\t\t\tpkh: 'tz1faswCTDciRzE4oJ9jn2Vm2dvjeyA9fUzU',\n\t\t\t\tpk: 'edpkuTXkJDGcFd5nh6VvMz8phXxU3Bi7h6hqgywNFi1vZTfQNnS1RV',\n\t\t\t\tsk: 'unencrypted:edsk4ArLQgBTLWG5FJmnGnT689VKoqhXwmDPBuGx3z4cvwU9MmrPZZ',\n\t\t\t\tbalance: totalBalance,\n\t\t\t},\n\t\t\tbaker2: {\n\t\t\t\tpkh: 'tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN',\n\t\t\t\tpk: 'edpktzNbDAUjUk697W7gYg2CRuBQjyPxbEg8dLccYYwKSKvkPvjtV9',\n\t\t\t\tsk: 'unencrypted:edsk39qAm1fiMjgmPkw1EgQYkMzkJezLNewd7PLNHTkr6w9XA2zdfo',\n\t\t\t\tbalance: totalBalance,\n\t\t\t},\n\t\t\tbaker3: {\n\t\t\t\tpkh: 'tz1b7tUupMgCNw2cCLpKTkSD1NZzB5TkP2sv',\n\t\t\t\tpk: 'edpkuFrRoDSEbJYgxRtLx2ps82UdaYc1WwfS9sE11yhauZt5DgCHbU',\n\t\t\t\tsk: 'unencrypted:edsk2uqQB9AY4FvioK2YMdfmyMrer5R8mGFyuaLLFfSRo8EoyNdht3',\n\t\t\t\tbalance: totalBalance,\n\t\t\t},\n\t\t};\n\n\t\t// Convert the bakers object to HJSON format\n\t\tconst hjsonContent = hjson.stringify(bakers, {\n\t\t\tquotes: 'min',\n\t\t\tbracesSameLine: true,\n\t\t\tseparator: false,\n\t\t});\n\n\t\t// Remove quotes around sk values and ensure proper indentation\n\t\tconst fixedHjsonContent = hjsonContent.replaceAll('\"', '');\n\n\t\t// Write the bakers.hjson file\n\t\tconst bakersHjsonPath = path.join(tezBoxConfigDir, 'bakers.hjson');\n\t\tawait fs.promises.writeFile(bakersHjsonPath, fixedHjsonContent, 'utf8');\n\t} catch (error) {\n\t\tthrow new Error(getErrorMessage(`Failed to prepare bakers`, error));\n\t}\n}\n\n/**\n * Generates a project ID based on the project directory.\n */\nfunction getProjectId(taskArgs: Opts): string {\n\treturn createHash('sha256').update(taskArgs.projectDir).digest('hex');\n}\n\n/**\n * Gets the docker container name for the sandbox.\n */\nfunction getDockerContainerName(taskArgs: Opts): string {\n\tconst projectId = getProjectId(taskArgs);\n\treturn `taq-${taskArgs.env}-${projectId}`;\n}\n\n/**\n * Gets the TezBox configuration directory.\n */\nfunction getTezBoxConfigDir(taskArgs: Opts): string {\n\tconst containerName = getDockerContainerName(taskArgs);\n\treturn path.join(taskArgs.projectDir, `.taq/.${containerName}/config`);\n}\n\n/**\n * Gets the TezBox data directory.\n */\nfunction getTezBoxDataDir(taskArgs: Opts): string {\n\tconst containerName = getDockerContainerName(taskArgs);\n\treturn path.join(taskArgs.projectDir, `.taq/.${containerName}/data`);\n}\n\n/**\n * Gets the docker image for TezBox.\n */\nfunction getImage(taskArgs: Opts): string {\n\treturn getDockerImage(getDefaultDockerImage(taskArgs), 'TAQ_TEZBOX_IMAGE');\n}\n\n/**\n * Checks if the sandbox is running.\n */\nasync function isSandboxRunning(taskArgs: Opts): Promise<boolean> {\n\tconst containerName = getDockerContainerName(taskArgs);\n\tconst cmd = `docker ps --filter \"name=${containerName}\" --format \"{{.ID}}\"`;\n\tconst { stdout } = await runCommand(cmd);\n\treturn stdout.trim() !== '';\n}\n\n/**\n * Checks if the sandbox is already running.\n */\nasync function checkSandboxRunning(taskArgs: Opts): Promise<boolean> {\n\tconst running = await isSandboxRunning(taskArgs);\n\tif (running) {\n\t\tawait sendAsyncRes('Sandbox is already running.');\n\t}\n\treturn running;\n}\n\nfunction getPortNumber(taskArgs: Opts) {\n\tconst rpcUrl = getSandboxConfig(taskArgs).rpcUrl;\n\tconst match = rpcUrl.match(/:(\\d+)/);\n\treturn match ? parseInt(match[1], 10) : 80;\n}\n\nfunction getContainerPort(taskArgs: Opts) {\n\treturn getPortNumber(taskArgs) + 1;\n}\n\n/**\n * Gets the docker run parameters.\n */\nasync function getDockerRunParams(taskArgs: Opts): Promise<DockerRunParams> {\n\tconst image = getImage(taskArgs);\n\tconst containerName = getDockerContainerName(taskArgs);\n\tconst platform = await getArch();\n\tconst configDir = getTezBoxConfigDir(taskArgs);\n\tconst dataDir = getTezBoxDataDir(taskArgs);\n\tconst port = getContainerPort(taskArgs);\n\n\treturn { platform, image, containerName, configDir, dataDir, port };\n}\n\n/**\n * Ensures directories exist.\n */\nasync function ensureDirectoriesExist(directories: string[]): Promise<void> {\n\tawait Promise.all(\n\t\tdirectories.map(dir => fs.promises.mkdir(dir, { recursive: true })),\n\t);\n}\n\n/**\n * Constructs the docker run command.\n */\nfunction constructDockerRunCommand(params: DockerRunParams): string {\n\tconst { platform, image, containerName, configDir, port } = params;\n\n\tconst dockerOptions = [\n\t\t'docker run',\n\t\t'-d',\n\t\t`--platform ${platform}`,\n\t\t'-p 8732:8732',\n\t\t`-p ${port}:20000`,\n\t\t`--name ${containerName}`,\n\t\t`-v \"${configDir}:/tezbox/overrides\"`,\n\t\timage,\n\t\t'S',\n\t];\n\n\treturn dockerOptions.join(' ');\n}\n\n/**\n * Validates the block time in the sandbox configuration.\n */\nfunction validateBlockTime(taskArgs: Opts): number | null {\n\tconst sandboxConfig = getSandboxConfig(taskArgs);\n\tconst blockTime = sandboxConfig.blockTime;\n\tif (blockTime === undefined || blockTime === null) {\n\t\tlogger.warn('Block time is not specified; skipping block_time override.');\n\t\treturn null;\n\t}\n\treturn blockTime;\n}\n\n/**\n * Writes sandbox parameters for a single protocol.\n */\nasync function writeSandboxParameters(\n\tprotocolId: string,\n\tparameters: Record<string, string | number>,\n\ttezBoxConfigDir: string,\n): Promise<void> {\n\tconst protocolsDir = path.join(tezBoxConfigDir, 'protocols', protocolId);\n\tawait fs.promises.mkdir(protocolsDir, { recursive: true });\n\n\tconst hjsonContent = hjson.stringify(parameters, {\n\t\tquotes: 'min',\n\t\tbracesSameLine: true,\n\t\tseparator: false,\n\t});\n\n\tconst sandboxParamsPath = path.join(protocolsDir, 'sandbox-parameters.hjson');\n\tawait fs.promises.writeFile(sandboxParamsPath, hjsonContent, 'utf8');\n\n\t// Ensure the file has write permissions\n\ttry {\n\t\tawait fs.promises.chmod(sandboxParamsPath, 0o644);\n\t} catch (error) {\n\t\tlogger.warn(getErrorMessage(`Failed to set file permissions for ${sandboxParamsPath}`, error));\n\t}\n}\n\n/**\n * Applies block time override to a single protocol.\n */\nasync function applyBlockTimeOverrideToProtocol(\n\tprotocolId: string,\n\tblockTime: number,\n\ttezBoxConfigDir: string,\n): Promise<void> {\n\tconst nonce_revelation_threshold = 16;\n\tconst minimal_block_delay = blockTime;\n\n\tconst parameters = {\n\t\tminimal_block_delay: minimal_block_delay.toString(),\n\t};\n\tawait writeSandboxParameters(protocolId, parameters, tezBoxConfigDir);\n}\n\n/**\n * Applies block time override to multiple protocols.\n */\nasync function applyBlockTimeOverrideToProtocols(\n\tprotocolIds: string[],\n\tblockTime: number,\n\ttezBoxConfigDir: string,\n): Promise<void> {\n\tawait Promise.all(\n\t\tprotocolIds.map(async protocolId => {\n\t\t\t// Skip alpha protocol as it's a placeholder\n\t\t\tif (/^alpha$/i.test(protocolId)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait applyBlockTimeOverrideToProtocol(protocolId, blockTime, tezBoxConfigDir);\n\t\t}),\n\t);\n}\n\n/**\n * Gets protocol identifiers from TezBox configuration.\n */\nasync function getProtocolIds(taskArgs: Opts): Promise<string[]> {\n\tconst image = getImage(taskArgs);\n\n\t// List the protocol directories inside the TezBox image\n\tconst cmd = `docker run --rm --entrypoint ls ${image} /tezbox/configuration/protocols`;\n\tconst { stdout } = await runCommand(cmd);\n\n\tconst protocolIds = stdout\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.map(line => line.trim())\n\t\t.filter(line => line !== '');\n\n\treturn protocolIds;\n}\n\n/**\n * Reads and parses protocol.hjson for a given protocolId.\n */\nasync function readProtocolJson(image: string, protocolId: string): Promise<ProtocolMapping | null> {\n\tconst cmd = `docker run --rm --entrypoint cat ${image} /tezbox/configuration/protocols/${protocolId}/protocol.hjson`;\n\n\ttry {\n\t\tconst { stdout } = await runCommand(cmd);\n\n\t\tif (!stdout.trim()) {\n\t\t\tlogger.warn(`protocol.hjson not found or empty for protocolId ${protocolId}; skipping this protocol.`);\n\t\t\treturn null;\n\t\t}\n\n\t\t// Parse the HJSON content\n\t\tconst protocolData = hjson.parse(stdout);\n\t\tconst protocolHash: string = protocolData.hash;\n\t\tif (protocolHash) {\n\t\t\treturn { id: protocolId, hash: protocolHash };\n\t\t} else {\n\t\t\tlogger.warn(`Protocol hash not found in protocol.hjson for protocolId ${protocolId}; skipping.`);\n\t\t\treturn null;\n\t\t}\n\t} catch (error) {\n\t\tlogger.warn(getErrorMessage(`Failed to read protocol.hjson for protocolId ${protocolId}`, error));\n\t\treturn null;\n\t}\n}\n\n/**\n * Gets protocol mappings.\n */\nasync function getProtocolMappings(taskArgs: Opts): Promise<ProtocolMapping[]> {\n\tconst image = getImage(taskArgs);\n\tconst protocolIds = await getProtocolIds(taskArgs);\n\n\tconst protocolMappingsPromises = protocolIds.map(async protocolId => {\n\t\tconst mapping = await readProtocolJson(image, protocolId);\n\t\treturn mapping;\n\t});\n\n\tconst protocolMappings = await Promise.all(protocolMappingsPromises);\n\treturn protocolMappings.filter((mapping): mapping is ProtocolMapping => mapping !== null);\n}\n\n/**\n * Gets protocol hashes from octez-client.\n */\nasync function getOctezClientProtocols(taskArgs: Opts): Promise<string[]> {\n\tconst image = getImage(taskArgs);\n\tconst cmd = `docker run --rm --entrypoint octez-client ${image} list mockup protocols`;\n\tconst { stdout } = await runCommand(cmd, stderr => {\n\t\tconst ignorableError = [\n\t\t\t'Base directory /tezbox/data/.tezos-client does not exist.',\n\t\t\t'Unable to connect to the node: \"Unix.Unix_error(Unix.ECONNREFUSED, \"connect\", \"\")\"',\n\t\t];\n\n\t\tif (stderr.trim() !== '' && !ignorableError.some(err => stderr.includes(err))) {\n\t\t\tthrow new Error(`Failed to list protocols: ${stderr.trim()}`);\n\t\t}\n\t});\n\n\tconst protocols = stdout\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.filter(line => line.trim() !== '');\n\n\treturn protocols;\n}\n\n/**\n * Prepares sandbox-parameters.hjson for block_time override.\n */\nasync function prepareSandboxParametersHjson(taskArgs: Opts, tezBoxConfigDir: string): Promise<void> {\n\ttry {\n\t\t// Validate block time\n\t\tconst blockTime = validateBlockTime(taskArgs);\n\t\tif (blockTime === null) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Get the protocol mappings from TezBox\n\t\tconst protocolMappings = await getProtocolMappings(taskArgs);\n\t\tconst hashToIdMap: Record<string, string> = {};\n\t\tfor (const mapping of protocolMappings) {\n\t\t\thashToIdMap[mapping.hash] = mapping.id;\n\t\t}\n\n\t\t// Get the list of protocol hashes supported by octez-client\n\t\tconst protocolHashes = await getOctezClientProtocols(taskArgs);\n\n\t\t// Map protocol hashes to TezBox protocol IDs\n\t\tconst protocolIdsToOverride = protocolHashes\n\t\t\t.map(hash => hashToIdMap[hash])\n\t\t\t.filter((id): id is string => id !== undefined);\n\n\t\tif (protocolIdsToOverride.length === 0) {\n\t\t\tlogger.warn('No matching protocol IDs found; cannot set block_time override.');\n\t\t\treturn;\n\t\t}\n\n\t\t// Debug: Log the protocol IDs to override\n\t\t// logger.info(`Protocol IDs to override: ${protocolIdsToOverride.join(', ')}`);\n\n\t\t// Apply block time override to each protocol ID\n\t\tawait applyBlockTimeOverrideToProtocols(protocolIdsToOverride, blockTime, tezBoxConfigDir);\n\t} catch (error) {\n\t\tconst errorMessage = getErrorMessage(`Failed to prepare sandbox parameters:`, error);\n\t\tthrow new Error(errorMessage);\n\t}\n}\n\n/**\n * Prepares baker.hjson if baking is disabled.\n */\nasync function prepareBakerHjson(tezBoxConfigDir: string): Promise<void> {\n\tconst servicesDir = path.join(tezBoxConfigDir, 'services');\n\ttry {\n\t\tawait fs.promises.mkdir(servicesDir, { recursive: true });\n\n\t\tconst bakerConfig = {\n\t\t\tautostart: false,\n\t\t};\n\n\t\tconst hjsonContent = hjson.stringify(bakerConfig, {\n\t\t\tquotes: 'all',\n\t\t\tbracesSameLine: true,\n\t\t\tseparator: true,\n\t\t});\n\n\t\tconst bakerConfigPath = path.join(servicesDir, 'baker.hjson');\n\t\tawait fs.promises.writeFile(bakerConfigPath, hjsonContent, 'utf8');\n\t} catch (error) {\n\t\tthrow new Error(getErrorMessage(`Failed to prepare baker.hjson`, error));\n\t}\n}\n\n/**\n * Prepares TezBox configuration overrides.\n */\nasync function prepareTezBoxOverrides(taskArgs: Opts): Promise<void> {\n\tconst tezBoxConfigDir = getTezBoxConfigDir(taskArgs);\n\n\ttry {\n\t\t// Get sandbox configuration\n\t\tconst sandboxConfig = getSandboxConfig(taskArgs);\n\n\t\t// Ensure the configuration directory exists\n\t\tawait fs.promises.mkdir(tezBoxConfigDir, { recursive: true });\n\n\t\t// Prepare tasks\n\t\tconst tasks: Promise<void>[] = [];\n\n\t\t// Prepare bakers.hjson\n\t\ttasks.push(prepareBakersHjson(taskArgs, tezBoxConfigDir));\n\n\t\t// Prepare accounts.hjson\n\t\tif (taskArgs.config.accounts) {\n\t\t\ttasks.push(prepareAccountsHjson(taskArgs, tezBoxConfigDir));\n\t\t}\n\n\t\t// Prepare sandbox-parameters.hjson for block_time\n\t\tif (sandboxConfig.blockTime) {\n\t\t\ttasks.push(prepareSandboxParametersHjson(taskArgs, tezBoxConfigDir));\n\t\t}\n\n\t\t// Prepare baker.hjson if baking is disabled\n\t\tif (sandboxConfig.baking === BakingOption.DISABLED) {\n\t\t\ttasks.push(prepareBakerHjson(tezBoxConfigDir));\n\t\t}\n\n\t\t// Run all preparations in parallel\n\t\tawait Promise.all(tasks);\n\t} catch (error) {\n\t\tthrow new Error(getErrorMessage(`Failed to prepare TezBox overrides`, error));\n\t}\n}\n\nfunction getProxyContainerName(taskArgs: Opts) {\n\treturn `${getDockerContainerName(taskArgs)}-proxy`;\n}\n\nasync function startProxyServer(taskArgs: Opts): Promise<void> {\n\tconst containerPort = getContainerPort(taskArgs);\n\tconst proxyPort = getPortNumber(taskArgs);\n\tconst proxyContainerName = getProxyContainerName(taskArgs);\n\n\tconst proxyCmd = `docker run -d --name ${proxyContainerName} \\\n --network host \\\n caddy:2-alpine \\\n caddy reverse-proxy \\\n --from http://:${proxyPort} \\\n --to http://127.0.0.1:${containerPort} \\\n --access-log`;\n\n\ttry {\n\t\tawait runCommand(proxyCmd);\n\t} catch (error) {\n\t\tthrow new Error(getErrorMessage(`Failed to start Caddy reverse proxy`, error));\n\t}\n}\n\nasync function stopProxyServer(taskArgs: Opts): Promise<void> {\n\tconst proxyContainerName = getProxyContainerName(taskArgs);\n\tconst cmd = `docker rm -f ${proxyContainerName}`;\n\tawait runCommand(cmd);\n}\n\n/**\n * Starts the sandbox.\n */\nasync function startSandbox(taskArgs: Opts): Promise<void> {\n\ttry {\n\t\t// Check for Docker availability\n\t\tawait checkDockerAvailability();\n\n\t\t// Check if the sandbox is already running\n\t\tif (await checkSandboxRunning(taskArgs)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Get Docker run parameters\n\t\tconst params = await getDockerRunParams(taskArgs);\n\n\t\t// Ensure necessary directories exist\n\t\tawait ensureDirectoriesExist([params.dataDir, params.configDir]);\n\n\t\t// Prepare TezBox configuration overrides\n\t\tawait prepareTezBoxOverrides(taskArgs);\n\n\t\t// Construct the Docker run command\n\t\tconst cmd = constructDockerRunCommand(params);\n\t\t// logger.info(`Starting sandbox with command: ${cmd}`);\n\n\t\t// Execute the Docker run command\n\t\tawait runCommand(cmd);\n\n\t\t// Start the proxy server\n\t\tawait startProxyServer(taskArgs);\n\n\t\t// Send a success response\n\t\tawait sendAsyncRes('Sandbox started successfully.');\n\t} catch (error) {\n\t\tawait sendAsyncErr(getErrorMessage(`Failed to start sandbox`, error));\n\t}\n}\n\n/**\n * Checks for Docker availability.\n */\nasync function checkDockerAvailability(): Promise<void> {\n\ttry {\n\t\tawait runCommand('docker --version');\n\t} catch (error) {\n\t\tthrow new Error('Docker is not installed or not running. Please install and start Docker.');\n\t}\n}\n\n/**\n * Removes the sandbox container.\n */\nasync function removeSandboxContainer(taskArgs: Opts): Promise<void> {\n\tconst containerName = getDockerContainerName(taskArgs);\n\tconst cmd = `docker rm -f ${containerName}`;\n\n\ttry {\n\t\tawait runCommand(cmd);\n\t} catch (error) {\n\t\tconst errorMessage = getErrorMessage('', error);\n\t\tif (errorMessage.includes('No such container')) {\n\t\t\t// Container does not exist\n\t\t\tawait sendAsyncRes('Sandbox is not running or already stopped.');\n\t\t} else {\n\t\t\tthrow new Error(errorMessage);\n\t\t}\n\t}\n\n\t// Stop the proxy server\n\tawait stopProxyServer(taskArgs);\n}\n\n/**\n * Stops the sandbox.\n */\nasync function stopSandbox(taskArgs: Opts): Promise<void> {\n\ttry {\n\t\t// Attempt to stop and remove the sandbox container\n\t\tawait removeSandboxContainer(taskArgs);\n\n\t\t// Optionally, clean up configuration directory if needed\n\t\tconst configDir = getTezBoxConfigDir(taskArgs);\n\t\tawait fs.promises.rm(configDir, { recursive: true, force: true });\n\n\t\t// Send a success response\n\t\tawait sendAsyncRes('Sandbox stopped and cleaned up.');\n\t} catch (error) {\n\t\tawait sendAsyncErr(getErrorMessage(`Failed to stop sandbox`, error));\n\t}\n}\n\n/**\n * Restarts the sandbox.\n */\nasync function restartSandbox(taskArgs: Opts): Promise<void> {\n\ttry {\n\t\t// Stop the sandbox if it's running\n\t\tawait removeSandboxContainer(taskArgs);\n\n\t\t// Start the sandbox\n\t\tawait startSandbox(taskArgs);\n\n\t\t// Send a success response\n\t\tawait sendAsyncRes('Sandbox restarted successfully.');\n\t} catch (error) {\n\t\tawait sendAsyncErr(getErrorMessage(`Failed to restart sandbox`, error));\n\t}\n}\n\n/**\n * Lists protocols.\n */\nasync function listProtocols(taskArgs: Opts): Promise<void> {\n\ttry {\n\t\tconst protocolHashes = await getOctezClientProtocols(taskArgs);\n\t\tconst protocolObjects = protocolHashes.map(protocol => ({ protocol }));\n\t\tawait sendAsyncJsonRes(protocolObjects);\n\t} catch (error) {\n\t\tawait sendAsyncErr(getErrorMessage(`Failed to list protocols`, error));\n\t}\n}\n\n/**\n * Lists accounts.\n */\nasync function listAccounts(taskArgs: Opts): Promise<void> {\n\ttry {\n\t\tif (await isSandboxRunning(taskArgs)) {\n\t\t\t// List accounts from the sandbox\n\t\t\tconst containerName = getDockerContainerName(taskArgs);\n\t\t\tconst cmd = `docker exec ${containerName} octez-client list known addresses`;\n\t\t\tconst { stdout } = await runCommand(cmd);\n\n\t\t\tif (!stdout.trim()) {\n\t\t\t\tawait sendAsyncRes('No accounts found.');\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst accounts = stdout\n\t\t\t\t.trim()\n\t\t\t\t.split('\\n')\n\t\t\t\t.filter(line => line.trim() !== '')\n\t\t\t\t.map(line => {\n\t\t\t\t\tconst [name, rest] = line.split(':');\n\t\t\t\t\tconst address = rest ? rest.trim().split(' ')[0] : '';\n\t\t\t\t\treturn { name: name.trim(), address };\n\t\t\t\t});\n\n\t\t\tawait sendAsyncJsonRes(accounts);\n\t\t} else {\n\t\t\tawait sendAsyncErr(`Sandbox is not running. Please start the sandbox before attempting to list accounts.`);\n\t\t}\n\t} catch (error) {\n\t\tawait sendAsyncErr(getErrorMessage(`Failed to list accounts`, error));\n\t}\n}\n\n/**\n * Bakes a block in the sandbox.\n */\nasync function bakeBlock(taskArgs: Opts): Promise<void> {\n\ttry {\n\t\tif (await isSandboxRunning(taskArgs)) {\n\t\t\tconst containerName = getDockerContainerName(taskArgs);\n\t\t\tconst cmd = `docker exec ${containerName} octez-client bake for baker1`;\n\n\t\t\tif (taskArgs.watch) {\n\t\t\t\tconsole.log('Baking on demand as operations are injected.');\n\t\t\t\tconsole.log('Press CTRL-C to stop and exit.');\n\t\t\t\tconsole.log();\n\n\t\t\t\twhile (true) {\n\t\t\t\t\tconsole.log('Waiting for operations to be injected...');\n\t\t\t\t\twhile (true) {\n\t\t\t\t\t\tconst { stdout } = await runCommand(\n\t\t\t\t\t\t\t`docker exec ${containerName} octez-client rpc get /chains/main/mempool/pending_operations`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst ops = JSON.parse(stdout);\n\t\t\t\t\t\tif (Array.isArray(ops.applied) && ops.applied.length > 0) break;\n\t\t\t\t\t\tawait new Promise(resolve => setTimeout(resolve, 1000)); // Wait for 1 second before checking again\n\t\t\t\t\t}\n\n\t\t\t\t\tawait runCommand(cmd);\n\t\t\t\t\tconsole.log('Block baked.');\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tawait runCommand(cmd);\n\t\t\t\tawait sendAsyncRes('Block baked successfully.');\n\t\t\t}\n\t\t} else {\n\t\t\ttry {\n\t\t\t\tawait sendAsyncErr('Sandbox is not running. Please start the sandbox before attempting to bake a block.');\n\t\t\t} catch {\n\t\t\t\t// Nothing to see here.\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\tawait sendAsyncErr(getErrorMessage(`Failed to bake block`, error));\n\t}\n}\n\n/**\n * Main proxy function to handle tasks.\n */\nexport const proxy = async (taskArgs: Opts): Promise<void> => {\n\tif (!isTezBoxEnvironment(taskArgs)) {\n\t\tawait sendAsyncErr(\n\t\t\t`This configuration doesn't appear to be configured to use TezBox environments. Check the ${taskArgs.env} environment in your .taq/config.json.`,\n\t\t);\n\t\treturn;\n\t}\n\n\tconst taskName = taskArgs.task?.toLowerCase().trim();\n\n\tconst taskHandlers: Record<string, (args: Opts) => Promise<void>> = {\n\t\t'start sandbox': startSandbox,\n\t\t'stop sandbox': stopSandbox,\n\t\t'restart sandbox': restartSandbox,\n\t\t'list protocols': listProtocols,\n\t\t'list-protocols': listProtocols,\n\t\t'show protocols': listProtocols,\n\t\t'show-protocols': listProtocols,\n\t\t'list accounts': listAccounts,\n\t\t'list-accounts': listAccounts,\n\t\t'show accounts': listAccounts,\n\t\t'show-accounts': listAccounts,\n\t\t'bake': bakeBlock,\n\t\t'bake block': bakeBlock,\n\t};\n\n\tconst handler = taskName ? taskHandlers[taskName] : undefined;\n\n\tif (handler) {\n\t\ttry {\n\t\t\tawait handler(taskArgs);\n\t\t} catch (error) {\n\t\t\tawait sendAsyncErr(getErrorMessage(`Error executing task '${taskArgs.task}'`, error));\n\t\t}\n\t} else {\n\t\tawait sendAsyncErr(taskArgs.task ? `Unknown task: ${taskArgs.task}` : 'No task provided');\n\t}\n};\n\nexport default proxy;\n","import { getDockerImage } from '@taqueria/node-sdk';\nimport { Opts } from './types';\n\nexport const TAQ_TEZBOX_IMAGE_ENV_VAR = 'TAQ_TEZBOX_IMAGE';\n\nexport const getDefaultDockerImage = (opts: Opts) => `ghcr.io/tez-capital/tezbox:tezos-v23.0-rc2`;\n\nexport const getImage = (opts: Opts) => getDockerImage(getDefaultDockerImage(opts), TAQ_TEZBOX_IMAGE_ENV_VAR);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,mBAAoD;;;ACApD,IAAAC,mBASO;AACP,oBAAkD;AAClD,uBAAsB;AACtB,YAAuB;AACvB,oBAA2B;AAE3B,SAAoB;AACpB,YAAuB;AACvB,WAAsB;;;ACjBtB,sBAA+B;AAKxB,IAAM,wBAAwB,CAAC,SAAe;;;ADyDrD,IAAM,SAAS;AAAA,EACd,MAAM,CAAC,YAAoB,QAAQ,IAAI,OAAO;AAAA,EAC9C,MAAM,CAAC,YAAoB,QAAQ,KAAK,OAAO;AAAA,EAC/C,OAAO,CAAC,YAAoB,QAAQ,MAAM,OAAO;AAClD;AAOA,SAAS,gBAAgB,QAAgB,OAAwB;AAChE,MAAI,WAAW,IAAI;AAClB,WAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,EAC7D;AACA,MAAI,OAAO,UAAU,WAAW;AAC/B,WAAO,GAAG,MAAM;AAAA,EACjB;AACA,QAAM,cAAc,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AACzE,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AAa;AAAA,MACb,SAAS,CAAC;AAAA,MACV,SAAS;AAAA,IACV,CAAC;AAAA,IACD,sBAAK,OAAO;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,SAAS,CAAC,gBAAgB;AAAA,MAC1B,aAAa;AAAA,MACb,SAAS,CAAC;AAAA,MACV,SAAS;AAAA,IACV,CAAC;AAAA,IACD,sBAAK,OAAO;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,SAAS,CAAC;AAAA,MACV,aAAa;AAAA,MACb,SAAS,CAAC;AAAA,MACV,SAAS;AAAA,MACT,UAAU;AAAA,IACX,CAAC;AAAA,IACD,sBAAK,OAAO;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,SAAS,CAAC,GAAG;AAAA,MACb,aAAa;AAAA,MACb,SAAS;AAAA,QACR,wBAAO,OAAO;AAAA,UACb,MAAM;AAAA,UACN,WAAW;AAAA,UACX,aACC;AAAA,UACD,SAAS;AAAA,QACV,CAAC;AAAA,MACF;AAAA,MACA,SAAS;AAAA,MACT,UAAU;AAAA,IACX,CAAC;AAAA,IACD,sBAAK,OAAO;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,SAAS,CAAC,gBAAgB;AAAA,MAC1B,aAAa;AAAA,MACb,SAAS,CAAC;AAAA,MACV,SAAS;AAAA,MACT,UAAU;AAAA,IACX,CAAC;AAAA,EACF;AAAA,EACA,OAAO;AACR,IAAI,QAAQ,IAAI;","names":["import_node_sdk","import_node_sdk","BigNumber","generateMnemonic","BigNumber"]}
|
package/index.mjs
CHANGED
|
@@ -20,7 +20,7 @@ import * as path from "path";
|
|
|
20
20
|
|
|
21
21
|
// docker.ts
|
|
22
22
|
import { getDockerImage } from "@taqueria/node-sdk";
|
|
23
|
-
var getDefaultDockerImage = (opts) => `ghcr.io/tez-capital/tezbox:tezos-
|
|
23
|
+
var getDefaultDockerImage = (opts) => `ghcr.io/tez-capital/tezbox:tezos-v23.0-rc2`;
|
|
24
24
|
|
|
25
25
|
// proxy.ts
|
|
26
26
|
var logger = {
|
|
@@ -314,7 +314,7 @@ function constructDockerRunCommand(params) {
|
|
|
314
314
|
`--name ${containerName}`,
|
|
315
315
|
`-v "${configDir}:/tezbox/overrides"`,
|
|
316
316
|
image,
|
|
317
|
-
"
|
|
317
|
+
"S"
|
|
318
318
|
];
|
|
319
319
|
return dockerOptions.join(" ");
|
|
320
320
|
}
|
package/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts","proxy.ts","docker.ts"],"sourcesContent":["import { Option, Plugin, PositionalArg, Task } from '@taqueria/node-sdk';\nimport proxy from './proxy';\n\nPlugin.create(_i18n => ({\n\talias: 'tezbox',\n\tschema: '1.0',\n\tversion: '0.1',\n\ttasks: [\n\t\tTask.create({\n\t\t\ttask: 'start sandbox',\n\t\t\tcommand: 'start sandbox',\n\t\t\taliases: ['start tezbox'],\n\t\t\tdescription: 'Starts a TezBox sandbox',\n\t\t\toptions: [],\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'none',\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'stop sandbox',\n\t\t\tcommand: 'stop sandbox',\n\t\t\taliases: ['stop tezbox'],\n\t\t\tdescription: 'Stops a TezBox sandbox',\n\t\t\toptions: [],\n\t\t\thandler: 'proxy',\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'restart sandbox',\n\t\t\tcommand: 'restart sandbox',\n\t\t\taliases: ['restart tezbox'],\n\t\t\tdescription: 'Restarts a TezBox sandbox',\n\t\t\toptions: [],\n\t\t\thandler: 'proxy',\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'list accounts',\n\t\t\tcommand: 'list accounts',\n\t\t\taliases: [],\n\t\t\tdescription: 'List the balances of all sandbox accounts',\n\t\t\toptions: [],\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'json',\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'bake',\n\t\t\tcommand: 'bake',\n\t\t\taliases: ['b'],\n\t\t\tdescription: 'Manually bake a block. Use when the \"baking\" setting of a TezBox sandbox is set to \"disabled\".',\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'watch',\n\t\t\t\t\tshortFlag: 'w',\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'Watch for operations as they are injected into the mempool and bake them as immediate as possible.',\n\t\t\t\t\tboolean: true,\n\t\t\t\t}),\n\t\t\t],\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'none',\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'show protocols',\n\t\t\tcommand: 'show protocols',\n\t\t\taliases: ['list protocols'],\n\t\t\tdescription: 'List protocols understood by this version of TezBox',\n\t\t\toptions: [],\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'json',\n\t\t}),\n\t],\n\tproxy: proxy,\n}), process.argv);\n","import {\n\texecCmd,\n\tgetArch,\n\tgetDockerImage,\n\tSandboxAccountConfig,\n\tSandboxConfig,\n\tsendAsyncErr,\n\tsendAsyncJsonRes,\n\tsendAsyncRes,\n} from '@taqueria/node-sdk';\nimport { generateSecretKey, InMemorySigner } from '@taquito/signer';\nimport BigNumber from 'bignumber.js';\nimport * as bip39 from 'bip39';\nimport { createHash } from 'crypto';\nimport { create } from 'domain';\nimport * as fs from 'fs';\nimport * as hjson from 'hjson';\nimport * as path from 'path';\nimport { getDefaultDockerImage } from './docker';\nimport { Opts } from './types';\n\ntype ConfigV1Environment = {\n\tsandboxes?: string[];\n};\n\ntype Mutez = string | number; // Represents balance in mutez\n\ntype InstantiatedAccount = Omit<SandboxAccountConfig, 'encryptedKey'> & {\n\tencryptedKey?: string;\n};\n\ninterface TezboxAccount {\n\tpkh: string;\n\tpk: string;\n\tsk: string;\n\tbalance: string;\n}\n\ntype SandboxConfigV1 = SandboxConfig;\n\ninterface ProtocolMapping {\n\tid: string; // e.g., \"Proxford\"\n\thash: string; // e.g., \"PsDELPH1...\"\n}\n\ninterface DockerRunParams {\n\tplatform: string;\n\timage: string;\n\tcontainerName: string;\n\tconfigDir: string;\n\tdataDir: string;\n\tport: number;\n}\n\nenum BakingOption {\n\tENABLED = 'enabled',\n\tDISABLED = 'disabled',\n}\n\n/**\n * Logger utility for standardized logging.\n */\nconst logger = {\n\tinfo: (message: string) => console.log(message),\n\twarn: (message: string) => console.warn(message),\n\terror: (message: string) => console.error(message),\n};\n\n/**\n * Extracts error message from unknown error type and prepends a prefix.\n/**\n * Extracts error message from unknown error type and optionally prepends a prefix.\n */\nfunction getErrorMessage(prefix: string, error: unknown): string {\n\tif (prefix === '') {\n\t\treturn error instanceof Error ? error.message : String(error);\n\t}\n\tif (typeof error === 'boolean') {\n\t\treturn `${prefix}:`;\n\t}\n\tconst errorString = error instanceof Error ? error.message : String(error);\n\treturn `${prefix}: ${errorString}`;\n}\n\n/**\n * Creates a command runner with optional logging capability\n */\nfunction createCommandRunner(enableLogging: boolean = false) {\n\tconst logFile = path.join(process.cwd(), 'tezbox-commands.log');\n\n\tasync function logExecution(sections: Record<string, string>): Promise<void> {\n\t\tif (!enableLogging) return;\n\n\t\tconst logEntry = Object.entries(sections)\n\t\t\t.map(([header, content]) =>\n\t\t\t\t[\n\t\t\t\t\t`\\n=== ${header} ===`,\n\t\t\t\t\tcontent || '[no content]',\n\t\t\t\t].join('\\n')\n\t\t\t)\n\t\t\t.join('\\n');\n\n\t\tawait fs.promises.appendFile(logFile, logEntry + '\\n\\n');\n\t}\n\n\t/**\n\t * Executes a shell command and standardizes error handling.\n\t */\n\treturn async function runCommand(\n\t\tcmd: string,\n\t\tstderrHandler?: (stderr: string) => void | Promise<void>,\n\t): Promise<{ stdout: string }> {\n\t\tawait logExecution({ COMMAND: cmd });\n\n\t\ttry {\n\t\t\tconst { stdout, stderr } = await execCmd(cmd);\n\n\t\t\tawait logExecution({\n\t\t\t\tSTDOUT: stdout,\n\t\t\t\tSTDERR: stderr.trim(),\n\t\t\t});\n\n\t\t\tif (stderr.trim()) {\n\t\t\t\tif (stderrHandler) {\n\t\t\t\t\tawait stderrHandler(stderr.trim());\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(stderr.trim());\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn { stdout };\n\t\t} catch (error) {\n\t\t\tawait logExecution({\n\t\t\t\tERROR: error instanceof Error ? error.message : String(error),\n\t\t\t});\n\n\t\t\tthrow new Error(getErrorMessage(`Command failed`, error));\n\t\t}\n\t};\n}\n\n// Create the runCommand function with logging enabled or disabled\n// const runCommand = createCommandRunner(true); // Set to false to disable logging\n\n/**\n * Executes a shell command and standardizes error handling.\n */\nasync function runCommand(\n\tcmd: string,\n\tstderrHandler?: (stderr: string) => void | Promise<void>,\n): Promise<{ stdout: string }> {\n\ttry {\n\t\tconst { stdout, stderr } = await execCmd(cmd);\n\t\tif (stderr.trim()) {\n\t\t\tif (stderrHandler) {\n\t\t\t\tawait stderrHandler(stderr.trim());\n\t\t\t} else {\n\t\t\t\tthrow new Error(stderr.trim());\n\t\t\t}\n\t\t}\n\t\treturn { stdout };\n\t} catch (error) {\n\t\tthrow new Error(getErrorMessage(`Command failed`, error));\n\t}\n}\n\n/**\n * Checks if the given environment is configured for TezBox.\n */\nfunction isTezBoxEnvironment(taskArgs: Opts): boolean {\n\tconst environment = taskArgs.config.environment[taskArgs.env];\n\tif (!environment || typeof environment !== 'object') return false;\n\n\tconst sandboxes = (environment as ConfigV1Environment).sandboxes;\n\tif (!Array.isArray(sandboxes) || sandboxes.length === 0) return false;\n\n\t// Currently, we don't have a way to tell if a sandbox is TezBox-provided\n\treturn true;\n}\n\n/**\n * Creates a Tezos account with the specified name and balance.\n */\nasync function instantiateDeclaredAccount(\n\tdeclaredAccountName: string,\n\tbalanceInMutez: BigNumber,\n): Promise<InstantiatedAccount> {\n\t// Generate a new account using BIP39 and Tezos key derivation\n\tconst account = await createNewAccount();\n\n\t// Return the instantiated account with real credentials\n\treturn {\n\t\tencryptedKey: `unencrypted:${account.pk}`,\n\t\tpublicKeyHash: account.pkh,\n\t\tsecretKey: account.sk,\n\t};\n}\n\n/**\n * Throws warning indicating function is not implemented yet.\n */\nasync function getInstantiatedAccounts(taskArgs: Opts): Promise<Record<string, InstantiatedAccount>> {\n\tconst sandboxConfig = getSandboxConfig(taskArgs);\n\tif (!sandboxConfig.accounts) {\n\t\tthrow new Error('No instantiated accounts found in sandbox config.');\n\t}\n\tconst accounts = sandboxConfig.accounts as Record<string, InstantiatedAccount>;\n\treturn Object.entries(accounts)\n\t\t.filter(([key]) => key !== 'default')\n\t\t.reduce((acc, [key, value]) => {\n\t\t\tacc[key] = value;\n\t\t\treturn acc;\n\t\t}, {} as Record<string, InstantiatedAccount>);\n}\n\n/**\n * Gets the sandbox configuration for the given environment.\n */\nfunction getSandboxConfig(taskArgs: Opts): SandboxConfigV1 {\n\tif (!isTezBoxEnvironment(taskArgs)) {\n\t\tthrow new Error(\n\t\t\t`This configuration doesn't appear to be configured to use TezBox environments. Check the ${taskArgs.env} environment in your .taq/config.json.`,\n\t\t);\n\t}\n\n\tconst environment = taskArgs.config.environment[taskArgs.env] as ConfigV1Environment;\n\tconst sandboxName = environment.sandboxes?.[0];\n\tif (sandboxName) {\n\t\tconst sandboxConfig = taskArgs.config.sandbox?.[sandboxName];\n\t\tif (sandboxConfig) {\n\t\t\tconst retval: SandboxConfigV1 = {\n\t\t\t\tblockTime: 1,\n\t\t\t\tbaking: BakingOption.ENABLED,\n\t\t\t\t...sandboxConfig,\n\t\t\t\t...sandboxConfig.annotations,\n\t\t\t};\n\n\t\t\treturn retval;\n\t\t}\n\t}\n\tthrow new Error(`No sandbox configuration found for ${taskArgs.env} environment.`);\n}\n\n/**\n * Gets or creates instantiated accounts.\n */\nasync function getOrCreateInstantiatedAccounts(\n\ttaskArgs: Opts,\n): Promise<Record<string, InstantiatedAccount>> {\n\tlet instantiatedAccounts: Record<string, InstantiatedAccount>;\n\n\ttry {\n\t\t// Attempt to get instantiated accounts\n\t\tinstantiatedAccounts = await getInstantiatedAccounts(taskArgs);\n\t} catch (error) {\n\t\t// No instantiated accounts available, so we need to instantiate them\n\t\tinstantiatedAccounts = {};\n\t\tconst declaredAccounts = taskArgs.config.accounts as Record<string, Mutez>;\n\n\t\tfor (const [accountName, balanceInMutez] of Object.entries(declaredAccounts)) {\n\t\t\t// Convert balance to BigNumber, removing any underscores used for formatting\n\t\t\tconst balanceInMutezBN = new BigNumber(balanceInMutez.toString().replace(/_/g, ''));\n\n\t\t\t// Instantiate the declared account\n\t\t\tconst instantiatedAccount = await instantiateDeclaredAccount(accountName, balanceInMutezBN);\n\n\t\t\t// Store the instantiated account\n\t\t\tinstantiatedAccounts[accountName] = instantiatedAccount;\n\t\t}\n\n\t\t// Optionally, save the instantiated accounts to persist them for future runs\n\t\tawait saveInstantiatedAccounts(instantiatedAccounts, taskArgs.projectDir, taskArgs.env);\n\t}\n\n\treturn instantiatedAccounts;\n}\n\n/**\n * Saves instantiated accounts to the local configuration file.\n * @param accounts Record of instantiated accounts\n * @param projectDir Project directory path\n * @param env Environment name\n */\nasync function saveInstantiatedAccounts(\n\taccounts: Record<string, InstantiatedAccount>,\n\tprojectDir: string,\n\tenv: string,\n): Promise<void> {\n\tconst configPath = path.join(projectDir, `.taq/config.local.${env}.json`);\n\n\ttry {\n\t\t// Read existing config or use an empty object if file doesn't exist\n\t\tlet config: Record<string, any> = {};\n\t\ttry {\n\t\t\tconst configContent = await fs.promises.readFile(configPath, 'utf8');\n\t\t\tconfig = JSON.parse(configContent);\n\t\t} catch (error) {\n\t\t\t// If file doesn't exist or there's an error reading it, we'll use an empty object\n\t\t}\n\n\t\t// Convert InstantiatedAccount to SandboxAccountConfig, omitting encryptedKey\n\t\tconst sandboxAccounts: Record<string, Omit<SandboxAccountConfig, 'encryptedKey'>> = {};\n\t\tfor (const [name, account] of Object.entries(accounts)) {\n\t\t\tsandboxAccounts[name] = {\n\t\t\t\tpublicKeyHash: account.publicKeyHash,\n\t\t\t\tsecretKey: account.secretKey,\n\t\t\t};\n\t\t}\n\n\t\t// Update only the accounts property in the config\n\t\tconfig.accounts = sandboxAccounts;\n\n\t\t// Ensure the directory exists\n\t\tawait fs.promises.mkdir(path.dirname(configPath), { recursive: true });\n\n\t\t// Write the updated config back to the file\n\t\tawait fs.promises.writeFile(configPath, JSON.stringify(config, null, 2), 'utf8');\n\t} catch (error) {\n\t\tthrow new Error(getErrorMessage('Failed to save instantiated accounts', error));\n\t}\n}\n\n/**\n * Generates a mnemonic phrase using BIP39.\n * @param strength The entropy bit length, defaults to 128 (resulting in a 12-word mnemonic).\n * @returns A promise that resolves to the generated mnemonic phrase.\n */\nasync function generateMnemonic(strength: number = 128): Promise<string> {\n\ttry {\n\t\tconst mnemonic = bip39.generateMnemonic(strength);\n\t\treturn mnemonic;\n\t} catch (error) {\n\t\tconsole.error('Error generating mnemonic:', error);\n\t\tthrow new Error('Failed to generate mnemonic');\n\t}\n}\n\n// Function to generate a new implicit account\nasync function createNewAccount() {\n\tconst mnemonic = await generateMnemonic();\n\n\t// Generate the BIP39 seed from the mnemonic\n\tconst seed = await bip39.mnemonicToSeed(mnemonic);\n\n\t// Convert the seed (Buffer) to a UInt8Array\n\tconst seedUInt8Array = new Uint8Array(seed);\n\n\t// Generate the secret key\n\tconst secretKey = generateSecretKey(seedUInt8Array, \"m/44'/1729'/0'/0'\", 'ed25519');\n\n\t// Derive the public key and public key hash from the secret key\n\tconst signer = new InMemorySigner(secretKey);\n\tconst publicKey = await signer.publicKey();\n\tconst publicKeyHash = await signer.publicKeyHash();\n\n\t// Return the object with pk, pkh, sk, and balance\n\treturn {\n\t\tpk: publicKey,\n\t\tpkh: publicKeyHash,\n\t\tsk: `unencrypted:${secretKey}`,\n\t};\n}\n\nfunction createFunderAccount() {\n\treturn createNewAccount().then(account => ({\n\t\tpublicKeyHash: account.pkh,\n\t\tsecretKey: account.sk,\n\t}));\n}\n\nasync function getPublicKeyFromSecretKey(secretKey: string) {\n\t// Initialize the signer with the secret key\n\tconst signer = await InMemorySigner.fromSecretKey(secretKey.replace('unencrypted:', ''));\n\n\t// Get the public key\n\tconst publicKey = await signer.publicKey();\n\n\treturn publicKey;\n}\n\n/**\n * Prepares TezBox accounts configuration.\n */\n/**\n * Prepares TezBox accounts configuration.\n */\nasync function prepareTezBoxAccounts(\n\tinstantiatedAccounts: Record<string, InstantiatedAccount>,\n\tdeclaredAccounts: Record<string, Mutez>,\n): Promise<Record<string, TezboxAccount>> {\n\t// Add funder account to instantiatedAccounts\n\t// instantiatedAccounts['funder'] = await createFunderAccount();\n\n\tconst tezboxAccounts: Record<string, TezboxAccount> = {};\n\n\tfor (const [accountName, accountData] of Object.entries(instantiatedAccounts)) {\n\t\tif (accountName === 'default') continue;\n\n\t\tconst secretKey = accountData.secretKey;\n\t\ttezboxAccounts[accountName] = {\n\t\t\tpkh: accountData.publicKeyHash,\n\t\t\tpk: await getPublicKeyFromSecretKey(secretKey),\n\t\t\tsk: secretKey,\n\t\t\tbalance: accountName === 'funder'\n\t\t\t\t? new BigNumber(100000000000000).toString()\n\t\t\t\t: new BigNumber(declaredAccounts[accountName].toString()).toString(),\n\t\t};\n\t}\n\n\treturn tezboxAccounts;\n}\n\n/**\n * Writes accounts.hjson file.\n */\nasync function writeAccountsHjson(\n\ttezboxAccounts: Record<string, TezboxAccount>,\n\ttezBoxConfigDir: string,\n): Promise<void> {\n\t// TODO: Remove for debugging\n\tawait Promise.resolve();\n\n\t// // Rearrange accounts record so that funder is first\n\t// const funderAccount = tezboxAccounts['funder'];\n\t// delete tezboxAccounts['funder'];\n\t// tezboxAccounts = { funder: funderAccount, ...tezboxAccounts };\n\n\t// Convert the accounts object to HJSON format\n\tconst hjsonContent = hjson.stringify(tezboxAccounts, {\n\t\tquotes: 'min',\n\t\tbracesSameLine: true,\n\t\tseparator: false,\n\t});\n\n\t// Remove quotes around sk values and ensure proper indentation\n\tconst fixedHjsonContent = hjsonContent.replaceAll('\"', '');\n\n\t// Write the accounts.hjson file\n\tconst accountsHjsonPath = path.join(tezBoxConfigDir, 'accounts.hjson');\n\tawait fs.promises.writeFile(accountsHjsonPath, fixedHjsonContent, 'utf8');\n}\n\n/**\n * Gets the declared accounts from the task arguments and removes underscores from Mutez values.\n */\nfunction getDeclaredAccounts(taskArgs: Opts): Record<string, Mutez> {\n\tconst declaredAccounts = taskArgs.config.accounts as Record<string, Mutez>;\n\treturn Object.entries(declaredAccounts).reduce((acc, [key, value]) => {\n\t\tacc[key] = value.toString().replace(/_/g, '');\n\t\treturn acc;\n\t}, {} as Record<string, Mutez>);\n}\n\n/**\n * Prepares accounts.hjson for TezBox.\n */\nasync function prepareAccountsHjson(taskArgs: Opts, tezBoxConfigDir: string): Promise<void> {\n\ttry {\n\t\t// Get or create instantiated accounts\n\t\tconst instantiatedAccounts = await getOrCreateInstantiatedAccounts(taskArgs);\n\n\t\t// Retrieve declared accounts\n\t\tconst declaredAccounts = getDeclaredAccounts(taskArgs);\n\n\t\t// Prepare tezbox accounts\n\t\tconst tezboxAccounts = await prepareTezBoxAccounts(instantiatedAccounts, declaredAccounts);\n\n\t\t// Write the accounts.hjson file\n\t\tawait writeAccountsHjson(tezboxAccounts, tezBoxConfigDir);\n\t} catch (error) {\n\t\tthrow new Error(getErrorMessage(`Failed to prepare accounts`, error));\n\t}\n}\n\n/**\n * Prepares bakers.hjson for TezBox.\n */\nasync function prepareBakersHjson(taskArgs: Opts, tezBoxConfigDir: string): Promise<void> {\n\ttry {\n\t\t// Get declared accounts\n\t\tconst declaredAccounts = getDeclaredAccounts(taskArgs);\n\n\t\t// Calculate total balance\n\t\tconst totalBalance = Object.values(declaredAccounts).reduce(\n\t\t\t(sum, balance) => BigNumber.sum(sum, balance),\n\t\t\tnew BigNumber(0),\n\t\t).toString();\n\n\t\t// Prepare bakers object\n\t\tconst bakers = {\n\t\t\tbaker1: {\n\t\t\t\tpkh: 'tz1faswCTDciRzE4oJ9jn2Vm2dvjeyA9fUzU',\n\t\t\t\tpk: 'edpkuTXkJDGcFd5nh6VvMz8phXxU3Bi7h6hqgywNFi1vZTfQNnS1RV',\n\t\t\t\tsk: 'unencrypted:edsk4ArLQgBTLWG5FJmnGnT689VKoqhXwmDPBuGx3z4cvwU9MmrPZZ',\n\t\t\t\tbalance: totalBalance,\n\t\t\t},\n\t\t\tbaker2: {\n\t\t\t\tpkh: 'tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN',\n\t\t\t\tpk: 'edpktzNbDAUjUk697W7gYg2CRuBQjyPxbEg8dLccYYwKSKvkPvjtV9',\n\t\t\t\tsk: 'unencrypted:edsk39qAm1fiMjgmPkw1EgQYkMzkJezLNewd7PLNHTkr6w9XA2zdfo',\n\t\t\t\tbalance: totalBalance,\n\t\t\t},\n\t\t\tbaker3: {\n\t\t\t\tpkh: 'tz1b7tUupMgCNw2cCLpKTkSD1NZzB5TkP2sv',\n\t\t\t\tpk: 'edpkuFrRoDSEbJYgxRtLx2ps82UdaYc1WwfS9sE11yhauZt5DgCHbU',\n\t\t\t\tsk: 'unencrypted:edsk2uqQB9AY4FvioK2YMdfmyMrer5R8mGFyuaLLFfSRo8EoyNdht3',\n\t\t\t\tbalance: totalBalance,\n\t\t\t},\n\t\t};\n\n\t\t// Convert the bakers object to HJSON format\n\t\tconst hjsonContent = hjson.stringify(bakers, {\n\t\t\tquotes: 'min',\n\t\t\tbracesSameLine: true,\n\t\t\tseparator: false,\n\t\t});\n\n\t\t// Remove quotes around sk values and ensure proper indentation\n\t\tconst fixedHjsonContent = hjsonContent.replaceAll('\"', '');\n\n\t\t// Write the bakers.hjson file\n\t\tconst bakersHjsonPath = path.join(tezBoxConfigDir, 'bakers.hjson');\n\t\tawait fs.promises.writeFile(bakersHjsonPath, fixedHjsonContent, 'utf8');\n\t} catch (error) {\n\t\tthrow new Error(getErrorMessage(`Failed to prepare bakers`, error));\n\t}\n}\n\n/**\n * Generates a project ID based on the project directory.\n */\nfunction getProjectId(taskArgs: Opts): string {\n\treturn createHash('sha256').update(taskArgs.projectDir).digest('hex');\n}\n\n/**\n * Gets the docker container name for the sandbox.\n */\nfunction getDockerContainerName(taskArgs: Opts): string {\n\tconst projectId = getProjectId(taskArgs);\n\treturn `taq-${taskArgs.env}-${projectId}`;\n}\n\n/**\n * Gets the TezBox configuration directory.\n */\nfunction getTezBoxConfigDir(taskArgs: Opts): string {\n\tconst containerName = getDockerContainerName(taskArgs);\n\treturn path.join(taskArgs.projectDir, `.taq/.${containerName}/config`);\n}\n\n/**\n * Gets the TezBox data directory.\n */\nfunction getTezBoxDataDir(taskArgs: Opts): string {\n\tconst containerName = getDockerContainerName(taskArgs);\n\treturn path.join(taskArgs.projectDir, `.taq/.${containerName}/data`);\n}\n\n/**\n * Gets the docker image for TezBox.\n */\nfunction getImage(taskArgs: Opts): string {\n\treturn getDockerImage(getDefaultDockerImage(taskArgs), 'TAQ_TEZBOX_IMAGE');\n}\n\n/**\n * Checks if the sandbox is running.\n */\nasync function isSandboxRunning(taskArgs: Opts): Promise<boolean> {\n\tconst containerName = getDockerContainerName(taskArgs);\n\tconst cmd = `docker ps --filter \"name=${containerName}\" --format \"{{.ID}}\"`;\n\tconst { stdout } = await runCommand(cmd);\n\treturn stdout.trim() !== '';\n}\n\n/**\n * Checks if the sandbox is already running.\n */\nasync function checkSandboxRunning(taskArgs: Opts): Promise<boolean> {\n\tconst running = await isSandboxRunning(taskArgs);\n\tif (running) {\n\t\tawait sendAsyncRes('Sandbox is already running.');\n\t}\n\treturn running;\n}\n\nfunction getPortNumber(taskArgs: Opts) {\n\tconst rpcUrl = getSandboxConfig(taskArgs).rpcUrl;\n\tconst match = rpcUrl.match(/:(\\d+)/);\n\treturn match ? parseInt(match[1], 10) : 80;\n}\n\nfunction getContainerPort(taskArgs: Opts) {\n\treturn getPortNumber(taskArgs) + 1;\n}\n\n/**\n * Gets the docker run parameters.\n */\nasync function getDockerRunParams(taskArgs: Opts): Promise<DockerRunParams> {\n\tconst image = getImage(taskArgs);\n\tconst containerName = getDockerContainerName(taskArgs);\n\tconst platform = await getArch();\n\tconst configDir = getTezBoxConfigDir(taskArgs);\n\tconst dataDir = getTezBoxDataDir(taskArgs);\n\tconst port = getContainerPort(taskArgs);\n\n\treturn { platform, image, containerName, configDir, dataDir, port };\n}\n\n/**\n * Ensures directories exist.\n */\nasync function ensureDirectoriesExist(directories: string[]): Promise<void> {\n\tawait Promise.all(\n\t\tdirectories.map(dir => fs.promises.mkdir(dir, { recursive: true })),\n\t);\n}\n\n/**\n * Constructs the docker run command.\n */\nfunction constructDockerRunCommand(params: DockerRunParams): string {\n\tconst { platform, image, containerName, configDir, port } = params;\n\n\tconst dockerOptions = [\n\t\t'docker run',\n\t\t'-d',\n\t\t`--platform ${platform}`,\n\t\t'-p 8732:8732',\n\t\t`-p ${port}:20000`,\n\t\t`--name ${containerName}`,\n\t\t`-v \"${configDir}:/tezbox/overrides\"`,\n\t\timage,\n\t\t'riobox',\n\t];\n\n\treturn dockerOptions.join(' ');\n}\n\n/**\n * Validates the block time in the sandbox configuration.\n */\nfunction validateBlockTime(taskArgs: Opts): number | null {\n\tconst sandboxConfig = getSandboxConfig(taskArgs);\n\tconst blockTime = sandboxConfig.blockTime;\n\tif (blockTime === undefined || blockTime === null) {\n\t\tlogger.warn('Block time is not specified; skipping block_time override.');\n\t\treturn null;\n\t}\n\treturn blockTime;\n}\n\n/**\n * Writes sandbox parameters for a single protocol.\n */\nasync function writeSandboxParameters(\n\tprotocolId: string,\n\tparameters: Record<string, string | number>,\n\ttezBoxConfigDir: string,\n): Promise<void> {\n\tconst protocolsDir = path.join(tezBoxConfigDir, 'protocols', protocolId);\n\tawait fs.promises.mkdir(protocolsDir, { recursive: true });\n\n\tconst hjsonContent = hjson.stringify(parameters, {\n\t\tquotes: 'min',\n\t\tbracesSameLine: true,\n\t\tseparator: false,\n\t});\n\n\tconst sandboxParamsPath = path.join(protocolsDir, 'sandbox-parameters.hjson');\n\tawait fs.promises.writeFile(sandboxParamsPath, hjsonContent, 'utf8');\n\n\t// Ensure the file has write permissions\n\ttry {\n\t\tawait fs.promises.chmod(sandboxParamsPath, 0o644);\n\t} catch (error) {\n\t\tlogger.warn(getErrorMessage(`Failed to set file permissions for ${sandboxParamsPath}`, error));\n\t}\n}\n\n/**\n * Applies block time override to a single protocol.\n */\nasync function applyBlockTimeOverrideToProtocol(\n\tprotocolId: string,\n\tblockTime: number,\n\ttezBoxConfigDir: string,\n): Promise<void> {\n\tconst nonce_revelation_threshold = 16;\n\tconst minimal_block_delay = blockTime;\n\n\tconst parameters = {\n\t\tminimal_block_delay: minimal_block_delay.toString(),\n\t};\n\tawait writeSandboxParameters(protocolId, parameters, tezBoxConfigDir);\n}\n\n/**\n * Applies block time override to multiple protocols.\n */\nasync function applyBlockTimeOverrideToProtocols(\n\tprotocolIds: string[],\n\tblockTime: number,\n\ttezBoxConfigDir: string,\n): Promise<void> {\n\tawait Promise.all(\n\t\tprotocolIds.map(async protocolId => {\n\t\t\t// Skip alpha protocol as it's a placeholder\n\t\t\tif (/^alpha$/i.test(protocolId)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait applyBlockTimeOverrideToProtocol(protocolId, blockTime, tezBoxConfigDir);\n\t\t}),\n\t);\n}\n\n/**\n * Gets protocol identifiers from TezBox configuration.\n */\nasync function getProtocolIds(taskArgs: Opts): Promise<string[]> {\n\tconst image = getImage(taskArgs);\n\n\t// List the protocol directories inside the TezBox image\n\tconst cmd = `docker run --rm --entrypoint ls ${image} /tezbox/configuration/protocols`;\n\tconst { stdout } = await runCommand(cmd);\n\n\tconst protocolIds = stdout\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.map(line => line.trim())\n\t\t.filter(line => line !== '');\n\n\treturn protocolIds;\n}\n\n/**\n * Reads and parses protocol.hjson for a given protocolId.\n */\nasync function readProtocolJson(image: string, protocolId: string): Promise<ProtocolMapping | null> {\n\tconst cmd = `docker run --rm --entrypoint cat ${image} /tezbox/configuration/protocols/${protocolId}/protocol.hjson`;\n\n\ttry {\n\t\tconst { stdout } = await runCommand(cmd);\n\n\t\tif (!stdout.trim()) {\n\t\t\tlogger.warn(`protocol.hjson not found or empty for protocolId ${protocolId}; skipping this protocol.`);\n\t\t\treturn null;\n\t\t}\n\n\t\t// Parse the HJSON content\n\t\tconst protocolData = hjson.parse(stdout);\n\t\tconst protocolHash: string = protocolData.hash;\n\t\tif (protocolHash) {\n\t\t\treturn { id: protocolId, hash: protocolHash };\n\t\t} else {\n\t\t\tlogger.warn(`Protocol hash not found in protocol.hjson for protocolId ${protocolId}; skipping.`);\n\t\t\treturn null;\n\t\t}\n\t} catch (error) {\n\t\tlogger.warn(getErrorMessage(`Failed to read protocol.hjson for protocolId ${protocolId}`, error));\n\t\treturn null;\n\t}\n}\n\n/**\n * Gets protocol mappings.\n */\nasync function getProtocolMappings(taskArgs: Opts): Promise<ProtocolMapping[]> {\n\tconst image = getImage(taskArgs);\n\tconst protocolIds = await getProtocolIds(taskArgs);\n\n\tconst protocolMappingsPromises = protocolIds.map(async protocolId => {\n\t\tconst mapping = await readProtocolJson(image, protocolId);\n\t\treturn mapping;\n\t});\n\n\tconst protocolMappings = await Promise.all(protocolMappingsPromises);\n\treturn protocolMappings.filter((mapping): mapping is ProtocolMapping => mapping !== null);\n}\n\n/**\n * Gets protocol hashes from octez-client.\n */\nasync function getOctezClientProtocols(taskArgs: Opts): Promise<string[]> {\n\tconst image = getImage(taskArgs);\n\tconst cmd = `docker run --rm --entrypoint octez-client ${image} list mockup protocols`;\n\tconst { stdout } = await runCommand(cmd, stderr => {\n\t\tconst ignorableError = [\n\t\t\t'Base directory /tezbox/data/.tezos-client does not exist.',\n\t\t\t'Unable to connect to the node: \"Unix.Unix_error(Unix.ECONNREFUSED, \"connect\", \"\")\"',\n\t\t];\n\n\t\tif (stderr.trim() !== '' && !ignorableError.some(err => stderr.includes(err))) {\n\t\t\tthrow new Error(`Failed to list protocols: ${stderr.trim()}`);\n\t\t}\n\t});\n\n\tconst protocols = stdout\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.filter(line => line.trim() !== '');\n\n\treturn protocols;\n}\n\n/**\n * Prepares sandbox-parameters.hjson for block_time override.\n */\nasync function prepareSandboxParametersHjson(taskArgs: Opts, tezBoxConfigDir: string): Promise<void> {\n\ttry {\n\t\t// Validate block time\n\t\tconst blockTime = validateBlockTime(taskArgs);\n\t\tif (blockTime === null) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Get the protocol mappings from TezBox\n\t\tconst protocolMappings = await getProtocolMappings(taskArgs);\n\t\tconst hashToIdMap: Record<string, string> = {};\n\t\tfor (const mapping of protocolMappings) {\n\t\t\thashToIdMap[mapping.hash] = mapping.id;\n\t\t}\n\n\t\t// Get the list of protocol hashes supported by octez-client\n\t\tconst protocolHashes = await getOctezClientProtocols(taskArgs);\n\n\t\t// Map protocol hashes to TezBox protocol IDs\n\t\tconst protocolIdsToOverride = protocolHashes\n\t\t\t.map(hash => hashToIdMap[hash])\n\t\t\t.filter((id): id is string => id !== undefined);\n\n\t\tif (protocolIdsToOverride.length === 0) {\n\t\t\tlogger.warn('No matching protocol IDs found; cannot set block_time override.');\n\t\t\treturn;\n\t\t}\n\n\t\t// Debug: Log the protocol IDs to override\n\t\t// logger.info(`Protocol IDs to override: ${protocolIdsToOverride.join(', ')}`);\n\n\t\t// Apply block time override to each protocol ID\n\t\tawait applyBlockTimeOverrideToProtocols(protocolIdsToOverride, blockTime, tezBoxConfigDir);\n\t} catch (error) {\n\t\tconst errorMessage = getErrorMessage(`Failed to prepare sandbox parameters:`, error);\n\t\tthrow new Error(errorMessage);\n\t}\n}\n\n/**\n * Prepares baker.hjson if baking is disabled.\n */\nasync function prepareBakerHjson(tezBoxConfigDir: string): Promise<void> {\n\tconst servicesDir = path.join(tezBoxConfigDir, 'services');\n\ttry {\n\t\tawait fs.promises.mkdir(servicesDir, { recursive: true });\n\n\t\tconst bakerConfig = {\n\t\t\tautostart: false,\n\t\t};\n\n\t\tconst hjsonContent = hjson.stringify(bakerConfig, {\n\t\t\tquotes: 'all',\n\t\t\tbracesSameLine: true,\n\t\t\tseparator: true,\n\t\t});\n\n\t\tconst bakerConfigPath = path.join(servicesDir, 'baker.hjson');\n\t\tawait fs.promises.writeFile(bakerConfigPath, hjsonContent, 'utf8');\n\t} catch (error) {\n\t\tthrow new Error(getErrorMessage(`Failed to prepare baker.hjson`, error));\n\t}\n}\n\n/**\n * Prepares TezBox configuration overrides.\n */\nasync function prepareTezBoxOverrides(taskArgs: Opts): Promise<void> {\n\tconst tezBoxConfigDir = getTezBoxConfigDir(taskArgs);\n\n\ttry {\n\t\t// Get sandbox configuration\n\t\tconst sandboxConfig = getSandboxConfig(taskArgs);\n\n\t\t// Ensure the configuration directory exists\n\t\tawait fs.promises.mkdir(tezBoxConfigDir, { recursive: true });\n\n\t\t// Prepare tasks\n\t\tconst tasks: Promise<void>[] = [];\n\n\t\t// Prepare bakers.hjson\n\t\ttasks.push(prepareBakersHjson(taskArgs, tezBoxConfigDir));\n\n\t\t// Prepare accounts.hjson\n\t\tif (taskArgs.config.accounts) {\n\t\t\ttasks.push(prepareAccountsHjson(taskArgs, tezBoxConfigDir));\n\t\t}\n\n\t\t// Prepare sandbox-parameters.hjson for block_time\n\t\tif (sandboxConfig.blockTime) {\n\t\t\ttasks.push(prepareSandboxParametersHjson(taskArgs, tezBoxConfigDir));\n\t\t}\n\n\t\t// Prepare baker.hjson if baking is disabled\n\t\tif (sandboxConfig.baking === BakingOption.DISABLED) {\n\t\t\ttasks.push(prepareBakerHjson(tezBoxConfigDir));\n\t\t}\n\n\t\t// Run all preparations in parallel\n\t\tawait Promise.all(tasks);\n\t} catch (error) {\n\t\tthrow new Error(getErrorMessage(`Failed to prepare TezBox overrides`, error));\n\t}\n}\n\nfunction getProxyContainerName(taskArgs: Opts) {\n\treturn `${getDockerContainerName(taskArgs)}-proxy`;\n}\n\nasync function startProxyServer(taskArgs: Opts): Promise<void> {\n\tconst containerPort = getContainerPort(taskArgs);\n\tconst proxyPort = getPortNumber(taskArgs);\n\tconst proxyContainerName = getProxyContainerName(taskArgs);\n\n\tconst proxyCmd = `docker run -d --name ${proxyContainerName} \\\n --network host \\\n caddy:2-alpine \\\n caddy reverse-proxy \\\n --from http://:${proxyPort} \\\n --to http://127.0.0.1:${containerPort} \\\n --access-log`;\n\n\ttry {\n\t\tawait runCommand(proxyCmd);\n\t} catch (error) {\n\t\tthrow new Error(getErrorMessage(`Failed to start Caddy reverse proxy`, error));\n\t}\n}\n\nasync function stopProxyServer(taskArgs: Opts): Promise<void> {\n\tconst proxyContainerName = getProxyContainerName(taskArgs);\n\tconst cmd = `docker rm -f ${proxyContainerName}`;\n\tawait runCommand(cmd);\n}\n\n/**\n * Starts the sandbox.\n */\nasync function startSandbox(taskArgs: Opts): Promise<void> {\n\ttry {\n\t\t// Check for Docker availability\n\t\tawait checkDockerAvailability();\n\n\t\t// Check if the sandbox is already running\n\t\tif (await checkSandboxRunning(taskArgs)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Get Docker run parameters\n\t\tconst params = await getDockerRunParams(taskArgs);\n\n\t\t// Ensure necessary directories exist\n\t\tawait ensureDirectoriesExist([params.dataDir, params.configDir]);\n\n\t\t// Prepare TezBox configuration overrides\n\t\tawait prepareTezBoxOverrides(taskArgs);\n\n\t\t// Construct the Docker run command\n\t\tconst cmd = constructDockerRunCommand(params);\n\t\t// logger.info(`Starting sandbox with command: ${cmd}`);\n\n\t\t// Execute the Docker run command\n\t\tawait runCommand(cmd);\n\n\t\t// Start the proxy server\n\t\tawait startProxyServer(taskArgs);\n\n\t\t// Send a success response\n\t\tawait sendAsyncRes('Sandbox started successfully.');\n\t} catch (error) {\n\t\tawait sendAsyncErr(getErrorMessage(`Failed to start sandbox`, error));\n\t}\n}\n\n/**\n * Checks for Docker availability.\n */\nasync function checkDockerAvailability(): Promise<void> {\n\ttry {\n\t\tawait runCommand('docker --version');\n\t} catch (error) {\n\t\tthrow new Error('Docker is not installed or not running. Please install and start Docker.');\n\t}\n}\n\n/**\n * Removes the sandbox container.\n */\nasync function removeSandboxContainer(taskArgs: Opts): Promise<void> {\n\tconst containerName = getDockerContainerName(taskArgs);\n\tconst cmd = `docker rm -f ${containerName}`;\n\n\ttry {\n\t\tawait runCommand(cmd);\n\t} catch (error) {\n\t\tconst errorMessage = getErrorMessage('', error);\n\t\tif (errorMessage.includes('No such container')) {\n\t\t\t// Container does not exist\n\t\t\tawait sendAsyncRes('Sandbox is not running or already stopped.');\n\t\t} else {\n\t\t\tthrow new Error(errorMessage);\n\t\t}\n\t}\n\n\t// Stop the proxy server\n\tawait stopProxyServer(taskArgs);\n}\n\n/**\n * Stops the sandbox.\n */\nasync function stopSandbox(taskArgs: Opts): Promise<void> {\n\ttry {\n\t\t// Attempt to stop and remove the sandbox container\n\t\tawait removeSandboxContainer(taskArgs);\n\n\t\t// Optionally, clean up configuration directory if needed\n\t\tconst configDir = getTezBoxConfigDir(taskArgs);\n\t\tawait fs.promises.rm(configDir, { recursive: true, force: true });\n\n\t\t// Send a success response\n\t\tawait sendAsyncRes('Sandbox stopped and cleaned up.');\n\t} catch (error) {\n\t\tawait sendAsyncErr(getErrorMessage(`Failed to stop sandbox`, error));\n\t}\n}\n\n/**\n * Restarts the sandbox.\n */\nasync function restartSandbox(taskArgs: Opts): Promise<void> {\n\ttry {\n\t\t// Stop the sandbox if it's running\n\t\tawait removeSandboxContainer(taskArgs);\n\n\t\t// Start the sandbox\n\t\tawait startSandbox(taskArgs);\n\n\t\t// Send a success response\n\t\tawait sendAsyncRes('Sandbox restarted successfully.');\n\t} catch (error) {\n\t\tawait sendAsyncErr(getErrorMessage(`Failed to restart sandbox`, error));\n\t}\n}\n\n/**\n * Lists protocols.\n */\nasync function listProtocols(taskArgs: Opts): Promise<void> {\n\ttry {\n\t\tconst protocolHashes = await getOctezClientProtocols(taskArgs);\n\t\tconst protocolObjects = protocolHashes.map(protocol => ({ protocol }));\n\t\tawait sendAsyncJsonRes(protocolObjects);\n\t} catch (error) {\n\t\tawait sendAsyncErr(getErrorMessage(`Failed to list protocols`, error));\n\t}\n}\n\n/**\n * Lists accounts.\n */\nasync function listAccounts(taskArgs: Opts): Promise<void> {\n\ttry {\n\t\tif (await isSandboxRunning(taskArgs)) {\n\t\t\t// List accounts from the sandbox\n\t\t\tconst containerName = getDockerContainerName(taskArgs);\n\t\t\tconst cmd = `docker exec ${containerName} octez-client list known addresses`;\n\t\t\tconst { stdout } = await runCommand(cmd);\n\n\t\t\tif (!stdout.trim()) {\n\t\t\t\tawait sendAsyncRes('No accounts found.');\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst accounts = stdout\n\t\t\t\t.trim()\n\t\t\t\t.split('\\n')\n\t\t\t\t.filter(line => line.trim() !== '')\n\t\t\t\t.map(line => {\n\t\t\t\t\tconst [name, rest] = line.split(':');\n\t\t\t\t\tconst address = rest ? rest.trim().split(' ')[0] : '';\n\t\t\t\t\treturn { name: name.trim(), address };\n\t\t\t\t});\n\n\t\t\tawait sendAsyncJsonRes(accounts);\n\t\t} else {\n\t\t\tawait sendAsyncErr(`Sandbox is not running. Please start the sandbox before attempting to list accounts.`);\n\t\t}\n\t} catch (error) {\n\t\tawait sendAsyncErr(getErrorMessage(`Failed to list accounts`, error));\n\t}\n}\n\n/**\n * Bakes a block in the sandbox.\n */\nasync function bakeBlock(taskArgs: Opts): Promise<void> {\n\ttry {\n\t\tif (await isSandboxRunning(taskArgs)) {\n\t\t\tconst containerName = getDockerContainerName(taskArgs);\n\t\t\tconst cmd = `docker exec ${containerName} octez-client bake for baker1`;\n\n\t\t\tif (taskArgs.watch) {\n\t\t\t\tconsole.log('Baking on demand as operations are injected.');\n\t\t\t\tconsole.log('Press CTRL-C to stop and exit.');\n\t\t\t\tconsole.log();\n\n\t\t\t\twhile (true) {\n\t\t\t\t\tconsole.log('Waiting for operations to be injected...');\n\t\t\t\t\twhile (true) {\n\t\t\t\t\t\tconst { stdout } = await runCommand(\n\t\t\t\t\t\t\t`docker exec ${containerName} octez-client rpc get /chains/main/mempool/pending_operations`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst ops = JSON.parse(stdout);\n\t\t\t\t\t\tif (Array.isArray(ops.applied) && ops.applied.length > 0) break;\n\t\t\t\t\t\tawait new Promise(resolve => setTimeout(resolve, 1000)); // Wait for 1 second before checking again\n\t\t\t\t\t}\n\n\t\t\t\t\tawait runCommand(cmd);\n\t\t\t\t\tconsole.log('Block baked.');\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tawait runCommand(cmd);\n\t\t\t\tawait sendAsyncRes('Block baked successfully.');\n\t\t\t}\n\t\t} else {\n\t\t\ttry {\n\t\t\t\tawait sendAsyncErr('Sandbox is not running. Please start the sandbox before attempting to bake a block.');\n\t\t\t} catch {\n\t\t\t\t// Nothing to see here.\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\tawait sendAsyncErr(getErrorMessage(`Failed to bake block`, error));\n\t}\n}\n\n/**\n * Main proxy function to handle tasks.\n */\nexport const proxy = async (taskArgs: Opts): Promise<void> => {\n\tif (!isTezBoxEnvironment(taskArgs)) {\n\t\tawait sendAsyncErr(\n\t\t\t`This configuration doesn't appear to be configured to use TezBox environments. Check the ${taskArgs.env} environment in your .taq/config.json.`,\n\t\t);\n\t\treturn;\n\t}\n\n\tconst taskName = taskArgs.task?.toLowerCase().trim();\n\n\tconst taskHandlers: Record<string, (args: Opts) => Promise<void>> = {\n\t\t'start sandbox': startSandbox,\n\t\t'stop sandbox': stopSandbox,\n\t\t'restart sandbox': restartSandbox,\n\t\t'list protocols': listProtocols,\n\t\t'list-protocols': listProtocols,\n\t\t'show protocols': listProtocols,\n\t\t'show-protocols': listProtocols,\n\t\t'list accounts': listAccounts,\n\t\t'list-accounts': listAccounts,\n\t\t'show accounts': listAccounts,\n\t\t'show-accounts': listAccounts,\n\t\t'bake': bakeBlock,\n\t\t'bake block': bakeBlock,\n\t};\n\n\tconst handler = taskName ? taskHandlers[taskName] : undefined;\n\n\tif (handler) {\n\t\ttry {\n\t\t\tawait handler(taskArgs);\n\t\t} catch (error) {\n\t\t\tawait sendAsyncErr(getErrorMessage(`Error executing task '${taskArgs.task}'`, error));\n\t\t}\n\t} else {\n\t\tawait sendAsyncErr(taskArgs.task ? `Unknown task: ${taskArgs.task}` : 'No task provided');\n\t}\n};\n\nexport default proxy;\n","import { getDockerImage } from '@taqueria/node-sdk';\nimport { Opts } from './types';\n\nexport const TAQ_TEZBOX_IMAGE_ENV_VAR = 'TAQ_TEZBOX_IMAGE';\n\nexport const getDefaultDockerImage = (opts: Opts) => `ghcr.io/tez-capital/tezbox:tezos-v22.0`;\n\nexport const getImage = (opts: Opts) => getDockerImage(getDefaultDockerImage(opts), TAQ_TEZBOX_IMAGE_ENV_VAR);\n"],"mappings":";AAAA,SAAS,QAAQ,QAAuB,YAAY;;;ACApD;AAAA,EACC;AAAA,EACA;AAAA,EACA,kBAAAA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,mBAAmB,sBAAsB;AAClD,OAAO,eAAe;AACtB,YAAY,WAAW;AACvB,SAAS,kBAAkB;AAE3B,YAAY,QAAQ;AACpB,YAAY,WAAW;AACvB,YAAY,UAAU;;;ACjBtB,SAAS,sBAAsB;AAKxB,IAAM,wBAAwB,CAAC,SAAe;;;ADyDrD,IAAM,SAAS;AAAA,EACd,MAAM,CAAC,YAAoB,QAAQ,IAAI,OAAO;AAAA,EAC9C,MAAM,CAAC,YAAoB,QAAQ,KAAK,OAAO;AAAA,EAC/C,OAAO,CAAC,YAAoB,QAAQ,MAAM,OAAO;AAClD;AAOA,SAAS,gBAAgB,QAAgB,OAAwB;AAChE,MAAI,WAAW,IAAI;AAClB,WAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,EAC7D;AACA,MAAI,OAAO,UAAU,WAAW;AAC/B,WAAO,GAAG,MAAM;AAAA,EACjB;AACA,QAAM,cAAc,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AACzE,SAAO,GAAG,MAAM,KAAK,WAAW;AACjC;AAgEA,eAAe,WACd,KAC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AC,gBAAgB;AAAA,MAC1B,aAAa;AAAA,MACb,SAAS,CAAC;AAAA,MACV,SAAS;AAAA,IACV,CAAC;AAAA,IACD,KAAK,OAAO;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,SAAS,CAAC;AAAA,MACV,aAAa;AAAA,MACb,SAAS,CAAC;AAAA,MACV,SAAS;AAAA,MACT,UAAU;AAAA,IACX,CAAC;AAAA,IACD,KAAK,OAAO;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,SAAS,CAAC,GAAG;AAAA,MACb,aAAa;AAAA,MACb,SAAS;AAAA,QACR,OAAO,OAAO;AAAA,UACb,MAAM;AAAA,UACN,WAAW;AAAA,UACX,aACC;AAAA,UACD,SAAS;AAAA,QACV,CAAC;AAAA,MACF;AAAA,MACA,SAAS;AAAA,MACT,UAAU;AAAA,IACX,CAAC;AAAA,IACD,KAAK,OAAO;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,SAAS,CAAC,gBAAgB;AAAA,MAC1B,aAAa;AAAA,MACb,SAAS,CAAC;AAAA,MACV,SAAS;AAAA,MACT,UAAU;AAAA,IACX,CAAC;AAAA,EACF;AAAA,EACA,OAAO;AACR,IAAI,QAAQ,IAAI;","names":["getDockerImage","generateMnemonic","getDockerImage"]}
|
|
1
|
+
{"version":3,"sources":["index.ts","proxy.ts","docker.ts"],"sourcesContent":["import { Option, Plugin, PositionalArg, Task } from '@taqueria/node-sdk';\nimport proxy from './proxy';\n\nPlugin.create(_i18n => ({\n\talias: 'tezbox',\n\tschema: '1.0',\n\tversion: '0.1',\n\ttasks: [\n\t\tTask.create({\n\t\t\ttask: 'start sandbox',\n\t\t\tcommand: 'start sandbox',\n\t\t\taliases: ['start tezbox'],\n\t\t\tdescription: 'Starts a TezBox sandbox',\n\t\t\toptions: [],\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'none',\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'stop sandbox',\n\t\t\tcommand: 'stop sandbox',\n\t\t\taliases: ['stop tezbox'],\n\t\t\tdescription: 'Stops a TezBox sandbox',\n\t\t\toptions: [],\n\t\t\thandler: 'proxy',\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'restart sandbox',\n\t\t\tcommand: 'restart sandbox',\n\t\t\taliases: ['restart tezbox'],\n\t\t\tdescription: 'Restarts a TezBox sandbox',\n\t\t\toptions: [],\n\t\t\thandler: 'proxy',\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'list accounts',\n\t\t\tcommand: 'list accounts',\n\t\t\taliases: [],\n\t\t\tdescription: 'List the balances of all sandbox accounts',\n\t\t\toptions: [],\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'json',\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'bake',\n\t\t\tcommand: 'bake',\n\t\t\taliases: ['b'],\n\t\t\tdescription: 'Manually bake a block. Use when the \"baking\" setting of a TezBox sandbox is set to \"disabled\".',\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'watch',\n\t\t\t\t\tshortFlag: 'w',\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'Watch for operations as they are injected into the mempool and bake them as immediate as possible.',\n\t\t\t\t\tboolean: true,\n\t\t\t\t}),\n\t\t\t],\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'none',\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'show protocols',\n\t\t\tcommand: 'show protocols',\n\t\t\taliases: ['list protocols'],\n\t\t\tdescription: 'List protocols understood by this version of TezBox',\n\t\t\toptions: [],\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'json',\n\t\t}),\n\t],\n\tproxy: proxy,\n}), process.argv);\n","import {\n\texecCmd,\n\tgetArch,\n\tgetDockerImage,\n\tSandboxAccountConfig,\n\tSandboxConfig,\n\tsendAsyncErr,\n\tsendAsyncJsonRes,\n\tsendAsyncRes,\n} from '@taqueria/node-sdk';\nimport { generateSecretKey, InMemorySigner } from '@taquito/signer';\nimport BigNumber from 'bignumber.js';\nimport * as bip39 from 'bip39';\nimport { createHash } from 'crypto';\nimport { create } from 'domain';\nimport * as fs from 'fs';\nimport * as hjson from 'hjson';\nimport * as path from 'path';\nimport { getDefaultDockerImage } from './docker';\nimport { Opts } from './types';\n\ntype ConfigV1Environment = {\n\tsandboxes?: string[];\n};\n\ntype Mutez = string | number; // Represents balance in mutez\n\ntype InstantiatedAccount = Omit<SandboxAccountConfig, 'encryptedKey'> & {\n\tencryptedKey?: string;\n};\n\ninterface TezboxAccount {\n\tpkh: string;\n\tpk: string;\n\tsk: string;\n\tbalance: string;\n}\n\ntype SandboxConfigV1 = SandboxConfig;\n\ninterface ProtocolMapping {\n\tid: string; // e.g., \"Proxford\"\n\thash: string; // e.g., \"PsDELPH1...\"\n}\n\ninterface DockerRunParams {\n\tplatform: string;\n\timage: string;\n\tcontainerName: string;\n\tconfigDir: string;\n\tdataDir: string;\n\tport: number;\n}\n\nenum BakingOption {\n\tENABLED = 'enabled',\n\tDISABLED = 'disabled',\n}\n\n/**\n * Logger utility for standardized logging.\n */\nconst logger = {\n\tinfo: (message: string) => console.log(message),\n\twarn: (message: string) => console.warn(message),\n\terror: (message: string) => console.error(message),\n};\n\n/**\n * Extracts error message from unknown error type and prepends a prefix.\n/**\n * Extracts error message from unknown error type and optionally prepends a prefix.\n */\nfunction getErrorMessage(prefix: string, error: unknown): string {\n\tif (prefix === '') {\n\t\treturn error instanceof Error ? error.message : String(error);\n\t}\n\tif (typeof error === 'boolean') {\n\t\treturn `${prefix}:`;\n\t}\n\tconst errorString = error instanceof Error ? error.message : String(error);\n\treturn `${prefix}: ${errorString}`;\n}\n\n/**\n * Creates a command runner with optional logging capability\n */\nfunction createCommandRunner(enableLogging: boolean = false) {\n\tconst logFile = path.join(process.cwd(), 'tezbox-commands.log');\n\n\tasync function logExecution(sections: Record<string, string>): Promise<void> {\n\t\tif (!enableLogging) return;\n\n\t\tconst logEntry = Object.entries(sections)\n\t\t\t.map(([header, content]) =>\n\t\t\t\t[\n\t\t\t\t\t`\\n=== ${header} ===`,\n\t\t\t\t\tcontent || '[no content]',\n\t\t\t\t].join('\\n')\n\t\t\t)\n\t\t\t.join('\\n');\n\n\t\tawait fs.promises.appendFile(logFile, logEntry + '\\n\\n');\n\t}\n\n\t/**\n\t * Executes a shell command and standardizes error handling.\n\t */\n\treturn async function runCommand(\n\t\tcmd: string,\n\t\tstderrHandler?: (stderr: string) => void | Promise<void>,\n\t): Promise<{ stdout: string }> {\n\t\tawait logExecution({ COMMAND: cmd });\n\n\t\ttry {\n\t\t\tconst { stdout, stderr } = await execCmd(cmd);\n\n\t\t\tawait logExecution({\n\t\t\t\tSTDOUT: stdout,\n\t\t\t\tSTDERR: stderr.trim(),\n\t\t\t});\n\n\t\t\tif (stderr.trim()) {\n\t\t\t\tif (stderrHandler) {\n\t\t\t\t\tawait stderrHandler(stderr.trim());\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(stderr.trim());\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn { stdout };\n\t\t} catch (error) {\n\t\t\tawait logExecution({\n\t\t\t\tERROR: error instanceof Error ? error.message : String(error),\n\t\t\t});\n\n\t\t\tthrow new Error(getErrorMessage(`Command failed`, error));\n\t\t}\n\t};\n}\n\n// Create the runCommand function with logging enabled or disabled\n// const runCommand = createCommandRunner(true); // Set to false to disable logging\n\n/**\n * Executes a shell command and standardizes error handling.\n */\nasync function runCommand(\n\tcmd: string,\n\tstderrHandler?: (stderr: string) => void | Promise<void>,\n): Promise<{ stdout: string }> {\n\ttry {\n\t\tconst { stdout, stderr } = await execCmd(cmd);\n\t\tif (stderr.trim()) {\n\t\t\tif (stderrHandler) {\n\t\t\t\tawait stderrHandler(stderr.trim());\n\t\t\t} else {\n\t\t\t\tthrow new Error(stderr.trim());\n\t\t\t}\n\t\t}\n\t\treturn { stdout };\n\t} catch (error) {\n\t\tthrow new Error(getErrorMessage(`Command failed`, error));\n\t}\n}\n\n/**\n * Checks if the given environment is configured for TezBox.\n */\nfunction isTezBoxEnvironment(taskArgs: Opts): boolean {\n\tconst environment = taskArgs.config.environment[taskArgs.env];\n\tif (!environment || typeof environment !== 'object') return false;\n\n\tconst sandboxes = (environment as ConfigV1Environment).sandboxes;\n\tif (!Array.isArray(sandboxes) || sandboxes.length === 0) return false;\n\n\t// Currently, we don't have a way to tell if a sandbox is TezBox-provided\n\treturn true;\n}\n\n/**\n * Creates a Tezos account with the specified name and balance.\n */\nasync function instantiateDeclaredAccount(\n\tdeclaredAccountName: string,\n\tbalanceInMutez: BigNumber,\n): Promise<InstantiatedAccount> {\n\t// Generate a new account using BIP39 and Tezos key derivation\n\tconst account = await createNewAccount();\n\n\t// Return the instantiated account with real credentials\n\treturn {\n\t\tencryptedKey: `unencrypted:${account.pk}`,\n\t\tpublicKeyHash: account.pkh,\n\t\tsecretKey: account.sk,\n\t};\n}\n\n/**\n * Throws warning indicating function is not implemented yet.\n */\nasync function getInstantiatedAccounts(taskArgs: Opts): Promise<Record<string, InstantiatedAccount>> {\n\tconst sandboxConfig = getSandboxConfig(taskArgs);\n\tif (!sandboxConfig.accounts) {\n\t\tthrow new Error('No instantiated accounts found in sandbox config.');\n\t}\n\tconst accounts = sandboxConfig.accounts as Record<string, InstantiatedAccount>;\n\treturn Object.entries(accounts)\n\t\t.filter(([key]) => key !== 'default')\n\t\t.reduce((acc, [key, value]) => {\n\t\t\tacc[key] = value;\n\t\t\treturn acc;\n\t\t}, {} as Record<string, InstantiatedAccount>);\n}\n\n/**\n * Gets the sandbox configuration for the given environment.\n */\nfunction getSandboxConfig(taskArgs: Opts): SandboxConfigV1 {\n\tif (!isTezBoxEnvironment(taskArgs)) {\n\t\tthrow new Error(\n\t\t\t`This configuration doesn't appear to be configured to use TezBox environments. Check the ${taskArgs.env} environment in your .taq/config.json.`,\n\t\t);\n\t}\n\n\tconst environment = taskArgs.config.environment[taskArgs.env] as ConfigV1Environment;\n\tconst sandboxName = environment.sandboxes?.[0];\n\tif (sandboxName) {\n\t\tconst sandboxConfig = taskArgs.config.sandbox?.[sandboxName];\n\t\tif (sandboxConfig) {\n\t\t\tconst retval: SandboxConfigV1 = {\n\t\t\t\tblockTime: 1,\n\t\t\t\tbaking: BakingOption.ENABLED,\n\t\t\t\t...sandboxConfig,\n\t\t\t\t...sandboxConfig.annotations,\n\t\t\t};\n\n\t\t\treturn retval;\n\t\t}\n\t}\n\tthrow new Error(`No sandbox configuration found for ${taskArgs.env} environment.`);\n}\n\n/**\n * Gets or creates instantiated accounts.\n */\nasync function getOrCreateInstantiatedAccounts(\n\ttaskArgs: Opts,\n): Promise<Record<string, InstantiatedAccount>> {\n\tlet instantiatedAccounts: Record<string, InstantiatedAccount>;\n\n\ttry {\n\t\t// Attempt to get instantiated accounts\n\t\tinstantiatedAccounts = await getInstantiatedAccounts(taskArgs);\n\t} catch (error) {\n\t\t// No instantiated accounts available, so we need to instantiate them\n\t\tinstantiatedAccounts = {};\n\t\tconst declaredAccounts = taskArgs.config.accounts as Record<string, Mutez>;\n\n\t\tfor (const [accountName, balanceInMutez] of Object.entries(declaredAccounts)) {\n\t\t\t// Convert balance to BigNumber, removing any underscores used for formatting\n\t\t\tconst balanceInMutezBN = new BigNumber(balanceInMutez.toString().replace(/_/g, ''));\n\n\t\t\t// Instantiate the declared account\n\t\t\tconst instantiatedAccount = await instantiateDeclaredAccount(accountName, balanceInMutezBN);\n\n\t\t\t// Store the instantiated account\n\t\t\tinstantiatedAccounts[accountName] = instantiatedAccount;\n\t\t}\n\n\t\t// Optionally, save the instantiated accounts to persist them for future runs\n\t\tawait saveInstantiatedAccounts(instantiatedAccounts, taskArgs.projectDir, taskArgs.env);\n\t}\n\n\treturn instantiatedAccounts;\n}\n\n/**\n * Saves instantiated accounts to the local configuration file.\n * @param accounts Record of instantiated accounts\n * @param projectDir Project directory path\n * @param env Environment name\n */\nasync function saveInstantiatedAccounts(\n\taccounts: Record<string, InstantiatedAccount>,\n\tprojectDir: string,\n\tenv: string,\n): Promise<void> {\n\tconst configPath = path.join(projectDir, `.taq/config.local.${env}.json`);\n\n\ttry {\n\t\t// Read existing config or use an empty object if file doesn't exist\n\t\tlet config: Record<string, any> = {};\n\t\ttry {\n\t\t\tconst configContent = await fs.promises.readFile(configPath, 'utf8');\n\t\t\tconfig = JSON.parse(configContent);\n\t\t} catch (error) {\n\t\t\t// If file doesn't exist or there's an error reading it, we'll use an empty object\n\t\t}\n\n\t\t// Convert InstantiatedAccount to SandboxAccountConfig, omitting encryptedKey\n\t\tconst sandboxAccounts: Record<string, Omit<SandboxAccountConfig, 'encryptedKey'>> = {};\n\t\tfor (const [name, account] of Object.entries(accounts)) {\n\t\t\tsandboxAccounts[name] = {\n\t\t\t\tpublicKeyHash: account.publicKeyHash,\n\t\t\t\tsecretKey: account.secretKey,\n\t\t\t};\n\t\t}\n\n\t\t// Update only the accounts property in the config\n\t\tconfig.accounts = sandboxAccounts;\n\n\t\t// Ensure the directory exists\n\t\tawait fs.promises.mkdir(path.dirname(configPath), { recursive: true });\n\n\t\t// Write the updated config back to the file\n\t\tawait fs.promises.writeFile(configPath, JSON.stringify(config, null, 2), 'utf8');\n\t} catch (error) {\n\t\tthrow new Error(getErrorMessage('Failed to save instantiated accounts', error));\n\t}\n}\n\n/**\n * Generates a mnemonic phrase using BIP39.\n * @param strength The entropy bit length, defaults to 128 (resulting in a 12-word mnemonic).\n * @returns A promise that resolves to the generated mnemonic phrase.\n */\nasync function generateMnemonic(strength: number = 128): Promise<string> {\n\ttry {\n\t\tconst mnemonic = bip39.generateMnemonic(strength);\n\t\treturn mnemonic;\n\t} catch (error) {\n\t\tconsole.error('Error generating mnemonic:', error);\n\t\tthrow new Error('Failed to generate mnemonic');\n\t}\n}\n\n// Function to generate a new implicit account\nasync function createNewAccount() {\n\tconst mnemonic = await generateMnemonic();\n\n\t// Generate the BIP39 seed from the mnemonic\n\tconst seed = await bip39.mnemonicToSeed(mnemonic);\n\n\t// Convert the seed (Buffer) to a UInt8Array\n\tconst seedUInt8Array = new Uint8Array(seed);\n\n\t// Generate the secret key\n\tconst secretKey = generateSecretKey(seedUInt8Array, \"m/44'/1729'/0'/0'\", 'ed25519');\n\n\t// Derive the public key and public key hash from the secret key\n\tconst signer = new InMemorySigner(secretKey);\n\tconst publicKey = await signer.publicKey();\n\tconst publicKeyHash = await signer.publicKeyHash();\n\n\t// Return the object with pk, pkh, sk, and balance\n\treturn {\n\t\tpk: publicKey,\n\t\tpkh: publicKeyHash,\n\t\tsk: `unencrypted:${secretKey}`,\n\t};\n}\n\nfunction createFunderAccount() {\n\treturn createNewAccount().then(account => ({\n\t\tpublicKeyHash: account.pkh,\n\t\tsecretKey: account.sk,\n\t}));\n}\n\nasync function getPublicKeyFromSecretKey(secretKey: string) {\n\t// Initialize the signer with the secret key\n\tconst signer = await InMemorySigner.fromSecretKey(secretKey.replace('unencrypted:', ''));\n\n\t// Get the public key\n\tconst publicKey = await signer.publicKey();\n\n\treturn publicKey;\n}\n\n/**\n * Prepares TezBox accounts configuration.\n */\n/**\n * Prepares TezBox accounts configuration.\n */\nasync function prepareTezBoxAccounts(\n\tinstantiatedAccounts: Record<string, InstantiatedAccount>,\n\tdeclaredAccounts: Record<string, Mutez>,\n): Promise<Record<string, TezboxAccount>> {\n\t// Add funder account to instantiatedAccounts\n\t// instantiatedAccounts['funder'] = await createFunderAccount();\n\n\tconst tezboxAccounts: Record<string, TezboxAccount> = {};\n\n\tfor (const [accountName, accountData] of Object.entries(instantiatedAccounts)) {\n\t\tif (accountName === 'default') continue;\n\n\t\tconst secretKey = accountData.secretKey;\n\t\ttezboxAccounts[accountName] = {\n\t\t\tpkh: accountData.publicKeyHash,\n\t\t\tpk: await getPublicKeyFromSecretKey(secretKey),\n\t\t\tsk: secretKey,\n\t\t\tbalance: accountName === 'funder'\n\t\t\t\t? new BigNumber(100000000000000).toString()\n\t\t\t\t: new BigNumber(declaredAccounts[accountName].toString()).toString(),\n\t\t};\n\t}\n\n\treturn tezboxAccounts;\n}\n\n/**\n * Writes accounts.hjson file.\n */\nasync function writeAccountsHjson(\n\ttezboxAccounts: Record<string, TezboxAccount>,\n\ttezBoxConfigDir: string,\n): Promise<void> {\n\t// TODO: Remove for debugging\n\tawait Promise.resolve();\n\n\t// // Rearrange accounts record so that funder is first\n\t// const funderAccount = tezboxAccounts['funder'];\n\t// delete tezboxAccounts['funder'];\n\t// tezboxAccounts = { funder: funderAccount, ...tezboxAccounts };\n\n\t// Convert the accounts object to HJSON format\n\tconst hjsonContent = hjson.stringify(tezboxAccounts, {\n\t\tquotes: 'min',\n\t\tbracesSameLine: true,\n\t\tseparator: false,\n\t});\n\n\t// Remove quotes around sk values and ensure proper indentation\n\tconst fixedHjsonContent = hjsonContent.replaceAll('\"', '');\n\n\t// Write the accounts.hjson file\n\tconst accountsHjsonPath = path.join(tezBoxConfigDir, 'accounts.hjson');\n\tawait fs.promises.writeFile(accountsHjsonPath, fixedHjsonContent, 'utf8');\n}\n\n/**\n * Gets the declared accounts from the task arguments and removes underscores from Mutez values.\n */\nfunction getDeclaredAccounts(taskArgs: Opts): Record<string, Mutez> {\n\tconst declaredAccounts = taskArgs.config.accounts as Record<string, Mutez>;\n\treturn Object.entries(declaredAccounts).reduce((acc, [key, value]) => {\n\t\tacc[key] = value.toString().replace(/_/g, '');\n\t\treturn acc;\n\t}, {} as Record<string, Mutez>);\n}\n\n/**\n * Prepares accounts.hjson for TezBox.\n */\nasync function prepareAccountsHjson(taskArgs: Opts, tezBoxConfigDir: string): Promise<void> {\n\ttry {\n\t\t// Get or create instantiated accounts\n\t\tconst instantiatedAccounts = await getOrCreateInstantiatedAccounts(taskArgs);\n\n\t\t// Retrieve declared accounts\n\t\tconst declaredAccounts = getDeclaredAccounts(taskArgs);\n\n\t\t// Prepare tezbox accounts\n\t\tconst tezboxAccounts = await prepareTezBoxAccounts(instantiatedAccounts, declaredAccounts);\n\n\t\t// Write the accounts.hjson file\n\t\tawait writeAccountsHjson(tezboxAccounts, tezBoxConfigDir);\n\t} catch (error) {\n\t\tthrow new Error(getErrorMessage(`Failed to prepare accounts`, error));\n\t}\n}\n\n/**\n * Prepares bakers.hjson for TezBox.\n */\nasync function prepareBakersHjson(taskArgs: Opts, tezBoxConfigDir: string): Promise<void> {\n\ttry {\n\t\t// Get declared accounts\n\t\tconst declaredAccounts = getDeclaredAccounts(taskArgs);\n\n\t\t// Calculate total balance\n\t\tconst totalBalance = Object.values(declaredAccounts).reduce(\n\t\t\t(sum, balance) => BigNumber.sum(sum, balance),\n\t\t\tnew BigNumber(0),\n\t\t).toString();\n\n\t\t// Prepare bakers object\n\t\tconst bakers = {\n\t\t\tbaker1: {\n\t\t\t\tpkh: 'tz1faswCTDciRzE4oJ9jn2Vm2dvjeyA9fUzU',\n\t\t\t\tpk: 'edpkuTXkJDGcFd5nh6VvMz8phXxU3Bi7h6hqgywNFi1vZTfQNnS1RV',\n\t\t\t\tsk: 'unencrypted:edsk4ArLQgBTLWG5FJmnGnT689VKoqhXwmDPBuGx3z4cvwU9MmrPZZ',\n\t\t\t\tbalance: totalBalance,\n\t\t\t},\n\t\t\tbaker2: {\n\t\t\t\tpkh: 'tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN',\n\t\t\t\tpk: 'edpktzNbDAUjUk697W7gYg2CRuBQjyPxbEg8dLccYYwKSKvkPvjtV9',\n\t\t\t\tsk: 'unencrypted:edsk39qAm1fiMjgmPkw1EgQYkMzkJezLNewd7PLNHTkr6w9XA2zdfo',\n\t\t\t\tbalance: totalBalance,\n\t\t\t},\n\t\t\tbaker3: {\n\t\t\t\tpkh: 'tz1b7tUupMgCNw2cCLpKTkSD1NZzB5TkP2sv',\n\t\t\t\tpk: 'edpkuFrRoDSEbJYgxRtLx2ps82UdaYc1WwfS9sE11yhauZt5DgCHbU',\n\t\t\t\tsk: 'unencrypted:edsk2uqQB9AY4FvioK2YMdfmyMrer5R8mGFyuaLLFfSRo8EoyNdht3',\n\t\t\t\tbalance: totalBalance,\n\t\t\t},\n\t\t};\n\n\t\t// Convert the bakers object to HJSON format\n\t\tconst hjsonContent = hjson.stringify(bakers, {\n\t\t\tquotes: 'min',\n\t\t\tbracesSameLine: true,\n\t\t\tseparator: false,\n\t\t});\n\n\t\t// Remove quotes around sk values and ensure proper indentation\n\t\tconst fixedHjsonContent = hjsonContent.replaceAll('\"', '');\n\n\t\t// Write the bakers.hjson file\n\t\tconst bakersHjsonPath = path.join(tezBoxConfigDir, 'bakers.hjson');\n\t\tawait fs.promises.writeFile(bakersHjsonPath, fixedHjsonContent, 'utf8');\n\t} catch (error) {\n\t\tthrow new Error(getErrorMessage(`Failed to prepare bakers`, error));\n\t}\n}\n\n/**\n * Generates a project ID based on the project directory.\n */\nfunction getProjectId(taskArgs: Opts): string {\n\treturn createHash('sha256').update(taskArgs.projectDir).digest('hex');\n}\n\n/**\n * Gets the docker container name for the sandbox.\n */\nfunction getDockerContainerName(taskArgs: Opts): string {\n\tconst projectId = getProjectId(taskArgs);\n\treturn `taq-${taskArgs.env}-${projectId}`;\n}\n\n/**\n * Gets the TezBox configuration directory.\n */\nfunction getTezBoxConfigDir(taskArgs: Opts): string {\n\tconst containerName = getDockerContainerName(taskArgs);\n\treturn path.join(taskArgs.projectDir, `.taq/.${containerName}/config`);\n}\n\n/**\n * Gets the TezBox data directory.\n */\nfunction getTezBoxDataDir(taskArgs: Opts): string {\n\tconst containerName = getDockerContainerName(taskArgs);\n\treturn path.join(taskArgs.projectDir, `.taq/.${containerName}/data`);\n}\n\n/**\n * Gets the docker image for TezBox.\n */\nfunction getImage(taskArgs: Opts): string {\n\treturn getDockerImage(getDefaultDockerImage(taskArgs), 'TAQ_TEZBOX_IMAGE');\n}\n\n/**\n * Checks if the sandbox is running.\n */\nasync function isSandboxRunning(taskArgs: Opts): Promise<boolean> {\n\tconst containerName = getDockerContainerName(taskArgs);\n\tconst cmd = `docker ps --filter \"name=${containerName}\" --format \"{{.ID}}\"`;\n\tconst { stdout } = await runCommand(cmd);\n\treturn stdout.trim() !== '';\n}\n\n/**\n * Checks if the sandbox is already running.\n */\nasync function checkSandboxRunning(taskArgs: Opts): Promise<boolean> {\n\tconst running = await isSandboxRunning(taskArgs);\n\tif (running) {\n\t\tawait sendAsyncRes('Sandbox is already running.');\n\t}\n\treturn running;\n}\n\nfunction getPortNumber(taskArgs: Opts) {\n\tconst rpcUrl = getSandboxConfig(taskArgs).rpcUrl;\n\tconst match = rpcUrl.match(/:(\\d+)/);\n\treturn match ? parseInt(match[1], 10) : 80;\n}\n\nfunction getContainerPort(taskArgs: Opts) {\n\treturn getPortNumber(taskArgs) + 1;\n}\n\n/**\n * Gets the docker run parameters.\n */\nasync function getDockerRunParams(taskArgs: Opts): Promise<DockerRunParams> {\n\tconst image = getImage(taskArgs);\n\tconst containerName = getDockerContainerName(taskArgs);\n\tconst platform = await getArch();\n\tconst configDir = getTezBoxConfigDir(taskArgs);\n\tconst dataDir = getTezBoxDataDir(taskArgs);\n\tconst port = getContainerPort(taskArgs);\n\n\treturn { platform, image, containerName, configDir, dataDir, port };\n}\n\n/**\n * Ensures directories exist.\n */\nasync function ensureDirectoriesExist(directories: string[]): Promise<void> {\n\tawait Promise.all(\n\t\tdirectories.map(dir => fs.promises.mkdir(dir, { recursive: true })),\n\t);\n}\n\n/**\n * Constructs the docker run command.\n */\nfunction constructDockerRunCommand(params: DockerRunParams): string {\n\tconst { platform, image, containerName, configDir, port } = params;\n\n\tconst dockerOptions = [\n\t\t'docker run',\n\t\t'-d',\n\t\t`--platform ${platform}`,\n\t\t'-p 8732:8732',\n\t\t`-p ${port}:20000`,\n\t\t`--name ${containerName}`,\n\t\t`-v \"${configDir}:/tezbox/overrides\"`,\n\t\timage,\n\t\t'S',\n\t];\n\n\treturn dockerOptions.join(' ');\n}\n\n/**\n * Validates the block time in the sandbox configuration.\n */\nfunction validateBlockTime(taskArgs: Opts): number | null {\n\tconst sandboxConfig = getSandboxConfig(taskArgs);\n\tconst blockTime = sandboxConfig.blockTime;\n\tif (blockTime === undefined || blockTime === null) {\n\t\tlogger.warn('Block time is not specified; skipping block_time override.');\n\t\treturn null;\n\t}\n\treturn blockTime;\n}\n\n/**\n * Writes sandbox parameters for a single protocol.\n */\nasync function writeSandboxParameters(\n\tprotocolId: string,\n\tparameters: Record<string, string | number>,\n\ttezBoxConfigDir: string,\n): Promise<void> {\n\tconst protocolsDir = path.join(tezBoxConfigDir, 'protocols', protocolId);\n\tawait fs.promises.mkdir(protocolsDir, { recursive: true });\n\n\tconst hjsonContent = hjson.stringify(parameters, {\n\t\tquotes: 'min',\n\t\tbracesSameLine: true,\n\t\tseparator: false,\n\t});\n\n\tconst sandboxParamsPath = path.join(protocolsDir, 'sandbox-parameters.hjson');\n\tawait fs.promises.writeFile(sandboxParamsPath, hjsonContent, 'utf8');\n\n\t// Ensure the file has write permissions\n\ttry {\n\t\tawait fs.promises.chmod(sandboxParamsPath, 0o644);\n\t} catch (error) {\n\t\tlogger.warn(getErrorMessage(`Failed to set file permissions for ${sandboxParamsPath}`, error));\n\t}\n}\n\n/**\n * Applies block time override to a single protocol.\n */\nasync function applyBlockTimeOverrideToProtocol(\n\tprotocolId: string,\n\tblockTime: number,\n\ttezBoxConfigDir: string,\n): Promise<void> {\n\tconst nonce_revelation_threshold = 16;\n\tconst minimal_block_delay = blockTime;\n\n\tconst parameters = {\n\t\tminimal_block_delay: minimal_block_delay.toString(),\n\t};\n\tawait writeSandboxParameters(protocolId, parameters, tezBoxConfigDir);\n}\n\n/**\n * Applies block time override to multiple protocols.\n */\nasync function applyBlockTimeOverrideToProtocols(\n\tprotocolIds: string[],\n\tblockTime: number,\n\ttezBoxConfigDir: string,\n): Promise<void> {\n\tawait Promise.all(\n\t\tprotocolIds.map(async protocolId => {\n\t\t\t// Skip alpha protocol as it's a placeholder\n\t\t\tif (/^alpha$/i.test(protocolId)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait applyBlockTimeOverrideToProtocol(protocolId, blockTime, tezBoxConfigDir);\n\t\t}),\n\t);\n}\n\n/**\n * Gets protocol identifiers from TezBox configuration.\n */\nasync function getProtocolIds(taskArgs: Opts): Promise<string[]> {\n\tconst image = getImage(taskArgs);\n\n\t// List the protocol directories inside the TezBox image\n\tconst cmd = `docker run --rm --entrypoint ls ${image} /tezbox/configuration/protocols`;\n\tconst { stdout } = await runCommand(cmd);\n\n\tconst protocolIds = stdout\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.map(line => line.trim())\n\t\t.filter(line => line !== '');\n\n\treturn protocolIds;\n}\n\n/**\n * Reads and parses protocol.hjson for a given protocolId.\n */\nasync function readProtocolJson(image: string, protocolId: string): Promise<ProtocolMapping | null> {\n\tconst cmd = `docker run --rm --entrypoint cat ${image} /tezbox/configuration/protocols/${protocolId}/protocol.hjson`;\n\n\ttry {\n\t\tconst { stdout } = await runCommand(cmd);\n\n\t\tif (!stdout.trim()) {\n\t\t\tlogger.warn(`protocol.hjson not found or empty for protocolId ${protocolId}; skipping this protocol.`);\n\t\t\treturn null;\n\t\t}\n\n\t\t// Parse the HJSON content\n\t\tconst protocolData = hjson.parse(stdout);\n\t\tconst protocolHash: string = protocolData.hash;\n\t\tif (protocolHash) {\n\t\t\treturn { id: protocolId, hash: protocolHash };\n\t\t} else {\n\t\t\tlogger.warn(`Protocol hash not found in protocol.hjson for protocolId ${protocolId}; skipping.`);\n\t\t\treturn null;\n\t\t}\n\t} catch (error) {\n\t\tlogger.warn(getErrorMessage(`Failed to read protocol.hjson for protocolId ${protocolId}`, error));\n\t\treturn null;\n\t}\n}\n\n/**\n * Gets protocol mappings.\n */\nasync function getProtocolMappings(taskArgs: Opts): Promise<ProtocolMapping[]> {\n\tconst image = getImage(taskArgs);\n\tconst protocolIds = await getProtocolIds(taskArgs);\n\n\tconst protocolMappingsPromises = protocolIds.map(async protocolId => {\n\t\tconst mapping = await readProtocolJson(image, protocolId);\n\t\treturn mapping;\n\t});\n\n\tconst protocolMappings = await Promise.all(protocolMappingsPromises);\n\treturn protocolMappings.filter((mapping): mapping is ProtocolMapping => mapping !== null);\n}\n\n/**\n * Gets protocol hashes from octez-client.\n */\nasync function getOctezClientProtocols(taskArgs: Opts): Promise<string[]> {\n\tconst image = getImage(taskArgs);\n\tconst cmd = `docker run --rm --entrypoint octez-client ${image} list mockup protocols`;\n\tconst { stdout } = await runCommand(cmd, stderr => {\n\t\tconst ignorableError = [\n\t\t\t'Base directory /tezbox/data/.tezos-client does not exist.',\n\t\t\t'Unable to connect to the node: \"Unix.Unix_error(Unix.ECONNREFUSED, \"connect\", \"\")\"',\n\t\t];\n\n\t\tif (stderr.trim() !== '' && !ignorableError.some(err => stderr.includes(err))) {\n\t\t\tthrow new Error(`Failed to list protocols: ${stderr.trim()}`);\n\t\t}\n\t});\n\n\tconst protocols = stdout\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.filter(line => line.trim() !== '');\n\n\treturn protocols;\n}\n\n/**\n * Prepares sandbox-parameters.hjson for block_time override.\n */\nasync function prepareSandboxParametersHjson(taskArgs: Opts, tezBoxConfigDir: string): Promise<void> {\n\ttry {\n\t\t// Validate block time\n\t\tconst blockTime = validateBlockTime(taskArgs);\n\t\tif (blockTime === null) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Get the protocol mappings from TezBox\n\t\tconst protocolMappings = await getProtocolMappings(taskArgs);\n\t\tconst hashToIdMap: Record<string, string> = {};\n\t\tfor (const mapping of protocolMappings) {\n\t\t\thashToIdMap[mapping.hash] = mapping.id;\n\t\t}\n\n\t\t// Get the list of protocol hashes supported by octez-client\n\t\tconst protocolHashes = await getOctezClientProtocols(taskArgs);\n\n\t\t// Map protocol hashes to TezBox protocol IDs\n\t\tconst protocolIdsToOverride = protocolHashes\n\t\t\t.map(hash => hashToIdMap[hash])\n\t\t\t.filter((id): id is string => id !== undefined);\n\n\t\tif (protocolIdsToOverride.length === 0) {\n\t\t\tlogger.warn('No matching protocol IDs found; cannot set block_time override.');\n\t\t\treturn;\n\t\t}\n\n\t\t// Debug: Log the protocol IDs to override\n\t\t// logger.info(`Protocol IDs to override: ${protocolIdsToOverride.join(', ')}`);\n\n\t\t// Apply block time override to each protocol ID\n\t\tawait applyBlockTimeOverrideToProtocols(protocolIdsToOverride, blockTime, tezBoxConfigDir);\n\t} catch (error) {\n\t\tconst errorMessage = getErrorMessage(`Failed to prepare sandbox parameters:`, error);\n\t\tthrow new Error(errorMessage);\n\t}\n}\n\n/**\n * Prepares baker.hjson if baking is disabled.\n */\nasync function prepareBakerHjson(tezBoxConfigDir: string): Promise<void> {\n\tconst servicesDir = path.join(tezBoxConfigDir, 'services');\n\ttry {\n\t\tawait fs.promises.mkdir(servicesDir, { recursive: true });\n\n\t\tconst bakerConfig = {\n\t\t\tautostart: false,\n\t\t};\n\n\t\tconst hjsonContent = hjson.stringify(bakerConfig, {\n\t\t\tquotes: 'all',\n\t\t\tbracesSameLine: true,\n\t\t\tseparator: true,\n\t\t});\n\n\t\tconst bakerConfigPath = path.join(servicesDir, 'baker.hjson');\n\t\tawait fs.promises.writeFile(bakerConfigPath, hjsonContent, 'utf8');\n\t} catch (error) {\n\t\tthrow new Error(getErrorMessage(`Failed to prepare baker.hjson`, error));\n\t}\n}\n\n/**\n * Prepares TezBox configuration overrides.\n */\nasync function prepareTezBoxOverrides(taskArgs: Opts): Promise<void> {\n\tconst tezBoxConfigDir = getTezBoxConfigDir(taskArgs);\n\n\ttry {\n\t\t// Get sandbox configuration\n\t\tconst sandboxConfig = getSandboxConfig(taskArgs);\n\n\t\t// Ensure the configuration directory exists\n\t\tawait fs.promises.mkdir(tezBoxConfigDir, { recursive: true });\n\n\t\t// Prepare tasks\n\t\tconst tasks: Promise<void>[] = [];\n\n\t\t// Prepare bakers.hjson\n\t\ttasks.push(prepareBakersHjson(taskArgs, tezBoxConfigDir));\n\n\t\t// Prepare accounts.hjson\n\t\tif (taskArgs.config.accounts) {\n\t\t\ttasks.push(prepareAccountsHjson(taskArgs, tezBoxConfigDir));\n\t\t}\n\n\t\t// Prepare sandbox-parameters.hjson for block_time\n\t\tif (sandboxConfig.blockTime) {\n\t\t\ttasks.push(prepareSandboxParametersHjson(taskArgs, tezBoxConfigDir));\n\t\t}\n\n\t\t// Prepare baker.hjson if baking is disabled\n\t\tif (sandboxConfig.baking === BakingOption.DISABLED) {\n\t\t\ttasks.push(prepareBakerHjson(tezBoxConfigDir));\n\t\t}\n\n\t\t// Run all preparations in parallel\n\t\tawait Promise.all(tasks);\n\t} catch (error) {\n\t\tthrow new Error(getErrorMessage(`Failed to prepare TezBox overrides`, error));\n\t}\n}\n\nfunction getProxyContainerName(taskArgs: Opts) {\n\treturn `${getDockerContainerName(taskArgs)}-proxy`;\n}\n\nasync function startProxyServer(taskArgs: Opts): Promise<void> {\n\tconst containerPort = getContainerPort(taskArgs);\n\tconst proxyPort = getPortNumber(taskArgs);\n\tconst proxyContainerName = getProxyContainerName(taskArgs);\n\n\tconst proxyCmd = `docker run -d --name ${proxyContainerName} \\\n --network host \\\n caddy:2-alpine \\\n caddy reverse-proxy \\\n --from http://:${proxyPort} \\\n --to http://127.0.0.1:${containerPort} \\\n --access-log`;\n\n\ttry {\n\t\tawait runCommand(proxyCmd);\n\t} catch (error) {\n\t\tthrow new Error(getErrorMessage(`Failed to start Caddy reverse proxy`, error));\n\t}\n}\n\nasync function stopProxyServer(taskArgs: Opts): Promise<void> {\n\tconst proxyContainerName = getProxyContainerName(taskArgs);\n\tconst cmd = `docker rm -f ${proxyContainerName}`;\n\tawait runCommand(cmd);\n}\n\n/**\n * Starts the sandbox.\n */\nasync function startSandbox(taskArgs: Opts): Promise<void> {\n\ttry {\n\t\t// Check for Docker availability\n\t\tawait checkDockerAvailability();\n\n\t\t// Check if the sandbox is already running\n\t\tif (await checkSandboxRunning(taskArgs)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Get Docker run parameters\n\t\tconst params = await getDockerRunParams(taskArgs);\n\n\t\t// Ensure necessary directories exist\n\t\tawait ensureDirectoriesExist([params.dataDir, params.configDir]);\n\n\t\t// Prepare TezBox configuration overrides\n\t\tawait prepareTezBoxOverrides(taskArgs);\n\n\t\t// Construct the Docker run command\n\t\tconst cmd = constructDockerRunCommand(params);\n\t\t// logger.info(`Starting sandbox with command: ${cmd}`);\n\n\t\t// Execute the Docker run command\n\t\tawait runCommand(cmd);\n\n\t\t// Start the proxy server\n\t\tawait startProxyServer(taskArgs);\n\n\t\t// Send a success response\n\t\tawait sendAsyncRes('Sandbox started successfully.');\n\t} catch (error) {\n\t\tawait sendAsyncErr(getErrorMessage(`Failed to start sandbox`, error));\n\t}\n}\n\n/**\n * Checks for Docker availability.\n */\nasync function checkDockerAvailability(): Promise<void> {\n\ttry {\n\t\tawait runCommand('docker --version');\n\t} catch (error) {\n\t\tthrow new Error('Docker is not installed or not running. Please install and start Docker.');\n\t}\n}\n\n/**\n * Removes the sandbox container.\n */\nasync function removeSandboxContainer(taskArgs: Opts): Promise<void> {\n\tconst containerName = getDockerContainerName(taskArgs);\n\tconst cmd = `docker rm -f ${containerName}`;\n\n\ttry {\n\t\tawait runCommand(cmd);\n\t} catch (error) {\n\t\tconst errorMessage = getErrorMessage('', error);\n\t\tif (errorMessage.includes('No such container')) {\n\t\t\t// Container does not exist\n\t\t\tawait sendAsyncRes('Sandbox is not running or already stopped.');\n\t\t} else {\n\t\t\tthrow new Error(errorMessage);\n\t\t}\n\t}\n\n\t// Stop the proxy server\n\tawait stopProxyServer(taskArgs);\n}\n\n/**\n * Stops the sandbox.\n */\nasync function stopSandbox(taskArgs: Opts): Promise<void> {\n\ttry {\n\t\t// Attempt to stop and remove the sandbox container\n\t\tawait removeSandboxContainer(taskArgs);\n\n\t\t// Optionally, clean up configuration directory if needed\n\t\tconst configDir = getTezBoxConfigDir(taskArgs);\n\t\tawait fs.promises.rm(configDir, { recursive: true, force: true });\n\n\t\t// Send a success response\n\t\tawait sendAsyncRes('Sandbox stopped and cleaned up.');\n\t} catch (error) {\n\t\tawait sendAsyncErr(getErrorMessage(`Failed to stop sandbox`, error));\n\t}\n}\n\n/**\n * Restarts the sandbox.\n */\nasync function restartSandbox(taskArgs: Opts): Promise<void> {\n\ttry {\n\t\t// Stop the sandbox if it's running\n\t\tawait removeSandboxContainer(taskArgs);\n\n\t\t// Start the sandbox\n\t\tawait startSandbox(taskArgs);\n\n\t\t// Send a success response\n\t\tawait sendAsyncRes('Sandbox restarted successfully.');\n\t} catch (error) {\n\t\tawait sendAsyncErr(getErrorMessage(`Failed to restart sandbox`, error));\n\t}\n}\n\n/**\n * Lists protocols.\n */\nasync function listProtocols(taskArgs: Opts): Promise<void> {\n\ttry {\n\t\tconst protocolHashes = await getOctezClientProtocols(taskArgs);\n\t\tconst protocolObjects = protocolHashes.map(protocol => ({ protocol }));\n\t\tawait sendAsyncJsonRes(protocolObjects);\n\t} catch (error) {\n\t\tawait sendAsyncErr(getErrorMessage(`Failed to list protocols`, error));\n\t}\n}\n\n/**\n * Lists accounts.\n */\nasync function listAccounts(taskArgs: Opts): Promise<void> {\n\ttry {\n\t\tif (await isSandboxRunning(taskArgs)) {\n\t\t\t// List accounts from the sandbox\n\t\t\tconst containerName = getDockerContainerName(taskArgs);\n\t\t\tconst cmd = `docker exec ${containerName} octez-client list known addresses`;\n\t\t\tconst { stdout } = await runCommand(cmd);\n\n\t\t\tif (!stdout.trim()) {\n\t\t\t\tawait sendAsyncRes('No accounts found.');\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst accounts = stdout\n\t\t\t\t.trim()\n\t\t\t\t.split('\\n')\n\t\t\t\t.filter(line => line.trim() !== '')\n\t\t\t\t.map(line => {\n\t\t\t\t\tconst [name, rest] = line.split(':');\n\t\t\t\t\tconst address = rest ? rest.trim().split(' ')[0] : '';\n\t\t\t\t\treturn { name: name.trim(), address };\n\t\t\t\t});\n\n\t\t\tawait sendAsyncJsonRes(accounts);\n\t\t} else {\n\t\t\tawait sendAsyncErr(`Sandbox is not running. Please start the sandbox before attempting to list accounts.`);\n\t\t}\n\t} catch (error) {\n\t\tawait sendAsyncErr(getErrorMessage(`Failed to list accounts`, error));\n\t}\n}\n\n/**\n * Bakes a block in the sandbox.\n */\nasync function bakeBlock(taskArgs: Opts): Promise<void> {\n\ttry {\n\t\tif (await isSandboxRunning(taskArgs)) {\n\t\t\tconst containerName = getDockerContainerName(taskArgs);\n\t\t\tconst cmd = `docker exec ${containerName} octez-client bake for baker1`;\n\n\t\t\tif (taskArgs.watch) {\n\t\t\t\tconsole.log('Baking on demand as operations are injected.');\n\t\t\t\tconsole.log('Press CTRL-C to stop and exit.');\n\t\t\t\tconsole.log();\n\n\t\t\t\twhile (true) {\n\t\t\t\t\tconsole.log('Waiting for operations to be injected...');\n\t\t\t\t\twhile (true) {\n\t\t\t\t\t\tconst { stdout } = await runCommand(\n\t\t\t\t\t\t\t`docker exec ${containerName} octez-client rpc get /chains/main/mempool/pending_operations`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst ops = JSON.parse(stdout);\n\t\t\t\t\t\tif (Array.isArray(ops.applied) && ops.applied.length > 0) break;\n\t\t\t\t\t\tawait new Promise(resolve => setTimeout(resolve, 1000)); // Wait for 1 second before checking again\n\t\t\t\t\t}\n\n\t\t\t\t\tawait runCommand(cmd);\n\t\t\t\t\tconsole.log('Block baked.');\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tawait runCommand(cmd);\n\t\t\t\tawait sendAsyncRes('Block baked successfully.');\n\t\t\t}\n\t\t} else {\n\t\t\ttry {\n\t\t\t\tawait sendAsyncErr('Sandbox is not running. Please start the sandbox before attempting to bake a block.');\n\t\t\t} catch {\n\t\t\t\t// Nothing to see here.\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\tawait sendAsyncErr(getErrorMessage(`Failed to bake block`, error));\n\t}\n}\n\n/**\n * Main proxy function to handle tasks.\n */\nexport const proxy = async (taskArgs: Opts): Promise<void> => {\n\tif (!isTezBoxEnvironment(taskArgs)) {\n\t\tawait sendAsyncErr(\n\t\t\t`This configuration doesn't appear to be configured to use TezBox environments. Check the ${taskArgs.env} environment in your .taq/config.json.`,\n\t\t);\n\t\treturn;\n\t}\n\n\tconst taskName = taskArgs.task?.toLowerCase().trim();\n\n\tconst taskHandlers: Record<string, (args: Opts) => Promise<void>> = {\n\t\t'start sandbox': startSandbox,\n\t\t'stop sandbox': stopSandbox,\n\t\t'restart sandbox': restartSandbox,\n\t\t'list protocols': listProtocols,\n\t\t'list-protocols': listProtocols,\n\t\t'show protocols': listProtocols,\n\t\t'show-protocols': listProtocols,\n\t\t'list accounts': listAccounts,\n\t\t'list-accounts': listAccounts,\n\t\t'show accounts': listAccounts,\n\t\t'show-accounts': listAccounts,\n\t\t'bake': bakeBlock,\n\t\t'bake block': bakeBlock,\n\t};\n\n\tconst handler = taskName ? taskHandlers[taskName] : undefined;\n\n\tif (handler) {\n\t\ttry {\n\t\t\tawait handler(taskArgs);\n\t\t} catch (error) {\n\t\t\tawait sendAsyncErr(getErrorMessage(`Error executing task '${taskArgs.task}'`, error));\n\t\t}\n\t} else {\n\t\tawait sendAsyncErr(taskArgs.task ? `Unknown task: ${taskArgs.task}` : 'No task provided');\n\t}\n};\n\nexport default proxy;\n","import { getDockerImage } from '@taqueria/node-sdk';\nimport { Opts } from './types';\n\nexport const TAQ_TEZBOX_IMAGE_ENV_VAR = 'TAQ_TEZBOX_IMAGE';\n\nexport const getDefaultDockerImage = (opts: Opts) => `ghcr.io/tez-capital/tezbox:tezos-v23.0-rc2`;\n\nexport const getImage = (opts: Opts) => getDockerImage(getDefaultDockerImage(opts), TAQ_TEZBOX_IMAGE_ENV_VAR);\n"],"mappings":";AAAA,SAAS,QAAQ,QAAuB,YAAY;;;ACApD;AAAA,EACC;AAAA,EACA;AAAA,EACA,kBAAAA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,mBAAmB,sBAAsB;AAClD,OAAO,eAAe;AACtB,YAAY,WAAW;AACvB,SAAS,kBAAkB;AAE3B,YAAY,QAAQ;AACpB,YAAY,WAAW;AACvB,YAAY,UAAU;;;ACjBtB,SAAS,sBAAsB;AAKxB,IAAM,wBAAwB,C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EACF;AAAA,EACA,OAAO;AACR,IAAI,QAAQ,IAAI;","names":["getDockerImage","generateMnemonic","getDockerImage"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taqueria/plugin-tezbox",
|
|
3
|
-
"version": "0.73.
|
|
3
|
+
"version": "0.73.9",
|
|
4
4
|
"description": "A plugin for Taqueria providing local sandbox capabilities built on TezBox",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"taqueria",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"http-proxy": "^1.18.1",
|
|
40
40
|
"portfinder": "^1.0.32",
|
|
41
41
|
"rambda": "^9.3.0",
|
|
42
|
-
"@taqueria/node-sdk": "0.73.
|
|
43
|
-
"@taqueria/protocol": "0.73.
|
|
42
|
+
"@taqueria/node-sdk": "0.73.9",
|
|
43
|
+
"@taqueria/protocol": "0.73.9"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/async-retry": "^1.4.8",
|