@taqueria/plugin-taquito 0.12.0 → 0.13.16

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
@@ -1,14 +1,9 @@
1
1
  var $iVZbm$taquerianodesdk = require("@taqueria/node-sdk");
2
2
  var $iVZbm$taquitosigner = require("@taquito/signer");
3
3
  var $iVZbm$taquitotaquito = require("@taquito/taquito");
4
- var $iVZbm$fastglob = require("fast-glob");
5
4
  var $iVZbm$fspromises = require("fs/promises");
6
5
  var $iVZbm$path = require("path");
7
6
 
8
- function $parcel$interopDefault(a) {
9
- return a && a.__esModule ? a.default : a;
10
- }
11
-
12
7
 
13
8
 
14
9
 
@@ -25,31 +20,42 @@ const $806c5c6032403442$var$addOrigination = (parsedArgs, batch)=>async (mapping
25
20
  const contractData = await (0, $iVZbm$fspromises.readFile)(contractAbspath, "utf-8");
26
21
  return (await batch).withOrigination({
27
22
  code: contractData,
28
- storage: mapping.storage
23
+ init: mapping.storage
29
24
  });
30
25
  };
26
+ const $806c5c6032403442$var$getDefaultStorageFilename = (contractName)=>{
27
+ const baseFilename = (0, $iVZbm$path.basename)(contractName, (0, $iVZbm$path.extname)(contractName));
28
+ const extFilename = (0, $iVZbm$path.extname)(contractName);
29
+ const defaultStorage = `${baseFilename}.default_storage${extFilename}`;
30
+ return defaultStorage;
31
+ };
32
+ // TODO: temporary quick solution. May refactor this to only deal with one contract later
31
33
  const $806c5c6032403442$var$getValidContracts = async (parsedArgs)=>{
32
- const contracts = parsedArgs.contract ? [
34
+ const contracts = [
33
35
  parsedArgs.contract
34
- ] : await (0, ($parcel$interopDefault($iVZbm$fastglob)))("**/*.tz", {
35
- cwd: parsedArgs.config.artifactsDir
36
- });
37
- return contracts.reduce((retval, filename)=>{
38
- const storage = (0, $iVZbm$taquerianodesdk.getInitialStorage)(parsedArgs)(filename);
36
+ ];
37
+ const storageFilename = parsedArgs.storage ?? $806c5c6032403442$var$getDefaultStorageFilename(contracts[0]);
38
+ return contracts.reduce(async (retval, filename)=>{
39
+ const storage = await (0, $iVZbm$taquerianodesdk.newGetInitialStorage)(parsedArgs, storageFilename);
39
40
  if (storage === undefined || storage === null) {
40
- (0, $iVZbm$taquerianodesdk.sendErr)(`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.${(0, $iVZbm$taquerianodesdk.getCurrentEnvironment)(parsedArgs)}.storage."${filename}"\n`);
41
+ (0, $iVZbm$taquerianodesdk.sendErr)(`❌ No initial storage file was found for ${filename}\nStorage must be specified in a file as a Michelson expression and will automatically be linked to this contract if specified with the name "${$806c5c6032403442$var$getDefaultStorageFilename(contracts[0])}" in the artifacts directory\nYou can also manually pass a storage file to the deploy task using the --storage STORAGE_FILE_NAME option\n`);
42
+ // sendErr(
43
+ // `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.${
44
+ // getCurrentEnvironment(parsedArgs)
45
+ // }.storage["${filename}"]\nThe value of the above JSON key should be the name of the file (absolute path or relative path with respect to the root of the Taqueria project) that contains the actual value of the storage, as a Michelson expression.\n`,
46
+ // );
41
47
  return retval;
42
48
  }
43
49
  return [
44
- ...retval,
50
+ ...await retval,
45
51
  {
46
52
  filename: filename,
47
53
  storage: storage
48
54
  }
49
55
  ];
50
- }, []);
56
+ }, Promise.resolve([]));
51
57
  };
