@alephium/web3 0.31.0 → 0.31.2

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.
@@ -221,6 +221,22 @@ class ProjectArtifact {
221
221
  }
222
222
  exports.ProjectArtifact = ProjectArtifact;
223
223
  ProjectArtifact.artifactFileName = '.project.json';
224
+ function removeOldArtifacts(dir) {
225
+ const files = fs_1.default.readdirSync(dir);
226
+ files.forEach((file) => {
227
+ const filePath = path.join(dir, file);
228
+ const stat = fs_1.default.statSync(filePath);
229
+ if (stat.isDirectory()) {
230
+ removeOldArtifacts(filePath);
231
+ }
232
+ else if (filePath.endsWith('.ral.json') || filePath.endsWith('.ral')) {
233
+ fs_1.default.unlinkSync(filePath);
234
+ }
235
+ });
236
+ if (fs_1.default.readdirSync(dir).length === 0) {
237
+ fs_1.default.rmdirSync(dir);
238
+ }
239
+ }
224
240
  class Project {
225
241
  static buildProjectArtifact(fullNodeVersion, sourceInfos, contracts, scripts, compilerOptions) {
226
242
  const files = new Map();
@@ -491,6 +507,9 @@ class Project {
491
507
  const projectArtifact = await ProjectArtifact.from(projectRootDir);
492
508
  if (projectArtifact === undefined ||
493
509
  projectArtifact.needToReCompile(nodeCompilerOptions, sourceFiles, fullNodeVersion)) {
510
+ if (fs_1.default.existsSync(artifactsRootDir)) {
511
+ removeOldArtifacts(artifactsRootDir);
512
+ }
494
513
  console.log(`Compiling contracts in folder "${contractsRootDir}"`);
495
514
  Project.currentProject = await Project.compile(fullNodeVersion, provider, sourceFiles, projectRootDir, contractsRootDir, artifactsRootDir, errorOnWarnings, nodeCompilerOptions);
496
515
  }
@@ -1031,7 +1050,6 @@ exports.ExecutableScript = ExecutableScript;
1031
1050
  function specialContractAddress(n) {
1032
1051
  const bytes = new Uint8Array(32).fill(0);
1033
1052
  bytes[31] = n;
1034
- console.log(utils_1.addressFromContractId);
1035
1053
  return (0, utils_1.addressFromContractId)((0, utils_1.binToHex)(bytes));
1036
1054
  }
1037
1055
  exports.CreateContractEventAddress = specialContractAddress(-1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alephium/web3",
3
- "version": "0.31.0",
3
+ "version": "0.31.2",
4
4
  "description": "A JS/TS library to interact with the Alephium platform",
5
5
  "license": "GPL",
6
6
  "main": "dist/src/index.js",
@@ -309,6 +309,23 @@ export class ProjectArtifact {
309
309
  }
310
310
  }
311
311
 
312
+ function removeOldArtifacts(dir: string) {
313
+ const files = fs.readdirSync(dir)
314
+ files.forEach((file) => {
315
+ const filePath = path.join(dir, file)
316
+ const stat = fs.statSync(filePath)
317
+ if (stat.isDirectory()) {
318
+ removeOldArtifacts(filePath)
319
+ } else if (filePath.endsWith('.ral.json') || filePath.endsWith('.ral')) {
320
+ fs.unlinkSync(filePath)
321
+ }
322
+ })
323
+
324
+ if (fs.readdirSync(dir).length === 0) {
325
+ fs.rmdirSync(dir)
326
+ }
327
+ }
328
+
312
329
  export class Project {
313
330
  sourceInfos: SourceInfo[]
314
331
  contracts: Map<string, Compiled<Contract>>
@@ -731,6 +748,9 @@ export class Project {
731
748
  projectArtifact === undefined ||
732
749
  projectArtifact.needToReCompile(nodeCompilerOptions, sourceFiles, fullNodeVersion)
733
750
  ) {
751
+ if (fs.existsSync(artifactsRootDir)) {
752
+ removeOldArtifacts(artifactsRootDir)
753
+ }
734
754
  console.log(`Compiling contracts in folder "${contractsRootDir}"`)
735
755
  Project.currentProject = await Project.compile(
736
756
  fullNodeVersion,
@@ -1575,7 +1595,6 @@ export interface CallContractResult<R> {
1575
1595
  function specialContractAddress(n: number): string {
1576
1596
  const bytes = new Uint8Array(32).fill(0)
1577
1597
  bytes[31] = n
1578
- console.log(addressFromContractId)
1579
1598
  return addressFromContractId(binToHex(bytes))
1580
1599
  }
1581
1600