@taqueria/plugin-taquito 0.18.0 → 0.19.3
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 +35 -2
- package/_readme.eta +36 -2
- package/index.js +161 -5
- package/index.js.map +1 -1
- package/index.ts +30 -2
- package/originate.ts +49 -5
- package/package.json +3 -2
- package/taquito.ts +31 -0
- package/transfer.ts +141 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Taqueria Taquito Plugin
|
|
2
2
|
|
|
3
|
-
The Taquito plugin provides
|
|
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
|
|
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
|
|
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
|
|
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
|
|
|
@@ -101,13 +103,44 @@ const $806c5c6032403442$var$createBatch = async (parsedArgs, tezos, destination)
|
|
|
101
103
|
const error = err;
|
|
102
104
|
if (error.message) {
|
|
103
105
|
const msg = error.message;
|
|
104
|
-
if (/ENOTFOUND/.test(msg))
|
|
105
|
-
|
|
106
|
-
|
|
106
|
+
if (/ENOTFOUND/.test(msg)) {
|
|
107
|
+
(0, $iVZbm$taquerianodesdk.sendErr)("The RPC URL may be invalid. Check your ./taq/config.json.\n");
|
|
108
|
+
(0, $iVZbm$taquerianodesdk.sendErr)(msg);
|
|
109
|
+
} else if (/ECONNREFUSED/.test(msg)) {
|
|
110
|
+
(0, $iVZbm$taquerianodesdk.sendErr)("The RPC URL may be down or the sandbox is not running.\n");
|
|
111
|
+
(0, $iVZbm$taquerianodesdk.sendErr)(msg);
|
|
112
|
+
} else if (/empty_implicit_contract/.test(msg)) {
|
|
113
|
+
(0, $iVZbm$taquerianodesdk.sendErr)("Your account does not have sufficient funds to perform this operation. If targeting a testnet you may get funds from a faucet at https://teztnets.xyz/.\n");
|
|
114
|
+
(0, $iVZbm$taquerianodesdk.sendErr)(msg);
|
|
115
|
+
} else {
|
|
116
|
+
(0, $iVZbm$taquerianodesdk.sendErr)("There was a problem communicating with the chain. Perhaps review your RPC URL of the network or sandbox you're targeting.\n");
|
|
117
|
+
(0, $iVZbm$taquerianodesdk.sendErr)(msg);
|
|
118
|
+
}
|
|
107
119
|
}
|
|
108
120
|
return undefined;
|
|
109
121
|
}
|
|
110
122
|
};
|
|
123
|
+
async function $806c5c6032403442$export$e4c4fcd791db1d6b(toolkit, privateKeyOrEmail, passphrase, mnemonic, secret) {
|
|
124
|
+
if (privateKeyOrEmail && passphrase && mnemonic && secret) return await (0, $iVZbm$taquitosigner.importKey)(toolkit, privateKeyOrEmail, passphrase, mnemonic, secret);
|
|
125
|
+
else if (mnemonic) {
|
|
126
|
+
const signer = (0, $iVZbm$taquitosigner.InMemorySigner).fromFundraiser(privateKeyOrEmail ?? "", passphrase ?? "", mnemonic);
|
|
127
|
+
toolkit.setProvider({
|
|
128
|
+
signer: signer
|
|
129
|
+
});
|
|
130
|
+
const pkh = await signer.publicKeyHash();
|
|
131
|
+
let op;
|
|
132
|
+
try {
|
|
133
|
+
op = await toolkit.tz.activate(pkh, secret ?? "");
|
|
134
|
+
if (op) await op.confirmation();
|
|
135
|
+
} catch (ex) {}
|
|
136
|
+
} else if (privateKeyOrEmail) {
|
|
137
|
+
// Fallback to regular import
|
|
138
|
+
const signer = await (0, $iVZbm$taquitosigner.InMemorySigner).fromSecretKey(privateKeyOrEmail, passphrase);
|
|
139
|
+
toolkit.setProvider({
|
|
140
|
+
signer: signer
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
111
144
|
const $806c5c6032403442$var$originateToNetworks = (parsedArgs, currentEnv)=>currentEnv.networks ? currentEnv.networks.reduce((retval, networkName)=>{
|
|
112
145
|
const network = (0, $iVZbm$taquerianodesdk.getNetworkConfig)(parsedArgs)(networkName);
|
|
113
146
|
if (network) {
|
|
@@ -115,7 +148,7 @@ const $806c5c6032403442$var$originateToNetworks = (parsedArgs, currentEnv)=>curr
|
|
|
115
148
|
if (network.faucet) {
|
|
116
149
|
const result = (async ()=>{
|
|
117
150
|
const tezos = new (0, $iVZbm$taquitotaquito.TezosToolkit)(network.rpcUrl);
|
|
118
|
-
await
|
|
151
|
+
await $806c5c6032403442$export$e4c4fcd791db1d6b(tezos, network.faucet.email, network.faucet.password, network.faucet.mnemonic.join(" "), network.faucet.activation_code);
|
|
119
152
|
return await $806c5c6032403442$var$createBatch(parsedArgs, tezos, networkName);
|
|
120
153
|
})();
|
|
121
154
|
return [
|
|
@@ -175,6 +208,102 @@ const $806c5c6032403442$export$acf571c34911f824 = (parsedArgs)=>{
|
|
|
175
208
|
var $806c5c6032403442$export$2e2bcd8739ae039 = $806c5c6032403442$export$acf571c34911f824;
|
|
176
209
|
|
|
177
210
|
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
const $944e64d99e99b46e$var$getFirstAccountAlias = (sandboxName, opts)=>{
|
|
216
|
+
const aliases = (0, $iVZbm$taquerianodesdk.getSandboxAccountNames)(opts)(sandboxName);
|
|
217
|
+
return aliases.shift();
|
|
218
|
+
};
|
|
219
|
+
const $944e64d99e99b46e$var$configureToolKitWithSandbox = async (parsedArgs, sandboxName)=>{
|
|
220
|
+
const sandbox = (0, $iVZbm$taquerianodesdk.getSandboxConfig)(parsedArgs)(sandboxName);
|
|
221
|
+
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.`);
|
|
222
|
+
let defaultAccount = (0, $iVZbm$taquerianodesdk.getDefaultAccount)(parsedArgs)(sandboxName);
|
|
223
|
+
if (!defaultAccount) {
|
|
224
|
+
const first = $944e64d99e99b46e$var$getFirstAccountAlias(sandboxName, parsedArgs);
|
|
225
|
+
if (first) {
|
|
226
|
+
defaultAccount = (0, $iVZbm$taquerianodesdk.getSandboxAccountConfig)(parsedArgs)(sandboxName)(first);
|
|
227
|
+
(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`);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
if (!defaultAccount) return (0, $iVZbm$taquerianodesdk.sendAsyncErr)(`No accounts are available for the sandbox called ${sandboxName} to perform the operation.`);
|
|
231
|
+
const tezos = new (0, $iVZbm$taquitotaquito.TezosToolkit)(sandbox.rpcUrl);
|
|
232
|
+
tezos.setProvider({
|
|
233
|
+
signer: new (0, $iVZbm$taquitosigner.InMemorySigner)(defaultAccount.secretKey.replace(/^unencrypted:/, ""))
|
|
234
|
+
});
|
|
235
|
+
return tezos;
|
|
236
|
+
};
|
|
237
|
+
const $944e64d99e99b46e$var$configureToolKitWithNetwork = async (parsedArgs, networkName)=>{
|
|
238
|
+
const network = (0, $iVZbm$taquerianodesdk.getNetworkConfig)(parsedArgs)(networkName);
|
|
239
|
+
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.`);
|
|
240
|
+
const faucet = network.faucet;
|
|
241
|
+
if (!faucet) return (0, $iVZbm$taquerianodesdk.sendAsyncErr)(`Network ${networkName} requires a valid faucet in config.json.`);
|
|
242
|
+
const tezos = new (0, $iVZbm$taquitotaquito.TezosToolkit)(network.rpcUrl);
|
|
243
|
+
await (0, $iVZbm$taquitosigner.importKey)(tezos, network.faucet.email ?? "", network.faucet.password, network.faucet.mnemonic.join(" "), network.faucet.activation_code);
|
|
244
|
+
return tezos;
|
|
245
|
+
};
|
|
246
|
+
const $944e64d99e99b46e$var$configureTezosToolKit = (parsedArgs, env)=>{
|
|
247
|
+
const targetConstraintErrMsg = "Each environment can only have one target, be it a sandbox or a network";
|
|
248
|
+
if (env.sandboxes?.length === 1 && env.networks?.length === 1) return (0, $iVZbm$taquerianodesdk.sendAsyncErr)(targetConstraintErrMsg);
|
|
249
|
+
if (env.sandboxes?.length === 1) return $944e64d99e99b46e$var$configureToolKitWithSandbox(parsedArgs, env.sandboxes[0]);
|
|
250
|
+
if (env.networks?.length === 1) return $944e64d99e99b46e$var$configureToolKitWithNetwork(parsedArgs, env.networks[0]);
|
|
251
|
+
return (0, $iVZbm$taquerianodesdk.sendAsyncErr)(targetConstraintErrMsg);
|
|
252
|
+
};
|
|
253
|
+
const $944e64d99e99b46e$var$isContractAddress = (contract)=>contract.startsWith("tz1") || contract.startsWith("tz2") || contract.startsWith("tz3") || contract.startsWith("KT1");
|
|
254
|
+
const $944e64d99e99b46e$var$getContractInfo = async (parsedArgs, env, tezos)=>{
|
|
255
|
+
const contract = parsedArgs.contract;
|
|
256
|
+
return {
|
|
257
|
+
contractAlias: $944e64d99e99b46e$var$isContractAddress(contract) ? "N/A" : contract,
|
|
258
|
+
contractAddress: $944e64d99e99b46e$var$isContractAddress(contract) ? contract : await (0, $iVZbm$taquerianodesdk.getAddressOfAlias)(env, contract),
|
|
259
|
+
tezTransfer: parsedArgs.tez ?? "0",
|
|
260
|
+
parameter: parsedArgs.param ? await (0, $iVZbm$taquerianodesdk.getParameter)(parsedArgs, parsedArgs.param) : "Unit",
|
|
261
|
+
entrypoint: parsedArgs.entrypoint ?? "default",
|
|
262
|
+
destination: tezos.rpc.getRpcUrl()
|
|
263
|
+
};
|
|
264
|
+
};
|
|
265
|
+
const $944e64d99e99b46e$var$performTransferOp = (tezos, contractInfo)=>{
|
|
266
|
+
return tezos.contract.transfer({
|
|
267
|
+
to: contractInfo.contractAddress,
|
|
268
|
+
amount: parseFloat(contractInfo.tezTransfer),
|
|
269
|
+
parameter: {
|
|
270
|
+
entrypoint: contractInfo.entrypoint,
|
|
271
|
+
value: new (0, $iVZbm$taquitomichelcodec.Parser)().parseMichelineExpression(contractInfo.parameter)
|
|
272
|
+
}
|
|
273
|
+
}).then((op)=>op.confirmation().then(()=>op.hash)).catch((err)=>(0, $iVZbm$taquerianodesdk.sendAsyncErr)(`Error during transfer operation:\n${err} ${JSON.stringify(err, null, 2)}`));
|
|
274
|
+
};
|
|
275
|
+
const $944e64d99e99b46e$export$c9b234447cf4ef7c = async (parsedArgs)=>{
|
|
276
|
+
const env = (0, $iVZbm$taquerianodesdk.getCurrentEnvironmentConfig)(parsedArgs);
|
|
277
|
+
if (!env) return (0, $iVZbm$taquerianodesdk.sendAsyncErr)(`There is no environment called ${parsedArgs.env} in your config.json.`);
|
|
278
|
+
try {
|
|
279
|
+
const tezos = await $944e64d99e99b46e$var$configureTezosToolKit(parsedArgs, env);
|
|
280
|
+
const contractInfo = await $944e64d99e99b46e$var$getContractInfo(parsedArgs, env, tezos);
|
|
281
|
+
await $944e64d99e99b46e$var$performTransferOp(tezos, contractInfo);
|
|
282
|
+
return (0, $iVZbm$taquerianodesdk.sendJsonRes)([
|
|
283
|
+
contractInfo
|
|
284
|
+
]);
|
|
285
|
+
} catch {
|
|
286
|
+
return (0, $iVZbm$taquerianodesdk.sendAsyncErr)("No operations performed.");
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
var $944e64d99e99b46e$export$2e2bcd8739ae039 = $944e64d99e99b46e$export$c9b234447cf4ef7c;
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
const $e6ed693f861ac256$export$71d25adf06a71b9 = (parsedArgs)=>{
|
|
293
|
+
switch(parsedArgs.task){
|
|
294
|
+
case "originate":
|
|
295
|
+
case "deploy":
|
|
296
|
+
return (0, $806c5c6032403442$export$2e2bcd8739ae039)(parsedArgs);
|
|
297
|
+
case "transfer":
|
|
298
|
+
case "call":
|
|
299
|
+
return (0, $944e64d99e99b46e$export$2e2bcd8739ae039)(parsedArgs);
|
|
300
|
+
default:
|
|
301
|
+
return (0, $iVZbm$taquerianodesdk.sendAsyncErr)(`${parsedArgs.task} is not an understood task by the Taquito plugin`);
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
var $e6ed693f861ac256$export$2e2bcd8739ae039 = $e6ed693f861ac256$export$71d25adf06a71b9;
|
|
305
|
+
|
|
306
|
+
|
|
178
307
|
(0, $iVZbm$taquerianodesdk.Plugin).create((_i18n)=>({
|
|
179
308
|
alias: "taquito",
|
|
180
309
|
schema: "1.0",
|
|
@@ -201,9 +330,36 @@ var $806c5c6032403442$export$2e2bcd8739ae039 = $806c5c6032403442$export$acf571c3
|
|
|
201
330
|
],
|
|
202
331
|
handler: "proxy",
|
|
203
332
|
encoding: "application/json"
|
|
333
|
+
}),
|
|
334
|
+
(0, $iVZbm$taquerianodesdk.Task).create({
|
|
335
|
+
task: "transfer",
|
|
336
|
+
command: "transfer <contract>",
|
|
337
|
+
description: "Transfer/call an implicit account or a smart contract (specified via its alias or address) deployed to a particular environment",
|
|
338
|
+
options: [
|
|
339
|
+
(0, $iVZbm$taquerianodesdk.Option).create({
|
|
340
|
+
flag: "tez",
|
|
341
|
+
description: "Amount of Tez to transfer",
|
|
342
|
+
required: false
|
|
343
|
+
}),
|
|
344
|
+
(0, $iVZbm$taquerianodesdk.Option).create({
|
|
345
|
+
flag: "param",
|
|
346
|
+
description: "Name of the parameter file that contains the parameter value as a Michelson expression, in the artifacts directory, used for invoking a deployed contract",
|
|
347
|
+
required: false
|
|
348
|
+
}),
|
|
349
|
+
(0, $iVZbm$taquerianodesdk.Option).create({
|
|
350
|
+
flag: "entrypoint",
|
|
351
|
+
description: "You may explicitly specify an entrypoint to make the parameter value shorter, without having to specify a chain of (Left (Right ... 14 ...))",
|
|
352
|
+
required: false
|
|
353
|
+
}),
|
|
354
|
+
],
|
|
355
|
+
aliases: [
|
|
356
|
+
"call"
|
|
357
|
+
],
|
|
358
|
+
handler: "proxy",
|
|
359
|
+
encoding: "application/json"
|
|
204
360
|
}),
|
|
205
361
|
],
|
|
206
|
-
proxy: (0, $
|
|
362
|
+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AE,QAAQ;gBACd,OAAO,EAAE,mBAAmB;gBAC5B,WAAW,EAAE,qDAAqD;gBAClE,OAAO,EAAE;oBACR,CAAA,GAAA,6BAAM,CAAA,CAAC,MAAM,CAAC;wBACb,IAAI,EAAE,OAAO;wBACb,WAAW,EAAE,wDAAwD;wBACrE,QAAQ,EAAE,KAAK;qBACf,CAAC;oBACF,CAAA,GAAA,6BAAM,CAAA,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;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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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:\n\t\t\t\t\t\t'Name of the parameter file that contains the parameter value as a Michelson expression, in the artifacts directory, used for invoking a deployed contract',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'entrypoint',\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'You may explicitly specify an entrypoint to make the parameter value shorter, without having to specify a chain of (Left (Right ... 14 ...))',\n\t\t\t\t\trequired: false,\n\t\t\t\t}),\n\t\t\t],\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('The RPC URL may be invalid. Check your ./taq/config.json.\\n');\n\t\t\t\tsendErr(msg);\n\t\t\t} else if (/ECONNREFUSED/.test(msg)) {\n\t\t\t\tsendErr('The RPC URL may be down or the sandbox is not running.\\n');\n\t\t\t\tsendErr(msg);\n\t\t\t} else if (/empty_implicit_contract/.test(msg)) {\n\t\t\t\tsendErr(\n\t\t\t\t\t'Your account does not have sufficient funds to perform this operation. If targeting a testnet you may get funds from a faucet at https://teztnets.xyz/.\\n',\n\t\t\t\t);\n\t\t\t\tsendErr(msg);\n\t\t\t} else {\n\t\t\t\tsendErr(\n\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\",\n\t\t\t\t);\n\t\t\t\tsendErr(msg);\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n};\n\n/**\n * @description Import a key to sign operation with the side-effect of setting the Tezos instance to use the InMemorySigner provider\n *\n * @param toolkit The toolkit instance to attach a signer\n * @param privateKeyOrEmail Key to load in memory\n * @param passphrase If the key is encrypted passphrase to decrypt it\n * @param mnemonic Faucet mnemonic\n * @param secret Faucet secret\n */\nexport async function importFaucet(\n\ttoolkit: TezosToolkit,\n\tprivateKeyOrEmail?: string,\n\tpassphrase?: string,\n\tmnemonic?: string,\n\tsecret?: string,\n) {\n\tif (privateKeyOrEmail && passphrase && mnemonic && secret) {\n\t\treturn await importKey(toolkit, privateKeyOrEmail, passphrase, mnemonic, secret);\n\t} else if (mnemonic) {\n\t\tconst signer = InMemorySigner.fromFundraiser(privateKeyOrEmail ?? '', passphrase ?? '', mnemonic);\n\t\ttoolkit.setProvider({ signer });\n\t\tconst pkh = await signer.publicKeyHash();\n\t\tlet op;\n\t\ttry {\n\t\t\top = await toolkit.tz.activate(pkh, secret ?? '');\n\t\t\tif (op) {\n\t\t\t\tawait op.confirmation();\n\t\t\t}\n\t\t} catch (ex: any) {\n\t\t}\n\t} else if (privateKeyOrEmail) {\n\t\t// Fallback to regular import\n\t\tconst signer = await InMemorySigner.fromSecretKey(privateKeyOrEmail, passphrase);\n\t\ttoolkit.setProvider({ signer });\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 importFaucet(\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
|
|
2
|
+
import taquito from './taquito';
|
|
3
3
|
|
|
4
4
|
Plugin.create(_i18n => ({
|
|
5
5
|
alias: 'taquito',
|
|
@@ -27,6 +27,34 @@ 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:
|
|
44
|
+
'Name of the parameter file that contains the parameter value as a Michelson expression, in the artifacts directory, used for invoking a deployed contract',
|
|
45
|
+
required: false,
|
|
46
|
+
}),
|
|
47
|
+
Option.create({
|
|
48
|
+
flag: 'entrypoint',
|
|
49
|
+
description:
|
|
50
|
+
'You may explicitly specify an entrypoint to make the parameter value shorter, without having to specify a chain of (Left (Right ... 14 ...))',
|
|
51
|
+
required: false,
|
|
52
|
+
}),
|
|
53
|
+
],
|
|
54
|
+
aliases: ['call'],
|
|
55
|
+
handler: 'proxy',
|
|
56
|
+
encoding: 'application/json',
|
|
57
|
+
}),
|
|
30
58
|
],
|
|
31
|
-
proxy:
|
|
59
|
+
proxy: taquito,
|
|
32
60
|
}), process.argv);
|
package/originate.ts
CHANGED
|
@@ -165,20 +165,64 @@ const createBatch = async (parsedArgs: Opts, tezos: TezosToolkit, destination: s
|
|
|
165
165
|
if (error.message) {
|
|
166
166
|
const msg = error.message;
|
|
167
167
|
if (/ENOTFOUND/.test(msg)) {
|
|
168
|
-
sendErr(
|
|
168
|
+
sendErr('The RPC URL may be invalid. Check your ./taq/config.json.\n');
|
|
169
|
+
sendErr(msg);
|
|
169
170
|
} else if (/ECONNREFUSED/.test(msg)) {
|
|
170
|
-
sendErr(
|
|
171
|
+
sendErr('The RPC URL may be down or the sandbox is not running.\n');
|
|
172
|
+
sendErr(msg);
|
|
173
|
+
} else if (/empty_implicit_contract/.test(msg)) {
|
|
174
|
+
sendErr(
|
|
175
|
+
'Your account does not have sufficient funds to perform this operation. If targeting a testnet you may get funds from a faucet at https://teztnets.xyz/.\n',
|
|
176
|
+
);
|
|
177
|
+
sendErr(msg);
|
|
171
178
|
} else {
|
|
172
179
|
sendErr(
|
|
173
|
-
|
|
174
|
-
+ " - There was a problem communicating with the chain. Perhaps review your RPC URL of the network or sandbox you're targeting.",
|
|
180
|
+
"There was a problem communicating with the chain. Perhaps review your RPC URL of the network or sandbox you're targeting.\n",
|
|
175
181
|
);
|
|
182
|
+
sendErr(msg);
|
|
176
183
|
}
|
|
177
184
|
}
|
|
178
185
|
return undefined;
|
|
179
186
|
}
|
|
180
187
|
};
|
|
181
188
|
|
|
189
|
+
/**
|
|
190
|
+
* @description Import a key to sign operation with the side-effect of setting the Tezos instance to use the InMemorySigner provider
|
|
191
|
+
*
|
|
192
|
+
* @param toolkit The toolkit instance to attach a signer
|
|
193
|
+
* @param privateKeyOrEmail Key to load in memory
|
|
194
|
+
* @param passphrase If the key is encrypted passphrase to decrypt it
|
|
195
|
+
* @param mnemonic Faucet mnemonic
|
|
196
|
+
* @param secret Faucet secret
|
|
197
|
+
*/
|
|
198
|
+
export async function importFaucet(
|
|
199
|
+
toolkit: TezosToolkit,
|
|
200
|
+
privateKeyOrEmail?: string,
|
|
201
|
+
passphrase?: string,
|
|
202
|
+
mnemonic?: string,
|
|
203
|
+
secret?: string,
|
|
204
|
+
) {
|
|
205
|
+
if (privateKeyOrEmail && passphrase && mnemonic && secret) {
|
|
206
|
+
return await importKey(toolkit, privateKeyOrEmail, passphrase, mnemonic, secret);
|
|
207
|
+
} else if (mnemonic) {
|
|
208
|
+
const signer = InMemorySigner.fromFundraiser(privateKeyOrEmail ?? '', passphrase ?? '', mnemonic);
|
|
209
|
+
toolkit.setProvider({ signer });
|
|
210
|
+
const pkh = await signer.publicKeyHash();
|
|
211
|
+
let op;
|
|
212
|
+
try {
|
|
213
|
+
op = await toolkit.tz.activate(pkh, secret ?? '');
|
|
214
|
+
if (op) {
|
|
215
|
+
await op.confirmation();
|
|
216
|
+
}
|
|
217
|
+
} catch (ex: any) {
|
|
218
|
+
}
|
|
219
|
+
} else if (privateKeyOrEmail) {
|
|
220
|
+
// Fallback to regular import
|
|
221
|
+
const signer = await InMemorySigner.fromSecretKey(privateKeyOrEmail, passphrase);
|
|
222
|
+
toolkit.setProvider({ signer });
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
182
226
|
const originateToNetworks = (parsedArgs: Opts, currentEnv: Protocol.Environment.t) =>
|
|
183
227
|
currentEnv.networks
|
|
184
228
|
? currentEnv.networks.reduce(
|
|
@@ -189,7 +233,7 @@ const originateToNetworks = (parsedArgs: Opts, currentEnv: Protocol.Environment.
|
|
|
189
233
|
if (network.faucet) {
|
|
190
234
|
const result = (async () => {
|
|
191
235
|
const tezos = new TezosToolkit(network.rpcUrl as string);
|
|
192
|
-
await
|
|
236
|
+
await importFaucet(
|
|
193
237
|
tezos,
|
|
194
238
|
network.faucet.email,
|
|
195
239
|
network.faucet.password,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taqueria/plugin-taquito",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.3",
|
|
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.
|
|
49
|
+
"@taqueria/node-sdk": "^0.19.3",
|
|
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;
|