@taqueria/plugin-taquito 0.10.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -89,7 +89,12 @@ const $806c5c6032403442$var$createBatch = async (parsedArgs, tezos, destination)
89
89
  return await $806c5c6032403442$var$mapOpToContract(contracts, op, destination);
90
90
  } catch (err) {
91
91
  const error = err;
92
- if (error.message) (0, $iVZbm$taquerianodesdk.sendErr)(error.message);
92
+ if (error.message) {
93
+ const msg = error.message;
94
+ if (/ENOTFOUND/.test(msg)) (0, $iVZbm$taquerianodesdk.sendErr)(msg + " - The RPC URL may be invalid. Check your ./taq/config.json.");
95
+ else if (/ECONNREFUSED/.test(msg)) (0, $iVZbm$taquerianodesdk.sendErr)(msg + " - The RPC URL may be down or the sandbox is not running.");
96
+ else (0, $iVZbm$taquerianodesdk.sendErr)(msg + " - There was a problem communicating with the chain. Perhaps review your RPC URL of the network or sandbox you're targeting.");
97
+ }
93
98
  return undefined;
94
99
  }
95
100
  };
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;AAAA;ACAA;;;;;;AAqCA,MAAM,0CAAoB,GAAG,CAAC,WAAmB,EAAE,IAAU,GAAK;IACjE,MAAM,OAAO,GAAG,CAAA,GAAA,6CAAsB,CAAA,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,AAAC;IAC1D,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC;CACvB,AAAC;AAEF,MAAM,wCAAkB,GAAG,CAAC,gBAAwB,EAAE,UAAgB,GACrE,CAAA,GAAA,gBAAI,CAAA,CAAC,UAAU,CAAC,MAAM,CAAC,YAAY,EAAE,QAAQ,IAAI,CAAC,gBAAgB,CAAC,GAAG,gBAAgB,GAAG,CAAC,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC,AAAC;AAEpH,MAAM,oCAAc,GAAG,CAAC,UAAgB,EAAE,KAAoC,GAC7E,OAAO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CAAC,GAAG,CAAC,KAAI,CAAC,CACtB,IAAI,CAAC,CAAA,IAAI,GACT,IAAI,CAAC,MAAM,CACV,CAAC,MAAM,EAAE,YAAY,GAAK;YACzB,OAAO,YAAY,GAChB;mBAAI,MAAM;mBAA4B,YAAY;aAAC,GACnD,MAAM,CAAC;SACV,EACD,EAAE,CACF,CACD,CACA,IAAI,CAAC,CAAA,OAAO,GAAI,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,GAAG,CAAA,GAAA,kCAAW,CAAA,CAAC,OAAO,CAAC,GAAG,CAAA,GAAA,8BAAO,CAAA,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC;CAC9G,AAAC;IAEF,wCAAyB,GAAV,yCAAS;;;ADlPxB,CAAA,GAAA,6BAAM,CAAA,CAAC,MAAM,CAAC,CAAA,KAAK,GAAK,CAAA;QACvB,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE,KAAK;QACb,OAAO,EAAE,KAAK;QACd,KAAK,EAAE;YACN,CAAA,GAAA,2BAAI,CAAA,CAAC,MAAM,CAAC;gBACX,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,mBAAmB;gBAC5B,WAAW,EAAE,qDAAqD;gBAClE,OAAO,EAAE,EAAE;gBACX,OAAO,EAAE;oBAAC,WAAW;iBAAC;gBACtB,OAAO,EAAE,OAAO;gBAChB,QAAQ,EAAE,kBAAkB;aAC5B,CAAC;SACF;QACD,KAAK,EAAE,CAAA,GAAA,wCAAS,CAAA;KAChB,CAAA,AAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC","sources":["taqueria-plugin-taquito/index.ts","taqueria-plugin-taquito/originate.ts"],"sourcesContent":["import { Plugin, Task } from '@taqueria/node-sdk';\nimport originate from './originate';\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\taliases: ['originate'],\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'application/json',\n\t\t}),\n\t],\n\tproxy: originate,\n}), process.argv);\n","import {\n\tgetCurrentEnvironment,\n\tgetCurrentEnvironmentConfig,\n\tgetDefaultAccount,\n\tgetInitialStorage,\n\tgetNetworkConfig,\n\tgetSandboxAccountConfig,\n\tgetSandboxAccountNames,\n\tgetSandboxConfig,\n\tsendAsyncErr,\n\tsendErr,\n\tsendJsonRes,\n} from '@taqueria/node-sdk';\nimport { Protocol, RequestArgs } from '@taqueria/node-sdk/types';\nimport { OperationContentsAndResultOrigination } from '@taquito/rpc';\nimport { importKey, InMemorySigner } from '@taquito/signer';\nimport { TezosToolkit, WalletOperationBatch } from '@taquito/taquito';\nimport { BatchWalletOperation } from '@taquito/taquito/dist/types/wallet/batch-operation';\nimport glob from 'fast-glob';\nimport { readFile } from 'fs/promises';\nimport { join } from 'path';\n\ninterface Opts extends RequestArgs.t {\n\tcontract?: string;\n}\n\ninterface ContractStorageMapping {\n\tfilename: string;\n\tstorage?: unknown;\n}\n\ninterface OriginationResult {\n\tcontract: string;\n\taddress: string;\n\tdestination: string;\n}\n\nconst getFirstAccountAlias = (sandboxName: string, opts: Opts) => {\n\tconst aliases = getSandboxAccountNames(opts)(sandboxName);\n\treturn aliases.shift();\n};\n\nconst getContractAbspath = (contractFilename: string, parsedArgs: Opts) =>\n\tjoin(parsedArgs.config.artifactsDir, /\\.tz$/.test(contractFilename) ? contractFilename : `${contractFilename}.tz`);\n\nconst addOrigination = (parsedArgs: Opts, batch: Promise<WalletOperationBatch>) =>\n\tasync (mapping: ContractStorageMapping) => {\n\t\tconst contractAbspath = getContractAbspath(mapping.filename, parsedArgs);\n\t\tconst contractData = await readFile(contractAbspath, 'utf-8');\n\t\treturn (await batch).withOrigination({\n\t\t\tcode: contractData,\n\t\t\tstorage: mapping.storage,\n\t\t});\n\t};\n\nconst getValidContracts = async (parsedArgs: Opts) => {\n\tconst contracts = parsedArgs.contract\n\t\t? [parsedArgs.contract]\n\t\t: (await glob('**/*.tz', { cwd: parsedArgs.config.artifactsDir })) as string[];\n\n\treturn contracts.reduce(\n\t\t(retval, filename) => {\n\t\t\tconst storage = getInitialStorage(parsedArgs)(filename);\n\t\t\tif (storage === undefined || storage === null) {\n\t\t\t\tsendErr(\n\t\t\t\t\t`Michelson artifact ${filename} has no initial storage specified for the target environment.\\nStorage is expected to be specified in .taq/config.json at JSON path: environment.${\n\t\t\t\t\t\tgetCurrentEnvironment(parsedArgs)\n\t\t\t\t\t}.storage.\"${filename}\"\\n`,\n\t\t\t\t);\n\t\t\t\treturn retval;\n\t\t\t}\n\t\t\treturn [...retval, { filename, storage }];\n\t\t},\n\t\t[] as ContractStorageMapping[],\n\t);\n};\n\nconst mapOpToContract = async (contracts: ContractStorageMapping[], op: BatchWalletOperation, destination: string) => {\n\tconst results = await op.operationResults();\n\n\treturn contracts.reduce(\n\t\t(retval, contract) => {\n\t\t\t// If initial storage was provided for the contract\n\t\t\t// then we submitted an operation to originate that contract\n\t\t\tif (contract.storage) {\n\t\t\t\t// WARNING - using side effect here.\n\t\t\t\t// For each iteration of reduce, results array is being modified-in-place.\n\t\t\t\t// TODO: Adjust to use recursion to avoid side-effect.\n\t\t\t\tconst result = results.shift() as OperationContentsAndResultOrigination;\n\t\t\t\tconst address = result && result.metadata.operation_result.originated_contracts\n\t\t\t\t\t? result.metadata.operation_result.originated_contracts.join(',')\n\t\t\t\t\t: 'Error';\n\n\t\t\t\treturn [\n\t\t\t\t\t...retval,\n\t\t\t\t\t{\n\t\t\t\t\t\tcontract: contract.filename,\n\t\t\t\t\t\taddress,\n\t\t\t\t\t\tdestination,\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\t...retval,\n\t\t\t\t{\n\t\t\t\t\tcontract: contract.filename,\n\t\t\t\t\taddress: 'Error',\n\t\t\t\t\tdestination,\n\t\t\t\t},\n\t\t\t];\n\t\t},\n\t\t[] as OriginationResult[],\n\t);\n};\n\nconst createBatch = async (parsedArgs: Opts, tezos: TezosToolkit, destination: string) => {\n\tconst contracts = await getValidContracts(parsedArgs);\n\tif (!contracts.length) {\n\t\treturn undefined;\n\t}\n\n\tconst batch = await contracts.reduce(\n\t\t(batch, contractMapping) =>\n\t\t\tcontractMapping.storage\n\t\t\t\t? addOrigination(parsedArgs, batch)(contractMapping)\n\t\t\t\t: batch,\n\t\tPromise.resolve(tezos.wallet.batch()),\n\t);\n\n\ttry {\n\t\tconst op = await batch.send();\n\t\tconst confirmed = await op.confirmation();\n\t\treturn await mapOpToContract(contracts, op, destination);\n\t} catch (err) {\n\t\tconst error = (err as { message: string });\n\t\tif (error.message) sendErr(error.message);\n\t\treturn undefined;\n\t}\n};\n\nconst originateToNetworks = (parsedArgs: Opts, currentEnv: Protocol.Environment.t) =>\n\tcurrentEnv.networks\n\t\t? currentEnv.networks.reduce(\n\t\t\t(retval, networkName) => {\n\t\t\t\tconst network = getNetworkConfig(parsedArgs)(networkName);\n\t\t\t\tif (network) {\n\t\t\t\t\tif (network.rpcUrl) {\n\t\t\t\t\t\tif (network.faucet) {\n\t\t\t\t\t\t\tconst result = (async () => {\n\t\t\t\t\t\t\t\tconst tezos = new TezosToolkit(network.rpcUrl as string);\n\t\t\t\t\t\t\t\tawait importKey(\n\t\t\t\t\t\t\t\t\ttezos,\n\t\t\t\t\t\t\t\t\tnetwork.faucet.email,\n\t\t\t\t\t\t\t\t\tnetwork.faucet.password,\n\t\t\t\t\t\t\t\t\tnetwork.faucet.mnemonic.join(' '),\n\t\t\t\t\t\t\t\t\tnetwork.faucet.activation_code,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn await createBatch(parsedArgs, tezos, networkName);\n\t\t\t\t\t\t\t})();\n\n\t\t\t\t\t\t\treturn [...retval, result];\n\t\t\t\t\t\t} else sendErr(`Network ${networkName} requires a valid faucet in config.json.`);\n\t\t\t\t\t} else sendErr(`Network \"${networkName} is missing an RPC url in config.json.\"`);\n\t\t\t\t} else {\n\t\t\t\t\tsendErr(\n\t\t\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\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn retval;\n\t\t\t},\n\t\t\t[] as Promise<OriginationResult[] | undefined>[],\n\t\t)\n\t\t: [];\n\nconst originateToSandboxes = (parsedArgs: Opts, currentEnv: Protocol.Environment.t) =>\n\tcurrentEnv.sandboxes\n\t\t? currentEnv.sandboxes.reduce(\n\t\t\t(retval, sandboxName) => {\n\t\t\t\tconst sandbox = getSandboxConfig(parsedArgs)(sandboxName);\n\t\t\t\tif (sandbox) {\n\t\t\t\t\tif (sandbox.rpcUrl) {\n\t\t\t\t\t\tlet defaultAccount = getDefaultAccount(parsedArgs)(sandboxName);\n\t\t\t\t\t\tif (!defaultAccount) {\n\t\t\t\t\t\t\tconst first = getFirstAccountAlias(sandboxName, parsedArgs);\n\t\t\t\t\t\t\tif (first) {\n\t\t\t\t\t\t\t\tdefaultAccount = getSandboxAccountConfig(parsedArgs)(sandboxName)(first);\n\t\t\t\t\t\t\t\t// TODO: The error should be a warning, not an error. Descriptive string should not begin with 'Warning:'\n\t\t\t\t\t\t\t\tsendErr(\n\t\t\t\t\t\t\t\t\t`Warning: A default origination account has not been specified for sandbox ${sandboxName}. Taqueria will use the account ${first} for this origination.\\nA default account can be specified in .taq/config.json at JSON path: sandbox.${sandboxName}.accounts.default\\n`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (defaultAccount) {\n\t\t\t\t\t\t\tconst secretKey = defaultAccount.secretKey;\n\t\t\t\t\t\t\tconst result = (async () => {\n\t\t\t\t\t\t\t\tconst tezos = new TezosToolkit(sandbox.rpcUrl as string);\n\t\t\t\t\t\t\t\ttezos.setProvider({\n\t\t\t\t\t\t\t\t\tsigner: new InMemorySigner(secretKey.replace(/^unencrypted:/, '')),\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\treturn await createBatch(parsedArgs, tezos, sandboxName);\n\t\t\t\t\t\t\t})();\n\n\t\t\t\t\t\t\treturn [...retval, result];\n\t\t\t\t\t\t} else sendErr(`No accounts are available for the sandbox called ${sandboxName} to perform origination.`);\n\t\t\t\t\t} else sendErr(`Sandbox \"${sandboxName} is missing an RPC url in config.json.\"`);\n\t\t\t\t} else {\n\t\t\t\t\tsendErr(\n\t\t\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\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn retval;\n\t\t\t},\n\t\t\t[] as Promise<OriginationResult[] | undefined>[],\n\t\t)\n\t\t: [];\n\nexport const originate = <T>(parsedArgs: Opts) => {\n\tconst env = getCurrentEnvironmentConfig(parsedArgs);\n\n\tif (!env) {\n\t\treturn sendAsyncErr(`There is no environment called ${parsedArgs.env} in your config.json.`);\n\t}\n\n\tconst jobs = [\n\t\t...originateToNetworks(parsedArgs, env),\n\t\t...originateToSandboxes(parsedArgs, env),\n\t];\n\n\treturn Promise.all(jobs)\n\t\t.then(jobs =>\n\t\t\tjobs.reduce(\n\t\t\t\t(retval, originations) => {\n\t\t\t\t\treturn originations\n\t\t\t\t\t\t? [...retval as OriginationResult[], ...originations]\n\t\t\t\t\t\t: retval;\n\t\t\t\t},\n\t\t\t\t[],\n\t\t\t)\n\t\t)\n\t\t.then(results => results && results.length > 0 ? sendJsonRes(results) : sendErr(`No contracts originated.`));\n};\n\nexport default originate;\n"],"names":[],"version":3,"file":"index.js.map","sourceRoot":"../"}
1
+ {"mappings":";;;;;;;;;;AAAA;ACAA;;;;;;AAqCA,MAAM,0CAAoB,GAAG,CAAC,WAAmB,EAAE,IAAU,GAAK;IACjE,MAAM,OAAO,GAAG,CAAA,GAAA,6CAAsB,CA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AAK,EAAE,SAAS;QAChB,MAAM,EAAE,KAAK;QACb,OAAO,EAAE,KAAK;QACd,KAAK,EAAE;YACN,CAAA,GAAA,2BAAI,CAAA,CAAC,MAAM,CAAC;gBACX,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,mBAAmB;gBAC5B,WAAW,EAAE,qDAAqD;gBAClE,OAAO,EAAE,EAAE;gBACX,OAAO,EAAE;oBAAC,WAAW;iBAAC;gBACtB,OAAO,EAAE,OAAO;gBAChB,QAAQ,EAAE,kBAAkB;aAC5B,CAAC;SACF;QACD,KAAK,EAAE,CAAA,GAAA,wCAAS,CAAA;KAChB,CAAA,AAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC","sources":["taqueria-plugin-taquito/index.ts","taqueria-plugin-taquito/originate.ts"],"sourcesContent":["import { Plugin, Task } from '@taqueria/node-sdk';\nimport originate from './originate';\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\taliases: ['originate'],\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'application/json',\n\t\t}),\n\t],\n\tproxy: originate,\n}), process.argv);\n","import {\n\tgetCurrentEnvironment,\n\tgetCurrentEnvironmentConfig,\n\tgetDefaultAccount,\n\tgetInitialStorage,\n\tgetNetworkConfig,\n\tgetSandboxAccountConfig,\n\tgetSandboxAccountNames,\n\tgetSandboxConfig,\n\tsendAsyncErr,\n\tsendErr,\n\tsendJsonRes,\n} from '@taqueria/node-sdk';\nimport { Protocol, RequestArgs } from '@taqueria/node-sdk/types';\nimport { OperationContentsAndResultOrigination } from '@taquito/rpc';\nimport { importKey, InMemorySigner } from '@taquito/signer';\nimport { TezosToolkit, WalletOperationBatch } from '@taquito/taquito';\nimport { BatchWalletOperation } from '@taquito/taquito/dist/types/wallet/batch-operation';\nimport glob from 'fast-glob';\nimport { readFile } from 'fs/promises';\nimport { join } from 'path';\n\ninterface Opts extends RequestArgs.t {\n\tcontract?: string;\n}\n\ninterface ContractStorageMapping {\n\tfilename: string;\n\tstorage?: unknown;\n}\n\ninterface OriginationResult {\n\tcontract: string;\n\taddress: string;\n\tdestination: string;\n}\n\nconst getFirstAccountAlias = (sandboxName: string, opts: Opts) => {\n\tconst aliases = getSandboxAccountNames(opts)(sandboxName);\n\treturn aliases.shift();\n};\n\nconst getContractAbspath = (contractFilename: string, parsedArgs: Opts) =>\n\tjoin(parsedArgs.config.artifactsDir, /\\.tz$/.test(contractFilename) ? contractFilename : `${contractFilename}.tz`);\n\nconst addOrigination = (parsedArgs: Opts, batch: Promise<WalletOperationBatch>) =>\n\tasync (mapping: ContractStorageMapping) => {\n\t\tconst contractAbspath = getContractAbspath(mapping.filename, parsedArgs);\n\t\tconst contractData = await readFile(contractAbspath, 'utf-8');\n\t\treturn (await batch).withOrigination({\n\t\t\tcode: contractData,\n\t\t\tstorage: mapping.storage,\n\t\t});\n\t};\n\nconst getValidContracts = async (parsedArgs: Opts) => {\n\tconst contracts = parsedArgs.contract\n\t\t? [parsedArgs.contract]\n\t\t: (await glob('**/*.tz', { cwd: parsedArgs.config.artifactsDir })) as string[];\n\n\treturn contracts.reduce(\n\t\t(retval, filename) => {\n\t\t\tconst storage = getInitialStorage(parsedArgs)(filename);\n\t\t\tif (storage === undefined || storage === null) {\n\t\t\t\tsendErr(\n\t\t\t\t\t`Michelson artifact ${filename} has no initial storage specified for the target environment.\\nStorage is expected to be specified in .taq/config.json at JSON path: environment.${\n\t\t\t\t\t\tgetCurrentEnvironment(parsedArgs)\n\t\t\t\t\t}.storage.\"${filename}\"\\n`,\n\t\t\t\t);\n\t\t\t\treturn retval;\n\t\t\t}\n\t\t\treturn [...retval, { filename, storage }];\n\t\t},\n\t\t[] as ContractStorageMapping[],\n\t);\n};\n\nconst mapOpToContract = async (contracts: ContractStorageMapping[], op: BatchWalletOperation, destination: string) => {\n\tconst results = await op.operationResults();\n\n\treturn contracts.reduce(\n\t\t(retval, contract) => {\n\t\t\t// If initial storage was provided for the contract\n\t\t\t// then we submitted an operation to originate that contract\n\t\t\tif (contract.storage) {\n\t\t\t\t// WARNING - using side effect here.\n\t\t\t\t// For each iteration of reduce, results array is being modified-in-place.\n\t\t\t\t// TODO: Adjust to use recursion to avoid side-effect.\n\t\t\t\tconst result = results.shift() as OperationContentsAndResultOrigination;\n\t\t\t\tconst address = result && result.metadata.operation_result.originated_contracts\n\t\t\t\t\t? result.metadata.operation_result.originated_contracts.join(',')\n\t\t\t\t\t: 'Error';\n\n\t\t\t\treturn [\n\t\t\t\t\t...retval,\n\t\t\t\t\t{\n\t\t\t\t\t\tcontract: contract.filename,\n\t\t\t\t\t\taddress,\n\t\t\t\t\t\tdestination,\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\t...retval,\n\t\t\t\t{\n\t\t\t\t\tcontract: contract.filename,\n\t\t\t\t\taddress: 'Error',\n\t\t\t\t\tdestination,\n\t\t\t\t},\n\t\t\t];\n\t\t},\n\t\t[] as OriginationResult[],\n\t);\n};\n\nconst createBatch = async (parsedArgs: Opts, tezos: TezosToolkit, destination: string) => {\n\tconst contracts = await getValidContracts(parsedArgs);\n\tif (!contracts.length) {\n\t\treturn undefined;\n\t}\n\n\tconst batch = await contracts.reduce(\n\t\t(batch, contractMapping) =>\n\t\t\tcontractMapping.storage\n\t\t\t\t? addOrigination(parsedArgs, batch)(contractMapping)\n\t\t\t\t: batch,\n\t\tPromise.resolve(tezos.wallet.batch()),\n\t);\n\n\ttry {\n\t\tconst op = await batch.send();\n\t\tconst confirmed = await op.confirmation();\n\t\treturn await mapOpToContract(contracts, op, destination);\n\t} catch (err) {\n\t\tconst error = (err as { message: string });\n\t\tif (error.message) {\n\t\t\tconst msg = error.message;\n\t\t\tif (/ENOTFOUND/.test(msg)) {\n\t\t\t\tsendErr(msg + ' - The RPC URL may be invalid. Check your ./taq/config.json.');\n\t\t\t} else if (/ECONNREFUSED/.test(msg)) {\n\t\t\t\tsendErr(msg + ' - The RPC URL may be down or the sandbox is not running.');\n\t\t\t} else {\n\t\t\t\tsendErr(\n\t\t\t\t\tmsg\n\t\t\t\t\t\t+ \" - There was a problem communicating with the chain. Perhaps review your RPC URL of the network or sandbox you're targeting.\",\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n};\n\nconst originateToNetworks = (parsedArgs: Opts, currentEnv: Protocol.Environment.t) =>\n\tcurrentEnv.networks\n\t\t? currentEnv.networks.reduce(\n\t\t\t(retval, networkName) => {\n\t\t\t\tconst network = getNetworkConfig(parsedArgs)(networkName);\n\t\t\t\tif (network) {\n\t\t\t\t\tif (network.rpcUrl) {\n\t\t\t\t\t\tif (network.faucet) {\n\t\t\t\t\t\t\tconst result = (async () => {\n\t\t\t\t\t\t\t\tconst tezos = new TezosToolkit(network.rpcUrl as string);\n\t\t\t\t\t\t\t\tawait importKey(\n\t\t\t\t\t\t\t\t\ttezos,\n\t\t\t\t\t\t\t\t\tnetwork.faucet.email,\n\t\t\t\t\t\t\t\t\tnetwork.faucet.password,\n\t\t\t\t\t\t\t\t\tnetwork.faucet.mnemonic.join(' '),\n\t\t\t\t\t\t\t\t\tnetwork.faucet.activation_code,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn await createBatch(parsedArgs, tezos, networkName);\n\t\t\t\t\t\t\t})();\n\n\t\t\t\t\t\t\treturn [...retval, result];\n\t\t\t\t\t\t} else sendErr(`Network ${networkName} requires a valid faucet in config.json.`);\n\t\t\t\t\t} else sendErr(`Network \"${networkName} is missing an RPC url in config.json.\"`);\n\t\t\t\t} else {\n\t\t\t\t\tsendErr(\n\t\t\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\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn retval;\n\t\t\t},\n\t\t\t[] as Promise<OriginationResult[] | undefined>[],\n\t\t)\n\t\t: [];\n\nconst originateToSandboxes = (parsedArgs: Opts, currentEnv: Protocol.Environment.t) =>\n\tcurrentEnv.sandboxes\n\t\t? currentEnv.sandboxes.reduce(\n\t\t\t(retval, sandboxName) => {\n\t\t\t\tconst sandbox = getSandboxConfig(parsedArgs)(sandboxName);\n\t\t\t\tif (sandbox) {\n\t\t\t\t\tif (sandbox.rpcUrl) {\n\t\t\t\t\t\tlet defaultAccount = getDefaultAccount(parsedArgs)(sandboxName);\n\t\t\t\t\t\tif (!defaultAccount) {\n\t\t\t\t\t\t\tconst first = getFirstAccountAlias(sandboxName, parsedArgs);\n\t\t\t\t\t\t\tif (first) {\n\t\t\t\t\t\t\t\tdefaultAccount = getSandboxAccountConfig(parsedArgs)(sandboxName)(first);\n\t\t\t\t\t\t\t\t// TODO: The error should be a warning, not an error. Descriptive string should not begin with 'Warning:'\n\t\t\t\t\t\t\t\tsendErr(\n\t\t\t\t\t\t\t\t\t`Warning: A default origination account has not been specified for sandbox ${sandboxName}. Taqueria will use the account ${first} for this origination.\\nA default account can be specified in .taq/config.json at JSON path: sandbox.${sandboxName}.accounts.default\\n`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (defaultAccount) {\n\t\t\t\t\t\t\tconst secretKey = defaultAccount.secretKey;\n\t\t\t\t\t\t\tconst result = (async () => {\n\t\t\t\t\t\t\t\tconst tezos = new TezosToolkit(sandbox.rpcUrl as string);\n\t\t\t\t\t\t\t\ttezos.setProvider({\n\t\t\t\t\t\t\t\t\tsigner: new InMemorySigner(secretKey.replace(/^unencrypted:/, '')),\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\treturn await createBatch(parsedArgs, tezos, sandboxName);\n\t\t\t\t\t\t\t})();\n\n\t\t\t\t\t\t\treturn [...retval, result];\n\t\t\t\t\t\t} else sendErr(`No accounts are available for the sandbox called ${sandboxName} to perform origination.`);\n\t\t\t\t\t} else sendErr(`Sandbox \"${sandboxName} is missing an RPC url in config.json.\"`);\n\t\t\t\t} else {\n\t\t\t\t\tsendErr(\n\t\t\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\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn retval;\n\t\t\t},\n\t\t\t[] as Promise<OriginationResult[] | undefined>[],\n\t\t)\n\t\t: [];\n\nexport const originate = <T>(parsedArgs: Opts) => {\n\tconst env = getCurrentEnvironmentConfig(parsedArgs);\n\n\tif (!env) {\n\t\treturn sendAsyncErr(`There is no environment called ${parsedArgs.env} in your config.json.`);\n\t}\n\n\tconst jobs = [\n\t\t...originateToNetworks(parsedArgs, env),\n\t\t...originateToSandboxes(parsedArgs, env),\n\t];\n\n\treturn Promise.all(jobs)\n\t\t.then(jobs =>\n\t\t\tjobs.reduce(\n\t\t\t\t(retval, originations) => {\n\t\t\t\t\treturn originations\n\t\t\t\t\t\t? [...retval as OriginationResult[], ...originations]\n\t\t\t\t\t\t: retval;\n\t\t\t\t},\n\t\t\t\t[],\n\t\t\t)\n\t\t)\n\t\t.then(results => results && results.length > 0 ? sendJsonRes(results) : sendErr(`No contracts originated.`));\n};\n\nexport default originate;\n"],"names":[],"version":3,"file":"index.js.map","sourceRoot":"../"}
package/originate.ts CHANGED
@@ -134,7 +134,19 @@ const createBatch = async (parsedArgs: Opts, tezos: TezosToolkit, destination: s
134
134
  return await mapOpToContract(contracts, op, destination);
135
135
  } catch (err) {
136
136
  const error = (err as { message: string });
137
- if (error.message) sendErr(error.message);
137
+ if (error.message) {
138
+ const msg = error.message;
139
+ if (/ENOTFOUND/.test(msg)) {
140
+ sendErr(msg + ' - The RPC URL may be invalid. Check your ./taq/config.json.');
141
+ } else if (/ECONNREFUSED/.test(msg)) {
142
+ sendErr(msg + ' - The RPC URL may be down or the sandbox is not running.');
143
+ } else {
144
+ sendErr(
145
+ msg
146
+ + " - There was a problem communicating with the chain. Perhaps review your RPC URL of the network or sandbox you're targeting.",
147
+ );
148
+ }
149
+ }
138
150
  return undefined;
139
151
  }
140
152
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taqueria/plugin-taquito",
3
- "version": "0.10.0",
3
+ "version": "0.13.0",
4
4
  "description": "A taqueria plugin for originating smart contracts using Taquito",
5
5
  "targets": {
6
6
  "default": {
@@ -46,7 +46,7 @@
46
46
  "typescript": "^4.7.2"
47
47
  },
48
48
  "dependencies": {
49
- "@taqueria/node-sdk": "^0.10.0",
49
+ "@taqueria/node-sdk": "^0.13.0",
50
50
  "@taquito/signer": "^13.0.1",
51
51
  "@taquito/taquito": "^13.0.1",
52
52
  "fast-glob": "^3.2.11"