@taqueria/plugin-taquito 0.0.0-pr-779-eaf2ca6a → 0.0.0-pr-776-b4c3aaa5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +37 -42
- package/index.js.map +1 -1
- package/originate.ts +5 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -16,28 +16,26 @@ function $parcel$interopDefault(a) {
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
const $806c5c6032403442$var$getFirstAccountAlias = (sandboxName, opts)=>{
|
|
19
|
-
const aliases = $iVZbm$taquerianodesdk.getSandboxAccountNames(opts)(sandboxName);
|
|
19
|
+
const aliases = (0, $iVZbm$taquerianodesdk.getSandboxAccountNames)(opts)(sandboxName);
|
|
20
20
|
return aliases.shift();
|
|
21
21
|
};
|
|
22
|
-
const $806c5c6032403442$var$getContractAbspath = (contractFilename, parsedArgs)
|
|
23
|
-
;
|
|
22
|
+
const $806c5c6032403442$var$getContractAbspath = (contractFilename, parsedArgs)=>(0, $iVZbm$path.join)(parsedArgs.config.artifactsDir, /\.tz$/.test(contractFilename) ? contractFilename : `${contractFilename}.tz`);
|
|
24
23
|
const $806c5c6032403442$var$addOrigination = (parsedArgs, batch)=>async (mapping)=>{
|
|
25
24
|
const contractAbspath = $806c5c6032403442$var$getContractAbspath(mapping.filename, parsedArgs);
|
|
26
|
-
const contractData = await $iVZbm$fspromises.readFile(contractAbspath, "utf-8");
|
|
25
|
+
const contractData = await (0, $iVZbm$fspromises.readFile)(contractAbspath, "utf-8");
|
|
27
26
|
return (await batch).withOrigination({
|
|
28
27
|
code: contractData,
|
|
29
28
|
storage: mapping.storage
|
|
30
29
|
});
|
|
31
|
-
}
|
|
32
|
-
;
|
|
30
|
+
};
|
|
33
31
|
const $806c5c6032403442$var$getValidContracts = async (parsedArgs)=>{
|
|
34
32
|
const contracts = parsedArgs.contract ? [
|
|
35
33
|
parsedArgs.contract
|
|
36
|
-
] : await ($parcel$interopDefault($iVZbm$fastglob))("**/*.tz", {
|
|
34
|
+
] : await (0, ($parcel$interopDefault($iVZbm$fastglob)))("**/*.tz", {
|
|
37
35
|
cwd: parsedArgs.config.artifactsDir
|
|
38
36
|
});
|
|
39
37
|
return contracts.reduce((retval, filename)=>{
|
|
40
|
-
const storage = $iVZbm$taquerianodesdk.getInitialStorage(parsedArgs)(filename);
|
|
38
|
+
const storage = (0, $iVZbm$taquerianodesdk.getInitialStorage)(parsedArgs)(filename);
|
|
41
39
|
if (!storage) throw `No initial storage provided for ${filename}`;
|
|
42
40
|
return [
|
|
43
41
|
...retval,
|
|
@@ -54,8 +52,11 @@ const $806c5c6032403442$var$mapOpToContract = async (contracts, op, destination)
|
|
|
54
52
|
// If initial storage was provided for the contract
|
|
55
53
|
// then we submitted an operation to originate that contract
|
|
56
54
|
if (contract.storage) {
|
|
57
|
-
|
|
58
|
-
|
|
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";
|
|
59
60
|
return [
|
|
60
61
|
...retval,
|
|
61
62
|
{
|
|
@@ -77,56 +78,54 @@ const $806c5c6032403442$var$mapOpToContract = async (contracts, op, destination)
|
|
|
77
78
|
};
|
|
78
79
|
const $806c5c6032403442$var$createBatch = async (parsedArgs, tezos, destination)=>{
|
|
79
80
|
const contracts = await $806c5c6032403442$var$getValidContracts(parsedArgs);
|
|
80
|
-
const batch1 = await contracts.reduce((batch, contractMapping)=>contractMapping.storage ? $806c5c6032403442$var$addOrigination(parsedArgs, batch)(contractMapping) : batch
|
|
81
|
-
, Promise.resolve(tezos.wallet.batch()));
|
|
81
|
+
const batch1 = await contracts.reduce((batch, contractMapping)=>contractMapping.storage ? $806c5c6032403442$var$addOrigination(parsedArgs, batch)(contractMapping) : batch, Promise.resolve(tezos.wallet.batch()));
|
|
82
82
|
try {
|
|
83
83
|
const op = await batch1.send();
|
|
84
84
|
const confirmed = await op.confirmation();
|
|
85
85
|
return await $806c5c6032403442$var$mapOpToContract(contracts, op, destination);
|
|
86
86
|
} catch (err) {
|
|
87
87
|
const error = err;
|
|
88
|
-
if (error.message) $iVZbm$taquerianodesdk.sendErr(error.message);
|
|
88
|
+
if (error.message) (0, $iVZbm$taquerianodesdk.sendErr)(error.message);
|
|
89
89
|
return undefined;
|
|
90
90
|
}
|
|
91
91
|
};
|
|
92
92
|
const $806c5c6032403442$var$originateToNetworks = (parsedArgs, currentEnv)=>currentEnv.networks ? currentEnv.networks.reduce((retval, networkName)=>{
|
|
93
|
-
const network = $iVZbm$taquerianodesdk.getNetworkConfig(parsedArgs)(networkName);
|
|
93
|
+
const network = (0, $iVZbm$taquerianodesdk.getNetworkConfig)(parsedArgs)(networkName);
|
|
94
94
|
if (network) {
|
|
95
95
|
if (network.rpcUrl) {
|
|
96
96
|
if (network.faucet) {
|
|
97
97
|
const result = (async ()=>{
|
|
98
|
-
const tezos = new $iVZbm$taquitotaquito.TezosToolkit(network.rpcUrl);
|
|
99
|
-
await $iVZbm$taquitosigner.importKey(tezos, network.faucet.email, network.faucet.password, network.faucet.mnemonic.join(
|
|
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
100
|
return await $806c5c6032403442$var$createBatch(parsedArgs, tezos, networkName);
|
|
101
101
|
})();
|
|
102
102
|
return [
|
|
103
103
|
...retval,
|
|
104
104
|
result
|
|
105
105
|
];
|
|
106
|
-
} else $iVZbm$taquerianodesdk.sendErr(`Network ${networkName} requires a valid faucet in config.json.`);
|
|
107
|
-
} else $iVZbm$taquerianodesdk.sendErr(`Network "${networkName} is missing an RPC url in config.json."`);
|
|
108
|
-
} else $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.`);
|
|
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
109
|
return retval;
|
|
110
|
-
}, []) : []
|
|
111
|
-
;
|
|
110
|
+
}, []) : [];
|
|
112
111
|
const $806c5c6032403442$var$originateToSandboxes = (parsedArgs, currentEnv)=>currentEnv.sandboxes ? currentEnv.sandboxes.reduce((retval, sandboxName)=>{
|
|
113
|
-
const sandbox = $iVZbm$taquerianodesdk.getSandboxConfig(parsedArgs)(sandboxName);
|
|
112
|
+
const sandbox = (0, $iVZbm$taquerianodesdk.getSandboxConfig)(parsedArgs)(sandboxName);
|
|
114
113
|
if (sandbox) {
|
|
115
114
|
if (sandbox.rpcUrl) {
|
|
116
|
-
let defaultAccount = $iVZbm$taquerianodesdk.getDefaultAccount(parsedArgs)(sandboxName);
|
|
115
|
+
let defaultAccount = (0, $iVZbm$taquerianodesdk.getDefaultAccount)(parsedArgs)(sandboxName);
|
|
117
116
|
if (!defaultAccount) {
|
|
118
117
|
const first = $806c5c6032403442$var$getFirstAccountAlias(sandboxName, parsedArgs);
|
|
119
118
|
if (first) {
|
|
120
|
-
defaultAccount = $iVZbm$taquerianodesdk.getSandboxAccountConfig(parsedArgs)(sandboxName)(first);
|
|
121
|
-
$iVZbm$taquerianodesdk.sendErr(`No default account has been configured for the sandbox called ${sandboxName}. Using the account called ${first} for origination.`);
|
|
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.`);
|
|
122
121
|
}
|
|
123
122
|
}
|
|
124
123
|
if (defaultAccount) {
|
|
125
124
|
const secretKey = defaultAccount.secretKey;
|
|
126
125
|
const result = (async ()=>{
|
|
127
|
-
const tezos = new $iVZbm$taquitotaquito.TezosToolkit(sandbox.rpcUrl);
|
|
126
|
+
const tezos = new (0, $iVZbm$taquitotaquito.TezosToolkit)(sandbox.rpcUrl);
|
|
128
127
|
tezos.setProvider({
|
|
129
|
-
signer: new $iVZbm$taquitosigner.InMemorySigner(secretKey.replace(/^unencrypted:/,
|
|
128
|
+
signer: new (0, $iVZbm$taquitosigner.InMemorySigner)(secretKey.replace(/^unencrypted:/, ""))
|
|
130
129
|
});
|
|
131
130
|
return await $806c5c6032403442$var$createBatch(parsedArgs, tezos, sandboxName);
|
|
132
131
|
})();
|
|
@@ -134,15 +133,14 @@ const $806c5c6032403442$var$originateToSandboxes = (parsedArgs, currentEnv)=>cur
|
|
|
134
133
|
...retval,
|
|
135
134
|
result
|
|
136
135
|
];
|
|
137
|
-
} else $iVZbm$taquerianodesdk.sendErr(`No accounts are available for the sandbox called ${sandboxName} to perform origination.`);
|
|
138
|
-
} else $iVZbm$taquerianodesdk.sendErr(`Sandbox "${sandboxName} is missing an RPC url in config.json."`);
|
|
139
|
-
} else $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.`);
|
|
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.`);
|
|
140
139
|
return retval;
|
|
141
|
-
}, []) : []
|
|
142
|
-
;
|
|
140
|
+
}, []) : [];
|
|
143
141
|
const $806c5c6032403442$export$acf571c34911f824 = (parsedArgs)=>{
|
|
144
|
-
const env = $iVZbm$taquerianodesdk.getCurrentEnvironmentConfig(parsedArgs);
|
|
145
|
-
if (!env) return $iVZbm$taquerianodesdk.sendAsyncErr(`There is no environment called ${parsedArgs.env} in your config.json.`);
|
|
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.`);
|
|
146
144
|
const jobs1 = [
|
|
147
145
|
...$806c5c6032403442$var$originateToNetworks(parsedArgs, env),
|
|
148
146
|
...$806c5c6032403442$var$originateToSandboxes(parsedArgs, env)
|
|
@@ -152,19 +150,17 @@ const $806c5c6032403442$export$acf571c34911f824 = (parsedArgs)=>{
|
|
|
152
150
|
...retval,
|
|
153
151
|
...originations
|
|
154
152
|
] : retval;
|
|
155
|
-
}, [])
|
|
156
|
-
).then((results)=>results && results.length > 0 ? $iVZbm$taquerianodesdk.sendJsonRes(results) : $iVZbm$taquerianodesdk.sendErr(`No contracts originated.`)
|
|
157
|
-
);
|
|
153
|
+
}, [])).then((results)=>results && results.length > 0 ? (0, $iVZbm$taquerianodesdk.sendJsonRes)(results) : (0, $iVZbm$taquerianodesdk.sendErr)(`No contracts originated.`));
|
|
158
154
|
};
|
|
159
155
|
var $806c5c6032403442$export$2e2bcd8739ae039 = $806c5c6032403442$export$acf571c34911f824;
|
|
160
156
|
|
|
161
157
|
|
|
162
|
-
$iVZbm$taquerianodesdk.Plugin.create((_i18n)=>({
|
|
158
|
+
(0, $iVZbm$taquerianodesdk.Plugin).create((_i18n)=>({
|
|
163
159
|
alias: "taquito",
|
|
164
160
|
schema: "1.0",
|
|
165
161
|
version: "0.1",
|
|
166
162
|
tasks: [
|
|
167
|
-
$iVZbm$taquerianodesdk.Task.create({
|
|
163
|
+
(0, $iVZbm$taquerianodesdk.Task).create({
|
|
168
164
|
task: "deploy",
|
|
169
165
|
command: "deploy [contract]",
|
|
170
166
|
description: "Deploy a smart contract to a particular environment",
|
|
@@ -176,9 +172,8 @@ $iVZbm$taquerianodesdk.Plugin.create((_i18n)=>({
|
|
|
176
172
|
encoding: "application/json"
|
|
177
173
|
}),
|
|
178
174
|
],
|
|
179
|
-
proxy: $806c5c6032403442$export$2e2bcd8739ae039
|
|
180
|
-
})
|
|
181
|
-
, process.argv);
|
|
175
|
+
proxy: (0, $806c5c6032403442$export$2e2bcd8739ae039)
|
|
176
|
+
}), process.argv);
|
|
182
177
|
|
|
183
178
|
|
|
184
179
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;AAAA;ACAA;;;;;;AAyBA,MAAM,0CAAoB,GAAG,CAAC,WAAmB,EAAE,IAAU,GAAK;IAC9D,MAAM,OAAO,GAAG,6CAAsB,CAAC,IAAI,CAAC,CAAE,WAAW,CAAC;IAC1D,OAAO,OAAO,CAAC,KAAK,EAAE,CAAA;CACzB;AAED,MAAM,wCAAkB,GAAG,CAAC,gBAAwB,EAAE,UAAgB,GAClE,gBAAI,CAAC,UAAU,CAAC,MAAM,CAAC,YAAY,EAAE,QAAQ,IAAI,CAAC,gBAAgB,CAAC,GAAG,gBAAgB,GAAG,CAAC,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC;AAAA;AAEtH,MAAM,oCAAc,GAAG,CAAC,UAAgB,EAAE,KAAoC,GAAK,OAAO,OAA+B,GAAK;QAC1H,MAAM,eAAe,GAAG,wCAAkB,CAAC,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC;QACxE,MAAM,YAAY,GAAG,MAAM,0BAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;QAC7D,OAAO,AAAC,CAAA,MAAM,KAAK,CAAA,CAAE,e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AAmB,CAAC,UAAU,EAAE,GAAG,CAAC;WACpC,0CAAoB,CAAC,UAAU,EAAE,GAAG,CAAC;KAC3C;IAED,OAAO,OAAO,CAAC,GAAG,CAAC,KAAI,CAAC,CACnB,IAAI,CAAC,CAAA,IAAI,GAAI,IAAI,CAAC,MAAM,CACrB,CAAC,MAAM,EAAE,YAAY,GAAK;YACtB,OAAO,YAAY,GACb;mBAAI,MAAM;mBAA4B,YAAY;aAAC,GACnD,MAAM,CAAA;SACf,EACD,EAAE,CACL;IAAA,CAAC,CACD,IAAI,CAAC,CAAA,OAAO,GAAI,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,GAAG,kCAAW,CAAC,OAAO,CAAC,GAAE,8BAAO,CAAC,CAAC,wBAAwB,CAAC,CAAC;IAAA,CAAC,CAAA;CAClH;IAED,wCAAwB,GAAT,yCAAS;;;AD/MxB,6BAAM,CAAC,MAAM,CAAC,CAAA,KAAK,GAAK,CAAA;QACpB,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} from '@taqueria/node-sdk'\nimport originate from './originate'\n\nPlugin.create(_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 { RequestArgs, PluginResponse, TaqError, LikeAPromise, Protocol} from \"@taqueria/node-sdk/types\";\nimport { TezosToolkit, WalletOperationBatch } from '@taquito/taquito';\nimport { InMemorySigner, importKey } from '@taquito/signer';\nimport { getSandboxAccountNames, getCurrentEnvironmentConfig, getNetworkConfig, getSandboxAccountConfig, getInitialStorage, sendErr, getSandboxConfig, getDefaultAccount, sendJsonRes, sendAsyncErr } from \"@taqueria/node-sdk\";\nimport { BatchWalletOperation } from \"@taquito/taquito/dist/types/wallet/batch-operation\";\nimport { OperationContentsAndResultOrigination } from \"@taquito/rpc\";\nimport glob from 'fast-glob'\nimport {join} from 'path'\nimport {readFile} from 'fs/promises'\n\ninterface Opts extends RequestArgs.t {\n contract?: string\n}\n\ninterface ContractStorageMapping {\n filename: string,\n storage?: unknown\n}\n\ninterface OriginationResult {\n contract: string\n address: string\n destination: string\n}\n\nconst getFirstAccountAlias = (sandboxName: string, opts: Opts) => {\n const aliases = getSandboxAccountNames(opts) (sandboxName)\n return aliases.shift()\n}\n\nconst getContractAbspath = (contractFilename: string, parsedArgs: Opts) => \n join(parsedArgs.config.artifactsDir, /\\.tz$/.test(contractFilename) ? contractFilename : `${contractFilename}.tz`)\n\nconst addOrigination = (parsedArgs: Opts, batch: Promise<WalletOperationBatch>) => async (mapping: ContractStorageMapping) => {\n const contractAbspath = getContractAbspath(mapping.filename, parsedArgs)\n const contractData = await readFile(contractAbspath, \"utf-8\")\n return (await batch).withOrigination({\n code: contractData,\n storage: mapping.storage,\n \n })\n}\n\nconst getValidContracts = async (parsedArgs: Opts) => {\n const contracts = parsedArgs.contract\n ? [parsedArgs.contract]\n : (await glob(\"**/*.tz\", {cwd: parsedArgs.config.artifactsDir})) as string[]\n\n return contracts.reduce(\n (retval, filename) => {\n const storage = getInitialStorage(parsedArgs) (filename)\n if (!storage) throw(`No initial storage provided for ${filename}`)\n return [...retval, {filename, storage}]\n },\n [] as ContractStorageMapping[]\n ) \n}\n\nconst mapOpToContract = async (contracts: ContractStorageMapping[], op: BatchWalletOperation, destination: string) => {\n const results = await op.operationResults()\n\n return contracts.reduce(\n (retval, contract) => {\n\n // If initial storage was provided for the contract\n // then we submitted an operation to originate that contract\n if (contract.storage) {\n const result = results.pop() as OperationContentsAndResultOrigination\n const address = result && result.metadata.operation_result.originated_contracts\n ? result.metadata.operation_result.originated_contracts.join(',')\n : 'Error'\n\n return [\n ...retval, {\n contract: contract.filename,\n address,\n destination\n }\n ]\n }\n\n return [\n ...retval, {\n contract: contract.filename,\n address: \"Error\",\n destination\n }\n ]\n },\n [] as OriginationResult[]\n )\n}\n\n\nconst createBatch = async (parsedArgs: Opts, tezos: TezosToolkit, destination: string) => {\n const contracts = await getValidContracts (parsedArgs) \n \n const batch = await contracts.reduce(\n (batch, contractMapping) => \n contractMapping.storage\n ? addOrigination(parsedArgs, batch) (contractMapping)\n : batch,\n Promise.resolve(tezos.wallet.batch())\n )\n \n try {\n const op = await batch.send()\n const confirmed = await op.confirmation()\n return await mapOpToContract(contracts, op, destination)\n }\n catch (err) {\n const error = (err as {message: string})\n if (error.message) sendErr(error.message)\n return undefined\n }\n}\n\nconst originateToNetworks = (parsedArgs: Opts, currentEnv: Protocol.Environment.t) =>\n currentEnv.networks\n ? currentEnv.networks.reduce(\n (retval, networkName) => {\n const network = getNetworkConfig (parsedArgs) (networkName)\n if (network) {\n if (network.rpcUrl) {\n if (network.faucet) {\n const result = (async () => {\n const tezos = new TezosToolkit(network.rpcUrl as string)\n await importKey(tezos, network.faucet.email, network.faucet.password, network.faucet.mnemonic.join(' '), network.faucet.activation_code)\n return await createBatch(parsedArgs, tezos, networkName)\n })()\n \n return [...retval, result]\n }\n else sendErr(`Network ${networkName} requires a valid faucet in config.json.`)\n }\n else sendErr(`Network \"${networkName} is missing an RPC url in config.json.\"`)\n }\n else 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.`)\n \n return retval\n },\n [] as Promise<OriginationResult[]|undefined>[]\n )\n : []\n\nconst originateToSandboxes = (parsedArgs: Opts, currentEnv: Protocol.Environment.t) =>\n currentEnv.sandboxes\n ? currentEnv.sandboxes.reduce(\n (retval, sandboxName) => {\n const sandbox = getSandboxConfig (parsedArgs) (sandboxName)\n if (sandbox) {\n if (sandbox.rpcUrl) {\n let defaultAccount = getDefaultAccount(parsedArgs) (sandboxName)\n if (!defaultAccount) {\n const first = getFirstAccountAlias(sandboxName, parsedArgs)\n if (first) {\n defaultAccount = getSandboxAccountConfig(parsedArgs) (sandboxName) (first)\n sendErr(`No default account has been configured for the sandbox called ${sandboxName}. Using the account called ${first} for origination.`)\n }\n }\n if (defaultAccount) {\n const secretKey = defaultAccount.secretKey\n const result = (async () => {\n const tezos = new TezosToolkit(sandbox.rpcUrl as string)\n tezos.setProvider({\n signer: new InMemorySigner(secretKey.replace(/^unencrypted:/, '')),\n });\n return await createBatch(parsedArgs, tezos, sandboxName)\n })()\n \n return [...retval, result]\n }\n else sendErr(`No accounts are available for the sandbox called ${sandboxName} to perform origination.`)\n }\n else sendErr(`Sandbox \"${sandboxName} is missing an RPC url in config.json.\"`)\n }\n else 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.`)\n\n return retval\n },\n [] as Promise<OriginationResult[]|undefined>[]\n )\n : []\n \n \n\nexport const originate = <T>(parsedArgs: Opts): LikeAPromise<PluginResponse, TaqError.t> => {\n const env = getCurrentEnvironmentConfig(parsedArgs)\n\n if (!env) {\n return sendAsyncErr(`There is no environment called ${parsedArgs.env} in your config.json.`)\n }\n\n const jobs = [\n ...originateToNetworks(parsedArgs, env),\n ...originateToSandboxes(parsedArgs, env)\n ]\n\n return Promise.all(jobs)\n .then(jobs => jobs.reduce(\n (retval, originations) => {\n return originations\n ? [...retval as OriginationResult[], ...originations]\n : retval\n },\n []\n ))\n .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;;;;;;AAyBA,MAAM,0CAAoB,GAAG,CAAC,WAAmB,EAAE,IAAU,GAAK;IAC9D,MAAM,OAAO,GAAG,CAAA,GAAA,6CAAsB,CAAA,CAAC,IAAI,CAAC,CAAE,WAAW,CAAC;IAC1D,OAAO,OAAO,CAAC,KAAK,EAAE,CAAA;CACzB;AAED,MAAM,wCAAkB,GAAG,CAAC,gBAAwB,EAAE,UAAgB,GAClE,CAAA,GAAA,gBAAI,CAAA,CAAC,UAAU,CAAC,MAAM,CAAC,YAAY,EAAE,QAAQ,IAAI,CAAC,gBAAgB,CAAC,GAAG,gBAAgB,GAAG,CAAC,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC;AAEtH,MAAM,oCAAc,GAAG,CAAC,UAAgB,EAAE,KAAoC,GAAK,OAAO,OAA+B,GAAK;QAC1H,MAAM,eAAe,GAAG,wCAAkB,CAAC,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC;QACxE,MAAM,YAAY,GAAG,MAAM,CAAA,GAAA,0BAAQ,CAAA,CAAC,eAAe,EAAE,OAAO,CAAC;QAC7D,OAAO,AAAC,CAAA,MAAM,KAAK,CAAA,CAAE,eAAe,CAAC;YACjC,IAAI,EAAE,YAAY;YAClB,OAAO,EAAE,OAAO,CAAC,OAAO;SAE3B,CAAC,CAAA;KACL;AAED,MAAM,uCAAiB,GAAG,OAAO,UAAgB,GAAK;IAClD,MAAM,SAAS,GAAG,UAAU,CAAC,QAAQ,GAC/B;QAAC,UAAU,CAAC,QAAQ;KAAC,GACpB,MAAM,CAAA,GAAA,yCAAI,CAAA,CAAC,SAAS,EAAE;QAAC,GAAG,EAAE,UAAU,CAAC,MAAM,CAAC,YAAY;KAAC,CAAC,AAAa;IAEhF,OAAO,S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AAM,KAAI,GAAG;WACN,yCAAmB,CAAC,UAAU,EAAE,GAAG,CAAC;WACpC,0CAAoB,CAAC,UAAU,EAAE,GAAG,CAAC;KAC3C;IAED,OAAO,OAAO,CAAC,GAAG,CAAC,KAAI,CAAC,CACnB,IAAI,CAAC,CAAA,IAAI,GAAI,IAAI,CAAC,MAAM,CACrB,CAAC,MAAM,EAAE,YAAY,GAAK;YACtB,OAAO,YAAY,GACb;mBAAI,MAAM;mBAA4B,YAAY;aAAC,GACnD,MAAM,CAAA;SACf,EACD,EAAE,CACL,CAAC,CACD,IAAI,CAAC,CAAA,OAAO,GAAI,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,GAAG,CAAA,GAAA,kCAAW,CAAA,CAAC,OAAO,CAAC,GAAE,CAAA,GAAA,8BAAO,CAAA,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAA;CAClH;IAED,wCAAwB,GAAT,yCAAS;;;ADnNxB,CAAA,GAAA,6BAAM,CAAA,CAAC,MAAM,CAAC,CAAA,KAAK,GAAK,CAAA;QACpB,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE,KAAK;QACb,OAAO,EAAE,KAAK;QACd,KAAK,EAAE;YACH,CAAA,GAAA,2BAAI,CAAA,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,CAAA,GAAA,wCAAS,CAAA;KACnB,CAAA,AAAC,EAAE,OAAO,CAAC,IAAI,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 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 { RequestArgs, PluginResponse, TaqError, LikeAPromise, Protocol} from \"@taqueria/node-sdk/types\";\nimport { TezosToolkit, WalletOperationBatch } from '@taquito/taquito';\nimport { InMemorySigner, importKey } from '@taquito/signer';\nimport { getSandboxAccountNames, getCurrentEnvironmentConfig, getNetworkConfig, getSandboxAccountConfig, getInitialStorage, sendErr, getSandboxConfig, getDefaultAccount, sendJsonRes, sendAsyncErr } from \"@taqueria/node-sdk\";\nimport { BatchWalletOperation } from \"@taquito/taquito/dist/types/wallet/batch-operation\";\nimport { OperationContentsAndResultOrigination } from \"@taquito/rpc\";\nimport glob from 'fast-glob'\nimport {join} from 'path'\nimport {readFile} from 'fs/promises'\n\ninterface Opts extends RequestArgs.t {\n contract?: string\n}\n\ninterface ContractStorageMapping {\n filename: string,\n storage?: unknown\n}\n\ninterface OriginationResult {\n contract: string\n address: string\n destination: string\n}\n\nconst getFirstAccountAlias = (sandboxName: string, opts: Opts) => {\n const aliases = getSandboxAccountNames(opts) (sandboxName)\n return aliases.shift()\n}\n\nconst getContractAbspath = (contractFilename: string, parsedArgs: Opts) => \n join(parsedArgs.config.artifactsDir, /\\.tz$/.test(contractFilename) ? contractFilename : `${contractFilename}.tz`)\n\nconst addOrigination = (parsedArgs: Opts, batch: Promise<WalletOperationBatch>) => async (mapping: ContractStorageMapping) => {\n const contractAbspath = getContractAbspath(mapping.filename, parsedArgs)\n const contractData = await readFile(contractAbspath, \"utf-8\")\n return (await batch).withOrigination({\n code: contractData,\n storage: mapping.storage,\n \n })\n}\n\nconst getValidContracts = async (parsedArgs: Opts) => {\n const contracts = parsedArgs.contract\n ? [parsedArgs.contract]\n : (await glob(\"**/*.tz\", {cwd: parsedArgs.config.artifactsDir})) as string[]\n\n return contracts.reduce(\n (retval, filename) => {\n const storage = getInitialStorage(parsedArgs) (filename)\n if (!storage) throw(`No initial storage provided for ${filename}`)\n return [...retval, {filename, storage}]\n },\n [] as ContractStorageMapping[]\n ) \n}\n\nconst mapOpToContract = async (contracts: ContractStorageMapping[], op: BatchWalletOperation, destination: string) => {\n const results = await op.operationResults()\n\n return contracts.reduce(\n (retval, contract) => {\n\n // If initial storage was provided for the contract\n // then we submitted an operation to originate that contract\n if (contract.storage) {\n\n // WARNING - using side effect here.\n // For each iteration of reduce, results array is being modified-in-place.\n // TODO: Adjust to use recursion to avoid side-effect.\n const result = results.shift() as OperationContentsAndResultOrigination\n const address = result && result.metadata.operation_result.originated_contracts\n ? result.metadata.operation_result.originated_contracts.join(',')\n : 'Error'\n\n return [\n ...retval, {\n contract: contract.filename,\n address,\n destination\n }\n ]\n }\n\n return [\n ...retval, {\n contract: contract.filename,\n address: \"Error\",\n destination\n }\n ]\n },\n [] as OriginationResult[]\n )\n}\n\n\nconst createBatch = async (parsedArgs: Opts, tezos: TezosToolkit, destination: string) => {\n const contracts = await getValidContracts (parsedArgs) \n \n const batch = await contracts.reduce(\n (batch, contractMapping) => \n contractMapping.storage\n ? addOrigination(parsedArgs, batch) (contractMapping)\n : batch,\n Promise.resolve(tezos.wallet.batch())\n )\n \n try {\n const op = await batch.send()\n const confirmed = await op.confirmation()\n return await mapOpToContract(contracts, op, destination)\n }\n catch (err) {\n const error = (err as {message: string})\n if (error.message) sendErr(error.message)\n return undefined\n }\n}\n\nconst originateToNetworks = (parsedArgs: Opts, currentEnv: Protocol.Environment.t) =>\n currentEnv.networks\n ? currentEnv.networks.reduce(\n (retval, networkName) => {\n const network = getNetworkConfig (parsedArgs) (networkName)\n if (network) {\n if (network.rpcUrl) {\n if (network.faucet) {\n const result = (async () => {\n const tezos = new TezosToolkit(network.rpcUrl as string)\n await importKey(tezos, network.faucet.email, network.faucet.password, network.faucet.mnemonic.join(' '), network.faucet.activation_code)\n return await createBatch(parsedArgs, tezos, networkName)\n })()\n \n return [...retval, result]\n }\n else sendErr(`Network ${networkName} requires a valid faucet in config.json.`)\n }\n else sendErr(`Network \"${networkName} is missing an RPC url in config.json.\"`)\n }\n else 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.`)\n \n return retval\n },\n [] as Promise<OriginationResult[]|undefined>[]\n )\n : []\n\nconst originateToSandboxes = (parsedArgs: Opts, currentEnv: Protocol.Environment.t) =>\n currentEnv.sandboxes\n ? currentEnv.sandboxes.reduce(\n (retval, sandboxName) => {\n const sandbox = getSandboxConfig (parsedArgs) (sandboxName)\n if (sandbox) {\n if (sandbox.rpcUrl) {\n let defaultAccount = getDefaultAccount(parsedArgs) (sandboxName)\n if (!defaultAccount) {\n const first = getFirstAccountAlias(sandboxName, parsedArgs)\n if (first) {\n defaultAccount = getSandboxAccountConfig(parsedArgs) (sandboxName) (first)\n sendErr(`No default account has been configured for the sandbox called ${sandboxName}. Using the account called ${first} for origination.`)\n }\n }\n if (defaultAccount) {\n const secretKey = defaultAccount.secretKey\n const result = (async () => {\n const tezos = new TezosToolkit(sandbox.rpcUrl as string)\n tezos.setProvider({\n signer: new InMemorySigner(secretKey.replace(/^unencrypted:/, '')),\n });\n return await createBatch(parsedArgs, tezos, sandboxName)\n })()\n \n return [...retval, result]\n }\n else sendErr(`No accounts are available for the sandbox called ${sandboxName} to perform origination.`)\n }\n else sendErr(`Sandbox \"${sandboxName} is missing an RPC url in config.json.\"`)\n }\n else 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.`)\n\n return retval\n },\n [] as Promise<OriginationResult[]|undefined>[]\n )\n : []\n \n \n\nexport const originate = <T>(parsedArgs: Opts): LikeAPromise<PluginResponse, TaqError.t> => {\n const env = getCurrentEnvironmentConfig(parsedArgs)\n\n if (!env) {\n return sendAsyncErr(`There is no environment called ${parsedArgs.env} in your config.json.`)\n }\n\n const jobs = [\n ...originateToNetworks(parsedArgs, env),\n ...originateToSandboxes(parsedArgs, env)\n ]\n\n return Promise.all(jobs)\n .then(jobs => jobs.reduce(\n (retval, originations) => {\n return originations\n ? [...retval as OriginationResult[], ...originations]\n : retval\n },\n []\n ))\n .then(results => results && results.length > 0 ? sendJsonRes(results): sendErr(`No contracts originated.`))\n}\n\nexport default originate\n"],"names":[],"version":3,"file":"index.js.map","sourceRoot":"../"}
|
package/originate.ts
CHANGED
|
@@ -65,7 +65,11 @@ const mapOpToContract = async (contracts: ContractStorageMapping[], op: BatchWal
|
|
|
65
65
|
// If initial storage was provided for the contract
|
|
66
66
|
// then we submitted an operation to originate that contract
|
|
67
67
|
if (contract.storage) {
|
|
68
|
-
|
|
68
|
+
|
|
69
|
+
// WARNING - using side effect here.
|
|
70
|
+
// For each iteration of reduce, results array is being modified-in-place.
|
|
71
|
+
// TODO: Adjust to use recursion to avoid side-effect.
|
|
72
|
+
const result = results.shift() as OperationContentsAndResultOrigination
|
|
69
73
|
const address = result && result.metadata.operation_result.originated_contracts
|
|
70
74
|
? result.metadata.operation_result.originated_contracts.join(',')
|
|
71
75
|
: 'Error'
|