52
- const $806c5c6032403442$var$mapOpToContract = async (contracts, op, destination)=>{
58
+ const $806c5c6032403442$var$mapOpToContract = async (parsedArgs, contracts, op, destination)=>{
53
59
  const results = await op.operationResults();
54
60
  return contracts.reduce((retval, contract)=>{
55
61
  // If initial storage was provided for the contract
@@ -60,11 +66,14 @@ const $806c5c6032403442$var$mapOpToContract = async (contracts, op, destination)
60
66
  // TODO: Adjust to use recursion to avoid side-effect.
61
67
  const result = results.shift();
62
68
  const address = result && result.metadata.operation_result.originated_contracts ? result.metadata.operation_result.originated_contracts.join(",") : "Error";
69
+ const alias = parsedArgs.alias ?? (0, $iVZbm$path.basename)(contract.filename, (0, $iVZbm$path.extname)(contract.filename));
70
+ if (address !== "Error") (0, $iVZbm$taquerianodesdk.updateAddressAlias)(parsedArgs, alias, address);
63
71
  return [
64
72
  ...retval,
65
73
  {
66
74
  contract: contract.filename,
67
75
  address: address,
76
+ alias: address !== "Error" ? alias : "N/A",
68
77
  destination: destination
69
78
  },
70
79
  ];
@@ -74,6 +83,7 @@ const $806c5c6032403442$var$mapOpToContract = async (contracts, op, destination)
74
83
  {
75
84
  contract: contract.filename,
76
85
  address: "Error",
86
+ alias: "N/A",
77
87
  destination: destination
78
88
  },
79
89
  ];
@@ -86,10 +96,15 @@ const $806c5c6032403442$var$createBatch = async (parsedArgs, tezos, destination)
86
96
  try {
87
97
  const op = await batch1.send();
88
98
  const confirmed = await op.confirmation();
89
- return await $806c5c6032403442$var$mapOpToContract(contracts, op, destination);
99
+ return await $806c5c6032403442$var$mapOpToContract(parsedArgs, contracts, op, destination);
90
100
  } catch (err) {
91
101
  const error = err;
92
- if (error.message) (0, $iVZbm$taquerianodesdk.sendErr)(error.message);
102
+ if (error.message) {
103
+ const msg = error.message;
104
+ if (/ENOTFOUND/.test(msg)) (0, $iVZbm$taquerianodesdk.sendErr)(msg + " - The RPC URL may be invalid. Check your ./taq/config.json.");
105
+ else if (/ECONNREFUSED/.test(msg)) (0, $iVZbm$taquerianodesdk.sendErr)(msg + " - The RPC URL may be down or the sandbox is not running.");
106
+ 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.");
107
+ }
93
108
  return undefined;
94
109
  }
95
110
  };
@@ -167,9 +182,20 @@ var $806c5c6032403442$export$2e2bcd8739ae039 = $806c5c6032403442$export$acf571c3
167
182
  tasks: [
168
183
  (0, $iVZbm$taquerianodesdk.Task).create({
169
184
  task: "deploy",
170
- command: "deploy [contract]",
185
+ command: "deploy <contract>",
171
186
  description: "Deploy a smart contract to a particular environment",
172
- options: [],
187
+ options: [
188
+ (0, $iVZbm$taquerianodesdk.Option).create({
189
+ flag: "alias",
190
+ description: "Alias used to refer to the deployed contract's address",
191
+ required: false
192
+ }),
193
+ (0, $iVZbm$taquerianodesdk.Option).create({
194
+ flag: "storage",
195
+ description: "Name of the storage file that contains the storage value as a Michelson expression, in the artifacts directory, used for originating a contract",
196
+ required: false
197
+ }),
198
+ ],
173
199
  aliases: [
174
200
  "originate"
175
201
  ],
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,OAA+B,GAAK;QAC1C,MAAM,eAAe,GAAG,wCAAkB,CAAC,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC,AAAC;QACzE,MAAM,YAAY,GAAG,MAAM,CAAA,GAAA,0BAAQ,CAAA,CAAC,eAAe,EAAE,OAAO,CAAC,AAAC;QAC9D,OAAO,AAAC,CAAA,MAAM,KAAK,CAAA,CAAE,eAAe,CAAC;YACpC,IAAI,EAAE,YAAY;YAClB,OAAO,EAAE,OAAO,CAAC,OAAO;SACxB,CAAC,CAAC;KACH,AAAC;AAEH,MAAM,uCA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,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;;;;;AA2CA,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,CA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import { Option, 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\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],\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\tnewGetInitialStorage,\n\tsendAsyncErr,\n\tsendErr,\n\tsendJsonRes,\n\tsendRes,\n\tupdateAddressAlias,\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 { basename, extname, join } from 'path';\n\ninterface Opts extends RequestArgs.t {\n\tcontract: string;\n\tstorage: string;\n\talias?: string;\n}\n\ninterface ContractStorageMapping {\n\tfilename: string;\n\tstorage?: unknown;\n}\n\ninterface OriginationResult {\n\tcontract: string;\n\taddress: string;\n\talias: 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\tinit: mapping.storage as any,\n\t\t});\n\t};\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\n// TODO: temporary quick solution. May refactor this to only deal with one contract later\nconst getValidContracts = async (parsedArgs: Opts) => {\n\tconst contracts = [parsedArgs.contract];\n\tconst storageFilename = parsedArgs.storage ?? getDefaultStorageFilename(contracts[0]);\n\n\treturn contracts.reduce(\n\t\tasync (retval, filename) => {\n\t\t\tconst storage = await newGetInitialStorage(parsedArgs, storageFilename);\n\t\t\tif (storage === undefined || storage === null) {\n\t\t\t\tsendErr(\n\t\t\t\t\t`❌ No initial storage file was found for ${filename}\\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\t\t\tgetDefaultStorageFilename(contracts[0])\n\t\t\t\t\t}\" in the artifacts directory\\nYou can also manually pass a storage file to the deploy task using the --storage STORAGE_FILE_NAME option\\n`,\n\t\t\t\t);\n\t\t\t\t// sendErr(\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}\"]\\nThe value of the above JSON key should be the name of the file (absolute path or relative path with respect to the root of the Taqueria project) that contains the actual value of the storage, as a Michelson expression.\\n`,\n\t\t\t\t// );\n\t\t\t\treturn retval;\n\t\t\t}\n\t\t\treturn [...(await retval), { filename, storage }];\n\t\t},\n\t\tPromise.resolve([] as ContractStorageMapping[]),\n\t);\n};\n\nconst mapOpToContract = async (\n\tparsedArgs: Opts,\n\tcontracts: ContractStorageMapping[],\n\top: BatchWalletOperation,\n\tdestination: string,\n) => {\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\tconst alias = parsedArgs.alias ?? basename(contract.filename, extname(contract.filename));\n\t\t\t\tif (address !== 'Error') updateAddressAlias(parsedArgs, alias, address);\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\talias: address !== 'Error' ? alias : 'N/A',\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\talias: 'N/A',\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(parsedArgs, 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/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Plugin, Task } from '@taqueria/node-sdk';
1
+ import { Option, Plugin, Task } from '@taqueria/node-sdk';
2
2
  import originate from './originate';
3
3
 
4
4
  Plugin.create(_i18n => ({
@@ -8,9 +8,21 @@ Plugin.create(_i18n => ({
8
8
  tasks: [
9
9
  Task.create({
10
10
  task: 'deploy',
11
- command: 'deploy [contract]',
11
+ command: 'deploy <contract>',
12
12
  description: 'Deploy a smart contract to a particular environment',
13
- options: [],
13
+ options: [
14
+ Option.create({
15
+ flag: 'alias',
16
+ description: "Alias used to refer to the deployed contract's address",
17
+ required: false,
18
+ }),
19
+ Option.create({
20
+ flag: 'storage',
21
+ description:
22
+ 'Name of the storage file that contains the storage value as a Michelson expression, in the artifacts directory, used for originating a contract',
23
+ required: false,
24
+ }),
25
+ ],
14
26
  aliases: ['originate'],
15
27
  handler: 'proxy',
16
28
  encoding: 'application/json',
package/originate.ts CHANGED
@@ -7,9 +7,12 @@ import {
7
7
  getSandboxAccountConfig,
8
8
  getSandboxAccountNames,
9
9
  getSandboxConfig,
10
+ newGetInitialStorage,
10
11
  sendAsyncErr,
11
12
  sendErr,
12
13
  sendJsonRes,
14
+ sendRes,
15
+ updateAddressAlias,
13
16
  } from '@taqueria/node-sdk';
14
17
  import { Protocol, RequestArgs } from '@taqueria/node-sdk/types';
15
18
  import { OperationContentsAndResultOrigination } from '@taquito/rpc';
@@ -18,10 +21,12 @@ import { TezosToolkit, WalletOperationBatch } from '@taquito/taquito';
18
21
  import { BatchWalletOperation } from '@taquito/taquito/dist/types/wallet/batch-operation';
19
22
  import glob from 'fast-glob';
20
23
  import { readFile } from 'fs/promises';
21
- import { join } from 'path';
24
+ import { basename, extname, join } from 'path';
22
25
 
23
26
  interface Opts extends RequestArgs.t {
24
- contract?: string;
27
+ contract: string;
28
+ storage: string;
29
+ alias?: string;
25
30
  }
26
31
 
27
32
  interface ContractStorageMapping {
@@ -32,6 +37,7 @@ interface ContractStorageMapping {
32
37
  interface OriginationResult {
33
38
  contract: string;
34
39
  address: string;
40
+ alias: string;
35
41
  destination: string;
36
42
  }
37
43
 
@@ -49,33 +55,50 @@ const addOrigination = (parsedArgs: Opts, batch: Promise<WalletOperationBatch>)
49
55
  const contractData = await readFile(contractAbspath, 'utf-8');
50
56
  return (await batch).withOrigination({
51
57
  code: contractData,
52
- storage: mapping.storage,
58
+ init: mapping.storage as any,
53
59
  });
54
60
  };
55
61
 
62
+ const getDefaultStorageFilename = (contractName: string): string => {
63
+ const baseFilename = basename(contractName, extname(contractName));
64
+ const extFilename = extname(contractName);
65
+ const defaultStorage = `${baseFilename}.default_storage${extFilename}`;
66
+ return defaultStorage;
67
+ };
68
+
69
+ // TODO: temporary quick solution. May refactor this to only deal with one contract later
56
70
  const getValidContracts = async (parsedArgs: Opts) => {
57
- const contracts = parsedArgs.contract
58
- ? [parsedArgs.contract]
59
- : (await glob('**/*.tz', { cwd: parsedArgs.config.artifactsDir })) as string[];
71
+ const contracts = [parsedArgs.contract];
72
+ const storageFilename = parsedArgs.storage ?? getDefaultStorageFilename(contracts[0]);
60
73
 
61
74
  return contracts.reduce(
62
- (retval, filename) => {
63
- const storage = getInitialStorage(parsedArgs)(filename);
75
+ async (retval, filename) => {
76
+ const storage = await newGetInitialStorage(parsedArgs, storageFilename);
64
77
  if (storage === undefined || storage === null) {
65
78
  sendErr(
66
- `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.${
67
- getCurrentEnvironment(parsedArgs)
68
- }.storage."${filename}"\n`,
79
+ `❌ No initial storage file was found for ${filename}\nStorage must be specified in a file as a Michelson expression and will automatically be linked to this contract if specified with the name "${
80
+ getDefaultStorageFilename(contracts[0])
81
+ }" in the artifacts directory\nYou can also manually pass a storage file to the deploy task using the --storage STORAGE_FILE_NAME option\n`,
69
82
  );
83
+ // sendErr(
84
+ // `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.${
85
+ // getCurrentEnvironment(parsedArgs)
86
+ // }.storage["${filename}"]\nThe value of the above JSON key should be the name of the file (absolute path or relative path with respect to the root of the Taqueria project) that contains the actual value of the storage, as a Michelson expression.\n`,
87
+ // );
70
88
  return retval;
71
89
  }
72
- return [...retval, { filename, storage }];
90
+ return [...(await retval), { filename, storage }];
73
91
  },
74
- [] as ContractStorageMapping[],
92
+ Promise.resolve([] as ContractStorageMapping[]),
75
93
  );
76
94
  };
77
95
 
78
- const mapOpToContract = async (contracts: ContractStorageMapping[], op: BatchWalletOperation, destination: string) => {
96
+ const mapOpToContract = async (
97
+ parsedArgs: Opts,
98
+ contracts: ContractStorageMapping[],
99
+ op: BatchWalletOperation,
100
+ destination: string,
101
+ ) => {
79
102
  const results = await op.operationResults();
80
103
 
81
104
  return contracts.reduce(
@@ -91,11 +114,15 @@ const mapOpToContract = async (contracts: ContractStorageMapping[], op: BatchWal
91
114
  ? result.metadata.operation_result.originated_contracts.join(',')
92
115
  : 'Error';
93
116
 
117
+ const alias = parsedArgs.alias ?? basename(contract.filename, extname(contract.filename));
118
+ if (address !== 'Error') updateAddressAlias(parsedArgs, alias, address);
119
+
94
120
  return [
95
121
  ...retval,
96
122
  {
97
123
  contract: contract.filename,
98
124
  address,
125
+ alias: address !== 'Error' ? alias : 'N/A',
99
126
  destination,
100
127
  },
101
128
  ];
@@ -106,6 +133,7 @@ const mapOpToContract = async (contracts: ContractStorageMapping[], op: BatchWal
106
133
  {
107
134
  contract: contract.filename,
108
135
  address: 'Error',
136
+ alias: 'N/A',
109
137
  destination,
110
138
  },
111
139
  ];
@@ -131,10 +159,22 @@ const createBatch = async (parsedArgs: Opts, tezos: TezosToolkit, destination: s
131
159
  try {
132
160
  const op = await batch.send();
133
161
  const confirmed = await op.confirmation();
134
- return await mapOpToContract(contracts, op, destination);
162
+ return await mapOpToContract(parsedArgs, contracts, op, destination);
135
163
  } catch (err) {
136
164
  const error = (err as { message: string });
137
- if (error.message) sendErr(error.message);
165
+ if (error.message) {
166
+ const msg = error.message;
167
+ if (/ENOTFOUND/.test(msg)) {
168
+ sendErr(msg + ' - The RPC URL may be invalid. Check your ./taq/config.json.');
169
+ } else if (/ECONNREFUSED/.test(msg)) {
170
+ sendErr(msg + ' - The RPC URL may be down or the sandbox is not running.');
171
+ } else {
172
+ sendErr(
173
+ msg
174
+ + " - There was a problem communicating with the chain. Perhaps review your RPC URL of the network or sandbox you're targeting.",
175
+ );
176
+ }
177
+ }
138
178
  return undefined;
139
179
  }
140
180
  };
package/package.json CHANGED
@@ -1,54 +1,54 @@
1
1
  {
2
- "name": "@taqueria/plugin-taquito",
3
- "version": "0.12.0",
4
- "description": "A taqueria plugin for originating smart contracts using Taquito",
5
- "targets": {
6
- "default": {
7
- "source": "./index.ts",
8
- "distDir": "./",
9
- "context": "node",
10
- "isLibrary": true
11
- }
12
- },
13
- "scripts": {
14
- "test": "echo \"Error: no test specified\" && exit 1",
15
- "pluginInfo": "npx ts-node index.ts --taqRun pluginInfo --i18n {\"foo:\"\"bar\"}",
16
- "build": "npx tsc -noEmit && npx parcel build --no-cache 2>&1",
17
- "debugPluginInfo": "node --inspect-brk index.js --taqRun pluginInfo --i18n {\"foo:\"\"bar\"}"
18
- },
19
- "keywords": [
20
- "taqueria",
21
- "tezos",
22
- "originate",
23
- "deploy",
24
- "ecad",
25
- "ecadlabs",
26
- "plugin",
27
- "taquito",
28
- "smart contract"
29
- ],
30
- "engines": {
31
- "node": ">=16"
32
- },
33
- "author": "ECAD Labs",
34
- "license": "Apache-2.0",
35
- "repository": {
36
- "type": "git",
37
- "url": "https://github.com/ecadlabs/taqueria.git",
38
- "directory": "taqueria-plugin-taquito"
39
- },
40
- "bugs": {
41
- "url": "https://github.com/ecadlabs/taqueria/issues"
42
- },
43
- "homepage": "https://github.com/ecadlabs/taqueria#readme",
44
- "devDependencies": {
45
- "parcel": "2.6.1",
46
- "typescript": "^4.7.2"
47
- },
48
- "dependencies": {
49
- "@taqueria/node-sdk": "^0.12.0",
50
- "@taquito/signer": "^13.0.1",
51
- "@taquito/taquito": "^13.0.1",
52
- "fast-glob": "^3.2.11"
53
- }
2
+ "name": "@taqueria/plugin-taquito",
3
+ "version": "0.13.16",
4
+ "description": "A taqueria plugin for originating smart contracts using Taquito",
5
+ "targets": {
6
+ "default": {
7
+ "source": "./index.ts",
8
+ "distDir": "./",
9
+ "context": "node",
10
+ "isLibrary": true
11
+ }
12
+ },
13
+ "scripts": {
14
+ "test": "echo \"Error: no test specified\" && exit 1",
15
+ "pluginInfo": "npx ts-node index.ts --taqRun pluginInfo --i18n {\"foo:\"\"bar\"}",
16
+ "build": "npx tsc -noEmit && npx parcel build --no-cache 2>&1",
17
+ "debugPluginInfo": "node --inspect-brk index.js --taqRun pluginInfo --i18n {\"foo:\"\"bar\"}"
18
+ },
19
+ "keywords": [
20
+ "taqueria",
21
+ "tezos",
22
+ "originate",
23
+ "deploy",
24
+ "ecad",
25
+ "ecadlabs",
26
+ "plugin",
27
+ "taquito",
28
+ "smart contract"
29
+ ],
30
+ "engines": {
31
+ "node": ">=16"
32
+ },
33
+ "author": "ECAD Labs",
34
+ "license": "Apache-2.0",
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "https://github.com/ecadlabs/taqueria.git",
38
+ "directory": "taqueria-plugin-taquito"
39
+ },
40
+ "bugs": {
41
+ "url": "https://github.com/ecadlabs/taqueria/issues"
42
+ },
43
+ "homepage": "https://github.com/ecadlabs/taqueria#readme",
44
+ "devDependencies": {
45
+ "parcel": "2.6.1",
46
+ "typescript": "^4.7.2"
47
+ },
48
+ "dependencies": {
49
+ "@taqueria/node-sdk": "^0.13.16",
50
+ "@taquito/signer": "^13.0.1",
51
+ "@taquito/taquito": "^13.0.1",
52
+ "fast-glob": "^3.2.11"
53
+ }
54
54
  }