@openzeppelin/wizard-stellar 0.4.4 → 0.5.0

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.
Files changed (64) hide show
  1. package/dist/add-pausable.d.ts +1 -1
  2. package/dist/add-pausable.d.ts.map +1 -1
  3. package/dist/add-pausable.js +8 -8
  4. package/dist/add-pausable.js.map +1 -1
  5. package/dist/add-upgradeable.d.ts +1 -1
  6. package/dist/add-upgradeable.d.ts.map +1 -1
  7. package/dist/add-upgradeable.js +2 -2
  8. package/dist/add-upgradeable.js.map +1 -1
  9. package/dist/common-options.d.ts +1 -0
  10. package/dist/common-options.d.ts.map +1 -1
  11. package/dist/common-options.js +2 -0
  12. package/dist/common-options.js.map +1 -1
  13. package/dist/contract.d.ts +2 -0
  14. package/dist/contract.d.ts.map +1 -1
  15. package/dist/contract.js +7 -0
  16. package/dist/contract.js.map +1 -1
  17. package/dist/fungible.d.ts.map +1 -1
  18. package/dist/fungible.js +38 -23
  19. package/dist/fungible.js.map +1 -1
  20. package/dist/generate/fungible.d.ts.map +1 -1
  21. package/dist/generate/fungible.js +1 -0
  22. package/dist/generate/fungible.js.map +1 -1
  23. package/dist/generate/non-fungible.d.ts.map +1 -1
  24. package/dist/generate/non-fungible.js +1 -0
  25. package/dist/generate/non-fungible.js.map +1 -1
  26. package/dist/generate/stablecoin.d.ts.map +1 -1
  27. package/dist/generate/stablecoin.js +1 -0
  28. package/dist/generate/stablecoin.js.map +1 -1
  29. package/dist/non-fungible.d.ts +1 -1
  30. package/dist/non-fungible.d.ts.map +1 -1
  31. package/dist/non-fungible.js +80 -41
  32. package/dist/non-fungible.js.map +1 -1
  33. package/dist/set-access-control.d.ts +2 -2
  34. package/dist/set-access-control.d.ts.map +1 -1
  35. package/dist/set-access-control.js +113 -10
  36. package/dist/set-access-control.js.map +1 -1
  37. package/dist/stablecoin.d.ts +2 -1
  38. package/dist/stablecoin.d.ts.map +1 -1
  39. package/dist/stablecoin.js +27 -6
  40. package/dist/stablecoin.js.map +1 -1
  41. package/dist/utils/compile-test.d.ts +1 -0
  42. package/dist/utils/compile-test.d.ts.map +1 -1
  43. package/dist/utils/compile-test.js +19 -5
  44. package/dist/utils/compile-test.js.map +1 -1
  45. package/dist/utils/version.d.ts +4 -4
  46. package/dist/utils/version.js +3 -3
  47. package/dist/zip-rust.d.ts.map +1 -1
  48. package/dist/zip-rust.js +4 -0
  49. package/dist/zip-rust.js.map +1 -1
  50. package/package.json +3 -3
  51. package/src/add-pausable.ts +29 -15
  52. package/src/add-upgradeable.ts +13 -6
  53. package/src/common-options.ts +3 -0
  54. package/src/contract.ts +9 -0
  55. package/src/fungible.ts +57 -29
  56. package/src/generate/fungible.ts +1 -0
  57. package/src/generate/non-fungible.ts +1 -0
  58. package/src/generate/stablecoin.ts +1 -0
  59. package/src/non-fungible.ts +121 -45
  60. package/src/set-access-control.ts +113 -9
  61. package/src/stablecoin.ts +39 -9
  62. package/src/utils/compile-test.ts +52 -25
  63. package/src/utils/version.ts +3 -3
  64. package/src/zip-rust.ts +5 -0
@@ -1,14 +1,14 @@
1
- import { tmpdir } from 'os';
2
1
  import type { ExecutionContext } from 'ava';
2
+ import { exec } from 'child_process';
3
+ import { mkdir, mkdtemp, rm } from 'fs/promises';
4
+ import { tmpdir } from 'os';
3
5
  import path from 'path';
4
6
  import { promisify } from 'util';
5
- import { exec } from 'child_process';
6
7
  import type { GenericOptions } from '../build-generic';
7
8
  import type { Contract } from '../contract';
8
- import { assertLayout, snapshotZipContents, expandPathsFromFilesPaths, extractPackage } from './zip-test';
9
- import { mkdtemp, rm } from 'fs/promises';
10
- import { contractOptionsToContractName } from '../zip-shared';
11
9
  import { zipRustProject } from '../zip-rust';
10
+ import { contractOptionsToContractName } from '../zip-shared';
11
+ import { assertLayout, expandPathsFromFilesPaths, extractPackage, snapshotZipContents } from './zip-test';
12
12
 
13
13
  const asyncExec = promisify(exec);
14
14
 
@@ -29,7 +29,6 @@ export const withTemporaryFolderDo =
29
29
  (...testFunctionArguments: Args) =>
30
30
  async (test: ExecutionContext) => {
31
31
  const temporaryFolder = await mkdtemp(path.join(tmpdir(), `compilation-test-${crypto.randomUUID()}`));
32
-
33
32
  try {
34
33
  await testFunction(...testFunctionArguments, test, temporaryFolder);
35
34
  } finally {
@@ -37,33 +36,61 @@ export const withTemporaryFolderDo =
37
36
  }
38
37
  };
