@taqueria/toolkit 0.28.4 → 0.28.5

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 CHANGED
@@ -15,6 +15,10 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
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.
18
22
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
19
23
  mod
20
24
  ));
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":";;;;;;;;;;;;;;;;;;;;;;AACA,yBAAsB;AAEtB,mBAAkB;;;ACHlB,sBAAwC;AACxC,kBAAiB;AAEjB,IAAM,YAAN,cAAwB,MAAM;AAAC;AAExB,IAAM,mBAAN,cAA+B,UAAU;AAAA,EAAzC;AAAA;AACN,SAAO,cAAc;AAAA;AACtB;AAEO,SAAS,cAAc,KAA4B;AACzD,SAAO,OAAO,QAAQ,YAAa,IAAe,eAAe,aAAa;AAC/E;AAEA,eAAsB,gBAAgB,KAAa;AAClD,MAAI;AACH,UAAM,aAAa,YAAAA,QAAK,KAAK,KAAK,MAAM;AACxC,cAAM,sBAAK,UAAU;AACrB,WAAO;AAAA,EACR,QAAE;AACD,UAAM,IAAI,iBAAiB,GAAG,sCAAsC;AAAA,EACrE;AACD;AAEA,SAAS,WAAW,UAAkB,SAAS,IAAI;AAClD,SAAO,GAAG,aAAa,WACrB,QAAQ,SAAS,EAAE,EACnB,QAA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,SAAS;AAAA,EACV,CAAC,EACA,OAAO,CAAC,YAAY,CAAC,EACrB,UAAU;AAEZ,MAAI,WAAW,EAAE,SAAS,KAAK,WAAW,YAAY;AACrD,OAAG,WAAW,YAAY,WAAW,QAAQ,WAAW,EAAE,KAAK,GAAG,CAAC;AAAA,EACpE;AAAO,YAAQ,IAAI,UAAU,gEAAgE;AAC9F;AAEA,SAAS,qBAAqB,KAAa,QAAgC;AAC1E,SAAO,OAAO,QAAQ,MAAM,EAAE;AAAA,IAC7B,CAAC,QAAQ,CAAC,KAAK,KAAK,MAAM;AACzB,UAAI;AACH,eAAO,GAAG,OAAO,SAAS;AAAA,MAC3B,SAAS,KAAP;AACD,gBAAQ,KAAK,iBAAiB,KAAK;AACnC,gBAAQ,KAAK,qFAAqF;AAClG,eAAO;AAAA,MACR;AAAA,IACD;AAAA,IACA;AAAA,EACD;AACD;AAEA,eAAe,IAAI,YAAoB,QAAgB,KAAa;AACnE,MAAI;AACH,UAAM,SAAS,MAAM,gBAAgB,UAAU;AAC/C,UAAM,SAAS,MAAM,iBAAiB,QAAQ,MAAM;AACpD,UAAM,iBAAiB,qBAAqB,KAAK,MAAM;AAEvD,kCAAM,gBAAgB;AAAA,MACrB,OAAO;AAAA,MACP,OAAO;AAAA,IACR,CAAC;AAAA,EACF,SAAS,KAAP;AACD,QAAI,cAAc,GAAG,GAAG;AACvB,cAAQ,MAAM,IAAI,OAAO;AACzB;AAAA,IACD;AACA,UAAM;AAAA,EACP;AACD;AAEA,cAAc,QAAQ,MAAM,GAAG;","names":["path","yargs"]}
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,yBAAsB;AAEtB,mBAAkB;;;ACHlB,sBAAwC;AACxC,kBAAiB;AAEjB,IAAM,YAAN,cAAwB,MAAM;AAA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O;AAAA,MACP,OAAO;AAAA,IACR,CAAC;AAAA,EACF,SAAS,KAAP;AACD,QAAI,cAAc,GAAG,GAAG;AACvB,cAAQ,MAAM,IAAI,OAAO;AACzB;AAAA,IACD;AACA,UAAM;AAAA,EACP;AACD;AAEA,cAAc,QAAQ,MAAM,GAAG;","names":["path","yargs"]}
package/index.js CHANGED
@@ -18,6 +18,10 @@ var __copyProps = (to, from4, except, desc) => {
18
18
  return to;
19
19
  };
20
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.
21
25
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
26
  mod
