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: Subaccounts #4456

Draft
wants to merge 26 commits into
base: dev
Choose a base branch
from
Draft

feat: Subaccounts #4456

wants to merge 26 commits into from

Conversation

iamacook
Copy link
Member

@iamacook iamacook commented Oct 31, 2024

What it solves

Implementation of creating (and funding) Subaccounts

How this PR fixes it

A new sidebar icon, context menu (accessible via the icon/drawer) and settings have been added that both list and open a Subaccount creation flow.

How to test it

Open a Safe and observe:

  • A new header icon in the sidebar that, when clicked, opens either a promo message (if no Subaccounts are owned) or a list, with an option to add more. (The presence of Subaccounts is signified by a badge number.)
  • If the current Safe has Subaccounts, a new item in the sidebar drawer menu (accessible via the three dots) should open the same component.
  • A new settings area under "Setup" has the option to add Subaccounts, and list/rename those which exist already.

Screenshots

image

image

image

image

image

image

image

image

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) 🧑‍💻

@iamacook iamacook self-assigned this Oct 31, 2024
Copy link

Copy link

github-actions bot commented Oct 31, 2024

Copy link

github-actions bot commented Oct 31, 2024

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
73.4% (-0.27% 🔻)
14438/19671
🔴 Branches
51.39% (-0.38% 🔻)
3541/6890
🔴 Functions
56.62% (-0.5% 🔻)
2091/3693
🟡 Lines
74.96% (-0.31% 🔻)
13127/17512
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🟢 mocks/terms.md.js 75% 100% 100% 100%
🟢
... / usePredictSafeAddressFromTxDetails.ts
90% 82.35% 100% 90%
🔴
... / index.tsx
50% 0% 0% 50%
🟡
... / index.tsx
62.5% 0% 0% 62.5%
🔴
... / index.tsx
55.56% 0% 0% 55.56%
🔴
... / ReviewSubaccount.tsx
35.71% 0% 0% 35.71%
🔴
... / SetupSubaccount.tsx
38.89% 22.22% 11.11% 39.62%
🔴
... / index.tsx
46.15% 0% 0% 46.15%
🟢
... / subaccounts.ts
75% 100% 100% 100%
🟡
... / index.tsx
71.43% 100% 0% 71.43%
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟢
... / txHistorySlice.ts
93.02% (+2.11% 🔼)
66.67% (-6.06% 🔻)
60%
94.74% (+1.88% 🔼)
🟡
... / formatters.ts
79.31% (-1.33% 🔻)
57.14% (-9.52% 🔻)
84.62% (-1.1% 🔻)
79.07% (-1.37% 🔻)
🔴
... / sdk.ts
39.42% (-0.44% 🔻)
9.76% (-0.5% 🔻)
29.41%
34.15% (-0.53% 🔻)
🟢 src/utils/date.ts
75.61% (-0.58% 🔻)
90% (+15% 🔼)
75%
80% (-0.65% 🔻)
🟢
... / utils.ts
89.47% (-1.19% 🔻)
80%
90.48% (+0.48% 🔼)
94.92%
🟢
... / Approvals.tsx
93.33% (-0.42% 🔻)
33.33% 100% 100%
🟡
... / index.tsx
76.92% (-1.65% 🔻)
42.86% (-17.14% 🔻)
100%
75% (-1.92% 🔻)
🔴
... / GlobalPushNotifications.tsx
62.2% (-0.18% 🔻)
38.57% (-1.13% 🔻)
58.73%
59.24% (-0.22% 🔻)
🟢
... / RecoveryProposalCard.tsx
93.33% (-0.22% 🔻)
75% (-8.33% 🔻)
80%
92.59% (-0.26% 🔻)
🟢
... / index.tsx
86.05%
40% (-2.42% 🔻)
42.86% 85.37%
🟢
... / index.tsx
66.67% (-8.33% 🔻)
0% (-100% 🔻)
0% 100%
🟡
... / useAllSafesGrouped.ts
53.57% (-1.6% 🔻)
0% 27.27%
63.64% (-1.58% 🔻)
🟢
... / index.tsx
100%
75% (-25% 🔻)
100% 100%
🟢
... / useTxPendingStatuses.ts
77.5% (-0.83% 🔻)
64.06% (-1.56% 🔻)
68.18%
86.41% (-0.97% 🔻)
🟡
... / index.tsx
59.86% (-0.27% 🔻)
42.42% 55.56%
60.58% (-0.29% 🔻)
🟡
... / index.tsx
59.18% (-0.82% 🔻)
0% 0%
61.7% (-0.8% 🔻)
🟡
... / index.tsx
56.25% (+2.59% 🔼)
9.52% (-7.14% 🔻)
11.11%
60% (+3.59% 🔼)
🔴
... / RecoverAccountFlowSetup.tsx
51.28% (-1.22% 🔻)
16.67% 30%
51.35% (-1.28% 🔻)

