@taqueria/plugin-taquito 0.18.0 → 0.19.2

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Taqueria Taquito Plugin
2
2
 
3
- The Taquito plugin provides a stateful task to originate a smart contract to a Tezos sandbox or testnet
3
+ The Taquito plugin provides stateful tasks to originate and interact with smart contracts in Tezos sandboxes or testnets
4
4
 
5
5
  ## Installation
6
6
 
@@ -23,7 +23,7 @@ taq originate <filename>
23
23
 
24
24
  ### Basic description
25
25
 
26
- The Taquito plugin exposes an `taq originate` task in Taqueria which will originate the specified Michelson contract to a Taqueria environment.
26
+ The Taquito plugin exposes a `taq originate` (or `taq deploy`) task in Taqueria which will originate the specified Michelson contract to a Taqueria environment.
27
27
 
28
28
  This will originate a Michelson `.tz` file in the `/artifacts` directory to the default environment (the sandbox named `local`).
29
29
 
@@ -39,6 +39,39 @@ After origination, an alias will be created to refer to the originated contract'
39
39
 
40
40
  - To provide an alias for the originated contract explicitly, use the `--alias` flag and supply a name.
41
41
 
42
+ ## The `taq transfer` task
43
+
44
+ Basic usage is:
45
+
46
+ ```shell
47
+ taq transfer <contract alias or address>
48
+ ```
49
+
50
+ ### Basic description
51
+
52
+ The Taquito plugin exposes a `taq transfer` (or `taq call`) task in Taqueria which will call the specified Michelson contract deployed to a Taqueria environment (default environment is one with sandbox named `local`).
53
+
54
+ This allows interactions from implicit accounts to implicit or smart contract accounts.
55
+
56
+ ### Options
57
+
58
+ - To target a different environment, use the `--env` flag with the named Taqueria environment you want to target.
59
+
60
+ - By default, the amount of tez sent is `0`. Use the `--tez` flag to specify an amount you want.
61
+
62
+ - By default, the parameter is `Unit`. Use the `--param` flag to specify a filename, in `/artifacts`, that contains the content of the parameter for the transfer/call.
63
+
64
+ - By default, the entrypoint is `default`, which points to no specific annotated entrypoint. Use `--entrypoint` to specify an annotated entrypoint to call. E.g. if the parameter type of a Michelson contract is `(or (or (int %decrement) (int %increment)) (unit %reset))`, then there are two ways to call the `increment` entrypoint, with parameter `(Left (Right 14))` or with parameter `14` if your command contains `--entrypoint increment`.
65
+
66
+ ### Examples
67
+
68
+ `taq call counter --param counter.parameter.param1.tz` will call a smart contract aliased as `counter` in the default environment with the parameter contained in that `.tz` file, transferring `0` tez.
69
+
70
+ `taq transfer tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb --tez 20` will transfer `20` tez to that address, which is some implicit account.
71
+
72
+ > ### :page_with_curl: Note
73
+ > `transfer` and `call` are exactly the same task. They are synonyms.
74
+
42
75
  ## Plugin Architecture
43
76
 
44
77
  This is a plugin developed for Taqueria built on NodeJS using the Taqueria Node SDK
package/_readme.eta CHANGED
@@ -2,7 +2,7 @@
2
2
  # Taqueria Taquito Plugin
3
3
  <% } %>
4
4
 
5
- The Taquito plugin provides a stateful task to originate a smart contract to a Tezos sandbox or testnet
5
+ The Taquito plugin provides stateful tasks to originate and interact with smart contracts in Tezos sandboxes or testnets
6
6
 
7
7
  ## Installation
8
8
 
@@ -25,7 +25,7 @@ taq originate <filename>
25
25
 
26
26
  ### Basic description
27
27
 
28
- The Taquito plugin exposes an `taq originate` task in Taqueria which will originate the specified Michelson contract to a Taqueria environment.
28
+ The Taquito plugin exposes a `taq originate` (or `taq deploy`) task in Taqueria which will originate the specified Michelson contract to a Taqueria environment.
29
29
 
30
30
  This will originate a Michelson `.tz` file in the `/artifacts` directory to the default environment (the sandbox named `local`).
31
31
 
@@ -41,6 +41,40 @@ After origination, an alias will be created to refer to the originated contract'
41
41
 
42
42
  - To provide an alias for the originated contract explicitly, use the `--alias` flag and supply a name.
43
43
 
