Skip to content

Commit

Permalink
Merge pull request #136 from 0xs34n/refactor/rename
Browse files Browse the repository at this point in the history
refactor(provider): rename `waitForTx` to `waitForTransaction`
  • Loading branch information
delaaxe authored Mar 8, 2022
2 parents b130516 + af4ef14 commit 570d1c2
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 12 deletions.
8 changes: 4 additions & 4 deletions __tests__/account.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('deploy and test Wallet', () => {
});
dapp = new Contract(compiledTestDapp.abi, dappResponse.address);
expect(dappResponse.code).toBe('TRANSACTION_RECEIVED');
await defaultProvider.waitForTx(dappResponse.transaction_hash);
await defaultProvider.waitForTransaction(dappResponse.transaction_hash);
});

test('same wallet address', () => {
Expand Down Expand Up @@ -80,7 +80,7 @@ describe('deploy and test Wallet', () => {
});

expect(code).toBe('TRANSACTION_RECEIVED');
await defaultProvider.waitForTx(transaction_hash);
await defaultProvider.waitForTransaction(transaction_hash);
});

test('read balance of wallet after transfer', async () => {
Expand Down Expand Up @@ -108,7 +108,7 @@ describe('deploy and test Wallet', () => {
);

expect(code).toBe('TRANSACTION_RECEIVED');
await defaultProvider.waitForTx(transaction_hash);
await defaultProvider.waitForTransaction(transaction_hash);
});

test('execute multiple transactions', async () => {
Expand All @@ -126,7 +126,7 @@ describe('deploy and test Wallet', () => {
]);

expect(code).toBe('TRANSACTION_RECEIVED');
await defaultProvider.waitForTx(transaction_hash);
await defaultProvider.waitForTransaction(transaction_hash);

const response = await dapp.call('get_number', { user: account.address });
expect(toBN(response.number as string).toString()).toStrictEqual('57');
Expand Down
4 changes: 2 additions & 2 deletions __tests__/accountContract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('deploy and test Wallet', () => {
amount: '1000',
});
expect(mintResponse.code).toBe('TRANSACTION_RECEIVED');
await defaultProvider.waitForTx(mintResponse.transaction_hash);
await defaultProvider.waitForTransaction(mintResponse.transaction_hash);
});

test('read nonce', async () => {
Expand Down Expand Up @@ -96,7 +96,7 @@ describe('deploy and test Wallet', () => {

expect(code).toBe('TRANSACTION_RECEIVED');

await defaultProvider.waitForTx(transaction_hash);
await defaultProvider.waitForTransaction(transaction_hash);
});

test('read balance of wallet after transfer', async () => {
Expand Down
8 changes: 4 additions & 4 deletions __tests__/contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('class Contract {}', () => {
});
erc20 = new Contract(compiledErc20.abi, address, defaultProvider);
expect(code).toBe('TRANSACTION_RECEIVED');
await defaultProvider.waitForTx(transaction_hash);
await defaultProvider.waitForTransaction(transaction_hash);

// Deploy Multicall

Expand All @@ -35,7 +35,7 @@ describe('class Contract {}', () => {

expect(m_code).toBe('TRANSACTION_RECEIVED');

await defaultProvider.waitForTx(m_transaction_hash);
await defaultProvider.waitForTransaction(m_transaction_hash);
});

test('read initial balance of that account', async () => {
Expand All @@ -52,7 +52,7 @@ describe('class Contract {}', () => {
});
expect(response.code).toBe('TRANSACTION_RECEIVED');

await defaultProvider.waitForTx(response.transaction_hash);
await defaultProvider.waitForTransaction(response.transaction_hash);
});

test('read balance after mint of that account', async () => {
Expand Down Expand Up @@ -93,7 +93,7 @@ describe('class Contract {}', () => {
});
contract = new Contract(compiledTypeTransformation.abi, address, defaultProvider);
expect(code).toBe('TRANSACTION_RECEIVED');
await defaultProvider.waitForTx(transaction_hash);
await defaultProvider.waitForTransaction(transaction_hash);
});

describe('Request Type Transformation', () => {
Expand Down
9 changes: 8 additions & 1 deletion src/provider/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ export class Provider implements ProviderInterface {
});
}

public async waitForTx(txHash: BigNumberish, retryInterval: number = 8000) {
public async waitForTransaction(txHash: BigNumberish, retryInterval: number = 8000) {
let onchain = false;
await wait(retryInterval);

Expand All @@ -355,4 +355,11 @@ export class Provider implements ProviderInterface {
}
}
}

/**
* @deprecated use `waitForTransaction` instead
*/
public async waitForTx(txHash: BigNumberish, retryInterval: number = 8000) {
return this.waitForTransaction(txHash, retryInterval);
}
}
7 changes: 6 additions & 1 deletion src/provider/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,10 @@ export abstract class ProviderInterface {
*/
public abstract invokeFunction(invocation: Invocation): Promise<AddTransactionResponse>;

public abstract waitForTx(txHash: BigNumberish, retryInterval?: number): Promise<void>;
public abstract waitForTransaction(txHash: BigNumberish, retryInterval?: number): Promise<void>;

/**
* @deprecated use `waitForTransaction` instead
*/
public abstract waitForTransaction(txHash: BigNumberish, retryInterval?: number): Promise<void>;
}

0 comments on commit 570d1c2

Please sign in to comment.