Skip to content

Commit 99fb425

Browse files
committed
pub not as head
1 parent 20a2547 commit 99fb425

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

packages/core/stellar/src/print.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ function printImplementedTrait(trait: TraitImplBlock): Lines[] {
223223
}
224224

225225
function printFunction(fn: ContractFunction): Lines[] {
226-
const head = `${fn.pub ? 'pub ' : ''}fn ${fn.name}`;
226+
const head = `fn ${fn.name}`;
227227
const args = fn.args.map(a => printArgument(a));
228228

229229
const codeLines = fn.codeBefore?.concat(fn.code) ?? fn.code;
@@ -239,7 +239,7 @@ function printFunction(fn: ContractFunction): Lines[] {
239239
}
240240
}
241241

242-
return printFunction2(head, args, fn.tag, fn.returns, undefined, codeLines);
242+
return printFunction2(fn.pub, head, args, fn.tag, fn.returns, undefined, codeLines);
243243
}
244244

245245
function printContractFunctions(contract: Contract): Lines[] {
@@ -271,12 +271,13 @@ function printContractFunctions(contract: Contract): Lines[] {
271271

272272
function printConstructor(contract: Contract): Lines[] {
273273
if (contract.constructorCode.length > 0) {
274-
const head = 'pub fn __constructor';
274+
const head = 'fn __constructor';
275275
const args = [getSelfArg(), ...contract.constructorArgs];
276276

277277
const body = spaceBetween(withSemicolons(contract.constructorCode));
278278

279279
const constructor = printFunction2(
280+
true,
280281
head,
281282
args.map(a => printArgument(a)),
282283
undefined,
@@ -293,6 +294,7 @@ function printConstructor(contract: Contract): Lines[] {
293294
// generic for functions and constructors
294295
// kindedName = 'fn foo'
295296
function printFunction2(
297+
pub: boolean,
296298
kindedName: string,
297299
args: string[],
298300
tag: string | undefined,
@@ -306,7 +308,13 @@ function printFunction2(
306308
fn.push(`#[${tag}]`);
307309
}
308310

309-
let accum = `${kindedName}(`;
311+
let accum = '';
312+
313+
if (pub) {
314+
accum += 'pub ';
315+
}
316+
317+
accum += `${kindedName}(`;
310318

311319
if (args.length > 0) {
312320
const formattedArgs = args.join(', ');

0 commit comments

Comments
 (0)