44
+ ## The `taq transfer` task
45
+
46
+ Basic usage is:
47
+
48
+ ```shell
49
+ taq transfer <contract alias or address>
50
+ ```
51
+
52
+ ### Basic description
53
+
54
+ The Taquito plugin exposes a `taq transfer` (or `taq call`) task in Taqueria which will call the specified Michelson contract deployed to a Taqueria environment (default environment is one with sandbox named `local`).
55
+
56
+ This allows interactions from implicit accounts to implicit or smart contract accounts.
57
+
58
+ ### Options
59
+
60
+ - To target a different environment, use the `--env` flag with the named Taqueria environment you want to target.
61
+
62
+ - By default, the amount of tez sent is `0`. Use the `--tez` flag to specify an amount you want.
63
+
64
+ - By default, the parameter is `Unit`. Use the `--param` flag to specify a filename, in `/artifacts`, that contains the content of the parameter for the transfer/call.
65
+
66
+ - By default, the entrypoint is `default`, which points to no specific annotated entrypoint. Use `--entrypoint` to specify an annotated entrypoint to call. E.g. if the parameter type of a Michelson contract is `(or (or (int %decrement) (int %increment)) (unit %reset))`, then there are two ways to call the `increment` entrypoint, with parameter `(Left (Right 14))` or with parameter `14` if your command contains `--entrypoint increment`.
67
+
68
+ ### Examples
69
+
70
+ `taq call counter --param counter.parameter.param1.tz` will call a smart contract aliased as `counter` in the default environment with the parameter contained in that `.tz` file, transferring `0` tez.
71
+
72
+ `taq transfer tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb --tez 20` will transfer `20` tez to that address, which is some implicit account.
73
+
74
+ <%~ it.noteOpenAdmonition %>
75
+ `transfer` and `call` are exactly the same task. They are synonyms.
76
+ <%= it.closeAdmonition %>
77
+
44
78
  ## Plugin Architecture
45
79
 
46
80
  This is a plugin developed for Taqueria built on NodeJS using the Taqueria Node SDK
package/index.js CHANGED
@@ -3,6 +3,8 @@ var $iVZbm$taquitosigner = require("@taquito/signer");
3
3
  var $iVZbm$taquitotaquito = require("@taquito/taquito");
4
4
  var $iVZbm$fspromises = require("fs/promises");
5
5
  var $iVZbm$path = require("path");
6
+ var $iVZbm$taquitomichelcodec = require("@taquito/michel-codec");
7
+
6
8
 
7
9
 
8
10
 
