Skip to content

Commit ffb6a12

Browse files
committed
fix: contract tests
1 parent 255fd3c commit ffb6a12

File tree

3 files changed

+15
-27
lines changed

3 files changed

+15
-27
lines changed

__tests__/contract.test.ts

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,20 @@ describe('class Contract {}', () => {
2222
let contract: Contract;
2323

2424
beforeAll(async () => {
25-
const { code, transaction_hash, address } = await provider.deployContract({
25+
const { transaction_hash, contract_address } = await provider.deployContract({
2626
contract: compiledErc20,
2727
});
28-
erc20 = new Contract(compiledErc20.abi, address!, provider);
29-
expect(code).toBe('TRANSACTION_RECEIVED');
28+
erc20 = new Contract(compiledErc20.abi, contract_address!, provider);
3029
await provider.waitForTransaction(transaction_hash);
3130
// Deploy Multicall
3231

33-
const {
34-
code: m_code,
35-
transaction_hash: m_transaction_hash,
36-
address: multicallAddress,
37-
} = await provider.deployContract({
38-
contract: compiledMulticall,
39-
});
32+
const { transaction_hash: m_transaction_hash, contract_address: multicallAddress } =
33+
await provider.deployContract({
34+
contract: compiledMulticall,
35+
});
4036

4137
contract = new Contract(compiledMulticall.abi, multicallAddress!, provider);
4238

43-
expect(m_code).toBe('TRANSACTION_RECEIVED');
44-
4539
await provider.waitForTransaction(m_transaction_hash);
4640
});
4741

@@ -92,11 +86,10 @@ describe('class Contract {}', () => {
9286
let contract: Contract;
9387

9488
beforeAll(async () => {
95-
const { code, transaction_hash, address } = await provider.deployContract({
89+
const { transaction_hash, contract_address } = await provider.deployContract({
9690
contract: compiledTypeTransformation,
9791
});
98-
contract = new Contract(compiledTypeTransformation.abi, address!, provider);
99-
expect(code).toBe('TRANSACTION_RECEIVED');
92+
contract = new Contract(compiledTypeTransformation.abi, contract_address!, provider);
10093
await provider.waitForTransaction(transaction_hash);
10194
});
10295

@@ -205,9 +198,8 @@ describe('class Contract {}', () => {
205198
const erc20Response = await provider.deployContract({
206199
contract: compiledErc20,
207200
});
208-
erc20Address = erc20Response.address!;
201+
erc20Address = erc20Response.contract_address!;
209202
erc20 = new Contract(compiledErc20.abi, erc20Address, provider);
210-
expect(erc20Response.code).toBe('TRANSACTION_RECEIVED');
211203
await provider.waitForTransaction(erc20Response.transaction_hash);
212204
});
213205

@@ -229,12 +221,11 @@ describe('class Contract {}', () => {
229221
describe('class ContractFactory {}', () => {
230222
let erc20Address: string;
231223
beforeAll(async () => {
232-
const { code, transaction_hash, address } = await provider.deployContract({
224+
const { transaction_hash, contract_address } = await provider.deployContract({
233225
contract: compiledErc20,
234226
});
235-
expect(code).toBe('TRANSACTION_RECEIVED');
236227
await provider.waitForTransaction(transaction_hash);
237-
erc20Address = address!;
228+
erc20Address = contract_address!;
238229
});
239230
test('deployment of new contract', async () => {
240231
const factory = new ContractFactory(compiledErc20, provider);

src/contract/contractFactory.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,16 @@ export class ContractFactory {
3434
constructorCalldata?: RawCalldata,
3535
addressSalt?: BigNumberish
3636
): Promise<Contract> {
37-
const { address, code, transaction_hash } = await this.providerOrAccount.deployContract({
37+
const { contract_address, transaction_hash } = await this.providerOrAccount.deployContract({
3838
contract: this.compiledContract,
3939
constructorCalldata,
4040
addressSalt,
4141
});
42-
assert(
43-
code === 'TRANSACTION_RECEIVED' && Boolean(address),
44-
'Deployment of the contract failed'
45-
);
42+
assert(Boolean(contract_address), 'Deployment of the contract failed');
4643

4744
const contractInstance = new Contract(
4845
this.compiledContract.abi,
49-
address!,
46+
contract_address!,
5047
this.providerOrAccount
5148
);
5249
contractInstance.deployTransactionHash = transaction_hash;

src/provider/default.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export class Provider implements ProviderInterface {
100100
return this.provider.declareContract(payload);
101101
}
102102

103-
public async waitForTransaction(txHash: BigNumberish, retryInterval: number): Promise<void> {
103+
public async waitForTransaction(txHash: BigNumberish, retryInterval?: number): Promise<void> {
104104
return this.provider.waitForTransaction(txHash, retryInterval);
105105
}
106106
}

0 commit comments

Comments
 (0)