Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deployment builder. #61

Merged
merged 9 commits into from
Mar 6, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add builder.
saeed-zil committed Mar 5, 2024
commit ea27e08c7b0d53c45e946b6d3edf61c3f969d968
76 changes: 76 additions & 0 deletions src/deployer/Builder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { TxParams } from "@zilliqa-js/account";

import {
OptionalUserDefinedLibraryList,
UserDefinedLibrary,
} from "./ScillaContractDeployer";

export class DeployBuilder {
private contractName: string;
private compress: boolean;
private userDefinedLibraries: OptionalUserDefinedLibraryList;
private txParams: TxParams | null;
private contractParams: any[];

constructor() {
this.contractName = "";
this.compress = false;
this.userDefinedLibraries = null;
this.txParams = null;
this.contractParams = [];
}

reset(): DeployBuilder {
this.contractName = "";
this.compress = false;
this.userDefinedLibraries = null;
this.txParams = null;
this.contractParams = [];
return this;
}

withName(contractName: string): DeployBuilder {
this.contractName = contractName;
return this;
}

withContractParams(params: any[]): DeployBuilder {
this.contractParams = params;
return this;
}

withTxParams(params: TxParams): DeployBuilder {
this.txParams = params;
return this;
}

withContractCompression(): DeployBuilder {
this.compress = true;
return this;
}

withUserDefinedLibraries(libraries: UserDefinedLibrary[]) {
this.userDefinedLibraries = libraries;
return this;
}

build(): Deployment {
return new Deployment(
this.contractName,
this.compress,
this.userDefinedLibraries,
this.txParams,
this.contractParams
);
}
}

class Deployment {
constructor(
private contractName: string,
private compress: boolean,
private userDefinedLibraries: OptionalUserDefinedLibraryList,
private txParams: TxParams | null,
private contractParams: any[]
) {}
}
2 changes: 1 addition & 1 deletion src/deployer/ScillaContractDeployer.ts
Original file line number Diff line number Diff line change
@@ -124,7 +124,7 @@ export interface UserDefinedLibrary {
address: string;
}

type OptionalUserDefinedLibraryList = UserDefinedLibrary[] | null;
export type OptionalUserDefinedLibraryList = UserDefinedLibrary[] | null;

export async function deploy(
hre: HardhatRuntimeEnvironment,