Skip to content

Commit

Permalink
fix(contract): fix waitForDeployment missing startBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
petarTxFusion committed Nov 1, 2024
1 parent fa17f54 commit 8ce644f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,12 @@ export class ContractFactory<

const deploymentTx = contract.deploymentTransaction()!;

contractWithCorrectAddress.deploymentTransaction = () =>
Object.assign(
Object.create(Object.getPrototypeOf(deploymentTx)),
deploymentTx,
deployTxReceipt
) as ContractTransactionResponse;
(deploymentTx as any).blockNumber = deployTxReceipt.blockNumber;
(deploymentTx as any).blockHash = deployTxReceipt.blockHash;
(deploymentTx as any).index = deployTxReceipt.index;
(deploymentTx as any).gasPrice = deployTxReceipt.gasPrice;

contractWithCorrectAddress.deploymentTransaction = () => deploymentTx;
return contractWithCorrectAddress;
}
}
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ describe('ContractFactory', () => {
const bytecode: string = Storage.contracts['Storage.sol:Storage'].bin;
const factory = new ContractFactory(abi, bytecode, wallet);
const contract = await factory.deploy();
await contract.waitForDeployment();

const code = await provider.getCode(await contract.getAddress());
expect(code).not.to.be.null;
Expand Down Expand Up @@ -119,6 +120,7 @@ describe('ContractFactory', () => {
const contract = await factory.deploy({
customData: {salt: ethers.hexlify(ethers.randomBytes(32))},
});
await contract.waitForDeployment();

const code = await provider.getCode(await contract.getAddress());
expect(code).not.to.be.null;
Expand Down

0 comments on commit 8ce644f

Please sign in to comment.