@taqueria/toolkit 0.42.13 → 0.43.1
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/bin/run.js +11 -37
- package/bin/run.js.map +1 -1
- package/chunk-BGUG3ZS5.js +50 -0
- package/chunk-BGUG3ZS5.js.map +1 -0
- package/chunk-SSYGV25P.js +10 -0
- package/chunk-SSYGV25P.js.map +1 -0
- package/chunk-UWGPOHCN.js +18 -0
- package/chunk-UWGPOHCN.js.map +1 -0
- package/index.js +29 -108
- package/index.js.map +1 -1
- package/package.json +13 -7
- package/tsconfig.json +3 -3
- package/v1.js +8 -38
- package/v1.js.map +1 -1
- package/v2.js +10 -59
- package/v2.js.map +1 -1
package/bin/run.js
CHANGED
|
@@ -1,50 +1,24 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
-
mod
|
|
24
|
-
));
|
|
25
2
|
|
|
26
3
|
// bin/run.ts
|
|
27
|
-
|
|
28
|
-
|
|
4
|
+
import { spawn } from "cross-spawn";
|
|
5
|
+
import yargs from "yargs";
|
|
29
6
|
|
|
30
7
|
// lib/env.ts
|
|
31
|
-
|
|
32
|
-
|
|
8
|
+
import { readdir, readFile, stat } from "fs/promises";
|
|
9
|
+
import path from "path";
|
|
33
10
|
var CustomErr = class extends Error {
|
|
34
11
|
};
|
|
35
12
|
var TaqNotFoundError = class extends CustomErr {
|
|
36
|
-
|
|
37
|
-
super(...arguments);
|
|
38
|
-
this.isCustomErr = true;
|
|
39
|
-
}
|
|
13
|
+
isCustomErr = true;
|
|
40
14
|
};
|
|
41
15
|
function isCustomError(err) {
|
|
42
16
|
return typeof err === "object" && err.hasOwnProperty("isCustomErr");
|
|
43
17
|
}
|
|
44
18
|
async function checkTaqProject(dir) {
|
|
45
19
|
try {
|
|
46
|
-
const searchPath =
|
|
47
|
-
await
|
|
20
|
+
const searchPath = path.join(dir, ".taq");
|
|
21
|
+
await stat(searchPath);
|
|
48
22
|
return searchPath;
|
|
49
23
|
} catch {
|
|
50
24
|
throw new TaqNotFoundError(`${dir} is not a valid Taqueria project.`);
|
|
@@ -57,14 +31,14 @@ var TaqConfigError = class extends CustomErr {
|
|
|
57
31
|
};
|
|
58
32
|
async function getConfig(taqDir, prefix) {
|
|
59
33
|
try {
|
|
60
|
-
const files = await
|
|
34
|
+
const files = await readdir(taqDir);
|
|
61
35
|
return files.reduce(
|
|
62
36
|
async (retval, file) => {
|
|
63
37
|
if (!file.endsWith(".json"))
|
|
64
38
|
return await retval;
|
|
65
39
|
return {
|
|
66
40
|
...await retval,
|
|
67
|
-
[getEnvName(file, prefix)]: await
|
|
41
|
+
[getEnvName(file, prefix)]: await readFile(path.join(taqDir, file), "utf-8")
|
|
68
42
|
};
|
|
69
43
|
},
|
|
70
44
|
Promise.resolve({})
|
|
@@ -93,7 +67,7 @@ function withArguments(cliArgs, fn) {
|
|
|
93
67
|
if (cliArgs[0].endsWith("node"))
|
|
94
68
|
cliArgs.shift();
|
|
95
69
|
const script = cliArgs.shift();
|
|
96
|
-
const parsedArgs = (
|
|
70
|
+
const parsedArgs = yargs(cliArgs).option("projectDir", {
|
|
97
71
|
alias: "p",
|
|
98
72
|
type: "string",
|
|
99
73
|
requiresArg: true
|
|
@@ -126,7 +100,7 @@ async function run(projectDir, prefix, cmd) {
|
|
|
126
100
|
const taqDir = await checkTaqProject(projectDir);
|
|
127
101
|
const config = await getEncodedConfig(taqDir, prefix);
|
|
128
102
|
const cmdWithEnvVars = toCommandWithEnvVars(cmd, config);
|
|
129
|
-
|
|
103
|
+
spawn(cmdWithEnvVars, {
|
|
130
104
|
shell: true,
|
|
131
105
|
stdio: "inherit"
|
|
132
106
|
});
|
package/bin/run.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["run.ts","../lib/env.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { spawn } from 'cross-spawn';\nimport path from 'path';\nimport yargs from 'yargs';\nimport { checkTaqProject, getEncodedConfig, isCustomError } from '../lib/env';\n\nfunction withArguments(cliArgs: string[], fn: (projectDir: string, prefix: string, cmd: string) => Promise<void>) {\n\tif (cliArgs[0].endsWith('node')) cliArgs.shift();\n\n\tconst script = cliArgs.shift();\n\n\tconst parsedArgs = yargs(cliArgs)\n\t\t.option('projectDir', {\n\t\t\talias: 'p',\n\t\t\ttype: 'string',\n\t\t\trequiresArg: true,\n\t\t})\n\t\t.option('prefix', {\n\t\t\ttype: 'string',\n\t\t\trequiresArg: true,\n\t\t\tdefault: '',\n\t\t})\n\t\t.global(['projectDir'])\n\t\t.parseSync();\n\n\tif (parsedArgs._.length > 0 && parsedArgs.projectDir) {\n\t\tfn(parsedArgs.projectDir, parsedArgs.prefix, parsedArgs._.join(' '));\n\t} else console.log(`Usage: ${script} --projectDir <projectDir> [--prefix <prefix>] <command>`);\n}\n\nfunction toCommandWithEnvVars(cmd: string, config: Record<string, string>) {\n\treturn Object.entries(config).reduce(\n\t\t(retval, [key, value]) => {\n\t\t\ttry {\n\t\t\t\treturn `${key}=${value} ${retval}`;\n\t\t\t} catch (err) {\n\t\t\t\tconsole.warn(`Could not set ${key}`);\n\t\t\t\tconsole.warn('Check the contents of the associated file and ensure that it can be Base64 encoded.');\n\t\t\t\treturn retval;\n\t\t\t}\n\t\t},\n\t\tcmd,\n\t);\n}\n\nasync function run(projectDir: string, prefix: string, cmd: string) {\n\ttry {\n\t\tconst taqDir = await checkTaqProject(projectDir);\n\t\tconst config = await getEncodedConfig(taqDir, prefix);\n\t\tconst cmdWithEnvVars = toCommandWithEnvVars(cmd, config);\n\n\t\tspawn(cmdWithEnvVars, {\n\t\t\tshell: true,\n\t\t\tstdio: 'inherit',\n\t\t});\n\t} catch (err) {\n\t\tif (isCustomError(err)) {\n\t\t\tconsole.error(err.message);\n\t\t\treturn;\n\t\t}\n\t\tthrow err;\n\t}\n}\n\nwithArguments(process.argv, run);\n","import { readdir, readFile, stat } from 'fs/promises';\nimport path from 'path';\n\nclass CustomErr extends Error {}\n\nexport class TaqNotFoundError extends CustomErr {\n\tpublic isCustomErr = true;\n}\n\nexport function isCustomError(err: unknown): err is Error {\n\treturn typeof err === 'object' && (err as object).hasOwnProperty('isCustomErr');\n}\n\nexport async function checkTaqProject(dir: string) {\n\ttry {\n\t\tconst searchPath = path.join(dir, '.taq');\n\t\tawait stat(searchPath);\n\t\treturn searchPath;\n\t} catch {\n\t\tthrow new TaqNotFoundError(`${dir} is not a valid Taqueria project.`);\n\t}\n}\n\nfunction getEnvName(filename: string, prefix = '') {\n\treturn `${prefix}TAQ_${filename}`\n\t\t.replace('.json', '')\n\t\t.replace(/\\./mg, '_')\n\t\t.replace(/\\-/mg, '_')\n\t\t.toUpperCase();\n}\n\nexport class TaqConfigError extends CustomErr {}\nexport async function getConfig(taqDir: string, prefix: string) {\n\ttry {\n\t\tconst files = await readdir(taqDir);\n\t\treturn files.reduce(\n\t\t\tasync (retval, file) => {\n\t\t\t\tif (!file.endsWith('.json')) return (await retval);\n\t\t\t\treturn {\n\t\t\t\t\t...(await retval),\n\t\t\t\t\t[getEnvName(file, prefix)]: await readFile(path.join(taqDir, file), 'utf-8'),\n\t\t\t\t};\n\t\t\t},\n\t\t\tPromise.resolve({}),\n\t\t);\n\t} catch {\n\t\tthrow new TaqConfigError(\n\t\t\t`There was a problem reading the config files in ${taqDir}. Please check file permissions are try again.`,\n\t\t);\n\t}\n}\n\nexport function encode(value: string) {\n\tconst buffer = Buffer.from(value, 'utf8');\n\treturn buffer.toString('base64');\n}\n\nexport async function getEncodedConfig(taqDir: string, prefix: string) {\n\tconst config = await getConfig(taqDir, prefix);\n\treturn Object.fromEntries(\n\t\tObject.entries(config).map(\n\t\t\t([k, v]) => [k, encode(v as string)],\n\t\t),\n\t);\n}\n\nexport async function getEnv(env: typeof process.env, taqDir: string, prefix: string = '') {\n\tconst realTaqDir = await checkTaqProject(taqDir);\n\treturn {\n\t\t...env,\n\t\t...await getEncodedConfig(realTaqDir, prefix),\n\t};\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["run.ts","../lib/env.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { spawn } from 'cross-spawn';\nimport path from 'path';\nimport yargs from 'yargs';\nimport { checkTaqProject, getEncodedConfig, isCustomError } from '../lib/env';\n\nfunction withArguments(cliArgs: string[], fn: (projectDir: string, prefix: string, cmd: string) => Promise<void>) {\n\tif (cliArgs[0].endsWith('node')) cliArgs.shift();\n\n\tconst script = cliArgs.shift();\n\n\tconst parsedArgs = yargs(cliArgs)\n\t\t.option('projectDir', {\n\t\t\talias: 'p',\n\t\t\ttype: 'string',\n\t\t\trequiresArg: true,\n\t\t})\n\t\t.option('prefix', {\n\t\t\ttype: 'string',\n\t\t\trequiresArg: true,\n\t\t\tdefault: '',\n\t\t})\n\t\t.global(['projectDir'])\n\t\t.parseSync();\n\n\tif (parsedArgs._.length > 0 && parsedArgs.projectDir) {\n\t\tfn(parsedArgs.projectDir, parsedArgs.prefix, parsedArgs._.join(' '));\n\t} else console.log(`Usage: ${script} --projectDir <projectDir> [--prefix <prefix>] <command>`);\n}\n\nfunction toCommandWithEnvVars(cmd: string, config: Record<string, string>) {\n\treturn Object.entries(config).reduce(\n\t\t(retval, [key, value]) => {\n\t\t\ttry {\n\t\t\t\treturn `${key}=${value} ${retval}`;\n\t\t\t} catch (err) {\n\t\t\t\tconsole.warn(`Could not set ${key}`);\n\t\t\t\tconsole.warn('Check the contents of the associated file and ensure that it can be Base64 encoded.');\n\t\t\t\treturn retval;\n\t\t\t}\n\t\t},\n\t\tcmd,\n\t);\n}\n\nasync function run(projectDir: string, prefix: string, cmd: string) {\n\ttry {\n\t\tconst taqDir = await checkTaqProject(projectDir);\n\t\tconst config = await getEncodedConfig(taqDir, prefix);\n\t\tconst cmdWithEnvVars = toCommandWithEnvVars(cmd, config);\n\n\t\tspawn(cmdWithEnvVars, {\n\t\t\tshell: true,\n\t\t\tstdio: 'inherit',\n\t\t});\n\t} catch (err) {\n\t\tif (isCustomError(err)) {\n\t\t\tconsole.error(err.message);\n\t\t\treturn;\n\t\t}\n\t\tthrow err;\n\t}\n}\n\nwithArguments(process.argv, run);\n","import { readdir, readFile, stat } from 'fs/promises';\nimport path from 'path';\n\nclass CustomErr extends Error {}\n\nexport class TaqNotFoundError extends CustomErr {\n\tpublic isCustomErr = true;\n}\n\nexport function isCustomError(err: unknown): err is Error {\n\treturn typeof err === 'object' && (err as object).hasOwnProperty('isCustomErr');\n}\n\nexport async function checkTaqProject(dir: string) {\n\ttry {\n\t\tconst searchPath = path.join(dir, '.taq');\n\t\tawait stat(searchPath);\n\t\treturn searchPath;\n\t} catch {\n\t\tthrow new TaqNotFoundError(`${dir} is not a valid Taqueria project.`);\n\t}\n}\n\nfunction getEnvName(filename: string, prefix = '') {\n\treturn `${prefix}TAQ_${filename}`\n\t\t.replace('.json', '')\n\t\t.replace(/\\./mg, '_')\n\t\t.replace(/\\-/mg, '_')\n\t\t.toUpperCase();\n}\n\nexport class TaqConfigError extends CustomErr {}\nexport async function getConfig(taqDir: string, prefix: string) {\n\ttry {\n\t\tconst files = await readdir(taqDir);\n\t\treturn files.reduce(\n\t\t\tasync (retval, file) => {\n\t\t\t\tif (!file.endsWith('.json')) return (await retval);\n\t\t\t\treturn {\n\t\t\t\t\t...(await retval),\n\t\t\t\t\t[getEnvName(file, prefix)]: await readFile(path.join(taqDir, file), 'utf-8'),\n\t\t\t\t};\n\t\t\t},\n\t\t\tPromise.resolve({}),\n\t\t);\n\t} catch {\n\t\tthrow new TaqConfigError(\n\t\t\t`There was a problem reading the config files in ${taqDir}. Please check file permissions are try again.`,\n\t\t);\n\t}\n}\n\nexport function encode(value: string) {\n\tconst buffer = Buffer.from(value, 'utf8');\n\treturn buffer.toString('base64');\n}\n\nexport async function getEncodedConfig(taqDir: string, prefix: string) {\n\tconst config = await getConfig(taqDir, prefix);\n\treturn Object.fromEntries(\n\t\tObject.entries(config).map(\n\t\t\t([k, v]) => [k, encode(v as string)],\n\t\t),\n\t);\n}\n\nexport async function getEnv(env: typeof process.env, taqDir: string, prefix: string = '') {\n\tconst realTaqDir = await checkTaqProject(taqDir);\n\treturn {\n\t\t...env,\n\t\t...await getEncodedConfig(realTaqDir, prefix),\n\t};\n}\n"],"mappings":";;;AACA,SAAS,aAAa;AAEtB,OAAO,WAAW;;;ACHlB,SAAS,SAAS,UAAU,YAAY;AACxC,OAAO,UAAU;AAEjB,IAAM,YAAN,cAAwB,MAAM;AAAC;AAExB,IAAM,mBAAN,cAA+B,UAAU;AAAA,EACxC,cAAc;AACtB;AAEO,SAAS,cAAc,KAA4B;AACzD,SAAO,OAAO,QAAQ,YAAa,IAAe,eAAe,aAAa;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AAA,IACD;AACA,UAAM;AAAA,EACP;AACD;AAEA,cAAc,QAAQ,MAAM,GAAG;","names":[]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__export
|
|
3
|
+
} from "./chunk-SSYGV25P.js";
|
|
4
|
+
|
|
5
|
+
// v2.ts
|
|
6
|
+
var v2_exports = {};
|
|
7
|
+
__export(v2_exports, {
|
|
8
|
+
getContractAddress: () => getContractAddress,
|
|
9
|
+
getCurrentEnv: () => getCurrentEnv,
|
|
10
|
+
getEnv: () => getEnv
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
// TaqError.ts
|
|
14
|
+
var TaqError = class extends Error {
|
|
15
|
+
isTaqError = true;
|
|
16
|
+
};
|
|
17
|
+
var isTaqError = (err) => typeof err === "object" && err.hasOwnProperty("isTaqError");
|
|
18
|
+
|
|
19
|
+
// v2.ts
|
|
20
|
+
function getEnv(envName, settings) {
|
|
21
|
+
const mainEnv = settings.config.environments?.[envName];
|
|
22
|
+
if (mainEnv) {
|
|
23
|
+
return {
|
|
24
|
+
...mainEnv,
|
|
25
|
+
...settings.environments[envName]
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
throw new TaqError(`There is no environment configured called ${envName}`);
|
|
29
|
+
}
|
|
30
|
+
var getCurrentEnv = (settings) => {
|
|
31
|
+
if (settings.config.environmentDefault) {
|
|
32
|
+
return getEnv(settings.config.environmentDefault, settings);
|
|
33
|
+
}
|
|
34
|
+
throw new TaqError(
|
|
35
|
+
`No default environment has been configured. Please set the "environmentDefault" property in your .taq/config.json.`
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
function getContractAddress(contractName, env) {
|
|
39
|
+
return env.contracts?.[contractName]?.address;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export {
|
|
43
|
+
TaqError,
|
|
44
|
+
isTaqError,
|
|
45
|
+
getEnv,
|
|
46
|
+
getCurrentEnv,
|
|
47
|
+
getContractAddress,
|
|
48
|
+
v2_exports
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=chunk-BGUG3ZS5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["v2.ts","TaqError.ts"],"sourcesContent":["// TODO: Write a comprehensive API for V2\nimport * as ConfigEnvironmentFileV2 from '@taqueria/protocol/ConfigEnvironmentFileV2';\nimport * as Config from '@taqueria/protocol/ConfigFileV2';\nimport { ConfigFileSetV2 } from '@taqueria/protocol/types-config-files';\nimport { isTaqError, TaqError } from './TaqError';\n\ntype ExpandedEnv = Record<string, unknown> & ConfigEnvironmentFileV2.t & { __type: 'expandedEnv' };\nexport function getEnv(envName: string, settings: ConfigFileSetV2): ExpandedEnv {\n\tconst mainEnv = settings.config.environments?.[envName];\n\tif (mainEnv) {\n\t\treturn {\n\t\t\t...mainEnv,\n\t\t\t...settings.environments[envName],\n\t\t} as ExpandedEnv;\n\t}\n\tthrow new TaqError(`There is no environment configured called ${envName}`);\n}\n\nexport const getCurrentEnv = (settings: ConfigFileSetV2) => {\n\tif (settings.config.environmentDefault) {\n\t\treturn getEnv(settings.config.environmentDefault, settings);\n\t}\n\tthrow new TaqError(\n\t\t`No default environment has been configured. Please set the \"environmentDefault\" property in your .taq/config.json.`,\n\t);\n};\n\nexport function getContractAddress(contractName: string, env: ExpandedEnv) {\n\treturn env.contracts?.[contractName]?.address;\n}\n","export class TaqError extends Error {\n\tpublic isTaqError = true;\n}\nexport const isTaqError = (err: unknown): err is TaqError =>\n\ttypeof err === 'object' && (err as object).hasOwnProperty('isTaqError');\n"],"mappings":";;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,WAAN,cAAuB,MAAM;AAAA,EAC5B,aAAa;AACrB;AACO,IAAM,aAAa,CAAC,QAC1B,OAAO,QAAQ,YAAa,IAAe,eAAe,YAAY;;;ADGhE,SAAS,OAAO,SAAiB,UAAwC;AAC/E,QAAM,UAAU,SAAS,OAAO,eAAe,OAAO;AACtD,MAAI,SAAS;AACZ,WAAO;AAAA,MACN,GAAG;AAAA,MACH,GAAG,SAAS,aAAa,OAAO;AAAA,IACjC;AAAA,EACD;AACA,QAAM,IAAI,SAAS,6CAA6C,OAAO,EAAE;AAC1E;AAEO,IAAM,gBAAgB,CAAC,aAA8B;AAC3D,MAAI,SAAS,OAAO,oBAAoB;AACvC,WAAO,OAAO,SAAS,OAAO,oBAAoB,QAAQ;AAAA,EAC3D;AACA,QAAM,IAAI;AAAA,IACT;AAAA,EACD;AACD;AAEO,SAAS,mBAAmB,cAAsB,KAAkB;AAC1E,SAAO,IAAI,YAAY,YAAY,GAAG;AACvC;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// v1.ts
|
|
2
|
+
var getCurrentEnv = (config) => {
|
|
3
|
+
const currentEnv = config?.environment?.default ? config.environment.default : "development";
|
|
4
|
+
return config.environment && config.environment[currentEnv] ? config.environment[currentEnv] : void 0;
|
|
5
|
+
};
|
|
6
|
+
var getAliasAddress = (config, alias) => {
|
|
7
|
+
const currentEnv = getCurrentEnv(config);
|
|
8
|
+
if (currentEnv?.aliases?.[alias]?.address)
|
|
9
|
+
return currentEnv.aliases[alias].address;
|
|
10
|
+
alert(`Address for alias, ${alias}, is missing. Please deploy a contract with such alias`);
|
|
11
|
+
return "";
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
getCurrentEnv,
|
|
16
|
+
getAliasAddress
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=chunk-UWGPOHCN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["v1.ts"],"sourcesContent":["import * as Config from '@taqueria/protocol/Config';\nimport * as Environment from '@taqueria/protocol/Environment';\n\nexport const getCurrentEnv = (config: Config.t): Environment.t | undefined => {\n\tconst currentEnv = config?.environment?.default ? config.environment.default as string : 'development';\n\treturn config.environment && config.environment[currentEnv]\n\t\t? config.environment[currentEnv] as Environment.t | undefined\n\t\t: undefined;\n};\n\nexport const getAliasAddress = (config: any, alias: string): string => {\n\tconst currentEnv = getCurrentEnv(config);\n\tif (currentEnv?.aliases?.[alias]?.address) return currentEnv.aliases[alias].address;\n\talert(`Address for alias, ${alias}, is missing. Please deploy a contract with such alias`);\n\treturn '';\n};\n"],"mappings":";AAGO,IAAM,gBAAgB,CAAC,WAAgD;AAC7E,QAAM,aAAa,QAAQ,aAAa,UAAU,OAAO,YAAY,UAAoB;AACzF,SAAO,OAAO,eAAe,OAAO,YAAY,UAAU,IACvD,OAAO,YAAY,UAAU,IAC7B;AACJ;AAEO,IAAM,kBAAkB,CAAC,QAAa,UAA0B;AACtE,QAAM,aAAa,cAAc,MAAM;AACvC,MAAI,YAAY,UAAU,KAAK,GAAG;AAAS,WAAO,WAAW,QAAQ,KAAK,EAAE;AAC5E,QAAM,sBAAsB,KAAK,wDAAwD;AACzF,SAAO;AACR;","names":[]}
|
package/index.js
CHANGED
|
@@ -1,106 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from4, except, desc) => {
|
|
13
|
-
if (from4 && typeof from4 === "object" || typeof from4 === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from4))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from4[key], enumerable: !(desc = __getOwnPropDesc(from4, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
import {
|
|
2
|
+
getAliasAddress,
|
|
3
|
+
getCurrentEnv
|
|
4
|
+
} from "./chunk-UWGPOHCN.js";
|
|
5
|
+
import {
|
|
6
|
+
TaqError,
|
|
7
|
+
isTaqError,
|
|
8
|
+
v2_exports
|
|
9
|
+
} from "./chunk-BGUG3ZS5.js";
|
|
10
|
+
import "./chunk-SSYGV25P.js";
|
|
29
11
|
|
|
30
12
|
// index.ts
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
V2: () => v2_exports,
|
|
36
|
-
getAliasAddress: () => getAliasAddress2,
|
|
37
|
-
getConfigAsV1: () => getConfigAsV1,
|
|
38
|
-
getConfigV2: () => getConfigV2,
|
|
39
|
-
getCurrentEnv: () => getCurrentEnv3,
|
|
40
|
-
isTaqError: () => isTaqError
|
|
41
|
-
});
|
|
42
|
-
module.exports = __toCommonJS(taqueria_toolkit_exports);
|
|
43
|
-
var Config = __toESM(require("@taqueria/protocol/Config"));
|
|
44
|
-
var ConfigEnvironmentFileV2 = __toESM(require("@taqueria/protocol/ConfigEnvironmentFileV2"));
|
|
45
|
-
var ConfigFileV2 = __toESM(require("@taqueria/protocol/ConfigFileV2"));
|
|
46
|
-
|
|
47
|
-
// TaqError.ts
|
|
48
|
-
var TaqError = class extends Error {
|
|
49
|
-
constructor() {
|
|
50
|
-
super(...arguments);
|
|
51
|
-
this.isTaqError = true;
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
var isTaqError = (err) => typeof err === "object" && err.hasOwnProperty("isTaqError");
|
|
55
|
-
|
|
56
|
-
// v1.ts
|
|
57
|
-
var getCurrentEnv = (config) => {
|
|
58
|
-
var _a;
|
|
59
|
-
const currentEnv = ((_a = config == null ? void 0 : config.environment) == null ? void 0 : _a.default) ? config.environment.default : "development";
|
|
60
|
-
return config.environment && config.environment[currentEnv] ? config.environment[currentEnv] : void 0;
|
|
61
|
-
};
|
|
62
|
-
var getAliasAddress = (config, alias) => {
|
|
63
|
-
var _a, _b;
|
|
64
|
-
const currentEnv = getCurrentEnv(config);
|
|
65
|
-
if ((_b = (_a = currentEnv == null ? void 0 : currentEnv.aliases) == null ? void 0 : _a[alias]) == null ? void 0 : _b.address)
|
|
66
|
-
return currentEnv.aliases[alias].address;
|
|
67
|
-
alert(`Address for alias, ${alias}, is missing. Please deploy a contract with such alias`);
|
|
68
|
-
return "";
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
// v2.ts
|
|
72
|
-
var v2_exports = {};
|
|
73
|
-
__export(v2_exports, {
|
|
74
|
-
getContractAddress: () => getContractAddress,
|
|
75
|
-
getCurrentEnv: () => getCurrentEnv2,
|
|
76
|
-
getEnv: () => getEnv
|
|
77
|
-
});
|
|
78
|
-
function getEnv(envName, settings) {
|
|
79
|
-
var _a;
|
|
80
|
-
const mainEnv = (_a = settings.config.environments) == null ? void 0 : _a[envName];
|
|
81
|
-
if (mainEnv) {
|
|
82
|
-
return {
|
|
83
|
-
...mainEnv,
|
|
84
|
-
...settings.environments[envName]
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
throw new TaqError(`There is no environment configured called ${envName}`);
|
|
88
|
-
}
|
|
89
|
-
var getCurrentEnv2 = (settings) => {
|
|
90
|
-
if (settings.config.environmentDefault) {
|
|
91
|
-
return getEnv(settings.config.environmentDefault, settings);
|
|
92
|
-
}
|
|
93
|
-
throw new TaqError(
|
|
94
|
-
`No default environment has been configured. Please set the "environmentDefault" property in your .taq/config.json.`
|
|
95
|
-
);
|
|
96
|
-
};
|
|
97
|
-
function getContractAddress(contractName, env) {
|
|
98
|
-
var _a, _b;
|
|
99
|
-
return (_b = (_a = env.contracts) == null ? void 0 : _a[contractName]) == null ? void 0 : _b.address;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// index.ts
|
|
103
|
-
var transform = __toESM(require("@taqueria/protocol/types-config-files"));
|
|
13
|
+
import * as Config from "@taqueria/protocol/Config";
|
|
14
|
+
import * as ConfigEnvironmentFileV2 from "@taqueria/protocol/ConfigEnvironmentFileV2";
|
|
15
|
+
import * as ConfigFileV2 from "@taqueria/protocol/ConfigFileV2";
|
|
16
|
+
import * as transform from "@taqueria/protocol/types-config-files";
|
|
104
17
|
var DEFAULT_ENV_VAR_PREFIX = "";
|
|
105
18
|
function withFixedEnv(env) {
|
|
106
19
|
return Object.entries(env).reduce(
|
|
@@ -133,7 +46,7 @@ function withEnv(env, prefix = DEFAULT_ENV_VAR_PREFIX) {
|
|
|
133
46
|
const decoded = decode(data);
|
|
134
47
|
const rawConfig = JSON.parse(decoded);
|
|
135
48
|
return rawConfig;
|
|
136
|
-
} catch
|
|
49
|
+
} catch {
|
|
137
50
|
throw new TaqError(
|
|
138
51
|
`Could not parse the config. Please ensure that the environment variable called ${key} is defined and set to the value of your config.json file using Base64 encoding.`
|
|
139
52
|
);
|
|
@@ -150,7 +63,7 @@ function withEnv(env, prefix = DEFAULT_ENV_VAR_PREFIX) {
|
|
|
150
63
|
const decoded = decode(data);
|
|
151
64
|
const rawConfig = JSON.parse(decoded);
|
|
152
65
|
return ConfigEnvironmentFileV2.from(rawConfig);
|
|
153
|
-
} catch
|
|
66
|
+
} catch {
|
|
154
67
|
throw new TaqError(
|
|
155
68
|
`Could not parse environment config for an environment called ${environmentName}. Please ensure that the environment variable called ${key} is defined and set to the value of your config.json file using Base64 encoding.`
|
|
156
69
|
);
|
|
@@ -164,7 +77,6 @@ function withEnv(env, prefix = DEFAULT_ENV_VAR_PREFIX) {
|
|
|
164
77
|
};
|
|
165
78
|
}
|
|
166
79
|
var getConfigAsV1 = (env, prefix = DEFAULT_ENV_VAR_PREFIX) => {
|
|
167
|
-
var _a;
|
|
168
80
|
const { getRawConfig, getEnvironmentConfig } = withEnv(withFixedEnv(env), prefix);
|
|
169
81
|
const rawConfig = getRawConfig();
|
|
170
82
|
try {
|
|
@@ -172,7 +84,7 @@ var getConfigAsV1 = (env, prefix = DEFAULT_ENV_VAR_PREFIX) => {
|
|
|
172
84
|
return Config.from(rawConfig);
|
|
173
85
|
else if (rawConfig.version.toLowerCase() === "v2") {
|
|
174
86
|
const config = ConfigFileV2.from(rawConfig);
|
|
175
|
-
const environments = Object.keys(
|
|
87
|
+
const environments = Object.keys(config.environments ?? {}).reduce(
|
|
176
88
|
(retval, envName) => ({
|
|
177
89
|
...retval,
|
|
178
90
|
[envName]: getEnvironmentConfig(envName)
|
|
@@ -192,7 +104,6 @@ var getConfigAsV1 = (env, prefix = DEFAULT_ENV_VAR_PREFIX) => {
|
|
|
192
104
|
}
|
|
193
105
|
};
|
|
194
106
|
function getConfigV2(env, prefix = DEFAULT_ENV_VAR_PREFIX) {
|
|
195
|
-
var _a;
|
|
196
107
|
const { getRawConfig, getEnvironmentConfig } = withEnv(withFixedEnv(env), prefix);
|
|
197
108
|
const rawConfig = getRawConfig();
|
|
198
109
|
try {
|
|
@@ -201,7 +112,7 @@ function getConfigV2(env, prefix = DEFAULT_ENV_VAR_PREFIX) {
|
|
|
201
112
|
return transform.transformConfigToConfigFileV2(configV1);
|
|
202
113
|
} else if (rawConfig.version.toLowerCase() === "v2") {
|
|
203
114
|
const configV2 = ConfigFileV2.from(rawConfig);
|
|
204
|
-
const environments = Object.keys(
|
|
115
|
+
const environments = Object.keys(configV2.environments ?? {}).reduce(
|
|
205
116
|
(retval2, envName) => ({ ...retval2, [envName]: getEnvironmentConfig(envName) }),
|
|
206
117
|
{}
|
|
207
118
|
);
|
|
@@ -219,5 +130,15 @@ function getConfigV2(env, prefix = DEFAULT_ENV_VAR_PREFIX) {
|
|
|
219
130
|
}
|
|
220
131
|
}
|
|
221
132
|
var getAliasAddress2 = getAliasAddress;
|
|
222
|
-
var
|
|
133
|
+
var getCurrentEnv2 = getCurrentEnv;
|
|
134
|
+
export {
|
|
135
|
+
Config,
|
|
136
|
+
TaqError,
|
|
137
|
+
v2_exports as V2,
|
|
138
|
+
getAliasAddress2 as getAliasAddress,
|
|
139
|
+
getConfigAsV1,
|
|
140
|
+
getConfigV2,
|
|
141
|
+
getCurrentEnv2 as getCurrentEnv,
|
|
142
|
+
isTaqError
|
|
143
|
+
};
|
|
223
144
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts","TaqError.ts","v1.ts","v2.ts"],"sourcesContent":["import * as Config from '@taqueria/protocol/Config';\nimport * as ConfigEnvironmentFileV2 from '@taqueria/protocol/ConfigEnvironmentFileV2';\nimport * as ConfigFileV2 from '@taqueria/protocol/ConfigFileV2';\nimport { isTaqError, TaqError } from './TaqError';\nexport { isTaqError, TaqError } from './TaqError';\nimport * as V1 from './v1';\nexport * as V2 from './v2';\nimport * as transform from '@taqueria/protocol/types-config-files';\n\nconst DEFAULT_ENV_VAR_PREFIX = '';\n\nfunction withFixedEnv(env: Record<string, string | undefined>) {\n\treturn Object.entries(env).reduce(\n\t\t(acc, [key, value]) => {\n\t\t\tif (key.startsWith('VITE_')) {\n\t\t\t\tconst newKey = key.replace('VITE_', '');\n\t\t\t\tacc[newKey] = value;\n\t\t\t}\n\t\t\tacc[key] = value;\n\t\t\treturn acc;\n\t\t},\n\t\t{} as Record<string, string | undefined>,\n\t);\n}\n\nfunction withEnv(env: Record<string, string | undefined>, prefix = DEFAULT_ENV_VAR_PREFIX) {\n\tconst getConfigEnvKey = () => `${prefix}TAQ_CONFIG`;\n\n\tconst decode = (value: string) => {\n\t\tconst buffer = Buffer.from(value, 'base64');\n\t\treturn buffer.toString('utf8');\n\t};\n\n\tconst getRawConfig = () => {\n\t\tconst key = getConfigEnvKey();\n\t\tconst data = env[key];\n\t\tif (!data) {\n\t\t\tthrow new TaqError(\n\t\t\t\t`Could not find config. Please ensure that the environment variable called ${key} is defined and set to the value of your config.json file using Base64 encoding.`,\n\t\t\t);\n\t\t}\n\t\ttry {\n\t\t\tconst decoded = decode(data);\n\t\t\tconst rawConfig = JSON.parse(decoded);\n\t\t\treturn rawConfig;\n\t\t} catch {\n\t\t\tthrow new TaqError(\n\t\t\t\t`Could not parse the config. Please ensure that the environment variable called ${key} is defined and set to the value of your config.json file using Base64 encoding.`,\n\t\t\t);\n\t\t}\n\t};\n\n\tconst getEnvironmentConfigKey = (environmentName: string) =>\n\t\t`${prefix}TAQ_CONFIG_LOCAL_${environmentName.toUpperCase()}`;\n\n\tconst getEnvironmentConfig = (environmentName: string) => {\n\t\tconst key = getEnvironmentConfigKey(environmentName);\n\t\tconst data = env[key];\n\t\tif (!data) {\n\t\t\treturn ConfigEnvironmentFileV2.from({});\n\t\t}\n\t\ttry {\n\t\t\tconst decoded = decode(data);\n\t\t\tconst rawConfig = JSON.parse(decoded);\n\t\t\treturn ConfigEnvironmentFileV2.from(rawConfig);\n\t\t} catch {\n\t\t\tthrow new TaqError(\n\t\t\t\t`Could not parse environment config for an environment called ${environmentName}. Please ensure that the environment variable called ${key} is defined and set to the value of your config.json file using Base64 encoding.`,\n\t\t\t);\n\t\t}\n\t};\n\n\treturn {\n\t\tgetConfigEnvKey,\n\t\tgetRawConfig,\n\t\tgetEnvironmentConfigKey,\n\t\tgetEnvironmentConfig,\n\t};\n}\n\nexport const getConfigAsV1 = (env: Record<string, string | undefined>, prefix = DEFAULT_ENV_VAR_PREFIX): Config.t => {\n\tconst { getRawConfig, getEnvironmentConfig } = withEnv(withFixedEnv(env), prefix);\n\n\tconst rawConfig = getRawConfig();\n\n\ttry {\n\t\t// If version v1, return the config object\n\t\tif (!rawConfig.version || rawConfig.version.toLowerCase() === 'v1') return Config.from(rawConfig);\n\t\t// If version v2, transform to V1 and return that\n\t\telse if (rawConfig.version.toLowerCase() === 'v2') {\n\t\t\tconst config = ConfigFileV2.from(rawConfig);\n\t\t\tconst environments = Object.keys(config.environments ?? {}).reduce(\n\t\t\t\t(retval, envName) => ({\n\t\t\t\t\t...retval,\n\t\t\t\t\t[envName]: getEnvironmentConfig(envName),\n\t\t\t\t}),\n\t\t\t\t{},\n\t\t\t);\n\n\t\t\treturn Config.create(transform.transformConfigFileV2ToConfig({\n\t\t\t\tconfig,\n\t\t\t\tenvironments,\n\t\t\t}));\n\t\t}\n\n\t\t// Other version handlers go here\n\t\tthrow new TaqError(`The version of your configuration is not yet supported.`);\n\t} catch (err) {\n\t\tthrow isTaqError(err)\n\t\t\t? err\n\t\t\t: new TaqError(\n\t\t\t\t`Something went wrong trying to parse your configuration. Please report this to the Taqueria Developers: ${err}`,\n\t\t\t);\n\t}\n};\n\nexport function getConfigV2(\n\tenv: Record<string, string | undefined>,\n\tprefix = DEFAULT_ENV_VAR_PREFIX,\n): transform.ConfigFileSetV2 {\n\tconst { getRawConfig, getEnvironmentConfig } = withEnv(withFixedEnv(env), prefix);\n\n\tconst rawConfig = getRawConfig();\n\n\ttry {\n\t\t// If version v1, return the config object\n\t\tif (!rawConfig.version || rawConfig.version.toLowerCase() === 'v1') {\n\t\t\tconst configV1 = Config.from(rawConfig);\n\t\t\treturn transform.transformConfigToConfigFileV2(configV1);\n\t\t} else if (rawConfig.version.toLowerCase() === 'v2') {\n\t\t\tconst configV2 = ConfigFileV2.from(rawConfig);\n\t\t\tconst environments = Object.keys(configV2.environments ?? {}).reduce(\n\t\t\t\t(retval, envName) => ({ ...retval, [envName]: getEnvironmentConfig(envName) }),\n\t\t\t\t{},\n\t\t\t);\n\t\t\tconst retval: transform.ConfigFileSetV2 = {\n\t\t\t\tconfig: configV2,\n\t\t\t\tenvironments,\n\t\t\t};\n\n\t\t\treturn retval;\n\t\t}\n\t\t// Other version handlers go here\n\t\t// No other versions we're aware of.\n\t\tthrow new TaqError(`The version of your configuration is not yet supported.`);\n\t} catch (err) {\n\t\tthrow isTaqError(err)\n\t\t\t? err\n\t\t\t: new TaqError(\n\t\t\t\t`Something went wrong trying to parse your configuration. Please report this to the Taqueria Developers: ${err}`,\n\t\t\t);\n\t}\n}\n\n// Backwards compatibility\n// Before introducing V1, the toolkit just exported these two functions\nconst getAliasAddress = V1.getAliasAddress;\nconst getCurrentEnv = V1.getCurrentEnv;\nexport { Config, getAliasAddress, getCurrentEnv };\n\n// New exports as of V2\nexport type ConfigFileSetV2 = transform.ConfigFileSetV2;\n","export class TaqError extends Error {\n\tpublic isTaqError = true;\n}\nexport const isTaqError = (err: unknown): err is TaqError =>\n\ttypeof err === 'object' && (err as object).hasOwnProperty('isTaqError');\n","import * as Config from '@taqueria/protocol/Config';\nimport * as Environment from '@taqueria/protocol/Environment';\n\nexport const getCurrentEnv = (config: Config.t): Environment.t | undefined => {\n\tconst currentEnv = config?.environment?.default ? config.environment.default as string : 'development';\n\treturn config.environment && config.environment[currentEnv]\n\t\t? config.environment[currentEnv] as Environment.t | undefined\n\t\t: undefined;\n};\n\nexport const getAliasAddress = (config: any, alias: string): string => {\n\tconst currentEnv = getCurrentEnv(config);\n\tif (currentEnv?.aliases?.[alias]?.address) return currentEnv.aliases[alias].address;\n\talert(`Address for alias, ${alias}, is missing. Please deploy a contract with such alias`);\n\treturn '';\n};\n","// TODO: Write a comprehensive API for V2\nimport * as ConfigEnvironmentFileV2 from '@taqueria/protocol/ConfigEnvironmentFileV2';\nimport * as Config from '@taqueria/protocol/ConfigFileV2';\nimport { ConfigFileSetV2 } from '@taqueria/protocol/types-config-files';\nimport { isTaqError, TaqError } from './TaqError';\n\ntype ExpandedEnv = Record<string, unknown> & ConfigEnvironmentFileV2.t & { __type: 'expandedEnv' };\nexport function getEnv(envName: string, settings: ConfigFileSetV2): ExpandedEnv {\n\tconst mainEnv = settings.config.environments?.[envName];\n\tif (mainEnv) {\n\t\treturn {\n\t\t\t...mainEnv,\n\t\t\t...settings.environments[envName],\n\t\t} as ExpandedEnv;\n\t}\n\tthrow new TaqError(`There is no environment configured called ${envName}`);\n}\n\nexport const getCurrentEnv = (settings: ConfigFileSetV2) => {\n\tif (settings.config.environmentDefault) {\n\t\treturn getEnv(settings.config.environmentDefault, settings);\n\t}\n\tthrow new TaqError(\n\t\t`No default environment has been configured. Please set the \"environmentDefault\" property in your .taq/config.json.`,\n\t);\n};\n\nexport function getContractAddress(contractName: string, env: ExpandedEnv) {\n\treturn env.contracts?.[contractName]?.address;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAAA;AAAA,EAAA;AAAA;AAAA,uBAAAC;AAAA,EAAA;AAAA;AAAA;AAAA,aAAwB;AACxB,8BAAyC;AACzC,mBAA8B;;;ACFvB,IAAM,WAAN,cAAuB,MAAM;AAAA,EAA7B;AAAA;AACN,SAAO,aAAa;AAAA;AACrB;AACO,IAAM,aAAa,CAAC,QAC1B,OAAO,QAAQ,YAAa,IAAe,eAAe,YAAY;;;ACDhE,IAAM,gBAAgB,CAAC,WAAgD;AAH9E;AAIC,QAAM,eAAa,sCAAQ,gBAAR,mBAAqB,WAAU,OAAO,YAAY,UAAoB;AACzF,SAAO,OAAO,eAAe,OAAO,YAAY,UAAU,IACvD,OAAO,YAAY,UAAU,IAC7B;AACJ;AAEO,IAAM,kBAAkB,CAAC,QAAa,UAA0B;AAVvE;AAWC,QAAM,aAAa,cAAc,MAAM;AACvC,OAAI,oDAAY,YAAZ,mBAAsB,WAAtB,mBAA8B;AAAS,WAAO,WAAW,QAAQ,KAAK,EAAE;AAC5E,QAAM,sBAAsB,KAAK,wDAAwD;AACzF,SAAO;AACR;;;ACfA;AAAA;AAAA;AAAA,uBAAAC;AAAA,EAAA;AAAA;AAOO,SAAS,OAAO,SAAiB,UAAwC;AAPhF;AAQC,QAAM,WAAU,cAAS,OAAO,iBAAhB,mBAA+B;AAC/C,MAAI,SAA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IAAI,SAAS,yDAAyD;AAAA,EAC7E,SAAS,KAAK;AACb,UAAM,WAAW,GAAG,IACjB,MACA,IAAI;AAAA,MACL,2GAA2G,GAAG;AAAA,IAC/G;AAAA,EACF;AACD;AAEO,SAAS,YACf,KACA,SAAS,wBACmB;AAvH7B;AAwHC,QAAM,EAAE,cAAc,qBAAqB,IAAI,QAAQ,aAAa,GAAG,GAAG,MAAM;AAEhF,QAAM,YAAY,aAAa;AAE/B,MAAI;AAEH,QAAI,CAAC,UAAU,WAAW,UAAU,QAAQ,YAAY,MAAM,MAAM;AACnE,YAAM,WAAkB,YAAK,SAAS;AACtC,aAAiB,wCAA8B,QAAQ;AAAA,IACxD,WAAW,UAAU,QAAQ,YAAY,MAAM,MAAM;AACpD,YAAM,WAAwB,kBAAK,SAAS;AAC5C,YAAM,eAAe,OAAO,MAAK,cAAS,iBAAT,YAAyB,CAAC,CAAC,EAAE;AAAA,QAC7D,CAACC,SAAQ,aAAa,EAAE,GAAGA,SAAQ,CAAC,OAAO,GAAG,qBAAqB,OAAO,EAAE;AAAA,QAC5E,CAAC;AAAA,MACF;AACA,YAAM,SAAoC;AAAA,QACzC,QAAQ;AAAA,QACR;AAAA,MACD;AAEA,aAAO;AAAA,IACR;AAGA,UAAM,IAAI,SAAS,yDAAyD;AAAA,EAC7E,SAAS,KAAK;AACb,UAAM,WAAW,GAAG,IACjB,MACA,IAAI;AAAA,MACL,2GAA2G,GAAG;AAAA,IAC/G;AAAA,EACF;AACD;AAIA,IAAMC,mBAAqB;AAC3B,IAAMC,iBAAmB;","names":["getAliasAddress","getCurrentEnv","getCurrentEnv","getCurrentEnv","retval","getAliasAddress","getCurrentEnv"]}
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["import * as Config from '@taqueria/protocol/Config';\nimport * as ConfigEnvironmentFileV2 from '@taqueria/protocol/ConfigEnvironmentFileV2';\nimport * as ConfigFileV2 from '@taqueria/protocol/ConfigFileV2';\nimport { isTaqError, TaqError } from './TaqError';\nexport { isTaqError, TaqError } from './TaqError';\nimport * as V1 from './v1';\nexport * as V2 from './v2';\nimport * as transform from '@taqueria/protocol/types-config-files';\n\nconst DEFAULT_ENV_VAR_PREFIX = '';\n\nfunction withFixedEnv(env: Record<string, string | undefined>) {\n\treturn Object.entries(env).reduce(\n\t\t(acc, [key, value]) => {\n\t\t\tif (key.startsWith('VITE_')) {\n\t\t\t\tconst newKey = key.replace('VITE_', '');\n\t\t\t\tacc[newKey] = value;\n\t\t\t}\n\t\t\tacc[key] = value;\n\t\t\treturn acc;\n\t\t},\n\t\t{} as Record<string, string | undefined>,\n\t);\n}\n\nfunction withEnv(env: Record<string, string | undefined>, prefix = DEFAULT_ENV_VAR_PREFIX) {\n\tconst getConfigEnvKey = () => `${prefix}TAQ_CONFIG`;\n\n\tconst decode = (value: string) => {\n\t\tconst buffer = Buffer.from(value, 'base64');\n\t\treturn buffer.toString('utf8');\n\t};\n\n\tconst getRawConfig = () => {\n\t\tconst key = getConfigEnvKey();\n\t\tconst data = env[key];\n\t\tif (!data) {\n\t\t\tthrow new TaqError(\n\t\t\t\t`Could not find config. Please ensure that the environment variable called ${key} is defined and set to the value of your config.json file using Base64 encoding.`,\n\t\t\t);\n\t\t}\n\t\ttry {\n\t\t\tconst decoded = decode(data);\n\t\t\tconst rawConfig = JSON.parse(decoded);\n\t\t\treturn rawConfig;\n\t\t} catch {\n\t\t\tthrow new TaqError(\n\t\t\t\t`Could not parse the config. Please ensure that the environment variable called ${key} is defined and set to the value of your config.json file using Base64 encoding.`,\n\t\t\t);\n\t\t}\n\t};\n\n\tconst getEnvironmentConfigKey = (environmentName: string) =>\n\t\t`${prefix}TAQ_CONFIG_LOCAL_${environmentName.toUpperCase()}`;\n\n\tconst getEnvironmentConfig = (environmentName: string) => {\n\t\tconst key = getEnvironmentConfigKey(environmentName);\n\t\tconst data = env[key];\n\t\tif (!data) {\n\t\t\treturn ConfigEnvironmentFileV2.from({});\n\t\t}\n\t\ttry {\n\t\t\tconst decoded = decode(data);\n\t\t\tconst rawConfig = JSON.parse(decoded);\n\t\t\treturn ConfigEnvironmentFileV2.from(rawConfig);\n\t\t} catch {\n\t\t\tthrow new TaqError(\n\t\t\t\t`Could not parse environment config for an environment called ${environmentName}. Please ensure that the environment variable called ${key} is defined and set to the value of your config.json file using Base64 encoding.`,\n\t\t\t);\n\t\t}\n\t};\n\n\treturn {\n\t\tgetConfigEnvKey,\n\t\tgetRawConfig,\n\t\tgetEnvironmentConfigKey,\n\t\tgetEnvironmentConfig,\n\t};\n}\n\nexport const getConfigAsV1 = (env: Record<string, string | undefined>, prefix = DEFAULT_ENV_VAR_PREFIX): Config.t => {\n\tconst { getRawConfig, getEnvironmentConfig } = withEnv(withFixedEnv(env), prefix);\n\n\tconst rawConfig = getRawConfig();\n\n\ttry {\n\t\t// If version v1, return the config object\n\t\tif (!rawConfig.version || rawConfig.version.toLowerCase() === 'v1') return Config.from(rawConfig);\n\t\t// If version v2, transform to V1 and return that\n\t\telse if (rawConfig.version.toLowerCase() === 'v2') {\n\t\t\tconst config = ConfigFileV2.from(rawConfig);\n\t\t\tconst environments = Object.keys(config.environments ?? {}).reduce(\n\t\t\t\t(retval, envName) => ({\n\t\t\t\t\t...retval,\n\t\t\t\t\t[envName]: getEnvironmentConfig(envName),\n\t\t\t\t}),\n\t\t\t\t{},\n\t\t\t);\n\n\t\t\treturn Config.create(transform.transformConfigFileV2ToConfig({\n\t\t\t\tconfig,\n\t\t\t\tenvironments,\n\t\t\t}));\n\t\t}\n\n\t\t// Other version handlers go here\n\t\tthrow new TaqError(`The version of your configuration is not yet supported.`);\n\t} catch (err) {\n\t\tthrow isTaqError(err)\n\t\t\t? err\n\t\t\t: new TaqError(\n\t\t\t\t`Something went wrong trying to parse your configuration. Please report this to the Taqueria Developers: ${err}`,\n\t\t\t);\n\t}\n};\n\nexport function getConfigV2(\n\tenv: Record<string, string | undefined>,\n\tprefix = DEFAULT_ENV_VAR_PREFIX,\n): transform.ConfigFileSetV2 {\n\tconst { getRawConfig, getEnvironmentConfig } = withEnv(withFixedEnv(env), prefix);\n\n\tconst rawConfig = getRawConfig();\n\n\ttry {\n\t\t// If version v1, return the config object\n\t\tif (!rawConfig.version || rawConfig.version.toLowerCase() === 'v1') {\n\t\t\tconst configV1 = Config.from(rawConfig);\n\t\t\treturn transform.transformConfigToConfigFileV2(configV1);\n\t\t} else if (rawConfig.version.toLowerCase() === 'v2') {\n\t\t\tconst configV2 = ConfigFileV2.from(rawConfig);\n\t\t\tconst environments = Object.keys(configV2.environments ?? {}).reduce(\n\t\t\t\t(retval, envName) => ({ ...retval, [envName]: getEnvironmentConfig(envName) }),\n\t\t\t\t{},\n\t\t\t);\n\t\t\tconst retval: transform.ConfigFileSetV2 = {\n\t\t\t\tconfig: configV2,\n\t\t\t\tenvironments,\n\t\t\t};\n\n\t\t\treturn retval;\n\t\t}\n\t\t// Other version handlers go here\n\t\t// No other versions we're aware of.\n\t\tthrow new TaqError(`The version of your configuration is not yet supported.`);\n\t} catch (err) {\n\t\tthrow isTaqError(err)\n\t\t\t? err\n\t\t\t: new TaqError(\n\t\t\t\t`Something went wrong trying to parse your configuration. Please report this to the Taqueria Developers: ${err}`,\n\t\t\t);\n\t}\n}\n\n// Backwards compatibility\n// Before introducing V1, the toolkit just exported these two functions\nconst getAliasAddress = V1.getAliasAddress;\nconst getCurrentEnv = V1.getCurrentEnv;\nexport { Config, getAliasAddress, getCurrentEnv };\n\n// New exports as of V2\nexport type ConfigFileSetV2 = transform.ConfigFileSetV2;\n"],"mappings":";;;;;;;;;;;;AAAA,YAAY,YAAY;AACxB,YAAY,6BAA6B;AACzC,YAAY,kBAAkB;AAK9B,YAAY,eAAe;AAE3B,IAAM,yBAAyB;AAE/B,SAAS,aAAa,KAAyC;AAC9D,SAAO,OAAO,QAAQ,GAAG,EAAE;AAAA,IAC1B,CAAC,KAAK,CAAC,KAAK,KAAK,MAAM;AACtB,UAAI,IAAI,WAAW,OAAO,GAAG;AAC5B,cAAM,SAAS,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EAAE;AAAA,QAC5E,CAAC;AAAA,MACF;AACA,YAAM,SAAoC;AAAA,QACzC,QAAQ;AAAA,QACR;AAAA,MACD;AAEA,aAAO;AAAA,IACR;AAGA,UAAM,IAAI,SAAS,yDAAyD;AAAA,EAC7E,SAAS,KAAK;AACb,UAAM,WAAW,GAAG,IACjB,MACA,IAAI;AAAA,MACL,2GAA2G,GAAG;AAAA,IAC/G;AAAA,EACF;AACD;AAIA,IAAMC,mBAAqB;AAC3B,IAAMC,iBAAmB;","names":["retval","getAliasAddress","getCurrentEnv"]}
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taqueria/toolkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.43.1",
|
|
4
4
|
"description": "A TypeScript library for NodeJS to work with Taqueria projects",
|
|
5
5
|
"source": "./index.ts",
|
|
6
6
|
"main": "./index.js",
|
|
7
7
|
"bin": {
|
|
8
8
|
"withTaq": "./bin/run.js"
|
|
9
9
|
},
|
|
10
|
+
"type": "module",
|
|
10
11
|
"scripts": {
|
|
11
12
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
12
13
|
"build": "npx tsc -p ./tsconfig.json && npx tsup"
|
|
@@ -37,7 +38,7 @@
|
|
|
37
38
|
"typescript": "^5.2.2"
|
|
38
39
|
},
|
|
39
40
|
"dependencies": {
|
|
40
|
-
"@taqueria/protocol": "^0.
|
|
41
|
+
"@taqueria/protocol": "^0.43.1",
|
|
41
42
|
"cross-spawn": "^7.0.3",
|
|
42
43
|
"yargs": "^17.7.2"
|
|
43
44
|
},
|
|
@@ -49,30 +50,35 @@
|
|
|
49
50
|
"v2.ts"
|
|
50
51
|
],
|
|
51
52
|
"sourcemap": true,
|
|
52
|
-
"target":
|
|
53
|
+
"target": [
|
|
54
|
+
"esnext"
|
|
55
|
+
],
|
|
53
56
|
"outDir": "./",
|
|
54
57
|
"dts": true,
|
|
55
58
|
"clean": false,
|
|
56
59
|
"shims": true,
|
|
57
60
|
"skipNodeModulesBundle": false,
|
|
58
|
-
"platform": "browser"
|
|
61
|
+
"platform": "browser",
|
|
62
|
+
"format": [
|
|
63
|
+
"esm"
|
|
64
|
+
]
|
|
59
65
|
},
|
|
60
66
|
{
|
|
61
67
|
"entry": [
|
|
62
68
|
"bin/run.ts"
|
|
63
69
|
],
|
|
64
70
|
"sourcemap": true,
|
|
65
|
-
"target": "
|
|
71
|
+
"target": "esnext",
|
|
66
72
|
"outDir": "./bin/",
|
|
67
73
|
"dts": false,
|
|
68
74
|
"clean": false,
|
|
69
75
|
"skipNodeModulesBundle": true,
|
|
70
|
-
"platform": "node"
|
|
76
|
+
"platform": "node",
|
|
77
|
+
"format": "esm"
|
|
71
78
|
}
|
|
72
79
|
],
|
|
73
80
|
"exports": {
|
|
74
81
|
"./lib/*": "./lib/*",
|
|
75
|
-
".*": "./*",
|
|
76
82
|
".": "./index.js",
|
|
77
83
|
"./v1": "./v1.js",
|
|
78
84
|
"./v2": "./v2.js"
|
package/tsconfig.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
12
12
|
|
|
13
13
|
/* Language and Environment */
|
|
14
|
-
"target": "
|
|
14
|
+
"target": "esnext", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
|
15
15
|
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
16
16
|
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
|
17
17
|
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
|
25
25
|
|
|
26
26
|
/* Modules */
|
|
27
|
-
"module": "
|
|
28
|
-
|
|
27
|
+
"module": "ESNext", /* Specify what module code is generated. */
|
|
28
|
+
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
|
|
29
29
|
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
30
30
|
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
31
31
|
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
package/v1.js
CHANGED
|
@@ -1,40 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// v1.ts
|
|
21
|
-
var v1_exports = {};
|
|
22
|
-
__export(v1_exports, {
|
|
23
|
-
getAliasAddress: () => getAliasAddress,
|
|
24
|
-
getCurrentEnv: () => getCurrentEnv
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(v1_exports);
|
|
27
|
-
var getCurrentEnv = (config) => {
|
|
28
|
-
var _a;
|
|
29
|
-
const currentEnv = ((_a = config == null ? void 0 : config.environment) == null ? void 0 : _a.default) ? config.environment.default : "development";
|
|
30
|
-
return config.environment && config.environment[currentEnv] ? config.environment[currentEnv] : void 0;
|
|
31
|
-
};
|
|
32
|
-
var getAliasAddress = (config, alias) => {
|
|
33
|
-
var _a, _b;
|
|
34
|
-
const currentEnv = getCurrentEnv(config);
|
|
35
|
-
if ((_b = (_a = currentEnv == null ? void 0 : currentEnv.aliases) == null ? void 0 : _a[alias]) == null ? void 0 : _b.address)
|
|
36
|
-
return currentEnv.aliases[alias].address;
|
|
37
|
-
alert(`Address for alias, ${alias}, is missing. Please deploy a contract with such alias`);
|
|
38
|
-
return "";
|
|
1
|
+
import {
|
|
2
|
+
getAliasAddress,
|
|
3
|
+
getCurrentEnv
|
|
4
|
+
} from "./chunk-UWGPOHCN.js";
|
|
5
|
+
import "./chunk-SSYGV25P.js";
|
|
6
|
+
export {
|
|
7
|
+
getAliasAddress,
|
|
8
|
+
getCurrentEnv
|
|
39
9
|
};
|
|
40
10
|
//# sourceMappingURL=v1.js.map
|
package/v1.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/v2.js
CHANGED
|
@@ -1,61 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import {
|
|
2
|
+
getContractAddress,
|
|
3
|
+
getCurrentEnv,
|
|
4
|
+
getEnv
|
|
5
|
+
} from "./chunk-BGUG3ZS5.js";
|
|
6
|
+
import "./chunk-SSYGV25P.js";
|
|
7
|
+
export {
|
|
8
|
+
getContractAddress,
|
|
9
|
+
getCurrentEnv,
|
|
10
|
+
getEnv
|
|
9
11
|
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// v2.ts
|
|
21
|
-
var v2_exports = {};
|
|
22
|
-
__export(v2_exports, {
|
|
23
|
-
getContractAddress: () => getContractAddress,
|
|
24
|
-
getCurrentEnv: () => getCurrentEnv,
|
|
25
|
-
getEnv: () => getEnv
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(v2_exports);
|
|
28
|
-
|
|
29
|
-
// TaqError.ts
|
|
30
|
-
var TaqError = class extends Error {
|
|
31
|
-
constructor() {
|
|
32
|
-
super(...arguments);
|
|
33
|
-
this.isTaqError = true;
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
// v2.ts
|
|
38
|
-
function getEnv(envName, settings) {
|
|
39
|
-
var _a;
|
|
40
|
-
const mainEnv = (_a = settings.config.environments) == null ? void 0 : _a[envName];
|
|
41
|
-
if (mainEnv) {
|
|
42
|
-
return {
|
|
43
|
-
...mainEnv,
|
|
44
|
-
...settings.environments[envName]
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
throw new TaqError(`There is no environment configured called ${envName}`);
|
|
48
|
-
}
|
|
49
|
-
var getCurrentEnv = (settings) => {
|
|
50
|
-
if (settings.config.environmentDefault) {
|
|
51
|
-
return getEnv(settings.config.environmentDefault, settings);
|
|
52
|
-
}
|
|
53
|
-
throw new TaqError(
|
|
54
|
-
`No default environment has been configured. Please set the "environmentDefault" property in your .taq/config.json.`
|
|
55
|
-
);
|
|
56
|
-
};
|
|
57
|
-
function getContractAddress(contractName, env) {
|
|
58
|
-
var _a, _b;
|
|
59
|
-
return (_b = (_a = env.contracts) == null ? void 0 : _a[contractName]) == null ? void 0 : _b.address;
|
|
60
|
-
}
|
|
61
12
|
//# sourceMappingURL=v2.js.map
|
package/v2.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|