@openzeppelin/wizard-stellar 0.4.5 → 0.6.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.
- package/dist/add-pausable.d.ts.map +1 -1
- package/dist/add-pausable.js +0 -2
- package/dist/add-pausable.js.map +1 -1
- package/dist/add-upgradeable.d.ts.map +1 -1
- package/dist/add-upgradeable.js +15 -14
- package/dist/add-upgradeable.js.map +1 -1
- package/dist/api.d.ts +5 -2
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +7 -1
- package/dist/api.js.map +1 -1
- package/dist/build-generic.d.ts +4 -0
- package/dist/build-generic.d.ts.map +1 -1
- package/dist/build-generic.js +3 -0
- package/dist/build-generic.js.map +1 -1
- package/dist/contract.d.ts +3 -0
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +4 -0
- package/dist/contract.js.map +1 -1
- package/dist/fungible.d.ts +1 -0
- package/dist/fungible.d.ts.map +1 -1
- package/dist/fungible.js +83 -40
- package/dist/fungible.js.map +1 -1
- package/dist/generate/fungible.d.ts.map +1 -1
- package/dist/generate/fungible.js +1 -0
- package/dist/generate/fungible.js.map +1 -1
- package/dist/generate/governor.d.ts +3 -0
- package/dist/generate/governor.d.ts.map +1 -0
- package/dist/generate/governor.js +24 -0
- package/dist/generate/governor.js.map +1 -0
- package/dist/generate/non-fungible.d.ts.map +1 -1
- package/dist/generate/non-fungible.js +1 -0
- package/dist/generate/non-fungible.js.map +1 -1
- package/dist/generate/sources.d.ts.map +1 -1
- package/dist/generate/sources.js +6 -0
- package/dist/generate/sources.js.map +1 -1
- package/dist/generate/stablecoin.d.ts.map +1 -1
- package/dist/generate/stablecoin.js +1 -0
- package/dist/generate/stablecoin.js.map +1 -1
- package/dist/governor.d.ts +17 -0
- package/dist/governor.d.ts.map +1 -0
- package/dist/governor.js +378 -0
- package/dist/governor.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/kind.js +1 -0
- package/dist/kind.js.map +1 -1
- package/dist/non-fungible.d.ts +1 -0
- package/dist/non-fungible.d.ts.map +1 -1
- package/dist/non-fungible.js +72 -22
- package/dist/non-fungible.js.map +1 -1
- package/dist/print.d.ts.map +1 -1
- package/dist/print.js +6 -1
- package/dist/print.js.map +1 -1
- package/dist/set-access-control.d.ts.map +1 -1
- package/dist/set-access-control.js +16 -10
- package/dist/set-access-control.js.map +1 -1
- package/dist/stablecoin.d.ts.map +1 -1
- package/dist/stablecoin.js +7 -0
- package/dist/stablecoin.js.map +1 -1
- package/dist/test.js +3 -0
- package/dist/test.js.map +1 -1
- package/dist/utils/compile-test.d.ts +2 -2
- package/dist/utils/compile-test.d.ts.map +1 -1
- package/dist/utils/compile-test.js +54 -3
- package/dist/utils/compile-test.js.map +1 -1
- package/dist/utils/version.d.ts +4 -4
- package/dist/utils/version.js +3 -3
- package/dist/zip-rust.d.ts.map +1 -1
- package/dist/zip-rust.js +3 -2
- package/dist/zip-rust.js.map +1 -1
- package/dist/zip-shared.d.ts +3 -4
- package/dist/zip-shared.d.ts.map +1 -1
- package/dist/zip-shared.js +20 -7
- package/dist/zip-shared.js.map +1 -1
- package/package.json +1 -1
- package/src/add-pausable.ts +0 -1
- package/src/add-upgradeable.ts +15 -16
- package/src/api.ts +15 -2
- package/src/build-generic.ts +6 -0
- package/src/contract.ts +6 -0
- package/src/fungible.ts +102 -40
- package/src/generate/fungible.ts +1 -0
- package/src/generate/governor.ts +24 -0
- package/src/generate/non-fungible.ts +1 -0
- package/src/generate/sources.ts +7 -0
- package/src/generate/stablecoin.ts +1 -0
- package/src/governor.ts +425 -0
- package/src/index.ts +2 -0
- package/src/kind.ts +1 -0
- package/src/non-fungible.ts +77 -14
- package/src/print.ts +6 -1
- package/src/set-access-control.ts +16 -10
- package/src/stablecoin.ts +8 -0
- package/src/test.ts +4 -0
- package/src/utils/compile-test.ts +84 -5
- package/src/utils/version.ts +3 -3
- package/src/zip-rust.ts +4 -2
- package/src/zip-shared.ts +17 -6
|
@@ -3,12 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.withTemporaryFolderDo = exports.runCargoTest = void 0;
|
|
7
|
+
exports.runRustCompilationTest = runRustCompilationTest;
|
|
7
8
|
const child_process_1 = require("child_process");
|
|
8
9
|
const promises_1 = require("fs/promises");
|
|
9
10
|
const os_1 = require("os");
|
|
10
11
|
const path_1 = __importDefault(require("path"));
|
|
11
12
|
const util_1 = require("util");
|
|
13
|
+
const common_options_1 = require("../common-options");
|
|
12
14
|
const zip_rust_1 = require("../zip-rust");
|
|
13
15
|
const zip_shared_1 = require("../zip-shared");
|
|
14
16
|
const zip_test_1 = require("./zip-test");
|
|
@@ -18,6 +20,46 @@ const runCargoTest = async (t, temporaryFolder) => {
|
|
|
18
20
|
t.regex(result.stdout, /0 failed/);
|
|
19
21
|
};
|
|
20
22
|
exports.runCargoTest = runCargoTest;
|
|
23
|
+
const resolvePath = (inputPath) => inputPath.startsWith('~/') ? path_1.default.join((0, os_1.homedir)(), inputPath.slice(2)) : path_1.default.resolve(inputPath);
|
|
24
|
+
const toCargoPath = (inputPath) => inputPath.replace(/\\/g, '/');
|
|
25
|
+
const localDependencies = [
|
|
26
|
+
['stellar-tokens', 'packages/tokens'],
|
|
27
|
+
['stellar-access', 'packages/access'],
|
|
28
|
+
['stellar-contract-utils', 'packages/contract-utils'],
|
|
29
|
+
['stellar-governance', 'packages/governance'],
|
|
30
|
+
['stellar-macros', 'packages/macros'],
|
|
31
|
+
];
|
|
32
|
+
const workspaceDependenciesPattern = /\[workspace\.dependencies\][\s\S]*?(?=\n\[profile\.release\])/;
|
|
33
|
+
async function rewriteWorkspaceCargoForLocalContracts(workspaceCargoPath, stellarContractsPath) {
|
|
34
|
+
const absoluteContractsPath = resolvePath(stellarContractsPath);
|
|
35
|
+
const upstreamCargoPath = path_1.default.join(absoluteContractsPath, 'Cargo.toml');
|
|
36
|
+
const upstreamLockPath = path_1.default.join(absoluteContractsPath, 'Cargo.lock');
|
|
37
|
+
const workspaceDir = path_1.default.dirname(workspaceCargoPath);
|
|
38
|
+
const [workspaceCargo, upstreamCargo] = await Promise.all([
|
|
39
|
+
(0, promises_1.readFile)(workspaceCargoPath, 'utf8'),
|
|
40
|
+
(0, promises_1.readFile)(upstreamCargoPath, 'utf8'),
|
|
41
|
+
]);
|
|
42
|
+
const sorobanMatch = upstreamCargo.match(/^\s*soroban-sdk\s*=\s*"([^"]+)"/m);
|
|
43
|
+
if (sorobanMatch === null || sorobanMatch[1] === undefined) {
|
|
44
|
+
throw new Error(`Unable to find soroban-sdk version in ${upstreamCargoPath}`);
|
|
45
|
+
}
|
|
46
|
+
const dependencyLines = [
|
|
47
|
+
`soroban-sdk = "${sorobanMatch[1]}"`,
|
|
48
|
+
...localDependencies.map(([crate, relativePath]) => `${crate} = { path = "${toCargoPath(path_1.default.join(absoluteContractsPath, relativePath))}" }`),
|
|
49
|
+
];
|
|
50
|
+
if (!workspaceDependenciesPattern.test(workspaceCargo)) {
|
|
51
|
+
throw new Error(`Unable to locate [workspace.dependencies] section in ${workspaceCargoPath}`);
|
|
52
|
+
}
|
|
53
|
+
const nextCargo = workspaceCargo.replace(workspaceDependenciesPattern, `[workspace.dependencies]\n${dependencyLines.join('\n')}\n`);
|
|
54
|
+
await (0, promises_1.writeFile)(workspaceCargoPath, nextCargo);
|
|
55
|
+
// Reuse upstream lockfile when available to minimize resolver drift/offline cache misses.
|
|
56
|
+
try {
|
|
57
|
+
await (0, promises_1.copyFile)(upstreamLockPath, path_1.default.join(workspaceDir, 'Cargo.lock'));
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
// Ignore if lockfile is unavailable.
|
|
61
|
+
}
|
|
62
|
+
}
|
|
21
63
|
const withTemporaryFolderDo = (testFunction) => (...testFunctionArguments) => async (test) => {
|
|
22
64
|
const temporaryFolder = await (0, promises_1.mkdtemp)(path_1.default.join((0, os_1.tmpdir)(), `compilation-test-${crypto.randomUUID()}`));
|
|
23
65
|
try {
|
|
@@ -44,13 +86,19 @@ const doRunRustCompilationTest = async (makeContract, opts, testOptions, test, f
|
|
|
44
86
|
const zip = await (0, zip_rust_1.zipRustProject)(makeContract(opts), opts);
|
|
45
87
|
(0, zip_test_1.assertLayout)(test, zip, (0, zip_test_1.expandPathsFromFilesPaths)(expectedZipFiles));
|
|
46
88
|
await (0, zip_test_1.extractPackage)(zip, folderPath);
|
|
89
|
+
if (process.env.STELLAR_CONTRACTS_PATH !== undefined) {
|
|
90
|
+
// Useful for release-candidate validation before crates.io publication.
|
|
91
|
+
await rewriteWorkspaceCargoForLocalContracts(path_1.default.join(folderPath, 'Cargo.toml'), process.env.STELLAR_CONTRACTS_PATH);
|
|
92
|
+
}
|
|
47
93
|
await (0, exports.runCargoTest)(test, folderPath);
|
|
48
94
|
if (testOptions.snapshotResult)
|
|
49
95
|
await (0, zip_test_1.snapshotZipContents)(test, zip, expectedZipFiles);
|
|
50
96
|
};
|
|
51
|
-
|
|
97
|
+
const _runRustCompilationTest = (0, exports.withTemporaryFolderDo)(async (makeContract, opts, testOptions, test, folderPath) => {
|
|
52
98
|
await doRunRustCompilationTest(makeContract, opts, testOptions, test, `${folderPath}/default`);
|
|
53
|
-
const
|
|
99
|
+
const mergedOpts = (0, common_options_1.withCommonContractDefaults)(opts);
|
|
100
|
+
const supportsExplicitImplementations = 'explicitImplementations' in mergedOpts;
|
|
101
|
+
const shouldBeExcludedOrHasAlreadyRun = testOptions.excludeExplicitTraitTest || !supportsExplicitImplementations || mergedOpts.explicitImplementations;
|
|
54
102
|
if (shouldBeExcludedOrHasAlreadyRun)
|
|
55
103
|
return;
|
|
56
104
|
try {
|
|
@@ -60,4 +108,7 @@ exports.runRustCompilationTest = (0, exports.withTemporaryFolderDo)(async (makeC
|
|
|
60
108
|
throw new Error(`EXPLICIT IMPLEMENTATION ERROR: ${error}`);
|
|
61
109
|
}
|
|
62
110
|
});
|
|
111
|
+
function runRustCompilationTest(makeContract, opts, testOptions) {
|
|
112
|
+
return _runRustCompilationTest(makeContract, opts, testOptions);
|
|
113
|
+
}
|
|
63
114
|
//# sourceMappingURL=compile-test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile-test.js","sourceRoot":"","sources":["../../src/utils/compile-test.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"compile-test.js","sourceRoot":"","sources":["../../src/utils/compile-test.ts"],"names":[],"mappings":";;;;;;AAwKA,wDAMC;AA7KD,iDAAqC;AACrC,0CAAgF;AAChF,2BAAqC;AACrC,gDAAwB;AACxB,+BAAiC;AAGjC,sDAA+D;AAE/D,0CAA6C;AAC7C,8CAA8D;AAC9D,yCAA0G;AAE1G,MAAM,SAAS,GAAG,IAAA,gBAAS,EAAC,oBAAI,CAAC,CAAC;AAE3B,MAAM,YAAY,GAAG,KAAK,EAAE,CAAmB,EAAE,eAAuB,EAAE,EAAE;IACjF,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,OAAO,eAAe,iBAAiB,CAAC,CAAC;IAExE,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AACrC,CAAC,CAAC;AAJW,QAAA,YAAY,gBAIvB;AAEF,MAAM,WAAW,GAAG,CAAC,SAAiB,EAAE,EAAE,CACxC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,cAAI,CAAC,IAAI,CAAC,IAAA,YAAO,GAAE,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,cAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAClG,MAAM,WAAW,GAAG,CAAC,SAAiB,EAAE,EAAE,CA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AC;AAEF,MAAM,uBAAuB,GAAG,IAAA,6BAAqB,EACnD,KAAK,EACH,YAA0B,EAC1B,IAAoB,EACpB,WAA4E,EAC5E,IAAsB,EACtB,UAAkB,EAClB,EAAE;IACF,MAAM,wBAAwB,CAAC,YAAY,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,UAAU,UAAU,CAAC,CAAC;IAE/F,MAAM,UAAU,GAAG,IAAA,2CAA0B,EAAC,IAA8C,CAAC,CAAC;IAC9F,MAAM,+BAA+B,GAAG,yBAAyB,IAAI,UAAU,CAAC;IAChF,MAAM,+BAA+B,GACnC,WAAW,CAAC,wBAAwB,IAAI,CAAC,+BAA+B,IAAI,UAAU,CAAC,uBAAuB,CAAC;IACjH,IAAI,+BAA+B;QAAE,OAAO;IAE5C,IAAI,CAAC;QACH,MAAM,wBAAwB,CAC5B,YAAY,EACZ,EAAE,GAAG,IAAI,EAAE,uBAAuB,EAAE,IAAI,EAAoB,EAC5D,WAAW,EACX,IAAI,EACJ,GAAG,UAAU,WAAW,CACzB,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,kCAAkC,KAAK,EAAE,CAAC,CAAC;IAC7D,CAAC;AACH,CAAC,CACF,CAAC;AAEF,SAAgB,sBAAsB,CACpC,YAAkC,EAClC,IAAO,EACP,WAA4E;IAE5E,OAAO,uBAAuB,CAAC,YAA4B,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;AAClF,CAAC"}
|
package/dist/utils/version.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The actual latest version to use in links.
|
|
3
3
|
*/
|
|
4
|
-
export declare const contractsVersion = "0.
|
|
5
|
-
export declare const contractsVersionTag = "v0.
|
|
4
|
+
export declare const contractsVersion = "0.7.1";
|
|
5
|
+
export declare const contractsVersionTag = "v0.7.1";
|
|
6
6
|
/**
|
|
7
7
|
* Semantic version string representing of the minimum compatible version of Contracts to display in output.
|
|
8
8
|
*/
|
|
9
|
-
export declare const compatibleContractsSemver = "^0.
|
|
9
|
+
export declare const compatibleContractsSemver = "^0.7.1";
|
|
10
10
|
/**
|
|
11
11
|
* The Soroban version for which compilation and testing have passing tests
|
|
12
12
|
*/
|
|
13
|
-
export declare const compatibleSorobanVersion = "
|
|
13
|
+
export declare const compatibleSorobanVersion = "25.3.0";
|
|
14
14
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/utils/version.js
CHANGED
|
@@ -4,14 +4,14 @@ exports.compatibleSorobanVersion = exports.compatibleContractsSemver = exports.c
|
|
|
4
4
|
/**
|
|
5
5
|
* The actual latest version to use in links.
|
|
6
6
|
*/
|
|
7
|
-
exports.contractsVersion = '0.
|
|
7
|
+
exports.contractsVersion = '0.7.1';
|
|
8
8
|
exports.contractsVersionTag = `v${exports.contractsVersion}`;
|
|
9
9
|
/**
|
|
10
10
|
* Semantic version string representing of the minimum compatible version of Contracts to display in output.
|
|
11
11
|
*/
|
|
12
|
-
exports.compatibleContractsSemver = '^0.
|
|
12
|
+
exports.compatibleContractsSemver = '^0.7.1';
|
|
13
13
|
/**
|
|
14
14
|
* The Soroban version for which compilation and testing have passing tests
|
|
15
15
|
*/
|
|
16
|
-
exports.compatibleSorobanVersion = '
|
|
16
|
+
exports.compatibleSorobanVersion = '25.3.0';
|
|
17
17
|
//# sourceMappingURL=version.js.map
|
package/dist/zip-rust.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zip-rust.d.ts","sourceRoot":"","sources":["../src/zip-rust.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"zip-rust.d.ts","sourceRoot":"","sources":["../src/zip-rust.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AA8B3C,eAAO,MAAM,wBAAwB,GAAI,GAAG,QAAQ,EAAE,MAAM,cAAc,UAczE,CAAC;AAIF,eAAO,MAAM,cAAc,GAAU,GAAG,QAAQ,EAAE,MAAM,cAAc,mBACb,CAAC"}
|
package/dist/zip-rust.js
CHANGED
|
@@ -27,11 +27,12 @@ target/
|
|
|
27
27
|
const createRustZipEnvironment = (c, opts) => {
|
|
28
28
|
const zip = new jszip_1.default();
|
|
29
29
|
const contractName = (0, zip_shared_1.contractOptionsToContractName)(opts?.kind || 'contract');
|
|
30
|
+
const requiredLibDeps = (0, zip_shared_1.getRequiredLibDependencies)(c);
|
|
30
31
|
zip.file(`contracts/${contractName}/src/contract.rs`, (0, print_1.removeCreateLevelAttributes)((0, print_1.printContract)(c)));
|
|
31
32
|
zip.file(`contracts/${contractName}/src/test.rs`, (0, zip_shared_1.printRustNameTest)(c));
|
|
32
33
|
zip.file(`contracts/${contractName}/src/lib.rs`, zip_shared_1.createRustLibFile);
|
|
33
|
-
zip.file(`contracts/${contractName}/Cargo.toml`, (0, zip_shared_1.printContractCargo)(contractName));
|
|
34
|
-
zip.file('Cargo.toml', zip_shared_1.workspaceCargo);
|
|
34
|
+
zip.file(`contracts/${contractName}/Cargo.toml`, (0, zip_shared_1.printContractCargo)(contractName, requiredLibDeps));
|
|
35
|
+
zip.file('Cargo.toml', (0, zip_shared_1.workspaceCargo)(requiredLibDeps));
|
|
35
36
|
zip.file('.gitignore', gitIgnore);
|
|
36
37
|
return zip;
|
|
37
38
|
};
|
package/dist/zip-rust.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zip-rust.js","sourceRoot":"","sources":["../src/zip-rust.ts"],"names":[],"mappings":";;;;;;AAA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E,MAAM,CAAC,CAAC;AAEpE,MAAM,cAAc,GAAG,KAAK,EAAE,CAAW,EAAE,IAAoB,EAAE,EAAE,CACxE,oBAAoB,CAAC,IAAA,gCAAwB,EAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;AAD7C,QAAA,cAAc,kBAC+B"}
|
package/dist/zip-shared.d.ts
CHANGED
|
@@ -3,11 +3,10 @@ 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
|
|
7
|
-
export declare const allDependencies: readonly ["stellar-tokens", "stellar-access", "stellar-contract-utils", "stellar-macros", "soroban-sdk"];
|
|
6
|
+
export declare function getRequiredLibDependencies(c: Pick<Contract, 'useClauses'>): string[];
|
|
8
7
|
export declare const addDependenciesWith: (dependencyValue: string, dependenciesToAdd: string[]) => string;
|
|
9
|
-
export declare const printContractCargo: (scaffoldContractName: string) => string;
|
|
8
|
+
export declare const printContractCargo: (scaffoldContractName: string, requiredLibDeps: readonly string[]) => string;
|
|
10
9
|
export declare const createRustLibFile = "#![no_std]\n#![allow(dead_code)]\n\nmod contract;\nmod test;\n";
|
|
11
|
-
export declare const workspaceCargo: string;
|
|
10
|
+
export declare const workspaceCargo: (requiredLibDeps: readonly string[]) => string;
|
|
12
11
|
export {};
|
|
13
12
|
//# sourceMappingURL=zip-shared.d.ts.map
|
package/dist/zip-shared.d.ts.map
CHANGED
|
@@ -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,YAAY,CAAC;AAG3C,iBAAS,iBAAiB,CAAC,MAAM,EAAE,MAAM,UAKxC;AAED,eAAO,MAAM,6BAA6B,0BAAoB,CAAC;AAE/D,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,CAAC,QAAQ,EAAE,iBAAiB,CAAC,GAAG,MAAM,EAAE,CAI7E;AAED,eAAO,MAAM,iBAAiB,GAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,iBAAiB,GAAG,MAAM,CAAC,WAqB9E,CAAC;
|
|
1
|
+
{"version":3,"file":"zip-shared.d.ts","sourceRoot":"","sources":["../src/zip-shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAG3C,iBAAS,iBAAiB,CAAC,MAAM,EAAE,MAAM,UAKxC;AAED,eAAO,MAAM,6BAA6B,0BAAoB,CAAC;AAE/D,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,CAAC,QAAQ,EAAE,iBAAiB,CAAC,GAAG,MAAM,EAAE,CAI7E;AAED,eAAO,MAAM,iBAAiB,GAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,iBAAiB,GAAG,MAAM,CAAC,WAqB9E,CAAC;AAiBF,wBAAgB,0BAA0B,CAAC,CAAC,EAAE,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,GAAG,MAAM,EAAE,CAGpF;AAED,eAAO,MAAM,mBAAmB,GAAI,iBAAiB,MAAM,EAAE,mBAAmB,MAAM,EAAE,WACG,CAAC;AAE5F,eAAO,MAAM,kBAAkB,GAAI,sBAAsB,MAAM,EAAE,iBAAiB,SAAS,MAAM,EAAE,WAiBT,CAAC;AAE3F,eAAO,MAAM,iBAAiB,mEAK7B,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,iBAAiB,SAAS,MAAM,EAAE,WA0BhE,CAAC"}
|
package/dist/zip-shared.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.workspaceCargo = exports.createRustLibFile = exports.printContractCargo = exports.addDependenciesWith = exports.
|
|
3
|
+
exports.workspaceCargo = exports.createRustLibFile = exports.printContractCargo = exports.addDependenciesWith = exports.printRustNameTest = exports.contractOptionsToContractName = void 0;
|
|
4
4
|
exports.getAddressArgs = getAddressArgs;
|
|
5
|
+
exports.getRequiredLibDependencies = getRequiredLibDependencies;
|
|
5
6
|
const version_1 = require("./utils/version");
|
|
6
7
|
function pascalToSnakeCase(string) {
|
|
7
8
|
return string
|
|
@@ -38,16 +39,27 @@ fn initial_state() {
|
|
|
38
39
|
// Add more tests bellow
|
|
39
40
|
`;
|
|
40
41
|
exports.printRustNameTest = printRustNameTest;
|
|
41
|
-
|
|
42
|
+
const libDependencies = [
|
|
42
43
|
'stellar-tokens',
|
|
43
44
|
'stellar-access',
|
|
44
45
|
'stellar-contract-utils',
|
|
46
|
+
'stellar-governance',
|
|
45
47
|
'stellar-macros',
|
|
46
48
|
];
|
|
47
|
-
|
|
49
|
+
// Derives required lib crate dependencies from the contract's use clauses.
|
|
50
|
+
// Each use clause has a containerPath like "stellar_tokens::fungible::Base".
|
|
51
|
+
// We extract the first segment (the crate name), convert underscores to hyphens
|
|
52
|
+
// to match Cargo naming (e.g., stellar_tokens -> stellar-tokens), then filter
|
|
53
|
+
// libDependencies to include only crates the contract actually references.
|
|
54
|
+
// Filtering against the known list preserves stable ordering and ignores
|
|
55
|
+
// non-lib crates like soroban_sdk (which is always added separately).
|
|
56
|
+
function getRequiredLibDependencies(c) {
|
|
57
|
+
const usedCrates = new Set(c.useClauses.map(uc => uc.containerPath.split('::')[0].replace(/_/g, '-')));
|
|
58
|
+
return libDependencies.filter(dep => usedCrates.has(dep));
|
|
59
|
+
}
|
|
48
60
|
const addDependenciesWith = (dependencyValue, dependenciesToAdd) => `${dependenciesToAdd.map(dependency => `${dependency} = ${dependencyValue}\n`).join('')}`;
|
|
49
61
|
exports.addDependenciesWith = addDependenciesWith;
|
|
50
|
-
const printContractCargo = (scaffoldContractName) => `[package]
|
|
62
|
+
const printContractCargo = (scaffoldContractName, requiredLibDeps) => `[package]
|
|
51
63
|
name = "${scaffoldContractName.replace(/_/, '-')}-contract"
|
|
52
64
|
edition.workspace = true
|
|
53
65
|
license.workspace = true
|
|
@@ -62,7 +74,7 @@ crate-type = ["cdylib"]
|
|
|
62
74
|
doctest = false
|
|
63
75
|
|
|
64
76
|
[dependencies]
|
|
65
|
-
${(0, exports.addDependenciesWith)('{ workspace = true }', [...
|
|
77
|
+
${(0, exports.addDependenciesWith)('{ workspace = true }', [...requiredLibDeps, 'soroban-sdk'])}
|
|
66
78
|
[dev-dependencies]
|
|
67
79
|
${(0, exports.addDependenciesWith)('{ workspace = true, features = ["testutils"] }', ['soroban-sdk'])}`;
|
|
68
80
|
exports.printContractCargo = printContractCargo;
|
|
@@ -72,7 +84,7 @@ exports.createRustLibFile = `#![no_std]
|
|
|
72
84
|
mod contract;
|
|
73
85
|
mod test;
|
|
74
86
|
`;
|
|
75
|
-
|
|
87
|
+
const workspaceCargo = (requiredLibDeps) => `[workspace]
|
|
76
88
|
resolver = "2"
|
|
77
89
|
members = ["contracts/*"]
|
|
78
90
|
|
|
@@ -83,7 +95,7 @@ license = "Apache-2.0"
|
|
|
83
95
|
version = "0.0.1"
|
|
84
96
|
|
|
85
97
|
[workspace.dependencies]
|
|
86
|
-
${(0, exports.addDependenciesWith)(`"${version_1.compatibleSorobanVersion}"`, ['soroban-sdk'])}${(0, exports.addDependenciesWith)(`"=${version_1.contractsVersion}"`, [...
|
|
98
|
+
${(0, exports.addDependenciesWith)(`"${version_1.compatibleSorobanVersion}"`, ['soroban-sdk'])}${(0, exports.addDependenciesWith)(`"=${version_1.contractsVersion}"`, [...requiredLibDeps])}
|
|
87
99
|
|
|
88
100
|
[profile.release]
|
|
89
101
|
opt-level = "z"
|
|
@@ -99,4 +111,5 @@ lto = true
|
|
|
99
111
|
inherits = "release"
|
|
100
112
|
debug-assertions = true
|
|
101
113
|
`;
|
|
114
|
+
exports.workspaceCargo = workspaceCargo;
|
|
102
115
|
//# sourceMappingURL=zip-shared.js.map
|
package/dist/zip-shared.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zip-shared.js","sourceRoot":"","sources":["../src/zip-shared.ts"],"names":[],"mappings":";;;AAYA,wCAIC;
|
|
1
|
+
{"version":3,"file":"zip-shared.js","sourceRoot":"","sources":["../src/zip-shared.ts"],"names":[],"mappings":";;;AAYA,wCAIC;AAwCD,gEAGC;AA1DD,6CAA6E;AAE7E,SAAS,iBAAiB,CAAC,MAAc;IACvC,OAAO,MAAM;SACV,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC;SAC1B,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;SACjB,WAAW,EAAE,CAAC;AACnB,CAAC;AAEY,QAAA,6BAA6B,GAAG,iBAAiB,CAAC;AAE/D,SAAgB,cAAc,CAAC,CAAoC;IACjE,OAAO,CAAC,CAAC,CAAC,eAAe,IAAI,EAAE,CAAC;SAC7B,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,SAAS,CAAC;SACnE,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;AAChD,CAAC;AAEM,MAAM,iBAAiB,GAAG,CAAC,CAA6C,EAAE,EAAE,CAAC;;;;qBAI/D,cAAc,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,oCAAoC,CAAC,CAAC,CAAC,EAAE;;yBAEhE,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI;;;;;;uCAMH,CAAC,CAAC,IAAI,MAAM,cAAc,CAAC,CAAC,CAAC;KAC7D,GAAG,CAAC,GAAG,EAAE,CAAC,yBAAyB,CAAC;KACpC,IAAI,CAAC,GAAG,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,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,CAAC,EAAE,CAAC;AAjB9E,QAAA,kBAAkB,sBAiB4D;AAE9E,QAAA,iBAAiB,GAAG;;;;;CAKhC,CAAC;AAEK,MAAM,cAAc,GAAG,CAAC,eAAkC,EAAE,EAAE,CAAC;;;;;;;;;;;EAWpE,IAAA,2BAAmB,EAAC,IAAI,kCAAwB,GAAG,EAAE,CAAC,aAAa,CAAC,CAAC,GAAG,IAAA,2BAAmB,EAAC,KAAK,0BAAgB,GAAG,EAAE,CAAC,GAAG,eAAe,CAAC,CAAC;;;;;;;;;;;;;;;CAe5I,CAAC;AA1BW,QAAA,cAAc,kBA0BzB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openzeppelin/wizard-stellar",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
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",
|
package/src/add-pausable.ts
CHANGED
|
@@ -7,7 +7,6 @@ import { defineFunctions } from './utils/define-functions';
|
|
|
7
7
|
export function addPausable(c: ContractBuilder, access: Access, explicitImplementations: boolean) {
|
|
8
8
|
c.addUseClause('stellar_contract_utils::pausable', 'self', { alias: 'pausable' });
|
|
9
9
|
c.addUseClause('stellar_contract_utils::pausable', 'Pausable');
|
|
10
|
-
if (!explicitImplementations) c.addUseClause('stellar_macros', 'default_impl');
|
|
11
10
|
|
|
12
11
|
const pausableTrait = {
|
|
13
12
|
traitName: 'Pausable',
|
package/src/add-upgradeable.ts
CHANGED
|
@@ -6,31 +6,30 @@ import { defineFunctions } from './utils/define-functions';
|
|
|
6
6
|
|
|
7
7
|
export function addUpgradeable(c: ContractBuilder, access: Access, explicitImplementations: boolean) {
|
|
8
8
|
const functions = defineFunctions({
|
|
9
|
-
|
|
10
|
-
args: [getSelfArg(), { name: 'operator', type: '
|
|
11
|
-
code: ['
|
|
9
|
+
upgrade: {
|
|
10
|
+
args: [getSelfArg(), { name: 'new_wasm_hash', type: 'BytesN<32>' }, { name: 'operator', type: 'Address' }],
|
|
11
|
+
code: ['upgradeable::upgrade(e, &new_wasm_hash)'],
|
|
12
12
|
},
|
|
13
|
-
|
|
14
|
-
name: '
|
|
15
|
-
args: [getSelfArg(), { name: '_operator', type: '
|
|
16
|
-
code: [],
|
|
13
|
+
upgrade_unused_operator: {
|
|
14
|
+
name: 'upgrade',
|
|
15
|
+
args: [getSelfArg(), { name: 'new_wasm_hash', type: 'BytesN<32>' }, { name: '_operator', type: 'Address' }],
|
|
16
|
+
code: ['upgradeable::upgrade(e, &new_wasm_hash)'],
|
|
17
17
|
},
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
c.addUseClause('
|
|
21
|
-
c.addUseClause('
|
|
22
|
-
|
|
23
|
-
c.
|
|
20
|
+
c.addUseClause('soroban_sdk', 'Address');
|
|
21
|
+
c.addUseClause('soroban_sdk', 'BytesN');
|
|
22
|
+
c.addUseClause('stellar_contract_utils::upgradeable', 'self', { alias: 'upgradeable' });
|
|
23
|
+
c.addUseClause('stellar_contract_utils::upgradeable', 'Upgradeable');
|
|
24
24
|
|
|
25
25
|
const upgradeableTrait = {
|
|
26
|
-
traitName: '
|
|
26
|
+
traitName: 'Upgradeable',
|
|
27
27
|
structName: c.name,
|
|
28
|
-
tags: [],
|
|
28
|
+
tags: ['contractimpl'],
|
|
29
29
|
section: 'Utils',
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
const upgradeFn: BaseFunction =
|
|
33
|
-
access === 'ownable' ? functions._require_auth_unused_operator : functions._require_auth;
|
|
32
|
+
const upgradeFn: BaseFunction = access === 'ownable' ? functions.upgrade_unused_operator : functions.upgrade;
|
|
34
33
|
|
|
35
34
|
c.addTraitFunction(upgradeableTrait, upgradeFn);
|
|
36
35
|
|
|
@@ -40,7 +39,7 @@ export function addUpgradeable(c: ContractBuilder, access: Access, explicitImple
|
|
|
40
39
|
upgradeFn,
|
|
41
40
|
access,
|
|
42
41
|
{
|
|
43
|
-
useMacro:
|
|
42
|
+
useMacro: true,
|
|
44
43
|
role: 'upgrader',
|
|
45
44
|
caller: 'operator',
|
|
46
45
|
},
|
package/src/api.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { CommonContractOptions } from './common-options';
|
|
1
|
+
import type { CommonContractOptions, CommonOptions } from './common-options';
|
|
2
2
|
import type { FungibleOptions } from './fungible';
|
|
3
|
+
import type { GovernorOptions } from './governor';
|
|
3
4
|
import type { NonFungibleOptions } from './non-fungible';
|
|
4
5
|
import type { StablecoinOptions } from './stablecoin';
|
|
5
6
|
import {
|
|
@@ -12,13 +13,18 @@ import {
|
|
|
12
13
|
defaults as fungibledefaults,
|
|
13
14
|
isAccessControlRequired as fungibleIsAccessControlRequired,
|
|
14
15
|
} from './fungible';
|
|
16
|
+
import {
|
|
17
|
+
printGovernor,
|
|
18
|
+
defaults as governorDefaults,
|
|
19
|
+
isAccessControlRequired as governorIsAccessControlRequired,
|
|
20
|
+
} from './governor';
|
|
15
21
|
import {
|
|
16
22
|
printNonFungible,
|
|
17
23
|
defaults as nonFungibledefaults,
|
|
18
24
|
isAccessControlRequired as nonFungibleIsAccessControlRequired,
|
|
19
25
|
} from './non-fungible';
|
|
20
26
|
|
|
21
|
-
export interface WizardContractAPI<Options extends
|
|
27
|
+
export interface WizardContractAPI<Options extends CommonOptions> {
|
|
22
28
|
/**
|
|
23
29
|
* Returns a string representation of a contract generated using the provided options. If opts is not provided, uses `defaults`.
|
|
24
30
|
*/
|
|
@@ -39,6 +45,7 @@ export interface AccessControlAPI<Options extends CommonContractOptions> {
|
|
|
39
45
|
}
|
|
40
46
|
|
|
41
47
|
export type Fungible = WizardContractAPI<FungibleOptions> & AccessControlAPI<FungibleOptions>;
|
|
48
|
+
export type Governor = WizardContractAPI<GovernorOptions> & AccessControlAPI<GovernorOptions>;
|
|
42
49
|
export type NonFungible = WizardContractAPI<NonFungibleOptions> & AccessControlAPI<NonFungibleOptions>;
|
|
43
50
|
export type Stablecoin = WizardContractAPI<StablecoinOptions> & AccessControlAPI<StablecoinOptions>;
|
|
44
51
|
|
|
@@ -48,6 +55,12 @@ export const fungible: Fungible = {
|
|
|
48
55
|
isAccessControlRequired: fungibleIsAccessControlRequired,
|
|
49
56
|
};
|
|
50
57
|
|
|
58
|
+
export const governor: Governor = {
|
|
59
|
+
print: printGovernor,
|
|
60
|
+
defaults: governorDefaults,
|
|
61
|
+
isAccessControlRequired: governorIsAccessControlRequired,
|
|
62
|
+
};
|
|
63
|
+
|
|
51
64
|
export const nonFungible: NonFungible = {
|
|
52
65
|
print: printNonFungible,
|
|
53
66
|
defaults: nonFungibledefaults,
|
package/src/build-generic.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { FungibleOptions } from './fungible';
|
|
2
2
|
import { buildFungible } from './fungible';
|
|
3
|
+
import type { GovernorOptions } from './governor';
|
|
4
|
+
import { buildGovernor } from './governor';
|
|
3
5
|
import type { NonFungibleOptions } from './non-fungible';
|
|
4
6
|
import { buildNonFungible } from './non-fungible';
|
|
5
7
|
import type { StablecoinOptions } from './stablecoin';
|
|
@@ -7,6 +9,7 @@ import { buildStablecoin } from './stablecoin';
|
|
|
7
9
|
|
|
8
10
|
export interface KindedOptions {
|
|
9
11
|
Fungible: { kind: 'Fungible' } & FungibleOptions;
|
|
12
|
+
Governor: { kind: 'Governor' } & GovernorOptions;
|
|
10
13
|
NonFungible: { kind: 'NonFungible' } & NonFungibleOptions;
|
|
11
14
|
Stablecoin: { kind: 'Stablecoin' } & StablecoinOptions;
|
|
12
15
|
}
|
|
@@ -18,6 +21,9 @@ export function buildGeneric(opts: GenericOptions) {
|
|
|
18
21
|
case 'Fungible':
|
|
19
22
|
return buildFungible(opts);
|
|
20
23
|
|
|
24
|
+
case 'Governor':
|
|
25
|
+
return buildGovernor(opts);
|
|
26
|
+
|
|
21
27
|
case 'NonFungible':
|
|
22
28
|
return buildNonFungible(opts);
|
|
23
29
|
|
package/src/contract.ts
CHANGED
|
@@ -10,6 +10,7 @@ export interface Contract {
|
|
|
10
10
|
constructorArgs: Argument[];
|
|
11
11
|
implementedTraits: TraitImplBlock[];
|
|
12
12
|
freeFunctions: ContractFunction[];
|
|
13
|
+
topLevelDeclarations: string[][];
|
|
13
14
|
variables: Variable[];
|
|
14
15
|
errors: Error[];
|
|
15
16
|
ownable: boolean;
|
|
@@ -81,6 +82,7 @@ export class ContractBuilder implements Contract {
|
|
|
81
82
|
|
|
82
83
|
readonly constructorArgs: Argument[] = [];
|
|
83
84
|
readonly constructorCode: string[] = [];
|
|
85
|
+
readonly topLevelDeclarations: string[][] = [];
|
|
84
86
|
|
|
85
87
|
private implementedTraitsMap: Map<string, TraitImplBlock> = new Map();
|
|
86
88
|
private freeFunctionsMap: Map<string, ContractFunction> = new Map();
|
|
@@ -250,6 +252,10 @@ export class ContractBuilder implements Contract {
|
|
|
250
252
|
existingFn.code = [...code];
|
|
251
253
|
}
|
|
252
254
|
|
|
255
|
+
addTopLevelDeclaration(lines: string[]): void {
|
|
256
|
+
this.topLevelDeclarations.push(lines);
|
|
257
|
+
}
|
|
258
|
+
|
|
253
259
|
addConstructorArgument(arg: Argument): void {
|
|
254
260
|
for (const existingArg of this.constructorArgs) {
|
|
255
261
|
if (existingArg.name == arg.name) {
|