39
38
 
39
+ const doRunRustCompilationTest = async (
40
+ makeContract: MakeContract,
41
+ opts: GenericOptions,
42
+ testOptions: { snapshotResult: boolean },
43
+ test: ExecutionContext,
44
+ folderPath: string,
45
+ ) => {
46
+ test.timeout(3_000_000);
47
+
48
+ await mkdir(folderPath, { recursive: true });
49
+
50
+ const scaffoldContractName = contractOptionsToContractName(opts?.kind || 'contract');
51
+
52
+ const expectedZipFiles = [
53
+ `contracts/${scaffoldContractName}/src/contract.rs`,
54
+ `contracts/${scaffoldContractName}/src/test.rs`,
55
+ `contracts/${scaffoldContractName}/src/lib.rs`,
56
+ `contracts/${scaffoldContractName}/Cargo.toml`,
57
+ 'Cargo.toml',
58
+ '.gitignore',
59
+ 'README.md',
60
+ ];
61
+
62
+ const zip = await zipRustProject(makeContract(opts), opts);
63
+
64
+ assertLayout(test, zip, expandPathsFromFilesPaths(expectedZipFiles));
65
+ await extractPackage(zip, folderPath);
66
+ await runCargoTest(test, folderPath);
67
+
68
+ if (testOptions.snapshotResult) await snapshotZipContents(test, zip, expectedZipFiles);
69
+ };
70
+
40
71
  export const runRustCompilationTest = withTemporaryFolderDo(
41
72
  async (
42
73
  makeContract: MakeContract,
43
74
  opts: GenericOptions,
44
- testOptions: { snapshotResult: boolean },
75
+ testOptions: { snapshotResult: boolean; excludeExplicitTraitTest?: boolean },
45
76
  test: ExecutionContext,
46
77
  folderPath: string,
47
78
  ) => {
48
- test.timeout(3_000_000);
79
+ await doRunRustCompilationTest(makeContract, opts, testOptions, test, `${folderPath}/default`);
49
80
 
50
- const scaffoldContractName = contractOptionsToContractName(opts?.kind || 'contract');
81
+ const shouldBeExcludedOrHasAlreadyRun = testOptions.excludeExplicitTraitTest || opts.explicitImplementations;
82
+ if (shouldBeExcludedOrHasAlreadyRun) return;
51
83
 
52
- const expectedZipFiles = [
53
- `contracts/${scaffoldContractName}/src/contract.rs`,
54
- `contracts/${scaffoldContractName}/src/test.rs`,
55
- `contracts/${scaffoldContractName}/src/lib.rs`,
56
- `contracts/${scaffoldContractName}/Cargo.toml`,
57
- 'Cargo.toml',
58
- 'README.md',
59
- ];
60
-
61
- const zip = await zipRustProject(makeContract(opts), opts);
62
-
63
- assertLayout(test, zip, expandPathsFromFilesPaths(expectedZipFiles));
64
- await extractPackage(zip, folderPath);
65
- await runCargoTest(test, folderPath);
66
-
67
- if (testOptions.snapshotResult) await snapshotZipContents(test, zip, expectedZipFiles);
84
+ try {
85
+ await doRunRustCompilationTest(
86
+ makeContract,
87
+ { ...opts, explicitImplementations: true },
88
+ testOptions,
89
+ test,
90
+ `${folderPath}/explicit`,
91
+ );
92
+ } catch (error) {
93
+ throw new Error(`EXPLICIT IMPLEMENTATION ERROR: ${error}`);
94
+ }
68
95
  },
69
96
  );
@@ -1,15 +1,15 @@
1
1
  /**
2
2
  * The actual latest version to use in links.
3
3
  */
4
- export const contractsVersion = '0.4.1';
4
+ export const contractsVersion = '0.6.0';
5
5
  export const contractsVersionTag = `v${contractsVersion}`;
6
6
 
7
7
  /**
8
8
  * Semantic version string representing of the minimum compatible version of Contracts to display in output.
9
9
  */
10
- export const compatibleContractsSemver = '^0.4.1';
10
+ export const compatibleContractsSemver = '^0.6.0';
11
11
 
12
12
  /**
13
13
  * The Soroban version for which compilation and testing have passing tests
14
14
  */
15
- export const compatibleSorobanVersion = '22.0.8';
15
+ export const compatibleSorobanVersion = '23.4.0';
package/src/zip-rust.ts CHANGED
@@ -25,6 +25,10 @@ Continue your development journey with [Stellar CLI](https://github.com/stellar/
25
25
  - See [Git installation guide](https://github.com/git-guides/install-git).
26
26
  `;
27
27
 
28
+ const gitIgnore = `\
29
+ target/
30
+ `;
31
+
28
32
  export const createRustZipEnvironment = (c: Contract, opts: GenericOptions) => {
29
33
  const zip = new JSZip();
30
34
 
@@ -35,6 +39,7 @@ export const createRustZipEnvironment = (c: Contract, opts: GenericOptions) => {
35
39
  zip.file(`contracts/${contractName}/src/lib.rs`, createRustLibFile);
36
40
  zip.file(`contracts/${contractName}/Cargo.toml`, printContractCargo(contractName));
37
41
  zip.file('Cargo.toml', workspaceCargo);
42
+ zip.file('.gitignore', gitIgnore);
38
43
 
39
44
  return zip;
40
45
  };