Test suite run success

1666 tests passing in 227 suites.

Report generated by 🧪jest coverage report action from cc3c894

Copy link

github-actions bot commented Oct 31, 2024

📦 Next.js Bundle Analysis for safe-wallet-web

This analysis was generated by the Next.js Bundle Analysis action. 🤖

⚠️ Global Bundle Size Increased

Page Size (compressed)
global 1.2 MB (🟡 +220 KB)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

Twenty-three Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load
/apps 25.72 KB (🟢 -13.8 KB) 1.22 MB
/apps/custom 23.77 KB (🟢 -13.8 KB) 1.22 MB
/apps/open 8.24 KB (🟢 -45.48 KB) 1.21 MB
/balances 37.48 KB (🟢 -95 B) 1.23 MB
/balances/nfts 16.88 KB (🟢 -667 B) 1.21 MB
/bridge 1.79 KB (🟢 -796 B) 1.2 MB
/home 38.87 KB (🟢 -19.78 KB) 1.24 MB
/new-safe/advanced-create 20.99 KB (🟢 -15.78 KB) 1.22 MB
/new-safe/create 20.08 KB (🟢 -15.78 KB) 1.22 MB
/new-safe/load 5.23 KB (🟢 -11.09 KB) 1.2 MB
/settings/environment-variables 8.51 KB (🟢 -282 B) 1.21 MB
/settings/notifications 26.65 KB (🟢 -179 B) 1.22 MB
/settings/safe-apps 10.26 KB (🟢 -12.91 KB) 1.21 MB
/settings/setup 38.02 KB (🟢 -8.24 KB) 1.23 MB
/share/safe-app 8.57 KB (🟢 -601 B) 1.21 MB
/stake 588 B (🟢 -22 B) 1.2 MB
/swap 730 B (🟢 -22 B) 1.2 MB
/transactions 56.02 KB (🟢 -54 KB) 1.25 MB
/transactions/history 55.98 KB (🟢 -54 KB) 1.25 MB
/transactions/messages 17.6 KB (🟢 -46.31 KB) 1.21 MB
/transactions/msg 8.33 KB (🟢 -46.4 KB) 1.21 MB
/transactions/queue 7.42 KB (🟢 -45.56 KB) 1.2 MB
/transactions/tx 1000 B (🟢 -45.91 KB) 1.2 MB
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this.

Copy link
Member

@schmanu schmanu left a comment

Choose a reason for hiding this comment

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

Looking and working great 🔥
I added some comments regarding multichain compatibility

Feature wise:
I think we could already add a new page on e.g. route /subaccounts which fetches and lists all SubAccounts / owned Safes of the currently opened Safe and simply offers links to open those.
We could also include the Create button there.

@iamacook iamacook changed the title PoC: Create (and fund) Subaccounts feat: Subaccounts Nov 28, 2024
Comment on lines +82 to +83
// TODO: Add link
href="#"
Copy link
Member Author

Choose a reason for hiding this comment

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

Marking this so we don't forget.

@iamacook iamacook requested a review from tmjssz November 29, 2024 07:12
Copy link

},
chain,
)
const saltNonce = subaccounts.safes.length.toString()
Copy link
Member

Choose a reason for hiding this comment

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

This could cause issues if someone replaces the parent Safe in the subaccount as the nonce would then be used up already.

Copy link
Member

Choose a reason for hiding this comment

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

We could either use the getAvailableSaltNonce function or maybe just use Date.now as these accounts are deployed immediately and not counterfactual.

Copy link
Member Author

Choose a reason for hiding this comment

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

As the Safes aren't counterfactual, I changed it to Date.now in 322f47d.

@iamacook iamacook marked this pull request as draft December 6, 2024 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants