Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Human readable descriptions #2371

Merged
merged 24 commits into from
Aug 30, 2023
Merged

feat: Add Human readable descriptions #2371

merged 24 commits into from
Aug 30, 2023

Conversation

usame-algan
Copy link
Member

@usame-algan usame-algan commented Aug 8, 2023

What it solves

First part of the EPIC #2011

Resolves #2448

Depends on safe-global/safe-client-gateway#631

How this PR fixes it

  • Displays human-readable descriptions for nonce replacement and notifications

ToDos

  • Update gateway-typescript-sdk type for TransactionInfo
  • Check remaining dispatch functions if they need a txDescription

How to test it

  1. Queue a transaction (transfer, settings change, custom transaction)
  2. Create a new transaction
  3. Open the nonce replacement form
  4. Observe human-readable descriptions
  5. If there is no human-readable description observe the same message as before
  6. Sign or execute a transaction
  7. Observe a human-readable description inside notifications and the notification center
  8. If there is no human-readable description observe a generic fallback saying Transaction as the Notification title

Screenshots

Screenshot 2023-08-11 at 15 41 52 Screenshot 2023-08-11 at 17 22 29 Screenshot 2023-08-11 at 13 18 53

Checklist

  • I've tested the branch on mobile 📱
  • I've documented how it affects the analytics (if at all) 📊
  • I've written a unit/e2e test for it (if applicable) 🧑‍💻

@github-actions
Copy link

github-actions bot commented Aug 8, 2023

Branch preview

✅ Deploy successful!

https://human_readable_txs--walletweb.review-wallet-web.5afe.dev

@github-actions
Copy link

github-actions bot commented Aug 8, 2023

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 0 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

src/config/constants.ts Outdated Show resolved Hide resolved
.vscode/settings.json Outdated Show resolved Hide resolved
@usame-algan usame-algan marked this pull request as ready for review August 11, 2023 15:22
@usame-algan usame-algan changed the title [PoC] Display human readable descriptions Display human readable descriptions Aug 11, 2023
@github-actions
Copy link

github-actions bot commented Aug 17, 2023

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 0 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

@usame-algan usame-algan changed the title Display human readable descriptions feat: Add Human readable descriptions Aug 28, 2023
Comment on lines 24 to 25
addToBatch: (safeTx?: SafeTransaction, origin?: string, humanDescription?: string) => Promise<string>
signTx: (safeTx?: SafeTransaction, txId?: string, origin?: string, humanDescription?: string) => Promise<string>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing humanDescription to these two methods seems oddly specific. I would suggest passing the whole txDetails.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed the signature to accept a transaction object instead.


dispatch(
showNotification({
title: humanDescription,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will it look like w/o a title?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went through each tx event that we show a notification for and made sure to add a humanDescription there, either from the CGW response or an appropriate fallback i.e. Transaction #<nonce> or Module transaction

Comment on lines 53 to 56
txDispatch(TxEvent.SIGNATURE_PROPOSE_FAILED, {
txId,
error: asError(error),
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary formatting

Suggested change
txDispatch(TxEvent.SIGNATURE_PROPOSE_FAILED, {
txId,
error: asError(error),
})
txDispatch(TxEvent.SIGNATURE_PROPOSE_FAILED, { txId, error: asError(error) })

src/hooks/useTransactionType.ts Outdated Show resolved Hide resolved
Comment on lines +19 to +32
[TxEvent.SIGN_FAILED]: 'Failed to sign. Please try again.',
[TxEvent.PROPOSED]: 'Successfully added to queue.',
[TxEvent.PROPOSE_FAILED]: 'Failed to add to queue. Please try again.',
[TxEvent.SIGNATURE_PROPOSED]: 'Successfully signed.',
[TxEvent.SIGNATURE_PROPOSE_FAILED]: 'Failed to send signature. Please try again.',
[TxEvent.EXECUTING]: 'Confirm the execution in your wallet.',
[TxEvent.PROCESSING]: 'Validating...',
[TxEvent.PROCESSING_MODULE]: 'Validating module interaction...',
[TxEvent.ONCHAIN_SIGNATURE_REQUESTED]: 'Confirm on-chain signature in your wallet.',
[TxEvent.ONCHAIN_SIGNATURE_SUCCESS]: 'On-chain signature request confirmed.',
[TxEvent.PROCESSED]: 'Successfully validated. Indexing...',
[TxEvent.REVERTED]: 'Reverted. Please check your gas settings.',
[TxEvent.SUCCESS]: 'Successfully executed.',
[TxEvent.FAILED]: 'Failed.',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these changes necessary? If there's no humanDescription, we now lose some context.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

humanDescription will be always there unless the feature is disabled for technical reasons.

Copy link
Member

@iamacook iamacook Aug 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the signature hash does not match on the gateway the humanDescription will be null. You can test this with spending limits atm:

image
image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I think we should add a fallback for the title. Maybe we can include the nonce, something like Transaction #113

@@ -50,6 +52,8 @@ const ExecuteForm = ({
const { setTxFlow } = useContext(TxModalContext)
const { needsRiskConfirmation, isRiskConfirmed, setIsRiskIgnored } = useContext(TxSecurityContext)

const tx = useAppSelector((state) => selectQueuedTransactionById(state, txId))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the transaction dispatchers (e.g. executeTx) were thunks, you could select this inside it as you already have the txId. It's an opinionated change though so I won't request it be changed.

src/components/tx/SignOrExecuteForm/hooks.ts Show resolved Hide resolved
src/services/tx/tx-sender/dispatch.ts Outdated Show resolved Hide resolved
src/config/constants.ts Outdated Show resolved Hide resolved
src/services/tx/tx-sender/dispatch.ts Outdated Show resolved Hide resolved
src/store/txHistorySlice.ts Outdated Show resolved Hide resolved
src/services/tx/tx-sender/dispatch.ts Outdated Show resolved Hide resolved
src/services/tx/tx-sender/dispatch.ts Show resolved Hide resolved
@francovenica
Copy link
Contributor

francovenica commented Aug 29, 2023

This message is the same as the one in stg currently. in this case I tried to execute a batch tx (2 fully signed tx in queue, and using the Execute batch button), but these tx are incompatible so is expected for the batch to fail. (for example creating 2 tx that removes the same owner)

Idk if something more user friendly can be set, or if the information in the tx means something for the user.
image

@francovenica
Copy link
Contributor

just "send"? in the description it shows that it should show what token you are sending, how much and to who.
In this case I'm testing in Goerli, sending GoerliETH
image

@usame-algan
Copy link
Member Author

@francovenica thanks for testing! I've fixed the "Send" issue. This was a regression, nice find! For Batch Executions I now added a static description so it should always say "Batch transaction" as the title.

@usame-algan
Copy link
Member Author

usame-algan commented Aug 29, 2023

@iamacook @katspaugh what do you think about removing all the custom fallbacks and only having one fallback to "Transaction" inside useTxNotifications. We would lose some information like the nonce but I don't think its too critical since thats how it was before.

Comment on lines 31 to 35
const HUMAN_DESCRIPTION_FALLBACK =
'Transaction ' +
(isMultisigExecutionInfo(result.transaction.executionInfo)
? `#${result.transaction.executionInfo.nonce}`
: '')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const HUMAN_DESCRIPTION_FALLBACK =
'Transaction ' +
(isMultisigExecutionInfo(result.transaction.executionInfo)
? `#${result.transaction.executionInfo.nonce}`
: '')
const HUMAN_DESCRIPTION_FALLBACK =
'Transaction' +
(isMultisigExecutionInfo(result.transaction.executionInfo)
? ` #${result.transaction.executionInfo.nonce}`
: '')

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reverted this change and use a generic fallback now.

@iamacook
Copy link
Member

@iamacook @katspaugh what do you think about removing all the custom fallbacks and only having one fallback to "Transaction" inside useTxNotifications. We would lose some information like the nonce but I don't think its too critical since thats how it was before.

Having a SSOT makes the most sense.

@github-actions
Copy link

github-actions bot commented Aug 29, 2023

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 0 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

Copy link
Member

@iamacook iamacook left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a failing test.

@francovenica
Copy link
Contributor

I tried the tx that Usame shared with me.
I was able to see most of them

I wasn't able to trigger "ONCHAIN_SIGNATURE_REQUESTED" and "ONCHAIN_SIGNATURE_SUCCESS". I'm gonna throw that, these probably were used back when every signature was on chain, even the ones that proposed a tx without execution.

The issue I reported about the nonce replacement message now show the tx name correctly

check the size of the nonce input tx display for mobile, looks fine as well:
image

Looks good to me

@francovenica
Copy link
Contributor

francovenica commented Aug 30, 2023

EDIT:
Found an issue a last minute. a error message that show a "GS013" error
image

To reproduce this create 2 tx and batch them (the new feature "batch tx", not the "Execute batch" button in the queue). Make the 1st tx to send a small amout of any tokens from the safe and the 2nd one to send the Max amount. These 2 transactions cannot be executed in batch so the error happens

@usame-algan
Copy link
Member Author

Found an issue a last minute. a error message that show a "GS013" error

Nice find! There was an issue with setting the fallback title. It should be fixed now and display Transaction at the top of the notification.

@francovenica
Copy link
Contributor

Yes, it has it now:
image

@usame-algan usame-algan merged commit 7659ab4 into dev Aug 30, 2023
9 checks passed
@usame-algan usame-algan deleted the human-readable-txs branch August 30, 2023 13:39
@github-actions github-actions bot locked and limited conversation to collaborators Aug 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Human-readable descriptions v1
4 participants