(Feature) [Spending Limits] Transaction List details#1271
(Feature) [Spending Limits] Transaction List details#1271mmv08 merged 24 commits intofeature/#413-SpendingLimit-in-appfrom
Conversation
|
CLA Assistant Lite All Contributors have signed the CLA. |
|
Travis automatic deployment: |
2 similar comments
|
Travis automatic deployment: |
|
Travis automatic deployment: |
- also set a default value for oldTxs
- create moduleTxSelector and fill the required data to build txTable
- also, renamed the `ExpandedTx` directory to `ExpandedTxRow` - the component exported from `ExpandedTxRow` now decides whether to display `ExpandedTx` or `ExpandedModuleTx`
…txList-SpendingLimit
|
Travis automatic deployment: |
…txList-SpendingLimit
ESLint Summary View Full Report
[warning] @typescript-eslint/explicit-module-boundary-types
[warning] @typescript-eslint/no-non-null-assertion
Report generated by eslint-plus-action |
|
Travis automatic deployment: |
src/logic/contracts/methodIds.ts
Outdated
| EXECUTE_ALLOWANCE_TRANSFER: 'executeAllowanceTransfer', | ||
| } | ||
|
|
||
| export const SPENDING_LIMIT_METHOD_TO_ID = { |
There was a problem hiding this comment.
this seems like id to a method, because the keys are IDs
There was a problem hiding this comment.
yes, that messed with my head too. That means that the METHOD_TO_ID const for Safe's methods, should be renamed as well. Isn't it?
There was a problem hiding this comment.
refactored a bit, moved these objects to the type file and renamed
|
|
||
| const moduleTransactions = await loadModuleTransactions(safeAddress) | ||
|
|
||
| if (moduleTransactions) { |
There was a problem hiding this comment.
the default response for this is [], I think you wanted to check .length
| const state = store.getState() | ||
|
|
||
| if (!safeAddress) { | ||
| return defaultResponse | ||
| } | ||
|
|
||
| const safe = state[SAFE_REDUCER_ID].getIn(['safes', safeAddress]) | ||
|
|
||
| if (!safe) { | ||
| return defaultResponse | ||
| } |
There was a problem hiding this comment.
why are we accessing state in a function whose responsibility is just to fetch transactions from the backend?
There was a problem hiding this comment.
no need to access it, thanks
| @@ -0,0 +1,32 @@ | |||
| import { handleActions } from 'redux-actions' | |||
There was a problem hiding this comment.
why do we need a separate reducer? what was wrong with the previous one we used for transactions?
There was a problem hiding this comment.
it's a different endpoint, and the returned data is quite different. Same strategy as with incomingTransactions
There was a problem hiding this comment.
But in the end, we get to merge them to a single list
There was a problem hiding this comment.
But in the end, we get to merge them to a single list
yes, but closer to the component.
Fortunately, this will work differently with the allTransactions endpoint approach.
In fact, I explored the strategy of storing the plain DTO in the store and then calculate data in the selector, it ended up working quite decently.
| const oldModuleTxs = state[safeAddress] ?? [] | ||
| const oldModuleTxsHashes = oldModuleTxs.map(({ transactionHash }) => transactionHash) | ||
| // filtering in this level happens, because backend is returning the whole list of txs | ||
| // so, to avoid re-storing all the txs, those already stored are filtered out |
There was a problem hiding this comment.
why does it matter if we restore them?
There was a problem hiding this comment.
the problem is not the "re-store", but the duplicates
There was a problem hiding this comment.
In that case, I would change the comment "to avoid duplicates..."
| const txToken = tokens.find((token) => token.address === tx.token) | ||
| const isSendingETH = txToken.address === ETH_ADDRESS | ||
| const txRecipient = isSendingETH ? tx.recipientAddress : txToken.address | ||
| const txToken = React.useMemo(() => tokens.find((token) => token.address === tx.token), [tokens, tx.token]) |
There was a problem hiding this comment.
tx.token is an object, will equality check for this case? if tx changes then it will be re-run I think
| notifiedTransaction: TX_NOTIFICATION_TYPES.STANDARD_TX, | ||
| enqueueSnackbar, | ||
| closeSnackbar, | ||
| } as any), |
There was a problem hiding this comment.
is it possible to remove as any? createTransaction method is typed
There was a problem hiding this comment.
also it's now not needed to pass closeSnackbar/enqueueSnackbar
There was a problem hiding this comment.
done, removed and fixed
| </Paragraph> | ||
| <ButtonLink | ||
| onClick={() => mutators.setMax(selectedTokenRecord.balance)} | ||
| onClick={() => |
There was a problem hiding this comment.
The component is getting really big, would be good to split it
| {(sortedData) => | ||
| sortedData.map((row, index) => ( | ||
| <React.Fragment key={index}> | ||
| <React.Fragment key={`${row.tx.safeTxHash}-${index}`}> |
There was a problem hiding this comment.
The index is not required in that case
There was a problem hiding this comment.
oops! fixed, thanks
| } | ||
|
|
||
| return getTransactionTableData(tx, cancelTxs.get(`${tx.nonce}`)) | ||
| return getTransactionTableData(tx as Transaction, cancelTxs.get(`${tx.nonce}`)) |
There was a problem hiding this comment.
what was the error there that required as?
There was a problem hiding this comment.
getTransactionTableData has issues with tx being of SafeModuleTransaction type.
I tried helping TS by using type guards, but it didn't work either: https://www.typescriptlang.org/docs/handbook/advanced-types.html#type-guards-and-differentiating-types
There was a problem hiding this comment.
Yeah we should explore using type guards, this is getting a problem for tokens also
…txList-SpendingLimit
- also reorganized imports
|
Travis automatic deployment: |
1 similar comment
|
Travis automatic deployment: |
|
Travis automatic deployment: |
…List-SpendingLimit
|
Travis automatic deployment: |
mmv08
left a comment
There was a problem hiding this comment.
Please address those small changes before merging, otherwise good job :)
| export const isSetAllowanceMethod = (data: string): boolean => { | ||
| const methodId = data.slice(0, 10) as keyof typeof SPENDING_LIMIT_METHOD_TO_ID | ||
| return SPENDING_LIMIT_METHOD_TO_ID[methodId] === SPENDING_LIMIT_METHODS_NAMES.SET_ALLOWANCE | ||
| const methodId = data.slice(0, 10) as keyof typeof SPENDING_LIMIT_METHOD_ID_TO_NAME |
There was a problem hiding this comment.
Would be good to export this keyof typeof thing to a separate type
src/logic/safe/store/actions/transactions/fetchTransactions/loadModuleTransactions.ts
Outdated
Show resolved
Hide resolved
| const moduleTransactions = await loadModuleTransactions(safeAddress) | ||
|
|
||
| if (moduleTransactions.length) { | ||
| dispatch(addModuleTransactions({ modules: moduleTransactions, safeAddress })) |
There was a problem hiding this comment.
Little inconsistency in naming, transactions get passed as modules
| @@ -0,0 +1,32 @@ | |||
| import { handleActions } from 'redux-actions' | |||
| } | ||
|
|
||
| return getTransactionTableData(tx, cancelTxs.get(`${tx.nonce}`)) | ||
| return getTransactionTableData(tx as Transaction, cancelTxs.get(`${tx.nonce}`)) |
There was a problem hiding this comment.
Yeah we should explore using type guards, this is getting a problem for tokens also
|
https://pr1271--safereact.review.gnosisdev.com/app/#/safes/0x9913B9180C20C6b0F21B6480c84422F6ebc4B808/transactions If I open a tx "Spending limit" created by sending funds using the user with the spending limit I get a console error and the page crashes |
|
Minor issue: EDIT: The system will not let you send more tokens than you have in the safe so is not critical. |
…List-SpendingLimit # Conflicts: # src/logic/safe/store/actions/transactions/fetchTransactions/fetchTransactions.ts # src/logic/safe/store/selectors/index.ts # src/routes/safe/components/Balances/SendModal/screens/ReviewTx/index.tsx # src/routes/safe/components/Transactions/TxsTable/ExpandedTxRow/TxDescription/CustomDescription.tsx # src/routes/safe/components/Transactions/TxsTable/columns.tsx # src/routes/safe/components/Transactions/TxsTable/index.tsx
|
@francovenica, thanks for the catch. Now ETH spending limit txs are properly displayed. |
|
Travis automatic deployment: |

This PR closes #691, by: