@openzeppelin/wizard-stellar 0.2.3 → 0.3.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 +9 -4
- package/dist/add-pausable.js.map +1 -1
- package/dist/add-upgradeable.d.ts.map +1 -1
- package/dist/add-upgradeable.js +6 -2
- 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 +9 -1
- package/dist/api.js.map +1 -1
- package/dist/build-generic.d.ts +5 -1
- 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 +1 -1
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +9 -1
- package/dist/contract.js.map +1 -1
- package/dist/fungible.d.ts +5 -2
- package/dist/fungible.d.ts.map +1 -1
- package/dist/fungible.js +80 -50
- package/dist/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 +3 -0
- package/dist/generate/stablecoin.d.ts.map +1 -0
- package/dist/generate/stablecoin.js +24 -0
- package/dist/generate/stablecoin.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- 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 +91 -71
- package/dist/non-fungible.js.map +1 -1
- package/dist/print.js +5 -5
- package/dist/print.js.map +1 -1
- package/dist/set-access-control.d.ts +7 -4
- package/dist/set-access-control.d.ts.map +1 -1
- package/dist/set-access-control.js +57 -15
- package/dist/set-access-control.js.map +1 -1
- package/dist/stablecoin.d.ts +11 -0
- package/dist/stablecoin.d.ts.map +1 -0
- package/dist/stablecoin.js +103 -0
- package/dist/stablecoin.js.map +1 -0
- package/dist/utils/define-functions.d.ts +4 -2
- package/dist/utils/define-functions.d.ts.map +1 -1
- package/dist/utils/define-functions.js +7 -1
- package/dist/utils/define-functions.js.map +1 -1
- package/dist/utils/version.d.ts +3 -3
- package/dist/utils/version.js +2 -2
- package/dist/zip-shared.d.ts +1 -1
- package/package.json +1 -1
- package/src/add-pausable.ts +9 -4
- package/src/add-upgradeable.ts +6 -2
- package/src/api.ts +27 -4
- package/src/build-generic.ts +6 -0
- package/src/contract.ts +9 -2
- package/src/fungible.ts +84 -56
- package/src/generate/sources.ts +7 -0
- package/src/generate/stablecoin.ts +23 -0
- package/src/index.ts +2 -0
- package/src/kind.ts +1 -0
- package/src/non-fungible.ts +98 -77
- package/src/print.ts +5 -5
- package/src/set-access-control.ts +72 -19
- package/src/stablecoin.ts +124 -0
- package/src/utils/define-functions.ts +11 -4
- package/src/utils/version.ts +2 -2
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DEFAULT_ACCESS_CONTROL = exports.accessOptions = void 0;
|
|
4
4
|
exports.setAccessControl = setAccessControl;
|
|
5
5
|
exports.requireAccessControl = requireAccessControl;
|
|
6
|
-
exports.accessOptions = [false, 'ownable'];
|
|
6
|
+
exports.accessOptions = [false, 'ownable', 'roles'];
|
|
7
7
|
exports.DEFAULT_ACCESS_CONTROL = 'ownable';
|
|
8
8
|
/**
|
|
9
9
|
* Sets access control for the contract via constructor args.
|
|
@@ -15,14 +15,36 @@ function setAccessControl(c, access) {
|
|
|
15
15
|
case 'ownable': {
|
|
16
16
|
if (!c.ownable) {
|
|
17
17
|
c.ownable = true;
|
|
18
|
-
c.addUseClause('soroban_sdk', '
|
|
19
|
-
c.addUseClause('
|
|
20
|
-
c.
|
|
18
|
+
c.addUseClause('soroban_sdk', 'Address');
|
|
19
|
+
c.addUseClause('stellar_ownable', 'self', { alias: 'ownable' });
|
|
20
|
+
c.addUseClause('stellar_ownable', 'Ownable');
|
|
21
|
+
const ownableTrait = {
|
|
22
|
+
traitName: 'Ownable',
|
|
23
|
+
structName: c.name,
|
|
24
|
+
tags: ['default_impl', 'contractimpl'],
|
|
25
|
+
section: 'Utils',
|
|
26
|
+
};
|
|
27
|
+
c.addTraitImplBlock(ownableTrait);
|
|
21
28
|
c.addConstructorArgument({ name: 'owner', type: 'Address' });
|
|
22
|
-
c.addConstructorCode('e
|
|
29
|
+
c.addConstructorCode('ownable::set_owner(e, &owner);');
|
|
23
30
|
}
|
|
24
31
|
break;
|
|
25
32
|
}
|
|
33
|
+
case 'roles': {
|
|
34
|
+
c.addUseClause('soroban_sdk', 'Address');
|
|
35
|
+
c.addUseClause('stellar_access_control', 'self', { alias: 'access_control' });
|
|
36
|
+
c.addUseClause('stellar_access_control', 'AccessControl');
|
|
37
|
+
const accessControltrait = {
|
|
38
|
+
traitName: 'AccessControl',
|
|
39
|
+
structName: c.name,
|
|
40
|
+
tags: ['default_impl', 'contractimpl'],
|
|
41
|
+
section: 'Utils',
|
|
42
|
+
};
|
|
43
|
+
c.addTraitImplBlock(accessControltrait);
|
|
44
|
+
c.addConstructorArgument({ name: 'admin', type: 'Address' });
|
|
45
|
+
c.addConstructorCode('access_control::set_admin(e, &admin);');
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
26
48
|
default: {
|
|
27
49
|
const _ = access;
|
|
28
50
|
throw new Error('Unknown value for `access`');
|
|
@@ -31,25 +53,45 @@ function setAccessControl(c, access) {
|
|
|
31
53
|
}
|
|
32
54
|
/**
|
|
33
55
|
* Enables access control for the contract and restricts the given function with access control.
|
|
34
|
-
*
|
|
35
|
-
* If `caller` is provided, requires that the caller is the owner. Otherwise, requires that the owner is authorized.
|
|
36
56
|
*/
|
|
37
|
-
function requireAccessControl(c, trait, fn, access,
|
|
57
|
+
function requireAccessControl(c, trait, fn, access, accessProps = { useMacro: true }) {
|
|
38
58
|
if (access === false) {
|
|
39
59
|
access = exports.DEFAULT_ACCESS_CONTROL;
|
|
40
60
|
}
|
|
41
61
|
setAccessControl(c, access);
|
|
42
62
|
switch (access) {
|
|
43
63
|
case 'ownable': {
|
|
44
|
-
c.addUseClause('
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
c.addFunctionCodeBefore(fn, [
|
|
64
|
+
c.addUseClause('stellar_ownable_macro', 'only_owner');
|
|
65
|
+
if (accessProps.useMacro) {
|
|
66
|
+
c.addFunctionTag(fn, 'only_owner', trait);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
c.addFunctionCodeBefore(fn, [`ownable::enforce_owner_auth(e);`], trait);
|
|
70
|
+
}
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
case 'roles': {
|
|
74
|
+
const { useMacro, caller, role } = accessProps;
|
|
75
|
+
if (caller && role) {
|
|
76
|
+
c.addUseClause('soroban_sdk', 'Symbol');
|
|
77
|
+
c.addConstructorArgument({ name: role, type: 'Address' });
|
|
78
|
+
c.addConstructorCode(`access_control::grant_role_no_auth(e, &admin, &${role}, &Symbol::new(e, "${role}"));`);
|
|
79
|
+
if (useMacro) {
|
|
80
|
+
c.addUseClause('stellar_access_control_macros', 'only_role');
|
|
81
|
+
c.addFunctionTag(fn, `only_role(${caller}, "${role}")`, trait);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
c.addFunctionCodeBefore(fn, [`access_control::ensure_role(e, ${caller}, &Symbol::new(e, "${role}"));`], trait);
|
|
85
|
+
}
|
|
50
86
|
}
|
|
51
87
|
else {
|
|
52
|
-
|
|
88
|
+
if (useMacro) {
|
|
89
|
+
c.addUseClause('stellar_access_control_macros', 'only_admin');
|
|
90
|
+
c.addFunctionTag(fn, 'only_admin', trait);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
c.addFunctionCodeBefore(fn, ['access_control::enforce_admin_auth(e);'], trait);
|
|
94
|
+
}
|
|
53
95
|
}
|
|
54
96
|
break;
|
|
55
97
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-access-control.js","sourceRoot":"","sources":["../src/set-access-control.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"set-access-control.js","sourceRoot":"","sources":["../src/set-access-control.ts"],"names":[],"mappings":";;;AAeA,4CA8CC;AAKD,oDA0DC;AA1HY,QAAA,aAAa,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,CAAU,CAAC;AACrD,QAAA,sBAAsB,GAAG,SAAS,CAAC;AAShD;;GAEG;AACH,SAAgB,gBAAgB,CAAC,CAAkB,EAAE,MAAc;IACjE,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,KAAK;YACR,MAAM;QACR,KAAK,SAAS,CAAC,CAAC,CAAC;YACf,IAAI,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;gBACf,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC;gBACjB,CAAC,CAAC,YAAY,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;gBACzC,CAAC,CAAC,YAAY,CAAC,iBAAiB,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;gBAChE,CAAC,CAAC,YAAY,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAC;gBAE7C,MAAM,YAAY,GAAG;oBACnB,SAAS,EAAE,SAAS;oBACpB,UAAU,EAAE,CAAC,CAAC,IAAI;oBAClB,IAAI,EAAE,CAAC,cAAc,EAAE,cAAc,CAAC;oBACtC,OAAO,EAAE,OAAO;iBACjB,CAAC;gBACF,CAAC,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC;gBAElC,CAAC,CAAC,sBAAsB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;gBAC7D,CAAC,CAAC,kBAAkB,CAAC,gCAAgC,CAAC,CAAC;YAC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CAAC;oBACN,CAAC,CAAC,qBAAqB,CAAC,EAAE,EAAE,CAAC,wCAAwC,CAAC,EAAE,KAAK,CAAC,CAAC;gBACjF,CAAC;YACH,CAAC;YAED,MAAM;QACR,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACR,MAAM,CAAC,GAAU,MAAM,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Contract } from './contract';
|
|
2
|
+
import type { FungibleOptions } from './fungible';
|
|
3
|
+
export declare const defaults: Required<StablecoinOptions>;
|
|
4
|
+
export declare const limitationsOptions: readonly [false, "allowlist", "blocklist"];
|
|
5
|
+
export declare function printStablecoin(opts?: StablecoinOptions): string;
|
|
6
|
+
export interface StablecoinOptions extends FungibleOptions {
|
|
7
|
+
limitations?: false | 'allowlist' | 'blocklist';
|
|
8
|
+
}
|
|
9
|
+
export declare function isAccessControlRequired(opts: Partial<StablecoinOptions>): boolean;
|
|
10
|
+
export declare function buildStablecoin(opts: StablecoinOptions): Contract;
|
|
11
|
+
//# sourceMappingURL=stablecoin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stablecoin.d.ts","sourceRoot":"","sources":["../src/stablecoin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAmB,MAAM,YAAY,CAAC;AAI5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAUlD,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,iBAAiB,CAKvC,CAAC;AAEX,eAAO,MAAM,kBAAkB,4CAA6C,CAAC;AAE7E,wBAAgB,eAAe,CAAC,IAAI,GAAE,iBAA4B,GAAG,MAAM,CAE1E;AAED,MAAM,WAAW,iBAAkB,SAAQ,eAAe;IACxD,WAAW,CAAC,EAAE,KAAK,GAAG,WAAW,GAAG,WAAW,CAAC;CACjD;AAWD,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAAG,OAAO,CAEjF;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,iBAAiB,GAAG,QAAQ,CAUjE"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.limitationsOptions = exports.defaults = void 0;
|
|
4
|
+
exports.printStablecoin = printStablecoin;
|
|
5
|
+
exports.isAccessControlRequired = isAccessControlRequired;
|
|
6
|
+
exports.buildStablecoin = buildStablecoin;
|
|
7
|
+
const define_functions_1 = require("./utils/define-functions");
|
|
8
|
+
const common_options_1 = require("./common-options");
|
|
9
|
+
const print_1 = require("./print");
|
|
10
|
+
const fungible_1 = require("./fungible");
|
|
11
|
+
const set_access_control_1 = require("./set-access-control");
|
|
12
|
+
exports.defaults = {
|
|
13
|
+
...fungible_1.defaults,
|
|
14
|
+
name: 'MyStablecoin',
|
|
15
|
+
symbol: 'MST',
|
|
16
|
+
limitations: false,
|
|
17
|
+
};
|
|
18
|
+
exports.limitationsOptions = [false, 'allowlist', 'blocklist'];
|
|
19
|
+
function printStablecoin(opts = exports.defaults) {
|
|
20
|
+
return (0, print_1.printContract)(buildStablecoin(opts));
|
|
21
|
+
}
|
|
22
|
+
function withDefaults(opts) {
|
|
23
|
+
var _a, _b, _c;
|
|
24
|
+
return {
|
|
25
|
+
...(0, fungible_1.withDefaults)(opts),
|
|
26
|
+
name: (_a = opts.name) !== null && _a !== void 0 ? _a : exports.defaults.name,
|
|
27
|
+
symbol: (_b = opts.symbol) !== null && _b !== void 0 ? _b : exports.defaults.symbol,
|
|
28
|
+
limitations: (_c = opts.limitations) !== null && _c !== void 0 ? _c : exports.defaults.limitations,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function isAccessControlRequired(opts) {
|
|
32
|
+
return (0, fungible_1.isAccessControlRequired)(opts) || opts.limitations !== false;
|
|
33
|
+
}
|
|
34
|
+
function buildStablecoin(opts) {
|
|
35
|
+
const allOpts = withDefaults(opts);
|
|
36
|
+
const c = (0, fungible_1.buildFungible)(allOpts);
|
|
37
|
+
if (allOpts.limitations) {
|
|
38
|
+
addLimitations(c, allOpts.access, allOpts.limitations);
|
|
39
|
+
}
|
|
40
|
+
return c;
|
|
41
|
+
}
|
|
42
|
+
function addLimitations(c, access, mode) {
|
|
43
|
+
const type = mode === 'allowlist';
|
|
44
|
+
const limitationsTrait = {
|
|
45
|
+
traitName: type ? 'FungibleAllowList' : 'FungibleBlockList',
|
|
46
|
+
structName: c.name,
|
|
47
|
+
tags: ['contractimpl'],
|
|
48
|
+
section: 'Extensions',
|
|
49
|
+
};
|
|
50
|
+
if (type) {
|
|
51
|
+
c.addUseClause('stellar_fungible', 'allowlist::{AllowList, FungibleAllowList}');
|
|
52
|
+
c.overrideAssocType('FungibleToken', 'type ContractType = AllowList;');
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
c.addUseClause('stellar_fungible', 'blocklist::{BlockList, FungibleBlockList}');
|
|
56
|
+
c.overrideAssocType('FungibleToken', 'type ContractType = BlockList;');
|
|
57
|
+
}
|
|
58
|
+
const [getterFn, addFn, removeFn] = type
|
|
59
|
+
? [functions.allowed, functions.allow_user, functions.disallow_user]
|
|
60
|
+
: [functions.blocked, functions.block_user, functions.unblock_user];
|
|
61
|
+
c.addTraitFunction(limitationsTrait, getterFn);
|
|
62
|
+
const accessProps = {
|
|
63
|
+
useMacro: true,
|
|
64
|
+
role: 'manager',
|
|
65
|
+
caller: 'operator',
|
|
66
|
+
};
|
|
67
|
+
c.addTraitFunction(limitationsTrait, addFn);
|
|
68
|
+
(0, set_access_control_1.requireAccessControl)(c, limitationsTrait, addFn, access, accessProps);
|
|
69
|
+
c.addTraitFunction(limitationsTrait, removeFn);
|
|
70
|
+
(0, set_access_control_1.requireAccessControl)(c, limitationsTrait, removeFn, access, accessProps);
|
|
71
|
+
}
|
|
72
|
+
const functions = {
|
|
73
|
+
...fungible_1.functions,
|
|
74
|
+
...(0, define_functions_1.defineFunctions)({
|
|
75
|
+
allowed: {
|
|
76
|
+
args: [(0, common_options_1.getSelfArg)(), { name: 'account', type: 'Address' }],
|
|
77
|
+
returns: 'bool',
|
|
78
|
+
code: ['AllowList::allowed(e, &account)'],
|
|
79
|
+
},
|
|
80
|
+
allow_user: {
|
|
81
|
+
args: [(0, common_options_1.getSelfArg)(), { name: 'user', type: 'Address' }, { name: 'operator', type: 'Address' }],
|
|
82
|
+
code: ['AllowList::allow_user(e, &user)'],
|
|
83
|
+
},
|
|
84
|
+
disallow_user: {
|
|
85
|
+
args: [(0, common_options_1.getSelfArg)(), { name: 'user', type: 'Address' }, { name: 'operator', type: 'Address' }],
|
|
86
|
+
code: ['AllowList::disallow_user(e, &user)'],
|
|
87
|
+
},
|
|
88
|
+
blocked: {
|
|
89
|
+
args: [(0, common_options_1.getSelfArg)(), { name: 'account', type: 'Address' }],
|
|
90
|
+
returns: 'bool',
|
|
91
|
+
code: ['BlockList::blocked(e, &account)'],
|
|
92
|
+
},
|
|
93
|
+
block_user: {
|
|
94
|
+
args: [(0, common_options_1.getSelfArg)(), { name: 'user', type: 'Address' }, { name: 'operator', type: 'Address' }],
|
|
95
|
+
code: ['BlockList::block_user(e, &user)'],
|
|
96
|
+
},
|
|
97
|
+
unblock_user: {
|
|
98
|
+
args: [(0, common_options_1.getSelfArg)(), { name: 'user', type: 'Address' }, { name: 'operator', type: 'Address' }],
|
|
99
|
+
code: ['BlockList::unblock_user(e, &user)'],
|
|
100
|
+
},
|
|
101
|
+
}),
|
|
102
|
+
};
|
|
103
|
+
//# sourceMappingURL=stablecoin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stablecoin.js","sourceRoot":"","sources":["../src/stablecoin.ts"],"names":[],"mappings":";;;AAuBA,0CAEC;AAeD,0DAEC;AAED,0CAUC;AArDD,+DAA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AE,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"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { BaseFunction } from '../contract';
|
|
2
|
-
type
|
|
3
|
-
|
|
2
|
+
type OverridableImplicitNameFunction = Omit<BaseFunction, 'name'> & {
|
|
3
|
+
name?: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function defineFunctions<F extends string>(fns: Record<F, OverridableImplicitNameFunction>): Record<F, BaseFunction>;
|
|
4
6
|
export {};
|
|
5
7
|
//# sourceMappingURL=define-functions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define-functions.d.ts","sourceRoot":"","sources":["../../src/utils/define-functions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,KAAK,
|
|
1
|
+
{"version":3,"file":"define-functions.d.ts","sourceRoot":"","sources":["../../src/utils/define-functions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,KAAK,+BAA+B,GAAG,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtF,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,EAC9C,GAAG,EAAE,MAAM,CAAC,CAAC,EAAE,+BAA+B,CAAC,GAC9C,MAAM,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC"}
|
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.defineFunctions = defineFunctions;
|
|
4
4
|
function defineFunctions(fns) {
|
|
5
|
-
return Object.fromEntries(Object.entries(fns).map(([
|
|
5
|
+
return Object.fromEntries(Object.entries(fns).map(([implicitName, fn]) => {
|
|
6
|
+
var _a;
|
|
7
|
+
return [
|
|
8
|
+
implicitName,
|
|
9
|
+
Object.assign({ name: (_a = fn.name) !== null && _a !== void 0 ? _a : implicitName }, fn),
|
|
10
|
+
];
|
|
11
|
+
}));
|
|
6
12
|
}
|
|
7
13
|
//# sourceMappingURL=define-functions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define-functions.js","sourceRoot":"","sources":["../../src/utils/define-functions.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"define-functions.js","sourceRoot":"","sources":["../../src/utils/define-functions.ts"],"names":[],"mappings":";;AAQA,0CAOC;AAPD,SAAgB,eAAe,CAAC,GAAoD;IAClF,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,EAAE,EAAE;;QAAC,OAAA;YAC9C,YAAY;YACZ,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAA,EAAE,CAAC,IAAI,mCAAI,YAAY,EAAE,EAAE,EAAE,CAAC;SACrD,CAAA;KAAA,CAAC,CACH,CAAC;AACJ,CAAC"}
|
package/dist/utils/version.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
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.3.0";
|
|
5
|
+
export declare const contractsVersionTag = "v0.3.0";
|
|
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.3.0";
|
|
10
10
|
/**
|
|
11
11
|
* The Soroban version for which compilation and testing have passing tests
|
|
12
12
|
*/
|
package/dist/utils/version.js
CHANGED
|
@@ -4,12 +4,12 @@ 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.3.0';
|
|
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.3.0';
|
|
13
13
|
/**
|
|
14
14
|
* The Soroban version for which compilation and testing have passing tests
|
|
15
15
|
*/
|
package/dist/zip-shared.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export declare const stellarDependencies: {
|
|
|
10
10
|
readonly pausable: readonly ["stellar-pausable", "stellar-pausable-macros"];
|
|
11
11
|
readonly upgradable: readonly ["stellar-upgradeable", "stellar-upgradeable-macros"];
|
|
12
12
|
};
|
|
13
|
-
export declare const allStellarDependencies: ("pausable" | "
|
|
13
|
+
export declare const allStellarDependencies: ("pausable" | "base" | "fungible" | "nonFungible" | "upgradable")[];
|
|
14
14
|
export declare const allDependencies: {
|
|
15
15
|
readonly soroban: readonly ["soroban-sdk"];
|
|
16
16
|
readonly base: readonly ["stellar-default-impl-macro"];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openzeppelin/wizard-stellar",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.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,6 +7,7 @@ import { defineFunctions } from './utils/define-functions';
|
|
|
7
7
|
export function addPausable(c: ContractBuilder, access: Access) {
|
|
8
8
|
c.addUseClause('stellar_pausable', 'self', { alias: 'pausable' });
|
|
9
9
|
c.addUseClause('stellar_pausable', 'Pausable');
|
|
10
|
+
c.addUseClause('stellar_default_impl_macro', 'default_impl');
|
|
10
11
|
|
|
11
12
|
const pausableTrait = {
|
|
12
13
|
traitName: 'Pausable',
|
|
@@ -19,8 +20,12 @@ export function addPausable(c: ContractBuilder, access: Access) {
|
|
|
19
20
|
c.addTraitFunction(pausableTrait, functions.pause);
|
|
20
21
|
c.addTraitFunction(pausableTrait, functions.unpause);
|
|
21
22
|
|
|
22
|
-
requireAccessControl(c, pausableTrait, functions.pause, access, 'caller');
|
|
23
|
-
requireAccessControl(c, pausableTrait, functions.unpause, access,
|
|
23
|
+
requireAccessControl(c, pausableTrait, functions.pause, access, { useMacro: true, role: 'pauser', caller: 'caller' });
|
|
24
|
+
requireAccessControl(c, pausableTrait, functions.unpause, access, {
|
|
25
|
+
useMacro: true,
|
|
26
|
+
role: 'pauser',
|
|
27
|
+
caller: 'caller',
|
|
28
|
+
});
|
|
24
29
|
}
|
|
25
30
|
|
|
26
31
|
const functions = defineFunctions({
|
|
@@ -31,10 +36,10 @@ const functions = defineFunctions({
|
|
|
31
36
|
},
|
|
32
37
|
pause: {
|
|
33
38
|
args: [getSelfArg(), { name: 'caller', type: 'Address' }],
|
|
34
|
-
code: ['pausable::pause(e
|
|
39
|
+
code: ['pausable::pause(e)'],
|
|
35
40
|
},
|
|
36
41
|
unpause: {
|
|
37
42
|
args: [getSelfArg(), { name: 'caller', type: 'Address' }],
|
|
38
|
-
code: ['pausable::unpause(e
|
|
43
|
+
code: ['pausable::unpause(e)'],
|
|
39
44
|
},
|
|
40
45
|
});
|
package/src/add-upgradeable.ts
CHANGED
|
@@ -8,7 +8,7 @@ export function addUpgradeable(c: ContractBuilder, access: Access) {
|
|
|
8
8
|
const functions = defineFunctions({
|
|
9
9
|
_require_auth: {
|
|
10
10
|
args: [getSelfArg(), { name: 'operator', type: '&Address' }],
|
|
11
|
-
code: [
|
|
11
|
+
code: [],
|
|
12
12
|
},
|
|
13
13
|
});
|
|
14
14
|
|
|
@@ -26,5 +26,9 @@ export function addUpgradeable(c: ContractBuilder, access: Access) {
|
|
|
26
26
|
|
|
27
27
|
c.addTraitFunction(upgradeableTrait, functions._require_auth);
|
|
28
28
|
|
|
29
|
-
requireAccessControl(c, upgradeableTrait, functions._require_auth, access,
|
|
29
|
+
requireAccessControl(c, upgradeableTrait, functions._require_auth, access, {
|
|
30
|
+
useMacro: false,
|
|
31
|
+
role: 'upgrader',
|
|
32
|
+
caller: 'operator',
|
|
33
|
+
});
|
|
30
34
|
}
|
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 {
|
|
5
|
-
import {
|
|
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
|
|
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
|
};
|
package/src/build-generic.ts
CHANGED
|
@@ -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.
|
|
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
|
|