Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions packages/core/src/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface Contract {
license: string;
parents: Parent[];
natspecTags: NatspecTag[];
modules: ImportContract[];
imports: ImportContract[];
functions: ContractFunction[];
constructorCode: string[];
Expand Down Expand Up @@ -80,6 +81,7 @@ export class ContractBuilder implements Contract {
upgradeable = false;

readonly using: Using[] = [];
readonly modules: ImportContract[] = [];
readonly natspecTags: NatspecTag[] = [];

readonly constructorArgs: FunctionArgument[] = [];
Expand Down Expand Up @@ -109,6 +111,7 @@ export class ContractBuilder implements Contract {
return [
...[...this.parentMap.values()].map(p => p.contract),
...this.using.map(u => u.library),
...this.modules,
];
}

Expand All @@ -126,10 +129,8 @@ export class ContractBuilder implements Contract {
return !present;
}

addImportOnly(contract: ImportContract): boolean {
const present = this.parentMap.has(contract.name);
this.parentMap.set(contract.name, { contract, params: [], importOnly: true });
return !present;
addImportOnly(contract: ImportContract) {
this.modules.push(contract);
}

addOverride(parent: ReferencedContract, baseFn: BaseFunction, mutability?: FunctionMutability) {
Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/print.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,11 @@ function printImports(imports: ImportContract[], helpers: Helpers): string[] {
const lines: string[] = [];
imports.map(p => {
const importContract = helpers.transformImport(p);
lines.push(`import {${importContract.name}} from "${importContract.path}";`);
if (importContract.name === ''){
lines.push(`import "${importContract.path}";`);
} else{
lines.push(`import {${importContract.name}} from "${importContract.path}";`);
}
});

return lines;
Expand Down