@taqueria/plugin-taquito 0.2.1 → 0.4.0-rc1

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,34 +1,42 @@
1
1
  # Taqueria Taquito Plugin
2
2
 
3
- This is a plugin developed for Taqueria built using TypeScript for NodeJS using the Taqueria Node SDK
3
+ The Taquito plugin provides a task to originate a smart contract to a Tezos network
4
4
 
5
+ ## Requirements
5
6
 
6
- This is a plugin developed for Taqueria built using TypeScript for NodeJS using the Taqueria Node SDK and distributed via NPM
7
+ The Taquito plugin has no additional requirements
7
8
 
8
- The Taquito plugin exposes a compile task in Taqueria which can target one, or all the Taquito contracts in the contracts folder and compile them to Michelson code output to the artifacts folder
9
+ ## Installation
9
10
 
10
- ## Tasks
11
+ To install the Taquito plugin on a Taqueria project, navigate to the project folder and run:
12
+ ```shell
13
+ taq install @taqueria/plugin-taquito
14
+ ```
11
15
 
12
- The Taquito plugin provides the following tasks to Taqueria:
13
- - `originate`
16
+ ## Configuration
14
17
 
15
- ## Requirements
18
+ ***Coming soon***
16
19
 
17
- - Taqueria v0.0.6 or later
18
- - Node.js v16 or later
19
- - Docker v0.8.4 or later
20
+ ## Usage
20
21
 
21
- ## Installation
22
+ The Taquito plugin exposes an `originate` task in Taqueria which will originate the specified Michelson contract to the configured network
22
23
 
23
- The Taquito plugin is distributed as an NPM package that can be installed and uninstalled on a project from the Taqueria CLI
24
+ ### Originating a Michelson Contract
24
25
 
25
- To install the LIGO plugin on a Taqueria project, navigate to the project folder and run:
26
- ```shell
27
- taq install @taqueria/plugin-taquito
28
- ```
26
+ ***Coming soon***
27
+
28
+ ### Examples
29
+
30
+ ***Coming soon***
29
31
 
30
32
  ## Plugin Architecture
31
33
 
32
- This is a plugin developed for Taqueria built on NodeJS using the Taqueria Node SDK and distributed via NPM
34
+ This is a plugin developed for Taqueria built on NodeJS using the Taqueria Node SDK
35
+
36
+ The plugin provides a single task `originate`, used for originating Michelson contracts to a Tezos network:
33
37
 