@@ -175,6 +177,102 @@ const $806c5c6032403442$export$acf571c34911f824 = (parsedArgs)=>{
175
177
  var $806c5c6032403442$export$2e2bcd8739ae039 = $806c5c6032403442$export$acf571c34911f824;
176
178
 
177
179
 
180
+
181
+
182
+
183
+
184
+ const $944e64d99e99b46e$var$getFirstAccountAlias = (sandboxName, opts)=>{
185
+ const aliases = (0, $iVZbm$taquerianodesdk.getSandboxAccountNames)(opts)(sandboxName);
186
+ return aliases.shift();
187
+ };
188
+ const $944e64d99e99b46e$var$configureToolKitWithSandbox = async (parsedArgs, sandboxName)=>{
189
+ const sandbox = (0, $iVZbm$taquerianodesdk.getSandboxConfig)(parsedArgs)(sandboxName);
190
+ if (!sandbox) return (0, $iVZbm$taquerianodesdk.sendAsyncErr)(`The current environment is configured to use a sandbox called '${sandboxName}'; however, no sandbox of this name has been configured in .taq/config.json.`);
191
+ let defaultAccount = (0, $iVZbm$taquerianodesdk.getDefaultAccount)(parsedArgs)(sandboxName);
192
+ if (!defaultAccount) {
193
+ const first = $944e64d99e99b46e$var$getFirstAccountAlias(sandboxName, parsedArgs);
194
+ if (first) {
195
+ defaultAccount = (0, $iVZbm$taquerianodesdk.getSandboxAccountConfig)(parsedArgs)(sandboxName)(first);
196
+ (0, $iVZbm$taquerianodesdk.sendErr)(`Warning: A default account has not been specified for sandbox ${sandboxName}. Taqueria will use the account ${first} for this operation.\nA default account can be specified in .taq/config.json at JSON path: sandbox.${sandboxName}.accounts.default\n`);
197
+ }
198
+ }
199
+ if (!defaultAccount) return (0, $iVZbm$taquerianodesdk.sendAsyncErr)(`No accounts are available for the sandbox called ${sandboxName} to perform the operation.`);
200
+ const tezos = new (0, $iVZbm$taquitotaquito.TezosToolkit)(sandbox.rpcUrl);
201
+ tezos.setProvider({
202
+ signer: new (0, $iVZbm$taquitosigner.InMemorySigner)(defaultAccount.secretKey.replace(/^unencrypted:/, ""))
203
+ });
204
+ return tezos;
205
+ };
206
+ const $944e64d99e99b46e$var$configureToolKitWithNetwork = async (parsedArgs, networkName)=>{
207
+ const network = (0, $iVZbm$taquerianodesdk.getNetworkConfig)(parsedArgs)(networkName);
208
+ if (!network) return (0, $iVZbm$taquerianodesdk.sendAsyncErr)(`The current environment is configured to use a network called '${networkName}'; however, no network of this name has been configured in .taq/config.json.`);
209
+ const faucet = network.faucet;
210
+ if (!faucet) return (0, $iVZbm$taquerianodesdk.sendAsyncErr)(`Network ${networkName} requires a valid faucet in config.json.`);
211
+ const tezos = new (0, $iVZbm$taquitotaquito.TezosToolkit)(network.rpcUrl);
212
+ await (0, $iVZbm$taquitosigner.importKey)(tezos, network.faucet.email, network.faucet.password, network.faucet.mnemonic.join(" "), network.faucet.activation_code);
213
+ return tezos;
214
+ };
215
+ const $944e64d99e99b46e$var$configureTezosToolKit = (parsedArgs, env)=>{
216
+ const targetConstraintErrMsg = "Each environment can only have one target, be it a sandbox or a network";
217
+ if (env.sandboxes?.length === 1 && env.networks?.length === 1) return (0, $iVZbm$taquerianodesdk.sendAsyncErr)(targetConstraintErrMsg);
218
+ if (env.sandboxes?.length === 1) return $944e64d99e99b46e$var$configureToolKitWithSandbox(parsedArgs, env.sandboxes[0]);
219
+ if (env.networks?.length === 1) return $944e64d99e99b46e$var$configureToolKitWithNetwork(parsedArgs, env.networks[0]);
220
+ return (0, $iVZbm$taquerianodesdk.sendAsyncErr)(targetConstraintErrMsg);
221
+ };
222
+ const $944e64d99e99b46e$var$isContractAddress = (contract)=>contract.startsWith("tz1") || contract.startsWith("tz2") || contract.startsWith("tz3") || contract.startsWith("KT1");
223
+ const $944e64d99e99b46e$var$getContractInfo = async (parsedArgs, env, tezos)=>{
224
+ const contract = parsedArgs.contract;
225
+ return {
226
+ contractAlias: $944e64d99e99b46e$var$isContractAddress(contract) ? "N/A" : contract,
227
+ contractAddress: $944e64d99e99b46e$var$isContractAddress(contract) ? contract : await (0, $iVZbm$taquerianodesdk.getAddressOfAlias)(env, contract),
228
+ tezTransfer: parsedArgs.tez ?? "0",
229
+ parameter: parsedArgs.param ? await (0, $iVZbm$taquerianodesdk.getParameter)(parsedArgs, parsedArgs.param) : "Unit",
230
+ entrypoint: parsedArgs.entrypoint ?? "default",
231
+ destination: tezos.rpc.getRpcUrl()
232
+ };
233
+ };
234
+ const $944e64d99e99b46e$var$performTransferOp = (tezos, contractInfo)=>{
235
+ return tezos.contract.transfer({
236
+ to: contractInfo.contractAddress,
237
+ amount: parseFloat(contractInfo.tezTransfer),
238
+ parameter: {
239
+ entrypoint: contractInfo.entrypoint,
240
+ value: new (0, $iVZbm$taquitomichelcodec.Parser)().parseMichelineExpression(contractInfo.parameter)
241
+ }
242
+ }).then((op)=>op.confirmation().then(()=>op.hash)).catch((err)=>(0, $iVZbm$taquerianodesdk.sendAsyncErr)(`Error during transfer operation:\n${err} ${JSON.stringify(err, null, 2)}`));
243
+ };
244
+ const $944e64d99e99b46e$export$c9b234447cf4ef7c = async (parsedArgs)=>{
245
+ const env = (0, $iVZbm$taquerianodesdk.getCurrentEnvironmentConfig)(parsedArgs);
246
+ if (!env) return (0, $iVZbm$taquerianodesdk.sendAsyncErr)(`There is no environment called ${parsedArgs.env} in your config.json.`);
247
+ try {
248
+ const tezos = await $944e64d99e99b46e$var$configureTezosToolKit(parsedArgs, env);
249
+ const contractInfo = await $944e64d99e99b46e$var$getContractInfo(parsedArgs, env, tezos);
250
+ await $944e64d99e99b46e$var$performTransferOp(tezos, contractInfo);
251
+ return (0, $iVZbm$taquerianodesdk.sendJsonRes)([
252
+ contractInfo
253
+ ]);
254
+ } catch {
255
+ return (0, $iVZbm$taquerianodesdk.sendAsyncErr)("No operations performed.");
256
+ }
257
+ };
258
+ var $944e64d99e99b46e$export$2e2bcd8739ae039 = $944e64d99e99b46e$export$c9b234447cf4ef7c;
259
+
260
+
261
+ const $e6ed693f861ac256$export$71d25adf06a71b9 = (parsedArgs)=>{
262
+ switch(parsedArgs.task){
263
+ case "originate":
264
+ case "deploy":
265
+ return (0, $806c5c6032403442$export$2e2bcd8739ae039)(parsedArgs);
266
+ case "transfer":
267
+ case "call":
268
+ return (0, $944e64d99e99b46e$export$2e2bcd8739ae039)(parsedArgs);
269
+ default:
270
+ return (0, $iVZbm$taquerianodesdk.sendAsyncErr)(`${parsedArgs.task} is not an understood task by the Taquito plugin`);
271
+ }
272
+ };
273
+ var $e6ed693f861ac256$export$2e2bcd8739ae039 = $e6ed693f861ac256$export$71d25adf06a71b9;
274
+
275
+
178
276
  (0, $iVZbm$taquerianodesdk.Plugin).create((_i18n)=>({
179
277
  alias: "taquito",
180
278
  schema: "1.0",
@@ -201,9 +299,36 @@ var $806c5c6032403442$export$2e2bcd8739ae039 = $806c5c6032403442$export$acf571c3
201
299
  ],
202
300
  handler: "proxy",
203
301
  encoding: "application/json"
302
+ }),
303
+ (0, $iVZbm$taquerianodesdk.Task).create({
304
+ task: "transfer",
305
+ command: "transfer <contract>",
306
+ description: "Transfer/call an implicit account or a smart contract (specified via its alias or address) deployed to a particular environment",
307
+ options: [
308
+ (0, $iVZbm$taquerianodesdk.Option).create({
309
+ flag: "tez",
310
+ description: "Amount of Tez to transfer",
311
+ required: false
312
+ }),
313
+ (0, $iVZbm$taquerianodesdk.Option).create({
314
+ flag: "param",
315
+ description: "Parameter to invoke the smart contract",
316
+ required: false
317
+ }),
318
+ (0, $iVZbm$taquerianodesdk.Option).create({
319
+ flag: "entrypoint",
320
+ description: "You may explicitly specify an entrypoint to make the parameter value shorter, without having to specify a chain of (Left (Right ... 14 ...))",
321
+ required: false
322
+ }),
323
+ ],
324
+ aliases: [
325
+ "call"
326
+ ],
327
+ handler: "proxy",
328
+ encoding: "application/json"
204
329
  }),
205
330
  ],
