@openzeppelin/wizard-stellar 0.2.3 → 0.4.1

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 (87) hide show
  1. package/dist/add-pausable.d.ts.map +1 -1
  2. package/dist/add-pausable.js +29 -8
  3. package/dist/add-pausable.js.map +1 -1
  4. package/dist/add-upgradeable.d.ts.map +1 -1
  5. package/dist/add-upgradeable.js +14 -4
  6. package/dist/add-upgradeable.js.map +1 -1
  7. package/dist/api.d.ts +5 -2
  8. package/dist/api.d.ts.map +1 -1
  9. package/dist/api.js +9 -1
  10. package/dist/api.js.map +1 -1
  11. package/dist/build-generic.d.ts +5 -1
  12. package/dist/build-generic.d.ts.map +1 -1
  13. package/dist/build-generic.js +3 -0
  14. package/dist/build-generic.js.map +1 -1
  15. package/dist/contract.d.ts +1 -1
  16. package/dist/contract.d.ts.map +1 -1
  17. package/dist/contract.js +9 -1
  18. package/dist/contract.js.map +1 -1
  19. package/dist/fungible.d.ts +5 -2
  20. package/dist/fungible.d.ts.map +1 -1
  21. package/dist/fungible.js +86 -55
  22. package/dist/fungible.js.map +1 -1
  23. package/dist/generate/sources.d.ts.map +1 -1
  24. package/dist/generate/sources.js +6 -0
  25. package/dist/generate/sources.js.map +1 -1
  26. package/dist/generate/stablecoin.d.ts +3 -0
  27. package/dist/generate/stablecoin.d.ts.map +1 -0
  28. package/dist/generate/stablecoin.js +24 -0
  29. package/dist/generate/stablecoin.js.map +1 -0
  30. package/dist/index.d.ts +2 -0
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +3 -1
  33. package/dist/index.js.map +1 -1
  34. package/dist/kind.js +1 -0
  35. package/dist/kind.js.map +1 -1
  36. package/dist/non-fungible.d.ts +1 -0
  37. package/dist/non-fungible.d.ts.map +1 -1
  38. package/dist/non-fungible.js +101 -81
  39. package/dist/non-fungible.js.map +1 -1
  40. package/dist/print.js +5 -5
  41. package/dist/print.js.map +1 -1
  42. package/dist/set-access-control.d.ts +7 -4
  43. package/dist/set-access-control.d.ts.map +1 -1
  44. package/dist/set-access-control.js +57 -15
  45. package/dist/set-access-control.js.map +1 -1
  46. package/dist/stablecoin.d.ts +11 -0
  47. package/dist/stablecoin.d.ts.map +1 -0
  48. package/dist/stablecoin.js +103 -0
  49. package/dist/stablecoin.js.map +1 -0
  50. package/dist/utils/define-functions.d.ts +4 -2
  51. package/dist/utils/define-functions.d.ts.map +1 -1
  52. package/dist/utils/define-functions.js +7 -1
  53. package/dist/utils/define-functions.js.map +1 -1
  54. package/dist/utils/version.d.ts +3 -3
  55. package/dist/utils/version.js +2 -2
  56. package/dist/zip-rust.d.ts +2 -1
  57. package/dist/zip-rust.d.ts.map +1 -1
  58. package/dist/zip-rust.js +8 -5
  59. package/dist/zip-rust.js.map +1 -1
  60. package/dist/zip-scaffold.d.ts +2 -2
  61. package/dist/zip-scaffold.d.ts.map +1 -1
  62. package/dist/zip-scaffold.js +14 -158
  63. package/dist/zip-scaffold.js.map +1 -1
  64. package/dist/zip-shared.d.ts +4 -17
  65. package/dist/zip-shared.d.ts.map +1 -1
  66. package/dist/zip-shared.js +25 -19
  67. package/dist/zip-shared.js.map +1 -1
  68. package/package.json +1 -1
  69. package/src/add-pausable.ts +31 -9
  70. package/src/add-upgradeable.ts +17 -5
  71. package/src/api.ts +27 -4
  72. package/src/build-generic.ts +6 -0
  73. package/src/contract.ts +9 -2
  74. package/src/fungible.ts +90 -61
  75. package/src/generate/sources.ts +7 -0
  76. package/src/generate/stablecoin.ts +23 -0
  77. package/src/index.ts +2 -0
  78. package/src/kind.ts +1 -0
  79. package/src/non-fungible.ts +108 -87
  80. package/src/print.ts +5 -5
  81. package/src/set-access-control.ts +72 -19
  82. package/src/stablecoin.ts +124 -0
  83. package/src/utils/define-functions.ts +11 -4
  84. package/src/utils/version.ts +2 -2
  85. package/src/zip-rust.ts +10 -6
  86. package/src/zip-scaffold.ts +15 -169
  87. package/src/zip-shared.ts +26 -22
