Skip to content

Commit

Permalink
Merge pull request #3504 from ethereum/issue/3496
Browse files Browse the repository at this point in the history
Remove optional revert error return types from web3-eth TS definitions
  • Loading branch information
ryanio authored May 7, 2020
2 parents e8b7a3f + 687742d commit 537d7ce
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
13 changes: 6 additions & 7 deletions packages/web3-eth/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import {
LogsOptions,
PastLogsOptions
} from 'web3-core';
import {RevertInstructionError, TransactionRevertInstructionError} from 'web3-core-helpers';
import {Subscription} from 'web3-core-subscriptions';
import {AbiCoder} from 'web3-eth-abi';
import {Accounts} from 'web3-eth-accounts';
Expand Down Expand Up @@ -295,12 +294,12 @@ export class Eth {
sendTransaction(
transactionConfig: TransactionConfig,
callback?: (error: Error, hash: string) => void
): PromiEvent<TransactionReceipt | TransactionRevertInstructionError>;
): PromiEvent<TransactionReceipt>;

sendSignedTransaction(
signedTransactionData: string,
callback?: (error: Error, hash: string) => void
): PromiEvent<TransactionReceipt | TransactionRevertInstructionError>;
): PromiEvent<TransactionReceipt>;

sign(
dataToSign: string,
Expand Down Expand Up @@ -328,20 +327,20 @@ export class Eth {
) => void
): Promise<RLPEncodedTransaction>;

call(transactionConfig: TransactionConfig): Promise<string | RevertInstructionError>;
call(transactionConfig: TransactionConfig): Promise<string>;
call(
transactionConfig: TransactionConfig,
defaultBlock?: BlockNumber
): Promise<string | RevertInstructionError>;
): Promise<string>;
call(
transactionConfig: TransactionConfig,
callback?: (error: Error, data: string) => void
): Promise<string | RevertInstructionError>;
): Promise<string>;
call(
transactionConfig: TransactionConfig,
defaultBlock: BlockNumber,
callback: (error: Error, data: string) => void
): Promise<string | RevertInstructionError>;
): Promise<string>;

estimateGas(
transactionConfig: TransactionConfig,
Expand Down
22 changes: 11 additions & 11 deletions packages/web3-eth/types/tests/eth.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,12 +379,12 @@ eth.getTransactionCount(

const code = '603d80600c6000396000f3007c0';

// $ExpectType PromiEvent<TransactionReceipt | TransactionRevertInstructionError>
// $ExpectType PromiEvent<TransactionReceipt>
eth.sendTransaction({
from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe',
data: 'code'
});
// $ExpectType PromiEvent<TransactionReceipt | TransactionRevertInstructionError>
// $ExpectType PromiEvent<TransactionReceipt>
eth.sendTransaction(
{
from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe',
Expand All @@ -393,9 +393,9 @@ eth.sendTransaction(
(error: Error, hash: string) => {}
);

// $ExpectType PromiEvent<TransactionReceipt | TransactionRevertInstructionError>
// $ExpectType PromiEvent<TransactionReceipt>
eth.sendSignedTransaction('0xf889808609184e72a0008227109');
// $ExpectType PromiEvent<TransactionReceipt | TransactionRevertInstructionError>
// $ExpectType PromiEvent<TransactionReceipt>
eth.sendSignedTransaction(
'0xf889808609184e72a0008227109',
(error: Error, hash: string) => {}
Expand Down Expand Up @@ -461,13 +461,13 @@ eth.signTransaction(
(error: Error, signedTransaction: RLPEncodedTransaction) => {}
);

// $ExpectType Promise<string | RevertInstructionError>
// $ExpectType Promise<string>
eth.call({
to: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', // contract address
data:
'0xc6888fa10000000000000000000000000000000000000000000000000000000000000003'
});
// $ExpectType Promise<string | RevertInstructionError>
// $ExpectType Promise<string>
eth.call(
{
to: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', // contract address
Expand All @@ -476,7 +476,7 @@ eth.call(
},
100
);
// $ExpectType Promise<string | RevertInstructionError>
// $ExpectType Promise<string>
eth.call(
{
to: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', // contract address
Expand All @@ -485,7 +485,7 @@ eth.call(
},
'100'
);
// $ExpectType Promise<string | RevertInstructionError>
// $ExpectType Promise<string>
eth.call(
{
to: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', // contract address
Expand All @@ -494,7 +494,7 @@ eth.call(
},
(error: Error, data: string) => {}
);
// $ExpectType Promise<string | RevertInstructionError>
// $ExpectType Promise<string>
eth.call(
{
to: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', // contract address
Expand All @@ -504,7 +504,7 @@ eth.call(
'100',
(error: Error, data: string) => {}
);
// $ExpectType Promise<string | RevertInstructionError>
// $ExpectType Promise<string>
eth.call(
{
to: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', // contract address
Expand All @@ -515,7 +515,7 @@ eth.call(
(error: Error, data: string) => {}
);

// $ExpectType Promise<string | RevertInstructionError>
// $ExpectType Promise<string>
eth.call(
{
to: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', // contract address
Expand Down

0 comments on commit 537d7ce

Please sign in to comment.