Skip to content

Commit 5c46728

Browse files
authored
A bit looser type for TransactionResponse (#1358)
1 parent 68678e6 commit 5c46728

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

packages/sdk-redux/src/reduxSlices/transactionTrackerSlice/registerNewTransaction.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import {ThunkDispatch} from '@reduxjs/toolkit';
2-
import {ethers, Transaction} from 'ethers';
2+
import {providers} from 'ethers';
33

44
import {initiateNewTransactionTrackingThunk} from './thunks/initiateNewTransactionTrackingThunk';
55
import {TransactionTitle} from './transactionTitle';
66

77
/**
88
* A simpler TransactionResponse type, similar to wagmi's SendTransactionResult,
99
*/
10-
export type NewTransactionResponse = Pick<ethers.providers.TransactionResponse, 'hash' | 'wait'> & Transaction;
10+
export type NewTransactionResponse = Flatten<
11+
Pick<providers.TransactionResponse, 'hash' | 'wait'> & Partial<providers.TransactionResponse>
12+
>;
1113

1214
export interface RegisterNewTransactionArg {
1315
/**
@@ -57,3 +59,8 @@ export const registerNewTransactionAndReturnQueryFnResult = async (arg: Register
5759
},
5860
};
5961
};
62+
63+
// Prefer flattened/spread syntax for IDE-s. Example: `A: { hash: string } vs B: Pick<TransactionResponse, "hash">`. A is the flattened syntax.
64+
type Flatten<T> = {
65+
[K in keyof T]: T[K];
66+
};

0 commit comments

Comments
 (0)