@openzeppelin/wizard-stellar 0.4.4 → 0.4.5
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 +1 -1
- package/dist/add-pausable.d.ts.map +1 -1
- package/dist/add-pausable.js +10 -8
- package/dist/add-pausable.js.map +1 -1
- package/dist/add-upgradeable.d.ts +1 -1
- package/dist/add-upgradeable.d.ts.map +1 -1
- package/dist/add-upgradeable.js +2 -2
- package/dist/add-upgradeable.js.map +1 -1
- package/dist/common-options.d.ts +1 -0
- package/dist/common-options.d.ts.map +1 -1
- package/dist/common-options.js +2 -0
- package/dist/common-options.js.map +1 -1
- package/dist/contract.d.ts +2 -0
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +7 -0
- package/dist/contract.js.map +1 -1
- package/dist/fungible.d.ts.map +1 -1
- package/dist/fungible.js +35 -14
- 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/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/stablecoin.d.ts.map +1 -1
- package/dist/generate/stablecoin.js +1 -0
- package/dist/generate/stablecoin.js.map +1 -1
- package/dist/non-fungible.d.ts +1 -1
- package/dist/non-fungible.d.ts.map +1 -1
- package/dist/non-fungible.js +86 -36
- package/dist/non-fungible.js.map +1 -1
- package/dist/set-access-control.d.ts +2 -2
- package/dist/set-access-control.d.ts.map +1 -1
- package/dist/set-access-control.js +105 -8
- package/dist/set-access-control.js.map +1 -1
- package/dist/stablecoin.d.ts +2 -1
- package/dist/stablecoin.d.ts.map +1 -1
- package/dist/stablecoin.js +27 -6
- package/dist/stablecoin.js.map +1 -1
- package/dist/utils/compile-test.d.ts +1 -0
- package/dist/utils/compile-test.d.ts.map +1 -1
- package/dist/utils/compile-test.js +19 -5
- package/dist/utils/compile-test.js.map +1 -1
- package/dist/zip-rust.d.ts.map +1 -1
- package/dist/zip-rust.js +4 -0
- package/dist/zip-rust.js.map +1 -1
- package/package.json +3 -3
- package/src/add-pausable.ts +30 -15
- package/src/add-upgradeable.ts +13 -6
- package/src/common-options.ts +3 -0
- package/src/contract.ts +9 -0
- package/src/fungible.ts +53 -19
- package/src/generate/fungible.ts +1 -0
- package/src/generate/non-fungible.ts +1 -0
- package/src/generate/stablecoin.ts +1 -0
- package/src/non-fungible.ts +123 -40
- package/src/set-access-control.ts +105 -7
- package/src/stablecoin.ts +39 -9
- package/src/utils/compile-test.ts +52 -25
- package/src/zip-rust.ts +5 -0
package/dist/stablecoin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stablecoin.js","sourceRoot":"","sources":["../src/stablecoin.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"stablecoin.js","sourceRoot":"","sources":["../src/stablecoin.ts"],"names":[],"mappings":";;;AAwBA,0CAEC;AAeD,0DAEC;AAED,0CAUC;AAvDD,qDAA8C;AAG9C,yCAMoB;AACpB,mCAAwC;AACxC,6DAAyE;AACzE,+DAA2D;AAE9C,QAAA,QAAQ,GAAgC;IACnD,GAAG,mBAAgB;IACnB,IAAI,EAAE,cAAc;IACpB,MAAM,EAAE,KAAK;IACb,WAAW,EAAE,KAAK;CACV,CAAC;AAEE,QAAA,kBAAkB,GAAG,CAAC,KAAK,EAAE,WAAW,EAAE,WAAW,CAAU,CAAC;AAG7E,SAAgB,eAAe,CAAC,OAA0B,gBAAQ;IAChE,OAAO,IAAA,qBAAa,EAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;AAC9C,CAAC;AAMD,SAAS,YAAY,CAAC,IAAuB;IAC3C,OAAO;QACL,GAAG,IAAA,uBAAoB,EAAC,IAAI,CAAC;QAC7B,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,gBAAQ,CAAC,IAAI;QA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CAAC;SAC7C;QACD,OAAO,EAAE;YACP,IAAI,EAAE,CAAC,IAAA,2BAAU,GAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;YAC1D,OAAO,EAAE,MAAM;YACf,IAAI,EAAE,CAAC,iCAAiC,CAAC;SAC1C;QACD,UAAU,EAAE;YACV,IAAI,EAAE,CAAC,IAAA,2BAAU,GAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;YAC9F,IAAI,EAAE,CAAC,iCAAiC,CAAC;SAC1C;QACD,YAAY,EAAE;YACZ,IAAI,EAAE,CAAC,IAAA,2BAAU,GAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;YAC9F,IAAI,EAAE,CAAC,mCAAmC,CAAC;SAC5C;KACF,CAAC;CACH,CAAC"}
|
|
@@ -7,6 +7,7 @@ export type MakeContract = (opt: GenericOptions) => Contract;
|
|
|
7
7
|
export declare const withTemporaryFolderDo: <Args extends unknown[]>(testFunction: WithTemporaryFolderTestFunction<Args>) => (...testFunctionArguments: Args) => (test: ExecutionContext) => Promise<void>;
|
|
8
8
|
export declare const runRustCompilationTest: (makeContract: MakeContract, opts: GenericOptions, testOptions: {
|
|
9
9
|
snapshotResult: boolean;
|
|
10
|
+
excludeExplicitTraitTest?: boolean;
|
|
10
11
|
}) => (test: ExecutionContext) => Promise<void>;
|
|
11
12
|
export {};
|
|
12
13
|
//# sourceMappingURL=compile-test.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile-test.d.ts","sourceRoot":"","sources":["../../src/utils/compile-test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compile-test.d.ts","sourceRoot":"","sources":["../../src/utils/compile-test.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAC;AAM5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAO5C,eAAO,MAAM,YAAY,GAAU,GAAG,gBAAgB,EAAE,iBAAiB,MAAM,kBAI9E,CAAC;AAEF,KAAK,+BAA+B,CAAC,IAAI,SAAS,OAAO,EAAE,IAAI,CAC7D,GAAG,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,gBAAgB,EAAE,MAAM,CAAC,KACzC,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAE1B,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,cAAc,KAAK,QAAQ,CAAC;AAE7D,eAAO,MAAM,qBAAqB,GAC/B,IAAI,SAAS,OAAO,EAAE,EAAE,cAAc,+BAA+B,CAAC,IAAI,CAAC,MAC3E,GAAG,uBAAuB,IAAI,MACxB,MAAM,gBAAgB,kBAO5B,CAAC;AAkCJ,eAAO,MAAM,sBAAsB;oBAIA,OAAO;+BAA6B,OAAO;OA7CrE,MAAM,gBAAgB,kBAkE9B,CAAC"}
|
|
@@ -4,14 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.runRustCompilationTest = exports.withTemporaryFolderDo = exports.runCargoTest = void 0;
|
|
7
|
+
const child_process_1 = require("child_process");
|
|
8
|
+
const promises_1 = require("fs/promises");
|
|
7
9
|
const os_1 = require("os");
|
|
8
10
|
const path_1 = __importDefault(require("path"));
|
|
9
11
|
const util_1 = require("util");
|
|
10
|
-
const child_process_1 = require("child_process");
|
|
11
|
-
const zip_test_1 = require("./zip-test");
|
|
12
|
-
const promises_1 = require("fs/promises");
|
|
13
|
-
const zip_shared_1 = require("../zip-shared");
|
|
14
12
|
const zip_rust_1 = require("../zip-rust");
|
|
13
|
+
const zip_shared_1 = require("../zip-shared");
|
|
14
|
+
const zip_test_1 = require("./zip-test");
|
|
15
15
|
const asyncExec = (0, util_1.promisify)(child_process_1.exec);
|
|
16
16
|
const runCargoTest = async (t, temporaryFolder) => {
|
|
17
17
|
const result = await asyncExec(`cd "${temporaryFolder}" && cargo test`);
|
|
@@ -28,8 +28,9 @@ const withTemporaryFolderDo = (testFunction) => (...testFunctionArguments) => as
|
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
30
|
exports.withTemporaryFolderDo = withTemporaryFolderDo;
|
|
31
|
-
|
|
31
|
+
const doRunRustCompilationTest = async (makeContract, opts, testOptions, test, folderPath) => {
|
|
32
32
|
test.timeout(3000000);
|
|
33
|
+
await (0, promises_1.mkdir)(folderPath, { recursive: true });
|
|
33
34
|
const scaffoldContractName = (0, zip_shared_1.contractOptionsToContractName)(opts?.kind || 'contract');
|
|
34
35
|
const expectedZipFiles = [
|
|
35
36
|
`contracts/${scaffoldContractName}/src/contract.rs`,
|
|
@@ -37,6 +38,7 @@ exports.runRustCompilationTest = (0, exports.withTemporaryFolderDo)(async (makeC
|
|
|
37
38
|
`contracts/${scaffoldContractName}/src/lib.rs`,
|
|
38
39
|
`contracts/${scaffoldContractName}/Cargo.toml`,
|
|
39
40
|
'Cargo.toml',
|
|
41
|
+
'.gitignore',
|
|
40
42
|
'README.md',
|
|
41
43
|
];
|
|
42
44
|
const zip = await (0, zip_rust_1.zipRustProject)(makeContract(opts), opts);
|
|
@@ -45,5 +47,17 @@ exports.runRustCompilationTest = (0, exports.withTemporaryFolderDo)(async (makeC
|
|
|
45
47
|
await (0, exports.runCargoTest)(test, folderPath);
|
|
46
48
|
if (testOptions.snapshotResult)
|
|
47
49
|
await (0, zip_test_1.snapshotZipContents)(test, zip, expectedZipFiles);
|
|
50
|
+
};
|
|
51
|
+
exports.runRustCompilationTest = (0, exports.withTemporaryFolderDo)(async (makeContract, opts, testOptions, test, folderPath) => {
|
|
52
|
+
await doRunRustCompilationTest(makeContract, opts, testOptions, test, `${folderPath}/default`);
|
|
53
|
+
const shouldBeExcludedOrHasAlreadyRun = testOptions.excludeExplicitTraitTest || opts.explicitImplementations;
|
|
54
|
+
if (shouldBeExcludedOrHasAlreadyRun)
|
|
55
|
+
return;
|
|
56
|
+
try {
|
|
57
|
+
await doRunRustCompilationTest(makeContract, { ...opts, explicitImplementations: true }, testOptions, test, `${folderPath}/explicit`);
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
throw new Error(`EXPLICIT IMPLEMENTATION ERROR: ${error}`);
|
|
61
|
+
}
|
|
48
62
|
});
|
|
49
63
|
//# 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":";;;;;;AACA,iDAAqC;AACrC,0CAAiD;AACjD,2BAA4B;AAC5B,gDAAwB;AACxB,+BAAiC;AAGjC,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;AAQK,MAAM,qBAAqB,GAChC,CAAyB,YAAmD,EAAE,EAAE,CAChF,CAAC,GAAG,qBAA2B,EAAE,EAAE,CACn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AAU,CAAC,CAAC;IACtC,MAAM,IAAA,oBAAY,EAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAErC,IAAI,WAAW,CAAC,cAAc;QAAE,MAAM,IAAA,8BAAmB,EAAC,IAAI,EAAE,GAAG,EAAE,gBAAgB,CAAC,CAAC;AACzF,CAAC,CAAC;AAEW,QAAA,sBAAsB,GAAG,IAAA,6BAAqB,EACzD,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,+BAA+B,GAAG,WAAW,CAAC,wBAAwB,IAAI,IAAI,CAAC,uBAAuB,CAAC;IAC7G,IAAI,+BAA+B;QAAE,OAAO;IAE5C,IAAI,CAAC;QACH,MAAM,wBAAwB,CAC5B,YAAY,EACZ,EAAE,GAAG,IAAI,EAAE,uBAAuB,EAAE,IAAI,EAAE,EAC1C,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"}
|
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;AA6B3C,eAAO,MAAM,wBAAwB,GAAI,GAAG,QAAQ,EAAE,MAAM,cAAc,UAazE,CAAC;AAIF,eAAO,MAAM,cAAc,GAAU,GAAG,QAAQ,EAAE,MAAM,cAAc,mBACb,CAAC"}
|
package/dist/zip-rust.js
CHANGED
|
@@ -21,6 +21,9 @@ Continue your development journey with [Stellar CLI](https://github.com/stellar/
|
|
|
21
21
|
- See [Rust and Stellar installation guide](https://developers.stellar.org/docs/build/smart-contracts/getting-started/setup).
|
|
22
22
|
- See [Git installation guide](https://github.com/git-guides/install-git).
|
|
23
23
|
`;
|
|
24
|
+
const gitIgnore = `\
|
|
25
|
+
target/
|
|
26
|
+
`;
|
|
24
27
|
const createRustZipEnvironment = (c, opts) => {
|
|
25
28
|
const zip = new jszip_1.default();
|
|
26
29
|
const contractName = (0, zip_shared_1.contractOptionsToContractName)(opts?.kind || 'contract');
|
|
@@ -29,6 +32,7 @@ const createRustZipEnvironment = (c, opts) => {
|
|
|
29
32
|
zip.file(`contracts/${contractName}/src/lib.rs`, zip_shared_1.createRustLibFile);
|
|
30
33
|
zip.file(`contracts/${contractName}/Cargo.toml`, (0, zip_shared_1.printContractCargo)(contractName));
|
|
31
34
|
zip.file('Cargo.toml', zip_shared_1.workspaceCargo);
|
|
35
|
+
zip.file('.gitignore', gitIgnore);
|
|
32
36
|
return zip;
|
|
33
37
|
};
|
|
34
38
|
exports.createRustZipEnvironment = createRustZipEnvironment;
|
package/dist/zip-rust.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zip-rust.js","sourceRoot":"","sources":["../src/zip-rust.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,mCAAqE;AACrE,6CAMsB;AAEtB,MAAM,MAAM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,CAAC;IACrG,GAAG,CAAC,IAAI,CAAC,aAAa,YAAY,cAAc,EAAE,IAAA,8BAAiB,EAAC,CAAC,CAAC,CAAC,CAAC;IACxE,GAAG,CAAC,IAAI,CAAC,aAAa,YAAY,aAAa,EAAE,8BAAiB,CAAC,CAAC;IACpE,GAAG,CAAC,IAAI,CAAC,aAAa,YAAY,aAAa,EAAE,IAAA,+BAAkB,EAAC,YAAY,CAAC,CAAC,CAAC;IACnF,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,2BAAc,CAAC,CAAC;IACvC,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;IAElC,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAbW,QAAA,wBAAwB,4BAanC;AAEF,MAAM,oBAAoB,GAAG,CAAC,GAAU,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openzeppelin/wizard-stellar",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
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",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"@types/semver": "^7.5.7",
|
|
26
26
|
"ava": "^6.0.0",
|
|
27
27
|
"rimraf": "^5.0.0",
|
|
28
|
+
"semver": "^7.6.0",
|
|
28
29
|
"ts-node": "^10.4.0",
|
|
29
|
-
"typescript": "^5.0.0"
|
|
30
|
-
"semver": "^7.6.0"
|
|
30
|
+
"typescript": "^5.0.0"
|
|
31
31
|
}
|
|
32
32
|
}
|
package/src/add-pausable.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { getSelfArg } from './common-options';
|
|
2
2
|
import type { BaseFunction, ContractBuilder } from './contract';
|
|
3
3
|
import type { Access } from './set-access-control';
|
|
4
|
-
import { requireAccessControl } from './set-access-control';
|
|
4
|
+
import { DEFAULT_ACCESS_CONTROL, requireAccessControl } from './set-access-control';
|
|
5
5
|
import { defineFunctions } from './utils/define-functions';
|
|
6
6
|
|
|
7
|
-
export function addPausable(c: ContractBuilder, access: Access) {
|
|
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
|
-
c.addUseClause('stellar_macros', 'default_impl');
|
|
10
|
+
if (!explicitImplementations) c.addUseClause('stellar_macros', 'default_impl');
|
|
11
11
|
|
|
12
12
|
const pausableTrait = {
|
|
13
13
|
traitName: 'Pausable',
|
|
@@ -16,23 +16,38 @@ export function addPausable(c: ContractBuilder, access: Access) {
|
|
|
16
16
|
section: 'Utils',
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
const
|
|
20
|
-
const
|
|
19
|
+
const effectiveAccess = access === false ? DEFAULT_ACCESS_CONTROL : access;
|
|
20
|
+
const pauseFn: BaseFunction = effectiveAccess === 'ownable' ? functions.pause_unused_caller : functions.pause;
|
|
21
|
+
const unpauseFn: BaseFunction = effectiveAccess === 'ownable' ? functions.unpause_unused_caller : functions.unpause;
|
|
21
22
|
|
|
22
23
|
c.addTraitFunction(pausableTrait, functions.paused);
|
|
23
24
|
c.addTraitFunction(pausableTrait, pauseFn);
|
|
24
25
|
c.addTraitFunction(pausableTrait, unpauseFn);
|
|
25
|
-
requireAccessControl(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
requireAccessControl(
|
|
27
|
+
c,
|
|
28
|
+
pausableTrait,
|
|
29
|
+
pauseFn,
|
|
30
|
+
effectiveAccess,
|
|
31
|
+
{
|
|
32
|
+
useMacro: true,
|
|
33
|
+
role: 'pauser',
|
|
34
|
+
caller: 'caller',
|
|
35
|
+
},
|
|
36
|
+
explicitImplementations,
|
|
37
|
+
);
|
|
30
38
|
|
|
31
|
-
requireAccessControl(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
39
|
+
requireAccessControl(
|
|
40
|
+
c,
|
|
41
|
+
pausableTrait,
|
|
42
|
+
unpauseFn,
|
|
43
|
+
effectiveAccess,
|
|
44
|
+
{
|
|
45
|
+
useMacro: true,
|
|
46
|
+
role: 'pauser',
|
|
47
|
+
caller: 'caller',
|
|
48
|
+
},
|
|
49
|
+
explicitImplementations,
|
|
50
|
+
);
|
|
36
51
|
}
|
|
37
52
|
|
|
38
53
|
const functions = defineFunctions({
|
package/src/add-upgradeable.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { requireAccessControl } from './set-access-control';
|
|
|
4
4
|
import type { BaseFunction, ContractBuilder } from './contract';
|
|
5
5
|
import { defineFunctions } from './utils/define-functions';
|
|
6
6
|
|
|
7
|
-
export function addUpgradeable(c: ContractBuilder, access: Access) {
|
|
7
|
+
export function addUpgradeable(c: ContractBuilder, access: Access, explicitImplementations: boolean) {
|
|
8
8
|
const functions = defineFunctions({
|
|
9
9
|
_require_auth: {
|
|
10
10
|
args: [getSelfArg(), { name: 'operator', type: '&Address' }],
|
|
@@ -34,9 +34,16 @@ export function addUpgradeable(c: ContractBuilder, access: Access) {
|
|
|
34
34
|
|
|
35
35
|
c.addTraitFunction(upgradeableTrait, upgradeFn);
|
|
36
36
|
|
|
37
|
-
requireAccessControl(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
requireAccessControl(
|
|
38
|
+
c,
|
|
39
|
+
upgradeableTrait,
|
|
40
|
+
upgradeFn,
|
|
41
|
+
access,
|
|
42
|
+
{
|
|
43
|
+
useMacro: false,
|
|
44
|
+
role: 'upgrader',
|
|
45
|
+
caller: 'operator',
|
|
46
|
+
},
|
|
47
|
+
explicitImplementations,
|
|
48
|
+
);
|
|
42
49
|
}
|
package/src/common-options.ts
CHANGED
|
@@ -10,6 +10,7 @@ export const defaults: Required<CommonOptions> = {
|
|
|
10
10
|
export const contractDefaults: Required<CommonContractOptions> = {
|
|
11
11
|
...defaults,
|
|
12
12
|
access: false,
|
|
13
|
+
explicitImplementations: false,
|
|
13
14
|
} as const;
|
|
14
15
|
|
|
15
16
|
export interface CommonOptions {
|
|
@@ -18,6 +19,7 @@ export interface CommonOptions {
|
|
|
18
19
|
|
|
19
20
|
export interface CommonContractOptions extends CommonOptions {
|
|
20
21
|
access?: Access;
|
|
22
|
+
explicitImplementations?: boolean;
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
export function withCommonDefaults(opts: CommonOptions): Required<CommonOptions> {
|
|
@@ -30,6 +32,7 @@ export function withCommonContractDefaults(opts: CommonContractOptions): Require
|
|
|
30
32
|
return {
|
|
31
33
|
...withCommonDefaults(opts),
|
|
32
34
|
access: opts.access ?? contractDefaults.access,
|
|
35
|
+
explicitImplementations: opts.explicitImplementations ?? contractDefaults.explicitImplementations,
|
|
33
36
|
};
|
|
34
37
|
}
|
|
35
38
|
|
package/src/contract.ts
CHANGED
|
@@ -185,6 +185,10 @@ export class ContractBuilder implements Contract {
|
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
+
addTraitForEachFunctions(baseTrait: BaseTraitImplBlock, functions: Record<string, BaseFunction>) {
|
|
189
|
+
Object.values(functions).forEach(fn => this.addTraitFunction(baseTrait, fn));
|
|
190
|
+
}
|
|
191
|
+
|
|
188
192
|
// used for adding a function to a trait implementation block
|
|
189
193
|
addTraitFunction(baseTrait: BaseTraitImplBlock, fn: BaseFunction): ContractFunction {
|
|
190
194
|
const t = this.addTraitImplBlock(baseTrait);
|
|
@@ -241,6 +245,11 @@ export class ContractBuilder implements Contract {
|
|
|
241
245
|
existingFn.tags = [...(existingFn.tags ?? []), tag];
|
|
242
246
|
}
|
|
243
247
|
|
|
248
|
+
setFunctionCode(fn: BaseFunction, code: string[], baseTrait?: BaseTraitImplBlock): void {
|
|
249
|
+
const existingFn = this.getOrCreateFunction(fn, baseTrait);
|
|
250
|
+
existingFn.code = [...code];
|
|
251
|
+
}
|
|
252
|
+
|
|
244
253
|
addConstructorArgument(arg: Argument): void {
|
|
245
254
|
for (const existingArg of this.constructorArgs) {
|
|
246
255
|
if (existingArg.name == arg.name) {
|
package/src/fungible.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { OptionsError } from './error';
|
|
|
11
11
|
import { contractDefaults as commonDefaults } from './common-options';
|
|
12
12
|
import { printContract } from './print';
|
|
13
13
|
import { toByteArray, toUint } from './utils/convert-strings';
|
|
14
|
+
import { pickKeys } from '@openzeppelin/wizard-common';
|
|
14
15
|
|
|
15
16
|
export const defaults: Required<FungibleOptions> = {
|
|
16
17
|
name: 'MyToken',
|
|
@@ -22,6 +23,7 @@ export const defaults: Required<FungibleOptions> = {
|
|
|
22
23
|
mintable: false,
|
|
23
24
|
access: commonDefaults.access,
|
|
24
25
|
info: commonDefaults.info,
|
|
26
|
+
explicitImplementations: commonDefaults.explicitImplementations,
|
|
25
27
|
} as const;
|
|
26
28
|
|
|
27
29
|
export function printFungible(opts: FungibleOptions = defaults): string {
|
|
@@ -59,58 +61,68 @@ export function buildFungible(opts: FungibleOptions): ContractBuilder {
|
|
|
59
61
|
|
|
60
62
|
const allOpts = withDefaults(opts);
|
|
61
63
|
|
|
62
|
-
addBase(c, toByteArray(allOpts.name), toByteArray(allOpts.symbol), allOpts.pausable);
|
|
64
|
+
addBase(c, toByteArray(allOpts.name), toByteArray(allOpts.symbol), allOpts.pausable, allOpts.explicitImplementations);
|
|
63
65
|
|
|
64
66
|
if (allOpts.premint) {
|
|
65
67
|
addPremint(c, allOpts.premint);
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
if (allOpts.pausable) {
|
|
69
|
-
addPausable(c, allOpts.access);
|
|
71
|
+
addPausable(c, allOpts.access, allOpts.explicitImplementations);
|
|
70
72
|
}
|
|
71
73
|
|
|
72
74
|
if (allOpts.upgradeable) {
|
|
73
|
-
addUpgradeable(c, allOpts.access);
|
|
75
|
+
addUpgradeable(c, allOpts.access, allOpts.explicitImplementations);
|
|
74
76
|
}
|
|
75
77
|
|
|
76
78
|
if (allOpts.burnable) {
|
|
77
|
-
addBurnable(c, allOpts.pausable);
|
|
79
|
+
addBurnable(c, allOpts.pausable, allOpts.explicitImplementations);
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
if (allOpts.mintable) {
|
|
81
|
-
addMintable(c, allOpts.access, allOpts.pausable);
|
|
83
|
+
addMintable(c, allOpts.access, allOpts.pausable, allOpts.explicitImplementations);
|
|
82
84
|
}
|
|
83
85
|
|
|
84
|
-
setAccessControl(c, allOpts.access);
|
|
86
|
+
setAccessControl(c, allOpts.access, allOpts.explicitImplementations);
|
|
85
87
|
setInfo(c, allOpts.info);
|
|
86
88
|
|
|
87
89
|
return c;
|
|
88
90
|
}
|
|
89
91
|
|
|
90
|
-
function addBase(
|
|
92
|
+
function addBase(
|
|
93
|
+
c: ContractBuilder,
|
|
94
|
+
name: string,
|
|
95
|
+
symbol: string,
|
|
96
|
+
pausable: boolean,
|
|
97
|
+
explicitImplementations: boolean,
|
|
98
|
+
) {
|
|
91
99
|
// Set metadata
|
|
92
100
|
c.addConstructorCode(`Base::set_metadata(e, 18, String::from_str(e, "${name}"), String::from_str(e, "${symbol}"));`);
|
|
93
101
|
|
|
94
102
|
// Set token functions
|
|
95
103
|
c.addUseClause('stellar_tokens::fungible', 'Base');
|
|
96
104
|
c.addUseClause('stellar_tokens::fungible', 'FungibleToken');
|
|
97
|
-
c.addUseClause('stellar_macros', 'default_impl');
|
|
105
|
+
if (!explicitImplementations) c.addUseClause('stellar_macros', 'default_impl');
|
|
98
106
|
c.addUseClause('soroban_sdk', 'contract');
|
|
99
107
|
c.addUseClause('soroban_sdk', 'contractimpl');
|
|
100
108
|
c.addUseClause('soroban_sdk', 'String');
|
|
101
109
|
c.addUseClause('soroban_sdk', 'Env');
|
|
110
|
+
if (explicitImplementations || pausable) {
|
|
111
|
+
c.addUseClause('soroban_sdk', 'Address');
|
|
112
|
+
}
|
|
102
113
|
|
|
103
114
|
const fungibleTokenTrait = {
|
|
104
115
|
traitName: 'FungibleToken',
|
|
105
116
|
structName: c.name,
|
|
106
|
-
tags: ['default_impl', 'contractimpl'],
|
|
117
|
+
tags: explicitImplementations ? ['contractimpl'] : ['default_impl', 'contractimpl'],
|
|
107
118
|
assocType: 'type ContractType = Base;',
|
|
108
119
|
};
|
|
109
120
|
|
|
110
121
|
c.addTraitImplBlock(fungibleTokenTrait);
|
|
111
122
|
|
|
123
|
+
if (explicitImplementations) c.addTraitForEachFunctions(fungibleTokenTrait, fungibleTokenTraitFunctions);
|
|
124
|
+
|
|
112
125
|
if (pausable) {
|
|
113
|
-
c.addUseClause('soroban_sdk', 'Address');
|
|
114
126
|
c.addUseClause('stellar_macros', 'when_not_paused');
|
|
115
127
|
|
|
116
128
|
c.addTraitFunction(fungibleTokenTrait, functions.transfer);
|
|
@@ -121,7 +133,7 @@ function addBase(c: ContractBuilder, name: string, symbol: string, pausable: boo
|
|
|
121
133
|
}
|
|
122
134
|
}
|
|
123
135
|
|
|
124
|
-
function addMintable(c: ContractBuilder, access: Access, pausable: boolean) {
|
|
136
|
+
function addMintable(c: ContractBuilder, access: Access, pausable: boolean, explicitImplementations: boolean) {
|
|
125
137
|
c.addUseClause('soroban_sdk', 'Address');
|
|
126
138
|
switch (access) {
|
|
127
139
|
case false:
|
|
@@ -129,7 +141,7 @@ function addMintable(c: ContractBuilder, access: Access, pausable: boolean) {
|
|
|
129
141
|
case 'ownable': {
|
|
130
142
|
c.addFreeFunction(functions.mint);
|
|
131
143
|
|
|
132
|
-
requireAccessControl(c, undefined, functions.mint, access);
|
|
144
|
+
requireAccessControl(c, undefined, functions.mint, access, undefined, explicitImplementations);
|
|
133
145
|
|
|
134
146
|
if (pausable) {
|
|
135
147
|
c.addFunctionTag(functions.mint, 'when_not_paused');
|
|
@@ -139,11 +151,18 @@ function addMintable(c: ContractBuilder, access: Access, pausable: boolean) {
|
|
|
139
151
|
case 'roles': {
|
|
140
152
|
c.addFreeFunction(functions.mint_with_caller);
|
|
141
153
|
|
|
142
|
-
requireAccessControl(
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
154
|
+
requireAccessControl(
|
|
155
|
+
c,
|
|
156
|
+
undefined,
|
|
157
|
+
functions.mint_with_caller,
|
|
158
|
+
access,
|
|
159
|
+
{
|
|
160
|
+
useMacro: true,
|
|
161
|
+
caller: 'caller',
|
|
162
|
+
role: 'minter',
|
|
163
|
+
},
|
|
164
|
+
explicitImplementations,
|
|
165
|
+
);
|
|
147
166
|
|
|
148
167
|
if (pausable) {
|
|
149
168
|
c.addFunctionTag(functions.mint_with_caller, 'when_not_paused');
|
|
@@ -157,7 +176,7 @@ function addMintable(c: ContractBuilder, access: Access, pausable: boolean) {
|
|
|
157
176
|
}
|
|
158
177
|
}
|
|
159
178
|
|
|
160
|
-
function addBurnable(c: ContractBuilder, pausable: boolean) {
|
|
179
|
+
function addBurnable(c: ContractBuilder, pausable: boolean, explicitImplementations: boolean) {
|
|
161
180
|
c.addUseClause('stellar_tokens::fungible', 'burnable::FungibleBurnable');
|
|
162
181
|
c.addUseClause('soroban_sdk', 'Address');
|
|
163
182
|
|
|
@@ -176,7 +195,8 @@ function addBurnable(c: ContractBuilder, pausable: boolean) {
|
|
|
176
195
|
|
|
177
196
|
c.addTraitFunction(fungibleBurnableTrait, functions.burn_from);
|
|
178
197
|
c.addFunctionTag(functions.burn_from, 'when_not_paused', fungibleBurnableTrait);
|
|
179
|
-
} else
|
|
198
|
+
} else if (explicitImplementations) c.addTraitForEachFunctions(fungibleBurnableTrait, fungibleBurnableFunctions);
|
|
199
|
+
else {
|
|
180
200
|
// prepend '#[default_impl]'
|
|
181
201
|
fungibleBurnableTrait.tags.unshift('default_impl');
|
|
182
202
|
c.addTraitImplBlock(fungibleBurnableTrait);
|
|
@@ -335,3 +355,17 @@ export const functions = defineFunctions({
|
|
|
335
355
|
code: ['Base::mint(e, &account, amount);'],
|
|
336
356
|
},
|
|
337
357
|
});
|
|
358
|
+
|
|
359
|
+
const fungibleTokenTraitFunctions = pickKeys(functions, [
|
|
360
|
+
'total_supply',
|
|
361
|
+
'balance',
|
|
362
|
+
'allowance',
|
|
363
|
+
'transfer',
|
|
364
|
+
'transfer_from',
|
|
365
|
+
'approve',
|
|
366
|
+
'decimals',
|
|
367
|
+
'name',
|
|
368
|
+
'symbol',
|
|
369
|
+
]);
|
|
370
|
+
|
|
371
|
+
const fungibleBurnableFunctions = pickKeys(functions, ['burn', 'burn_from']);
|
package/src/generate/fungible.ts
CHANGED