23
27
  ));
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 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(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(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,cAC7C,OAAO,YAAY,cACnB;AACJ;AAEO,IAAM,kBAAkB,CAAC,QAAa,UAA0B;AAVvE;AAWC,QAAM,aAAa,cAAc,MAAM;AACvC,OAAI,oDAAY,YAAZ,mBAAsB,WAAtB,mBAA8B;AAAS,WAAO,WAAW,QAAQ,OAAO;AAC5E,QAAM,sBAAsB,6DAA6D;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,SAAS;AACZ,WAAO;AAAA,MACN,GAAG;AAAA,MACH,GAAG,SAAS,aAAa;AAAA,IAC1B;AAAA,EACD;AACA,QAAM,IAAI,SAAS,6CAA6C,SAAS;AAC1E;AAE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S,iBAAT,YAAyB,CAAC,CAAC,EAAE;AAAA,QAC7D,CAACC,SAAQ,aAAa,EAAE,GAAGA,SAAQ,CAAC,UAAU,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,KAAP;AACD,UAAM,WAAW,GAAG,IACjB,MACA,IAAI;AAAA,MACL,2GAA2G;AAAA,IAC5G;AAAA,EACF;AACD;AAIA,IAAMC,mBAAqB;AAC3B,IAAMC,iBAAmB;","names":["getAliasAddress","getCurrentEnv","getCurrentEnv","getCurrentEnv","retval","getAliasAddress","getCurrentEnv"]}
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 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(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(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,6DAA6D;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,SAAS;AACZ,WAAO;AAAA,MACN,GAAG;AAAA,MACH,GAAG,SAAS,aAAa,OAAO;AAAA,IACjC;AAAA,EACD;AACA,QAAM,IAAI,SAAS,6CAA6C,SAAS;AAC1E;AAEO,IAAMC,iBAAgB,CAAC,aAA8B;AAC3D,MAAI,SAAS,OAAO,oBAAoB;AACvC,WAAO,OAA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AAa,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,KAAP;AACD,UAAM,WAAW,GAAG,IACjB,MACA,IAAI;AAAA,MACL,2GAA2G;AAAA,IAC5G;AAAA,EACF;AACD;AAIA,IAAMC,mBAAqB;AAC3B,IAAMC,iBAAmB;","names":["getAliasAddress","getCurrentEnv","getCurrentEnv","getCurrentEnv","retval","getAliasAddress","getCurrentEnv"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taqueria/toolkit",
3
- "version": "0.28.4",
3
+ "version": "0.28.5",
4
4
  "description": "A TypeScript library for NodeJS to work with Taqueria projects",
5
5
  "source": "./index.ts",
6
6
  "main": "./index.js",
@@ -37,7 +37,7 @@
37
37
  "typescript": "^4.7.2"
38
38
  },
39
39
  "dependencies": {
40
- "@taqueria/protocol": "^0.28.4",
40
+ "@taqueria/protocol": "^0.28.5",
41
41
  "cross-spawn": "^7.0.3",
42
42
  "yargs": "^17.6.2"
43
43
  },
package/v1.js.map CHANGED
@@ -1 +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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,IAAM,gBAAgB,CAAC,WAAgD;AAH9E;AAIC,QAAM,eAAa,sCAAQ,gBAAR,mBAAqB,WAAU,OAAO,YAAY,UAAoB;AACzF,SAAO,OAAO,eAAe,OAAO,YAAY,cAC7C,OAAO,YAAY,cACnB;AACJ;AAEO,IAAM,kBAAkB,CAAC,QAAa,UAA0B;AAVvE;AAWC,QAAM,aAAa,cAAc,MAAM;AACvC,OAAI,oDAAY,YAAZ,mBAAsB,WAAtB,mBAA8B;AAAS,WAAO,WAAW,QAAQ,OAAO;AAC5E,QAAM,sBAAsB,6DAA6D;AACzF,SAAO;AACR;","names":[]}
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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,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,6DAA6D;AACzF,SAAO;AACR;","names":[]}
package/v2.js.map CHANGED
@@ -1 +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;AAAA;;;ACAO,IAAM,WAAN,cAAuB,MAAM;AAAA,EAA7B;AAAA;AACN,SAAO,aAAa;AAAA;AACrB;;;ADKO,SAAS,OAAO,SAAiB,UAAwC;AAPhF;AAQC,QAAM,WAAU,cAAS,OAAO,iBAAhB,mBAA+B;AAC/C,MAAI,SAAS;AACZ,WAAO;AAAA,MACN,GAAG;AAAA,MACH,GAAG,SAAS,aAAa;AAAA,IAC1B;AAAA,EACD;AACA,QAAM,IAAI,SAAS,6CAA6C,SAAS;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;AA3B3E;AA4BC,UAAO,eAAI,cAAJ,mBAAgB,kBAAhB,mBAA+B;AACvC;","names":[]}
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;AAAA;;;ACAO,IAAM,WAAN,cAAuB,MAAM;AAAA,EAA7B;AAAA;AACN,SAAO,aAAa;AAAA;AACrB;;;ADKO,SAAS,OAAO,SAAiB,UAAwC;AAPhF;AAQC,QAAM,WAAU,cAAS,OAAO,iBAAhB,mBAA+B;AAC/C,MAAI,SAAS;AACZ,WAAO;AAAA,MACN,GAAG;AAAA,MACH,GAAG,SAAS,aAAa,OAAO;AAAA,IACjC;AAAA,EACD;AACA,QAAM,IAAI,SAAS,6CAA6C,SAAS;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;AA3B3E;AA4BC,UAAO,eAAI,cAAJ,mBAAgB,kBAAhB,mBAA+B;AACvC;","names":[]}