206
- proxy: (0, $806c5c6032403442$export$2e2bcd8739ae039)
331
+ proxy: (0, $e6ed693f861ac256$export$2e2bcd8739ae039)
207
332
  }), process.argv);
208
333
 
209
334
 
package/index.js.map CHANGED
@@ -1 +1 @@
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,GA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;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 { 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":"../"}
1
+ {"mappings":";;;;;;;AAAA;ACAA;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,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,OA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A,CAAC,MAAM,CAAC;wBACb,IAAI,EAAE,SAAS;wBACf,WAAW,EACV,iJAAiJ;wBAClJ,QAAQ,EAAE,KAAK;qBACf,CAAC;iBACF;gBACD,OAAO,EAAE;oBAAC,WAAW;iBAAC;gBACtB,OAAO,EAAE,OAAO;gBAChB,QAAQ,EAAE,kBAAkB;aAC5B,CAAC;YACF,CAAA,GAAA,2BAAI,CAAA,CAAC,MAAM,CAAC;gBACX,IAAI,EAAE,UAAU;gBAChB,OAAO,EAAE,qBAAqB;gBAC9B,WAAW,EACV,iIAAiI;gBAClI,OAAO,EAAE;oBACR,CAAA,GAAA,6BAAM,CAAA,CAAC,MAAM,CAAC;wBACb,IAAI,EAAE,KAAK;wBACX,WAAW,EAAE,2BAA2B;wBACxC,QAAQ,EAAE,KAAK;qBACf,CAAC;oBACF,CAAA,GAAA,6BAAM,CAAA,CAAC,MAAM,CAAC;wBACb,IAAI,EAAE,OAAO;wBACb,WAAW,EAAE,wCAAwC;wBACrD,QAAQ,EAAE,KAAK;qBACf,CAAC;oBACF,CAAA,GAAA,6BAAM,CAAA,CAAC,MAAM,CAAC;wBACb,IAAI,EAAE,YAAY;wBAClB,WAAW,EACV,8IAA8I;wBAC/I,QAAQ,EAAE,KAAK;qBACf,CAAC;iBACF;gBACD,OAAO,EAAE;oBAAC,MAAM;iBAAC;gBACjB,OAAO,EAAE,OAAO;gBAChB,QAAQ,EAAE,kBAAkB;aAC5B,CAAC;SACF;QACD,KAAK,EAAE,CAAA,GAAA,wCAAO,CAAA;KACd,CAAA,AAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC","sources":["taqueria-plugin-taquito/index.ts","taqueria-plugin-taquito/taquito.ts","taqueria-plugin-taquito/originate.ts","taqueria-plugin-taquito/transfer.ts"],"sourcesContent":["import { Option, Plugin, Task } from '@taqueria/node-sdk';\nimport taquito from './taquito';\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\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: 'tez',\n\t\t\t\t\tdescription: 'Amount of Tez 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: 'Parameter to invoke the smart 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],\n\t\t\taliases: ['call'],\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'application/json',\n\t\t}),\n\t],\n\tproxy: taquito,\n}), process.argv);\n","import { sendAsyncErr } from '@taqueria/node-sdk';\nimport { RequestArgs } from '@taqueria/node-sdk/types';\nimport originate from './originate';\nimport transfer from './transfer';\n\ninterface Opts extends RequestArgs.ProxyRequestArgs {\n\t// from originate.ts\n\tstorage: string;\n\talias?: string;\n\t// from transfer.ts\n\ttez?: string;\n\tparam?: string;\n\tentrypoint?: string;\n\t// from originate.ts and transfer.ts\n\tcontract: string;\n}\n\nexport const taquito = (parsedArgs: Opts): Promise<void> => {\n\tswitch (parsedArgs.task) {\n\t\tcase 'originate':\n\t\tcase 'deploy':\n\t\t\treturn originate(parsedArgs);\n\t\tcase 'transfer':\n\t\tcase 'call':\n\t\t\treturn transfer(parsedArgs);\n\t\tdefault:\n\t\t\treturn sendAsyncErr(`${parsedArgs.task} is not an understood task by the Taquito plugin`);\n\t}\n};\n\nexport default taquito;\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","import {\n\tgetAddressOfAlias,\n\tgetCurrentEnvironmentConfig,\n\tgetDefaultAccount,\n\tgetNetworkConfig,\n\tgetParameter,\n\tgetSandboxAccountConfig,\n\tgetSandboxAccountNames,\n\tgetSandboxConfig,\n\tsendAsyncErr,\n\tsendErr,\n\tsendJsonRes,\n} from '@taqueria/node-sdk';\nimport { Environment, RequestArgs } from '@taqueria/node-sdk/types';\nimport { Expr, Parser } from '@taquito/michel-codec';\nimport { importKey, InMemorySigner } from '@taquito/signer';\nimport { TezosToolkit } from '@taquito/taquito';\n\ninterface Opts extends RequestArgs.t {\n\tcontract: string;\n\ttez?: string;\n\tparam?: string;\n\tentrypoint?: string;\n}\n\ntype TableRow = {\n\tcontractAlias: string;\n\tcontractAddress: string;\n\ttezTransfer: string;\n\tparameter: string;\n\tentrypoint: 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 configureToolKitWithSandbox = async (parsedArgs: Opts, sandboxName: string): Promise<TezosToolkit> => {\n\tconst sandbox = getSandboxConfig(parsedArgs)(sandboxName);\n\tif (!sandbox) {\n\t\treturn sendAsyncErr(\n\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);\n\t}\n\n\tlet defaultAccount = getDefaultAccount(parsedArgs)(sandboxName);\n\tif (!defaultAccount) {\n\t\tconst first = getFirstAccountAlias(sandboxName, parsedArgs);\n\t\tif (first) {\n\t\t\tdefaultAccount = getSandboxAccountConfig(parsedArgs)(sandboxName)(first);\n\t\t\tsendErr(\n\t\t\t\t`Warning: A default account has not been specified for sandbox ${sandboxName}. Taqueria will use the account ${first} for this operation.\\nA default account can be specified in .taq/config.json at JSON path: sandbox.${sandboxName}.accounts.default\\n`,\n\t\t\t);\n\t\t}\n\t}\n\tif (!defaultAccount) {\n\t\treturn sendAsyncErr(`No accounts are available for the sandbox called ${sandboxName} to perform the operation.`);\n\t}\n\n\tconst tezos = new TezosToolkit(sandbox.rpcUrl as string);\n\ttezos.setProvider({\n\t\tsigner: new InMemorySigner((defaultAccount.secretKey as string).replace(/^unencrypted:/, '')),\n\t});\n\treturn tezos;\n};\n\nconst configureToolKitWithNetwork = async (parsedArgs: Opts, networkName: string): Promise<TezosToolkit> => {\n\tconst network = getNetworkConfig(parsedArgs)(networkName);\n\tif (!network) {\n\t\treturn sendAsyncErr(\n\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);\n\t}\n\n\tconst faucet = network.faucet;\n\tif (!faucet) return sendAsyncErr(`Network ${networkName} requires a valid faucet in config.json.`);\n\n\tconst tezos = new TezosToolkit(network.rpcUrl as string);\n\tawait importKey(\n\t\ttezos,\n\t\tnetwork.faucet.email,\n\t\tnetwork.faucet.password,\n\t\tnetwork.faucet.mnemonic.join(' '),\n\t\tnetwork.faucet.activation_code,\n\t);\n\treturn tezos;\n};\n\nconst configureTezosToolKit = (parsedArgs: Opts, env: Environment.t): Promise<TezosToolkit> => {\n\tconst targetConstraintErrMsg = 'Each environment can only have one target, be it a sandbox or a network';\n\tif (env.sandboxes?.length === 1 && env.networks?.length === 1) return sendAsyncErr(targetConstraintErrMsg);\n\tif (env.sandboxes?.length === 1) return configureToolKitWithSandbox(parsedArgs, env.sandboxes[0]);\n\tif (env.networks?.length === 1) return configureToolKitWithNetwork(parsedArgs, env.networks[0]);\n\treturn sendAsyncErr(targetConstraintErrMsg);\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, tezos: TezosToolkit): Promise<TableRow> => {\n\tconst contract = parsedArgs.contract;\n\treturn {\n\t\tcontractAlias: isContractAddress(contract) ? 'N/A' : contract,\n\t\tcontractAddress: isContractAddress(contract) ? contract : await getAddressOfAlias(env, contract),\n\t\ttezTransfer: parsedArgs.tez ?? '0',\n\t\tparameter: parsedArgs.param ? await getParameter(parsedArgs, parsedArgs.param) : 'Unit',\n\t\tentrypoint: parsedArgs.entrypoint ?? 'default',\n\t\tdestination: tezos.rpc.getRpcUrl(),\n\t};\n};\n\nconst performTransferOp = (tezos: TezosToolkit, contractInfo: TableRow): Promise<string> => {\n\treturn tezos.contract\n\t\t.transfer({\n\t\t\tto: contractInfo.contractAddress,\n\t\t\tamount: parseFloat(contractInfo.tezTransfer),\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})\n\t\t.then(op => op.confirmation().then(() => op.hash))\n\t\t.catch(err => sendAsyncErr(`Error during transfer operation:\\n${err} ${JSON.stringify(err, null, 2)}`));\n};\n\nexport const transfer = async (parsedArgs: Opts): 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 tezos = await configureTezosToolKit(parsedArgs, env);\n\t\tconst contractInfo = await getContractInfo(parsedArgs, env, tezos);\n\t\tawait performTransferOp(tezos, contractInfo);\n\t\treturn sendJsonRes([contractInfo]);\n\t} catch {\n\t\treturn sendAsyncErr('No operations performed.');\n\t}\n};\n\nexport default transfer;\n"],"names":[],"version":3,"file":"index.js.map","sourceRoot":"../"}
package/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Option, Plugin, Task } from '@taqueria/node-sdk';
2
- import originate from './originate';
2
+ import taquito from './taquito';
3
3
 
