Skip to content
This repository was archived by the owner on Nov 10, 2023. It is now read-only.

(Feature) Spending Limit#1637

Merged
fernandomg merged 30 commits intodevelopmentfrom
feature/413-spendingLimit
Nov 25, 2020
Merged

(Feature) Spending Limit#1637
fernandomg merged 30 commits intodevelopmentfrom
feature/413-spendingLimit

Conversation

@fernandomg
Copy link
Contributor

@fernandomg fernandomg commented Nov 20, 2020

This PR is a replacement for #1351. Given it's a big feature and it was there for around 4 months, its history became very hard to follow.

This PR closes #413, by:

  • supporting Spending Limits module as a Safe's feature
  • Allowing to add/edit/remove a beneficiary
  • Identifying and listing Spending Limit transactions in the transactions table

NOTE:
Before merging this feature, we need to remove the hardcoded address in constants.ts file and set the global variable REACT_APP_SPENDING_LIMIT_MODULE_ADDRESS to the audited module address.


How to test

  • "Allowances" was replaced by "Spending Limit"
  • Consider that feature mockups were made way before the new Safe's designs, so there will be differences.

This is an ordered list of the feature's sub-tasks.
Implementation details are in the PRs description.

task issue PR important feedback
Spending Limit Settings tab #689 #1151 #1151 (comment)
#1151 (comment)
New Spending Limit #690 #1218
Remove Spending Limit #692 #1261
List of Spending Limit #1039 #1261 #1261 (comment)
#1261 (comment)
Send funds #693 #1276 #1276 (comment)
#1276 (comment)
Transaction list #691 #1271 #1271 (comment)


What this feature adds to the safe:

Spending Limit as a Setting option

image

New Spending Limit

setup review listing beneficiaries
image image image

Identify Spending Limit Transactions

first ever spending limit new beneficiary already known beneficiary
image image image
Action 1: Enable Module
Action 2: Add Beneficiary
Action 3: Set the Spending Limit
Action 1: Add Beneficiary
Action 2: Set the Spending Limit
Set the Spending Limit

Use the Spending Limit allowance

send transaction details
image image

@fernandomg fernandomg self-assigned this Nov 20, 2020
@github-actions
Copy link

CLA Assistant Lite All Contributors have signed the CLA.

@github-actions
Copy link

github-actions bot commented Nov 20, 2020

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 3 0
Ignored 2 N/A
  • Result: ✅ success

  • Annotations: 3 total


[warning] @typescript-eslint/explicit-module-boundary-types

Require explicit return and argument types on exported functions' and classes' public class methods


[warning] @typescript-eslint/no-non-null-assertion

Disallows non-null assertions using the ! postfix operator


Report generated by eslint-plus-action

@fernandomg fernandomg force-pushed the feature/413-spendingLimit branch from bc68b4c to c135a04 Compare November 20, 2020 16:24
@ghost
Copy link

ghost commented Nov 20, 2020

Travis automatic deployment:
https://pr1637--safereact.review.gnosisdev.com/rinkeby/app

@ghost
Copy link

ghost commented Nov 20, 2020

Travis automatic deployment:
https://pr1637--safereact.review.gnosisdev.com/volta/app

@ghost
Copy link

ghost commented Nov 20, 2020

Travis automatic deployment:
https://pr1637--safereact.review.gnosisdev.com/rinkeby/app

@ghost
Copy link

ghost commented Nov 20, 2020

Travis automatic deployment:
https://pr1637--safereact.review.gnosisdev.com/volta/app