@@ -1,129 +1,13 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.zipScaffold = zipScaffold;
7
- const jszip_1 = __importDefault(require("jszip"));
8
- const print_1 = require("./print");
9
- const version_1 = require("./utils/version");
10
- const zip_shared_1 = require("./zip-shared");
11
- function getAddressArgs(c) {
12
- return c.constructorArgs
13
- .filter(constructorArg => { var _a; return ((_a = constructorArg.type) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'address'; })
14
- .map(constructorArg => constructorArg.name);
15
- }
16
- const setupSh = (c, opts, scaffoldContractName) => {
17
- const environmentsFileUpdate = (setUpContract, setUpScaffoldContractName) => `
18
- # Update environments.toml: remove original contracts and insert wizard's contract
19
- setup_environment() {
20
- local file="environments.toml"
21
- local temp
22
- temp="$(mktemp)"
23
-
24
- local in_dev_contracts=0
25
- local skip_entry=0
26
- local contract_entry_inserted=0
27
- insert_contract_entry() {
28
- {
29
- printf '%s\\n' "[development.contracts.${setUpScaffoldContractName}_contract]" \\
30
- "client = true" "" \\
31
- "# If your contract has a \\\`__constructor\\\`, specify your arguments to it here." \\
32
- "# These are the same arguments you could pass after the \\\`--\\\` in a call to" \\
33
- "# \\\`stellar contract deploy\\\`" \\
34
- "# Only available in \\\`development\\\` and \\\`test\\\` environments" \\
35
- ${setUpContract.constructorArgs.length
36
- ? // Mind the spacing
37
- `"# TODO add appropriate values for for the constructors arguments" \\
38
- "constructor_args = \\"\\"\\"" \\
39
- "${setUpContract.constructorArgs.map(constructorArg => { var _a; return `--${constructorArg.name} \\"ADD_${constructorArg.name.toLocaleUpperCase()}_${((_a = constructorArg.type) === null || _a === void 0 ? void 0 : _a.toLocaleUpperCase()) || 'ARGUMENT'}_HERE\\"`; }).join(' ')}" \\
40
- "\\"\\"\\"" \\
41
- ""`
42
- : '""'}
43
- } >> "$temp"
44
- }
45
-
46
- while IFS= read -r line; do
47
- if [[ $contract_entry_inserted -eq 0 && $line == '[staging.network]' ]]; then
48
- insert_contract_entry
49
- contract_entry_inserted=1
50
- fi
51
-
52
- if [[ $line =~ ^\\[development\\.contracts\\]$ ]]; then
53
- printf '%s\\n' "$line" >> "$temp"
54
- in_dev_contracts=1
55
- skip_entry=0
56
- continue
57
- fi
58
-
59
- if [[ $line =~ ^\\[[^]]+\\]$ ]]; then
60
- if (( in_dev_contracts )) && [[ $line =~ ^\\[development\\.contracts\\..+\\]$ ]]; then
61
- skip_entry=1
62
- in_dev_contracts=0
63
- continue
64
- fi
65
- in_dev_contracts=0
66
- skip_entry=0
67
- printf '%s\\n' "$line" >> "$temp"
68
- continue
69
- fi
70
-
71
- if (( skip_entry )); then
72
- continue
73
- fi
74
-
75
- if (( in_dev_contracts )); then
76
- if [[ $line =~ ^[[:space:]]*# ]]; then
77
- printf '%s\\n' "$line" >> "$temp"
78
- fi
79
- continue
80
- fi
81
-
82
- printf '%s\\n' "$line" >> "$temp"
83
- done < "$file"
84
-
85
- mv "$temp" "$file"
86
- }
87
- `;
88
- const updateWorkspaceCargo = `update_cargo() {
89
- cp Cargo.toml Cargo.toml.bak
90
-
91
- cat <<EOF > deps.tmp
92
- ${(0, zip_shared_1.addDependenciesWith)(`{ git = "https://github.com/OpenZeppelin/stellar-contracts", tag = "${version_1.contractsVersionTag}" }`, zip_shared_1.allStellarDependencies)}${(0, zip_shared_1.addDependenciesWith)(`{ version = "${version_1.compatibleSorobanVersion}" }`, ['soroban'])}
93
- EOF
94
-
95
- awk '
96
- BEGIN {
97
- inserted = 0
98
- deps = ""
99
- while ((getline line < "deps.tmp") > 0) {
100
- deps = deps line "\\n"
101
- }
102
- close("deps.tmp")
103
- }
104
- /^\\[workspace.dependencies\\]/ {
105
- in_deps = 1
106
- print
107
- if (!inserted) {
108
- printf "%s", deps
109
- inserted = 1
110
- }
111
- next
112
- }
113
- /^\\[/ { in_deps = 0 }
114
- in_deps { next }
115
- { print }
116
- ' Cargo.toml.bak > Cargo.toml
117
-
118
- rm deps.tmp
119
- rm Cargo.toml.bak
120
- }`;
121
- return `\
3
+ exports.zipScaffoldProject = void 0;
4
+ const zip_rust_1 = require("./zip-rust");
5
+ const setupSh = `\
122
6
  #!/usr/bin/env bash
123
7
  #
124
8
  # setup.sh
125
- #
126
- # This script is meant to set up a Scaffold project and insert the Wizard's contracts in the project
9
+ #
10
+ # This script is meant to set up a Scaffold project with the Wizard's contracts
127
11
 
128
12
  check_is_installed() {
129
13
  if ! which "$1" &> /dev/null; then
@@ -134,18 +18,7 @@ check_is_installed() {
134
18
  }
135
19
 
136
20
  scaffold() {
137
- tmp_folder="tmp"
138
- stellar scaffold init "$tmp_folder"
139
-
140
- rm -rf "$tmp_folder/contracts"
141
-
142
- local current_directory
143
- current_directory="$(cd "$(dirname "\${BASH_SOURCE[0]}")" && pwd)"
144
-
145
- shopt -s dotglob
146
-
147
- cp -a "$current_directory/$tmp_folder"/. "$current_directory"/
148
- rm -rf "$current_directory/$tmp_folder"
21
+ stellar-scaffold upgrade
149
22
  }
150
23
 
151
24
  init_git(){
@@ -154,10 +27,6 @@ init_git(){
154
27
  git commit -m "openzeppelin: add wizard output" --quiet
155
28
  }
156
29
 
157
- ${environmentsFileUpdate(c, scaffoldContractName)}
158
-
159
- ${updateWorkspaceCargo}
160
-
161
30
  build_contracts() {
162
31
  cargo build
163
32
  }
@@ -187,10 +56,6 @@ then
187
56
  echo "🏗️ Building Scaffold project"
188
57
 
189
58
  scaffold
190
-
191
- setup_environment
192
-
193
- update_cargo
194
59
 
195
60
  build_contracts
196
61
 
@@ -203,13 +68,10 @@ else
203
68
  echo "✅ Scaffold project already initialized."
204
69
  fi
205
70
  `;
206
- };
207
- const readme = (c) => {
208
- const hasTodosToResolve = (c) => getAddressArgs(c).length > 0;
209
- return `\
71
+ const wizardReadme = `\
210
72
  # Sample Scaffold Project
211
73
 
212
- This project demonstrates a basic Scaffold use case. It comes with a contract generated by [OpenZeppelin Wizard](https://wizard.openzeppelin.com/), a test for that contract, and a script that initiate a Stellar Scaffold project with this contract. [Scaffold Stellar](https://github.com/AhaLabs/scaffold-stellar?tab=readme-ov-file#scaffold-stellar) is a convention-over-configuration toolkit for blockchain and distributed application development on the Stellar network. It provides a seamless development experience through CLI tools, smart contract management, and deployment utilities.
74
+ This project demonstrates a basic Scaffold use case. It comes with a contract generated by [OpenZeppelin Wizard](https://wizard.openzeppelin.com/), a test for that contract, and a script that initiates a Stellar Scaffold project with this contract. [Scaffold Stellar](https://github.com/AhaLabs/scaffold-stellar?tab=readme-ov-file#scaffold-stellar) is a convention-over-configuration toolkit for blockchain and distributed application development on the Stellar network. It provides a seamless development experience through CLI tools, smart contract management, and deployment utilities.
213
75
 
214
76
  ## Installing dependencies
215
77
 
@@ -224,7 +86,6 @@ This project demonstrates a basic Scaffold use case. It comes with a contract ge
224
86
  \`\`\`
225
87
  bash setup.sh
226
88
  \`\`\`
227
- ${hasTodosToResolve(c) ? '\n## Resolve any TODOs \n\nSearch for any TODO comments in the project and resolve them (search for TODO with your code editor).\n' : ''}
228
89
 
229
90
  ## Testing the contract
230
91
 
@@ -244,16 +105,11 @@ stellar scaffold watch --build-clients
244
105
  npm run dev
245
106
  \`\`\`
246
107
  `;
247
- };
248
- async function zipScaffold(c, opts) {
249
- const zip = new jszip_1.default();
250
- const scaffoldContractName = (0, zip_shared_1.contractOptionsToContractName)((opts === null || opts === void 0 ? void 0 : opts.kind) || 'contract');
251
- zip.file(`contracts/${scaffoldContractName}/src/contract.rs`, (0, print_1.removeCreateLevelAttributes)((0, print_1.printContract)(c)));
252
- zip.file(`contracts/${scaffoldContractName}/src/test.rs`, (0, zip_shared_1.printRustNameTest)(c));
253
- zip.file(`contracts/${scaffoldContractName}/src/lib.rs`, zip_shared_1.createRustLibFile);
254
- zip.file(`contracts/${scaffoldContractName}/Cargo.toml`, (0, zip_shared_1.printContractCargo)(scaffoldContractName));
255
- zip.file('setup.sh', setupSh(c, opts, scaffoldContractName));
256
- zip.file('README-WIZARD.md', readme(c));
108
+ const addScaffoldProjectFiles = (zip) => {
109
+ zip.file('README-WIZARD.md', wizardReadme);
110
+ zip.file('setup.sh', setupSh);
257
111
  return zip;
258
- }
112
+ };
113
+ const zipScaffoldProject = async (c, opts) => addScaffoldProjectFiles((0, zip_rust_1.createRustZipEnvironment)(c, opts));
114
+ exports.zipScaffoldProject = zipScaffoldProject;
259
115
  //# sourceMappingURL=zip-scaffold.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"zip-scaffold.js","sourceRoot":"","sources":["../src/zip-scaffold.ts"],"names":[],"mappings":";;;;;AAmQA,kCAaC;AAhRD,kDAA0B;AAG1B,mCAAqE;AACrE,6CAAgF;AAChF,6CAOsB;AAEtB,SAAS,cAAc,CAAC,CAAW;IACjC,OAAO,CAAC,CAAC,eAAe;SACrB,MAAM,CAAC,cAAc,CAAC,EAAE,WAAC,OAAA,CAAA,MAAA,cAAc,CAAC,IAAI,0CAAE,WAAW,EAAE,MAAK,SAAS,CAAA,EAAA,CAAC;SAC1E,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,OAAO,GAAG,CAAC,CAAW,EAAE,IAAoB,EAAE,oBAA4B,EAAE,EAAE;IAClF,MAAM,sBAAsB,GAAG,CAAC,aAAuB,EAAE,yBAAiC,EAAE,EAAE,CAAC;;;;;;;;;;;;+CAYlD,yBAAyB;;;;;;UAO9D,aAAa,CAAC,eAAe,CAAC,MAAM;QAClC,CAAC,CAAC,mBAAmB;YACnB;;WAEH,aAAa,CAAC,eAAe,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE,WAAC,OAAA,KAAK,cAAc,CAAC,IAAI,WAAW,cAAc,CAAC,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAA,MAAA,cAAc,CAAC,IAAI,0CAAE,iBAAiB,EAAE,KAAI,UAAU,UAAU,CAAA,EAAA,CAAC,CAAC,IAAI,CAAC,GAAG,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AAI,CAAC,aAAa,oBAAoB,cAAc,EAAE,IAAA,8BAAiB,EAAC,CAAC,CAAC,CAAC,CAAC;IAChF,GAAG,CAAC,IAAI,CAAC,aAAa,oBAAoB,aAAa,EAAE,8BAAiB,CAAC,CAAC;IAC5E,GAAG,CAAC,IAAI,CAAC,aAAa,oBAAoB,aAAa,EAAE,IAAA,+BAAkB,EAAC,oBAAoB,CAAC,CAAC,CAAC;IACnG,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,oBAAoB,CAAC,CAAC,CAAC;IAC7D,GAAG,CAAC,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAExC,OAAO,GAAG,CAAC;AACb,CAAC"}
1
+ {"version":3,"file":"zip-scaffold.js","sourceRoot":"","sources":["../src/zip-scaffold.ts"],"names":[],"mappings":";;;AAGA,yCAAsD;AAEtD,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiEf,CAAC;AAEF,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCpB,CAAC;AAEF,MAAM,uBAAuB,GAAG,CAAC,GAAU,EAAE,EAAE;IAC7C,GAAG,CAAC,IAAI,CAAC,kBAAkB,EAAE,YAAY,CAAC,CAAC;IAC3C,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAE9B,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAEK,MAAM,kBAAkB,GAAG,KAAK,EAAE,CAAW,EAAE,IAAoB,EAAE,EAAE,CAC5E,uBAAuB,CAAC,IAAA,mCAAwB,EAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;AADhD,QAAA,kBAAkB,sBAC8B"}
@@ -3,24 +3,11 @@ declare function pascalToSnakeCase(string: string): string;
3
3
  export declare const contractOptionsToContractName: typeof pascalToSnakeCase;
4
4
  export declare function getAddressArgs(c: Pick<Contract, 'constructorArgs'>): string[];
5
5
  export declare const printRustNameTest: (c: Pick<Contract, "constructorArgs" | "name">) => string;
6
- export declare const stellarDependencies: {
7
- readonly base: readonly ["stellar-default-impl-macro"];
8
- readonly fungible: readonly ["stellar-fungible"];
9
- readonly nonFungible: readonly ["stellar-non-fungible"];
10
- readonly pausable: readonly ["stellar-pausable", "stellar-pausable-macros"];
11
- readonly upgradable: readonly ["stellar-upgradeable", "stellar-upgradeable-macros"];
12
- };
13
- export declare const allStellarDependencies: ("pausable" | "fungible" | "base" | "nonFungible" | "upgradable")[];
14
- export declare const allDependencies: {
15
- readonly soroban: readonly ["soroban-sdk"];
16
- readonly base: readonly ["stellar-default-impl-macro"];
17
- readonly fungible: readonly ["stellar-fungible"];
18
- readonly nonFungible: readonly ["stellar-non-fungible"];
19
- readonly pausable: readonly ["stellar-pausable", "stellar-pausable-macros"];
20
- readonly upgradable: readonly ["stellar-upgradeable", "stellar-upgradeable-macros"];
21
- };
22
- export declare const addDependenciesWith: (dependencyValue: string, dependenciesToAdd: (keyof typeof allDependencies)[]) => string;
6
+ export declare const libDependencies: readonly ["stellar-tokens", "stellar-access", "stellar-contract-utils", "stellar-macros"];
7
+ export declare const allDependencies: readonly ["stellar-tokens", "stellar-access", "stellar-contract-utils", "stellar-macros", "soroban-sdk"];
8
+ export declare const addDependenciesWith: (dependencyValue: string, dependenciesToAdd: string[]) => string;
23
9
  export declare const printContractCargo: (scaffoldContractName: string) => string;
24
10
  export declare const createRustLibFile = "#![no_std]\n#![allow(dead_code)]\n\nmod contract;\nmod test;\n";
11
+ export declare const workspaceCargo: string;
25
12
  export {};
26
13
  //# sourceMappingURL=zip-shared.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"zip-shared.d.ts","sourceRoot":"","sources":["../src/zip-shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAA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kB,yBAA0B,MAAM,WAc2B,CAAC;AAE3F,eAAO,MAAM,iBAAiB,mEAK7B,CAAC;AAEF,eAAO,MAAM,cAAc,QAY1B,CAAC"}
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createRustLibFile = exports.printContractCargo = exports.addDependenciesWith = exports.allDependencies = exports.allStellarDependencies = exports.stellarDependencies = exports.printRustNameTest = exports.contractOptionsToContractName = void 0;
3
+ exports.workspaceCargo = exports.createRustLibFile = exports.printContractCargo = exports.addDependenciesWith = exports.allDependencies = exports.libDependencies = exports.printRustNameTest = exports.contractOptionsToContractName = void 0;
4
4
  exports.getAddressArgs = getAddressArgs;
5
+ const version_1 = require("./utils/version");
5
6
  function pascalToSnakeCase(string) {
6
7
  return string
7
8
  .replace(/([A-Z])/g, '_$1')
@@ -37,22 +38,14 @@ fn initial_state() {
37
38
  // Add more tests bellow
38
39
  `;
39
40
  exports.printRustNameTest = printRustNameTest;
40
- const getKeysOf = (objectToGetKeysOf) => Object.keys(objectToGetKeysOf);
41
- exports.stellarDependencies = {
42
- base: ['stellar-default-impl-macro'],
43
- fungible: ['stellar-fungible'],
44
- nonFungible: ['stellar-non-fungible'],
45
- pausable: ['stellar-pausable', 'stellar-pausable-macros'],
46
- upgradable: ['stellar-upgradeable', 'stellar-upgradeable-macros'],
47
- };
48
- exports.allStellarDependencies = getKeysOf(exports.stellarDependencies);
49
- exports.allDependencies = {
50
- ...exports.stellarDependencies,
51
- soroban: ['soroban-sdk'],
52
- };
53
- const addDependenciesWith = (dependencyValue, dependenciesToAdd) => dependenciesToAdd.reduce((addedDependency, dependencyName) => {
54
- return `${addedDependency}${exports.allDependencies[dependencyName].map(cargoDependencies => `${cargoDependencies} = ${dependencyValue}\n`).join('')}`;
55
- }, '');
41
+ exports.libDependencies = [
42
+ 'stellar-tokens',
43
+ 'stellar-access',
44
+ 'stellar-contract-utils',
45
+ 'stellar-macros',
46
+ ];
47
+ exports.allDependencies = [...exports.libDependencies, 'soroban-sdk'];
48
+ const addDependenciesWith = (dependencyValue, dependenciesToAdd) => `${dependenciesToAdd.map(dependency => `${dependency} = ${dependencyValue}\n`).join('')}`;
56
49
  exports.addDependenciesWith = addDependenciesWith;
57
50
  const printContractCargo = (scaffoldContractName) => `[package]
58
51
  name = "${scaffoldContractName.replace(/_/, '-')}-contract"
@@ -66,9 +59,9 @@ crate-type = ["cdylib"]
66
59
  doctest = false
67
60
 
68
61
  [dependencies]
69
- ${(0, exports.addDependenciesWith)('{ workspace = true }', [...exports.allStellarDependencies, 'soroban'])}
62
+ ${(0, exports.addDependenciesWith)('{ workspace = true }', [...exports.allDependencies])}
70
63
  [dev-dependencies]
71
- ${(0, exports.addDependenciesWith)('{ workspace = true, features = ["testutils"] }', ['soroban'])}`;
64
+ ${(0, exports.addDependenciesWith)('{ workspace = true, features = ["testutils"] }', ['soroban-sdk'])}`;
72
65
  exports.printContractCargo = printContractCargo;
73
66
  exports.createRustLibFile = `#![no_std]
74
67
  #![allow(dead_code)]
@@ -76,4 +69,17 @@ exports.createRustLibFile = `#![no_std]
76
69
  mod contract;
77
70
  mod test;
78
71
  `;
72
+ exports.workspaceCargo = `[workspace]
73
+ resolver = "2"
74
+ members = ["contracts/*"]
75
+
76
+ [workspace.package]
77
+ authors = []
78
+ edition = "2021"
79
+ license = "Apache-2.0"
80
+ version = "0.0.1"
81
+
82
+ [workspace.dependencies]
83
+ ${(0, exports.addDependenciesWith)(`"${version_1.compatibleSorobanVersion}"`, ['soroban-sdk'])}${(0, exports.addDependenciesWith)(`"=${version_1.contractsVersion}"`, [...exports.libDependencies])}
84
+ `;
79
85
  //# sourceMappingURL=zip-shared.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"zip-shared.js","sourceRoot":"","sources":["../src/zip-shared.ts"],"names":[],"mappings":";;;AAWA,wCAIC;AAbD,SAAS,iBAAiB,CAAC,MAAc;IACvC,OAAO,MAAM;SACV,OAAO,CAAC,UAAU,EAA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CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,UAAU,MAAM,eAAe,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;AAD/E,QAAA,mBAAmB,uBAC4D;AAErF,MAAM,kBAAkB,GAAG,CAAC,oBAA4B,EAAE,EAAE,CAAC;UAC1D,oBAAoB,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC;;;;;;;;;;;EAW9C,IAAA,2BAAmB,EAAC,sBAAsB,EAAE,CAAC,GAAG,uBAAe,CAAC,CAAC;;EAEjE,IAAA,2BAAmB,EAAC,gDAAgD,EAAE,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC;AAd9E,QAAA,kBAAkB,sBAc4D;AAE9E,QAAA,iBAAiB,GAAG;;;;;CAKhC,CAAC;AAEW,QAAA,cAAc,GAAG;;;;;;;;;;;EAW5B,IAAA,2BAAmB,EAAC,IAAI,kCAAwB,GAAG,EAAE,CAAC,aAAa,CAAC,CAAC,GAAG,IAAA,2BAAmB,EAAC,KAAK,0BAAgB,GAAG,EAAE,CAAC,GAAG,uBAAe,CAAC,CAAC;CAC5I,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openzeppelin/wizard-stellar",
3
- "version": "0.2.3",
3
+ "version": "0.4.1",
4
4
  "description": "A boilerplate generator to get started with OpenZeppelin Stellar Soroban Contracts",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": "https://github.com/OpenZeppelin/contracts-wizard",
@@ -1,12 +1,13 @@
1
1
  import { getSelfArg } from './common-options';
2
- import type { ContractBuilder } from './contract';
2
+ import type { BaseFunction, ContractBuilder } from './contract';
3
3
  import type { Access } from './set-access-control';
4
4
  import { requireAccessControl } from './set-access-control';
5
5
  import { defineFunctions } from './utils/define-functions';
6
6
 
7
7
  export function addPausable(c: ContractBuilder, access: Access) {
8
- c.addUseClause('stellar_pausable', 'self', { alias: 'pausable' });
9
- c.addUseClause('stellar_pausable', 'Pausable');
8
+ c.addUseClause('stellar_contract_utils::pausable', 'self', { alias: 'pausable' });
9
+ c.addUseClause('stellar_contract_utils::pausable', 'Pausable');
10
+ c.addUseClause('stellar_macros', 'default_impl');
10
11
 
11
12
  const pausableTrait = {
12
13
  traitName: 'Pausable',
@@ -15,12 +16,23 @@ export function addPausable(c: ContractBuilder, access: Access) {
15
16
  section: 'Utils',
16
17
  };
17
18
 
19
+ const pauseFn: BaseFunction = access === 'ownable' ? functions.pause_unused_caller : functions.pause;
20
+ const unpauseFn: BaseFunction = access === 'ownable' ? functions.unpause_unused_caller : functions.unpause;
21
+
18
22
  c.addTraitFunction(pausableTrait, functions.paused);
19
- c.addTraitFunction(pausableTrait, functions.pause);
20
- c.addTraitFunction(pausableTrait, functions.unpause);
23
+ c.addTraitFunction(pausableTrait, pauseFn);
24
+ c.addTraitFunction(pausableTrait, unpauseFn);
25
+ requireAccessControl(c, pausableTrait, pauseFn, access, {
26
+ useMacro: true,
27
+ role: 'pauser',
28
+ caller: 'caller',
29
+ });
21
30
 
22
- requireAccessControl(c, pausableTrait, functions.pause, access, 'caller');
23
- requireAccessControl(c, pausableTrait, functions.unpause, access, 'caller');
31
+ requireAccessControl(c, pausableTrait, unpauseFn, access, {
32
+ useMacro: true,
33
+ role: 'pauser',
34
+ caller: 'caller',
35
+ });
24
36
  }
25
37
 
26
38
  const functions = defineFunctions({
@@ -31,10 +43,20 @@ const functions = defineFunctions({
31
43
  },
32
44
  pause: {
33
45
  args: [getSelfArg(), { name: 'caller', type: 'Address' }],
34
- code: ['pausable::pause(e, &caller)'],
46
+ code: ['pausable::pause(e)'],
47
+ },
48
+ pause_unused_caller: {
49
+ name: 'pause',
50
+ args: [getSelfArg(), { name: '_caller', type: 'Address' }],
51
+ code: ['pausable::pause(e)'],
35
52
  },
36
53
  unpause: {
37
54
  args: [getSelfArg(), { name: 'caller', type: 'Address' }],
38
- code: ['pausable::unpause(e, &caller)'],
55
+ code: ['pausable::unpause(e)'],
56
+ },
57
+ unpause_unused_caller: {
58
+ name: 'unpause',
59
+ args: [getSelfArg(), { name: '_caller', type: 'Address' }],
60
+ code: ['pausable::unpause(e)'],
39
61
  },
40
62
  });
@@ -1,7 +1,7 @@
1
1
  import { getSelfArg } from './common-options';
2
2
  import type { Access } from './set-access-control';
3
3
  import { requireAccessControl } from './set-access-control';
4
- import type { ContractBuilder } from './contract';
4
+ import type { BaseFunction, ContractBuilder } from './contract';
5
5
  import { defineFunctions } from './utils/define-functions';
6
6
 
7
7
  export function addUpgradeable(c: ContractBuilder, access: Access) {
@@ -10,10 +10,15 @@ export function addUpgradeable(c: ContractBuilder, access: Access) {
10
10
  args: [getSelfArg(), { name: 'operator', type: '&Address' }],
11
11
  code: ['operator.require_auth();'],
12
12
  },
13
+ _require_auth_unused_operator: {
14
+ name: '_require_auth',
15
+ args: [getSelfArg(), { name: '_operator', type: '&Address' }],
16
+ code: [],
17
+ },
13
18
  });
14
19
 
15
- c.addUseClause('stellar_upgradeable', 'UpgradeableInternal');
16
- c.addUseClause('stellar_upgradeable_macros', 'Upgradeable');
20
+ c.addUseClause('stellar_contract_utils::upgradeable', 'UpgradeableInternal');
21
+ c.addUseClause('stellar_macros', 'Upgradeable');
17
22
 
18
23
  c.addDerives('Upgradeable');
19
24
 
@@ -24,7 +29,14 @@ export function addUpgradeable(c: ContractBuilder, access: Access) {
24
29
  section: 'Utils',
25
30
  };
26
31
 
27
- c.addTraitFunction(upgradeableTrait, functions._require_auth);
32
+ const upgradeFn: BaseFunction =
33
+ access === 'ownable' ? functions._require_auth_unused_operator : functions._require_auth;
34
+
35
+ c.addTraitFunction(upgradeableTrait, upgradeFn);
28
36
 
29
- requireAccessControl(c, upgradeableTrait, functions._require_auth, access, '*operator');
37
+ requireAccessControl(c, upgradeableTrait, upgradeFn, access, {
38
+ useMacro: false,
39
+ role: 'upgrader',
40
+ caller: 'operator',
41
+ });
30
42
  }
package/src/api.ts CHANGED
@@ -1,8 +1,22 @@
1
1
  import type { CommonContractOptions } from './common-options';
2
2
  import type { FungibleOptions } from './fungible';
3
3
  import type { NonFungibleOptions } from './non-fungible';
4
- import { printFungible, defaults as fungibledefaults } from './fungible';
5
- import { printNonFungible, defaults as nonFungibledefaults } from './non-fungible';
4
+ import type { StablecoinOptions } from './stablecoin';
5
+ import {
6
+ printStablecoin,
7
+ defaults as stablecoinDefaults,
8
+ isAccessControlRequired as stablecoinIsAccessControlRequired,
9
+ } from './stablecoin';
10
+ import {
11
+ printFungible,
12
+ defaults as fungibledefaults,
13
+ isAccessControlRequired as fungibleIsAccessControlRequired,
14
+ } from './fungible';
15
+ import {
16
+ printNonFungible,
17
+ defaults as nonFungibledefaults,
18
+ isAccessControlRequired as nonFungibleIsAccessControlRequired,
19
+ } from './non-fungible';
6
20
 
7
21
  export interface WizardContractAPI<Options extends CommonContractOptions> {
8
22
  /**
@@ -24,15 +38,24 @@ export interface AccessControlAPI<Options extends CommonContractOptions> {
24
38
  isAccessControlRequired: (opts: Partial<Options>) => boolean;
25
39
  }
26
40
 
27
- export type Fungible = WizardContractAPI<FungibleOptions>; // TODO add AccessControlAPI<FungibleOptions> when access control is implemented, if useful
28
- export type NonFungible = WizardContractAPI<NonFungibleOptions>;
41
+ export type Fungible = WizardContractAPI<FungibleOptions> & AccessControlAPI<FungibleOptions>;
42
+ export type NonFungible = WizardContractAPI<NonFungibleOptions> & AccessControlAPI<NonFungibleOptions>;
43
+ export type Stablecoin = WizardContractAPI<StablecoinOptions> & AccessControlAPI<StablecoinOptions>;
29
44
 
30
45
  export const fungible: Fungible = {
31
46
  print: printFungible,
32
47
  defaults: fungibledefaults,
48
+ isAccessControlRequired: fungibleIsAccessControlRequired,
33
49
  };
34
50
 
35
51
  export const nonFungible: NonFungible = {
36
52
  print: printNonFungible,
37
53
  defaults: nonFungibledefaults,
54
+ isAccessControlRequired: nonFungibleIsAccessControlRequired,
55
+ };
56
+
57
+ export const stablecoin: Stablecoin = {
58
+ print: printStablecoin,
59
+ defaults: stablecoinDefaults,
60
+ isAccessControlRequired: stablecoinIsAccessControlRequired,
38
61
  };
@@ -2,10 +2,13 @@ import type { FungibleOptions } from './fungible';
2
2
  import { buildFungible } from './fungible';
3
3
  import type { NonFungibleOptions } from './non-fungible';
4
4
  import { buildNonFungible } from './non-fungible';
5
+ import type { StablecoinOptions } from './stablecoin';
6
+ import { buildStablecoin } from './stablecoin';
5
7
 
6
8
  export interface KindedOptions {
7
9
  Fungible: { kind: 'Fungible' } & FungibleOptions;
8
10
  NonFungible: { kind: 'NonFungible' } & NonFungibleOptions;
11
+ Stablecoin: { kind: 'Stablecoin' } & StablecoinOptions;
9
12
  }
10
13
 
11
14
  export type GenericOptions = KindedOptions[keyof KindedOptions];
@@ -18,6 +21,9 @@ export function buildGeneric(opts: GenericOptions) {
18
21
  case 'NonFungible':
19
22
  return buildNonFungible(opts);
20
23
 
24
+ case 'Stablecoin':
25
+ return buildStablecoin(opts);
26
+
21
27
  default: {
22
28
  const _: never = opts;
23
29
  throw new Error('Unknown kind');
package/src/contract.ts CHANGED
@@ -56,8 +56,8 @@ export interface BaseFunction {
56
56
  }
57
57
 
58
58
  export interface ContractFunction extends BaseFunction {
59
+ tags: string[];
59
60
  codeBefore?: string[];
60
- tag?: string;
61
61
  }
62
62
 
63
63
  export interface Variable {
@@ -177,6 +177,7 @@ export class ContractBuilder implements Contract {
177
177
  const contractFn: ContractFunction = {
178
178
  ...fn,
179
179
  pub: true,
180
+ tags: [],
180
181
  codeBefore: [],
181
182
  };
182
183
  this.freeFunctionsMap.set(signature, contractFn);
@@ -201,6 +202,7 @@ export class ContractBuilder implements Contract {
201
202
  // Otherwise, add the function
202
203
  const contractFn: ContractFunction = {
203
204
  ...fn,
205
+ tags: [],
204
206
  codeBefore: [],
205
207
  };
206
208
  t.functions.push(contractFn);
@@ -236,7 +238,7 @@ export class ContractBuilder implements Contract {
236
238
 
237
239
  addFunctionTag(fn: BaseFunction, tag: string, baseTrait?: BaseTraitImplBlock): void {
238
240
  const existingFn = this.getOrCreateFunction(fn, baseTrait);
239
- existingFn.tag = tag;
241
+ existingFn.tags = [...(existingFn.tags ?? []), tag];
240
242
  }
241
243
 
242
244
  addConstructorArgument(arg: Argument): void {
@@ -249,6 +251,11 @@ export class ContractBuilder implements Contract {
249
251
  }
250
252
 
251
253
  addConstructorCode(code: string): void {
254
+ for (const existingCode of this.constructorCode) {
255
+ if (existingCode === code) {
256
+ return;
257
+ }
258
+ }
252
259
  this.constructorCode.push(code);
253
260
  }
254
261