34
- For detailed usage and configuration information, view the LIGO plugin documentation on the Taqueria website [here](https://taqueria.io/docs/plugins/plugin-taquito)
38
+ | attribute | value |
39
+ |------------|:-------------------------|
40
+ | task | 'deploy' |
41
+ | command | 'deploy [contract]` |
42
+ | aliases | ['originate'] |
package/_readme.eta ADDED
@@ -0,0 +1,44 @@
1
+ <% if (it.output == "github") { %>
2
+ # Taqueria Taquito Plugin
3
+ <% } %>
4
+
5
+ The Taquito plugin provides a task to originate a smart contract to a Tezos network
6
+
7
+ ## Requirements
8
+
9
+ The Taquito plugin has no additional requirements
10
+
11
+ ## Installation
12
+
13
+ To install the Taquito plugin on a Taqueria project, navigate to the project folder and run:
14
+ ```shell
15
+ taq install @taqueria/plugin-taquito
16
+ ```
17
+
18
+ ## Configuration
19
+
20
+ ***Coming soon***
21
+
22
+ ## Usage
23
+
24
+ The Taquito plugin exposes an `originate` task in Taqueria which will originate the specified Michelson contract to the configured network
25
+
26
+ ### Originating a Michelson Contract
27
+
28
+ ***Coming soon***
29
+
30
+ ### Examples
31
+
32
+ ***Coming soon***
33
+
34
+ ## Plugin Architecture
35
+
36
+ This is a plugin developed for Taqueria built on NodeJS using the Taqueria Node SDK
37
+
38
+ The plugin provides a single task `originate`, used for originating Michelson contracts to a Tezos network:
39
+
40
+ | attribute | value |
41
+ |------------|:-------------------------|
42
+ | task | 'deploy' |
43
+ | command | 'deploy [contract]` |
44
+ | aliases | ['originate'] |
package/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  var $iVZbm$taquerianodesdk = require("@taqueria/node-sdk");
2
- var $iVZbm$fastglob = require("fast-glob");
3
- var $iVZbm$path = require("path");
2
+ var $iVZbm$taquitosigner = require("@taquito/signer");
4
3
  var $iVZbm$taquitotaquito = require("@taquito/taquito");
4
+ var $iVZbm$fastglob = require("fast-glob");
5
5
  var $iVZbm$fspromises = require("fs/promises");
6
- var $iVZbm$taquitosigner = require("@taquito/signer");
6
+ var $iVZbm$path = require("path");
7
7
 
8
8
  function $parcel$interopDefault(a) {
9
9
  return a && a.__esModule ? a.default : a;
@@ -15,153 +15,152 @@ function $parcel$interopDefault(a) {
15
15
 
16
16
 
17
17
 
18
- const $806c5c6032403442$var$getContractAbspath = (contractFilename, parsedArgs)=>$iVZbm$path.join(parsedArgs.artifactsDir, /\.tz$/.test(contractFilename) ? contractFilename : `${contractFilename}.tz`)
19
- ;
20
- const $806c5c6032403442$var$originateContractToSandbox = async (contractFilename, parsedArgs, storage, sandboxName, sandbox)=>{
21
- try {
22
- if (sandbox && sandbox.rpcUrl) {
23
- const contractAbspath = $806c5c6032403442$var$getContractAbspath(contractFilename, parsedArgs);
24
- const tezos = new $iVZbm$taquitotaquito.TezosToolkit(sandbox.rpcUrl);
25
- const secretKey = $806c5c6032403442$var$getAccountSecretKey(sandbox);
26
- if (secretKey) {
27
- tezos.setProvider({
28
- signer: new $iVZbm$taquitosigner.InMemorySigner(secretKey)
29
- });
30
- const contractData = await $iVZbm$fspromises.readFile(contractAbspath, "utf-8");
31
- return tezos.contract.originate({
32
- code: contractData,
33
- storage: storage
34
- }).then((operation)=>({
35
- contract: contractFilename,
36
- address: operation.contractAddress,
37
- destination: sandboxName
38
- })
39
- ).catch((previous)=>Promise.reject({
40
- errCode: "E_ORIGINATE",
41
- errMsg: `Could not originate ${contractFilename} on the sandbox '${sandboxName}'`,
42
- previous: previous
43
- })
44
- );
45
- } else return Promise.reject({
46
- errCode: "E_INVALID_SANDBOX_ACCOUNT",
47
- errMsg: `Please configure a default account for the ${sandboxName} to be used for origination.`,
48
- context: sandbox
49
- });
50
- }
51
- return Promise.reject({
52
- errCode: "E_INVALID_SANDBOX_URL",
53
- errMsg: 'The sandbox configuration is invalid and missing the RPC url',
54
- context: sandbox
55
- });
56
- } catch (err) {
57
- return Promise.reject({
58
- errCode: "E_ORIGINATE",
59
- errMsg: "An unexpected error occured when trying to originate a contract",
60
- previous: err
61
- });
62
- }
18
+ const $806c5c6032403442$var$getFirstAccountAlias = (sandboxName, opts)=>{
19
+ const aliases = (0, $iVZbm$taquerianodesdk.getSandboxAccountNames)(opts)(sandboxName);
20
+ return aliases.shift();
63
21
  };
64
- const $806c5c6032403442$var$originateContractToNetwork = async (contractFilename, parsedArgs, storage, networkName, network)=>{
65
- try {
66
- if (network && network.rpcUrl) {
67
- const contractAbspath = $806c5c6032403442$var$getContractAbspath(contractFilename, parsedArgs);
68
- const tezos = new $iVZbm$taquitotaquito.TezosToolkit(network.rpcUrl);
69
- if (network.faucet) {
70
- await $iVZbm$taquitosigner.importKey(tezos, network.faucet.email, network.faucet.password, network.faucet.mnemonic.join(' '), network.faucet.activation_code);
71
- const contractData = await $iVZbm$fspromises.readFile(contractAbspath, "utf-8");
72
- return tezos.contract.originate({
73
- code: contractData,
74
- storage: storage
75
- }).then((operation)=>({
76
- contract: contractFilename,
77
- address: operation.contractAddress,
78
- destination: networkName
79
- })
80
- ).catch((previous)=>Promise.reject({
81
- errCode: "E_ORIGINATE",
82
- errMsg: `Could not originate ${contractFilename} on the network '${networkName}'`,
83
- previous: previous
84
- })
85
- );
86
- } else return Promise.reject({
87
- errCode: "E_INVALID_NETWORK_FAUCET",
88
- errMsg: `Please configure a faucet for the ${network} network to be used for origination.`,
89
- context: network
90
- });
91
- }
92
- return Promise.reject({
93
- errCode: "E_INVALID_NETWORK_URL",
94
- errMsg: 'The network configuration is invalid and missing the RPC url',
95
- context: network
22
+ const $806c5c6032403442$var$getContractAbspath = (contractFilename, parsedArgs)=>(0, $iVZbm$path.join)(parsedArgs.config.artifactsDir, /\.tz$/.test(contractFilename) ? contractFilename : `${contractFilename}.tz`);
23
+ const $806c5c6032403442$var$addOrigination = (parsedArgs, batch)=>async (mapping)=>{
24
+ const contractAbspath = $806c5c6032403442$var$getContractAbspath(mapping.filename, parsedArgs);
25
+ const contractData = await (0, $iVZbm$fspromises.readFile)(contractAbspath, "utf-8");
26
+ return (await batch).withOrigination({
27
+ code: contractData,
28
+ storage: mapping.storage
96
29
  });
97
- } catch (err) {
98
- return Promise.reject({
99
- errCode: "E_ORIGINATE",
100
- errMsg: "An unexpected error occured when trying to originate a contract",
101
- previous: err
102
- });
103
- }
104
- };
105
- const $806c5c6032403442$var$getNetworkConfig = (networkName, config)=>{
106
- return !config.network[networkName] ? undefined : config.network[networkName];
30
+ };
31
+ const $806c5c6032403442$var$getValidContracts = async (parsedArgs)=>{
32
+ const contracts = parsedArgs.contract ? [
33
+ 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);
39
+ if (!storage) throw `No initial storage provided for ${filename}`;
40
+ return [
41
+ ...retval,
42
+ {
43
+ filename: filename,
44
+ storage: storage
45
+ }
46
+ ];
47
+ }, []);
107
48
  };
108
- const $806c5c6032403442$var$getSandboxConfig = (sandboxName, config)=>{
109
- return !config.sandbox[sandboxName] ? undefined : config.sandbox[sandboxName];
49
+ const $806c5c6032403442$var$mapOpToContract = async (contracts, op, destination)=>{
50
+ const results = await op.operationResults();
51
+ return contracts.reduce((retval, contract)=>{
52
+ // If initial storage was provided for the contract
53
+ // then we submitted an operation to originate that contract
54
+ if (contract.storage) {
55
+ // WARNING - using side effect here.
56
+ // For each iteration of reduce, results array is being modified-in-place.
57
+ // TODO: Adjust to use recursion to avoid side-effect.
58
+ const result = results.shift();
59
+ const address = result && result.metadata.operation_result.originated_contracts ? result.metadata.operation_result.originated_contracts.join(",") : "Error";
60
+ return [
61
+ ...retval,
62
+ {
63
+ contract: contract.filename,
64
+ address: address,
65
+ destination: destination
66
+ },
67
+ ];
68
+ }
69
+ return [
70
+ ...retval,
71
+ {
72
+ contract: contract.filename,
73
+ address: "Error",
74
+ destination: destination
75
+ },
76
+ ];
77
+ }, []);
110
78
  };
111
- const $806c5c6032403442$var$getAccountSecretKey = (sandbox)=>{
112
- if (sandbox.accounts && sandbox.accounts.default) {
113
- const accountName = sandbox.accounts.default;
114
- const accountDetails = sandbox.accounts[accountName];
115
- if (accountDetails.keys) return accountDetails.keys.secretKey.replace(/unencrypted:/, '');
79
+ const $806c5c6032403442$var$createBatch = async (parsedArgs, tezos, destination)=>{
80
+ const contracts = await $806c5c6032403442$var$getValidContracts(parsedArgs);
81
+ const batch1 = await contracts.reduce((batch, contractMapping)=>contractMapping.storage ? $806c5c6032403442$var$addOrigination(parsedArgs, batch)(contractMapping) : batch, Promise.resolve(tezos.wallet.batch()));
82
+ try {
83
+ const op = await batch1.send();
84
+ const confirmed = await op.confirmation();
85
+ return await $806c5c6032403442$var$mapOpToContract(contracts, op, destination);
86
+ } catch (err) {
87
+ const error = err;
88
+ if (error.message) (0, $iVZbm$taquerianodesdk.sendErr)(error.message);
89
+ return undefined;
116
90
  }
117
- return undefined;
118
91
  };
119
- const $806c5c6032403442$var$originateContract = (parsedArgs)=>(contractFilename)=>{
120
- // TODO: Should getting the default environment be provided by the SDK or the framework?
121
- const currentEnv = parsedArgs.env ? parsedArgs.env : parsedArgs.config.environment ? parsedArgs.config.environment.default : 'development';
122
- const env = parsedArgs.config.environment && parsedArgs.config.environment[currentEnv] ? parsedArgs.config.environment[currentEnv] : undefined;
123
- if (!env) return Promise.reject({
124
- errCode: "E_INVALID_ENV",
125
- errMsg: `No environment configured in your configuration file called ${parsedArgs.env}`,
126
- context: parsedArgs.config
127
- });
128
- if (!env.storage || !env.storage[contractFilename]) return Promise.reject({
129
- errCode: "E_INVALID_STORAGE",
130
- errMsg: `No storage configured in your configuration file for ${contractFilename}`,
131
- context: env
132
- });
133
- const networkProcesses = !env.networks ? [] : env.networks.reduce((retval, network)=>$806c5c6032403442$var$getNetworkConfig(network, parsedArgs.config) ? [
134
- ...retval,
135
- $806c5c6032403442$var$originateContractToNetwork(contractFilename, parsedArgs, env.storage[contractFilename], network, $806c5c6032403442$var$getNetworkConfig(network, parsedArgs.config))
136
- ] : retval
137
- , []);
138
- const allProcesses = !env.sandboxes ? [] : env.sandboxes.reduce((retval, sandbox)=>$806c5c6032403442$var$getSandboxConfig(sandbox, parsedArgs.config) ? [
139
- ...retval,
140
- $806c5c6032403442$var$originateContractToSandbox(contractFilename, parsedArgs, env.storage[contractFilename], sandbox, $806c5c6032403442$var$getSandboxConfig(sandbox, parsedArgs.config))
141
- ] : retval
142
- , networkProcesses);
143
- return Promise.all(allProcesses);
144
- }
145
- ;
146
- const $806c5c6032403442$var$originateAll = (parsedArgs)=>($parcel$interopDefault($iVZbm$fastglob))("**/*.tz", {
147
- cwd: parsedArgs.artifactsDir
148
- }).then((files)=>Promise.all(files.map($806c5c6032403442$var$originateContract(parsedArgs)))
149
- ).then((results)=>results.flat(1)
150
- )
151
- ;
92
+ const $806c5c6032403442$var$originateToNetworks = (parsedArgs, currentEnv)=>currentEnv.networks ? currentEnv.networks.reduce((retval, networkName)=>{
93
+ const network = (0, $iVZbm$taquerianodesdk.getNetworkConfig)(parsedArgs)(networkName);
94
+ if (network) {
95
+ if (network.rpcUrl) {
96
+ if (network.faucet) {
97
+ const result = (async ()=>{
98
+ const tezos = new (0, $iVZbm$taquitotaquito.TezosToolkit)(network.rpcUrl);
99
+ await (0, $iVZbm$taquitosigner.importKey)(tezos, network.faucet.email, network.faucet.password, network.faucet.mnemonic.join(" "), network.faucet.activation_code);
100
+ return await $806c5c6032403442$var$createBatch(parsedArgs, tezos, networkName);
101
+ })();
102
+ return [
103
+ ...retval,
104
+ result
105
+ ];
106
+ } else (0, $iVZbm$taquerianodesdk.sendErr)(`Network ${networkName} requires a valid faucet in config.json.`);
107
+ } else (0, $iVZbm$taquerianodesdk.sendErr)(`Network "${networkName} is missing an RPC url in config.json."`);
108
+ } else (0, $iVZbm$taquerianodesdk.sendErr)(`The current environment is configured to use a network called '${networkName}'; however, no network of this name has been configured in .taq/config.json.`);
109
+ return retval;
110
+ }, []) : [];
111
+ const $806c5c6032403442$var$originateToSandboxes = (parsedArgs, currentEnv)=>currentEnv.sandboxes ? currentEnv.sandboxes.reduce((retval, sandboxName)=>{
112
+ const sandbox = (0, $iVZbm$taquerianodesdk.getSandboxConfig)(parsedArgs)(sandboxName);
113
+ if (sandbox) {
114
+ if (sandbox.rpcUrl) {
115
+ let defaultAccount = (0, $iVZbm$taquerianodesdk.getDefaultAccount)(parsedArgs)(sandboxName);
116
+ if (!defaultAccount) {
117
+ const first = $806c5c6032403442$var$getFirstAccountAlias(sandboxName, parsedArgs);
118
+ if (first) {
119
+ defaultAccount = (0, $iVZbm$taquerianodesdk.getSandboxAccountConfig)(parsedArgs)(sandboxName)(first);
120
+ (0, $iVZbm$taquerianodesdk.sendErr)(`No default account has been configured for the sandbox called ${sandboxName}. Using the account called ${first} for origination.`);
121
+ }
122
+ }
123
+ if (defaultAccount) {
124
+ const secretKey = defaultAccount.secretKey;
125
+ const result = (async ()=>{
126
+ const tezos = new (0, $iVZbm$taquitotaquito.TezosToolkit)(sandbox.rpcUrl);
127
+ tezos.setProvider({
128
+ signer: new (0, $iVZbm$taquitosigner.InMemorySigner)(secretKey.replace(/^unencrypted:/, ""))
129
+ });
130
+ return await $806c5c6032403442$var$createBatch(parsedArgs, tezos, sandboxName);
131
+ })();
132
+ return [
133
+ ...retval,
134
+ result
135
+ ];
136
+ } else (0, $iVZbm$taquerianodesdk.sendErr)(`No accounts are available for the sandbox called ${sandboxName} to perform origination.`);
137
+ } else (0, $iVZbm$taquerianodesdk.sendErr)(`Sandbox "${sandboxName} is missing an RPC url in config.json."`);
138
+ } else (0, $iVZbm$taquerianodesdk.sendErr)(`The current environment is configured to use a sandbox called '${sandboxName}'; however, no sandbox of this name has been configured in .taq/config.json.`);
139
+ return retval;
140
+ }, []) : [];
152
141
  const $806c5c6032403442$export$acf571c34911f824 = (parsedArgs)=>{
153
- const p = parsedArgs.contract ? $806c5c6032403442$var$originateContract(parsedArgs)(parsedArgs.contract) : $806c5c6032403442$var$originateAll(parsedArgs);
154
- return p.then($iVZbm$taquerianodesdk.sendAsyncJsonRes);
142
+ const env = (0, $iVZbm$taquerianodesdk.getCurrentEnvironmentConfig)(parsedArgs);
143
+ if (!env) return (0, $iVZbm$taquerianodesdk.sendAsyncErr)(`There is no environment called ${parsedArgs.env} in your config.json.`);
144
+ const jobs1 = [
145
+ ...$806c5c6032403442$var$originateToNetworks(parsedArgs, env),
146
+ ...$806c5c6032403442$var$originateToSandboxes(parsedArgs, env),
147
+ ];
148
+ return Promise.all(jobs1).then((jobs)=>jobs.reduce((retval, originations)=>{
149
+ return originations ? [
150
+ ...retval,
151
+ ...originations
152
+ ] : retval;
153
+ }, [])).then((results)=>results && results.length > 0 ? (0, $iVZbm$taquerianodesdk.sendJsonRes)(results) : (0, $iVZbm$taquerianodesdk.sendErr)(`No contracts originated.`));
155
154
  };
156
155
  var $806c5c6032403442$export$2e2bcd8739ae039 = $806c5c6032403442$export$acf571c34911f824;
157
156
 
158
157
 
159
- $iVZbm$taquerianodesdk.Plugin.create((i18n)=>({
158
+ (0, $iVZbm$taquerianodesdk.Plugin).create((_i18n)=>({
160
159
  alias: "taquito",
161
160
  schema: "1.0",
162
161
  version: "0.1",
163
162
  tasks: [
164
- $iVZbm$taquerianodesdk.Task.create({
163
+ (0, $iVZbm$taquerianodesdk.Task).create({
165
164
  task: "deploy",
166
165
  command: "deploy [contract]",
167
166
  description: "Deploy a smart contract to a particular environment",
@@ -173,9 +172,8 @@ $iVZbm$taquerianodesdk.Plugin.create((i18n)=>({
173
172
  encoding: "application/json"
174
173
  }),
175
174
  ],
176
- proxy: $806c5c6032403442$export$2e2bcd8739ae039
177
- })
178
- , process.argv);
175
+ proxy: (0, $806c5c6032403442$export$2e2bcd8739ae039)
176
+ }), process.argv);
179
177
 
180
178
 
181
179
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;AAAA;ACAA;;;;;;AAgBA,MAAM,wCAAkB,GAAG,CAAC,gBAAwB,EAAE,UAA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CAAC;AAAA;AAE9B,MAAM,yCAAS,GAAG,CAAI,UAAgB,GAA+C;IACxF,MAAM,CAAC,GAAG,UAAU,CAAC,QAAQ,GACvB,uCAAiB,CAAC,UAAU,CAAC,CAAE,UAAU,CAAC,QAAQ,CAAW,GAC7D,kCAAY,CAAC,UAAU,CAAC;IAE9B,OAAO,CAAC,CAAC,IAAI,CAAC,uCAAgB,CAAC,CAAA;CAClC;IAED,wCAAwB,GAAT,yCAAS;;;ADpMxB,6BAAM,CAAC,MAAM,CAAC,CAAC,IAAU,GAAM,CAAA;QAC3B,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE,KAAK;QACb,OAAO,EAAE,KAAK;QACd,KAAK,EAAE;YACH,2BAAI,CAAC,MAAM,CAAC;gBACR,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,mBAAmB;gBAC5B,WAAW,EAAE,qDAAqD;gBAClE,OAAO,EAAE,EACR;gBACD,OAAO,EAAE;oBAAC,WAAW;iBAAC;gBACtB,OAAO,EAAE,OAAO;gBAChB,QAAQ,EAAE,kBAAkB;aAC/B,CAAC;SACL;QACD,KAAK,EAAE,wCAAS;KACnB,CAAA;AAAC,EAAE,OAAO,CAAC,IAAI,CAAC","sources":["taqueria-plugin-taquito/index.ts","taqueria-plugin-taquito/originate.ts"],"sourcesContent":["import {Plugin, Task, EconomicalProtocol} from '@taqueria/node-sdk'\nimport type { i18n} from '@taqueria/node-sdk/types'\nimport originate from './originate'\n\nPlugin.create((i18n: i18n) => ({\n alias: \"taquito\",\n schema: \"1.0\",\n version: \"0.1\",\n tasks: [\n Task.create({\n task: \"deploy\",\n command: \"deploy [contract]\",\n description: \"Deploy a smart contract to a particular environment\",\n options: [\n ],\n aliases: [\"originate\"],\n handler: \"proxy\",\n encoding: \"application/json\"\n }),\n ],\n proxy: originate\n}), process.argv)\n","import { SanitizedArgs, PluginResponse, AccountDetails, Failure, LikeAPromise, Config, NetworkConfig, SandboxConfig} from \"@taqueria/node-sdk/types\";\nimport glob from 'fast-glob'\nimport {join} from 'path'\nimport { TezosToolkit } from '@taquito/taquito';\nimport {readFile} from 'fs/promises'\nimport { InMemorySigner, importKey } from '@taquito/signer';\nimport { sendAsyncJsonRes } from \"@taqueria/node-sdk\";\n\ntype Opts = SanitizedArgs & Record<string, unknown>\n\ninterface OriginationResult {\n contract: string\n address: string\n destination: string\n}\n\nconst getContractAbspath = (contractFilename: string, parsedArgs: Opts) => \n join(parsedArgs.artifactsDir, /\\.tz$/.test(contractFilename) ? contractFilename : `${contractFilename}.tz`)\n\n\nconst originateContractToSandbox = async (contractFilename: string, parsedArgs: Opts, storage: unknown, sandboxName: string, sandbox: SandboxConfig | undefined): LikeAPromise<OriginationResult, Failure<unknown>> => {\n try {\n if (sandbox && sandbox.rpcUrl) {\n const contractAbspath = getContractAbspath(contractFilename, parsedArgs)\n const tezos = new TezosToolkit(sandbox.rpcUrl)\n const secretKey = getAccountSecretKey(sandbox)\n if (secretKey) {\n tezos.setProvider({\n signer: new InMemorySigner(secretKey),\n });\n\n const contractData = await readFile(contractAbspath, \"utf-8\")\n return tezos.contract.originate({\n code: contractData,\n storage: storage\n })\n .then(operation => ({\n contract: contractFilename,\n address: operation.contractAddress as string,\n destination: sandboxName\n }))\n .catch(previous => Promise.reject({\n errCode: \"E_ORIGINATE\",\n errMsg: `Could not originate ${contractFilename} on the sandbox '${sandboxName}'`,\n previous\n }))\n }\n else {\n return Promise.reject({\n errCode: \"E_INVALID_SANDBOX_ACCOUNT\",\n errMsg: `Please configure a default account for the ${sandboxName} to be used for origination.`,\n context: sandbox\n })\n }\n }\n return Promise.reject({\n errCode: \"E_INVALID_SANDBOX_URL\",\n errMsg: 'The sandbox configuration is invalid and missing the RPC url',\n context: sandbox\n })\n }\n catch (err) {\n return Promise.reject({\n errCode: \"E_ORIGINATE\",\n errMsg: \"An unexpected error occured when trying to originate a contract\",\n previous: err\n })\n }\n}\n\nconst originateContractToNetwork = async (contractFilename: string, parsedArgs: Opts, storage: unknown, networkName: string, network: NetworkConfig|undefined): LikeAPromise<OriginationResult, Failure<unknown>> => {\n try {\n if (network && network.rpcUrl) {\n const contractAbspath = getContractAbspath(contractFilename, parsedArgs)\n const tezos = new TezosToolkit(network.rpcUrl)\n if (network.faucet) {\n await importKey(tezos, network.faucet.email, network.faucet.password, network.faucet.mnemonic.join(' '), network.faucet.activation_code)\n\n const contractData = await readFile(contractAbspath, \"utf-8\")\n return tezos.contract.originate({\n code: contractData,\n storage: storage\n })\n .then(operation => ({\n contract: contractFilename,\n address: operation.contractAddress as string,\n destination: networkName\n }))\n .catch(previous => Promise.reject({\n errCode: \"E_ORIGINATE\",\n errMsg: `Could not originate ${contractFilename} on the network '${networkName}'`,\n previous\n }))\n }\n else {\n return Promise.reject({\n errCode: \"E_INVALID_NETWORK_FAUCET\",\n errMsg: `Please configure a faucet for the ${network} network to be used for origination.`,\n context: network\n })\n }\n }\n return Promise.reject({\n errCode: \"E_INVALID_NETWORK_URL\",\n errMsg: 'The network configuration is invalid and missing the RPC url',\n context: network\n })\n }\n catch (err) {\n return Promise.reject({\n errCode: \"E_ORIGINATE\",\n errMsg: \"An unexpected error occured when trying to originate a contract\",\n previous: err\n })\n }\n}\n\nconst getNetworkConfig = (networkName: string, config: Config) => {\n return !config.network[networkName]\n ? undefined\n : config.network[networkName]\n}\n\nconst getSandboxConfig = (sandboxName: string, config: Config) => {\n return !config.sandbox[sandboxName]\n ? undefined\n : config.sandbox[sandboxName]\n}\n\nconst getAccountSecretKey = (sandbox: SandboxConfig) => {\n if (sandbox.accounts && sandbox.accounts.default) {\n const accountName = (sandbox.accounts.default as string);\n const accountDetails = sandbox.accounts[accountName] as AccountDetails\n if (accountDetails.keys) return accountDetails.keys.secretKey.replace(/unencrypted:/, '')\n }\n\n return undefined \n}\n\nconst originateContract = (parsedArgs: Opts) => (contractFilename: string) => {\n // TODO: Should getting the default environment be provided by the SDK or the framework?\n const currentEnv = parsedArgs.env\n ? (parsedArgs.env as string)\n : (\n parsedArgs.config.environment\n ? parsedArgs.config.environment.default\n : 'development'\n )\n const env = parsedArgs.config.environment && parsedArgs.config.environment[currentEnv]\n ? parsedArgs.config.environment[currentEnv]\n : undefined\n\n if (!env) {\n return Promise.reject({\n errCode: \"E_INVALID_ENV\",\n errMsg: `No environment configured in your configuration file called ${parsedArgs.env}`,\n context: parsedArgs.config\n }) \n }\n\n if (!env.storage || !env.storage[contractFilename]) {\n return Promise.reject({\n errCode: \"E_INVALID_STORAGE\",\n errMsg: `No storage configured in your configuration file for ${contractFilename}`,\n context: env\n })\n }\n\n const networkProcesses = !env.networks ? [] : env.networks.reduce(\n (retval: LikeAPromise<OriginationResult, Failure<unknown>>[], network) => \n getNetworkConfig(network, parsedArgs.config)\n ? [...retval, originateContractToNetwork(contractFilename, parsedArgs, env.storage[contractFilename], network, getNetworkConfig(network, parsedArgs.config))]\n : retval,\n []\n )\n\n const allProcesses = !env.sandboxes ? [] : env.sandboxes.reduce(\n (retval: LikeAPromise<OriginationResult, Failure<unknown>>[], sandbox) => getSandboxConfig(sandbox, parsedArgs.config)\n ? [...retval, originateContractToSandbox(contractFilename, parsedArgs, env.storage[contractFilename], sandbox, getSandboxConfig(sandbox, parsedArgs.config))]\n : retval \n ,\n networkProcesses\n )\n \n return Promise.all(allProcesses)\n}\n\nconst originateAll = (parsedArgs: Opts) =>\n glob(\"**/*.tz\", {cwd: parsedArgs.artifactsDir})\n .then(files => Promise.all(files.map(originateContract(parsedArgs))))\n .then(results => results.flat(1))\n\nexport const originate = <T>(parsedArgs: Opts): LikeAPromise<PluginResponse, Failure<T>> => {\n const p = parsedArgs.contract\n ? originateContract(parsedArgs) (parsedArgs.contract as string)\n : originateAll(parsedArgs)\n\n return p.then(sendAsyncJsonRes)\n}\n\nexport default originate"],"names":[],"version":3,"file":"index.js.map","sourceRoot":"../"}
1
+ {"mappings":";;;;;;;;;;AAAA;ACAA;;;;;;AAoCA,MAAM,0CAAoB,GAAG,CAAC,WAAmB,EAAE,IAAU,GAAK;IACjE,MA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AG9F,MAAM,KAAI,GAAG;WACT,yCAAmB,CAAC,UAAU,EAAE,GAAG,CAAC;WACpC,0CAAoB,CAAC,UAAU,EAAE,GAAG,CAAC;KACxC,AAAC;IAEF,OAAO,OAAO,CAAC,GAAG,CAAC,KAAI,CAAC,CACtB,IAAI,CAAC,CAAA,IAAI,GACT,IAAI,CAAC,MAAM,CACV,CAAC,MAAM,EAAE,YAAY,GAAK;YACzB,OAAO,YAAY,GAChB;mBAAI,MAAM;mBAA4B,YAAY;aAAC,GACnD,MAAM,CAAC;SACV,EACD,EAAE,CACF,CACD,CACA,IAAI,CAAC,CAAA,OAAO,GAAI,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,GAAG,CAAA,GAAA,kCAAW,CAAA,CAAC,OAAO,CAAC,GAAG,CAAA,GAAA,8BAAO,CAAA,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC;CAC9G,AAAC;IAEF,wCAAyB,GAAV,yCAAS;;;ADtOxB,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\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 { LikeAPromise, PluginResponse, Protocol, RequestArgs, TaqError } 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) throw (`No initial storage provided for ${filename}`);\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\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\tsendErr(\n\t\t\t\t\t\t\t\t\t`No default account has been configured for the sandbox called ${sandboxName}. Using the account called ${first} for origination.`,\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): LikeAPromise<PluginResponse, TaqError.t> => {\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,22 +1,20 @@
1
- import {Plugin, Task, EconomicalProtocol} from '@taqueria/node-sdk'
2
- import type { i18n} from '@taqueria/node-sdk/types'
3
- import originate from './originate'
1
+ import { Plugin, Task } from '@taqueria/node-sdk';
2
+ import originate from './originate';
4
3
 
5
- Plugin.create((i18n: i18n) => ({
6
- alias: "taquito",
7
- schema: "1.0",
8
- version: "0.1",
9
- tasks: [
10
- Task.create({
11
- task: "deploy",
12
- command: "deploy [contract]",
13
- description: "Deploy a smart contract to a particular environment",
14
- options: [
15
- ],
16
- aliases: ["originate"],
17
- handler: "proxy",
18
- encoding: "application/json"
19
- }),
20
- ],
21
- proxy: originate
22
- }), process.argv)
4
+ Plugin.create(_i18n => ({
5
+ alias: 'taquito',
6
+ schema: '1.0',
7
+ version: '0.1',
8
+ tasks: [
9
+ Task.create({
10
+ task: 'deploy',
11
+ command: 'deploy [contract]',
12
+ description: 'Deploy a smart contract to a particular environment',
13
+ options: [],
14
+ aliases: ['originate'],
15
+ handler: 'proxy',
16
+ encoding: 'application/json',
17
+ }),
18
+ ],
19
+ proxy: originate,
20
+ }), process.argv);