@latticexyz/cli 1.31.2 → 1.31.3

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.
@@ -204027,7 +204027,7 @@ var import_promises = require("fs/promises");
204027
204027
  var import_ejs = __toESM(require_ejs());
204028
204028
  var import_path = __toESM(require("path"));
204029
204029
  var contractsDir = import_path.default.join(__dirname, "../../src/contracts");
204030
- var stubLibDeploy = (0, import_promises.readFile)(import_path.default.join(contractsDir, "LibDeploy.sol"));
204030
+ var stubLibDeploy = (0, import_promises.readFile)(import_path.default.join(contractsDir, "LibDeployStub.sol"));
204031
204031
 
204032
204032
  // src/utils/types.ts
204033
204033
  var import_typechain = __toESM(require_dist());
@@ -180793,7 +180793,7 @@ var import_promises = require("fs/promises");
180793
180793
  var import_ejs = __toESM(require_ejs());
180794
180794
  var import_path = __toESM(require("path"));
180795
180795
  var contractsDir = import_path.default.join(__dirname, "../../src/contracts");
180796
- var stubLibDeploy = (0, import_promises.readFile)(import_path.default.join(contractsDir, "LibDeploy.sol"));
180796
+ var stubLibDeploy = (0, import_promises.readFile)(import_path.default.join(contractsDir, "LibDeployStub.sol"));
180797
180797
  function generateLibDeploy(configPath, out, systems) {
180798
180798
  return __async(this, null, function* () {
180799
180799
  const config = JSON.parse(yield (0, import_promises.readFile)(configPath, { encoding: "utf8" }));
@@ -180819,7 +180819,7 @@ var import_promises = require("fs/promises");
180819
180819
  var import_ejs = __toESM(require_ejs());
180820
180820
  var import_path = __toESM(require("path"));
180821
180821
  var contractsDir = import_path.default.join(__dirname, "../../src/contracts");
180822
- var stubLibDeploy = (0, import_promises.readFile)(import_path.default.join(contractsDir, "LibDeploy.sol"));
180822
+ var stubLibDeploy = (0, import_promises.readFile)(import_path.default.join(contractsDir, "LibDeployStub.sol"));
180823
180823
 
180824
180824
  // src/utils/types.ts
180825
180825
  var import_typechain = __toESM(require_dist());
@@ -33968,12 +33968,12 @@ var require_url_json_rpc_provider = __commonJS({
33968
33968
  var _version_1 = require_version25();
33969
33969
  var logger = new logger_1.Logger(_version_1.version);
33970
33970
  var json_rpc_provider_1 = require_json_rpc_provider();
33971
- var StaticJsonRpcProvider = function(_super) {
33972
- __extends(StaticJsonRpcProvider2, _super);
33973
- function StaticJsonRpcProvider2() {
33971
+ var StaticJsonRpcProvider2 = function(_super) {
33972
+ __extends(StaticJsonRpcProvider3, _super);
33973
+ function StaticJsonRpcProvider3() {
33974
33974
  return _super !== null && _super.apply(this, arguments) || this;
33975
33975
  }
33976
- StaticJsonRpcProvider2.prototype.detectNetwork = function() {
33976
+ StaticJsonRpcProvider3.prototype.detectNetwork = function() {
33977
33977
  return __awaiter(this, void 0, void 0, function() {
33978
33978
  var network;
33979
33979
  return __generator(this, function(_a) {
@@ -33999,9 +33999,9 @@ var require_url_json_rpc_provider = __commonJS({
33999
33999
  });
34000
34000
  });
34001
34001
  };
34002
- return StaticJsonRpcProvider2;
34002
+ return StaticJsonRpcProvider3;
34003
34003
  }(json_rpc_provider_1.JsonRpcProvider);
34004
- exports.StaticJsonRpcProvider = StaticJsonRpcProvider;
34004
+ exports.StaticJsonRpcProvider = StaticJsonRpcProvider2;
34005
34005
  var UrlJsonRpcProvider = function(_super) {
34006
34006
  __extends(UrlJsonRpcProvider2, _super);
34007
34007
  function UrlJsonRpcProvider2(network, apiKey) {
@@ -34042,7 +34042,7 @@ var require_url_json_rpc_provider = __commonJS({
34042
34042
  });
34043
34043
  };
34044
34044
  return UrlJsonRpcProvider2;
34045
- }(StaticJsonRpcProvider);
34045
+ }(StaticJsonRpcProvider2);
34046
34046
  exports.UrlJsonRpcProvider = UrlJsonRpcProvider;
34047
34047
  }
34048
34048
  });
@@ -216279,7 +216279,7 @@ var import_promises = require("fs/promises");
216279
216279
  var import_ejs = __toESM(require_ejs());
216280
216280
  var import_path = __toESM(require("path"));
216281
216281
  var contractsDir = import_path.default.join(__dirname, "../../src/contracts");
216282
- var stubLibDeploy = (0, import_promises.readFile)(import_path.default.join(contractsDir, "LibDeploy.sol"));
216282
+ var stubLibDeploy = (0, import_promises.readFile)(import_path.default.join(contractsDir, "LibDeployStub.sol"));
216283
216283
  function generateLibDeploy(configPath, out, systems) {
216284
216284
  return __async(this, null, function* () {
216285
216285
  const config = JSON.parse(yield (0, import_promises.readFile)(configPath, { encoding: "utf8" }));
@@ -216338,7 +216338,7 @@ function copyAbi(inDir, outDir, contract) {
216338
216338
  try {
216339
216339
  return (0, import_fs2.copyFileSync)(import_path2.default.join(inDir, contract + ".sol", contract + ".json"), import_path2.default.join(outDir, contract + ".json"));
216340
216340
  } catch (e) {
216341
- console.warn(e);
216341
+ console.log("Skipping", contract);
216342
216342
  }
216343
216343
  }
216344
216344
  function filterAbi(abiIn = "./out", abiOut = "./abi", exclude = ["Component", "IComponent"]) {
@@ -217364,11 +217364,22 @@ function execa(file, args, options) {
217364
217364
  }
217365
217365
 
217366
217366
  // src/utils/deploy.ts
217367
+ var import_providers = __toESM(require_lib32());
217367
217368
  var contractsDir2 = __dirname + "/../../src/contracts";
217368
- function deploy(deployerPrivateKey, rpc = "http://localhost:8545", worldAddress, reuseComponents) {
217369
+ function deploy(deployerPrivateKey, rpc = "http://localhost:8545", worldAddress, reuseComponents, gasPrice) {
217369
217370
  return __async(this, null, function* () {
217370
- var _a, _b;
217371
+ var _a, _b, _c;
217371
217372
  const address = deployerPrivateKey ? new import_ethers.Wallet(deployerPrivateKey).address : import_ethers.constants.AddressZero;
217373
+ if (gasPrice == null) {
217374
+ try {
217375
+ console.log("Fetching gas price...");
217376
+ const provider = new import_providers.StaticJsonRpcProvider(rpc, { name: "AnyNetwork", chainId: 1234 });
217377
+ gasPrice = (yield provider.getGasPrice()).toNumber() * 1.3;
217378
+ console.log("Gas price:", gasPrice);
217379
+ } catch (e) {
217380
+ console.log("Could not fetch gas price");
217381
+ }
217382
+ }
217372
217383
  const child = execa(
217373
217384
  "forge",
217374
217385
  [
@@ -217384,12 +217395,14 @@ function deploy(deployerPrivateKey, rpc = "http://localhost:8545", worldAddress,
217384
217395
  worldAddress || import_ethers.constants.AddressZero,
217385
217396
  reuseComponents ? "true" : "false",
217386
217397
  "--fork-url",
217387
- rpc
217398
+ rpc,
217399
+ ...gasPrice != null ? ["--with-gas-price", String(gasPrice)] : []
217388
217400
  ],
217389
- { stdio: ["inherit", "pipe", "inherit"] }
217401
+ { stdio: ["inherit", "pipe", "pipe"] }
217390
217402
  );
217391
- (_a = child.stdout) == null ? void 0 : _a.on("data", (data) => console.log(data.toString()));
217392
- const lines = (_b = (yield child).stdout) == null ? void 0 : _b.split("\n");
217403
+ (_a = child.stderr) == null ? void 0 : _a.on("data", (data) => console.log("stderr:", data.toString()));
217404
+ (_b = child.stdout) == null ? void 0 : _b.on("data", (data) => console.log(data.toString()));
217405
+ const lines = (_c = (yield child).stdout) == null ? void 0 : _c.split("\n");
217393
217406
  const deployedWorldAddress = findLog(lines, "world: address");
217394
217407
  const initialBlockNumber = findLog(lines, "initialBlockNumber: uint256");
217395
217408
  return { child: yield child, deployedWorldAddress, initialBlockNumber };
@@ -217403,7 +217416,13 @@ function generateAndDeploy(args) {
217403
217416
  try {
217404
217417
  libDeployPath = yield generateLibDeploy(args.config, contractsDir2, args.systems);
217405
217418
  yield generateTypes(void 0, "./types", { clear: args.clear });
217406
- const result = yield deploy(args.deployerPrivateKey, args.rpc, args.worldAddress, Boolean(args.systems));
217419
+ const result = yield deploy(
217420
+ args.deployerPrivateKey,
217421
+ args.rpc,
217422
+ args.worldAddress,
217423
+ Boolean(args.systems),
217424
+ args.gasPrice
217425
+ );
217407
217426
  deployedWorldAddress = result.deployedWorldAddress;
217408
217427
  initialBlockNumber = result.initialBlockNumber;
217409
217428
  } catch (e) {
@@ -217411,7 +217430,7 @@ function generateAndDeploy(args) {
217411
217430
  } finally {
217412
217431
  console.log("Cleaning up deployment script");
217413
217432
  if (libDeployPath)
217414
- resetLibDeploy(contractsDir2);
217433
+ yield resetLibDeploy(contractsDir2);
217415
217434
  }
217416
217435
  return { deployedWorldAddress, initialBlockNumber };
217417
217436
  });
@@ -217480,7 +217499,8 @@ var builder = (yargs) => yargs.options({
217480
217499
  systems: { type: "string", desc: "Only upgrade the given systems. Requires World address." },
217481
217500
  watch: { type: "boolean", desc: "Automatically redeploy changed systems" },
217482
217501
  dev: { type: "boolean", desc: "Automatically use funded dev private key for local development" },
217483
- openUrl: { type: "string", desc: "Opens a browser at the provided url with the worldAddress url param prefilled" }
217502
+ openUrl: { type: "string", desc: "Opens a browser at the provided url with the worldAddress url param prefilled" },
217503
+ gasPrice: { type: "number", desc: "Gas price to set for deploy transactions" }
217484
217504
  });
217485
217505
  var handler = (args) => __async(void 0, null, function* () {
217486
217506
  var _a;
@@ -217488,7 +217508,7 @@ var handler = (args) => __async(void 0, null, function* () {
217488
217508
  console.error("Error: Upgrading systems requires a World address.");
217489
217509
  process.exit(1);
217490
217510
  }
217491
- const deployerPrivateKey = ((_a = args.deployerPrivateKey) != null ? _a : args.dev) ? "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" : void 0;
217511
+ const deployerPrivateKey = (_a = args.deployerPrivateKey) != null ? _a : args.dev ? "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" : void 0;
217492
217512
  const { deployedWorldAddress: worldAddress, initialBlockNumber } = yield generateAndDeploy(__spreadProps(__spreadValues({}, args), {
217493
217513
  deployerPrivateKey,
217494
217514
  clear: true
@@ -217500,14 +217520,15 @@ var handler = (args) => __async(void 0, null, function* () {
217500
217520
  import_openurl.default.open(url2.toString());
217501
217521
  }
217502
217522
  if (args.watch) {
217503
- const { config, rpc } = args;
217523
+ const { config, rpc, gasPrice } = args;
217504
217524
  hsr("./src", (systems) => {
217505
217525
  return generateAndDeploy({
217506
217526
  config,
217507
217527
  deployerPrivateKey,
217508
217528
  worldAddress,
217509
217529
  rpc,
217510
- systems
217530
+ systems,
217531
+ gasPrice
217511
217532
  });
217512
217533
  });
217513
217534
  } else {
@@ -31932,12 +31932,12 @@ var require_url_json_rpc_provider = __commonJS({
31932
31932
  var _version_1 = require_version22();
31933
31933
  var logger = new logger_1.Logger(_version_1.version);
31934
31934
  var json_rpc_provider_1 = require_json_rpc_provider();
31935
- var StaticJsonRpcProvider = function(_super) {
31936
- __extends(StaticJsonRpcProvider2, _super);
31937
- function StaticJsonRpcProvider2() {
31935
+ var StaticJsonRpcProvider2 = function(_super) {
31936
+ __extends(StaticJsonRpcProvider3, _super);
31937
+ function StaticJsonRpcProvider3() {
31938
31938
  return _super !== null && _super.apply(this, arguments) || this;
31939
31939
  }
31940
- StaticJsonRpcProvider2.prototype.detectNetwork = function() {
31940
+ StaticJsonRpcProvider3.prototype.detectNetwork = function() {
31941
31941
  return __awaiter(this, void 0, void 0, function() {
31942
31942
  var network;
31943
31943
  return __generator(this, function(_a2) {
@@ -31963,9 +31963,9 @@ var require_url_json_rpc_provider = __commonJS({
31963
31963
  });
31964
31964
  });
31965
31965
  };
31966
- return StaticJsonRpcProvider2;
31966
+ return StaticJsonRpcProvider3;
31967
31967
  }(json_rpc_provider_1.JsonRpcProvider);
31968
- exports.StaticJsonRpcProvider = StaticJsonRpcProvider;
31968
+ exports.StaticJsonRpcProvider = StaticJsonRpcProvider2;
31969
31969
  var UrlJsonRpcProvider = function(_super) {
31970
31970
  __extends(UrlJsonRpcProvider2, _super);
31971
31971
  function UrlJsonRpcProvider2(network, apiKey) {
@@ -32006,7 +32006,7 @@ var require_url_json_rpc_provider = __commonJS({
32006
32006
  });
32007
32007
  };
32008
32008
  return UrlJsonRpcProvider2;
32009
- }(StaticJsonRpcProvider);
32009
+ }(StaticJsonRpcProvider2);
32010
32010
  exports.UrlJsonRpcProvider = UrlJsonRpcProvider;
32011
32011
  }
32012
32012
  });
@@ -269078,7 +269078,7 @@ var import_promises = require("fs/promises");
269078
269078
  var import_ejs = __toESM(require_ejs());
269079
269079
  var import_path = __toESM(require("path"));
269080
269080
  var contractsDir = import_path.default.join(__dirname, "../../src/contracts");
269081
- var stubLibDeploy = (0, import_promises.readFile)(import_path.default.join(contractsDir, "LibDeploy.sol"));
269081
+ var stubLibDeploy = (0, import_promises.readFile)(import_path.default.join(contractsDir, "LibDeployStub.sol"));
269082
269082
  function generateLibDeploy(configPath, out, systems) {
269083
269083
  return __async(this, null, function* () {
269084
269084
  const config = JSON.parse(yield (0, import_promises.readFile)(configPath, { encoding: "utf8" }));
@@ -269137,7 +269137,7 @@ function copyAbi(inDir, outDir, contract) {
269137
269137
  try {
269138
269138
  return (0, import_fs2.copyFileSync)(import_path2.default.join(inDir, contract + ".sol", contract + ".json"), import_path2.default.join(outDir, contract + ".json"));
269139
269139
  } catch (e) {
269140
- console.warn(e);
269140
+ console.log("Skipping", contract);
269141
269141
  }
269142
269142
  }
269143
269143
  function filterAbi(abiIn = "./out", abiOut = "./abi", exclude = ["Component", "IComponent"]) {
@@ -270163,11 +270163,22 @@ function execa(file, args, options) {
270163
270163
  }
270164
270164
 
270165
270165
  // src/utils/deploy.ts
270166
+ var import_providers = __toESM(require_lib29());
270166
270167
  var contractsDir2 = __dirname + "/../../src/contracts";
270167
- function deploy(deployerPrivateKey, rpc = "http://localhost:8545", worldAddress, reuseComponents) {
270168
+ function deploy(deployerPrivateKey, rpc = "http://localhost:8545", worldAddress, reuseComponents, gasPrice) {
270168
270169
  return __async(this, null, function* () {
270169
- var _a2, _b;
270170
+ var _a2, _b, _c;
270170
270171
  const address = deployerPrivateKey ? new import_ethers.Wallet(deployerPrivateKey).address : import_ethers.constants.AddressZero;
270172
+ if (gasPrice == null) {
270173
+ try {
270174
+ console.log("Fetching gas price...");
270175
+ const provider = new import_providers.StaticJsonRpcProvider(rpc, { name: "AnyNetwork", chainId: 1234 });
270176
+ gasPrice = (yield provider.getGasPrice()).toNumber() * 1.3;
270177
+ console.log("Gas price:", gasPrice);
270178
+ } catch (e) {
270179
+ console.log("Could not fetch gas price");
270180
+ }
270181
+ }
270171
270182
  const child = execa(
270172
270183
  "forge",
270173
270184
  [
@@ -270183,12 +270194,14 @@ function deploy(deployerPrivateKey, rpc = "http://localhost:8545", worldAddress,
270183
270194
  worldAddress || import_ethers.constants.AddressZero,
270184
270195
  reuseComponents ? "true" : "false",
270185
270196
  "--fork-url",
270186
- rpc
270197
+ rpc,
270198
+ ...gasPrice != null ? ["--with-gas-price", String(gasPrice)] : []
270187
270199
  ],
270188
- { stdio: ["inherit", "pipe", "inherit"] }
270200
+ { stdio: ["inherit", "pipe", "pipe"] }
270189
270201
  );
270190
- (_a2 = child.stdout) == null ? void 0 : _a2.on("data", (data) => console.log(data.toString()));
270191
- const lines = (_b = (yield child).stdout) == null ? void 0 : _b.split("\n");
270202
+ (_a2 = child.stderr) == null ? void 0 : _a2.on("data", (data) => console.log("stderr:", data.toString()));
270203
+ (_b = child.stdout) == null ? void 0 : _b.on("data", (data) => console.log(data.toString()));
270204
+ const lines = (_c = (yield child).stdout) == null ? void 0 : _c.split("\n");
270192
270205
  const deployedWorldAddress = findLog(lines, "world: address");
270193
270206
  const initialBlockNumber = findLog(lines, "initialBlockNumber: uint256");
270194
270207
  return { child: yield child, deployedWorldAddress, initialBlockNumber };
@@ -270202,7 +270215,13 @@ function generateAndDeploy(args) {
270202
270215
  try {
270203
270216
  libDeployPath = yield generateLibDeploy(args.config, contractsDir2, args.systems);
270204
270217
  yield generateTypes(void 0, "./types", { clear: args.clear });
270205
- const result = yield deploy(args.deployerPrivateKey, args.rpc, args.worldAddress, Boolean(args.systems));
270218
+ const result = yield deploy(
270219
+ args.deployerPrivateKey,
270220
+ args.rpc,
270221
+ args.worldAddress,
270222
+ Boolean(args.systems),
270223
+ args.gasPrice
270224
+ );
270206
270225
  deployedWorldAddress = result.deployedWorldAddress;
270207
270226
  initialBlockNumber = result.initialBlockNumber;
270208
270227
  } catch (e) {
@@ -270210,7 +270229,7 @@ function generateAndDeploy(args) {
270210
270229
  } finally {
270211
270230
  console.log("Cleaning up deployment script");
270212
270231
  if (libDeployPath)
270213
- resetLibDeploy(contractsDir2);
270232
+ yield resetLibDeploy(contractsDir2);
270214
270233
  }
270215
270234
  return { deployedWorldAddress, initialBlockNumber };
270216
270235
  });
@@ -180822,7 +180822,7 @@ var import_promises = require("fs/promises");
180822
180822
  var import_ejs = __toESM(require_ejs());
180823
180823
  var import_path = __toESM(require("path"));
180824
180824
  var contractsDir = import_path.default.join(__dirname, "../../src/contracts");
180825
- var stubLibDeploy = (0, import_promises.readFile)(import_path.default.join(contractsDir, "LibDeploy.sol"));
180825
+ var stubLibDeploy = (0, import_promises.readFile)(import_path.default.join(contractsDir, "LibDeployStub.sol"));
180826
180826
 
180827
180827
  // src/utils/types.ts
180828
180828
  var import_typechain = __toESM(require_dist());
@@ -180806,7 +180806,7 @@ var import_promises = require("fs/promises");
180806
180806
  var import_ejs = __toESM(require_ejs());
180807
180807
  var import_path = __toESM(require("path"));
180808
180808
  var contractsDir = import_path.default.join(__dirname, "../../src/contracts");
180809
- var stubLibDeploy = (0, import_promises.readFile)(import_path.default.join(contractsDir, "LibDeploy.sol"));
180809
+ var stubLibDeploy = (0, import_promises.readFile)(import_path.default.join(contractsDir, "LibDeployStub.sol"));
180810
180810
 
180811
180811
  // src/utils/types.ts
180812
180812
  var import_typechain = __toESM(require_dist());
@@ -180823,7 +180823,7 @@ var import_promises = require("fs/promises");
180823
180823
  var import_ejs = __toESM(require_ejs());
180824
180824
  var import_path = __toESM(require("path"));
180825
180825
  var contractsDir = import_path.default.join(__dirname, "../../src/contracts");
180826
- var stubLibDeploy = (0, import_promises.readFile)(import_path.default.join(contractsDir, "LibDeploy.sol"));
180826
+ var stubLibDeploy = (0, import_promises.readFile)(import_path.default.join(contractsDir, "LibDeployStub.sol"));
180827
180827
 
180828
180828
  // src/utils/types.ts
180829
180829
  var import_typechain = __toESM(require_dist());
@@ -180810,7 +180810,7 @@ var import_promises = require("fs/promises");
180810
180810
  var import_ejs = __toESM(require_ejs());
180811
180811
  var import_path = __toESM(require("path"));
180812
180812
  var contractsDir = import_path.default.join(__dirname, "../../src/contracts");
180813
- var stubLibDeploy = (0, import_promises.readFile)(import_path.default.join(contractsDir, "LibDeploy.sol"));
180813
+ var stubLibDeploy = (0, import_promises.readFile)(import_path.default.join(contractsDir, "LibDeployStub.sol"));
180814
180814
 
180815
180815
  // src/utils/types.ts
180816
180816
  var import_typechain = __toESM(require_dist());
@@ -180819,7 +180819,7 @@ var import_promises = require("fs/promises");
180819
180819
  var import_ejs = __toESM(require_ejs());
180820
180820
  var import_path = __toESM(require("path"));
180821
180821
  var contractsDir = import_path.default.join(__dirname, "../../src/contracts");
180822
- var stubLibDeploy = (0, import_promises.readFile)(import_path.default.join(contractsDir, "LibDeploy.sol"));
180822
+ var stubLibDeploy = (0, import_promises.readFile)(import_path.default.join(contractsDir, "LibDeployStub.sol"));
180823
180823
  function generateLibDeploy(configPath, out, systems) {
180824
180824
  return __async(this, null, function* () {
180825
180825
  const config = JSON.parse(yield (0, import_promises.readFile)(configPath, { encoding: "utf8" }));
@@ -216210,7 +216210,7 @@ var import_promises = require("fs/promises");
216210
216210
  var import_ejs = __toESM(require_ejs());
216211
216211
  var import_path = __toESM(require("path"));
216212
216212
  var contractsDir = import_path.default.join(__dirname, "../../src/contracts");
216213
- var stubLibDeploy = (0, import_promises.readFile)(import_path.default.join(contractsDir, "LibDeploy.sol"));
216213
+ var stubLibDeploy = (0, import_promises.readFile)(import_path.default.join(contractsDir, "LibDeployStub.sol"));
216214
216214
 
216215
216215
  // src/utils/types.ts
216216
216216
  var import_typechain = __toESM(require_dist());
@@ -180825,7 +180825,7 @@ var import_promises = require("fs/promises");
180825
180825
  var import_ejs = __toESM(require_ejs());
180826
180826
  var import_path = __toESM(require("path"));
180827
180827
  var contractsDir = import_path.default.join(__dirname, "../../src/contracts");
180828
- var stubLibDeploy = (0, import_promises.readFile)(import_path.default.join(contractsDir, "LibDeploy.sol"));
180828
+ var stubLibDeploy = (0, import_promises.readFile)(import_path.default.join(contractsDir, "LibDeployStub.sol"));
180829
180829
 
180830
180830
  // src/utils/types.ts
180831
180831
  var import_typechain = __toESM(require_dist());
@@ -180850,7 +180850,7 @@ function copyAbi(inDir, outDir, contract) {
180850
180850
  try {
180851
180851
  return (0, import_fs2.copyFileSync)(import_path2.default.join(inDir, contract + ".sol", contract + ".json"), import_path2.default.join(outDir, contract + ".json"));
180852
180852
  } catch (e) {
180853
- console.warn(e);
180853
+ console.log("Skipping", contract);
180854
180854
  }
180855
180855
  }
180856
180856
  function filterAbi(abiIn = "./out", abiOut = "./abi", exclude = ["Component", "IComponent"]) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@latticexyz/cli",
3
- "version": "1.31.2",
3
+ "version": "1.31.3",
4
4
  "description": "Command line interface for mud",
5
5
  "main": "dist/index.js",
6
6
  "license": "MIT",
@@ -37,10 +37,10 @@
37
37
  "typescript": "^4.6.4"
38
38
  },
39
39
  "dependencies": {
40
- "@latticexyz/services": "^1.31.2",
41
- "@latticexyz/solecs": "^1.31.2",
42
- "@latticexyz/std-contracts": "^1.31.2",
43
- "@latticexyz/utils": "^1.31.2",
40
+ "@latticexyz/services": "^1.31.3",
41
+ "@latticexyz/solecs": "^1.31.3",
42
+ "@latticexyz/std-contracts": "^1.31.3",
43
+ "@latticexyz/utils": "^1.31.3",
44
44
  "@typechain/ethers-v5": "^10.1.1",
45
45
  "chalk": "^5.0.1",
46
46
  "chokidar": "^3.5.3",
@@ -70,5 +70,5 @@
70
70
  "pkg": {
71
71
  "scripts": "build/**/*.js"
72
72
  },
73
- "gitHead": "bdcbdd6cb1a056779b73307acce20eccc65ad062"
73
+ "gitHead": "637b7ffd31cdf0ba1256e17bc31fecf9030c2c57"
74
74
  }
@@ -21,6 +21,7 @@ export const builder: CommandBuilder<Options, Options> = (yargs) =>
21
21
  watch: { type: "boolean", desc: "Automatically redeploy changed systems" },
22
22
  dev: { type: "boolean", desc: "Automatically use funded dev private key for local development" },
23
23
  openUrl: { type: "string", desc: "Opens a browser at the provided url with the worldAddress url param prefilled" },
24
+ gasPrice: { type: "number", desc: "Gas price to set for deploy transactions" },
24
25
  });
25
26
 
26
27
  export const handler = async (args: Arguments<Options>): Promise<void> => {
@@ -30,9 +31,10 @@ export const handler = async (args: Arguments<Options>): Promise<void> => {
30
31
  }
31
32
 
32
33
  const deployerPrivateKey =
33
- args.deployerPrivateKey ?? args.dev
34
+ args.deployerPrivateKey ??
35
+ (args.dev
34
36
  ? "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" // Default anvil private key
35
- : undefined;
37
+ : undefined);
36
38
 
37
39
  // Deploy world, components and systems
38
40
  const { deployedWorldAddress: worldAddress, initialBlockNumber } = await generateAndDeploy({
@@ -50,7 +52,7 @@ export const handler = async (args: Arguments<Options>): Promise<void> => {
50
52
 
51
53
  // Set up watcher for system files to redeploy on change
52
54
  if (args.watch) {
53
- const { config, rpc } = args;
55
+ const { config, rpc, gasPrice } = args;
54
56
 
55
57
  hsr("./src", (systems: string[]) => {
56
58
  return generateAndDeploy({
@@ -59,6 +61,7 @@ export const handler = async (args: Arguments<Options>): Promise<void> => {
59
61
  worldAddress,
60
62
  rpc,
61
63
  systems,
64
+ gasPrice,
62
65
  });
63
66
  });
64
67
  } else {
@@ -0,0 +1,23 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity >=0.8.0;
3
+
4
+ // NOTE: THIS IS A STUB TO MAKE IMPORTS WORK.
5
+ // The real LibDeploy.sol is generated automatically
6
+ // when calling `mud test` or `mud deploy-contracts`.
7
+ // To manually generate the real LibDeploy.sol use
8
+ // `mud codegen-libdeploy`.
9
+
10
+ import {IWorld} from "solecs/interfaces/IWorld.sol";
11
+
12
+ struct DeployResult {
13
+ IWorld world;
14
+ address deployer;
15
+ }
16
+
17
+ library LibDeploy {
18
+ function deploy(
19
+ address _deployer,
20
+ address _world,
21
+ bool _reuseComponents
22
+ ) internal returns (DeployResult memory result) {}
23
+ }
@@ -21,7 +21,7 @@ function copyAbi(inDir: string, outDir: string, contract: string) {
21
21
  try {
22
22
  return copyFileSync(path.join(inDir, contract + ".sol", contract + ".json"), path.join(outDir, contract + ".json"));
23
23
  } catch (e) {
24
- console.warn(e);
24
+ console.log("Skipping", contract);
25
25
  }
26
26
  }
27
27
 
@@ -4,8 +4,15 @@ import path from "path";
4
4
 
5
5
  const contractsDir = path.join(__dirname, "../../src/contracts");
6
6
 
7
- const stubLibDeploy = readFile(path.join(contractsDir, "LibDeploy.sol"));
8
-
7
+ const stubLibDeploy = readFile(path.join(contractsDir, "LibDeployStub.sol"));
8
+
9
+ /**
10
+ * Generate LibDeploy.sol from deploy.json
11
+ * @param configPath path to deploy.json
12
+ * @param out output directory for LibDeploy.sol
13
+ * @param systems optional, only generate deploy code for the given systems
14
+ * @returns path to generated LibDeploy.sol
15
+ */
9
16
  export async function generateLibDeploy(configPath: string, out: string, systems?: string | string[]) {
10
17
  // Parse config
11
18
  const config = JSON.parse(await readFile(configPath, { encoding: "utf8" }));
@@ -3,17 +3,38 @@ import { generateLibDeploy, resetLibDeploy } from "./codegen";
3
3
  import { findLog } from "./findLog";
4
4
  import { generateTypes } from "./types";
5
5
  import { execa } from "execa";
6
+ import { StaticJsonRpcProvider } from "@ethersproject/providers";
6
7
 
7
8
  const contractsDir = __dirname + "/../../src/contracts";
8
9
 
10
+ /**
11
+ * Deploy world, components and systems from deploy.json
12
+ * @param deployerPrivateKey private key of deployer
13
+ * @param rpc rpc url
14
+ * @param worldAddress optional, address of existing world
15
+ * @param reuseComponents optional, reuse existing components
16
+ * @returns address of deployed world
17
+ */
9
18
  export async function deploy(
10
19
  deployerPrivateKey?: string,
11
20
  rpc = "http://localhost:8545",
12
21
  worldAddress?: string,
13
- reuseComponents?: boolean
22
+ reuseComponents?: boolean,
23
+ gasPrice?: number
14
24
  ) {
15
25
  const address = deployerPrivateKey ? new Wallet(deployerPrivateKey).address : constants.AddressZero;
16
26
 
27
+ if (gasPrice == null) {
28
+ try {
29
+ console.log("Fetching gas price...");
30
+ const provider = new StaticJsonRpcProvider(rpc, { name: "AnyNetwork", chainId: 1234 });
31
+ gasPrice = (await provider.getGasPrice()).toNumber() * 1.3; // 30% multiplier for faster inclusion
32
+ console.log("Gas price:", gasPrice);
33
+ } catch (e) {
34
+ console.log("Could not fetch gas price");
35
+ }
36
+ }
37
+
17
38
  const child = execa(
18
39
  "forge",
19
40
  [
@@ -30,10 +51,12 @@ export async function deploy(
30
51
  reuseComponents ? "true" : "false", // Reuse components?
31
52
  "--fork-url",
32
53
  rpc,
54
+ ...(gasPrice != null ? ["--with-gas-price", String(gasPrice)] : []),
33
55
  ],
34
- { stdio: ["inherit", "pipe", "inherit"] }
56
+ { stdio: ["inherit", "pipe", "pipe"] }
35
57
  );
36
58
 
59
+ child.stderr?.on("data", (data) => console.log("stderr:", data.toString()));
37
60
  child.stdout?.on("data", (data) => console.log(data.toString()));
38
61
 
39
62
  // Extract world address from deploy script
@@ -51,6 +74,7 @@ export type DeployOptions = {
51
74
  rpc: string;
52
75
  systems?: string | string[];
53
76
  clear?: boolean;
77
+ gasPrice?: number;
54
78
  };
55
79
 
56
80
  export async function generateAndDeploy(args: DeployOptions) {
@@ -66,7 +90,13 @@ export async function generateAndDeploy(args: DeployOptions) {
66
90
  await generateTypes(undefined, "./types", { clear: args.clear });
67
91
 
68
92
  // Call deploy script
69
- const result = await deploy(args.deployerPrivateKey, args.rpc, args.worldAddress, Boolean(args.systems));
93
+ const result = await deploy(
94
+ args.deployerPrivateKey,
95
+ args.rpc,
96
+ args.worldAddress,
97
+ Boolean(args.systems),
98
+ args.gasPrice
99
+ );
70
100
  deployedWorldAddress = result.deployedWorldAddress;
71
101
  initialBlockNumber = result.initialBlockNumber;
72
102
 
@@ -76,7 +106,7 @@ export async function generateAndDeploy(args: DeployOptions) {
76
106
  } finally {
77
107
  // Remove generated LibDeploy
78
108
  console.log("Cleaning up deployment script");
79
- if (libDeployPath) resetLibDeploy(contractsDir);
109
+ if (libDeployPath) await resetLibDeploy(contractsDir);
80
110
  }
81
111
 
82
112
  return { deployedWorldAddress, initialBlockNumber };