Skip to content

Commit

Permalink
add clone method to web3 target
Browse files Browse the repository at this point in the history
  • Loading branch information
krzkaczor committed Dec 23, 2018
1 parent 667d07a commit a0abc66
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/targets/web3/generation.ts
Expand Up @@ -66,6 +66,7 @@ export function codegen(contract: Contract) {
cb?: Callback<EventLog[]>
): Promise<EventLog[]>;
setProvider(provider: Provider): void;
clone(): ${contract.name};
}
`;

Expand Down
9 changes: 9 additions & 0 deletions test/integration/targets/web3-1.0.0/DumbContract.spec.web3.ts
Expand Up @@ -69,4 +69,13 @@ describe("DumbContract", () => {

expect(await contract.methods.testString("abc").call()).to.be.deep.eq("abc");
});

it("should allow to clone contracts ", async () => {
const contract = (await deployContract("DumbContract")) as DumbContract;

const contractClone = await contract.clone();

expect(contractClone).not.to.be.eq(contract);
expect(contractClone.options.address).to.be.eq(contract.options.address);
});
});

0 comments on commit a0abc66

Please sign in to comment.