return (
<>
<ResetTimeLabel>
<Text size="xl">Set a reset-time to have the allowance automatically refill after a defined time-period.</Text>
Copy link
Collaborator

Choose a reason for hiding this comment

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

"Set a reset time so the allowance automatically refills after the defined time period"

@fernandomg
Copy link
Contributor Author

@francovenica, frow what we discussed in the walkthrough with the team. The only visible addition was the explanatory text next to the reset time toggle button in the "new spending limit" modal.

@ghost
Copy link

ghost commented Nov 24, 2020

Travis automatic deployment:
https://pr1637--safereact.review.gnosisdev.com/rinkeby/app

@francovenica
Copy link
Contributor

Should we show the exact number here for < 0.0001 allowed tokens to use?
image.png

@francovenica
Copy link
Contributor

francovenica commented Nov 24, 2020

If you disable the token in the assets tab it also goes away in the spending limit.
I don't know what the solution could it be here.
Could we cash the token symbol if a spending limit is created. Or show a default symbol for the tokens and at least show the name and limit set

image.png
image.png

@francovenica
Copy link
Contributor

francovenica commented Nov 24, 2020

We have to deal with editing the spending limit to an amount lower than what was already used. Disable the "Spending limit" radiobutton or something. Maybe for the 2.17 release
image.png

Also deal with this inconsistency for that scenario
image.png

@francovenica
Copy link
Contributor

I gave spending limits to an user and then I removed him as owner of the safe.
Still, I was able to go to etherscan and execute the contract to use those tokens.
I don't know if that's an issue, since it was the idea that non owner also should be able to use the spending limits, but since we decided that for now only owners should be allowed to use it I just want to be sure.

It respects the limit allowed still, so at least that user won't be able to use more of what it was set to him.

The safe: https://pr1637--safereact.review.gnosisdev.com/rinkeby/app/#/safes/0x7f58E04c2949CDA2A61E7413E9d8DA93b1726D7F/transactions
This 2 tx were created by that user as non owner from etherscan
image.png

image.png

@lukasschor
Copy link
Contributor

I gave spending limits to an user and then I removed him as owner of the safe.
Still, I was able to go to etherscan and execute the contract to use those tokens.
I don't know if that's an issue, since it was the idea that non owner also should be able to use the spending limits, but since we decided that for now only owners should be allowed to use it I just want to be sure.

It respects the limit allowed still, so at least that user won't be able to use more of what it was set to him.

The safe: https://pr1637--safereact.review.gnosisdev.com/rinkeby/app/#/safes/0x7f58E04c2949CDA2A61E7413E9d8DA93b1726D7F/transactions
This 2 tx were created by that user as non owner from etherscan
image.png

image.png

Yeah that's fine. It should be possible to use the spending limit as a non-owner. Just not via our UI yet. :)

@ghost
Copy link

ghost commented Nov 25, 2020

Travis automatic deployment:
https://pr1637--safereact.review.gnosisdev.com/volta/app

@fernandomg
Copy link
Contributor Author

@francovenica,

Should we show the exact number here for < 0.0001 allowed tokens to use?

❓ may a tooltip be helpful here?


If you disable the token in the assets tab it also goes away in the spending limit.
I don't know what the solution could it be here.
Could we cash the token symbol if a spending limit is created. Or show a default symbol for the tokens > and at least show the name and limit set

✔️ fixed


We have to deal with editing the spending limit to an amount lower than what was already used. Disable the "Spending limit" radiobutton or something. Maybe for the 2.17 release

🗒️ exactly. As it was discussed with the team during the walkthrough.

@ghost
Copy link

ghost commented Nov 25, 2020

Travis automatic deployment:
https://pr1637--safereact.review.gnosisdev.com/volta/app

@ghost
Copy link

ghost commented Nov 25, 2020

Travis automatic deployment:
https://pr1637--safereact.review.gnosisdev.com/rinkeby/app

1 similar comment
@ghost
Copy link

ghost commented Nov 25, 2020

Travis automatic deployment:
https://pr1637--safereact.review.gnosisdev.com/rinkeby/app

@ghost
Copy link

ghost commented Nov 25, 2020

Travis automatic deployment:
https://pr1637--safereact.review.gnosisdev.com/volta/app

@ghost
Copy link

ghost commented Nov 25, 2020

Travis automatic deployment:
https://pr1637--safereact.review.gnosisdev.com/volta/app

@ghost
Copy link

ghost commented Nov 25, 2020

Travis automatic deployment:
https://pr1637--safereact.review.gnosisdev.com/rinkeby/app

@francovenica
Copy link
Contributor

The issue with the token not showing when disabling them in the assets tab was fixed
An issue where the value of the token was not properly being processed by the input was fixed

The other reports can be left for improvements for the 2.17 version

An owner being able to use tokens from outside of the safe while not being an owner is not an issue then.

Tested:

  • Set the spending limit. The 1st tx will add the module
  • To delete the module we need to include this fix. (the issue with deleting the module only happens if 2 or more modules are enabled) (Fix) remove module feature #1646
  • Use the tokens with single signature
  • Use only the amount set
  • Update the spending limit
  • Check the refresh of the limit (tested with the daily refresh)
  • Remove the spending limit from the user
  • Tried to trick the system to spend more than intended and checking that such tx fails to do so
  • Use the spending limit from outside of the safe with the limitations applied
  • "Send max" button in the send funds form takes in account if spending limit is used or not
  • Spending limit pagination and sorting

It looks good to me

@ghost
Copy link

ghost commented Nov 25, 2020

Travis automatic deployment:
https://pr1637--safereact.review.gnosisdev.com/volta/app

@ghost
Copy link

ghost commented Nov 25, 2020

Travis automatic deployment:
https://pr1637--safereact.review.gnosisdev.com/rinkeby/app

@fernandomg fernandomg merged commit fc1250d into development Nov 25, 2020
@fernandomg fernandomg deleted the feature/413-spendingLimit branch November 25, 2020 18:59
@github-actions github-actions bot locked and limited conversation to collaborators Nov 25, 2020
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.

Spending Limits

5 participants