Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Arvolear committed Nov 2, 2023
1 parent c090119 commit e4c4d30
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 6 additions & 9 deletions src/deployer/Deployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,19 @@ export class Deployer {

public async deploy<T, A = T, I = any>(
contract: Instance<A, I> | (T extends Truffle.Contract<I> ? T : never),
argsOrParameters: TypedArgs<A> | OverridesAndLibs = {},
argsOrParameters: OverridesAndLibs | TypedArgs<A> = [] as TypedArgs<A>,
parameters: OverridesAndLibs = {},
): Promise<I> {
const adapter = this._resolveAdapter(contract);

const minimalContract = await adapter.fromInstance(contract, parameters);

let contractAddress: string;
if (argsOrParameters instanceof Array) {
contractAddress = await minimalContract.deploy(argsOrParameters, parameters);
} else if (argsOrParameters instanceof Object) {
contractAddress = await minimalContract.deploy([], argsOrParameters);
} else {
contractAddress = await minimalContract.deploy([], {});
if (!(argsOrParameters instanceof Array)) {
parameters = argsOrParameters;
argsOrParameters = [] as TypedArgs<A>;
}

const contractAddress = await minimalContract.deploy(argsOrParameters as TypedArgs<A>, parameters);

return adapter.toInstance(contract, contractAddress, parameters);
}

Expand Down

0 comments on commit e4c4d30

Please sign in to comment.