4
4
  Plugin.create(_i18n => ({
5
5
  alias: 'taquito',
@@ -27,6 +27,33 @@ Plugin.create(_i18n => ({
27
27
  handler: 'proxy',
28
28
  encoding: 'application/json',
29
29
  }),
30
+ Task.create({
31
+ task: 'transfer',
32
+ command: 'transfer <contract>',
33
+ description:
34
+ 'Transfer/call an implicit account or a smart contract (specified via its alias or address) deployed to a particular environment',
35
+ options: [
36
+ Option.create({
37
+ flag: 'tez',
38
+ description: 'Amount of Tez to transfer',
39
+ required: false,
40
+ }),
41
+ Option.create({
42
+ flag: 'param',
43
+ description: 'Parameter to invoke the smart contract',
44
+ required: false,
45
+ }),
46
+ Option.create({
47
+ flag: 'entrypoint',
48
+ description:
49
+ 'You may explicitly specify an entrypoint to make the parameter value shorter, without having to specify a chain of (Left (Right ... 14 ...))',
50
+ required: false,
51
+ }),
52
+ ],
53
+ aliases: ['call'],
54
+ handler: 'proxy',
55
+ encoding: 'application/json',
56
+ }),
30
57
  ],
31
- proxy: originate,
58
+ proxy: taquito,
32
59
  }), process.argv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taqueria/plugin-taquito",
3
- "version": "0.18.0",
3
+ "version": "0.19.2",
4
4
  "description": "A taqueria plugin for originating smart contracts using Taquito",
5
5
  "targets": {
6
6
  "default": {
@@ -46,7 +46,8 @@
46
46
  "typescript": "^4.7.2"
47
47
  },
48
48
  "dependencies": {
49
- "@taqueria/node-sdk": "^0.18.0",
49
+ "@taqueria/node-sdk": "^0.19.2",
50
+ "@taquito/michel-codec": "^13.0.1",
50
51
  "@taquito/signer": "^13.0.1",
51
52
  "@taquito/taquito": "^13.0.1",
52
53
  "fast-glob": "^3.2.11"
package/taquito.ts ADDED
@@ -0,0 +1,31 @@
1
+ import { sendAsyncErr } from '@taqueria/node-sdk';
2
+ import { RequestArgs } from '@taqueria/node-sdk/types';
3
+ import originate from './originate';
4
+ import transfer from './transfer';
5
+
6
+ interface Opts extends RequestArgs.ProxyRequestArgs {
7
+ // from originate.ts
8
+ storage: string;
9
+ alias?: string;
10
+ // from transfer.ts
11
+ tez?: string;
12
+ param?: string;
13
+ entrypoint?: string;
14
+ // from originate.ts and transfer.ts
15
+ contract: string;
16
+ }
17
+
18
+ export const taquito = (parsedArgs: Opts): Promise<void> => {
19
+ switch (parsedArgs.task) {
20
+ case 'originate':
21
+ case 'deploy':
22
+ return originate(parsedArgs);
23
+ case 'transfer':
24
+ case 'call':
25
+ return transfer(parsedArgs);
26
+ default:
27
+ return sendAsyncErr(`${parsedArgs.task} is not an understood task by the Taquito plugin`);
28
+ }
29
+ };
30
+
31
+ export default taquito;
package/transfer.ts ADDED
@@ -0,0 +1,141 @@
1
+ import {
2
+ getAddressOfAlias,
3
+ getCurrentEnvironmentConfig,
4
+ getDefaultAccount,
5
+ getNetworkConfig,
6
+ getParameter,
7
+ getSandboxAccountConfig,
8
+ getSandboxAccountNames,
9
+ getSandboxConfig,
10
+ sendAsyncErr,
11
+ sendErr,
12
+ sendJsonRes,
13
+ } from '@taqueria/node-sdk';
14
+ import { Environment, RequestArgs } from '@taqueria/node-sdk/types';
15
+ import { Expr, Parser } from '@taquito/michel-codec';
16
+ import { importKey, InMemorySigner } from '@taquito/signer';
17
+ import { TezosToolkit } from '@taquito/taquito';
18
+
19
+ interface Opts extends RequestArgs.t {
20
+ contract: string;
21
+ tez?: string;
22
+ param?: string;
23
+ entrypoint?: string;
24
+ }
25
+
26
+ type TableRow = {
27
+ contractAlias: string;
28
+ contractAddress: string;
29
+ tezTransfer: string;
30
+ parameter: string;
31
+ entrypoint: string;
32
+ destination: string;
33
+ };
34
+
35
+ const getFirstAccountAlias = (sandboxName: string, opts: Opts) => {
36
+ const aliases = getSandboxAccountNames(opts)(sandboxName);
37
+ return aliases.shift();
38
+ };
39
+
40
+ const configureToolKitWithSandbox = async (parsedArgs: Opts, sandboxName: string): Promise<TezosToolkit> => {
41
+ const sandbox = getSandboxConfig(parsedArgs)(sandboxName);
42
+ if (!sandbox) {
43
+ return sendAsyncErr(
44
+ `The current environment is configured to use a sandbox called '${sandboxName}'; however, no sandbox of this name has been configured in .taq/config.json.`,
45
+ );
46
+ }
47
+
48
+ let defaultAccount = getDefaultAccount(parsedArgs)(sandboxName);
49
+ if (!defaultAccount) {
50
+ const first = getFirstAccountAlias(sandboxName, parsedArgs);
51
+ if (first) {
52
+ defaultAccount = getSandboxAccountConfig(parsedArgs)(sandboxName)(first);
53
+ sendErr(
54
+ `Warning: A default account has not been specified for sandbox ${sandboxName}. Taqueria will use the account ${first} for this operation.\nA default account can be specified in .taq/config.json at JSON path: sandbox.${sandboxName}.accounts.default\n`,
55
+ );
56
+ }
57
+ }
58
+ if (!defaultAccount) {
59
+ return sendAsyncErr(`No accounts are available for the sandbox called ${sandboxName} to perform the operation.`);
60
+ }
61
+
62
+ const tezos = new TezosToolkit(sandbox.rpcUrl as string);
63
+ tezos.setProvider({
64
+ signer: new InMemorySigner((defaultAccount.secretKey as string).replace(/^unencrypted:/, '')),
65
+ });
66
+ return tezos;
67
+ };
68
+
69
+ const configureToolKitWithNetwork = async (parsedArgs: Opts, networkName: string): Promise<TezosToolkit> => {
70
+ const network = getNetworkConfig(parsedArgs)(networkName);
71
+ if (!network) {
72
+ return sendAsyncErr(
73
+ `The current environment is configured to use a network called '${networkName}'; however, no network of this name has been configured in .taq/config.json.`,
74
+ );
75
+ }
76
+
77
+ const faucet = network.faucet;
78
+ if (!faucet) return sendAsyncErr(`Network ${networkName} requires a valid faucet in config.json.`);
79
+
80
+ const tezos = new TezosToolkit(network.rpcUrl as string);
81
+ await importKey(
82
+ tezos,
83
+ network.faucet.email,
84
+ network.faucet.password,
85
+ network.faucet.mnemonic.join(' '),
86
+ network.faucet.activation_code,
87
+ );
88
+ return tezos;
89
+ };
90
+
91
+ const configureTezosToolKit = (parsedArgs: Opts, env: Environment.t): Promise<TezosToolkit> => {
92
+ const targetConstraintErrMsg = 'Each environment can only have one target, be it a sandbox or a network';
93
+ if (env.sandboxes?.length === 1 && env.networks?.length === 1) return sendAsyncErr(targetConstraintErrMsg);
94
+ if (env.sandboxes?.length === 1) return configureToolKitWithSandbox(parsedArgs, env.sandboxes[0]);
95
+ if (env.networks?.length === 1) return configureToolKitWithNetwork(parsedArgs, env.networks[0]);
96
+ return sendAsyncErr(targetConstraintErrMsg);
97
+ };
98
+
99
+ const isContractAddress = (contract: string): boolean =>
100
+ contract.startsWith('tz1') || contract.startsWith('tz2') || contract.startsWith('tz3') || contract.startsWith('KT1');
101
+
102
+ const getContractInfo = async (parsedArgs: Opts, env: Environment.t, tezos: TezosToolkit): Promise<TableRow> => {
103
+ const contract = parsedArgs.contract;
104
+ return {
105
+ contractAlias: isContractAddress(contract) ? 'N/A' : contract,
106
+ contractAddress: isContractAddress(contract) ? contract : await getAddressOfAlias(env, contract),
107
+ tezTransfer: parsedArgs.tez ?? '0',
108
+ parameter: parsedArgs.param ? await getParameter(parsedArgs, parsedArgs.param) : 'Unit',
109
+ entrypoint: parsedArgs.entrypoint ?? 'default',
110
+ destination: tezos.rpc.getRpcUrl(),
111
+ };
112
+ };
113
+
114
+ const performTransferOp = (tezos: TezosToolkit, contractInfo: TableRow): Promise<string> => {
115
+ return tezos.contract
116
+ .transfer({
117
+ to: contractInfo.contractAddress,
118
+ amount: parseFloat(contractInfo.tezTransfer),
119
+ parameter: {
120
+ entrypoint: contractInfo.entrypoint,
121
+ value: new Parser().parseMichelineExpression(contractInfo.parameter) as Expr,
122
+ },
123
+ })
124
+ .then(op => op.confirmation().then(() => op.hash))
125
+ .catch(err => sendAsyncErr(`Error during transfer operation:\n${err} ${JSON.stringify(err, null, 2)}`));
126
+ };
127
+
128
+ export const transfer = async (parsedArgs: Opts): Promise<void> => {
129
+ const env = getCurrentEnvironmentConfig(parsedArgs);
130
+ if (!env) return sendAsyncErr(`There is no environment called ${parsedArgs.env} in your config.json.`);
131
+ try {
132
+ const tezos = await configureTezosToolKit(parsedArgs, env);
133
+ const contractInfo = await getContractInfo(parsedArgs, env, tezos);
134
+ await performTransferOp(tezos, contractInfo);
135
+ return sendJsonRes([contractInfo]);
136
+ } catch {
137
+ return sendAsyncErr('No operations performed.');
138
+ }
139
+ };
140
+
141
+ export default transfer;