@openzeppelin/wizard-stellar 0.6.1 → 0.6.3
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/api.d.ts +3 -0
- 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/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/vault.d.ts +3 -0
- package/dist/generate/vault.d.ts.map +1 -0
- package/dist/generate/vault.js +21 -0
- package/dist/generate/vault.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/set-info.d.ts.map +1 -1
- package/dist/set-info.js +17 -2
- package/dist/set-info.js.map +1 -1
- package/dist/utils/compile-test.d.ts.map +1 -1
- package/dist/utils/compile-test.js +4 -1
- package/dist/utils/compile-test.js.map +1 -1
- package/dist/vault.d.ts +16 -0
- package/dist/vault.d.ts.map +1 -0
- package/dist/vault.js +334 -0
- package/dist/vault.js.map +1 -0
- package/dist/zip-rust.d.ts.map +1 -1
- package/dist/zip-rust.js +1 -1
- package/dist/zip-rust.js.map +1 -1
- package/dist/zip-shared.d.ts +1 -0
- package/dist/zip-shared.d.ts.map +1 -1
- package/dist/zip-shared.js +60 -1
- package/dist/zip-shared.js.map +1 -1
- package/package.json +1 -1
- package/src/api.ts +13 -0
- package/src/build-generic.ts +6 -0
- package/src/generate/sources.ts +7 -0
- package/src/generate/vault.ts +21 -0
- package/src/index.ts +2 -0
- package/src/kind.ts +1 -0
- package/src/set-info.ts +21 -2
- package/src/utils/compile-test.ts +5 -1
- package/src/vault.ts +378 -0
- package/src/zip-rust.ts +5 -1
- package/src/zip-shared.ts +62 -0
package/dist/vault.js
ADDED
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.functions = exports.defaults = void 0;
|
|
4
|
+
exports.printVault = printVault;
|
|
5
|
+
exports.withDefaults = withDefaults;
|
|
6
|
+
exports.isAccessControlRequired = isAccessControlRequired;
|
|
7
|
+
exports.buildVault = buildVault;
|
|
8
|
+
const contract_1 = require("./contract");
|
|
9
|
+
const set_access_control_1 = require("./set-access-control");
|
|
10
|
+
const add_pausable_1 = require("./add-pausable");
|
|
11
|
+
const add_upgradeable_1 = require("./add-upgradeable");
|
|
12
|
+
const define_functions_1 = require("./utils/define-functions");
|
|
13
|
+
const common_options_1 = require("./common-options");
|
|
14
|
+
const set_info_1 = require("./set-info");
|
|
15
|
+
const common_options_2 = require("./common-options");
|
|
16
|
+
const print_1 = require("./print");
|
|
17
|
+
const convert_strings_1 = require("./utils/convert-strings");
|
|
18
|
+
const error_1 = require("./error");
|
|
19
|
+
const wizard_common_1 = require("@openzeppelin/wizard-common");
|
|
20
|
+
// Upper bound enforced by the library's `Vault::set_decimals_offset`
|
|
21
|
+
// (`stellar_tokens::vault::MAX_DECIMALS_OFFSET`); a larger value panics on deploy.
|
|
22
|
+
const MAX_DECIMALS_OFFSET = 10;
|
|
23
|
+
exports.defaults = {
|
|
24
|
+
name: 'MyVault',
|
|
25
|
+
symbol: 'MTK',
|
|
26
|
+
decimalsOffset: '0',
|
|
27
|
+
pausable: false,
|
|
28
|
+
upgradeable: false,
|
|
29
|
+
access: common_options_2.contractDefaults.access,
|
|
30
|
+
info: common_options_2.contractDefaults.info,
|
|
31
|
+
explicitImplementations: common_options_2.contractDefaults.explicitImplementations,
|
|
32
|
+
};
|
|
33
|
+
function printVault(opts = exports.defaults) {
|
|
34
|
+
return (0, print_1.printContract)(buildVault(opts));
|
|
35
|
+
}
|
|
36
|
+
function withDefaults(opts) {
|
|
37
|
+
return {
|
|
38
|
+
...opts,
|
|
39
|
+
...(0, common_options_1.withCommonContractDefaults)(opts),
|
|
40
|
+
decimalsOffset: opts.decimalsOffset ?? exports.defaults.decimalsOffset,
|
|
41
|
+
pausable: opts.pausable ?? exports.defaults.pausable,
|
|
42
|
+
upgradeable: opts.upgradeable ?? exports.defaults.upgradeable,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function isAccessControlRequired(opts) {
|
|
46
|
+
return opts.pausable === true || opts.upgradeable === true;
|
|
47
|
+
}
|
|
48
|
+
function buildVault(opts) {
|
|
49
|
+
const c = new contract_1.ContractBuilder(opts.name);
|
|
50
|
+
const allOpts = withDefaults(opts);
|
|
51
|
+
const decimalsOffset = (0, convert_strings_1.toUint)(allOpts.decimalsOffset, 'decimalsOffset', 'u32');
|
|
52
|
+
if (decimalsOffset > MAX_DECIMALS_OFFSET) {
|
|
53
|
+
throw new error_1.OptionsError({
|
|
54
|
+
decimalsOffset: `Maximum decimals offset is ${MAX_DECIMALS_OFFSET}`,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
addBase(c, (0, convert_strings_1.toByteArray)(allOpts.name), (0, convert_strings_1.toByteArray)(allOpts.symbol), decimalsOffset, allOpts.pausable, allOpts.explicitImplementations);
|
|
58
|
+
if (allOpts.pausable) {
|
|
59
|
+
(0, add_pausable_1.addPausable)(c, allOpts.access, allOpts.explicitImplementations);
|
|
60
|
+
}
|
|
61
|
+
if (allOpts.upgradeable) {
|
|
62
|
+
(0, add_upgradeable_1.addUpgradeable)(c, allOpts.access, allOpts.explicitImplementations);
|
|
63
|
+
}
|
|
64
|
+
(0, set_access_control_1.setAccessControl)(c, allOpts.access, allOpts.explicitImplementations);
|
|
65
|
+
// The AccessControl trait surface (e.g. `get_existing_roles`, role lookups)
|
|
66
|
+
// references `Symbol` and `Vec`, which the contracttrait macro and explicit
|
|
67
|
+
// implementations need in scope even when no function is role-gated.
|
|
68
|
+
if (allOpts.access === 'roles') {
|
|
69
|
+
c.addUseClause('soroban_sdk', 'Symbol');
|
|
70
|
+
c.addUseClause('soroban_sdk', 'Vec');
|
|
71
|
+
}
|
|
72
|
+
(0, set_info_1.setInfo)(c, allOpts.info);
|
|
73
|
+
return c;
|
|
74
|
+
}
|
|
75
|
+
function addBase(c, name, symbol, decimalsOffset, pausable, explicitImplementations) {
|
|
76
|
+
// The underlying asset is supplied at deployment, while the virtual decimals
|
|
77
|
+
// offset is a baked-in configuration value. The offset must be set before the
|
|
78
|
+
// metadata because the vault derives its decimals from the underlying asset's
|
|
79
|
+
// decimals plus the offset.
|
|
80
|
+
c.addConstructorArgument({ name: 'asset', type: 'Address' });
|
|
81
|
+
c.addConstructorCode('Vault::set_asset(e, asset);');
|
|
82
|
+
c.addConstructorCode(`Vault::set_decimals_offset(e, ${decimalsOffset});`);
|
|
83
|
+
c.addConstructorCode(`Base::set_metadata(e, Self::decimals(e), String::from_str(e, "${name}"), String::from_str(e, "${symbol}"));`);
|
|
84
|
+
// Set token functions
|
|
85
|
+
c.addUseClause('stellar_tokens::fungible', 'Base');
|
|
86
|
+
c.addUseClause('stellar_tokens::fungible', 'FungibleToken');
|
|
87
|
+
c.addUseClause('stellar_tokens::vault', 'FungibleVault');
|
|
88
|
+
c.addUseClause('stellar_tokens::vault', 'Vault');
|
|
89
|
+
// The base token functions we emit delegate to `Self::ContractType::...`,
|
|
90
|
+
// which resolve through the `ContractOverrides` trait that `Vault` implements,
|
|
91
|
+
// so it must be in scope. This happens with explicit implementations (all
|
|
92
|
+
// functions are spelled out) and when pausable adds transfer overrides.
|
|
93
|
+
if (explicitImplementations || pausable)
|
|
94
|
+
c.addUseClause('stellar_tokens::fungible', 'ContractOverrides');
|
|
95
|
+
c.addUseClause('soroban_sdk', 'contract');
|
|
96
|
+
c.addUseClause('soroban_sdk', 'contractimpl');
|
|
97
|
+
c.addUseClause('soroban_sdk', 'String');
|
|
98
|
+
c.addUseClause('soroban_sdk', 'Env');
|
|
99
|
+
c.addUseClause('soroban_sdk', 'Address');
|
|
100
|
+
c.addUseClause('soroban_sdk', 'MuxedAddress');
|
|
101
|
+
const fungibleTokenTrait = {
|
|
102
|
+
traitName: 'FungibleToken',
|
|
103
|
+
structName: c.name,
|
|
104
|
+
tags: explicitImplementations ? ['contractimpl'] : ['contractimpl(contracttrait)'],
|
|
105
|
+
assocType: 'type ContractType = Vault;',
|
|
106
|
+
};
|
|
107
|
+
c.addTraitImplBlock(fungibleTokenTrait);
|
|
108
|
+
if (explicitImplementations) {
|
|
109
|
+
c.addTraitForEachFunctions(fungibleTokenTrait, fungibleTokenTraitFunctions);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
// The vault overrides decimals to derive them from the underlying asset and
|
|
113
|
+
// the virtual decimals offset.
|
|
114
|
+
c.addTraitFunction(fungibleTokenTrait, exports.functions.decimals);
|
|
115
|
+
}
|
|
116
|
+
if (pausable) {
|
|
117
|
+
c.addUseClause('stellar_macros', 'when_not_paused');
|
|
118
|
+
c.addTraitFunction(fungibleTokenTrait, exports.functions.transfer);
|
|
119
|
+
c.addFunctionTag(exports.functions.transfer, 'when_not_paused', fungibleTokenTrait);
|
|
120
|
+
c.addTraitFunction(fungibleTokenTrait, exports.functions.transfer_from);
|
|
121
|
+
c.addFunctionTag(exports.functions.transfer_from, 'when_not_paused', fungibleTokenTrait);
|
|
122
|
+
}
|
|
123
|
+
const fungibleVaultTrait = {
|
|
124
|
+
traitName: 'FungibleVault',
|
|
125
|
+
structName: c.name,
|
|
126
|
+
tags: explicitImplementations ? ['contractimpl'] : ['contractimpl(contracttrait)'],
|
|
127
|
+
section: 'Extensions',
|
|
128
|
+
};
|
|
129
|
+
if (explicitImplementations) {
|
|
130
|
+
c.addTraitForEachFunctions(fungibleVaultTrait, fungibleVaultTraitFunctions);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
c.addTraitImplBlock(fungibleVaultTrait);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
exports.functions = (0, define_functions_1.defineFunctions)({
|
|
137
|
+
// FungibleToken Trait
|
|
138
|
+
total_supply: {
|
|
139
|
+
args: [(0, common_options_1.getSelfArg)()],
|
|
140
|
+
returns: 'i128',
|
|
141
|
+
code: ['Self::ContractType::total_supply(e)'],
|
|
142
|
+
},
|
|
143
|
+
balance: {
|
|
144
|
+
args: [(0, common_options_1.getSelfArg)(), { name: 'account', type: 'Address' }],
|
|
145
|
+
returns: 'i128',
|
|
146
|
+
code: ['Self::ContractType::balance(e, &account)'],
|
|
147
|
+
},
|
|
148
|
+
allowance: {
|
|
149
|
+
args: [(0, common_options_1.getSelfArg)(), { name: 'owner', type: 'Address' }, { name: 'spender', type: 'Address' }],
|
|
150
|
+
returns: 'i128',
|
|
151
|
+
code: ['Self::ContractType::allowance(e, &owner, &spender)'],
|
|
152
|
+
},
|
|
153
|
+
transfer: {
|
|
154
|
+
args: [
|
|
155
|
+
(0, common_options_1.getSelfArg)(),
|
|
156
|
+
{ name: 'from', type: 'Address' },
|
|
157
|
+
{ name: 'to', type: 'MuxedAddress' },
|
|
158
|
+
{ name: 'amount', type: 'i128' },
|
|
159
|
+
],
|
|
160
|
+
code: ['Self::ContractType::transfer(e, &from, &to, amount)'],
|
|
161
|
+
},
|
|
162
|
+
transfer_from: {
|
|
163
|
+
args: [
|
|
164
|
+
(0, common_options_1.getSelfArg)(),
|
|
165
|
+
{ name: 'spender', type: 'Address' },
|
|
166
|
+
{ name: 'from', type: 'Address' },
|
|
167
|
+
{ name: 'to', type: 'Address' },
|
|
168
|
+
{ name: 'amount', type: 'i128' },
|
|
169
|
+
],
|
|
170
|
+
code: ['Self::ContractType::transfer_from(e, &spender, &from, &to, amount)'],
|
|
171
|
+
},
|
|
172
|
+
approve: {
|
|
173
|
+
args: [
|
|
174
|
+
(0, common_options_1.getSelfArg)(),
|
|
175
|
+
{ name: 'owner', type: 'Address' },
|
|
176
|
+
{ name: 'spender', type: 'Address' },
|
|
177
|
+
{ name: 'amount', type: 'i128' },
|
|
178
|
+
{ name: 'live_until_ledger', type: 'u32' },
|
|
179
|
+
],
|
|
180
|
+
code: ['Self::ContractType::approve(e, &owner, &spender, amount, live_until_ledger)'],
|
|
181
|
+
},
|
|
182
|
+
// The vault derives decimals from the underlying asset's decimals plus the
|
|
183
|
+
// virtual offset, so it overrides the default metadata-based implementation.
|
|
184
|
+
decimals: {
|
|
185
|
+
args: [(0, common_options_1.getSelfArg)()],
|
|
186
|
+
returns: 'u32',
|
|
187
|
+
code: ['Vault::decimals(e)'],
|
|
188
|
+
},
|
|
189
|
+
name: {
|
|
190
|
+
args: [(0, common_options_1.getSelfArg)()],
|
|
191
|
+
returns: 'String',
|
|
192
|
+
code: ['Self::ContractType::name(e)'],
|
|
193
|
+
},
|
|
194
|
+
symbol: {
|
|
195
|
+
args: [(0, common_options_1.getSelfArg)()],
|
|
196
|
+
returns: 'String',
|
|
197
|
+
code: ['Self::ContractType::symbol(e)'],
|
|
198
|
+
},
|
|
199
|
+
// FungibleVault Trait
|
|
200
|
+
query_asset: {
|
|
201
|
+
args: [(0, common_options_1.getSelfArg)()],
|
|
202
|
+
returns: 'Address',
|
|
203
|
+
code: ['Self::ContractType::query_asset(e)'],
|
|
204
|
+
},
|
|
205
|
+
total_assets: {
|
|
206
|
+
args: [(0, common_options_1.getSelfArg)()],
|
|
207
|
+
returns: 'i128',
|
|
208
|
+
code: ['Self::ContractType::total_assets(e)'],
|
|
209
|
+
},
|
|
210
|
+
convert_to_shares: {
|
|
211
|
+
args: [(0, common_options_1.getSelfArg)(), { name: 'assets', type: 'i128' }],
|
|
212
|
+
returns: 'i128',
|
|
213
|
+
code: ['Self::ContractType::convert_to_shares(e, assets)'],
|
|
214
|
+
},
|
|
215
|
+
convert_to_assets: {
|
|
216
|
+
args: [(0, common_options_1.getSelfArg)(), { name: 'shares', type: 'i128' }],
|
|
217
|
+
returns: 'i128',
|
|
218
|
+
code: ['Self::ContractType::convert_to_assets(e, shares)'],
|
|
219
|
+
},
|
|
220
|
+
max_deposit: {
|
|
221
|
+
args: [(0, common_options_1.getSelfArg)(), { name: 'receiver', type: 'Address' }],
|
|
222
|
+
returns: 'i128',
|
|
223
|
+
code: ['Self::ContractType::max_deposit(e, receiver)'],
|
|
224
|
+
},
|
|
225
|
+
preview_deposit: {
|
|
226
|
+
args: [(0, common_options_1.getSelfArg)(), { name: 'assets', type: 'i128' }],
|
|
227
|
+
returns: 'i128',
|
|
228
|
+
code: ['Self::ContractType::preview_deposit(e, assets)'],
|
|
229
|
+
},
|
|
230
|
+
deposit: {
|
|
231
|
+
args: [
|
|
232
|
+
(0, common_options_1.getSelfArg)(),
|
|
233
|
+
{ name: 'assets', type: 'i128' },
|
|
234
|
+
{ name: 'receiver', type: 'Address' },
|
|
235
|
+
{ name: 'from', type: 'Address' },
|
|
236
|
+
{ name: 'operator', type: 'Address' },
|
|
237
|
+
],
|
|
238
|
+
returns: 'i128',
|
|
239
|
+
code: ['Self::ContractType::deposit(e, assets, receiver, from, operator)'],
|
|
240
|
+
},
|
|
241
|
+
max_mint: {
|
|
242
|
+
args: [(0, common_options_1.getSelfArg)(), { name: 'receiver', type: 'Address' }],
|
|
243
|
+
returns: 'i128',
|
|
244
|
+
code: ['Self::ContractType::max_mint(e, receiver)'],
|
|
245
|
+
},
|
|
246
|
+
preview_mint: {
|
|
247
|
+
args: [(0, common_options_1.getSelfArg)(), { name: 'shares', type: 'i128' }],
|
|
248
|
+
returns: 'i128',
|
|
249
|
+
code: ['Self::ContractType::preview_mint(e, shares)'],
|
|
250
|
+
},
|
|
251
|
+
mint: {
|
|
252
|
+
args: [
|
|
253
|
+
(0, common_options_1.getSelfArg)(),
|
|
254
|
+
{ name: 'shares', type: 'i128' },
|
|
255
|
+
{ name: 'receiver', type: 'Address' },
|
|
256
|
+
{ name: 'from', type: 'Address' },
|
|
257
|
+
{ name: 'operator', type: 'Address' },
|
|
258
|
+
],
|
|
259
|
+
returns: 'i128',
|
|
260
|
+
code: ['Self::ContractType::mint(e, shares, receiver, from, operator)'],
|
|
261
|
+
},
|
|
262
|
+
max_withdraw: {
|
|
263
|
+
args: [(0, common_options_1.getSelfArg)(), { name: 'owner', type: 'Address' }],
|
|
264
|
+
returns: 'i128',
|
|
265
|
+
code: ['Self::ContractType::max_withdraw(e, owner)'],
|
|
266
|
+
},
|
|
267
|
+
preview_withdraw: {
|
|
268
|
+
args: [(0, common_options_1.getSelfArg)(), { name: 'assets', type: 'i128' }],
|
|
269
|
+
returns: 'i128',
|
|
270
|
+
code: ['Self::ContractType::preview_withdraw(e, assets)'],
|
|
271
|
+
},
|
|
272
|
+
withdraw: {
|
|
273
|
+
args: [
|
|
274
|
+
(0, common_options_1.getSelfArg)(),
|
|
275
|
+
{ name: 'assets', type: 'i128' },
|
|
276
|
+
{ name: 'receiver', type: 'Address' },
|
|
277
|
+
{ name: 'owner', type: 'Address' },
|
|
278
|
+
{ name: 'operator', type: 'Address' },
|
|
279
|
+
],
|
|
280
|
+
returns: 'i128',
|
|
281
|
+
code: ['Self::ContractType::withdraw(e, assets, receiver, owner, operator)'],
|
|
282
|
+
},
|
|
283
|
+
max_redeem: {
|
|
284
|
+
args: [(0, common_options_1.getSelfArg)(), { name: 'owner', type: 'Address' }],
|
|
285
|
+
returns: 'i128',
|
|
286
|
+
code: ['Self::ContractType::max_redeem(e, owner)'],
|
|
287
|
+
},
|
|
288
|
+
preview_redeem: {
|
|
289
|
+
args: [(0, common_options_1.getSelfArg)(), { name: 'shares', type: 'i128' }],
|
|
290
|
+
returns: 'i128',
|
|
291
|
+
code: ['Self::ContractType::preview_redeem(e, shares)'],
|
|
292
|
+
},
|
|
293
|
+
redeem: {
|
|
294
|
+
args: [
|
|
295
|
+
(0, common_options_1.getSelfArg)(),
|
|
296
|
+
{ name: 'shares', type: 'i128' },
|
|
297
|
+
{ name: 'receiver', type: 'Address' },
|
|
298
|
+
{ name: 'owner', type: 'Address' },
|
|
299
|
+
{ name: 'operator', type: 'Address' },
|
|
300
|
+
],
|
|
301
|
+
returns: 'i128',
|
|
302
|
+
code: ['Self::ContractType::redeem(e, shares, receiver, owner, operator)'],
|
|
303
|
+
},
|
|
304
|
+
});
|
|
305
|
+
const fungibleTokenTraitFunctions = (0, wizard_common_1.pickKeys)(exports.functions, [
|
|
306
|
+
'total_supply',
|
|
307
|
+
'balance',
|
|
308
|
+
'allowance',
|
|
309
|
+
'transfer',
|
|
310
|
+
'transfer_from',
|
|
311
|
+
'approve',
|
|
312
|
+
'decimals',
|
|
313
|
+
'name',
|
|
314
|
+
'symbol',
|
|
315
|
+
]);
|
|
316
|
+
const fungibleVaultTraitFunctions = (0, wizard_common_1.pickKeys)(exports.functions, [
|
|
317
|
+
'query_asset',
|
|
318
|
+
'total_assets',
|
|
319
|
+
'convert_to_shares',
|
|
320
|
+
'convert_to_assets',
|
|
321
|
+
'max_deposit',
|
|
322
|
+
'preview_deposit',
|
|
323
|
+
'deposit',
|
|
324
|
+
'max_mint',
|
|
325
|
+
'preview_mint',
|
|
326
|
+
'mint',
|
|
327
|
+
'max_withdraw',
|
|
328
|
+
'preview_withdraw',
|
|
329
|
+
'withdraw',
|
|
330
|
+
'max_redeem',
|
|
331
|
+
'preview_redeem',
|
|
332
|
+
'redeem',
|
|
333
|
+
]);
|
|
334
|
+
//# sourceMappingURL=vault.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vault.js","sourceRoot":"","sources":["../src/vault.ts"],"names":[],"mappings":";;;AA8BA,gCAEC;AAUD,oCAQC;AAED,0DAEC;AAED,gCA0CC;AAlGD,yCAA6C;AAE7C,6DAAwD;AACxD,iDAA6C;AAC7C,uDAAmD;AACnD,+DAA2D;AAE3D,qDAA0E;AAC1E,yCAAqC;AACrC,qDAAsE;AACtE,mCAAwC;AACxC,6DAA8D;AAC9D,mCAAuC;AACvC,+DAAuD;AAEvD,qEAAqE;AACrE,mFAAmF;AACnF,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAElB,QAAA,QAAQ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,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;AA+B3C,eAAO,MAAM,wBAAwB,GAAI,GAAG,QAAQ,EAAE,MAAM,cAAc,UAiBzE,CAAC;AAIF,eAAO,MAAM,cAAc,GAAU,GAAG,QAAQ,EAAE,MAAM,cAAc,mBACb,CAAC"}
|
package/dist/zip-rust.js
CHANGED
|
@@ -29,7 +29,7 @@ const createRustZipEnvironment = (c, opts) => {
|
|
|
29
29
|
const contractName = (0, zip_shared_1.contractOptionsToContractName)(opts?.kind || 'contract');
|
|
30
30
|
const requiredLibDeps = (0, zip_shared_1.getRequiredLibDependencies)(c);
|
|
31
31
|
zip.file(`contracts/${contractName}/src/contract.rs`, (0, print_1.removeCreateLevelAttributes)((0, print_1.printContract)(c)));
|
|
32
|
-
zip.file(`contracts/${contractName}/src/test.rs`, (0, zip_shared_1.printRustNameTest)(c));
|
|
32
|
+
zip.file(`contracts/${contractName}/src/test.rs`, opts?.kind === 'Vault' ? (0, zip_shared_1.printVaultRustTest)(c) : (0, zip_shared_1.printRustNameTest)(c));
|
|
33
33
|
zip.file(`contracts/${contractName}/src/lib.rs`, zip_shared_1.createRustLibFile);
|
|
34
34
|
zip.file(`contracts/${contractName}/Cargo.toml`, (0, zip_shared_1.printContractCargo)(contractName, requiredLibDeps));
|
|
35
35
|
zip.file('Cargo.toml', (0, zip_shared_1.workspaceCargo)(requiredLibDeps));
|
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,
|
|
1
|
+
{"version":3,"file":"zip-rust.js","sourceRoot":"","sources":["../src/zip-rust.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,mCAAqE;AACrE,6CAQsB;AAEtB,MAAM,MAAM,GAAG;;;;;;;;;;;;;CAad,CAAC;AAEF,MAAM,SAAS,GAAG;;CAEjB,CAAC;AAEK,MAAM,wBAAwB,GAAG,CAAC,CAAW,EAAE,IAAoB,EAAE,EAAE;IAC5E,MAAM,GAAG,GAAG,IAAI,eAAK,EAAE,CAAC;IAExB,MAAM,YAAY,GAAG,IAAA,0CAA6B,EAAC,IAAI,EAAE,IAAI,IAAI,UAAU,CAAC,CAAC;IAC7E,MAAM,eAAe,GAAG,IAAA,uCAA0B,EAAC,CAAC,CAAC,CAAC;IAEtD,GAAG,CAAC,IAAI,CAAC,aAAa,YAAY,kBAAkB,EAAE,IAAA,mCAA2B,EAAC,IAAA,qBAAa,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACrG,GAAG,CAAC,IAAI,CACN,aAAa,YAAY,cAAc,EACvC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,IAAA,+BAAkB,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAA,8BAAiB,EAAC,CAAC,CAAC,CACtE,CAAC;IACF,GAAG,CAAC,IAAI,CAAC,aAAa,YAAY,aAAa,EAAE,8BAAiB,CAAC,CAAC;IACpE,GAAG,CAAC,IAAI,CAAC,aAAa,YAAY,aAAa,EAAE,IAAA,+BAAkB,EAAC,YAAY,EAAE,eAAe,CAAC,CAAC,CAAC;IACpG,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,IAAA,2BAAc,EAAC,eAAe,CAAC,CAAC,CAAC;IACxD,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;IAElC,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAjBW,QAAA,wBAAwB,4BAiBnC;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/dist/zip-shared.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ 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 printVaultRustTest: (c: Pick<Contract, "constructorArgs" | "name">) => string;
|
|
6
7
|
export declare function getRequiredLibDependencies(c: Pick<Contract, 'useClauses'>): string[];
|
|
7
8
|
export declare const addDependenciesWith: (dependencyValue: string, dependenciesToAdd: string[]) => string;
|
|
8
9
|
export declare const printContractCargo: (scaffoldContractName: string, requiredLibDeps: readonly string[]) => string;
|
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,i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C;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,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.workspaceCargo = exports.createRustLibFile = exports.printContractCargo = exports.addDependenciesWith = exports.printRustNameTest = exports.contractOptionsToContractName = void 0;
|
|
3
|
+
exports.workspaceCargo = exports.createRustLibFile = exports.printContractCargo = exports.addDependenciesWith = exports.printVaultRustTest = exports.printRustNameTest = exports.contractOptionsToContractName = void 0;
|
|
4
4
|
exports.getAddressArgs = getAddressArgs;
|
|
5
5
|
exports.getRequiredLibDependencies = getRequiredLibDependencies;
|
|
6
6
|
const version_1 = require("./utils/version");
|
|
@@ -39,6 +39,65 @@ fn initial_state() {
|
|
|
39
39
|
// Add more tests bellow
|
|
40
40
|
`;
|
|
41
41
|
exports.printRustNameTest = printRustNameTest;
|
|
42
|
+
// The vault's constructor takes an underlying asset address and derives its own
|
|
43
|
+
// decimals by calling into that asset contract. A generated address would have
|
|
44
|
+
// no `decimals()` to call, so the test deploys a minimal mock fungible asset
|
|
45
|
+
// first and registers the vault against it. A single-element tuple needs a
|
|
46
|
+
// trailing comma in Rust.
|
|
47
|
+
const printVaultRustTest = (c) => {
|
|
48
|
+
const registerArgs = (c.constructorArgs || []).map(arg => arg.name === 'asset' ? 'asset_address.clone()' : 'Address::generate(&env)');
|
|
49
|
+
const registerTuple = `(${registerArgs.join(', ')}${registerArgs.length === 1 ? ',' : ''})`;
|
|
50
|
+
return `#![cfg(test)]
|
|
51
|
+
|
|
52
|
+
extern crate std;
|
|
53
|
+
|
|
54
|
+
use soroban_sdk::{
|
|
55
|
+
contract, contractimpl, testutils::Address as _, Address, Env, MuxedAddress, String,
|
|
56
|
+
};
|
|
57
|
+
use stellar_tokens::fungible::{Base, FungibleToken};
|
|
58
|
+
|
|
59
|
+
use crate::contract::{ ${c.name}, ${c.name}Client };
|
|
60
|
+
|
|
61
|
+
// Mock asset contract: a minimal fungible token used as the vault's underlying asset.
|
|
62
|
+
#[contract]
|
|
63
|
+
pub struct MockAssetContract;
|
|
64
|
+
|
|
65
|
+
#[contractimpl]
|
|
66
|
+
impl MockAssetContract {
|
|
67
|
+
pub fn __constructor(e: &Env, initial_supply: i128, admin: Address) {
|
|
68
|
+
Base::set_metadata(
|
|
69
|
+
e,
|
|
70
|
+
18,
|
|
71
|
+
String::from_str(e, "Mock Asset Token"),
|
|
72
|
+
String::from_str(e, "MAT"),
|
|
73
|
+
);
|
|
74
|
+
Base::mint(e, &admin, initial_supply);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
#[contractimpl(contracttrait)]
|
|
79
|
+
impl FungibleToken for MockAssetContract {
|
|
80
|
+
type ContractType = Base;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
#[test]
|
|
84
|
+
fn initial_state() {
|
|
85
|
+
let env = Env::default();
|
|
86
|
+
|
|
87
|
+
let admin = Address::generate(&env);
|
|
88
|
+
let asset_address = env.register(MockAssetContract, (1_000_000_000i128, admin));
|
|
89
|
+
|
|
90
|
+
let contract_addr = env.register(${c.name}, ${registerTuple});
|
|
91
|
+
let client = ${c.name}Client::new(&env, &contract_addr);
|
|
92
|
+
|
|
93
|
+
assert_eq!(client.query_asset(), asset_address);
|
|
94
|
+
assert_eq!(client.name(), String::from_str(&env, "${c.name}"));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Add more tests bellow
|
|
98
|
+
`;
|
|
99
|
+
};
|
|
100
|
+
exports.printVaultRustTest = printVaultRustTest;
|
|
42
101
|
const libDependencies = [
|
|
43
102
|
'stellar-tokens',
|
|
44
103
|
'stellar-access',
|
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;AAsGD,gEAGC;AAxHD,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,G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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.6.
|
|
3
|
+
"version": "0.6.3",
|
|
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/api.ts
CHANGED
|
@@ -3,11 +3,17 @@ import type { FungibleOptions } from './fungible';
|
|
|
3
3
|
import type { GovernorOptions } from './governor';
|
|
4
4
|
import type { NonFungibleOptions } from './non-fungible';
|
|
5
5
|
import type { StablecoinOptions } from './stablecoin';
|
|
6
|
+
import type { VaultOptions } from './vault';
|
|
6
7
|
import {
|
|
7
8
|
printStablecoin,
|
|
8
9
|
defaults as stablecoinDefaults,
|
|
9
10
|
isAccessControlRequired as stablecoinIsAccessControlRequired,
|
|
10
11
|
} from './stablecoin';
|
|
12
|
+
import {
|
|
13
|
+
printVault,
|
|
14
|
+
defaults as vaultDefaults,
|
|
15
|
+
isAccessControlRequired as vaultIsAccessControlRequired,
|
|
16
|
+
} from './vault';
|
|
11
17
|
import {
|
|
12
18
|
printFungible,
|
|
13
19
|
defaults as fungibledefaults,
|
|
@@ -48,6 +54,7 @@ export type Fungible = WizardContractAPI<FungibleOptions> & AccessControlAPI<Fun
|
|
|
48
54
|
export type Governor = WizardContractAPI<GovernorOptions> & AccessControlAPI<GovernorOptions>;
|
|
49
55
|
export type NonFungible = WizardContractAPI<NonFungibleOptions> & AccessControlAPI<NonFungibleOptions>;
|
|
50
56
|
export type Stablecoin = WizardContractAPI<StablecoinOptions> & AccessControlAPI<StablecoinOptions>;
|
|
57
|
+
export type Vault = WizardContractAPI<VaultOptions> & AccessControlAPI<VaultOptions>;
|
|
51
58
|
|
|
52
59
|
export const fungible: Fungible = {
|
|
53
60
|
print: printFungible,
|
|
@@ -72,3 +79,9 @@ export const stablecoin: Stablecoin = {
|
|
|
72
79
|
defaults: stablecoinDefaults,
|
|
73
80
|
isAccessControlRequired: stablecoinIsAccessControlRequired,
|
|
74
81
|
};
|
|
82
|
+
|
|
83
|
+
export const vault: Vault = {
|
|
84
|
+
print: printVault,
|
|
85
|
+
defaults: vaultDefaults,
|
|
86
|
+
isAccessControlRequired: vaultIsAccessControlRequired,
|
|
87
|
+
};
|
package/src/build-generic.ts
CHANGED
|
@@ -6,12 +6,15 @@ import type { NonFungibleOptions } from './non-fungible';
|
|
|
6
6
|
import { buildNonFungible } from './non-fungible';
|
|
7
7
|
import type { StablecoinOptions } from './stablecoin';
|
|
8
8
|
import { buildStablecoin } from './stablecoin';
|
|
9
|
+
import type { VaultOptions } from './vault';
|
|
10
|
+
import { buildVault } from './vault';
|
|
9
11
|
|
|
10
12
|
export interface KindedOptions {
|
|
11
13
|
Fungible: { kind: 'Fungible' } & FungibleOptions;
|
|
12
14
|
Governor: { kind: 'Governor' } & GovernorOptions;
|
|
13
15
|
NonFungible: { kind: 'NonFungible' } & NonFungibleOptions;
|
|
14
16
|
Stablecoin: { kind: 'Stablecoin' } & StablecoinOptions;
|
|
17
|
+
Vault: { kind: 'Vault' } & VaultOptions;
|
|
15
18
|
}
|
|
16
19
|
|
|
17
20
|
export type GenericOptions = KindedOptions[keyof KindedOptions];
|
|
@@ -30,6 +33,9 @@ export function buildGeneric(opts: GenericOptions) {
|
|
|
30
33
|
case 'Stablecoin':
|
|
31
34
|
return buildStablecoin(opts);
|
|
32
35
|
|
|
36
|
+
case 'Vault':
|
|
37
|
+
return buildVault(opts);
|
|
38
|
+
|
|
33
39
|
default: {
|
|
34
40
|
const _: never = opts;
|
|
35
41
|
throw new Error('Unknown kind');
|
package/src/generate/sources.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { generateFungibleOptions } from './fungible';
|
|
|
6
6
|
import { generateGovernorOptions } from './governor';
|
|
7
7
|
import { generateNonFungibleOptions } from './non-fungible';
|
|
8
8
|
import { generateStablecoinOptions } from './stablecoin';
|
|
9
|
+
import { generateVaultOptions } from './vault';
|
|
9
10
|
import type { GenericOptions, KindedOptions } from '../build-generic';
|
|
10
11
|
import { buildGeneric } from '../build-generic';
|
|
11
12
|
import { printContract } from '../print';
|
|
@@ -38,6 +39,12 @@ export function* generateOptions(kind?: Kind): Generator<GenericOptions> {
|
|
|
38
39
|
yield { kind: 'Stablecoin', ...kindOpts };
|
|
39
40
|
}
|
|
40
41
|
}
|
|
42
|
+
|
|
43
|
+
if (!kind || kind === 'Vault') {
|
|
44
|
+
for (const kindOpts of generateVaultOptions()) {
|
|
45
|
+
yield { kind: 'Vault', ...kindOpts };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
41
48
|
}
|
|
42
49
|
|
|
43
50
|
interface GeneratedContract {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { VaultOptions } from '../vault';
|
|
2
|
+
import { accessOptions } from '../set-access-control';
|
|
3
|
+
import { infoOptions } from '../set-info';
|
|
4
|
+
import { generateAlternatives } from './alternatives';
|
|
5
|
+
|
|
6
|
+
const booleans = [true, false];
|
|
7
|
+
|
|
8
|
+
const blueprint = {
|
|
9
|
+
name: ['MyVault'],
|
|
10
|
+
symbol: ['MTK'],
|
|
11
|
+
decimalsOffset: ['0', '2'],
|
|
12
|
+
pausable: booleans,
|
|
13
|
+
upgradeable: booleans,
|
|
14
|
+
access: accessOptions,
|
|
15
|
+
info: infoOptions,
|
|
16
|
+
explicitImplementations: booleans,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export function* generateVaultOptions(): Generator<Required<VaultOptions>> {
|
|
20
|
+
yield* generateAlternatives(blueprint);
|
|
21
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -25,8 +25,10 @@ export { fungible } from './api';
|
|
|
25
25
|
export { governor } from './api';
|
|
26
26
|
export { nonFungible } from './api';
|
|
27
27
|
export { stablecoin } from './api';
|
|
28
|
+
export { vault } from './api';
|
|
28
29
|
|
|
29
30
|
export type { FungibleOptions } from './fungible';
|
|
30
31
|
export type { GovernorOptions } from './governor';
|
|
31
32
|
export type { NonFungibleOptions } from './non-fungible';
|
|
32
33
|
export type { StablecoinOptions } from './stablecoin';
|
|
34
|
+
export type { VaultOptions } from './vault';
|
package/src/kind.ts
CHANGED
package/src/set-info.ts
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
import type { ContractBuilder } from './contract';
|
|
2
|
+
import { OptionsError } from './error';
|
|
3
|
+
|
|
4
|
+
// These values are printed into a // comment line in the generated Rust. LF
|
|
5
|
+
// ends that comment, letting following text become source. CR and U+2028/U+2029
|
|
6
|
+
// cannot break out in Rust, but are rejected as defense in depth (review tools
|
|
7
|
+
// render U+2028/U+2029 as line breaks).
|
|
8
|
+
const LINE_TERMINATOR = /[\n\r\u2028\u2029]/u;
|
|
9
|
+
|
|
10
|
+
function checkSingleLine(value: string, field: string): void {
|
|
11
|
+
if (LINE_TERMINATOR.test(value)) {
|
|
12
|
+
throw new OptionsError({ [field]: 'Must not contain line breaks' });
|
|
13
|
+
}
|
|
14
|
+
}
|
|
2
15
|
|
|
3
16
|
export const infoOptions = [{}, { license: 'WTFPL' }] as const;
|
|
4
17
|
|
|
@@ -10,7 +23,13 @@ export type Info = {
|
|
|
10
23
|
};
|
|
11
24
|
|
|
12
25
|
export function setInfo(c: ContractBuilder, { securityContact, license }: Info): void {
|
|
13
|
-
if (securityContact)
|
|
26
|
+
if (securityContact) {
|
|
27
|
+
checkSingleLine(securityContact, 'securityContact');
|
|
28
|
+
c.addContractMetadata({ key: 'security_contact', value: securityContact });
|
|
29
|
+
}
|
|
14
30
|
|
|
15
|
-
if (license)
|
|
31
|
+
if (license) {
|
|
32
|
+
checkSingleLine(license, 'license');
|
|
33
|
+
c.license = license;
|
|
34
|
+
}
|
|
16
35
|
}
|