@taqueria/plugin-taquito 0.37.49 → 0.37.50

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/index.js CHANGED
@@ -375,10 +375,27 @@ var createBatchForOriginate = (tezos, contractsInfo) => contractsInfo.reduce((ac
375
375
  balance: contractInfo.mutezTransfer.toString(),
376
376
  mutez: true
377
377
  }), tezos.wallet.batch());
378
- var performOriginateOps = async (tezos, env, contractsInfo, maxTimeout) => {
378
+ function withIntervalHack(fn) {
379
+ return async function(...args) {
380
+ const originalSetInterval = setInterval;
381
+ const intervals = [];
382
+ global.setInterval = (callback, delay) => {
383
+ const id = originalSetInterval(callback, delay);
384
+ intervals.push(id);
385
+ return id;
386
+ };
387
+ try {
388
+ return await fn(...args);
389
+ } finally {
390
+ intervals.forEach((id) => clearInterval(id));
391
+ global.setInterval = originalSetInterval;
392
+ }
393
+ };
394
+ }
395
+ var performOriginateOps = withIntervalHack((tezos, env, contractsInfo, maxTimeout) => {
379
396
  const batch = createBatchForOriginate(tezos, contractsInfo);
380
397
  try {
381
- return await doWithin(maxTimeout, async () => {
398
+ return doWithin(maxTimeout, async () => {
382
399
  const op = await batch.send();
383
400
  await op.confirmation();
384
401
  return op;
@@ -386,7 +403,7 @@ var performOriginateOps = async (tezos, env, contractsInfo, maxTimeout) => {
386
403
  } catch (err) {
387
404
  return handleOpsError(err, env);
388
405
  }
389
- };
406
+ });
390
407
  var prepContractInfoForDisplay2 = async (parsedArgs, tezos, contractInfo, op) => {
391
408
  var _a, _b, _c;
392
409
  const protocolArgs = import_node_sdk5.RequestArgs.create(parsedArgs);
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts","main.ts","fund.ts","common.ts","transfer.ts","instantiate_account.ts","originate.ts"],"sourcesContent":["import { Option, Plugin, Task } from '@taqueria/node-sdk';\nimport main from './main';\n\nPlugin.create(_i18n => ({\n\talias: 'taquito',\n\tschema: '1.0',\n\tversion: '0.1',\n\ttasks: [\n\t\tTask.create({\n\t\t\ttask: 'deploy',\n\t\t\tcommand: 'deploy <contract>',\n\t\t\tdescription: 'Deploy a smart contract to a particular environment',\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'alias',\n\t\t\t\t\tdescription: \"Alias used to refer to the deployed contract's address\",\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'storage',\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'Name of the storage file that contains the storage value as a Michelson expression, in the artifacts directory, used for originating a contract',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'sender',\n\t\t\t\t\tdescription: 'Name of an instantiated account to use as the sender of the originate operation',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'mutez',\n\t\t\t\t\tdescription: 'Amount of Mutez to transfer',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'timeout',\n\t\t\t\t\tshortFlag: 't',\n\t\t\t\t\tdefaultValue: 40,\n\t\t\t\t\tdescription: 'Number of retry attempts (to avoid congestion and network failures)',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t],\n\t\t\taliases: ['originate'],\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'application/json',\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'transfer',\n\t\t\tcommand: 'transfer <contract>',\n\t\t\tdescription:\n\t\t\t\t'Transfer/call an implicit account or a smart contract (specified via its alias or address) deployed to a particular environment',\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'mutez',\n\t\t\t\t\tdescription: 'Amount of Mutez to transfer',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'param',\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'Name of the parameter file that contains the parameter value as a Michelson expression, in the artifacts directory, used for invoking a deployed contract',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'entrypoint',\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'You may explicitly specify an entrypoint to make the parameter value shorter, without having to specify a chain of (Left (Right ... 14 ...))',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'sender',\n\t\t\t\t\tdescription: 'Name of an instantiated account to use as the sender of the transfer operation',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'timeout',\n\t\t\t\t\tshortFlag: 't',\n\t\t\t\t\tdefaultValue: 40,\n\t\t\t\t\tdescription: 'Number of retry attempts (to avoid congestion and network failures)',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t],\n\t\t\taliases: ['call'],\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'application/json',\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'fund',\n\t\t\tcommand: 'fund',\n\t\t\tdescription: 'Fund all the instantiated accounts up to the desired/declared amount in a target environment',\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'application/json',\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'timeout',\n\t\t\t\t\tshortFlag: 't',\n\t\t\t\t\tdefaultValue: 40,\n\t\t\t\t\tdescription: 'Number of retry attempts (to avoid congestion and network failures)',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t],\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'instantiate-account',\n\t\t\tcommand: 'instantiate-account',\n\t\t\tdescription:\n\t\t\t\t'Instantiate all accounts declared in the \"accounts\" field at the root level of the config file to a target environment',\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'application/json',\n\t\t}),\n\t],\n\tproxy: main,\n}), process.argv);\n","import { RequestArgs, sendAsyncErr } from '@taqueria/node-sdk';\nimport { IntersectionOpts as Opts } from './common';\nimport fund from './fund';\nimport instantiate_account from './instantiate_account';\nimport originate from './originate';\nimport transfer from './transfer';\n\nexport const main = (parsedArgs: RequestArgs.t): Promise<void> => {\n\tconst unsafeArgs = parsedArgs as unknown as Opts;\n\tswitch (unsafeArgs.task) {\n\t\tcase 'deploy':\n\t\t\treturn originate(unsafeArgs);\n\t\tcase 'transfer':\n\t\t\treturn transfer(unsafeArgs);\n\t\tcase 'instantiate-account':\n\t\t\treturn instantiate_account(parsedArgs);\n\t\tcase 'fund':\n\t\t\treturn fund(unsafeArgs);\n\t\tdefault:\n\t\t\treturn sendAsyncErr(`${unsafeArgs} is not an understood task by the Taquito plugin`);\n\t}\n};\n\nexport default main;\n","import {\n\tgetCurrentEnvironment,\n\tgetCurrentEnvironmentConfig,\n\tRequestArgs,\n\tsendAsyncErr,\n\tsendJsonRes,\n\tsendWarn,\n} from '@taqueria/node-sdk';\nimport { TezosToolkit } from '@taquito/taquito';\nimport {\n\tconfigureToolKitForNetwork,\n\tFundOpts,\n\tFundOpts as Opts,\n\tgetDeclaredAccounts,\n\tgetEnvTypeAndNodeConfig,\n\tgetNetworkInstantiatedAccounts,\n} from './common';\nimport { ContractInfo, performTransferOps } from './transfer';\n\ntype TableRow = {\n\taccountAlias: string;\n\taccountAddress: string;\n\tmutezFunded: string;\n};\n\nconst getAccountsInfo = (\n\tparsedArgs: RequestArgs.t,\n\ttezos: TezosToolkit,\n\tinstantiatedAccounts: Record<string, any>,\n): Promise<ContractInfo[]> =>\n\tPromise.all(\n\t\tObject.entries(instantiatedAccounts)\n\t\t\t.map(async (instantiatedAccount: [string, any]) => {\n\t\t\t\tconst alias = instantiatedAccount[0];\n\t\t\t\tconst aliasInfo = instantiatedAccount[1];\n\n\t\t\t\tconst declaredMutez: number | undefined = getDeclaredAccounts(parsedArgs)[alias];\n\t\t\t\tconst currentBalanceInMutez = (await tezos.tz.getBalance(aliasInfo.publicKeyHash)).toNumber();\n\t\t\t\tconst amountToFillInMutez = declaredMutez ? Math.max(declaredMutez - currentBalanceInMutez, 0) : 0;\n\n\t\t\t\tif (!declaredMutez) {\n\t\t\t\t\tsendWarn(\n\t\t\t\t\t\t`Warning: ${alias} is instantiated in the target environment but not declared in the root level \"accounts\" field of ./.taq/config.json so ${alias} will not be funded as you don't have a declared tez amount set there for ${alias}\\n`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tcontractAlias: alias,\n\t\t\t\t\tcontractAddress: aliasInfo.publicKeyHash,\n\t\t\t\t\tparameter: 'Unit',\n\t\t\t\t\tentrypoint: 'default',\n\t\t\t\t\tmutezTransfer: parseInt(amountToFillInMutez.toString()),\n\t\t\t\t};\n\t\t\t}),\n\t)\n\t\t.then(accountsInfo => accountsInfo.filter(accountInfo => accountInfo.mutezTransfer !== 0))\n\t\t.catch(err => sendAsyncErr(`Something went wrong while extracting account information - ${err}`));\n\nconst prepAccountsInfoForDisplay = (accountsInfo: ContractInfo[]): TableRow[] =>\n\taccountsInfo.map(accountInfo => {\n\t\treturn {\n\t\t\taccountAlias: accountInfo.contractAlias,\n\t\t\taccountAddress: accountInfo.contractAddress,\n\t\t\tmutezFunded: accountInfo.mutezTransfer.toString(),\n\t\t};\n\t});\n\nconst fund = async (parsedArgs: FundOpts): Promise<void> => {\n\tconst env = getCurrentEnvironmentConfig(parsedArgs);\n\tif (!env) return sendAsyncErr(`There is no environment called ${parsedArgs.env} in your config.json`);\n\ttry {\n\t\tconst [envType, nodeConfig] = await getEnvTypeAndNodeConfig(parsedArgs, env);\n\t\tif (envType !== 'Network') return sendAsyncErr('taq fund can only be executed in a network environment');\n\t\tconst tezos = await configureToolKitForNetwork(parsedArgs, nodeConfig);\n\n\t\tconst instantiatedAccounts = getNetworkInstantiatedAccounts(nodeConfig);\n\n\t\tconst accountsInfo = await getAccountsInfo(parsedArgs, tezos, instantiatedAccounts);\n\t\tif (accountsInfo.length === 0) {\n\t\t\treturn sendJsonRes(\n\t\t\t\t`All instantiated accounts in the current environment, \"${parsedArgs.env}\", are funded up to or beyond the declared amount`,\n\t\t\t);\n\t\t}\n\n\t\tawait performTransferOps(tezos, getCurrentEnvironment(parsedArgs), accountsInfo, parsedArgs.timeout);\n\n\t\tconst accountsInfoForDisplay = prepAccountsInfoForDisplay(accountsInfo);\n\t\treturn sendJsonRes(accountsInfoForDisplay);\n\t} catch {\n\t\treturn sendAsyncErr('No operations performed');\n\t}\n};\n\nexport default fund;\n","import {\n\tgetAccountPrivateKey,\n\tgetDefaultSandboxAccount,\n\tgetNetworkConfig,\n\tgetSandboxConfig,\n\tRequestArgs,\n\tsendAsyncErr,\n\tsendErr,\n\tTAQ_OPERATOR_ACCOUNT,\n} from '@taqueria/node-sdk';\nimport {\n\tEnvironment,\n\tNetworkConfig,\n\tProtocol,\n\tProxyTaskArgs,\n\tSandboxAccountConfig,\n\tSandboxConfig,\n} from '@taqueria/node-sdk/types';\nimport { importKey, InMemorySigner } from '@taquito/signer';\nimport { TezosToolkit } from '@taquito/taquito';\n\nexport type OriginateOpts = ProxyTaskArgs.t & {\n\tcontract: string;\n\tstorage: string;\n\talias?: string;\n\tsender?: string;\n\tmutez?: string;\n\ttimeout: number;\n};\n\nexport type TransferOpts = ProxyTaskArgs.t & {\n\tcontract: string;\n\tmutez?: string;\n\tparam?: string;\n\tentrypoint?: string;\n\tsender?: string;\n\ttimeout: number;\n};\n\nexport type FundOpts = ProxyTaskArgs.t & {\n\ttimeout: number;\n};\n\nexport type InstantiateAccountOpts = ProxyTaskArgs.t;\n\n// To be used for the main entrypoint of the plugin\nexport type IntersectionOpts = OriginateOpts & TransferOpts & InstantiateAccountOpts & FundOpts;\n\n// To be used for common functions in this file\ntype UnionOpts = OriginateOpts | TransferOpts | InstantiateAccountOpts | FundOpts;\n\nexport const getEnvTypeAndNodeConfig = (\n\tparsedArgs: RequestArgs.t,\n\tenv: Environment.t,\n): Promise<['Network', NetworkConfig.t] | ['Sandbox', SandboxConfig.t]> => {\n\tconst targetConstraintErrMsg = 'Each environment can only have one target, be it a network or a sandbox';\n\tif (env.networks?.length === 1 && env.sandboxes?.length === 1) return sendAsyncErr(targetConstraintErrMsg);\n\tif (env.networks?.length === 1) {\n\t\tconst networkName = env.networks[0];\n\t\tconst network = getNetworkConfig(parsedArgs)(networkName);\n\t\tif (!network) {\n\t\t\treturn sendAsyncErr(\n\t\t\t\t`The current environment is configured to use a network called '${networkName}'; however, no network of this name has been configured in .taq/config.json`,\n\t\t\t);\n\t\t}\n\t\treturn Promise.resolve(['Network', network]);\n\t}\n\tif (env.sandboxes?.length === 1) {\n\t\tconst sandboxName = env.sandboxes[0];\n\t\tconst sandbox = getSandboxConfig(parsedArgs)(sandboxName);\n\t\tif (!sandbox) {\n\t\t\treturn sendAsyncErr(\n\t\t\t\t`The current environment is configured to use a sandbox called '${sandboxName}'; however, no sandbox of this name has been configured in .taq/config.json`,\n\t\t\t);\n\t\t}\n\t\treturn Promise.resolve(['Sandbox', sandbox]);\n\t}\n\treturn sendAsyncErr(targetConstraintErrMsg);\n};\n\nexport const configureToolKitForSandbox = async (sandbox: SandboxConfig.t, sender?: string): Promise<TezosToolkit> => {\n\tlet accountKey: string;\n\tif (sender && sender !== 'default') {\n\t\tconst accounts = getSandboxInstantiatedAccounts(sandbox);\n\t\tif (accounts.hasOwnProperty(sender)) {\n\t\t\taccountKey = accounts[sender].secretKey;\n\t\t} else {\n\t\t\treturn sendAsyncErr(\n\t\t\t\t`${sender} is not an account instantiated in the current environment. Check .taq/config.json`,\n\t\t\t);\n\t\t}\n\t} else {\n\t\tconst defaultAccount = getDefaultSandboxAccount(sandbox);\n\t\tif (!defaultAccount) {\n\t\t\treturn sendAsyncErr(\n\t\t\t\t`No default account is specified in the sandbox to perform the operation. Please use the --sender flag to explicitly specify the account to use as the sender of the operation`,\n\t\t\t);\n\t\t}\n\t\taccountKey = defaultAccount.secretKey;\n\t}\n\n\tconst tezos = new TezosToolkit(sandbox.rpcUrl as string);\n\ttezos.setProvider({ signer: new InMemorySigner(accountKey.replace(/^unencrypted:/, '')) });\n\treturn tezos;\n};\n\nexport const configureToolKitForNetwork = async (\n\tparsedArgs: RequestArgs.t,\n\tnetwork: NetworkConfig.t,\n\tsender?: string,\n): Promise<TezosToolkit> => {\n\tlet account: string;\n\tif (sender && sender !== TAQ_OPERATOR_ACCOUNT) {\n\t\tconst accounts = getNetworkInstantiatedAccounts(network);\n\t\tif (accounts.hasOwnProperty(sender)) {\n\t\t\taccount = sender;\n\t\t} else {\n\t\t\treturn sendAsyncErr(\n\t\t\t\t`${sender} is not an account instantiated in the current environment. Check .taq/config.json`,\n\t\t\t);\n\t\t}\n\t} else {\n\t\taccount = TAQ_OPERATOR_ACCOUNT;\n\t}\n\n\tconst tezos = new TezosToolkit(network.rpcUrl as string);\n\tconst key = await getAccountPrivateKey(parsedArgs, network, account);\n\tawait importKey(tezos, key);\n\treturn tezos;\n};\n\nexport const getDeclaredAccounts = (parsedArgs: RequestArgs.t): Record<string, number> =>\n\tObject.entries(parsedArgs.config.accounts ?? {}).reduce(\n\t\t(acc, declaredAccount) => {\n\t\t\tconst alias: string = declaredAccount[0];\n\t\t\tconst mutez: string | number = declaredAccount[1];\n\t\t\treturn {\n\t\t\t\t...acc,\n\t\t\t\t[alias]: typeof mutez === 'string' ? parseFloat(mutez) : mutez,\n\t\t\t};\n\t\t},\n\t\t{} as Record<string, number>,\n\t);\n\nexport const getSandboxInstantiatedAccounts = (sandbox: SandboxConfig.t): Record<string, SandboxAccountConfig.t> =>\n\t(sandbox?.accounts)\n\t\t? Object.entries(sandbox.accounts).reduce(\n\t\t\t(acc, instantiatedAccount) => {\n\t\t\t\tconst alias: string = instantiatedAccount[0];\n\t\t\t\tconst keys = instantiatedAccount[1];\n\t\t\t\treturn alias !== 'default'\n\t\t\t\t\t? {\n\t\t\t\t\t\t...acc,\n\t\t\t\t\t\t[alias]: keys,\n\t\t\t\t\t}\n\t\t\t\t\t: acc;\n\t\t\t},\n\t\t\t{},\n\t\t)\n\t\t: {};\n\nexport const getNetworkInstantiatedAccounts = (network: NetworkConfig.t): Record<string, any> =>\n\tnetwork.accounts\n\t\t? Object.entries(network.accounts).reduce(\n\t\t\t(acc, instantiatedAccount) => {\n\t\t\t\tconst alias: string = instantiatedAccount[0];\n\t\t\t\tconst keys = instantiatedAccount[1];\n\t\t\t\treturn alias !== TAQ_OPERATOR_ACCOUNT\n\t\t\t\t\t? {\n\t\t\t\t\t\t...acc,\n\t\t\t\t\t\t[alias]: keys,\n\t\t\t\t\t}\n\t\t\t\t\t: acc;\n\t\t\t},\n\t\t\t{},\n\t\t)\n\t\t: {};\n\nexport const generateAccountKeys = async (\n\tparsedArgs: RequestArgs.t,\n\tnetwork: NetworkConfig.t,\n\taccount: string,\n): Promise<void> => {\n\tconst tezos = new TezosToolkit(network.rpcUrl as string);\n\tconst key = await getAccountPrivateKey(parsedArgs, network, account);\n\tawait importKey(tezos, key);\n};\n\nexport const handleOpsError = (err: unknown, env: string): Promise<never> => {\n\tif (err instanceof Error) {\n\t\tconst msg = err.message;\n\t\tif (/ENOTFOUND/.test(msg)) return sendAsyncErr('The RPC URL may be invalid. Check ./.taq/config.json');\n\t\tif (/ECONNREFUSED/.test(msg)) return sendAsyncErr('The RPC URL may be down or the sandbox is not running');\n\t\tif (/empty_implicit_contract/.test(msg)) {\n\t\t\tconst result = msg.match(/(?<=\"implicit\":\")tz[^\"]+(?=\")/);\n\t\t\tconst publicKeyHash = result ? result[0] : undefined;\n\t\t\tif (publicKeyHash) {\n\t\t\t\treturn sendAsyncErr(\n\t\t\t\t\t`The account ${publicKeyHash} for the target environment, \"${env}\", may not be funded\\nTo fund this account:\\n1. Go to https://teztnets.xyz and click \"Faucet\" of the target testnet\\n2. Copy and paste the above key into the wallet address field\\n3. Request some Tez (Note that you might need to wait for a few seconds for the network to register the funds)`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn sendAsyncErr(`Error while performing operation:\\n${err} ${JSON.stringify(err, null, 2)}`);\n};\n\nexport const doWithin = async <T>(seconds: number, fn: () => Promise<T>) => {\n\tlet captured: Error = new Error(\n\t\t'Operation timed out. Please try again and perhaps increase the timeout using the --timeout option.',\n\t);\n\tlet timeout: ReturnType<typeof setTimeout>;\n\n\tconst maxTimeout = new Promise((resolve, reject) => {\n\t\ttimeout = setTimeout(() => {\n\t\t\treject(captured);\n\t\t}, seconds * 1000);\n\t}) as Promise<T>;\n\n\tconst process = async () => {\n\t\twhile (true) {\n\t\t\ttry {\n\t\t\t\tconst retval: T = await fn();\n\t\t\t\treturn retval;\n\t\t\t} catch (err) {\n\t\t\t\tcaptured = err as Error;\n\t\t\t}\n\t\t}\n\t};\n\n\treturn Promise.race<T>([process(), maxTimeout]).then(retval => {\n\t\tclearTimeout(timeout);\n\t\treturn retval;\n\t});\n};\n","import {\n\tgetAddressOfAlias,\n\tgetCurrentEnvironment,\n\tgetCurrentEnvironmentConfig,\n\tgetParameter,\n\tRequestArgs,\n\tsendAsyncErr,\n\tsendJsonRes,\n} from '@taqueria/node-sdk';\nimport { Environment } from '@taqueria/node-sdk/types';\nimport { Expr, Parser } from '@taquito/michel-codec';\nimport { TezosToolkit, WalletOperationBatch } from '@taquito/taquito';\nimport { BatchWalletOperation } from '@taquito/taquito/dist/types/wallet/batch-operation';\nimport {\n\tconfigureToolKitForNetwork,\n\tconfigureToolKitForSandbox,\n\tdoWithin,\n\tgetEnvTypeAndNodeConfig,\n\thandleOpsError,\n\tTransferOpts as Opts,\n} from './common';\n\nexport type ContractInfo = {\n\tcontractAlias: string;\n\tcontractAddress: string;\n\tparameter: string;\n\tentrypoint: string;\n\tmutezTransfer: number;\n};\n\ntype TableRow = {\n\tcontractAlias: string;\n\tcontractAddress: string;\n\tparameter: string;\n\tentrypoint: string;\n\tmutezTransfer: string;\n\tdestination: string;\n};\n\nconst isContractAddress = (contract: string): boolean =>\n\tcontract.startsWith('tz1') || contract.startsWith('tz2') || contract.startsWith('tz3') || contract.startsWith('KT1');\n\nconst getContractInfo = async (parsedArgs: Opts, env: Environment.t): Promise<ContractInfo> => {\n\tconst contract = parsedArgs.contract;\n\tconst protocolArgs = RequestArgs.create(parsedArgs);\n\treturn {\n\t\tcontractAlias: isContractAddress(contract) ? 'N/A' : contract,\n\t\tcontractAddress: isContractAddress(contract) ? contract : await getAddressOfAlias(env, contract),\n\t\tparameter: parsedArgs.param ? await getParameter(protocolArgs, parsedArgs.param) : 'Unit',\n\t\tentrypoint: parsedArgs.entrypoint ?? 'default',\n\t\tmutezTransfer: parseInt(parsedArgs.mutez ?? '0'),\n\t};\n};\n\nconst createBatchForTransfer = (tezos: TezosToolkit, contractsInfo: ContractInfo[]): WalletOperationBatch =>\n\tcontractsInfo.reduce((acc, contractInfo) =>\n\t\tacc.withTransfer({\n\t\t\tto: contractInfo.contractAddress,\n\t\t\tamount: contractInfo.mutezTransfer,\n\t\t\tparameter: {\n\t\t\t\tentrypoint: contractInfo.entrypoint,\n\t\t\t\tvalue: new Parser().parseMichelineExpression(contractInfo.parameter) as Expr,\n\t\t\t},\n\t\t\tmutez: true,\n\t\t}), tezos.wallet.batch());\n\nexport const performTransferOps = async (\n\ttezos: TezosToolkit,\n\tenv: string,\n\tcontractsInfo: ContractInfo[],\n\tmaxTimeout: number,\n): Promise<BatchWalletOperation> => {\n\tconst batch = createBatchForTransfer(tezos, contractsInfo);\n\ttry {\n\t\treturn await doWithin<BatchWalletOperation>(maxTimeout, async () => {\n\t\t\tconst op = await batch.send();\n\t\t\tawait op.confirmation();\n\t\t\treturn op;\n\t\t});\n\t} catch (err) {\n\t\treturn handleOpsError(err, env);\n\t}\n};\n\nconst prepContractInfoForDisplay = (tezos: TezosToolkit, contractInfo: ContractInfo): TableRow => {\n\treturn {\n\t\tcontractAlias: contractInfo.contractAlias,\n\t\tcontractAddress: contractInfo.contractAddress,\n\t\tparameter: contractInfo.parameter,\n\t\tentrypoint: contractInfo.entrypoint,\n\t\tmutezTransfer: contractInfo.mutezTransfer.toString(),\n\t\tdestination: tezos.rpc.getRpcUrl(),\n\t};\n};\n\nconst transfer = async (opts: Opts): Promise<void> => {\n\tconst protocolArgs = RequestArgs.create(opts);\n\tconst env = getCurrentEnvironmentConfig(protocolArgs);\n\tif (!env) return sendAsyncErr(`There is no environment called ${protocolArgs.env} in your config.json`);\n\ttry {\n\t\tconst [envType, nodeConfig] = await getEnvTypeAndNodeConfig(protocolArgs, env);\n\t\tconst tezos = await (envType === 'Network'\n\t\t\t? configureToolKitForNetwork(protocolArgs, nodeConfig, opts.sender)\n\t\t\t: configureToolKitForSandbox(nodeConfig, opts.sender));\n\n\t\tconst contractInfo = await getContractInfo(opts, env);\n\n\t\tawait performTransferOps(tezos, getCurrentEnvironment(protocolArgs), [contractInfo], opts.timeout);\n\n\t\tconst contractInfoForDisplay = prepContractInfoForDisplay(tezos, contractInfo);\n\t\treturn sendJsonRes([contractInfoForDisplay]);\n\t} catch {\n\t\treturn sendAsyncErr('No operations performed');\n\t}\n};\n\nexport default transfer;\n","import { getCurrentEnvironmentConfig, RequestArgs, sendAsyncErr, sendJsonRes, sendWarn } from '@taqueria/node-sdk';\nimport {\n\tgenerateAccountKeys,\n\tgetDeclaredAccounts,\n\tgetEnvTypeAndNodeConfig,\n\tgetNetworkInstantiatedAccounts,\n} from './common';\n\nconst instantiate_account = async (parsedArgs: RequestArgs.t): Promise<void> => {\n\tconst env = getCurrentEnvironmentConfig(parsedArgs);\n\tif (!env) return sendAsyncErr(`There is no environment called ${parsedArgs.env} in your config.json`);\n\ttry {\n\t\tconst [envType, nodeConfig] = await getEnvTypeAndNodeConfig(parsedArgs, env);\n\t\tif (envType !== 'Network') {\n\t\t\treturn sendAsyncErr('taq instantiate-account can only be executed in a network environment');\n\t\t}\n\n\t\tconst declaredAccountAliases = Object.keys(getDeclaredAccounts(parsedArgs));\n\t\tconst instantiatedAccounts = getNetworkInstantiatedAccounts(nodeConfig);\n\n\t\tlet accountsInstantiated = [];\n\t\tfor (const declaredAccountAlias of declaredAccountAliases) {\n\t\t\tif (!instantiatedAccounts.hasOwnProperty(declaredAccountAlias)) {\n\t\t\t\tawait generateAccountKeys(parsedArgs, nodeConfig, declaredAccountAlias);\n\t\t\t\taccountsInstantiated.push(declaredAccountAlias);\n\t\t\t} else {\n\t\t\t\tsendWarn(\n\t\t\t\t\t`Note: ${declaredAccountAlias} is already instantiated in the current environment, \"${parsedArgs.env}\"`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (accountsInstantiated.length !== 0) {\n\t\t\treturn sendJsonRes(\n\t\t\t\t`Accounts instantiated: ${\n\t\t\t\t\taccountsInstantiated.join(', ')\n\t\t\t\t}.\\nPlease execute \"taq fund\" targeting the same environment to fund these accounts`,\n\t\t\t);\n\t\t} else {\n\t\t\treturn sendJsonRes(\n\t\t\t\t`No accounts were instantiated because they were all instantiated in the target environment already`,\n\t\t\t);\n\t\t}\n\t} catch (err) {\n\t\tawait sendAsyncErr('No operations performed');\n\t\tif (parsedArgs.debug) await sendAsyncErr(String(err));\n\t}\n};\n\nexport default instantiate_account;\n","import {\n\taddTzExtensionIfMissing,\n\tgetArtifactsDir,\n\tgetContractContent,\n\tgetCurrentEnvironment,\n\tgetCurrentEnvironmentConfig,\n\tNonEmptyString,\n\tRequestArgs,\n\tsendAsyncErr,\n\tsendErr,\n\tsendJsonRes,\n\tupdateAddressAlias,\n} from '@taqueria/node-sdk';\nimport { OperationContentsAndResultOrigination } from '@taquito/rpc';\nimport { TezosToolkit, WalletOperationBatch } from '@taquito/taquito';\nimport { BatchWalletOperation } from '@taquito/taquito/dist/types/wallet/batch-operation';\nimport { basename, extname, join } from 'path';\nimport {\n\tconfigureToolKitForNetwork,\n\tconfigureToolKitForSandbox,\n\tdoWithin,\n\tgetEnvTypeAndNodeConfig,\n\thandleOpsError,\n\tOriginateOpts as Opts,\n} from './common';\n\ntype ContractInfo = {\n\tcontract: string;\n\tcode: string;\n\tinitStorage: string;\n\tmutezTransfer: number;\n};\n\ntype TableRow = {\n\tcontract: string;\n\taddress: string;\n\talias: string;\n\tbalanceInMutez: string;\n\tdestination: string;\n};\n\nconst getContractPath = (parsedArgs: RequestArgs.t, contractFilename: string) =>\n\tjoin(getArtifactsDir(parsedArgs), /\\.tz$/.test(contractFilename) ? contractFilename : `${contractFilename}.tz`);\n\nconst getDefaultStorageFilename = (contractName: string): string => {\n\tconst baseFilename = basename(contractName, extname(contractName));\n\tconst extFilename = extname(contractName);\n\tconst defaultStorage = `${baseFilename}.default_storage${extFilename}`;\n\treturn defaultStorage;\n};\n\nconst getContractInfo = async (parsedArgs: Opts): Promise<ContractInfo> => {\n\tconst contract = parsedArgs.contract;\n\tconst protocolArgs = RequestArgs.create(parsedArgs);\n\tconst contractWithTzExtension = addTzExtensionIfMissing(contract);\n\tconst contractCode = await getContractContent(protocolArgs, contractWithTzExtension);\n\tif (contractCode === undefined) {\n\t\treturn sendAsyncErr(\n\t\t\t`Please generate ${contractWithTzExtension} with one of the compilers (LIGO, SmartPy, Archetype) or write it manually and put it under /${parsedArgs.config.artifactsDir}\\n`,\n\t\t);\n\t}\n\n\tconst storageFilename = parsedArgs.storage ?? getDefaultStorageFilename(contractWithTzExtension);\n\tconst contractInitStorage = await getContractContent(protocolArgs, storageFilename);\n\tif (contractInitStorage === undefined) {\n\t\treturn sendAsyncErr(\n\t\t\t`❌ No initial storage file was found for ${contractWithTzExtension}\\nStorage must be specified in a file as a Michelson expression and will automatically be linked to this contract if specified with the name \"${\n\t\t\t\tgetDefaultStorageFilename(contractWithTzExtension)\n\t\t\t}\" in the artifacts directory\\nYou can also manually pass a storage file to the originate task using the --storage STORAGE_FILE_NAME option\\n`,\n\t\t);\n\t}\n\n\treturn {\n\t\tcontract,\n\t\tcode: contractCode,\n\t\tinitStorage: contractInitStorage,\n\t\tmutezTransfer: parseInt(parsedArgs.mutez ?? '0'),\n\t};\n};\n\nconst createBatchForOriginate = (tezos: TezosToolkit, contractsInfo: ContractInfo[]): WalletOperationBatch =>\n\tcontractsInfo.reduce((acc, contractInfo) =>\n\t\tacc.withOrigination({\n\t\t\tcode: contractInfo.code,\n\t\t\tinit: contractInfo.initStorage,\n\t\t\tbalance: contractInfo.mutezTransfer.toString(),\n\t\t\tmutez: true,\n\t\t}), tezos.wallet.batch());\n\nexport const performOriginateOps = async (\n\ttezos: TezosToolkit,\n\tenv: string,\n\tcontractsInfo: ContractInfo[],\n\tmaxTimeout: number,\n): Promise<BatchWalletOperation> => {\n\tconst batch = createBatchForOriginate(tezos, contractsInfo);\n\ttry {\n\t\treturn await doWithin<BatchWalletOperation>(maxTimeout, async () => {\n\t\t\tconst op = await batch.send();\n\t\t\tawait op.confirmation();\n\t\t\treturn op;\n\t\t});\n\t} catch (err) {\n\t\treturn handleOpsError(err, env);\n\t}\n};\n\nconst prepContractInfoForDisplay = async (\n\tparsedArgs: Opts,\n\ttezos: TezosToolkit,\n\tcontractInfo: ContractInfo,\n\top: BatchWalletOperation,\n): Promise<TableRow> => {\n\tconst protocolArgs = RequestArgs.create(parsedArgs);\n\tconst operationResults = await op.operationResults();\n\tconst originationResults = (operationResults ?? [])\n\t\t.filter(result => result.kind === 'origination')\n\t\t.map(result => result as OperationContentsAndResultOrigination);\n\n\t// Length should be 1 since we are batching originate operations into one\n\tconst result = originationResults.length === 1 ? originationResults[0] : undefined;\n\tconst address = result?.metadata?.operation_result?.originated_contracts?.join(',');\n\tconst alias = parsedArgs.alias ?? basename(contractInfo.contract, extname(contractInfo.contract));\n\n\tconst displayableAddress = address ?? 'Something went wrong during origination';\n\n\tif (address) {\n\t\tconst validatedAddress = NonEmptyString.create(address);\n\t\tawait updateAddressAlias(protocolArgs, alias, validatedAddress);\n\t}\n\n\treturn {\n\t\tcontract: contractInfo.contract,\n\t\taddress: displayableAddress,\n\t\talias: address ? alias : 'N/A',\n\t\tbalanceInMutez: contractInfo.mutezTransfer.toString(),\n\t\tdestination: tezos.rpc.getRpcUrl(),\n\t};\n};\n\nconst originate = async (parsedArgs: Opts): Promise<void> => {\n\tconst protocolArgs = RequestArgs.create(parsedArgs);\n\tconst env = getCurrentEnvironmentConfig(protocolArgs);\n\tif (!env) return sendAsyncErr(`There is no environment called ${parsedArgs.env} in your config.json`);\n\ttry {\n\t\tconst [envType, nodeConfig] = await getEnvTypeAndNodeConfig(protocolArgs, env);\n\t\tconst tezos = await (envType === 'Network'\n\t\t\t? configureToolKitForNetwork(protocolArgs, nodeConfig, parsedArgs.sender)\n\t\t\t: configureToolKitForSandbox(nodeConfig, parsedArgs.sender));\n\n\t\tconst contractInfo = await getContractInfo(parsedArgs);\n\n\t\tconst op = await performOriginateOps(\n\t\t\ttezos,\n\t\t\tgetCurrentEnvironment(protocolArgs),\n\t\t\t[contractInfo],\n\t\t\tparsedArgs.timeout,\n\t\t);\n\n\t\tconst contractInfoForDisplay = await prepContractInfoForDisplay(parsedArgs, tezos, contractInfo, op);\n\t\treturn sendJsonRes([contractInfoForDisplay]);\n\t} catch {\n\t\treturn sendAsyncErr('No operations performed');\n\t}\n};\n\nexport default originate;\n"],"mappings":";;;AAAA,IAAAA,mBAAqC;;;ACArC,IAAAC,mBAA0C;;;ACA1C,IAAAC,mBAOO;;;ACPP,sBASO;AASP,oBAA0C;AAC1C,qBAA6B;AAgCtB,IAAM,0BAA0B,CACtC,YACA,QAC0E;AAtD3E;AAuDC,QAAM,yBAAyB;AAC/B,QAAI,SAAI,aAAJ,mBAAc,YAAW,OAAK,SAAI,cAAJ,mBAAe,YAAW;AAAG,eAAO,8BAAa,sBAAsB;AACzG,QAAI,SAAI,aAAJ,mBAAc,YAAW,GAAG;AAC/B,UAAM,cAAc,IAAI,SAAS;AACjC,UAAM,cAAU,kCAAiB,UAAU,EAAE,WAAW;AACxD,QAAI,CAAC,SAAS;AACb,iBAAO;AAAA,QACN,kEAAkE;AAAA,MACnE;AAAA,IACD;AACA,WAAO,QAAQ,QAAQ,CAAC,WAAW,OAAO,CAAC;AAAA,EAC5C;AACA,QAAI,S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b,MAAM;AAAA,UACN,aAAa;AAAA,UACb,UAAU;AAAA,QACX,CAAC;AAAA,QACD,wBAAO,OAAO;AAAA,UACb,MAAM;AAAA,UACN,WAAW;AAAA,UACX,cAAc;AAAA,UACd,aAAa;AAAA,UACb,UAAU;AAAA,QACX,CAAC;AAAA,MACF;AAAA,MACA,SAAS,CAAC,MAAM;AAAA,MAChB,SAAS;AAAA,MACT,UAAU;AAAA,IACX,CAAC;AAAA,IACD,sBAAK,OAAO;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,MACb,SAAS;AAAA,MACT,UAAU;AAAA,MACV,SAAS;AAAA,QACR,wBAAO,OAAO;AAAA,UACb,MAAM;AAAA,UACN,WAAW;AAAA,UACX,cAAc;AAAA,UACd,aAAa;AAAA,UACb,UAAU;AAAA,QACX,CAAC;AAAA,MACF;AAAA,IACD,CAAC;AAAA,IACD,sBAAK,OAAO;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aACC;AAAA,MACD,SAAS;AAAA,MACT,UAAU;AAAA,IACX,CAAC;AAAA,EACF;AAAA,EACA,OAAO;AACR,IAAI,QAAQ,IAAI;","names":["import_node_sdk","import_node_sdk","import_node_sdk","process","import_node_sdk","import_node_sdk","import_node_sdk","getContractInfo","prepContractInfoForDisplay","result"]}
1
+ {"version":3,"sources":["index.ts","main.ts","fund.ts","common.ts","transfer.ts","instantiate_account.ts","originate.ts"],"sourcesContent":["import { Option, Plugin, Task } from '@taqueria/node-sdk';\nimport main from './main';\n\nPlugin.create(_i18n => ({\n\talias: 'taquito',\n\tschema: '1.0',\n\tversion: '0.1',\n\ttasks: [\n\t\tTask.create({\n\t\t\ttask: 'deploy',\n\t\t\tcommand: 'deploy <contract>',\n\t\t\tdescription: 'Deploy a smart contract to a particular environment',\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'alias',\n\t\t\t\t\tdescription: \"Alias used to refer to the deployed contract's address\",\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'storage',\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'Name of the storage file that contains the storage value as a Michelson expression, in the artifacts directory, used for originating a contract',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'sender',\n\t\t\t\t\tdescription: 'Name of an instantiated account to use as the sender of the originate operation',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'mutez',\n\t\t\t\t\tdescription: 'Amount of Mutez to transfer',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'timeout',\n\t\t\t\t\tshortFlag: 't',\n\t\t\t\t\tdefaultValue: 40,\n\t\t\t\t\tdescription: 'Number of retry attempts (to avoid congestion and network failures)',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t],\n\t\t\taliases: ['originate'],\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'application/json',\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'transfer',\n\t\t\tcommand: 'transfer <contract>',\n\t\t\tdescription:\n\t\t\t\t'Transfer/call an implicit account or a smart contract (specified via its alias or address) deployed to a particular environment',\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'mutez',\n\t\t\t\t\tdescription: 'Amount of Mutez to transfer',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'param',\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'Name of the parameter file that contains the parameter value as a Michelson expression, in the artifacts directory, used for invoking a deployed contract',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'entrypoint',\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'You may explicitly specify an entrypoint to make the parameter value shorter, without having to specify a chain of (Left (Right ... 14 ...))',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'sender',\n\t\t\t\t\tdescription: 'Name of an instantiated account to use as the sender of the transfer operation',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'timeout',\n\t\t\t\t\tshortFlag: 't',\n\t\t\t\t\tdefaultValue: 40,\n\t\t\t\t\tdescription: 'Number of retry attempts (to avoid congestion and network failures)',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t],\n\t\t\taliases: ['call'],\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'application/json',\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'fund',\n\t\t\tcommand: 'fund',\n\t\t\tdescription: 'Fund all the instantiated accounts up to the desired/declared amount in a target environment',\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'application/json',\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'timeout',\n\t\t\t\t\tshortFlag: 't',\n\t\t\t\t\tdefaultValue: 40,\n\t\t\t\t\tdescription: 'Number of retry attempts (to avoid congestion and network failures)',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t],\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'instantiate-account',\n\t\t\tcommand: 'instantiate-account',\n\t\t\tdescription:\n\t\t\t\t'Instantiate all accounts declared in the \"accounts\" field at the root level of the config file to a target environment',\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'application/json',\n\t\t}),\n\t],\n\tproxy: main,\n}), process.argv);\n","import { RequestArgs, sendAsyncErr } from '@taqueria/node-sdk';\nimport { IntersectionOpts as Opts } from './common';\nimport fund from './fund';\nimport instantiate_account from './instantiate_account';\nimport originate from './originate';\nimport transfer from './transfer';\n\nexport const main = (parsedArgs: RequestArgs.t): Promise<void> => {\n\tconst unsafeArgs = parsedArgs as unknown as Opts;\n\tswitch (unsafeArgs.task) {\n\t\tcase 'deploy':\n\t\t\treturn originate(unsafeArgs);\n\t\tcase 'transfer':\n\t\t\treturn transfer(unsafeArgs);\n\t\tcase 'instantiate-account':\n\t\t\treturn instantiate_account(parsedArgs);\n\t\tcase 'fund':\n\t\t\treturn fund(unsafeArgs);\n\t\tdefault:\n\t\t\treturn sendAsyncErr(`${unsafeArgs} is not an understood task by the Taquito plugin`);\n\t}\n};\n\nexport default main;\n","import {\n\tgetCurrentEnvironment,\n\tgetCurrentEnvironmentConfig,\n\tRequestArgs,\n\tsendAsyncErr,\n\tsendJsonRes,\n\tsendWarn,\n} from '@taqueria/node-sdk';\nimport { TezosToolkit } from '@taquito/taquito';\nimport {\n\tconfigureToolKitForNetwork,\n\tFundOpts,\n\tFundOpts as Opts,\n\tgetDeclaredAccounts,\n\tgetEnvTypeAndNodeConfig,\n\tgetNetworkInstantiatedAccounts,\n} from './common';\nimport { ContractInfo, performTransferOps } from './transfer';\n\ntype TableRow = {\n\taccountAlias: string;\n\taccountAddress: string;\n\tmutezFunded: string;\n};\n\nconst getAccountsInfo = (\n\tparsedArgs: RequestArgs.t,\n\ttezos: TezosToolkit,\n\tinstantiatedAccounts: Record<string, any>,\n): Promise<ContractInfo[]> =>\n\tPromise.all(\n\t\tObject.entries(instantiatedAccounts)\n\t\t\t.map(async (instantiatedAccount: [string, any]) => {\n\t\t\t\tconst alias = instantiatedAccount[0];\n\t\t\t\tconst aliasInfo = instantiatedAccount[1];\n\n\t\t\t\tconst declaredMutez: number | undefined = getDeclaredAccounts(parsedArgs)[alias];\n\t\t\t\tconst currentBalanceInMutez = (await tezos.tz.getBalance(aliasInfo.publicKeyHash)).toNumber();\n\t\t\t\tconst amountToFillInMutez = declaredMutez ? Math.max(declaredMutez - currentBalanceInMutez, 0) : 0;\n\n\t\t\t\tif (!declaredMutez) {\n\t\t\t\t\tsendWarn(\n\t\t\t\t\t\t`Warning: ${alias} is instantiated in the target environment but not declared in the root level \"accounts\" field of ./.taq/config.json so ${alias} will not be funded as you don't have a declared tez amount set there for ${alias}\\n`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tcontractAlias: alias,\n\t\t\t\t\tcontractAddress: aliasInfo.publicKeyHash,\n\t\t\t\t\tparameter: 'Unit',\n\t\t\t\t\tentrypoint: 'default',\n\t\t\t\t\tmutezTransfer: parseInt(amountToFillInMutez.toString()),\n\t\t\t\t};\n\t\t\t}),\n\t)\n\t\t.then(accountsInfo => accountsInfo.filter(accountInfo => accountInfo.mutezTransfer !== 0))\n\t\t.catch(err => sendAsyncErr(`Something went wrong while extracting account information - ${err}`));\n\nconst prepAccountsInfoForDisplay = (accountsInfo: ContractInfo[]): TableRow[] =>\n\taccountsInfo.map(accountInfo => {\n\t\treturn {\n\t\t\taccountAlias: accountInfo.contractAlias,\n\t\t\taccountAddress: accountInfo.contractAddress,\n\t\t\tmutezFunded: accountInfo.mutezTransfer.toString(),\n\t\t};\n\t});\n\nconst fund = async (parsedArgs: FundOpts): Promise<void> => {\n\tconst env = getCurrentEnvironmentConfig(parsedArgs);\n\tif (!env) return sendAsyncErr(`There is no environment called ${parsedArgs.env} in your config.json`);\n\ttry {\n\t\tconst [envType, nodeConfig] = await getEnvTypeAndNodeConfig(parsedArgs, env);\n\t\tif (envType !== 'Network') return sendAsyncErr('taq fund can only be executed in a network environment');\n\t\tconst tezos = await configureToolKitForNetwork(parsedArgs, nodeConfig);\n\n\t\tconst instantiatedAccounts = getNetworkInstantiatedAccounts(nodeConfig);\n\n\t\tconst accountsInfo = await getAccountsInfo(parsedArgs, tezos, instantiatedAccounts);\n\t\tif (accountsInfo.length === 0) {\n\t\t\treturn sendJsonRes(\n\t\t\t\t`All instantiated accounts in the current environment, \"${parsedArgs.env}\", are funded up to or beyond the declared amount`,\n\t\t\t);\n\t\t}\n\n\t\tawait performTransferOps(tezos, getCurrentEnvironment(parsedArgs), accountsInfo, parsedArgs.timeout);\n\n\t\tconst accountsInfoForDisplay = prepAccountsInfoForDisplay(accountsInfo);\n\t\treturn sendJsonRes(accountsInfoForDisplay);\n\t} catch {\n\t\treturn sendAsyncErr('No operations performed');\n\t}\n};\n\nexport default fund;\n","import {\n\tgetAccountPrivateKey,\n\tgetDefaultSandboxAccount,\n\tgetNetworkConfig,\n\tgetSandboxConfig,\n\tRequestArgs,\n\tsendAsyncErr,\n\tsendErr,\n\tTAQ_OPERATOR_ACCOUNT,\n} from '@taqueria/node-sdk';\nimport {\n\tEnvironment,\n\tNetworkConfig,\n\tProtocol,\n\tProxyTaskArgs,\n\tSandboxAccountConfig,\n\tSandboxConfig,\n} from '@taqueria/node-sdk/types';\nimport { importKey, InMemorySigner } from '@taquito/signer';\nimport { TezosToolkit } from '@taquito/taquito';\n\nexport type OriginateOpts = ProxyTaskArgs.t & {\n\tcontract: string;\n\tstorage: string;\n\talias?: string;\n\tsender?: string;\n\tmutez?: string;\n\ttimeout: number;\n};\n\nexport type TransferOpts = ProxyTaskArgs.t & {\n\tcontract: string;\n\tmutez?: string;\n\tparam?: string;\n\tentrypoint?: string;\n\tsender?: string;\n\ttimeout: number;\n};\n\nexport type FundOpts = ProxyTaskArgs.t & {\n\ttimeout: number;\n};\n\nexport type InstantiateAccountOpts = ProxyTaskArgs.t;\n\n// To be used for the main entrypoint of the plugin\nexport type IntersectionOpts = OriginateOpts & TransferOpts & InstantiateAccountOpts & FundOpts;\n\n// To be used for common functions in this file\ntype UnionOpts = OriginateOpts | TransferOpts | InstantiateAccountOpts | FundOpts;\n\nexport const getEnvTypeAndNodeConfig = (\n\tparsedArgs: RequestArgs.t,\n\tenv: Environment.t,\n): Promise<['Network', NetworkConfig.t] | ['Sandbox', SandboxConfig.t]> => {\n\tconst targetConstraintErrMsg = 'Each environment can only have one target, be it a network or a sandbox';\n\tif (env.networks?.length === 1 && env.sandboxes?.length === 1) return sendAsyncErr(targetConstraintErrMsg);\n\tif (env.networks?.length === 1) {\n\t\tconst networkName = env.networks[0];\n\t\tconst network = getNetworkConfig(parsedArgs)(networkName);\n\t\tif (!network) {\n\t\t\treturn sendAsyncErr(\n\t\t\t\t`The current environment is configured to use a network called '${networkName}'; however, no network of this name has been configured in .taq/config.json`,\n\t\t\t);\n\t\t}\n\t\treturn Promise.resolve(['Network', network]);\n\t}\n\tif (env.sandboxes?.length === 1) {\n\t\tconst sandboxName = env.sandboxes[0];\n\t\tconst sandbox = getSandboxConfig(parsedArgs)(sandboxName);\n\t\tif (!sandbox) {\n\t\t\treturn sendAsyncErr(\n\t\t\t\t`The current environment is configured to use a sandbox called '${sandboxName}'; however, no sandbox of this name has been configured in .taq/config.json`,\n\t\t\t);\n\t\t}\n\t\treturn Promise.resolve(['Sandbox', sandbox]);\n\t}\n\treturn sendAsyncErr(targetConstraintErrMsg);\n};\n\nexport const configureToolKitForSandbox = async (sandbox: SandboxConfig.t, sender?: string): Promise<TezosToolkit> => {\n\tlet accountKey: string;\n\tif (sender && sender !== 'default') {\n\t\tconst accounts = getSandboxInstantiatedAccounts(sandbox);\n\t\tif (accounts.hasOwnProperty(sender)) {\n\t\t\taccountKey = accounts[sender].secretKey;\n\t\t} else {\n\t\t\treturn sendAsyncErr(\n\t\t\t\t`${sender} is not an account instantiated in the current environment. Check .taq/config.json`,\n\t\t\t);\n\t\t}\n\t} else {\n\t\tconst defaultAccount = getDefaultSandboxAccount(sandbox);\n\t\tif (!defaultAccount) {\n\t\t\treturn sendAsyncErr(\n\t\t\t\t`No default account is specified in the sandbox to perform the operation. Please use the --sender flag to explicitly specify the account to use as the sender of the operation`,\n\t\t\t);\n\t\t}\n\t\taccountKey = defaultAccount.secretKey;\n\t}\n\n\tconst tezos = new TezosToolkit(sandbox.rpcUrl as string);\n\ttezos.setProvider({ signer: new InMemorySigner(accountKey.replace(/^unencrypted:/, '')) });\n\treturn tezos;\n};\n\nexport const configureToolKitForNetwork = async (\n\tparsedArgs: RequestArgs.t,\n\tnetwork: NetworkConfig.t,\n\tsender?: string,\n): Promise<TezosToolkit> => {\n\tlet account: string;\n\tif (sender && sender !== TAQ_OPERATOR_ACCOUNT) {\n\t\tconst accounts = getNetworkInstantiatedAccounts(network);\n\t\tif (accounts.hasOwnProperty(sender)) {\n\t\t\taccount = sender;\n\t\t} else {\n\t\t\treturn sendAsyncErr(\n\t\t\t\t`${sender} is not an account instantiated in the current environment. Check .taq/config.json`,\n\t\t\t);\n\t\t}\n\t} else {\n\t\taccount = TAQ_OPERATOR_ACCOUNT;\n\t}\n\n\tconst tezos = new TezosToolkit(network.rpcUrl as string);\n\tconst key = await getAccountPrivateKey(parsedArgs, network, account);\n\tawait importKey(tezos, key);\n\treturn tezos;\n};\n\nexport const getDeclaredAccounts = (parsedArgs: RequestArgs.t): Record<string, number> =>\n\tObject.entries(parsedArgs.config.accounts ?? {}).reduce(\n\t\t(acc, declaredAccount) => {\n\t\t\tconst alias: string = declaredAccount[0];\n\t\t\tconst mutez: string | number = declaredAccount[1];\n\t\t\treturn {\n\t\t\t\t...acc,\n\t\t\t\t[alias]: typeof mutez === 'string' ? parseFloat(mutez) : mutez,\n\t\t\t};\n\t\t},\n\t\t{} as Record<string, number>,\n\t);\n\nexport const getSandboxInstantiatedAccounts = (sandbox: SandboxConfig.t): Record<string, SandboxAccountConfig.t> =>\n\t(sandbox?.accounts)\n\t\t? Object.entries(sandbox.accounts).reduce(\n\t\t\t(acc, instantiatedAccount) => {\n\t\t\t\tconst alias: string = instantiatedAccount[0];\n\t\t\t\tconst keys = instantiatedAccount[1];\n\t\t\t\treturn alias !== 'default'\n\t\t\t\t\t? {\n\t\t\t\t\t\t...acc,\n\t\t\t\t\t\t[alias]: keys,\n\t\t\t\t\t}\n\t\t\t\t\t: acc;\n\t\t\t},\n\t\t\t{},\n\t\t)\n\t\t: {};\n\nexport const getNetworkInstantiatedAccounts = (network: NetworkConfig.t): Record<string, any> =>\n\tnetwork.accounts\n\t\t? Object.entries(network.accounts).reduce(\n\t\t\t(acc, instantiatedAccount) => {\n\t\t\t\tconst alias: string = instantiatedAccount[0];\n\t\t\t\tconst keys = instantiatedAccount[1];\n\t\t\t\treturn alias !== TAQ_OPERATOR_ACCOUNT\n\t\t\t\t\t? {\n\t\t\t\t\t\t...acc,\n\t\t\t\t\t\t[alias]: keys,\n\t\t\t\t\t}\n\t\t\t\t\t: acc;\n\t\t\t},\n\t\t\t{},\n\t\t)\n\t\t: {};\n\nexport const generateAccountKeys = async (\n\tparsedArgs: RequestArgs.t,\n\tnetwork: NetworkConfig.t,\n\taccount: string,\n): Promise<void> => {\n\tconst tezos = new TezosToolkit(network.rpcUrl as string);\n\tconst key = await getAccountPrivateKey(parsedArgs, network, account);\n\tawait importKey(tezos, key);\n};\n\nexport const handleOpsError = (err: unknown, env: string): Promise<never> => {\n\tif (err instanceof Error) {\n\t\tconst msg = err.message;\n\t\tif (/ENOTFOUND/.test(msg)) return sendAsyncErr('The RPC URL may be invalid. Check ./.taq/config.json');\n\t\tif (/ECONNREFUSED/.test(msg)) return sendAsyncErr('The RPC URL may be down or the sandbox is not running');\n\t\tif (/empty_implicit_contract/.test(msg)) {\n\t\t\tconst result = msg.match(/(?<=\"implicit\":\")tz[^\"]+(?=\")/);\n\t\t\tconst publicKeyHash = result ? result[0] : undefined;\n\t\t\tif (publicKeyHash) {\n\t\t\t\treturn sendAsyncErr(\n\t\t\t\t\t`The account ${publicKeyHash} for the target environment, \"${env}\", may not be funded\\nTo fund this account:\\n1. Go to https://teztnets.xyz and click \"Faucet\" of the target testnet\\n2. Copy and paste the above key into the wallet address field\\n3. Request some Tez (Note that you might need to wait for a few seconds for the network to register the funds)`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn sendAsyncErr(`Error while performing operation:\\n${err} ${JSON.stringify(err, null, 2)}`);\n};\n\nexport const doWithin = async <T>(seconds: number, fn: () => Promise<T>) => {\n\tlet captured: Error = new Error(\n\t\t'Operation timed out. Please try again and perhaps increase the timeout using the --timeout option.',\n\t);\n\tlet timeout: ReturnType<typeof setTimeout>;\n\n\tconst maxTimeout = new Promise((resolve, reject) => {\n\t\ttimeout = setTimeout(() => {\n\t\t\treject(captured);\n\t\t}, seconds * 1000);\n\t}) as Promise<T>;\n\n\tconst process = async () => {\n\t\twhile (true) {\n\t\t\ttry {\n\t\t\t\tconst retval: T = await fn();\n\t\t\t\treturn retval;\n\t\t\t} catch (err) {\n\t\t\t\tcaptured = err as Error;\n\t\t\t}\n\t\t}\n\t};\n\n\treturn Promise.race<T>([process(), maxTimeout]).then(retval => {\n\t\tclearTimeout(timeout);\n\t\treturn retval;\n\t});\n};\n","import {\n\tgetAddressOfAlias,\n\tgetCurrentEnvironment,\n\tgetCurrentEnvironmentConfig,\n\tgetParameter,\n\tRequestArgs,\n\tsendAsyncErr,\n\tsendJsonRes,\n} from '@taqueria/node-sdk';\nimport { Environment } from '@taqueria/node-sdk/types';\nimport { Expr, Parser } from '@taquito/michel-codec';\nimport { TezosToolkit, WalletOperationBatch } from '@taquito/taquito';\nimport { BatchWalletOperation } from '@taquito/taquito/dist/types/wallet/batch-operation';\nimport {\n\tconfigureToolKitForNetwork,\n\tconfigureToolKitForSandbox,\n\tdoWithin,\n\tgetEnvTypeAndNodeConfig,\n\thandleOpsError,\n\tTransferOpts as Opts,\n} from './common';\n\nexport type ContractInfo = {\n\tcontractAlias: string;\n\tcontractAddress: string;\n\tparameter: string;\n\tentrypoint: string;\n\tmutezTransfer: number;\n};\n\ntype TableRow = {\n\tcontractAlias: string;\n\tcontractAddress: string;\n\tparameter: string;\n\tentrypoint: string;\n\tmutezTransfer: string;\n\tdestination: string;\n};\n\nconst isContractAddress = (contract: string): boolean =>\n\tcontract.startsWith('tz1') || contract.startsWith('tz2') || contract.startsWith('tz3') || contract.startsWith('KT1');\n\nconst getContractInfo = async (parsedArgs: Opts, env: Environment.t): Promise<ContractInfo> => {\n\tconst contract = parsedArgs.contract;\n\tconst protocolArgs = RequestArgs.create(parsedArgs);\n\treturn {\n\t\tcontractAlias: isContractAddress(contract) ? 'N/A' : contract,\n\t\tcontractAddress: isContractAddress(contract) ? contract : await getAddressOfAlias(env, contract),\n\t\tparameter: parsedArgs.param ? await getParameter(protocolArgs, parsedArgs.param) : 'Unit',\n\t\tentrypoint: parsedArgs.entrypoint ?? 'default',\n\t\tmutezTransfer: parseInt(parsedArgs.mutez ?? '0'),\n\t};\n};\n\nconst createBatchForTransfer = (tezos: TezosToolkit, contractsInfo: ContractInfo[]): WalletOperationBatch =>\n\tcontractsInfo.reduce((acc, contractInfo) =>\n\t\tacc.withTransfer({\n\t\t\tto: contractInfo.contractAddress,\n\t\t\tamount: contractInfo.mutezTransfer,\n\t\t\tparameter: {\n\t\t\t\tentrypoint: contractInfo.entrypoint,\n\t\t\t\tvalue: new Parser().parseMichelineExpression(contractInfo.parameter) as Expr,\n\t\t\t},\n\t\t\tmutez: true,\n\t\t}), tezos.wallet.batch());\n\nexport const performTransferOps = async (\n\ttezos: TezosToolkit,\n\tenv: string,\n\tcontractsInfo: ContractInfo[],\n\tmaxTimeout: number,\n): Promise<BatchWalletOperation> => {\n\tconst batch = createBatchForTransfer(tezos, contractsInfo);\n\ttry {\n\t\treturn await doWithin<BatchWalletOperation>(maxTimeout, async () => {\n\t\t\tconst op = await batch.send();\n\t\t\tawait op.confirmation();\n\t\t\treturn op;\n\t\t});\n\t} catch (err) {\n\t\treturn handleOpsError(err, env);\n\t}\n};\n\nconst prepContractInfoForDisplay = (tezos: TezosToolkit, contractInfo: ContractInfo): TableRow => {\n\treturn {\n\t\tcontractAlias: contractInfo.contractAlias,\n\t\tcontractAddress: contractInfo.contractAddress,\n\t\tparameter: contractInfo.parameter,\n\t\tentrypoint: contractInfo.entrypoint,\n\t\tmutezTransfer: contractInfo.mutezTransfer.toString(),\n\t\tdestination: tezos.rpc.getRpcUrl(),\n\t};\n};\n\nconst transfer = async (opts: Opts): Promise<void> => {\n\tconst protocolArgs = RequestArgs.create(opts);\n\tconst env = getCurrentEnvironmentConfig(protocolArgs);\n\tif (!env) return sendAsyncErr(`There is no environment called ${protocolArgs.env} in your config.json`);\n\ttry {\n\t\tconst [envType, nodeConfig] = await getEnvTypeAndNodeConfig(protocolArgs, env);\n\t\tconst tezos = await (envType === 'Network'\n\t\t\t? configureToolKitForNetwork(protocolArgs, nodeConfig, opts.sender)\n\t\t\t: configureToolKitForSandbox(nodeConfig, opts.sender));\n\n\t\tconst contractInfo = await getContractInfo(opts, env);\n\n\t\tawait performTransferOps(tezos, getCurrentEnvironment(protocolArgs), [contractInfo], opts.timeout);\n\n\t\tconst contractInfoForDisplay = prepContractInfoForDisplay(tezos, contractInfo);\n\t\treturn sendJsonRes([contractInfoForDisplay]);\n\t} catch {\n\t\treturn sendAsyncErr('No operations performed');\n\t}\n};\n\nexport default transfer;\n","import { getCurrentEnvironmentConfig, RequestArgs, sendAsyncErr, sendJsonRes, sendWarn } from '@taqueria/node-sdk';\nimport {\n\tgenerateAccountKeys,\n\tgetDeclaredAccounts,\n\tgetEnvTypeAndNodeConfig,\n\tgetNetworkInstantiatedAccounts,\n} from './common';\n\nconst instantiate_account = async (parsedArgs: RequestArgs.t): Promise<void> => {\n\tconst env = getCurrentEnvironmentConfig(parsedArgs);\n\tif (!env) return sendAsyncErr(`There is no environment called ${parsedArgs.env} in your config.json`);\n\ttry {\n\t\tconst [envType, nodeConfig] = await getEnvTypeAndNodeConfig(parsedArgs, env);\n\t\tif (envType !== 'Network') {\n\t\t\treturn sendAsyncErr('taq instantiate-account can only be executed in a network environment');\n\t\t}\n\n\t\tconst declaredAccountAliases = Object.keys(getDeclaredAccounts(parsedArgs));\n\t\tconst instantiatedAccounts = getNetworkInstantiatedAccounts(nodeConfig);\n\n\t\tlet accountsInstantiated = [];\n\t\tfor (const declaredAccountAlias of declaredAccountAliases) {\n\t\t\tif (!instantiatedAccounts.hasOwnProperty(declaredAccountAlias)) {\n\t\t\t\tawait generateAccountKeys(parsedArgs, nodeConfig, declaredAccountAlias);\n\t\t\t\taccountsInstantiated.push(declaredAccountAlias);\n\t\t\t} else {\n\t\t\t\tsendWarn(\n\t\t\t\t\t`Note: ${declaredAccountAlias} is already instantiated in the current environment, \"${parsedArgs.env}\"`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (accountsInstantiated.length !== 0) {\n\t\t\treturn sendJsonRes(\n\t\t\t\t`Accounts instantiated: ${\n\t\t\t\t\taccountsInstantiated.join(', ')\n\t\t\t\t}.\\nPlease execute \"taq fund\" targeting the same environment to fund these accounts`,\n\t\t\t);\n\t\t} else {\n\t\t\treturn sendJsonRes(\n\t\t\t\t`No accounts were instantiated because they were all instantiated in the target environment already`,\n\t\t\t);\n\t\t}\n\t} catch (err) {\n\t\tawait sendAsyncErr('No operations performed');\n\t\tif (parsedArgs.debug) await sendAsyncErr(String(err));\n\t}\n};\n\nexport default instantiate_account;\n","import {\n\taddTzExtensionIfMissing,\n\tgetArtifactsDir,\n\tgetContractContent,\n\tgetCurrentEnvironment,\n\tgetCurrentEnvironmentConfig,\n\tNonEmptyString,\n\tRequestArgs,\n\tsendAsyncErr,\n\tsendErr,\n\tsendJsonRes,\n\tupdateAddressAlias,\n} from '@taqueria/node-sdk';\nimport { OperationContentsAndResultOrigination } from '@taquito/rpc';\nimport { TezosToolkit, WalletOperationBatch } from '@taquito/taquito';\nimport { BatchWalletOperation } from '@taquito/taquito/dist/types/wallet/batch-operation';\nimport { basename, extname, join } from 'path';\nimport {\n\tconfigureToolKitForNetwork,\n\tconfigureToolKitForSandbox,\n\tdoWithin,\n\tgetEnvTypeAndNodeConfig,\n\thandleOpsError,\n\tOriginateOpts as Opts,\n} from './common';\n\ntype ContractInfo = {\n\tcontract: string;\n\tcode: string;\n\tinitStorage: string;\n\tmutezTransfer: number;\n};\n\ntype TableRow = {\n\tcontract: string;\n\taddress: string;\n\talias: string;\n\tbalanceInMutez: string;\n\tdestination: string;\n};\n\nconst getContractPath = (parsedArgs: RequestArgs.t, contractFilename: string) =>\n\tjoin(getArtifactsDir(parsedArgs), /\\.tz$/.test(contractFilename) ? contractFilename : `${contractFilename}.tz`);\n\nconst getDefaultStorageFilename = (contractName: string): string => {\n\tconst baseFilename = basename(contractName, extname(contractName));\n\tconst extFilename = extname(contractName);\n\tconst defaultStorage = `${baseFilename}.default_storage${extFilename}`;\n\treturn defaultStorage;\n};\n\nconst getContractInfo = async (parsedArgs: Opts): Promise<ContractInfo> => {\n\tconst contract = parsedArgs.contract;\n\tconst protocolArgs = RequestArgs.create(parsedArgs);\n\tconst contractWithTzExtension = addTzExtensionIfMissing(contract);\n\tconst contractCode = await getContractContent(protocolArgs, contractWithTzExtension);\n\tif (contractCode === undefined) {\n\t\treturn sendAsyncErr(\n\t\t\t`Please generate ${contractWithTzExtension} with one of the compilers (LIGO, SmartPy, Archetype) or write it manually and put it under /${parsedArgs.config.artifactsDir}\\n`,\n\t\t);\n\t}\n\n\tconst storageFilename = parsedArgs.storage ?? getDefaultStorageFilename(contractWithTzExtension);\n\tconst contractInitStorage = await getContractContent(protocolArgs, storageFilename);\n\tif (contractInitStorage === undefined) {\n\t\treturn sendAsyncErr(\n\t\t\t`❌ No initial storage file was found for ${contractWithTzExtension}\\nStorage must be specified in a file as a Michelson expression and will automatically be linked to this contract if specified with the name \"${\n\t\t\t\tgetDefaultStorageFilename(contractWithTzExtension)\n\t\t\t}\" in the artifacts directory\\nYou can also manually pass a storage file to the originate task using the --storage STORAGE_FILE_NAME option\\n`,\n\t\t);\n\t}\n\n\treturn {\n\t\tcontract,\n\t\tcode: contractCode,\n\t\tinitStorage: contractInitStorage,\n\t\tmutezTransfer: parseInt(parsedArgs.mutez ?? '0'),\n\t};\n};\n\nconst createBatchForOriginate = (tezos: TezosToolkit, contractsInfo: ContractInfo[]): WalletOperationBatch =>\n\tcontractsInfo.reduce((acc, contractInfo) =>\n\t\tacc.withOrigination({\n\t\t\tcode: contractInfo.code,\n\t\t\tinit: contractInfo.initStorage,\n\t\t\tbalance: contractInfo.mutezTransfer.toString(),\n\t\t\tmutez: true,\n\t\t}), tezos.wallet.batch());\n\n// Provide a means to clear intervals that were created but not cleaned up in either\n// Taquito or RxJS. This is a hack to prevent the program from hanging after all promises have resolved.\t\t\nfunction withIntervalHack(fn: CallableFunction) {\n\treturn async function (...args: unknown[]) {\n\t\tconst originalSetInterval = setInterval;\n\t\tconst intervals: NodeJS.Timeout[] = [];\n\n\t\t// Override global setInterval\n\t\t// @ts-ignore\n\t\tglobal.setInterval = (callback, delay) => {\n\t\t\tconst id = originalSetInterval(callback, delay);\n\t\t\tintervals.push(id);\n\t\t\treturn id;\n\t\t};\n\n\t\ttry {\n\t\t\treturn await fn(...args);\n\t\t} finally {\n\t\t\t// Clear intervals and restore original setInterval\n\t\t\tintervals.forEach((id) => clearInterval(id));\n\t\t\tglobal.setInterval = originalSetInterval;\n\t\t}\n\t};\n}\n\nconst performOriginateOps = withIntervalHack((\n\ttezos: TezosToolkit,\n\tenv: string,\n\tcontractsInfo: ContractInfo[],\n\tmaxTimeout: number,\n): Promise<BatchWalletOperation> => {\n\tconst batch = createBatchForOriginate(tezos, contractsInfo);\n\n\ttry {\n\t\treturn doWithin<BatchWalletOperation>(maxTimeout, async () => {\n\t\t\tconst op = await batch.send();\n\t\t\tawait op.confirmation();\n\t\t\treturn op;\n\t\t});\n\t} catch (err) {\n\t\treturn handleOpsError(err, env);\n\t}\n});\n\t\t\t\t\n\nconst prepContractInfoForDisplay = async (\n\tparsedArgs: Opts,\n\ttezos: TezosToolkit,\n\tcontractInfo: ContractInfo,\n\top: BatchWalletOperation,\n): Promise<TableRow> => {\n\tconst protocolArgs = RequestArgs.create(parsedArgs);\n\tconst operationResults = await op.operationResults();\n\tconst originationResults = (operationResults ?? [])\n\t\t.filter(result => result.kind === 'origination')\n\t\t.map(result => result as OperationContentsAndResultOrigination);\n\n\t// Length should be 1 since we are batching originate operations into one\n\tconst result = originationResults.length === 1 ? originationResults[0] : undefined;\n\tconst address = result?.metadata?.operation_result?.originated_contracts?.join(',');\n\tconst alias = parsedArgs.alias ?? basename(contractInfo.contract, extname(contractInfo.contract));\n\n\tconst displayableAddress = address ?? 'Something went wrong during origination';\n\n\tif (address) {\n\t\tconst validatedAddress = NonEmptyString.create(address);\n\t\tawait updateAddressAlias(protocolArgs, alias, validatedAddress);\n\t}\n\n\treturn {\n\t\tcontract: contractInfo.contract,\n\t\taddress: displayableAddress,\n\t\talias: address ? alias : 'N/A',\n\t\tbalanceInMutez: contractInfo.mutezTransfer.toString(),\n\t\tdestination: tezos.rpc.getRpcUrl(),\n\t};\n};\n\nconst originate = async (parsedArgs: Opts): Promise<void> => {\n\tconst protocolArgs = RequestArgs.create(parsedArgs);\n\tconst env = getCurrentEnvironmentConfig(protocolArgs);\n\tif (!env) return sendAsyncErr(`There is no environment called ${parsedArgs.env} in your config.json`);\n\ttry {\n\t\tconst [envType, nodeConfig] = await getEnvTypeAndNodeConfig(protocolArgs, env);\n\t\tconst tezos = await (envType === 'Network'\n\t\t\t? configureToolKitForNetwork(protocolArgs, nodeConfig, parsedArgs.sender)\n\t\t\t: configureToolKitForSandbox(nodeConfig, parsedArgs.sender));\n\n\t\t\n\t\tconst contractInfo = await getContractInfo(parsedArgs);\n\n\t\tconst op = await performOriginateOps(\n\t\t\ttezos,\n\t\t\tgetCurrentEnvironment(protocolArgs),\n\t\t\t[contractInfo],\n\t\t\tparsedArgs.timeout,\n\t\t);\n\n\t\tconst contractInfoForDisplay = await prepContractInfoForDisplay(parsedArgs, tezos, contractInfo, op);\n\t\treturn sendJsonRes([contractInfoForDisplay]);\n\t} catch {\n\t\treturn sendAsyncErr('No operations performed');\n\t}\n};\n\nexport default originate;\n"],"mappings":";;;AAAA,IAAAA,mBAAqC;;;ACArC,IAAAC,mBAA0C;;;ACA1C,IAAAC,mBAOO;;;ACPP,sBASO;AASP,oBAA0C;AAC1C,qBAA6B;AAgCtB,IAAM,0BAA0B,CACtC,YACA,QAC0E;AAtD3E;AAuDC,QAAM,yBAAyB;AAC/B,QAAI,SAAI,aAAJ,mBAAc,YAAW,OAAK,SAAI,cAAJ,mBAAe,YAAW;AAAG,eA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AAA,IACD,CAAC;AAAA,IACD,sBAAK,OAAO;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aACC;AAAA,MACD,SAAS;AAAA,MACT,UAAU;AAAA,IACX,CAAC;AAAA,EACF;AAAA,EACA,OAAO;AACR,IAAI,QAAQ,IAAI;","names":["import_node_sdk","import_node_sdk","import_node_sdk","process","import_node_sdk","import_node_sdk","import_node_sdk","getContractInfo","prepContractInfoForDisplay","result"]}
package/index.mjs CHANGED
@@ -405,10 +405,27 @@ var createBatchForOriginate = (tezos, contractsInfo) => contractsInfo.reduce((ac
405
405
  balance: contractInfo.mutezTransfer.toString(),
406
406
  mutez: true
407
407
  }), tezos.wallet.batch());
408
- var performOriginateOps = async (tezos, env, contractsInfo, maxTimeout) => {
408
+ function withIntervalHack(fn) {
409
+ return async function(...args) {
410
+ const originalSetInterval = setInterval;
411
+ const intervals = [];
412
+ global.setInterval = (callback, delay) => {
413
+ const id = originalSetInterval(callback, delay);
414
+ intervals.push(id);
415
+ return id;
416
+ };
417
+ try {
418
+ return await fn(...args);
419
+ } finally {
420
+ intervals.forEach((id) => clearInterval(id));
421
+ global.setInterval = originalSetInterval;
422
+ }
423
+ };
424
+ }
425
+ var performOriginateOps = withIntervalHack((tezos, env, contractsInfo, maxTimeout) => {
409
426
  const batch = createBatchForOriginate(tezos, contractsInfo);
410
427
  try {
411
- return await doWithin(maxTimeout, async () => {
428
+ return doWithin(maxTimeout, async () => {
412
429
  const op = await batch.send();
413
430
  await op.confirmation();
414
431
  return op;
@@ -416,7 +433,7 @@ var performOriginateOps = async (tezos, env, contractsInfo, maxTimeout) => {
416
433
  } catch (err) {
417
434
  return handleOpsError(err, env);
418
435
  }
419
- };
436
+ });
420
437
  var prepContractInfoForDisplay2 = async (parsedArgs, tezos, contractInfo, op) => {
421
438
  var _a, _b, _c;
422
439
  const protocolArgs = RequestArgs5.create(parsedArgs);
package/index.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts","main.ts","fund.ts","common.ts","transfer.ts","instantiate_account.ts","originate.ts"],"sourcesContent":["import { Option, Plugin, Task } from '@taqueria/node-sdk';\nimport main from './main';\n\nPlugin.create(_i18n => ({\n\talias: 'taquito',\n\tschema: '1.0',\n\tversion: '0.1',\n\ttasks: [\n\t\tTask.create({\n\t\t\ttask: 'deploy',\n\t\t\tcommand: 'deploy <contract>',\n\t\t\tdescription: 'Deploy a smart contract to a particular environment',\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'alias',\n\t\t\t\t\tdescription: \"Alias used to refer to the deployed contract's address\",\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'storage',\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'Name of the storage file that contains the storage value as a Michelson expression, in the artifacts directory, used for originating a contract',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'sender',\n\t\t\t\t\tdescription: 'Name of an instantiated account to use as the sender of the originate operation',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'mutez',\n\t\t\t\t\tdescription: 'Amount of Mutez to transfer',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'timeout',\n\t\t\t\t\tshortFlag: 't',\n\t\t\t\t\tdefaultValue: 40,\n\t\t\t\t\tdescription: 'Number of retry attempts (to avoid congestion and network failures)',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t],\n\t\t\taliases: ['originate'],\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'application/json',\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'transfer',\n\t\t\tcommand: 'transfer <contract>',\n\t\t\tdescription:\n\t\t\t\t'Transfer/call an implicit account or a smart contract (specified via its alias or address) deployed to a particular environment',\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'mutez',\n\t\t\t\t\tdescription: 'Amount of Mutez to transfer',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'param',\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'Name of the parameter file that contains the parameter value as a Michelson expression, in the artifacts directory, used for invoking a deployed contract',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'entrypoint',\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'You may explicitly specify an entrypoint to make the parameter value shorter, without having to specify a chain of (Left (Right ... 14 ...))',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'sender',\n\t\t\t\t\tdescription: 'Name of an instantiated account to use as the sender of the transfer operation',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'timeout',\n\t\t\t\t\tshortFlag: 't',\n\t\t\t\t\tdefaultValue: 40,\n\t\t\t\t\tdescription: 'Number of retry attempts (to avoid congestion and network failures)',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t],\n\t\t\taliases: ['call'],\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'application/json',\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'fund',\n\t\t\tcommand: 'fund',\n\t\t\tdescription: 'Fund all the instantiated accounts up to the desired/declared amount in a target environment',\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'application/json',\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'timeout',\n\t\t\t\t\tshortFlag: 't',\n\t\t\t\t\tdefaultValue: 40,\n\t\t\t\t\tdescription: 'Number of retry attempts (to avoid congestion and network failures)',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t],\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'instantiate-account',\n\t\t\tcommand: 'instantiate-account',\n\t\t\tdescription:\n\t\t\t\t'Instantiate all accounts declared in the \"accounts\" field at the root level of the config file to a target environment',\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'application/json',\n\t\t}),\n\t],\n\tproxy: main,\n}), process.argv);\n","import { RequestArgs, sendAsyncErr } from '@taqueria/node-sdk';\nimport { IntersectionOpts as Opts } from './common';\nimport fund from './fund';\nimport instantiate_account from './instantiate_account';\nimport originate from './originate';\nimport transfer from './transfer';\n\nexport const main = (parsedArgs: RequestArgs.t): Promise<void> => {\n\tconst unsafeArgs = parsedArgs as unknown as Opts;\n\tswitch (unsafeArgs.task) {\n\t\tcase 'deploy':\n\t\t\treturn originate(unsafeArgs);\n\t\tcase 'transfer':\n\t\t\treturn transfer(unsafeArgs);\n\t\tcase 'instantiate-account':\n\t\t\treturn instantiate_account(parsedArgs);\n\t\tcase 'fund':\n\t\t\treturn fund(unsafeArgs);\n\t\tdefault:\n\t\t\treturn sendAsyncErr(`${unsafeArgs} is not an understood task by the Taquito plugin`);\n\t}\n};\n\nexport default main;\n","import {\n\tgetCurrentEnvironment,\n\tgetCurrentEnvironmentConfig,\n\tRequestArgs,\n\tsendAsyncErr,\n\tsendJsonRes,\n\tsendWarn,\n} from '@taqueria/node-sdk';\nimport { TezosToolkit } from '@taquito/taquito';\nimport {\n\tconfigureToolKitForNetwork,\n\tFundOpts,\n\tFundOpts as Opts,\n\tgetDeclaredAccounts,\n\tgetEnvTypeAndNodeConfig,\n\tgetNetworkInstantiatedAccounts,\n} from './common';\nimport { ContractInfo, performTransferOps } from './transfer';\n\ntype TableRow = {\n\taccountAlias: string;\n\taccountAddress: string;\n\tmutezFunded: string;\n};\n\nconst getAccountsInfo = (\n\tparsedArgs: RequestArgs.t,\n\ttezos: TezosToolkit,\n\tinstantiatedAccounts: Record<string, any>,\n): Promise<ContractInfo[]> =>\n\tPromise.all(\n\t\tObject.entries(instantiatedAccounts)\n\t\t\t.map(async (instantiatedAccount: [string, any]) => {\n\t\t\t\tconst alias = instantiatedAccount[0];\n\t\t\t\tconst aliasInfo = instantiatedAccount[1];\n\n\t\t\t\tconst declaredMutez: number | undefined = getDeclaredAccounts(parsedArgs)[alias];\n\t\t\t\tconst currentBalanceInMutez = (await tezos.tz.getBalance(aliasInfo.publicKeyHash)).toNumber();\n\t\t\t\tconst amountToFillInMutez = declaredMutez ? Math.max(declaredMutez - currentBalanceInMutez, 0) : 0;\n\n\t\t\t\tif (!declaredMutez) {\n\t\t\t\t\tsendWarn(\n\t\t\t\t\t\t`Warning: ${alias} is instantiated in the target environment but not declared in the root level \"accounts\" field of ./.taq/config.json so ${alias} will not be funded as you don't have a declared tez amount set there for ${alias}\\n`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tcontractAlias: alias,\n\t\t\t\t\tcontractAddress: aliasInfo.publicKeyHash,\n\t\t\t\t\tparameter: 'Unit',\n\t\t\t\t\tentrypoint: 'default',\n\t\t\t\t\tmutezTransfer: parseInt(amountToFillInMutez.toString()),\n\t\t\t\t};\n\t\t\t}),\n\t)\n\t\t.then(accountsInfo => accountsInfo.filter(accountInfo => accountInfo.mutezTransfer !== 0))\n\t\t.catch(err => sendAsyncErr(`Something went wrong while extracting account information - ${err}`));\n\nconst prepAccountsInfoForDisplay = (accountsInfo: ContractInfo[]): TableRow[] =>\n\taccountsInfo.map(accountInfo => {\n\t\treturn {\n\t\t\taccountAlias: accountInfo.contractAlias,\n\t\t\taccountAddress: accountInfo.contractAddress,\n\t\t\tmutezFunded: accountInfo.mutezTransfer.toString(),\n\t\t};\n\t});\n\nconst fund = async (parsedArgs: FundOpts): Promise<void> => {\n\tconst env = getCurrentEnvironmentConfig(parsedArgs);\n\tif (!env) return sendAsyncErr(`There is no environment called ${parsedArgs.env} in your config.json`);\n\ttry {\n\t\tconst [envType, nodeConfig] = await getEnvTypeAndNodeConfig(parsedArgs, env);\n\t\tif (envType !== 'Network') return sendAsyncErr('taq fund can only be executed in a network environment');\n\t\tconst tezos = await configureToolKitForNetwork(parsedArgs, nodeConfig);\n\n\t\tconst instantiatedAccounts = getNetworkInstantiatedAccounts(nodeConfig);\n\n\t\tconst accountsInfo = await getAccountsInfo(parsedArgs, tezos, instantiatedAccounts);\n\t\tif (accountsInfo.length === 0) {\n\t\t\treturn sendJsonRes(\n\t\t\t\t`All instantiated accounts in the current environment, \"${parsedArgs.env}\", are funded up to or beyond the declared amount`,\n\t\t\t);\n\t\t}\n\n\t\tawait performTransferOps(tezos, getCurrentEnvironment(parsedArgs), accountsInfo, parsedArgs.timeout);\n\n\t\tconst accountsInfoForDisplay = prepAccountsInfoForDisplay(accountsInfo);\n\t\treturn sendJsonRes(accountsInfoForDisplay);\n\t} catch {\n\t\treturn sendAsyncErr('No operations performed');\n\t}\n};\n\nexport default fund;\n","import {\n\tgetAccountPrivateKey,\n\tgetDefaultSandboxAccount,\n\tgetNetworkConfig,\n\tgetSandboxConfig,\n\tRequestArgs,\n\tsendAsyncErr,\n\tsendErr,\n\tTAQ_OPERATOR_ACCOUNT,\n} from '@taqueria/node-sdk';\nimport {\n\tEnvironment,\n\tNetworkConfig,\n\tProtocol,\n\tProxyTaskArgs,\n\tSandboxAccountConfig,\n\tSandboxConfig,\n} from '@taqueria/node-sdk/types';\nimport { importKey, InMemorySigner } from '@taquito/signer';\nimport { TezosToolkit } from '@taquito/taquito';\n\nexport type OriginateOpts = ProxyTaskArgs.t & {\n\tcontract: string;\n\tstorage: string;\n\talias?: string;\n\tsender?: string;\n\tmutez?: string;\n\ttimeout: number;\n};\n\nexport type TransferOpts = ProxyTaskArgs.t & {\n\tcontract: string;\n\tmutez?: string;\n\tparam?: string;\n\tentrypoint?: string;\n\tsender?: string;\n\ttimeout: number;\n};\n\nexport type FundOpts = ProxyTaskArgs.t & {\n\ttimeout: number;\n};\n\nexport type InstantiateAccountOpts = ProxyTaskArgs.t;\n\n// To be used for the main entrypoint of the plugin\nexport type IntersectionOpts = OriginateOpts & TransferOpts & InstantiateAccountOpts & FundOpts;\n\n// To be used for common functions in this file\ntype UnionOpts = OriginateOpts | TransferOpts | InstantiateAccountOpts | FundOpts;\n\nexport const getEnvTypeAndNodeConfig = (\n\tparsedArgs: RequestArgs.t,\n\tenv: Environment.t,\n): Promise<['Network', NetworkConfig.t] | ['Sandbox', SandboxConfig.t]> => {\n\tconst targetConstraintErrMsg = 'Each environment can only have one target, be it a network or a sandbox';\n\tif (env.networks?.length === 1 && env.sandboxes?.length === 1) return sendAsyncErr(targetConstraintErrMsg);\n\tif (env.networks?.length === 1) {\n\t\tconst networkName = env.networks[0];\n\t\tconst network = getNetworkConfig(parsedArgs)(networkName);\n\t\tif (!network) {\n\t\t\treturn sendAsyncErr(\n\t\t\t\t`The current environment is configured to use a network called '${networkName}'; however, no network of this name has been configured in .taq/config.json`,\n\t\t\t);\n\t\t}\n\t\treturn Promise.resolve(['Network', network]);\n\t}\n\tif (env.sandboxes?.length === 1) {\n\t\tconst sandboxName = env.sandboxes[0];\n\t\tconst sandbox = getSandboxConfig(parsedArgs)(sandboxName);\n\t\tif (!sandbox) {\n\t\t\treturn sendAsyncErr(\n\t\t\t\t`The current environment is configured to use a sandbox called '${sandboxName}'; however, no sandbox of this name has been configured in .taq/config.json`,\n\t\t\t);\n\t\t}\n\t\treturn Promise.resolve(['Sandbox', sandbox]);\n\t}\n\treturn sendAsyncErr(targetConstraintErrMsg);\n};\n\nexport const configureToolKitForSandbox = async (sandbox: SandboxConfig.t, sender?: string): Promise<TezosToolkit> => {\n\tlet accountKey: string;\n\tif (sender && sender !== 'default') {\n\t\tconst accounts = getSandboxInstantiatedAccounts(sandbox);\n\t\tif (accounts.hasOwnProperty(sender)) {\n\t\t\taccountKey = accounts[sender].secretKey;\n\t\t} else {\n\t\t\treturn sendAsyncErr(\n\t\t\t\t`${sender} is not an account instantiated in the current environment. Check .taq/config.json`,\n\t\t\t);\n\t\t}\n\t} else {\n\t\tconst defaultAccount = getDefaultSandboxAccount(sandbox);\n\t\tif (!defaultAccount) {\n\t\t\treturn sendAsyncErr(\n\t\t\t\t`No default account is specified in the sandbox to perform the operation. Please use the --sender flag to explicitly specify the account to use as the sender of the operation`,\n\t\t\t);\n\t\t}\n\t\taccountKey = defaultAccount.secretKey;\n\t}\n\n\tconst tezos = new TezosToolkit(sandbox.rpcUrl as string);\n\ttezos.setProvider({ signer: new InMemorySigner(accountKey.replace(/^unencrypted:/, '')) });\n\treturn tezos;\n};\n\nexport const configureToolKitForNetwork = async (\n\tparsedArgs: RequestArgs.t,\n\tnetwork: NetworkConfig.t,\n\tsender?: string,\n): Promise<TezosToolkit> => {\n\tlet account: string;\n\tif (sender && sender !== TAQ_OPERATOR_ACCOUNT) {\n\t\tconst accounts = getNetworkInstantiatedAccounts(network);\n\t\tif (accounts.hasOwnProperty(sender)) {\n\t\t\taccount = sender;\n\t\t} else {\n\t\t\treturn sendAsyncErr(\n\t\t\t\t`${sender} is not an account instantiated in the current environment. Check .taq/config.json`,\n\t\t\t);\n\t\t}\n\t} else {\n\t\taccount = TAQ_OPERATOR_ACCOUNT;\n\t}\n\n\tconst tezos = new TezosToolkit(network.rpcUrl as string);\n\tconst key = await getAccountPrivateKey(parsedArgs, network, account);\n\tawait importKey(tezos, key);\n\treturn tezos;\n};\n\nexport const getDeclaredAccounts = (parsedArgs: RequestArgs.t): Record<string, number> =>\n\tObject.entries(parsedArgs.config.accounts ?? {}).reduce(\n\t\t(acc, declaredAccount) => {\n\t\t\tconst alias: string = declaredAccount[0];\n\t\t\tconst mutez: string | number = declaredAccount[1];\n\t\t\treturn {\n\t\t\t\t...acc,\n\t\t\t\t[alias]: typeof mutez === 'string' ? parseFloat(mutez) : mutez,\n\t\t\t};\n\t\t},\n\t\t{} as Record<string, number>,\n\t);\n\nexport const getSandboxInstantiatedAccounts = (sandbox: SandboxConfig.t): Record<string, SandboxAccountConfig.t> =>\n\t(sandbox?.accounts)\n\t\t? Object.entries(sandbox.accounts).reduce(\n\t\t\t(acc, instantiatedAccount) => {\n\t\t\t\tconst alias: string = instantiatedAccount[0];\n\t\t\t\tconst keys = instantiatedAccount[1];\n\t\t\t\treturn alias !== 'default'\n\t\t\t\t\t? {\n\t\t\t\t\t\t...acc,\n\t\t\t\t\t\t[alias]: keys,\n\t\t\t\t\t}\n\t\t\t\t\t: acc;\n\t\t\t},\n\t\t\t{},\n\t\t)\n\t\t: {};\n\nexport const getNetworkInstantiatedAccounts = (network: NetworkConfig.t): Record<string, any> =>\n\tnetwork.accounts\n\t\t? Object.entries(network.accounts).reduce(\n\t\t\t(acc, instantiatedAccount) => {\n\t\t\t\tconst alias: string = instantiatedAccount[0];\n\t\t\t\tconst keys = instantiatedAccount[1];\n\t\t\t\treturn alias !== TAQ_OPERATOR_ACCOUNT\n\t\t\t\t\t? {\n\t\t\t\t\t\t...acc,\n\t\t\t\t\t\t[alias]: keys,\n\t\t\t\t\t}\n\t\t\t\t\t: acc;\n\t\t\t},\n\t\t\t{},\n\t\t)\n\t\t: {};\n\nexport const generateAccountKeys = async (\n\tparsedArgs: RequestArgs.t,\n\tnetwork: NetworkConfig.t,\n\taccount: string,\n): Promise<void> => {\n\tconst tezos = new TezosToolkit(network.rpcUrl as string);\n\tconst key = await getAccountPrivateKey(parsedArgs, network, account);\n\tawait importKey(tezos, key);\n};\n\nexport const handleOpsError = (err: unknown, env: string): Promise<never> => {\n\tif (err instanceof Error) {\n\t\tconst msg = err.message;\n\t\tif (/ENOTFOUND/.test(msg)) return sendAsyncErr('The RPC URL may be invalid. Check ./.taq/config.json');\n\t\tif (/ECONNREFUSED/.test(msg)) return sendAsyncErr('The RPC URL may be down or the sandbox is not running');\n\t\tif (/empty_implicit_contract/.test(msg)) {\n\t\t\tconst result = msg.match(/(?<=\"implicit\":\")tz[^\"]+(?=\")/);\n\t\t\tconst publicKeyHash = result ? result[0] : undefined;\n\t\t\tif (publicKeyHash) {\n\t\t\t\treturn sendAsyncErr(\n\t\t\t\t\t`The account ${publicKeyHash} for the target environment, \"${env}\", may not be funded\\nTo fund this account:\\n1. Go to https://teztnets.xyz and click \"Faucet\" of the target testnet\\n2. Copy and paste the above key into the wallet address field\\n3. Request some Tez (Note that you might need to wait for a few seconds for the network to register the funds)`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn sendAsyncErr(`Error while performing operation:\\n${err} ${JSON.stringify(err, null, 2)}`);\n};\n\nexport const doWithin = async <T>(seconds: number, fn: () => Promise<T>) => {\n\tlet captured: Error = new Error(\n\t\t'Operation timed out. Please try again and perhaps increase the timeout using the --timeout option.',\n\t);\n\tlet timeout: ReturnType<typeof setTimeout>;\n\n\tconst maxTimeout = new Promise((resolve, reject) => {\n\t\ttimeout = setTimeout(() => {\n\t\t\treject(captured);\n\t\t}, seconds * 1000);\n\t}) as Promise<T>;\n\n\tconst process = async () => {\n\t\twhile (true) {\n\t\t\ttry {\n\t\t\t\tconst retval: T = await fn();\n\t\t\t\treturn retval;\n\t\t\t} catch (err) {\n\t\t\t\tcaptured = err as Error;\n\t\t\t}\n\t\t}\n\t};\n\n\treturn Promise.race<T>([process(), maxTimeout]).then(retval => {\n\t\tclearTimeout(timeout);\n\t\treturn retval;\n\t});\n};\n","import {\n\tgetAddressOfAlias,\n\tgetCurrentEnvironment,\n\tgetCurrentEnvironmentConfig,\n\tgetParameter,\n\tRequestArgs,\n\tsendAsyncErr,\n\tsendJsonRes,\n} from '@taqueria/node-sdk';\nimport { Environment } from '@taqueria/node-sdk/types';\nimport { Expr, Parser } from '@taquito/michel-codec';\nimport { TezosToolkit, WalletOperationBatch } from '@taquito/taquito';\nimport { BatchWalletOperation } from '@taquito/taquito/dist/types/wallet/batch-operation';\nimport {\n\tconfigureToolKitForNetwork,\n\tconfigureToolKitForSandbox,\n\tdoWithin,\n\tgetEnvTypeAndNodeConfig,\n\thandleOpsError,\n\tTransferOpts as Opts,\n} from './common';\n\nexport type ContractInfo = {\n\tcontractAlias: string;\n\tcontractAddress: string;\n\tparameter: string;\n\tentrypoint: string;\n\tmutezTransfer: number;\n};\n\ntype TableRow = {\n\tcontractAlias: string;\n\tcontractAddress: string;\n\tparameter: string;\n\tentrypoint: string;\n\tmutezTransfer: string;\n\tdestination: string;\n};\n\nconst isContractAddress = (contract: string): boolean =>\n\tcontract.startsWith('tz1') || contract.startsWith('tz2') || contract.startsWith('tz3') || contract.startsWith('KT1');\n\nconst getContractInfo = async (parsedArgs: Opts, env: Environment.t): Promise<ContractInfo> => {\n\tconst contract = parsedArgs.contract;\n\tconst protocolArgs = RequestArgs.create(parsedArgs);\n\treturn {\n\t\tcontractAlias: isContractAddress(contract) ? 'N/A' : contract,\n\t\tcontractAddress: isContractAddress(contract) ? contract : await getAddressOfAlias(env, contract),\n\t\tparameter: parsedArgs.param ? await getParameter(protocolArgs, parsedArgs.param) : 'Unit',\n\t\tentrypoint: parsedArgs.entrypoint ?? 'default',\n\t\tmutezTransfer: parseInt(parsedArgs.mutez ?? '0'),\n\t};\n};\n\nconst createBatchForTransfer = (tezos: TezosToolkit, contractsInfo: ContractInfo[]): WalletOperationBatch =>\n\tcontractsInfo.reduce((acc, contractInfo) =>\n\t\tacc.withTransfer({\n\t\t\tto: contractInfo.contractAddress,\n\t\t\tamount: contractInfo.mutezTransfer,\n\t\t\tparameter: {\n\t\t\t\tentrypoint: contractInfo.entrypoint,\n\t\t\t\tvalue: new Parser().parseMichelineExpression(contractInfo.parameter) as Expr,\n\t\t\t},\n\t\t\tmutez: true,\n\t\t}), tezos.wallet.batch());\n\nexport const performTransferOps = async (\n\ttezos: TezosToolkit,\n\tenv: string,\n\tcontractsInfo: ContractInfo[],\n\tmaxTimeout: number,\n): Promise<BatchWalletOperation> => {\n\tconst batch = createBatchForTransfer(tezos, contractsInfo);\n\ttry {\n\t\treturn await doWithin<BatchWalletOperation>(maxTimeout, async () => {\n\t\t\tconst op = await batch.send();\n\t\t\tawait op.confirmation();\n\t\t\treturn op;\n\t\t});\n\t} catch (err) {\n\t\treturn handleOpsError(err, env);\n\t}\n};\n\nconst prepContractInfoForDisplay = (tezos: TezosToolkit, contractInfo: ContractInfo): TableRow => {\n\treturn {\n\t\tcontractAlias: contractInfo.contractAlias,\n\t\tcontractAddress: contractInfo.contractAddress,\n\t\tparameter: contractInfo.parameter,\n\t\tentrypoint: contractInfo.entrypoint,\n\t\tmutezTransfer: contractInfo.mutezTransfer.toString(),\n\t\tdestination: tezos.rpc.getRpcUrl(),\n\t};\n};\n\nconst transfer = async (opts: Opts): Promise<void> => {\n\tconst protocolArgs = RequestArgs.create(opts);\n\tconst env = getCurrentEnvironmentConfig(protocolArgs);\n\tif (!env) return sendAsyncErr(`There is no environment called ${protocolArgs.env} in your config.json`);\n\ttry {\n\t\tconst [envType, nodeConfig] = await getEnvTypeAndNodeConfig(protocolArgs, env);\n\t\tconst tezos = await (envType === 'Network'\n\t\t\t? configureToolKitForNetwork(protocolArgs, nodeConfig, opts.sender)\n\t\t\t: configureToolKitForSandbox(nodeConfig, opts.sender));\n\n\t\tconst contractInfo = await getContractInfo(opts, env);\n\n\t\tawait performTransferOps(tezos, getCurrentEnvironment(protocolArgs), [contractInfo], opts.timeout);\n\n\t\tconst contractInfoForDisplay = prepContractInfoForDisplay(tezos, contractInfo);\n\t\treturn sendJsonRes([contractInfoForDisplay]);\n\t} catch {\n\t\treturn sendAsyncErr('No operations performed');\n\t}\n};\n\nexport default transfer;\n","import { getCurrentEnvironmentConfig, RequestArgs, sendAsyncErr, sendJsonRes, sendWarn } from '@taqueria/node-sdk';\nimport {\n\tgenerateAccountKeys,\n\tgetDeclaredAccounts,\n\tgetEnvTypeAndNodeConfig,\n\tgetNetworkInstantiatedAccounts,\n} from './common';\n\nconst instantiate_account = async (parsedArgs: RequestArgs.t): Promise<void> => {\n\tconst env = getCurrentEnvironmentConfig(parsedArgs);\n\tif (!env) return sendAsyncErr(`There is no environment called ${parsedArgs.env} in your config.json`);\n\ttry {\n\t\tconst [envType, nodeConfig] = await getEnvTypeAndNodeConfig(parsedArgs, env);\n\t\tif (envType !== 'Network') {\n\t\t\treturn sendAsyncErr('taq instantiate-account can only be executed in a network environment');\n\t\t}\n\n\t\tconst declaredAccountAliases = Object.keys(getDeclaredAccounts(parsedArgs));\n\t\tconst instantiatedAccounts = getNetworkInstantiatedAccounts(nodeConfig);\n\n\t\tlet accountsInstantiated = [];\n\t\tfor (const declaredAccountAlias of declaredAccountAliases) {\n\t\t\tif (!instantiatedAccounts.hasOwnProperty(declaredAccountAlias)) {\n\t\t\t\tawait generateAccountKeys(parsedArgs, nodeConfig, declaredAccountAlias);\n\t\t\t\taccountsInstantiated.push(declaredAccountAlias);\n\t\t\t} else {\n\t\t\t\tsendWarn(\n\t\t\t\t\t`Note: ${declaredAccountAlias} is already instantiated in the current environment, \"${parsedArgs.env}\"`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (accountsInstantiated.length !== 0) {\n\t\t\treturn sendJsonRes(\n\t\t\t\t`Accounts instantiated: ${\n\t\t\t\t\taccountsInstantiated.join(', ')\n\t\t\t\t}.\\nPlease execute \"taq fund\" targeting the same environment to fund these accounts`,\n\t\t\t);\n\t\t} else {\n\t\t\treturn sendJsonRes(\n\t\t\t\t`No accounts were instantiated because they were all instantiated in the target environment already`,\n\t\t\t);\n\t\t}\n\t} catch (err) {\n\t\tawait sendAsyncErr('No operations performed');\n\t\tif (parsedArgs.debug) await sendAsyncErr(String(err));\n\t}\n};\n\nexport default instantiate_account;\n","import {\n\taddTzExtensionIfMissing,\n\tgetArtifactsDir,\n\tgetContractContent,\n\tgetCurrentEnvironment,\n\tgetCurrentEnvironmentConfig,\n\tNonEmptyString,\n\tRequestArgs,\n\tsendAsyncErr,\n\tsendErr,\n\tsendJsonRes,\n\tupdateAddressAlias,\n} from '@taqueria/node-sdk';\nimport { OperationContentsAndResultOrigination } from '@taquito/rpc';\nimport { TezosToolkit, WalletOperationBatch } from '@taquito/taquito';\nimport { BatchWalletOperation } from '@taquito/taquito/dist/types/wallet/batch-operation';\nimport { basename, extname, join } from 'path';\nimport {\n\tconfigureToolKitForNetwork,\n\tconfigureToolKitForSandbox,\n\tdoWithin,\n\tgetEnvTypeAndNodeConfig,\n\thandleOpsError,\n\tOriginateOpts as Opts,\n} from './common';\n\ntype ContractInfo = {\n\tcontract: string;\n\tcode: string;\n\tinitStorage: string;\n\tmutezTransfer: number;\n};\n\ntype TableRow = {\n\tcontract: string;\n\taddress: string;\n\talias: string;\n\tbalanceInMutez: string;\n\tdestination: string;\n};\n\nconst getContractPath = (parsedArgs: RequestArgs.t, contractFilename: string) =>\n\tjoin(getArtifactsDir(parsedArgs), /\\.tz$/.test(contractFilename) ? contractFilename : `${contractFilename}.tz`);\n\nconst getDefaultStorageFilename = (contractName: string): string => {\n\tconst baseFilename = basename(contractName, extname(contractName));\n\tconst extFilename = extname(contractName);\n\tconst defaultStorage = `${baseFilename}.default_storage${extFilename}`;\n\treturn defaultStorage;\n};\n\nconst getContractInfo = async (parsedArgs: Opts): Promise<ContractInfo> => {\n\tconst contract = parsedArgs.contract;\n\tconst protocolArgs = RequestArgs.create(parsedArgs);\n\tconst contractWithTzExtension = addTzExtensionIfMissing(contract);\n\tconst contractCode = await getContractContent(protocolArgs, contractWithTzExtension);\n\tif (contractCode === undefined) {\n\t\treturn sendAsyncErr(\n\t\t\t`Please generate ${contractWithTzExtension} with one of the compilers (LIGO, SmartPy, Archetype) or write it manually and put it under /${parsedArgs.config.artifactsDir}\\n`,\n\t\t);\n\t}\n\n\tconst storageFilename = parsedArgs.storage ?? getDefaultStorageFilename(contractWithTzExtension);\n\tconst contractInitStorage = await getContractContent(protocolArgs, storageFilename);\n\tif (contractInitStorage === undefined) {\n\t\treturn sendAsyncErr(\n\t\t\t`❌ No initial storage file was found for ${contractWithTzExtension}\\nStorage must be specified in a file as a Michelson expression and will automatically be linked to this contract if specified with the name \"${\n\t\t\t\tgetDefaultStorageFilename(contractWithTzExtension)\n\t\t\t}\" in the artifacts directory\\nYou can also manually pass a storage file to the originate task using the --storage STORAGE_FILE_NAME option\\n`,\n\t\t);\n\t}\n\n\treturn {\n\t\tcontract,\n\t\tcode: contractCode,\n\t\tinitStorage: contractInitStorage,\n\t\tmutezTransfer: parseInt(parsedArgs.mutez ?? '0'),\n\t};\n};\n\nconst createBatchForOriginate = (tezos: TezosToolkit, contractsInfo: ContractInfo[]): WalletOperationBatch =>\n\tcontractsInfo.reduce((acc, contractInfo) =>\n\t\tacc.withOrigination({\n\t\t\tcode: contractInfo.code,\n\t\t\tinit: contractInfo.initStorage,\n\t\t\tbalance: contractInfo.mutezTransfer.toString(),\n\t\t\tmutez: true,\n\t\t}), tezos.wallet.batch());\n\nexport const performOriginateOps = async (\n\ttezos: TezosToolkit,\n\tenv: string,\n\tcontractsInfo: ContractInfo[],\n\tmaxTimeout: number,\n): Promise<BatchWalletOperation> => {\n\tconst batch = createBatchForOriginate(tezos, contractsInfo);\n\ttry {\n\t\treturn await doWithin<BatchWalletOperation>(maxTimeout, async () => {\n\t\t\tconst op = await batch.send();\n\t\t\tawait op.confirmation();\n\t\t\treturn op;\n\t\t});\n\t} catch (err) {\n\t\treturn handleOpsError(err, env);\n\t}\n};\n\nconst prepContractInfoForDisplay = async (\n\tparsedArgs: Opts,\n\ttezos: TezosToolkit,\n\tcontractInfo: ContractInfo,\n\top: BatchWalletOperation,\n): Promise<TableRow> => {\n\tconst protocolArgs = RequestArgs.create(parsedArgs);\n\tconst operationResults = await op.operationResults();\n\tconst originationResults = (operationResults ?? [])\n\t\t.filter(result => result.kind === 'origination')\n\t\t.map(result => result as OperationContentsAndResultOrigination);\n\n\t// Length should be 1 since we are batching originate operations into one\n\tconst result = originationResults.length === 1 ? originationResults[0] : undefined;\n\tconst address = result?.metadata?.operation_result?.originated_contracts?.join(',');\n\tconst alias = parsedArgs.alias ?? basename(contractInfo.contract, extname(contractInfo.contract));\n\n\tconst displayableAddress = address ?? 'Something went wrong during origination';\n\n\tif (address) {\n\t\tconst validatedAddress = NonEmptyString.create(address);\n\t\tawait updateAddressAlias(protocolArgs, alias, validatedAddress);\n\t}\n\n\treturn {\n\t\tcontract: contractInfo.contract,\n\t\taddress: displayableAddress,\n\t\talias: address ? alias : 'N/A',\n\t\tbalanceInMutez: contractInfo.mutezTransfer.toString(),\n\t\tdestination: tezos.rpc.getRpcUrl(),\n\t};\n};\n\nconst originate = async (parsedArgs: Opts): Promise<void> => {\n\tconst protocolArgs = RequestArgs.create(parsedArgs);\n\tconst env = getCurrentEnvironmentConfig(protocolArgs);\n\tif (!env) return sendAsyncErr(`There is no environment called ${parsedArgs.env} in your config.json`);\n\ttry {\n\t\tconst [envType, nodeConfig] = await getEnvTypeAndNodeConfig(protocolArgs, env);\n\t\tconst tezos = await (envType === 'Network'\n\t\t\t? configureToolKitForNetwork(protocolArgs, nodeConfig, parsedArgs.sender)\n\t\t\t: configureToolKitForSandbox(nodeConfig, parsedArgs.sender));\n\n\t\tconst contractInfo = await getContractInfo(parsedArgs);\n\n\t\tconst op = await performOriginateOps(\n\t\t\ttezos,\n\t\t\tgetCurrentEnvironment(protocolArgs),\n\t\t\t[contractInfo],\n\t\t\tparsedArgs.timeout,\n\t\t);\n\n\t\tconst contractInfoForDisplay = await prepContractInfoForDisplay(parsedArgs, tezos, contractInfo, op);\n\t\treturn sendJsonRes([contractInfoForDisplay]);\n\t} catch {\n\t\treturn sendAsyncErr('No operations performed');\n\t}\n};\n\nexport default originate;\n"],"mappings":";AAAA,SAAS,QAAQ,QAAQ,YAAY;;;ACArC,SAAsB,gBAAAA,qBAAoB;;;ACA1C;AAAA,EACC,yBAAAC;AAAA,EACA,+BAAAC;AAAA,EAEA,gBAAAC;AAAA,EACA,eAAAC;AAAA,EACA;AAAA,OACM;;;ACPP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EAEA;AAAA,OACM;AASP,SAAS,WAAW,sBAAsB;AAC1C,SAAS,oBAAoB;AAgCtB,IAAM,0BAA0B,CACtC,YACA,QAC0E;AAtD3E;AAuDC,QAAM,yBAAyB;AAC/B,QAAI,SAA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ACT,aACC;AAAA,MACD,SAAS;AAAA,MACT,UAAU;AAAA,IACX,CAAC;AAAA,EACF;AAAA,EACA,OAAO;AACR,IAAI,QAAQ,IAAI;","names":["sendAsyncErr","getCurrentEnvironment","getCurrentEnvironmentConfig","sendAsyncErr","sendJsonRes","process","RequestArgs","sendAsyncErr","RequestArgs","sendAsyncErr","sendAsyncErr","getCurrentEnvironmentConfig","sendJsonRes","getCurrentEnvironment","getCurrentEnvironmentConfig","sendAsyncErr","sendJsonRes","sendWarn","getCurrentEnvironmentConfig","sendAsyncErr","sendWarn","sendJsonRes","getCurrentEnvironment","getCurrentEnvironmentConfig","RequestArgs","sendAsyncErr","sendJsonRes","getContractInfo","RequestArgs","sendAsyncErr","prepContractInfoForDisplay","result","getCurrentEnvironmentConfig","getCurrentEnvironment","sendJsonRes","sendAsyncErr"]}
1
+ {"version":3,"sources":["index.ts","main.ts","fund.ts","common.ts","transfer.ts","instantiate_account.ts","originate.ts"],"sourcesContent":["import { Option, Plugin, Task } from '@taqueria/node-sdk';\nimport main from './main';\n\nPlugin.create(_i18n => ({\n\talias: 'taquito',\n\tschema: '1.0',\n\tversion: '0.1',\n\ttasks: [\n\t\tTask.create({\n\t\t\ttask: 'deploy',\n\t\t\tcommand: 'deploy <contract>',\n\t\t\tdescription: 'Deploy a smart contract to a particular environment',\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'alias',\n\t\t\t\t\tdescription: \"Alias used to refer to the deployed contract's address\",\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'storage',\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'Name of the storage file that contains the storage value as a Michelson expression, in the artifacts directory, used for originating a contract',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'sender',\n\t\t\t\t\tdescription: 'Name of an instantiated account to use as the sender of the originate operation',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'mutez',\n\t\t\t\t\tdescription: 'Amount of Mutez to transfer',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'timeout',\n\t\t\t\t\tshortFlag: 't',\n\t\t\t\t\tdefaultValue: 40,\n\t\t\t\t\tdescription: 'Number of retry attempts (to avoid congestion and network failures)',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t],\n\t\t\taliases: ['originate'],\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'application/json',\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'transfer',\n\t\t\tcommand: 'transfer <contract>',\n\t\t\tdescription:\n\t\t\t\t'Transfer/call an implicit account or a smart contract (specified via its alias or address) deployed to a particular environment',\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'mutez',\n\t\t\t\t\tdescription: 'Amount of Mutez to transfer',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'param',\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'Name of the parameter file that contains the parameter value as a Michelson expression, in the artifacts directory, used for invoking a deployed contract',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'entrypoint',\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'You may explicitly specify an entrypoint to make the parameter value shorter, without having to specify a chain of (Left (Right ... 14 ...))',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'sender',\n\t\t\t\t\tdescription: 'Name of an instantiated account to use as the sender of the transfer operation',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'timeout',\n\t\t\t\t\tshortFlag: 't',\n\t\t\t\t\tdefaultValue: 40,\n\t\t\t\t\tdescription: 'Number of retry attempts (to avoid congestion and network failures)',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t],\n\t\t\taliases: ['call'],\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'application/json',\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'fund',\n\t\t\tcommand: 'fund',\n\t\t\tdescription: 'Fund all the instantiated accounts up to the desired/declared amount in a target environment',\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'application/json',\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'timeout',\n\t\t\t\t\tshortFlag: 't',\n\t\t\t\t\tdefaultValue: 40,\n\t\t\t\t\tdescription: 'Number of retry attempts (to avoid congestion and network failures)',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t],\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'instantiate-account',\n\t\t\tcommand: 'instantiate-account',\n\t\t\tdescription:\n\t\t\t\t'Instantiate all accounts declared in the \"accounts\" field at the root level of the config file to a target environment',\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'application/json',\n\t\t}),\n\t],\n\tproxy: main,\n}), process.argv);\n","import { RequestArgs, sendAsyncErr } from '@taqueria/node-sdk';\nimport { IntersectionOpts as Opts } from './common';\nimport fund from './fund';\nimport instantiate_account from './instantiate_account';\nimport originate from './originate';\nimport transfer from './transfer';\n\nexport const main = (parsedArgs: RequestArgs.t): Promise<void> => {\n\tconst unsafeArgs = parsedArgs as unknown as Opts;\n\tswitch (unsafeArgs.task) {\n\t\tcase 'deploy':\n\t\t\treturn originate(unsafeArgs);\n\t\tcase 'transfer':\n\t\t\treturn transfer(unsafeArgs);\n\t\tcase 'instantiate-account':\n\t\t\treturn instantiate_account(parsedArgs);\n\t\tcase 'fund':\n\t\t\treturn fund(unsafeArgs);\n\t\tdefault:\n\t\t\treturn sendAsyncErr(`${unsafeArgs} is not an understood task by the Taquito plugin`);\n\t}\n};\n\nexport default main;\n","import {\n\tgetCurrentEnvironment,\n\tgetCurrentEnvironmentConfig,\n\tRequestArgs,\n\tsendAsyncErr,\n\tsendJsonRes,\n\tsendWarn,\n} from '@taqueria/node-sdk';\nimport { TezosToolkit } from '@taquito/taquito';\nimport {\n\tconfigureToolKitForNetwork,\n\tFundOpts,\n\tFundOpts as Opts,\n\tgetDeclaredAccounts,\n\tgetEnvTypeAndNodeConfig,\n\tgetNetworkInstantiatedAccounts,\n} from './common';\nimport { ContractInfo, performTransferOps } from './transfer';\n\ntype TableRow = {\n\taccountAlias: string;\n\taccountAddress: string;\n\tmutezFunded: string;\n};\n\nconst getAccountsInfo = (\n\tparsedArgs: RequestArgs.t,\n\ttezos: TezosToolkit,\n\tinstantiatedAccounts: Record<string, any>,\n): Promise<ContractInfo[]> =>\n\tPromise.all(\n\t\tObject.entries(instantiatedAccounts)\n\t\t\t.map(async (instantiatedAccount: [string, any]) => {\n\t\t\t\tconst alias = instantiatedAccount[0];\n\t\t\t\tconst aliasInfo = instantiatedAccount[1];\n\n\t\t\t\tconst declaredMutez: number | undefined = getDeclaredAccounts(parsedArgs)[alias];\n\t\t\t\tconst currentBalanceInMutez = (await tezos.tz.getBalance(aliasInfo.publicKeyHash)).toNumber();\n\t\t\t\tconst amountToFillInMutez = declaredMutez ? Math.max(declaredMutez - currentBalanceInMutez, 0) : 0;\n\n\t\t\t\tif (!declaredMutez) {\n\t\t\t\t\tsendWarn(\n\t\t\t\t\t\t`Warning: ${alias} is instantiated in the target environment but not declared in the root level \"accounts\" field of ./.taq/config.json so ${alias} will not be funded as you don't have a declared tez amount set there for ${alias}\\n`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tcontractAlias: alias,\n\t\t\t\t\tcontractAddress: aliasInfo.publicKeyHash,\n\t\t\t\t\tparameter: 'Unit',\n\t\t\t\t\tentrypoint: 'default',\n\t\t\t\t\tmutezTransfer: parseInt(amountToFillInMutez.toString()),\n\t\t\t\t};\n\t\t\t}),\n\t)\n\t\t.then(accountsInfo => accountsInfo.filter(accountInfo => accountInfo.mutezTransfer !== 0))\n\t\t.catch(err => sendAsyncErr(`Something went wrong while extracting account information - ${err}`));\n\nconst prepAccountsInfoForDisplay = (accountsInfo: ContractInfo[]): TableRow[] =>\n\taccountsInfo.map(accountInfo => {\n\t\treturn {\n\t\t\taccountAlias: accountInfo.contractAlias,\n\t\t\taccountAddress: accountInfo.contractAddress,\n\t\t\tmutezFunded: accountInfo.mutezTransfer.toString(),\n\t\t};\n\t});\n\nconst fund = async (parsedArgs: FundOpts): Promise<void> => {\n\tconst env = getCurrentEnvironmentConfig(parsedArgs);\n\tif (!env) return sendAsyncErr(`There is no environment called ${parsedArgs.env} in your config.json`);\n\ttry {\n\t\tconst [envType, nodeConfig] = await getEnvTypeAndNodeConfig(parsedArgs, env);\n\t\tif (envType !== 'Network') return sendAsyncErr('taq fund can only be executed in a network environment');\n\t\tconst tezos = await configureToolKitForNetwork(parsedArgs, nodeConfig);\n\n\t\tconst instantiatedAccounts = getNetworkInstantiatedAccounts(nodeConfig);\n\n\t\tconst accountsInfo = await getAccountsInfo(parsedArgs, tezos, instantiatedAccounts);\n\t\tif (accountsInfo.length === 0) {\n\t\t\treturn sendJsonRes(\n\t\t\t\t`All instantiated accounts in the current environment, \"${parsedArgs.env}\", are funded up to or beyond the declared amount`,\n\t\t\t);\n\t\t}\n\n\t\tawait performTransferOps(tezos, getCurrentEnvironment(parsedArgs), accountsInfo, parsedArgs.timeout);\n\n\t\tconst accountsInfoForDisplay = prepAccountsInfoForDisplay(accountsInfo);\n\t\treturn sendJsonRes(accountsInfoForDisplay);\n\t} catch {\n\t\treturn sendAsyncErr('No operations performed');\n\t}\n};\n\nexport default fund;\n","import {\n\tgetAccountPrivateKey,\n\tgetDefaultSandboxAccount,\n\tgetNetworkConfig,\n\tgetSandboxConfig,\n\tRequestArgs,\n\tsendAsyncErr,\n\tsendErr,\n\tTAQ_OPERATOR_ACCOUNT,\n} from '@taqueria/node-sdk';\nimport {\n\tEnvironment,\n\tNetworkConfig,\n\tProtocol,\n\tProxyTaskArgs,\n\tSandboxAccountConfig,\n\tSandboxConfig,\n} from '@taqueria/node-sdk/types';\nimport { importKey, InMemorySigner } from '@taquito/signer';\nimport { TezosToolkit } from '@taquito/taquito';\n\nexport type OriginateOpts = ProxyTaskArgs.t & {\n\tcontract: string;\n\tstorage: string;\n\talias?: string;\n\tsender?: string;\n\tmutez?: string;\n\ttimeout: number;\n};\n\nexport type TransferOpts = ProxyTaskArgs.t & {\n\tcontract: string;\n\tmutez?: string;\n\tparam?: string;\n\tentrypoint?: string;\n\tsender?: string;\n\ttimeout: number;\n};\n\nexport type FundOpts = ProxyTaskArgs.t & {\n\ttimeout: number;\n};\n\nexport type InstantiateAccountOpts = ProxyTaskArgs.t;\n\n// To be used for the main entrypoint of the plugin\nexport type IntersectionOpts = OriginateOpts & TransferOpts & InstantiateAccountOpts & FundOpts;\n\n// To be used for common functions in this file\ntype UnionOpts = OriginateOpts | TransferOpts | InstantiateAccountOpts | FundOpts;\n\nexport const getEnvTypeAndNodeConfig = (\n\tparsedArgs: RequestArgs.t,\n\tenv: Environment.t,\n): Promise<['Network', NetworkConfig.t] | ['Sandbox', SandboxConfig.t]> => {\n\tconst targetConstraintErrMsg = 'Each environment can only have one target, be it a network or a sandbox';\n\tif (env.networks?.length === 1 && env.sandboxes?.length === 1) return sendAsyncErr(targetConstraintErrMsg);\n\tif (env.networks?.length === 1) {\n\t\tconst networkName = env.networks[0];\n\t\tconst network = getNetworkConfig(parsedArgs)(networkName);\n\t\tif (!network) {\n\t\t\treturn sendAsyncErr(\n\t\t\t\t`The current environment is configured to use a network called '${networkName}'; however, no network of this name has been configured in .taq/config.json`,\n\t\t\t);\n\t\t}\n\t\treturn Promise.resolve(['Network', network]);\n\t}\n\tif (env.sandboxes?.length === 1) {\n\t\tconst sandboxName = env.sandboxes[0];\n\t\tconst sandbox = getSandboxConfig(parsedArgs)(sandboxName);\n\t\tif (!sandbox) {\n\t\t\treturn sendAsyncErr(\n\t\t\t\t`The current environment is configured to use a sandbox called '${sandboxName}'; however, no sandbox of this name has been configured in .taq/config.json`,\n\t\t\t);\n\t\t}\n\t\treturn Promise.resolve(['Sandbox', sandbox]);\n\t}\n\treturn sendAsyncErr(targetConstraintErrMsg);\n};\n\nexport const configureToolKitForSandbox = async (sandbox: SandboxConfig.t, sender?: string): Promise<TezosToolkit> => {\n\tlet accountKey: string;\n\tif (sender && sender !== 'default') {\n\t\tconst accounts = getSandboxInstantiatedAccounts(sandbox);\n\t\tif (accounts.hasOwnProperty(sender)) {\n\t\t\taccountKey = accounts[sender].secretKey;\n\t\t} else {\n\t\t\treturn sendAsyncErr(\n\t\t\t\t`${sender} is not an account instantiated in the current environment. Check .taq/config.json`,\n\t\t\t);\n\t\t}\n\t} else {\n\t\tconst defaultAccount = getDefaultSandboxAccount(sandbox);\n\t\tif (!defaultAccount) {\n\t\t\treturn sendAsyncErr(\n\t\t\t\t`No default account is specified in the sandbox to perform the operation. Please use the --sender flag to explicitly specify the account to use as the sender of the operation`,\n\t\t\t);\n\t\t}\n\t\taccountKey = defaultAccount.secretKey;\n\t}\n\n\tconst tezos = new TezosToolkit(sandbox.rpcUrl as string);\n\ttezos.setProvider({ signer: new InMemorySigner(accountKey.replace(/^unencrypted:/, '')) });\n\treturn tezos;\n};\n\nexport const configureToolKitForNetwork = async (\n\tparsedArgs: RequestArgs.t,\n\tnetwork: NetworkConfig.t,\n\tsender?: string,\n): Promise<TezosToolkit> => {\n\tlet account: string;\n\tif (sender && sender !== TAQ_OPERATOR_ACCOUNT) {\n\t\tconst accounts = getNetworkInstantiatedAccounts(network);\n\t\tif (accounts.hasOwnProperty(sender)) {\n\t\t\taccount = sender;\n\t\t} else {\n\t\t\treturn sendAsyncErr(\n\t\t\t\t`${sender} is not an account instantiated in the current environment. Check .taq/config.json`,\n\t\t\t);\n\t\t}\n\t} else {\n\t\taccount = TAQ_OPERATOR_ACCOUNT;\n\t}\n\n\tconst tezos = new TezosToolkit(network.rpcUrl as string);\n\tconst key = await getAccountPrivateKey(parsedArgs, network, account);\n\tawait importKey(tezos, key);\n\treturn tezos;\n};\n\nexport const getDeclaredAccounts = (parsedArgs: RequestArgs.t): Record<string, number> =>\n\tObject.entries(parsedArgs.config.accounts ?? {}).reduce(\n\t\t(acc, declaredAccount) => {\n\t\t\tconst alias: string = declaredAccount[0];\n\t\t\tconst mutez: string | number = declaredAccount[1];\n\t\t\treturn {\n\t\t\t\t...acc,\n\t\t\t\t[alias]: typeof mutez === 'string' ? parseFloat(mutez) : mutez,\n\t\t\t};\n\t\t},\n\t\t{} as Record<string, number>,\n\t);\n\nexport const getSandboxInstantiatedAccounts = (sandbox: SandboxConfig.t): Record<string, SandboxAccountConfig.t> =>\n\t(sandbox?.accounts)\n\t\t? Object.entries(sandbox.accounts).reduce(\n\t\t\t(acc, instantiatedAccount) => {\n\t\t\t\tconst alias: string = instantiatedAccount[0];\n\t\t\t\tconst keys = instantiatedAccount[1];\n\t\t\t\treturn alias !== 'default'\n\t\t\t\t\t? {\n\t\t\t\t\t\t...acc,\n\t\t\t\t\t\t[alias]: keys,\n\t\t\t\t\t}\n\t\t\t\t\t: acc;\n\t\t\t},\n\t\t\t{},\n\t\t)\n\t\t: {};\n\nexport const getNetworkInstantiatedAccounts = (network: NetworkConfig.t): Record<string, any> =>\n\tnetwork.accounts\n\t\t? Object.entries(network.accounts).reduce(\n\t\t\t(acc, instantiatedAccount) => {\n\t\t\t\tconst alias: string = instantiatedAccount[0];\n\t\t\t\tconst keys = instantiatedAccount[1];\n\t\t\t\treturn alias !== TAQ_OPERATOR_ACCOUNT\n\t\t\t\t\t? {\n\t\t\t\t\t\t...acc,\n\t\t\t\t\t\t[alias]: keys,\n\t\t\t\t\t}\n\t\t\t\t\t: acc;\n\t\t\t},\n\t\t\t{},\n\t\t)\n\t\t: {};\n\nexport const generateAccountKeys = async (\n\tparsedArgs: RequestArgs.t,\n\tnetwork: NetworkConfig.t,\n\taccount: string,\n): Promise<void> => {\n\tconst tezos = new TezosToolkit(network.rpcUrl as string);\n\tconst key = await getAccountPrivateKey(parsedArgs, network, account);\n\tawait importKey(tezos, key);\n};\n\nexport const handleOpsError = (err: unknown, env: string): Promise<never> => {\n\tif (err instanceof Error) {\n\t\tconst msg = err.message;\n\t\tif (/ENOTFOUND/.test(msg)) return sendAsyncErr('The RPC URL may be invalid. Check ./.taq/config.json');\n\t\tif (/ECONNREFUSED/.test(msg)) return sendAsyncErr('The RPC URL may be down or the sandbox is not running');\n\t\tif (/empty_implicit_contract/.test(msg)) {\n\t\t\tconst result = msg.match(/(?<=\"implicit\":\")tz[^\"]+(?=\")/);\n\t\t\tconst publicKeyHash = result ? result[0] : undefined;\n\t\t\tif (publicKeyHash) {\n\t\t\t\treturn sendAsyncErr(\n\t\t\t\t\t`The account ${publicKeyHash} for the target environment, \"${env}\", may not be funded\\nTo fund this account:\\n1. Go to https://teztnets.xyz and click \"Faucet\" of the target testnet\\n2. Copy and paste the above key into the wallet address field\\n3. Request some Tez (Note that you might need to wait for a few seconds for the network to register the funds)`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn sendAsyncErr(`Error while performing operation:\\n${err} ${JSON.stringify(err, null, 2)}`);\n};\n\nexport const doWithin = async <T>(seconds: number, fn: () => Promise<T>) => {\n\tlet captured: Error = new Error(\n\t\t'Operation timed out. Please try again and perhaps increase the timeout using the --timeout option.',\n\t);\n\tlet timeout: ReturnType<typeof setTimeout>;\n\n\tconst maxTimeout = new Promise((resolve, reject) => {\n\t\ttimeout = setTimeout(() => {\n\t\t\treject(captured);\n\t\t}, seconds * 1000);\n\t}) as Promise<T>;\n\n\tconst process = async () => {\n\t\twhile (true) {\n\t\t\ttry {\n\t\t\t\tconst retval: T = await fn();\n\t\t\t\treturn retval;\n\t\t\t} catch (err) {\n\t\t\t\tcaptured = err as Error;\n\t\t\t}\n\t\t}\n\t};\n\n\treturn Promise.race<T>([process(), maxTimeout]).then(retval => {\n\t\tclearTimeout(timeout);\n\t\treturn retval;\n\t});\n};\n","import {\n\tgetAddressOfAlias,\n\tgetCurrentEnvironment,\n\tgetCurrentEnvironmentConfig,\n\tgetParameter,\n\tRequestArgs,\n\tsendAsyncErr,\n\tsendJsonRes,\n} from '@taqueria/node-sdk';\nimport { Environment } from '@taqueria/node-sdk/types';\nimport { Expr, Parser } from '@taquito/michel-codec';\nimport { TezosToolkit, WalletOperationBatch } from '@taquito/taquito';\nimport { BatchWalletOperation } from '@taquito/taquito/dist/types/wallet/batch-operation';\nimport {\n\tconfigureToolKitForNetwork,\n\tconfigureToolKitForSandbox,\n\tdoWithin,\n\tgetEnvTypeAndNodeConfig,\n\thandleOpsError,\n\tTransferOpts as Opts,\n} from './common';\n\nexport type ContractInfo = {\n\tcontractAlias: string;\n\tcontractAddress: string;\n\tparameter: string;\n\tentrypoint: string;\n\tmutezTransfer: number;\n};\n\ntype TableRow = {\n\tcontractAlias: string;\n\tcontractAddress: string;\n\tparameter: string;\n\tentrypoint: string;\n\tmutezTransfer: string;\n\tdestination: string;\n};\n\nconst isContractAddress = (contract: string): boolean =>\n\tcontract.startsWith('tz1') || contract.startsWith('tz2') || contract.startsWith('tz3') || contract.startsWith('KT1');\n\nconst getContractInfo = async (parsedArgs: Opts, env: Environment.t): Promise<ContractInfo> => {\n\tconst contract = parsedArgs.contract;\n\tconst protocolArgs = RequestArgs.create(parsedArgs);\n\treturn {\n\t\tcontractAlias: isContractAddress(contract) ? 'N/A' : contract,\n\t\tcontractAddress: isContractAddress(contract) ? contract : await getAddressOfAlias(env, contract),\n\t\tparameter: parsedArgs.param ? await getParameter(protocolArgs, parsedArgs.param) : 'Unit',\n\t\tentrypoint: parsedArgs.entrypoint ?? 'default',\n\t\tmutezTransfer: parseInt(parsedArgs.mutez ?? '0'),\n\t};\n};\n\nconst createBatchForTransfer = (tezos: TezosToolkit, contractsInfo: ContractInfo[]): WalletOperationBatch =>\n\tcontractsInfo.reduce((acc, contractInfo) =>\n\t\tacc.withTransfer({\n\t\t\tto: contractInfo.contractAddress,\n\t\t\tamount: contractInfo.mutezTransfer,\n\t\t\tparameter: {\n\t\t\t\tentrypoint: contractInfo.entrypoint,\n\t\t\t\tvalue: new Parser().parseMichelineExpression(contractInfo.parameter) as Expr,\n\t\t\t},\n\t\t\tmutez: true,\n\t\t}), tezos.wallet.batch());\n\nexport const performTransferOps = async (\n\ttezos: TezosToolkit,\n\tenv: string,\n\tcontractsInfo: ContractInfo[],\n\tmaxTimeout: number,\n): Promise<BatchWalletOperation> => {\n\tconst batch = createBatchForTransfer(tezos, contractsInfo);\n\ttry {\n\t\treturn await doWithin<BatchWalletOperation>(maxTimeout, async () => {\n\t\t\tconst op = await batch.send();\n\t\t\tawait op.confirmation();\n\t\t\treturn op;\n\t\t});\n\t} catch (err) {\n\t\treturn handleOpsError(err, env);\n\t}\n};\n\nconst prepContractInfoForDisplay = (tezos: TezosToolkit, contractInfo: ContractInfo): TableRow => {\n\treturn {\n\t\tcontractAlias: contractInfo.contractAlias,\n\t\tcontractAddress: contractInfo.contractAddress,\n\t\tparameter: contractInfo.parameter,\n\t\tentrypoint: contractInfo.entrypoint,\n\t\tmutezTransfer: contractInfo.mutezTransfer.toString(),\n\t\tdestination: tezos.rpc.getRpcUrl(),\n\t};\n};\n\nconst transfer = async (opts: Opts): Promise<void> => {\n\tconst protocolArgs = RequestArgs.create(opts);\n\tconst env = getCurrentEnvironmentConfig(protocolArgs);\n\tif (!env) return sendAsyncErr(`There is no environment called ${protocolArgs.env} in your config.json`);\n\ttry {\n\t\tconst [envType, nodeConfig] = await getEnvTypeAndNodeConfig(protocolArgs, env);\n\t\tconst tezos = await (envType === 'Network'\n\t\t\t? configureToolKitForNetwork(protocolArgs, nodeConfig, opts.sender)\n\t\t\t: configureToolKitForSandbox(nodeConfig, opts.sender));\n\n\t\tconst contractInfo = await getContractInfo(opts, env);\n\n\t\tawait performTransferOps(tezos, getCurrentEnvironment(protocolArgs), [contractInfo], opts.timeout);\n\n\t\tconst contractInfoForDisplay = prepContractInfoForDisplay(tezos, contractInfo);\n\t\treturn sendJsonRes([contractInfoForDisplay]);\n\t} catch {\n\t\treturn sendAsyncErr('No operations performed');\n\t}\n};\n\nexport default transfer;\n","import { getCurrentEnvironmentConfig, RequestArgs, sendAsyncErr, sendJsonRes, sendWarn } from '@taqueria/node-sdk';\nimport {\n\tgenerateAccountKeys,\n\tgetDeclaredAccounts,\n\tgetEnvTypeAndNodeConfig,\n\tgetNetworkInstantiatedAccounts,\n} from './common';\n\nconst instantiate_account = async (parsedArgs: RequestArgs.t): Promise<void> => {\n\tconst env = getCurrentEnvironmentConfig(parsedArgs);\n\tif (!env) return sendAsyncErr(`There is no environment called ${parsedArgs.env} in your config.json`);\n\ttry {\n\t\tconst [envType, nodeConfig] = await getEnvTypeAndNodeConfig(parsedArgs, env);\n\t\tif (envType !== 'Network') {\n\t\t\treturn sendAsyncErr('taq instantiate-account can only be executed in a network environment');\n\t\t}\n\n\t\tconst declaredAccountAliases = Object.keys(getDeclaredAccounts(parsedArgs));\n\t\tconst instantiatedAccounts = getNetworkInstantiatedAccounts(nodeConfig);\n\n\t\tlet accountsInstantiated = [];\n\t\tfor (const declaredAccountAlias of declaredAccountAliases) {\n\t\t\tif (!instantiatedAccounts.hasOwnProperty(declaredAccountAlias)) {\n\t\t\t\tawait generateAccountKeys(parsedArgs, nodeConfig, declaredAccountAlias);\n\t\t\t\taccountsInstantiated.push(declaredAccountAlias);\n\t\t\t} else {\n\t\t\t\tsendWarn(\n\t\t\t\t\t`Note: ${declaredAccountAlias} is already instantiated in the current environment, \"${parsedArgs.env}\"`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (accountsInstantiated.length !== 0) {\n\t\t\treturn sendJsonRes(\n\t\t\t\t`Accounts instantiated: ${\n\t\t\t\t\taccountsInstantiated.join(', ')\n\t\t\t\t}.\\nPlease execute \"taq fund\" targeting the same environment to fund these accounts`,\n\t\t\t);\n\t\t} else {\n\t\t\treturn sendJsonRes(\n\t\t\t\t`No accounts were instantiated because they were all instantiated in the target environment already`,\n\t\t\t);\n\t\t}\n\t} catch (err) {\n\t\tawait sendAsyncErr('No operations performed');\n\t\tif (parsedArgs.debug) await sendAsyncErr(String(err));\n\t}\n};\n\nexport default instantiate_account;\n","import {\n\taddTzExtensionIfMissing,\n\tgetArtifactsDir,\n\tgetContractContent,\n\tgetCurrentEnvironment,\n\tgetCurrentEnvironmentConfig,\n\tNonEmptyString,\n\tRequestArgs,\n\tsendAsyncErr,\n\tsendErr,\n\tsendJsonRes,\n\tupdateAddressAlias,\n} from '@taqueria/node-sdk';\nimport { OperationContentsAndResultOrigination } from '@taquito/rpc';\nimport { TezosToolkit, WalletOperationBatch } from '@taquito/taquito';\nimport { BatchWalletOperation } from '@taquito/taquito/dist/types/wallet/batch-operation';\nimport { basename, extname, join } from 'path';\nimport {\n\tconfigureToolKitForNetwork,\n\tconfigureToolKitForSandbox,\n\tdoWithin,\n\tgetEnvTypeAndNodeConfig,\n\thandleOpsError,\n\tOriginateOpts as Opts,\n} from './common';\n\ntype ContractInfo = {\n\tcontract: string;\n\tcode: string;\n\tinitStorage: string;\n\tmutezTransfer: number;\n};\n\ntype TableRow = {\n\tcontract: string;\n\taddress: string;\n\talias: string;\n\tbalanceInMutez: string;\n\tdestination: string;\n};\n\nconst getContractPath = (parsedArgs: RequestArgs.t, contractFilename: string) =>\n\tjoin(getArtifactsDir(parsedArgs), /\\.tz$/.test(contractFilename) ? contractFilename : `${contractFilename}.tz`);\n\nconst getDefaultStorageFilename = (contractName: string): string => {\n\tconst baseFilename = basename(contractName, extname(contractName));\n\tconst extFilename = extname(contractName);\n\tconst defaultStorage = `${baseFilename}.default_storage${extFilename}`;\n\treturn defaultStorage;\n};\n\nconst getContractInfo = async (parsedArgs: Opts): Promise<ContractInfo> => {\n\tconst contract = parsedArgs.contract;\n\tconst protocolArgs = RequestArgs.create(parsedArgs);\n\tconst contractWithTzExtension = addTzExtensionIfMissing(contract);\n\tconst contractCode = await getContractContent(protocolArgs, contractWithTzExtension);\n\tif (contractCode === undefined) {\n\t\treturn sendAsyncErr(\n\t\t\t`Please generate ${contractWithTzExtension} with one of the compilers (LIGO, SmartPy, Archetype) or write it manually and put it under /${parsedArgs.config.artifactsDir}\\n`,\n\t\t);\n\t}\n\n\tconst storageFilename = parsedArgs.storage ?? getDefaultStorageFilename(contractWithTzExtension);\n\tconst contractInitStorage = await getContractContent(protocolArgs, storageFilename);\n\tif (contractInitStorage === undefined) {\n\t\treturn sendAsyncErr(\n\t\t\t`❌ No initial storage file was found for ${contractWithTzExtension}\\nStorage must be specified in a file as a Michelson expression and will automatically be linked to this contract if specified with the name \"${\n\t\t\t\tgetDefaultStorageFilename(contractWithTzExtension)\n\t\t\t}\" in the artifacts directory\\nYou can also manually pass a storage file to the originate task using the --storage STORAGE_FILE_NAME option\\n`,\n\t\t);\n\t}\n\n\treturn {\n\t\tcontract,\n\t\tcode: contractCode,\n\t\tinitStorage: contractInitStorage,\n\t\tmutezTransfer: parseInt(parsedArgs.mutez ?? '0'),\n\t};\n};\n\nconst createBatchForOriginate = (tezos: TezosToolkit, contractsInfo: ContractInfo[]): WalletOperationBatch =>\n\tcontractsInfo.reduce((acc, contractInfo) =>\n\t\tacc.withOrigination({\n\t\t\tcode: contractInfo.code,\n\t\t\tinit: contractInfo.initStorage,\n\t\t\tbalance: contractInfo.mutezTransfer.toString(),\n\t\t\tmutez: true,\n\t\t}), tezos.wallet.batch());\n\n// Provide a means to clear intervals that were created but not cleaned up in either\n// Taquito or RxJS. This is a hack to prevent the program from hanging after all promises have resolved.\t\t\nfunction withIntervalHack(fn: CallableFunction) {\n\treturn async function (...args: unknown[]) {\n\t\tconst originalSetInterval = setInterval;\n\t\tconst intervals: NodeJS.Timeout[] = [];\n\n\t\t// Override global setInterval\n\t\t// @ts-ignore\n\t\tglobal.setInterval = (callback, delay) => {\n\t\t\tconst id = originalSetInterval(callback, delay);\n\t\t\tintervals.push(id);\n\t\t\treturn id;\n\t\t};\n\n\t\ttry {\n\t\t\treturn await fn(...args);\n\t\t} finally {\n\t\t\t// Clear intervals and restore original setInterval\n\t\t\tintervals.forEach((id) => clearInterval(id));\n\t\t\tglobal.setInterval = originalSetInterval;\n\t\t}\n\t};\n}\n\nconst performOriginateOps = withIntervalHack((\n\ttezos: TezosToolkit,\n\tenv: string,\n\tcontractsInfo: ContractInfo[],\n\tmaxTimeout: number,\n): Promise<BatchWalletOperation> => {\n\tconst batch = createBatchForOriginate(tezos, contractsInfo);\n\n\ttry {\n\t\treturn doWithin<BatchWalletOperation>(maxTimeout, async () => {\n\t\t\tconst op = await batch.send();\n\t\t\tawait op.confirmation();\n\t\t\treturn op;\n\t\t});\n\t} catch (err) {\n\t\treturn handleOpsError(err, env);\n\t}\n});\n\t\t\t\t\n\nconst prepContractInfoForDisplay = async (\n\tparsedArgs: Opts,\n\ttezos: TezosToolkit,\n\tcontractInfo: ContractInfo,\n\top: BatchWalletOperation,\n): Promise<TableRow> => {\n\tconst protocolArgs = RequestArgs.create(parsedArgs);\n\tconst operationResults = await op.operationResults();\n\tconst originationResults = (operationResults ?? [])\n\t\t.filter(result => result.kind === 'origination')\n\t\t.map(result => result as OperationContentsAndResultOrigination);\n\n\t// Length should be 1 since we are batching originate operations into one\n\tconst result = originationResults.length === 1 ? originationResults[0] : undefined;\n\tconst address = result?.metadata?.operation_result?.originated_contracts?.join(',');\n\tconst alias = parsedArgs.alias ?? basename(contractInfo.contract, extname(contractInfo.contract));\n\n\tconst displayableAddress = address ?? 'Something went wrong during origination';\n\n\tif (address) {\n\t\tconst validatedAddress = NonEmptyString.create(address);\n\t\tawait updateAddressAlias(protocolArgs, alias, validatedAddress);\n\t}\n\n\treturn {\n\t\tcontract: contractInfo.contract,\n\t\taddress: displayableAddress,\n\t\talias: address ? alias : 'N/A',\n\t\tbalanceInMutez: contractInfo.mutezTransfer.toString(),\n\t\tdestination: tezos.rpc.getRpcUrl(),\n\t};\n};\n\nconst originate = async (parsedArgs: Opts): Promise<void> => {\n\tconst protocolArgs = RequestArgs.create(parsedArgs);\n\tconst env = getCurrentEnvironmentConfig(protocolArgs);\n\tif (!env) return sendAsyncErr(`There is no environment called ${parsedArgs.env} in your config.json`);\n\ttry {\n\t\tconst [envType, nodeConfig] = await getEnvTypeAndNodeConfig(protocolArgs, env);\n\t\tconst tezos = await (envType === 'Network'\n\t\t\t? configureToolKitForNetwork(protocolArgs, nodeConfig, parsedArgs.sender)\n\t\t\t: configureToolKitForSandbox(nodeConfig, parsedArgs.sender));\n\n\t\t\n\t\tconst contractInfo = await getContractInfo(parsedArgs);\n\n\t\tconst op = await performOriginateOps(\n\t\t\ttezos,\n\t\t\tgetCurrentEnvironment(protocolArgs),\n\t\t\t[contractInfo],\n\t\t\tparsedArgs.timeout,\n\t\t);\n\n\t\tconst contractInfoForDisplay = await prepContractInfoForDisplay(parsedArgs, tezos, contractInfo, op);\n\t\treturn sendJsonRes([contractInfoForDisplay]);\n\t} catch {\n\t\treturn sendAsyncErr('No operations performed');\n\t}\n};\n\nexport default originate;\n"],"mappings":";AAAA,SAAS,QAAQ,QAAQ,YAAY;;;ACArC,SAAsB,gBAAAA,qBAAoB;;;ACA1C;AAAA,EACC,yBAAAC;AAAA,EACA,+BAAAC;AAAA,EAEA,gBAAAC;AAAA,EACA,eAAAC;AAAA,EACA;AAAA,OACM;;;ACPP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EAEA;AAAA,OACM;AASP,SAAS,WAAW,sBAAsB;AAC1C,SAAS,oBAAoB;AAgCtB,IAAM,0BAA0B,CACtC,YACA,QAC0E;AAtD3E;AAuDC,QAAM,yBAAyB;AAC/B,QAAI,SAAI,aAAJ,mBAAc,YAAW,OAAK,SAAI,cAAJ,mBAAe,YAAW;AAAG,WAAO,aAAa,sBAAsB;AACzG,QAAI,SAAI,aAAJ,mBAAc,YAAW,GAAG;AAC/B,UAAM,cAAc,IAAI,SAAS;AACjC,UAAM,UAA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A,MACV,SAAS;AAAA,QACR,OAAO,OAAO;AAAA,UACb,MAAM;AAAA,UACN,WAAW;AAAA,UACX,cAAc;AAAA,UACd,aAAa;AAAA,UACb,UAAU;AAAA,QACX,CAAC;AAAA,MACF;AAAA,IACD,CAAC;AAAA,IACD,KAAK,OAAO;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aACC;AAAA,MACD,SAAS;AAAA,MACT,UAAU;AAAA,IACX,CAAC;AAAA,EACF;AAAA,EACA,OAAO;AACR,IAAI,QAAQ,IAAI;","names":["sendAsyncErr","getCurrentEnvironment","getCurrentEnvironmentConfig","sendAsyncErr","sendJsonRes","process","RequestArgs","sendAsyncErr","RequestArgs","sendAsyncErr","sendAsyncErr","getCurrentEnvironmentConfig","sendJsonRes","getCurrentEnvironment","getCurrentEnvironmentConfig","sendAsyncErr","sendJsonRes","sendWarn","getCurrentEnvironmentConfig","sendAsyncErr","sendWarn","sendJsonRes","getCurrentEnvironment","getCurrentEnvironmentConfig","RequestArgs","sendAsyncErr","sendJsonRes","getContractInfo","RequestArgs","sendAsyncErr","prepContractInfoForDisplay","result","getCurrentEnvironmentConfig","getCurrentEnvironment","sendJsonRes","sendAsyncErr"]}
package/originate.ts CHANGED
@@ -87,15 +87,41 @@ const createBatchForOriginate = (tezos: TezosToolkit, contractsInfo: ContractInf
87
87
  mutez: true,
88
88
  }), tezos.wallet.batch());
89
89
 
90
- export const performOriginateOps = async (
90
+ // Provide a means to clear intervals that were created but not cleaned up in either
91
+ // Taquito or RxJS. This is a hack to prevent the program from hanging after all promises have resolved.
92
+ function withIntervalHack(fn: CallableFunction) {
93
+ return async function (...args: unknown[]) {
94
+ const originalSetInterval = setInterval;
95
+ const intervals: NodeJS.Timeout[] = [];
96
+
97
+ // Override global setInterval
98
+ // @ts-ignore
99
+ global.setInterval = (callback, delay) => {
100
+ const id = originalSetInterval(callback, delay);
101
+ intervals.push(id);
102
+ return id;
103
+ };
104
+
105
+ try {
106
+ return await fn(...args);
107
+ } finally {
108
+ // Clear intervals and restore original setInterval
109
+ intervals.forEach((id) => clearInterval(id));
110
+ global.setInterval = originalSetInterval;
111
+ }
112
+ };
113
+ }
114
+
115
+ const performOriginateOps = withIntervalHack((
91
116
  tezos: TezosToolkit,
92
117
  env: string,
93
118
  contractsInfo: ContractInfo[],
94
119
  maxTimeout: number,
95
120
  ): Promise<BatchWalletOperation> => {
96
121
  const batch = createBatchForOriginate(tezos, contractsInfo);
122
+
97
123
  try {
98
- return await doWithin<BatchWalletOperation>(maxTimeout, async () => {
124
+ return doWithin<BatchWalletOperation>(maxTimeout, async () => {
99
125
  const op = await batch.send();
100
126
  await op.confirmation();
101
127
  return op;
@@ -103,7 +129,8 @@ export const performOriginateOps = async (
103
129
  } catch (err) {
104
130
  return handleOpsError(err, env);
105
131
  }
106
- };
132
+ });
133
+
107
134
 
108
135
  const prepContractInfoForDisplay = async (
109
136
  parsedArgs: Opts,
@@ -148,6 +175,7 @@ const originate = async (parsedArgs: Opts): Promise<void> => {
148
175
  ? configureToolKitForNetwork(protocolArgs, nodeConfig, parsedArgs.sender)
149
176
  : configureToolKitForSandbox(nodeConfig, parsedArgs.sender));
150
177
 
178
+
151
179
  const contractInfo = await getContractInfo(parsedArgs);
152
180
 
153
181
  const op = await performOriginateOps(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taqueria/plugin-taquito",
3
- "version": "0.37.49",
3
+ "version": "0.37.50",
4
4
  "description": "A taqueria plugin for originating smart contracts using Taquito",
5
5
  "targets": {
6
6
  "default": {
@@ -42,11 +42,12 @@
42
42
  },
43
43
  "homepage": "https://github.com/pinnacle-labs/taqueria#readme",
44
44
  "dependencies": {
45
- "@taqueria/node-sdk": "^0.37.49",
46
- "@taquito/michel-codec": "^17.1.0",
47
- "@taquito/signer": "^17.1.0",
48
- "@taquito/taquito": "^17.1.0",
49
- "fast-glob": "^3.2.12"
45
+ "@taqueria/node-sdk": "^0.37.50",
46
+ "@taquito/michel-codec": "^17.2.0",
47
+ "@taquito/signer": "^17.2.0",
48
+ "@taquito/taquito": "^17.2.0",
49
+ "fast-glob": "^3.2.12",
50
+ "wtfnode": "^0.9.1"
50
51
  },
51
52
  "devDependencies": {
52
53
  "tsup": "6.5.0",
@@ -68,5 +69,5 @@
68
69
  "cjs"
69
70
  ]
70
71
  },
71
- "gitHead": "1db9a91066a26477480a511404062f1ab6124fca"
72
+ "gitHead": "ad97f6c8ae197fc8fab9f02f7f9129c214b4e266"
72
73
  }