@ckb-lumos/config-manager
Advanced tools
Comparing version 0.0.0-canary-f2fbef5-20240311091511 to 0.0.0-canary-f3acc1f-20240606024131
@@ -14,12 +14,8 @@ "use strict"; | ||
const SIGHASH_OUTPUT_LOC = [0, 1]; | ||
exports.SIGHASH_OUTPUT_LOC = SIGHASH_OUTPUT_LOC; | ||
const MULTISIG_OUTPUT_LOC = [0, 4]; | ||
exports.MULTISIG_OUTPUT_LOC = MULTISIG_OUTPUT_LOC; | ||
const DAO_OUTPUT_LOC = [0, 2]; | ||
exports.DAO_OUTPUT_LOC = DAO_OUTPUT_LOC; | ||
const SIGHASH_GROUP_OUTPUT_LOC = [1, 0]; | ||
const SIGHASH_OUTPUT_LOC = exports.SIGHASH_OUTPUT_LOC = [0, 1]; | ||
const MULTISIG_OUTPUT_LOC = exports.MULTISIG_OUTPUT_LOC = [0, 4]; | ||
const DAO_OUTPUT_LOC = exports.DAO_OUTPUT_LOC = [0, 2]; | ||
const SIGHASH_GROUP_OUTPUT_LOC = exports.SIGHASH_GROUP_OUTPUT_LOC = [1, 0]; | ||
// prettier-ignore | ||
exports.SIGHASH_GROUP_OUTPUT_LOC = SIGHASH_GROUP_OUTPUT_LOC; | ||
const MULTISIG_GROUP_OUTPUT_LOC = [1, 1]; | ||
const MULTISIG_GROUP_OUTPUT_LOC = exports.MULTISIG_GROUP_OUTPUT_LOC = [1, 1]; | ||
@@ -36,3 +32,2 @@ /** | ||
*/ | ||
exports.MULTISIG_GROUP_OUTPUT_LOC = MULTISIG_GROUP_OUTPUT_LOC; | ||
function generateGenesisScriptConfigs(genesisBlock) { | ||
@@ -39,0 +34,0 @@ if (!genesisBlock || Number(genesisBlock.header.number) !== 0) { |
@@ -105,4 +105,4 @@ "use strict"; | ||
var _refresh = require("./refresh"); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
//# sourceMappingURL=index.js.map |
@@ -5,3 +5,3 @@ import { Config } from "./types"; | ||
export declare function getConfig(): Config; | ||
export declare function initializeConfig(inputConfig?: Config): void; | ||
export declare function initializeConfig(inputConfig: Config): void; | ||
//# sourceMappingURL=manager.d.ts.map |
@@ -11,3 +11,2 @@ "use strict"; | ||
var _deepFreezeStrict = _interopRequireDefault(require("deep-freeze-strict")); | ||
var _base = require("@ckb-lumos/base"); | ||
var _predefined = require("./predefined"); | ||
@@ -22,3 +21,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
assertHexString(debugPath, hash); | ||
if (hash.length != 66) { | ||
// 2 for 0x | ||
// 64 for 32 bytes in hex format | ||
const hashHexLength = 66; | ||
if (hash.length !== hashHexLength) { | ||
throw new Error(`${debugPath} must be a hex string of 66 characters long!`); | ||
@@ -69,43 +71,6 @@ } | ||
} | ||
/** | ||
* Initialize current app with a config. The initializaton steps work as follows: | ||
* 1. If `LUMOS_CONFIG_NAME` environment variable is set to a predefined config, | ||
* the predefined config is loaded; | ||
* 2. If `LUMOS_CONFIG_FILE` environment variable is set, it will be used as the | ||
* name of a file containing the Config to use. | ||
* 3. A file named `config.json` in current running directory will be used as the | ||
* file containing the Config to use. | ||
* @deprecated | ||
* @returns void | ||
*/ | ||
function initializeConfigLegacy() { | ||
var _process; | ||
const env = (_process = process) === null || _process === void 0 ? void 0 : _process.env; | ||
const configName = env === null || env === void 0 ? void 0 : env.LUMOS_CONFIG_NAME; | ||
if ((configName === "LINA" || configName === "AGGRON4") && _predefined.predefined[configName]) { | ||
config = _predefined.predefined[configName]; | ||
return; | ||
} | ||
const configFile = env === null || env === void 0 ? void 0 : env.LUMOS_CONFIG_FILE; | ||
const configFilename = configFile || "config.json"; | ||
try { | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const data = require("fs").readFileSync(configFilename); | ||
const loadedConfig = JSON.parse(data); | ||
validateConfig(loadedConfig); | ||
config = (0, _deepFreezeStrict.default)(loadedConfig); | ||
} catch (e) { | ||
throw new Error(`Error loading config from file ${configFilename}: ${e}`); | ||
} | ||
} | ||
function initializeConfig(inputConfig) { | ||
if (!inputConfig) { | ||
_base.logger.deprecated("initializeConfig with env will be deprecated, please migrate to initializeConfig(...)"); | ||
initializeConfigLegacy(); | ||
} else { | ||
validateConfig(inputConfig); | ||
config = (0, _deepFreezeStrict.default)(inputConfig); | ||
} | ||
validateConfig(inputConfig); | ||
config = (0, _deepFreezeStrict.default)(inputConfig); | ||
} | ||
//# sourceMappingURL=manager.js.map |
@@ -60,2 +60,9 @@ import { ScriptConfig } from "./types"; | ||
}; | ||
XUDT: { | ||
CODE_HASH: string; | ||
HASH_TYPE: "data1"; | ||
TX_HASH: string; | ||
INDEX: string; | ||
DEP_TYPE: "code"; | ||
}; | ||
}; | ||
@@ -111,2 +118,9 @@ }; | ||
}; | ||
XUDT: { | ||
CODE_HASH: string; | ||
HASH_TYPE: "type"; | ||
TX_HASH: string; | ||
INDEX: string; | ||
DEP_TYPE: "code"; | ||
}; | ||
}; | ||
@@ -113,0 +127,0 @@ }; |
@@ -64,2 +64,9 @@ "use strict"; | ||
DEP_TYPE: "code" | ||
}, | ||
XUDT: { | ||
CODE_HASH: "0x50bd8d6680b8b9cf98b73f3c08faf8b2a21914311954118ad6609be6e78a1b95", | ||
HASH_TYPE: "data1", | ||
TX_HASH: "0xc07844ce21b38e4b071dd0e1ee3b0e27afd8d7532491327f39b786343f558ab7", | ||
INDEX: "0x0", | ||
DEP_TYPE: "code" | ||
} | ||
@@ -112,13 +119,19 @@ } | ||
HASH_TYPE: "type", | ||
TX_HASH: "0x3d4296df1bd2cc2bd3f483f61ab7ebeac462a2f336f2b944168fe6ba5d81c014", | ||
TX_HASH: "0xec18bf0d857c981c3d1f4e17999b9b90c484b303378e94de1a57b0872f5d4602", | ||
INDEX: "0x0", | ||
DEP_TYPE: "code" | ||
}, | ||
XUDT: { | ||
CODE_HASH: "0x25c29dc317811a6f6f3985a7a9ebc4838bd388d19d0feeecf0bcd60f6c0975bb", | ||
HASH_TYPE: "type", | ||
TX_HASH: "0xbf6fb538763efec2a70a6a3dcb7242787087e1030c4e7d86585bc63a9d337f5f", | ||
INDEX: "0x0", | ||
DEP_TYPE: "code" | ||
} | ||
} | ||
}); | ||
const predefined = { | ||
const predefined = exports.predefined = { | ||
LINA, | ||
AGGRON4 | ||
}; | ||
exports.predefined = predefined; | ||
//# sourceMappingURL=predefined.js.map |
{ | ||
"name": "@ckb-lumos/config-manager", | ||
"version": "0.0.0-canary-f2fbef5-20240311091511", | ||
"version": "0.0.0-canary-f3acc1f-20240606024131", | ||
"description": "Config manager for lumos", | ||
@@ -28,6 +28,6 @@ "author": "Xuejie Xiao <xxuejie@gmail.com>", | ||
"dependencies": { | ||
"@ckb-lumos/base": "0.0.0-canary-f2fbef5-20240311091511", | ||
"@ckb-lumos/bi": "0.0.0-canary-f2fbef5-20240311091511", | ||
"@ckb-lumos/codec": "0.0.0-canary-f2fbef5-20240311091511", | ||
"@ckb-lumos/rpc": "0.0.0-canary-f2fbef5-20240311091511", | ||
"@ckb-lumos/base": "0.0.0-canary-f3acc1f-20240606024131", | ||
"@ckb-lumos/bi": "0.0.0-canary-f3acc1f-20240606024131", | ||
"@ckb-lumos/codec": "0.0.0-canary-f3acc1f-20240606024131", | ||
"@ckb-lumos/rpc": "0.0.0-canary-f3acc1f-20240606024131", | ||
"@types/deep-freeze-strict": "^1.1.0", | ||
@@ -34,0 +34,0 @@ "deep-freeze-strict": "^1.1.1" |
import deepFreeze from "deep-freeze-strict"; | ||
import { logger } from "@ckb-lumos/base"; | ||
import { Config } from "./types"; | ||
@@ -14,3 +13,6 @@ import { predefined } from "./predefined"; | ||
assertHexString(debugPath, hash); | ||
if (hash.length != 66) { | ||
// 2 for 0x | ||
// 64 for 32 bytes in hex format | ||
const hashHexLength = 66; | ||
if (hash.length !== hashHexLength) { | ||
throw new Error(`${debugPath} must be a hex string of 66 characters long!`); | ||
@@ -81,48 +83,5 @@ } | ||
/** | ||
* Initialize current app with a config. The initializaton steps work as follows: | ||
* 1. If `LUMOS_CONFIG_NAME` environment variable is set to a predefined config, | ||
* the predefined config is loaded; | ||
* 2. If `LUMOS_CONFIG_FILE` environment variable is set, it will be used as the | ||
* name of a file containing the Config to use. | ||
* 3. A file named `config.json` in current running directory will be used as the | ||
* file containing the Config to use. | ||
* @deprecated | ||
* @returns void | ||
*/ | ||
function initializeConfigLegacy() { | ||
const env = process?.env; | ||
const configName = env?.LUMOS_CONFIG_NAME; | ||
if ( | ||
(configName === "LINA" || configName === "AGGRON4") && | ||
predefined[configName] | ||
) { | ||
config = predefined[configName]; | ||
return; | ||
} | ||
const configFile = env?.LUMOS_CONFIG_FILE; | ||
const configFilename = configFile || "config.json"; | ||
try { | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const data = require("fs").readFileSync(configFilename); | ||
const loadedConfig = JSON.parse(data); | ||
validateConfig(loadedConfig); | ||
config = deepFreeze(loadedConfig); | ||
} catch (e) { | ||
throw new Error(`Error loading config from file ${configFilename}: ${e}`); | ||
} | ||
export function initializeConfig(inputConfig: Config): void { | ||
validateConfig(inputConfig); | ||
config = deepFreeze(inputConfig); | ||
} | ||
export function initializeConfig(inputConfig?: Config): void { | ||
if (!inputConfig) { | ||
logger.deprecated( | ||
"initializeConfig with env will be deprecated, please migrate to initializeConfig(...)" | ||
); | ||
initializeConfigLegacy(); | ||
} else { | ||
validateConfig(inputConfig); | ||
config = deepFreeze(inputConfig); | ||
} | ||
} |
@@ -77,2 +77,11 @@ import deepFreeze from "deep-freeze-strict"; | ||
}, | ||
XUDT: { | ||
CODE_HASH: | ||
"0x50bd8d6680b8b9cf98b73f3c08faf8b2a21914311954118ad6609be6e78a1b95", | ||
HASH_TYPE: "data1", | ||
TX_HASH: | ||
"0xc07844ce21b38e4b071dd0e1ee3b0e27afd8d7532491327f39b786343f558ab7", | ||
INDEX: "0x0", | ||
DEP_TYPE: "code", | ||
}, | ||
}, | ||
@@ -137,6 +146,15 @@ }); | ||
TX_HASH: | ||
"0x3d4296df1bd2cc2bd3f483f61ab7ebeac462a2f336f2b944168fe6ba5d81c014", | ||
"0xec18bf0d857c981c3d1f4e17999b9b90c484b303378e94de1a57b0872f5d4602", | ||
INDEX: "0x0", | ||
DEP_TYPE: "code", | ||
}, | ||
XUDT: { | ||
CODE_HASH: | ||
"0x25c29dc317811a6f6f3985a7a9ebc4838bd388d19d0feeecf0bcd60f6c0975bb", | ||
HASH_TYPE: "type", | ||
TX_HASH: | ||
"0xbf6fb538763efec2a70a6a3dcb7242787087e1030c4e7d86585bc63a9d337f5f", | ||
INDEX: "0x0", | ||
DEP_TYPE: "code", | ||
}, | ||
}, | ||
@@ -143,0 +161,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
0
89866
1337
+ Added@ckb-lumos/base@0.0.0-canary-f3acc1f-20240606024131(transitive)
+ Added@ckb-lumos/bi@0.0.0-canary-f3acc1f-20240606024131(transitive)
+ Added@ckb-lumos/codec@0.0.0-canary-f3acc1f-20240606024131(transitive)
+ Added@ckb-lumos/rpc@0.0.0-canary-f3acc1f-20240606024131(transitive)
+ Added@ckb-lumos/toolkit@0.0.0-canary-f3acc1f-20240606024131(transitive)
- Removed@ckb-lumos/base@0.0.0-canary-f2fbef5-20240311091511(transitive)
- Removed@ckb-lumos/bi@0.0.0-canary-f2fbef5-20240311091511(transitive)
- Removed@ckb-lumos/codec@0.0.0-canary-f2fbef5-20240311091511(transitive)
- Removed@ckb-lumos/rpc@0.0.0-canary-f2fbef5-20240311091511(transitive)
- Removed@ckb-lumos/toolkit@0.0.0-canary-f2fbef5-20240311091511(transitive)