@taqueria/plugin-taquito 0.0.0-pr-810-53ffecf2 → 0.0.0-pr-829-20439d01
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 +43 -51
- package/index.js.map +1 -1
- package/package.json +2 -2
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,
|
|
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))(
|
|
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,
|
|
@@ -58,7 +56,7 @@ const $806c5c6032403442$var$mapOpToContract = async (contracts, op, destination)
|
|
|
58
56
|
// For each iteration of reduce, results array is being modified-in-place.
|
|
59
57
|
// TODO: Adjust to use recursion to avoid side-effect.
|
|
60
58
|
const result = results.shift();
|
|
61
|
-
const address = result && result.metadata.operation_result.originated_contracts ? result.metadata.operation_result.originated_contracts.join(
|
|
59
|
+
const address = result && result.metadata.operation_result.originated_contracts ? result.metadata.operation_result.originated_contracts.join(",") : "Error";
|
|
62
60
|
return [
|
|
63
61
|
...retval,
|
|
64
62
|
{
|
|
@@ -72,7 +70,7 @@ const $806c5c6032403442$var$mapOpToContract = async (contracts, op, destination)
|
|
|
72
70
|
...retval,
|
|
73
71
|
{
|
|
74
72
|
contract: contract.filename,
|
|
75
|
-
address:
|
|
73
|
+
address: "Error",
|
|
76
74
|
destination: destination
|
|
77
75
|
},
|
|
78
76
|
];
|
|
@@ -80,56 +78,54 @@ const $806c5c6032403442$var$mapOpToContract = async (contracts, op, destination)
|
|
|
80
78
|
};
|
|
81
79
|
const $806c5c6032403442$var$createBatch = async (parsedArgs, tezos, destination)=>{
|
|
82
80
|
const contracts = await $806c5c6032403442$var$getValidContracts(parsedArgs);
|
|
83
|
-
const batch1 = await contracts.reduce((batch, contractMapping)=>contractMapping.storage ? $806c5c6032403442$var$addOrigination(parsedArgs, batch)(contractMapping) : batch
|
|
84
|
-
, 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()));
|
|
85
82
|
try {
|
|
86
83
|
const op = await batch1.send();
|
|
87
84
|
const confirmed = await op.confirmation();
|
|
88
85
|
return await $806c5c6032403442$var$mapOpToContract(contracts, op, destination);
|
|
89
86
|
} catch (err) {
|
|
90
87
|
const error = err;
|
|
91
|
-
if (error.message) $iVZbm$taquerianodesdk.sendErr(error.message);
|
|
88
|
+
if (error.message) (0, $iVZbm$taquerianodesdk.sendErr)(error.message);
|
|
92
89
|
return undefined;
|
|
93
90
|
}
|
|
94
91
|
};
|
|
95
92
|
const $806c5c6032403442$var$originateToNetworks = (parsedArgs, currentEnv)=>currentEnv.networks ? currentEnv.networks.reduce((retval, networkName)=>{
|
|
96
|
-
const network = $iVZbm$taquerianodesdk.getNetworkConfig(parsedArgs)(networkName);
|
|
93
|
+
const network = (0, $iVZbm$taquerianodesdk.getNetworkConfig)(parsedArgs)(networkName);
|
|
97
94
|
if (network) {
|
|
98
95
|
if (network.rpcUrl) {
|
|
99
96
|
if (network.faucet) {
|
|
100
97
|
const result = (async ()=>{
|
|
101
|
-
const tezos = new $iVZbm$taquitotaquito.TezosToolkit(network.rpcUrl);
|
|
102
|
-
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);
|
|
103
100
|
return await $806c5c6032403442$var$createBatch(parsedArgs, tezos, networkName);
|
|
104
101
|
})();
|
|
105
102
|
return [
|
|
106
103
|
...retval,
|
|
107
104
|
result
|
|
108
105
|
];
|
|
109
|
-
} else $iVZbm$taquerianodesdk.sendErr(`Network ${networkName} requires a valid faucet in config.json.`);
|
|
110
|
-
} else $iVZbm$taquerianodesdk.sendErr(`Network "${networkName} is missing an RPC url in config.json."`);
|
|
111
|
-
} 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.`);
|
|
112
109
|
return retval;
|
|
113
|
-
}, []) : []
|
|
114
|
-
;
|
|
110
|
+
}, []) : [];
|
|
115
111
|
const $806c5c6032403442$var$originateToSandboxes = (parsedArgs, currentEnv)=>currentEnv.sandboxes ? currentEnv.sandboxes.reduce((retval, sandboxName)=>{
|
|
116
|
-
const sandbox = $iVZbm$taquerianodesdk.getSandboxConfig(parsedArgs)(sandboxName);
|
|
112
|
+
const sandbox = (0, $iVZbm$taquerianodesdk.getSandboxConfig)(parsedArgs)(sandboxName);
|
|
117
113
|
if (sandbox) {
|
|
118
114
|
if (sandbox.rpcUrl) {
|
|
119
|
-
let defaultAccount = $iVZbm$taquerianodesdk.getDefaultAccount(parsedArgs)(sandboxName);
|
|
115
|
+
let defaultAccount = (0, $iVZbm$taquerianodesdk.getDefaultAccount)(parsedArgs)(sandboxName);
|
|
120
116
|
if (!defaultAccount) {
|
|
121
117
|
const first = $806c5c6032403442$var$getFirstAccountAlias(sandboxName, parsedArgs);
|
|
122
118
|
if (first) {
|
|
123
|
-
defaultAccount = $iVZbm$taquerianodesdk.getSandboxAccountConfig(parsedArgs)(sandboxName)(first);
|
|
124
|
-
$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.`);
|
|
125
121
|
}
|
|
126
122
|
}
|
|
127
123
|
if (defaultAccount) {
|
|
128
124
|
const secretKey = defaultAccount.secretKey;
|
|
129
125
|
const result = (async ()=>{
|
|
130
|
-
const tezos = new $iVZbm$taquitotaquito.TezosToolkit(sandbox.rpcUrl);
|
|
126
|
+
const tezos = new (0, $iVZbm$taquitotaquito.TezosToolkit)(sandbox.rpcUrl);
|
|
131
127
|
tezos.setProvider({
|
|
132
|
-
signer: new $iVZbm$taquitosigner.InMemorySigner(secretKey.replace(/^unencrypted:/,
|
|
128
|
+
signer: new (0, $iVZbm$taquitosigner.InMemorySigner)(secretKey.replace(/^unencrypted:/, ""))
|
|
133
129
|
});
|
|
134
130
|
return await $806c5c6032403442$var$createBatch(parsedArgs, tezos, sandboxName);
|
|
135
131
|
})();
|
|
@@ -137,15 +133,14 @@ const $806c5c6032403442$var$originateToSandboxes = (parsedArgs, currentEnv)=>cur
|
|
|
137
133
|
...retval,
|
|
138
134
|
result
|
|
139
135
|
];
|
|
140
|
-
} else $iVZbm$taquerianodesdk.sendErr(`No accounts are available for the sandbox called ${sandboxName} to perform origination.`);
|
|
141
|
-
} else $iVZbm$taquerianodesdk.sendErr(`Sandbox "${sandboxName} is missing an RPC url in config.json."`);
|
|
142
|
-
} 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.`);
|
|
143
139
|
return retval;
|
|
144
|
-
}, []) : []
|
|
145
|
-
;
|
|
140
|
+
}, []) : [];
|
|
146
141
|
const $806c5c6032403442$export$acf571c34911f824 = (parsedArgs)=>{
|
|
147
|
-
const env = $iVZbm$taquerianodesdk.getCurrentEnvironmentConfig(parsedArgs);
|
|
148
|
-
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.`);
|
|
149
144
|
const jobs1 = [
|
|
150
145
|
...$806c5c6032403442$var$originateToNetworks(parsedArgs, env),
|
|
151
146
|
...$806c5c6032403442$var$originateToSandboxes(parsedArgs, env),
|
|
@@ -155,33 +150,30 @@ const $806c5c6032403442$export$acf571c34911f824 = (parsedArgs)=>{
|
|
|
155
150
|
...retval,
|
|
156
151
|
...originations
|
|
157
152
|
] : retval;
|
|
158
|
-
}, [])
|
|
159
|
-
).then((results)=>results && results.length > 0 ? $iVZbm$taquerianodesdk.sendJsonRes(results) : $iVZbm$taquerianodesdk.sendErr(`No contracts originated.`)
|
|
160
|
-
);
|
|
153
|
+
}, [])).then((results)=>results && results.length > 0 ? (0, $iVZbm$taquerianodesdk.sendJsonRes)(results) : (0, $iVZbm$taquerianodesdk.sendErr)(`No contracts originated.`));
|
|
161
154
|
};
|
|
162
155
|
var $806c5c6032403442$export$2e2bcd8739ae039 = $806c5c6032403442$export$acf571c34911f824;
|
|
163
156
|
|
|
164
157
|
|
|
165
|
-
$iVZbm$taquerianodesdk.Plugin.create((_i18n)=>({
|
|
166
|
-
alias:
|
|
167
|
-
schema:
|
|
168
|
-
version:
|
|
158
|
+
(0, $iVZbm$taquerianodesdk.Plugin).create((_i18n)=>({
|
|
159
|
+
alias: "taquito",
|
|
160
|
+
schema: "1.0",
|
|
161
|
+
version: "0.1",
|
|
169
162
|
tasks: [
|
|
170
|
-
$iVZbm$taquerianodesdk.Task.create({
|
|
171
|
-
task:
|
|
172
|
-
command:
|
|
173
|
-
description:
|
|
163
|
+
(0, $iVZbm$taquerianodesdk.Task).create({
|
|
164
|
+
task: "deploy",
|
|
165
|
+
command: "deploy [contract]",
|
|
166
|
+
description: "Deploy a smart contract to a particular environment",
|
|
174
167
|
options: [],
|
|
175
168
|
aliases: [
|
|
176
|
-
|
|
169
|
+
"originate"
|
|
177
170
|
],
|
|
178
|
-
handler:
|
|
179
|
-
encoding:
|
|
171
|
+
handler: "proxy",
|
|
172
|
+
encoding: "application/json"
|
|
180
173
|
}),
|
|
181
174
|
],
|
|
182
|
-
proxy: $806c5c6032403442$export$2e2bcd8739ae039
|
|
183
|
-
})
|
|
184
|
-
, process.argv);
|
|
175
|
+
proxy: (0, $806c5c6032403442$export$2e2bcd8739ae039)
|
|
176
|
+
}), process.argv);
|
|
185
177
|
|
|
186
178
|
|
|
187
179
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;AAAA;ACAA;;;;;;AAoCA,MAAM,0CAAoB,GAAG,CAAC,WAAmB,EAAE,IAAU,GAAK;IACjE,MAAM,OAAO,GAAG,6CAAsB,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,gBAAI,CAAC,UAAU,CAAC,MAAM,CAAC,YAAY,EAAE,QAAQ,IAAI,CAAC,gBAAgB,CAAC,GAAG,gBAAgB,GAAG,CAAC,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC;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,CAAC,MAAM,CAAC;gBACX,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,mBAAmB;gBAC5B,WAAW,EAAE,qDAAqD;gBAClE,OAAO,EAAE,EAAE;gBACX,OAAO,EAAE;oBAAC,WAAW;iBAAC;gBACtB,OAAO,EAAE,OAAO;gBAChB,QAAQ,EAAE,kBAAkB;aAC5B,CAAC;SACF;QACD,KAAK,EAAE,wCAAS;KAChB,CAAA;AAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC","sources":["taqueria-plugin-taquito/index.ts","taqueria-plugin-taquito/originate.ts"],"sourcesContent":["import { Plugin, Task } from '@taqueria/node-sdk';\nimport originate from './originate';\n\nPlugin.create(_i18n => ({\n\talias: 'taquito',\n\tschema: '1.0',\n\tversion: '0.1',\n\ttasks: [\n\t\tTask.create({\n\t\t\ttask: 'deploy',\n\t\t\tcommand: 'deploy [contract]',\n\t\t\tdescription: 'Deploy a smart contract to a particular environment',\n\t\t\toptions: [],\n\t\t\taliases: ['originate'],\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'application/json',\n\t\t}),\n\t],\n\tproxy: originate,\n}), process.argv);\n","import {\n\tgetCurrentEnvironmentConfig,\n\tgetDefaultAccount,\n\tgetInitialStorage,\n\tgetNetworkConfig,\n\tgetSandboxAccountConfig,\n\tgetSandboxAccountNames,\n\tgetSandboxConfig,\n\tsendAsyncErr,\n\tsendErr,\n\tsendJsonRes,\n} from '@taqueria/node-sdk';\nimport { LikeAPromise, PluginResponse, Protocol, RequestArgs, TaqError } from '@taqueria/node-sdk/types';\nimport { OperationContentsAndResultOrigination } from '@taquito/rpc';\nimport { importKey, InMemorySigner } from '@taquito/signer';\nimport { TezosToolkit, WalletOperationBatch } from '@taquito/taquito';\nimport { BatchWalletOperation } from '@taquito/taquito/dist/types/wallet/batch-operation';\nimport glob from 'fast-glob';\nimport { readFile } from 'fs/promises';\nimport { join } from 'path';\n\ninterface Opts extends RequestArgs.t {\n\tcontract?: string;\n}\n\ninterface ContractStorageMapping {\n\tfilename: string;\n\tstorage?: unknown;\n}\n\ninterface OriginationResult {\n\tcontract: string;\n\taddress: string;\n\tdestination: string;\n}\n\nconst getFirstAccountAlias = (sandboxName: string, opts: Opts) => {\n\tconst aliases = getSandboxAccountNames(opts)(sandboxName);\n\treturn aliases.shift();\n};\n\nconst getContractAbspath = (contractFilename: string, parsedArgs: Opts) =>\n\tjoin(parsedArgs.config.artifactsDir, /\\.tz$/.test(contractFilename) ? contractFilename : `${contractFilename}.tz`);\n\nconst addOrigination = (parsedArgs: Opts, batch: Promise<WalletOperationBatch>) =>\n\tasync (mapping: ContractStorageMapping) => {\n\t\tconst contractAbspath = getContractAbspath(mapping.filename, parsedArgs);\n\t\tconst contractData = await readFile(contractAbspath, 'utf-8');\n\t\treturn (await batch).withOrigination({\n\t\t\tcode: contractData,\n\t\t\tstorage: mapping.storage,\n\t\t});\n\t};\n\nconst getValidContracts = async (parsedArgs: Opts) => {\n\tconst contracts = parsedArgs.contract\n\t\t? [parsedArgs.contract]\n\t\t: (await glob('**/*.tz', { cwd: parsedArgs.config.artifactsDir })) as string[];\n\n\treturn contracts.reduce(\n\t\t(retval, filename) => {\n\t\t\tconst storage = getInitialStorage(parsedArgs)(filename);\n\t\t\tif (!storage) throw (`No initial storage provided for ${filename}`);\n\t\t\treturn [...retval, { filename, storage }];\n\t\t},\n\t\t[] as ContractStorageMapping[],\n\t);\n};\n\nconst mapOpToContract = async (contracts: ContractStorageMapping[], op: BatchWalletOperation, destination: string) => {\n\tconst results = await op.operationResults();\n\n\treturn contracts.reduce(\n\t\t(retval, contract) => {\n\t\t\t// If initial storage was provided for the contract\n\t\t\t// then we submitted an operation to originate that contract\n\t\t\tif (contract.storage) {\n\t\t\t\t// WARNING - using side effect here.\n\t\t\t\t// For each iteration of reduce, results array is being modified-in-place.\n\t\t\t\t// TODO: Adjust to use recursion to avoid side-effect.\n\t\t\t\tconst result = results.shift() as OperationContentsAndResultOrigination;\n\t\t\t\tconst address = result && result.metadata.operation_result.originated_contracts\n\t\t\t\t\t? result.metadata.operation_result.originated_contracts.join(',')\n\t\t\t\t\t: 'Error';\n\n\t\t\t\treturn [\n\t\t\t\t\t...retval,\n\t\t\t\t\t{\n\t\t\t\t\t\tcontract: contract.filename,\n\t\t\t\t\t\taddress,\n\t\t\t\t\t\tdestination,\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\t...retval,\n\t\t\t\t{\n\t\t\t\t\tcontract: contract.filename,\n\t\t\t\t\taddress: 'Error',\n\t\t\t\t\tdestination,\n\t\t\t\t},\n\t\t\t];\n\t\t},\n\t\t[] as OriginationResult[],\n\t);\n};\n\nconst createBatch = async (parsedArgs: Opts, tezos: TezosToolkit, destination: string) => {\n\tconst contracts = await getValidContracts(parsedArgs);\n\n\tconst batch = await contracts.reduce(\n\t\t(batch, contractMapping) =>\n\t\t\tcontractMapping.storage\n\t\t\t\t? addOrigination(parsedArgs, batch)(contractMapping)\n\t\t\t\t: batch,\n\t\tPromise.resolve(tezos.wallet.batch()),\n\t);\n\n\ttry {\n\t\tconst op = await batch.send();\n\t\tconst confirmed = await op.confirmation();\n\t\treturn await mapOpToContract(contracts, op, destination);\n\t} catch (err) {\n\t\tconst error = (err as { message: string });\n\t\tif (error.message) sendErr(error.message);\n\t\treturn undefined;\n\t}\n};\n\nconst originateToNetworks = (parsedArgs: Opts, currentEnv: Protocol.Environment.t) =>\n\tcurrentEnv.networks\n\t\t? currentEnv.networks.reduce(\n\t\t\t(retval, networkName) => {\n\t\t\t\tconst network = getNetworkConfig(parsedArgs)(networkName);\n\t\t\t\tif (network) {\n\t\t\t\t\tif (network.rpcUrl) {\n\t\t\t\t\t\tif (network.faucet) {\n\t\t\t\t\t\t\tconst result = (async () => {\n\t\t\t\t\t\t\t\tconst tezos = new TezosToolkit(network.rpcUrl as string);\n\t\t\t\t\t\t\t\tawait importKey(\n\t\t\t\t\t\t\t\t\ttezos,\n\t\t\t\t\t\t\t\t\tnetwork.faucet.email,\n\t\t\t\t\t\t\t\t\tnetwork.faucet.password,\n\t\t\t\t\t\t\t\t\tnetwork.faucet.mnemonic.join(' '),\n\t\t\t\t\t\t\t\t\tnetwork.faucet.activation_code,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn await createBatch(parsedArgs, tezos, networkName);\n\t\t\t\t\t\t\t})();\n\n\t\t\t\t\t\t\treturn [...retval, result];\n\t\t\t\t\t\t} else sendErr(`Network ${networkName} requires a valid faucet in config.json.`);\n\t\t\t\t\t} else sendErr(`Network \"${networkName} is missing an RPC url in config.json.\"`);\n\t\t\t\t} else {\n\t\t\t\t\tsendErr(\n\t\t\t\t\t\t`The current environment is configured to use a network called '${networkName}'; however, no network of this name has been configured in .taq/config.json.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn retval;\n\t\t\t},\n\t\t\t[] as Promise<OriginationResult[] | undefined>[],\n\t\t)\n\t\t: [];\n\nconst originateToSandboxes = (parsedArgs: Opts, currentEnv: Protocol.Environment.t) =>\n\tcurrentEnv.sandboxes\n\t\t? currentEnv.sandboxes.reduce(\n\t\t\t(retval, sandboxName) => {\n\t\t\t\tconst sandbox = getSandboxConfig(parsedArgs)(sandboxName);\n\t\t\t\tif (sandbox) {\n\t\t\t\t\tif (sandbox.rpcUrl) {\n\t\t\t\t\t\tlet defaultAccount = getDefaultAccount(parsedArgs)(sandboxName);\n\t\t\t\t\t\tif (!defaultAccount) {\n\t\t\t\t\t\t\tconst first = getFirstAccountAlias(sandboxName, parsedArgs);\n\t\t\t\t\t\t\tif (first) {\n\t\t\t\t\t\t\t\tdefaultAccount = getSandboxAccountConfig(parsedArgs)(sandboxName)(first);\n\t\t\t\t\t\t\t\tsendErr(\n\t\t\t\t\t\t\t\t\t`No default account has been configured for the sandbox called ${sandboxName}. Using the account called ${first} for origination.`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (defaultAccount) {\n\t\t\t\t\t\t\tconst secretKey = defaultAccount.secretKey;\n\t\t\t\t\t\t\tconst result = (async () => {\n\t\t\t\t\t\t\t\tconst tezos = new TezosToolkit(sandbox.rpcUrl as string);\n\t\t\t\t\t\t\t\ttezos.setProvider({\n\t\t\t\t\t\t\t\t\tsigner: new InMemorySigner(secretKey.replace(/^unencrypted:/, '')),\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\treturn await createBatch(parsedArgs, tezos, sandboxName);\n\t\t\t\t\t\t\t})();\n\n\t\t\t\t\t\t\treturn [...retval, result];\n\t\t\t\t\t\t} else sendErr(`No accounts are available for the sandbox called ${sandboxName} to perform origination.`);\n\t\t\t\t\t} else sendErr(`Sandbox \"${sandboxName} is missing an RPC url in config.json.\"`);\n\t\t\t\t} else {\n\t\t\t\t\tsendErr(\n\t\t\t\t\t\t`The current environment is configured to use a sandbox called '${sandboxName}'; however, no sandbox of this name has been configured in .taq/config.json.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn retval;\n\t\t\t},\n\t\t\t[] as Promise<OriginationResult[] | undefined>[],\n\t\t)\n\t\t: [];\n\nexport const originate = <T>(parsedArgs: Opts): LikeAPromise<PluginResponse, TaqError.t> => {\n\tconst env = getCurrentEnvironmentConfig(parsedArgs);\n\n\tif (!env) {\n\t\treturn sendAsyncErr(`There is no environment called ${parsedArgs.env} in your config.json.`);\n\t}\n\n\tconst jobs = [\n\t\t...originateToNetworks(parsedArgs, env),\n\t\t...originateToSandboxes(parsedArgs, env),\n\t];\n\n\treturn Promise.all(jobs)\n\t\t.then(jobs =>\n\t\t\tjobs.reduce(\n\t\t\t\t(retval, originations) => {\n\t\t\t\t\treturn originations\n\t\t\t\t\t\t? [...retval as OriginationResult[], ...originations]\n\t\t\t\t\t\t: retval;\n\t\t\t\t},\n\t\t\t\t[],\n\t\t\t)\n\t\t)\n\t\t.then(results => results && results.length > 0 ? sendJsonRes(results) : sendErr(`No contracts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,CAAA,GAAA,wCAAS,CAAA;KAChB,CAAA,AAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC","sources":["taqueria-plugin-taquito/index.ts","taqueria-plugin-taquito/originate.ts"],"sourcesContent":["import { Plugin, Task } from '@taqueria/node-sdk';\nimport originate from './originate';\n\nPlugin.create(_i18n => ({\n\talias: 'taquito',\n\tschema: '1.0',\n\tversion: '0.1',\n\ttasks: [\n\t\tTask.create({\n\t\t\ttask: 'deploy',\n\t\t\tcommand: 'deploy [contract]',\n\t\t\tdescription: 'Deploy a smart contract to a particular environment',\n\t\t\toptions: [],\n\t\t\taliases: ['originate'],\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'application/json',\n\t\t}),\n\t],\n\tproxy: originate,\n}), process.argv);\n","import {\n\tgetCurrentEnvironmentConfig,\n\tgetDefaultAccount,\n\tgetInitialStorage,\n\tgetNetworkConfig,\n\tgetSandboxAccountConfig,\n\tgetSandboxAccountNames,\n\tgetSandboxConfig,\n\tsendAsyncErr,\n\tsendErr,\n\tsendJsonRes,\n} from '@taqueria/node-sdk';\nimport { LikeAPromise, PluginResponse, Protocol, RequestArgs, TaqError } from '@taqueria/node-sdk/types';\nimport { OperationContentsAndResultOrigination } from '@taquito/rpc';\nimport { importKey, InMemorySigner } from '@taquito/signer';\nimport { TezosToolkit, WalletOperationBatch } from '@taquito/taquito';\nimport { BatchWalletOperation } from '@taquito/taquito/dist/types/wallet/batch-operation';\nimport glob from 'fast-glob';\nimport { readFile } from 'fs/promises';\nimport { join } from 'path';\n\ninterface Opts extends RequestArgs.t {\n\tcontract?: string;\n}\n\ninterface ContractStorageMapping {\n\tfilename: string;\n\tstorage?: unknown;\n}\n\ninterface OriginationResult {\n\tcontract: string;\n\taddress: string;\n\tdestination: string;\n}\n\nconst getFirstAccountAlias = (sandboxName: string, opts: Opts) => {\n\tconst aliases = getSandboxAccountNames(opts)(sandboxName);\n\treturn aliases.shift();\n};\n\nconst getContractAbspath = (contractFilename: string, parsedArgs: Opts) =>\n\tjoin(parsedArgs.config.artifactsDir, /\\.tz$/.test(contractFilename) ? contractFilename : `${contractFilename}.tz`);\n\nconst addOrigination = (parsedArgs: Opts, batch: Promise<WalletOperationBatch>) =>\n\tasync (mapping: ContractStorageMapping) => {\n\t\tconst contractAbspath = getContractAbspath(mapping.filename, parsedArgs);\n\t\tconst contractData = await readFile(contractAbspath, 'utf-8');\n\t\treturn (await batch).withOrigination({\n\t\t\tcode: contractData,\n\t\t\tstorage: mapping.storage,\n\t\t});\n\t};\n\nconst getValidContracts = async (parsedArgs: Opts) => {\n\tconst contracts = parsedArgs.contract\n\t\t? [parsedArgs.contract]\n\t\t: (await glob('**/*.tz', { cwd: parsedArgs.config.artifactsDir })) as string[];\n\n\treturn contracts.reduce(\n\t\t(retval, filename) => {\n\t\t\tconst storage = getInitialStorage(parsedArgs)(filename);\n\t\t\tif (!storage) throw (`No initial storage provided for ${filename}`);\n\t\t\treturn [...retval, { filename, storage }];\n\t\t},\n\t\t[] as ContractStorageMapping[],\n\t);\n};\n\nconst mapOpToContract = async (contracts: ContractStorageMapping[], op: BatchWalletOperation, destination: string) => {\n\tconst results = await op.operationResults();\n\n\treturn contracts.reduce(\n\t\t(retval, contract) => {\n\t\t\t// If initial storage was provided for the contract\n\t\t\t// then we submitted an operation to originate that contract\n\t\t\tif (contract.storage) {\n\t\t\t\t// WARNING - using side effect here.\n\t\t\t\t// For each iteration of reduce, results array is being modified-in-place.\n\t\t\t\t// TODO: Adjust to use recursion to avoid side-effect.\n\t\t\t\tconst result = results.shift() as OperationContentsAndResultOrigination;\n\t\t\t\tconst address = result && result.metadata.operation_result.originated_contracts\n\t\t\t\t\t? result.metadata.operation_result.originated_contracts.join(',')\n\t\t\t\t\t: 'Error';\n\n\t\t\t\treturn [\n\t\t\t\t\t...retval,\n\t\t\t\t\t{\n\t\t\t\t\t\tcontract: contract.filename,\n\t\t\t\t\t\taddress,\n\t\t\t\t\t\tdestination,\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\t...retval,\n\t\t\t\t{\n\t\t\t\t\tcontract: contract.filename,\n\t\t\t\t\taddress: 'Error',\n\t\t\t\t\tdestination,\n\t\t\t\t},\n\t\t\t];\n\t\t},\n\t\t[] as OriginationResult[],\n\t);\n};\n\nconst createBatch = async (parsedArgs: Opts, tezos: TezosToolkit, destination: string) => {\n\tconst contracts = await getValidContracts(parsedArgs);\n\n\tconst batch = await contracts.reduce(\n\t\t(batch, contractMapping) =>\n\t\t\tcontractMapping.storage\n\t\t\t\t? addOrigination(parsedArgs, batch)(contractMapping)\n\t\t\t\t: batch,\n\t\tPromise.resolve(tezos.wallet.batch()),\n\t);\n\n\ttry {\n\t\tconst op = await batch.send();\n\t\tconst confirmed = await op.confirmation();\n\t\treturn await mapOpToContract(contracts, op, destination);\n\t} catch (err) {\n\t\tconst error = (err as { message: string });\n\t\tif (error.message) sendErr(error.message);\n\t\treturn undefined;\n\t}\n};\n\nconst originateToNetworks = (parsedArgs: Opts, currentEnv: Protocol.Environment.t) =>\n\tcurrentEnv.networks\n\t\t? currentEnv.networks.reduce(\n\t\t\t(retval, networkName) => {\n\t\t\t\tconst network = getNetworkConfig(parsedArgs)(networkName);\n\t\t\t\tif (network) {\n\t\t\t\t\tif (network.rpcUrl) {\n\t\t\t\t\t\tif (network.faucet) {\n\t\t\t\t\t\t\tconst result = (async () => {\n\t\t\t\t\t\t\t\tconst tezos = new TezosToolkit(network.rpcUrl as string);\n\t\t\t\t\t\t\t\tawait importKey(\n\t\t\t\t\t\t\t\t\ttezos,\n\t\t\t\t\t\t\t\t\tnetwork.faucet.email,\n\t\t\t\t\t\t\t\t\tnetwork.faucet.password,\n\t\t\t\t\t\t\t\t\tnetwork.faucet.mnemonic.join(' '),\n\t\t\t\t\t\t\t\t\tnetwork.faucet.activation_code,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn await createBatch(parsedArgs, tezos, networkName);\n\t\t\t\t\t\t\t})();\n\n\t\t\t\t\t\t\treturn [...retval, result];\n\t\t\t\t\t\t} else sendErr(`Network ${networkName} requires a valid faucet in config.json.`);\n\t\t\t\t\t} else sendErr(`Network \"${networkName} is missing an RPC url in config.json.\"`);\n\t\t\t\t} else {\n\t\t\t\t\tsendErr(\n\t\t\t\t\t\t`The current environment is configured to use a network called '${networkName}'; however, no network of this name has been configured in .taq/config.json.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn retval;\n\t\t\t},\n\t\t\t[] as Promise<OriginationResult[] | undefined>[],\n\t\t)\n\t\t: [];\n\nconst originateToSandboxes = (parsedArgs: Opts, currentEnv: Protocol.Environment.t) =>\n\tcurrentEnv.sandboxes\n\t\t? currentEnv.sandboxes.reduce(\n\t\t\t(retval, sandboxName) => {\n\t\t\t\tconst sandbox = getSandboxConfig(parsedArgs)(sandboxName);\n\t\t\t\tif (sandbox) {\n\t\t\t\t\tif (sandbox.rpcUrl) {\n\t\t\t\t\t\tlet defaultAccount = getDefaultAccount(parsedArgs)(sandboxName);\n\t\t\t\t\t\tif (!defaultAccount) {\n\t\t\t\t\t\t\tconst first = getFirstAccountAlias(sandboxName, parsedArgs);\n\t\t\t\t\t\t\tif (first) {\n\t\t\t\t\t\t\t\tdefaultAccount = getSandboxAccountConfig(parsedArgs)(sandboxName)(first);\n\t\t\t\t\t\t\t\tsendErr(\n\t\t\t\t\t\t\t\t\t`No default account has been configured for the sandbox called ${sandboxName}. Using the account called ${first} for origination.`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (defaultAccount) {\n\t\t\t\t\t\t\tconst secretKey = defaultAccount.secretKey;\n\t\t\t\t\t\t\tconst result = (async () => {\n\t\t\t\t\t\t\t\tconst tezos = new TezosToolkit(sandbox.rpcUrl as string);\n\t\t\t\t\t\t\t\ttezos.setProvider({\n\t\t\t\t\t\t\t\t\tsigner: new InMemorySigner(secretKey.replace(/^unencrypted:/, '')),\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\treturn await createBatch(parsedArgs, tezos, sandboxName);\n\t\t\t\t\t\t\t})();\n\n\t\t\t\t\t\t\treturn [...retval, result];\n\t\t\t\t\t\t} else sendErr(`No accounts are available for the sandbox called ${sandboxName} to perform origination.`);\n\t\t\t\t\t} else sendErr(`Sandbox \"${sandboxName} is missing an RPC url in config.json.\"`);\n\t\t\t\t} else {\n\t\t\t\t\tsendErr(\n\t\t\t\t\t\t`The current environment is configured to use a sandbox called '${sandboxName}'; however, no sandbox of this name has been configured in .taq/config.json.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn retval;\n\t\t\t},\n\t\t\t[] as Promise<OriginationResult[] | undefined>[],\n\t\t)\n\t\t: [];\n\nexport const originate = <T>(parsedArgs: Opts): LikeAPromise<PluginResponse, TaqError.t> => {\n\tconst env = getCurrentEnvironmentConfig(parsedArgs);\n\n\tif (!env) {\n\t\treturn sendAsyncErr(`There is no environment called ${parsedArgs.env} in your config.json.`);\n\t}\n\n\tconst jobs = [\n\t\t...originateToNetworks(parsedArgs, env),\n\t\t...originateToSandboxes(parsedArgs, env),\n\t];\n\n\treturn Promise.all(jobs)\n\t\t.then(jobs =>\n\t\t\tjobs.reduce(\n\t\t\t\t(retval, originations) => {\n\t\t\t\t\treturn originations\n\t\t\t\t\t\t? [...retval as OriginationResult[], ...originations]\n\t\t\t\t\t\t: retval;\n\t\t\t\t},\n\t\t\t\t[],\n\t\t\t)\n\t\t)\n\t\t.then(results => results && results.length > 0 ? sendJsonRes(results) : sendErr(`No contracts originated.`));\n};\n\nexport default originate;\n"],"names":[],"version":3,"file":"index.js.map","sourceRoot":"../"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taqueria/plugin-taquito",
|
|
3
|
-
"version": "0.0.0-pr-
|
|
3
|
+
"version": "0.0.0-pr-829-20439d01",
|
|
4
4
|
"description": "A taqueria plugin for originating smart contracts using Taquito",
|
|
5
5
|
"targets": {
|
|
6
6
|
"default": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"homepage": "https://github.com/ecadlabs/taqueria#readme",
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"parcel": "^2.
|
|
45
|
+
"parcel": "^2.6.0",
|
|
46
46
|
"typescript": "^4.7.2"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|