-
Notifications
You must be signed in to change notification settings - Fork 470
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(safenet): Multi-recipient token transfers #4788
base: safenet
Are you sure you want to change the base?
Conversation
Branch preview❌ Deploy failed! |
Coverage report for
|
St.❔ |
Category | Percentage | Covered / Total |
---|---|---|---|
🟡 | Statements | 74.13% (-0% 🔻) |
14865/20052 |
🔴 | Branches | 51.84% (-0.02% 🔻) |
3566/6879 |
🔴 | Functions | 56.98% (-0% 🔻) |
2106/3696 |
🟡 | Lines | 75.66% (+0% 🔼) |
13489/17829 |
Show files with reduced coverage 🔻
St.❔ |
File | Statements | Branches | Functions | Lines |
---|---|---|---|---|---|
🟢 | ... / index.tsx |
100% | 83.33% (-16.67% 🔻) |
100% | 100% |
🟢 | ... / useRemoteSafeApps.ts |
86.84% (-4.07% 🔻) |
57.14% (-9.52% 🔻) |
83.33% (-7.58% 🔻) |
90.63% (-2.23% 🔻) |
🟢 | ... / index.tsx |
66.67% (-8.33% 🔻) |
0% (-100% 🔻) |
0% | 80% (-20% 🔻) |
🟡 | ... / index.tsx |
74.07% (+2.07% 🔼) |
58.82% (-2.71% 🔻) |
33.33% (+13.33% 🔼) |
76% (+2.09% 🔼) |
Test suite run failed
Failed tests: 3/1793. Failed suites: 2/242.
● ConfirmationView › should display a confirmation screen for a SETTINGS_CHANGE transaction
expect(received).toMatchSnapshot()
Snapshot name: `ConfirmationView should display a confirmation screen for a SETTINGS_CHANGE transaction 1`
- Snapshot - 8
+ Received + 12
@@ -279,18 +279,22 @@
data-testid="tx-data-row"
>
<div
class="MuiBox-root css-axw7ok"
>
- <img
- alt="ETH"
- class="image"
- height="26"
- loading="lazy"
- referrerpolicy="no-referrer"
- src="/images/common/token-placeholder.svg"
- />
+ <div
+ class="container false"
+ >
+ <img
+ alt="ETH"
+ class="image"
+ height="26"
+ loading="lazy"
+ referrerpolicy="no-referrer"
+ src="/images/common/token-placeholder.svg"
+ />
+ </div>
<p
class="MuiTypography-root MuiTypography-body1 css-w5uidf-MuiTypography-root"
>
ETH
</p>
116 | )
117 |
> 118 | expect(container).toMatchSnapshot()
| ^
119 | })
120 |
121 | it("should display a confirmation with method call when the transaction type is not found in the ConfirmationView's mapper", () => {
at Object.toMatchSnapshot (src/components/tx/confirmation-views/ConfirmationView.test.tsx:118:23)
● ConfirmationView › should display a confirmation with method call when the transaction type is not found in the ConfirmationView's mapper
expect(received).toMatchSnapshot()
Snapshot name: `ConfirmationView should display a confirmation with method call when the transaction type is not found in the ConfirmationView's mapper 1`
- Snapshot - 8
+ Received + 12
@@ -168,18 +168,22 @@
data-testid="tx-data-row"
>
<div
class="MuiBox-root css-axw7ok"
>
- <img
- alt="ETH"
- class="image"
- height="26"
- loading="lazy"
- referrerpolicy="no-referrer"
- src="/images/common/token-placeholder.svg"
- />
+ <div
+ class="container false"
+ >
+ <img
+ alt="ETH"
+ class="image"
+ height="26"
+ loading="lazy"
+ referrerpolicy="no-referrer"
+ src="/images/common/token-placeholder.svg"
+ />
+ </div>
<p
class="MuiTypography-root MuiTypography-body1 css-w5uidf-MuiTypography-root"
>
ETH
</p>
131 | )
132 |
> 133 | expect(container).toMatchSnapshot()
| ^
134 | })
135 | })
136 |
at Object.toMatchSnapshot (src/components/tx/confirmation-views/ConfirmationView.test.tsx:133:23)
● SignOrExecute › should display a confirmation screen
expect(received).toMatchSnapshot()
Snapshot name: `SignOrExecute should display a confirmation screen 1`
- Snapshot - 1
+ Received + 70
@@ -76,11 +76,80 @@
role="region"
>
<div
class="MuiAccordionDetails-root css-w74p4c-MuiAccordionDetails-root"
data-testid="decoded-tx-details"
- />
+ >
+ <div
+ class="MuiBox-root css-164r41r"
+ >
+ <div
+ class="MuiGrid-root MuiGrid-container css-86qz5o-MuiGrid-root"
+ >
+ <div
+ class="MuiGrid-root MuiGrid-item css-1wehkfy-MuiGrid-root"
+ data-testid="tx-row-title"
+ style="word-break: break-word;"
+ >
+ <p
+ class="MuiTypography-root MuiTypography-body1 css-shf88x-MuiTypography-root"
+ >
+ Safenet checks:
+ </p>
+ </div>
+ <div
+ class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-true css-1vd824g-MuiGrid-root"
+ data-testid="tx-data-row"
+ >
+ <div
+ class="safenetGradientRow MuiBox-root css-0"
+ style="border-radius: calc(var(--space-1) - 1px); display: flex; align-items: stretch; flex-direction: column; justify-content: space-between;"
+ >
+ <div
+ class="MuiBox-root css-0"
+ style="display: flex; flex-direction: row; justify-content: space-between; align-items: center;"
+ >
+ <mock-icon
+ aria-hidden=""
+ class="MuiSvgIcon-root MuiSvgIcon-fontSizeSmall css-tqxw8e-MuiSvgIcon-root"
+ focusable="false"
+ />
+ <h5
+ class="MuiTypography-root MuiTypography-h5 css-1ukimg9-MuiTypography-root"
+ >
+ Powered by Safenet
+ </h5>
+ </div>
+ <div
+ class="MuiBox-root css-0"
+ style="border-radius: 0 0 var(--space-1) var(--space-1); margin: 0px 1px 1px 1px;"
+ >
+ <span
+ class="MuiCircularProgress-root MuiCircularProgress-indeterminate MuiCircularProgress-colorPrimary css-k0aauw-MuiCircularProgress-root"
+ role="progressbar"
+ style="width: 22px; height: 22px;"
+ >
+ <svg
+ class="MuiCircularProgress-svg css-54pwck-MuiCircularProgress-svg"
+ viewBox="22 22 44 44"
+ >
+ <circle
+ class="MuiCircularProgress-circle MuiCircularProgress-circleIndeterminate css-960umw-MuiCircularProgress-circle"
+ cx="44"
+ cy="44"
+ fill="none"
+ r="20.2"
+ stroke-width="3.6"
+ />
+ </svg>
+ </span>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
</div>
</div>
</div>
</div>
</div>
54 |
55 | expect(getByTestId('sign-btn')).toBeInTheDocument()
> 56 | expect(container).toMatchSnapshot()
| ^
57 | })
58 |
59 | it('should display an error screen', async () => {
at Object.toMatchSnapshot (src/components/tx/SignOrExecuteForm/__tests__/SignOrExecute.test.tsx:56:23)
Report generated by 🧪jest coverage report action from 95dd1ed
📦 Next.js Bundle Analysis for @safe-global/webThis analysis was generated by the Next.js Bundle Analysis action. 🤖
|
Page | Size (compressed) |
---|---|
global |
1.05 MB (🟡 +63 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!
New Page Added
The following page was added to the bundle from the code in this PR:
Page | Size (compressed) | First Load |
---|---|---|
/settings/safenet |
218.55 KB |
1.26 MB |
Thirty-one Pages Changed Size
The following pages changed size from the code in this PR compared to its base branch:
Page | Size (compressed) | First Load |
---|---|---|
/ |
508 B (🟢 -2 B) |
1.05 MB |
/address-book |
23.21 KB (🟡 +142 B) |
1.07 MB |
/apps |
35.54 KB (🟡 +1.82 KB) |
1.09 MB |
/apps/custom |
33.6 KB (🟡 +1.82 KB) |
1.08 MB |
/apps/open |
55.72 KB (🟡 +2.11 KB) |
1.1 MB |
/balances |
29.94 KB (🟡 +243 B) |
1.08 MB |
/balances/nfts |
9.56 KB (🟡 +13 B) |
1.06 MB |
/bridge |
2.56 KB (🟡 +3 B) |
1.05 MB |
/cookie |
8.77 KB (🟡 +1 B) |
1.06 MB |
/home |
61.24 KB (🟡 +1.98 KB) |
1.11 MB |
/new-safe/advanced-create |
26.38 KB (🟢 -70 B) |
1.08 MB |
/new-safe/create |
25.52 KB (🟢 -71 B) |
1.08 MB |
/privacy |
14.57 KB (🟡 +2 B) |
1.06 MB |
/settings/appearance |
2.25 KB (🟡 +2 B) |
1.05 MB |
/settings/environment-variables |
3.27 KB (🟢 -1 B) |
1.05 MB |
/settings/modules |
4.11 KB (🟡 +54 B) |
1.05 MB |
/settings/notifications |
6.33 KB (🟢 -14.99 KB) |
1.06 MB |
/settings/safe-apps |
20.4 KB (🟡 +2.13 KB) |
1.07 MB |
/settings/security |
2.34 KB (🟡 +1 B) |
1.05 MB |
/settings/setup |
30.83 KB (🟡 +94 B) |
1.08 MB |
/share/safe-app |
7.56 KB (🟢 -5 B) |
1.06 MB |
/stake |
618 B (🟢 -1 B) |
1.05 MB |
/swap |
761 B (🟡 +1 B) |
1.05 MB |
/terms |
12.93 KB (🟡 +1 B) |
1.06 MB |
/transactions |
99.58 KB (🟡 +3 KB) |
1.15 MB |
/transactions/history |
99.54 KB (🟡 +3 KB) |
1.15 MB |
/transactions/messages |
60.37 KB (🟡 +2.07 KB) |
1.11 MB |
/transactions/msg |
56.62 KB (🟡 +2.07 KB) |
1.11 MB |
/transactions/queue |
49.47 KB (🟡 +2.08 KB) |
1.1 MB |
/transactions/tx |
48.83 KB (🟡 +2.07 KB) |
1.1 MB |
/welcome/accounts |
409 B (🟡 +2 B) |
1.05 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.
apps/web/src/components/tx-flow/flows/SafenetTokenTransfers/CSVAirdropAppModal/index.tsx
Outdated
Show resolved
Hide resolved
apps/web/src/components/tx-flow/flows/SafenetTokenTransfers/CSVAirdropAppModal/index.tsx
Outdated
Show resolved
Hide resolved
apps/web/src/components/tx-flow/flows/SafenetTokenTransfers/CreateTokenTransfers.tsx
Outdated
Show resolved
Hide resolved
apps/web/src/components/tx-flow/flows/SafenetTokenTransfers/CreateTokenTransfers.tsx
Outdated
Show resolved
Hide resolved
apps/web/src/components/tx-flow/flows/SafenetTokenTransfers/CreateTokenTransfers.tsx
Outdated
Show resolved
Hide resolved
import { type SafeBalanceResponse } from '@safe-global/safe-gateway-typescript-sdk' | ||
|
||
export const useTokenAmount = (selectedToken: SafeBalanceResponse['items'][0] | undefined) => { | ||
const totalFiatAmount = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not understand why we need to consider decimals
for the fiatBalance
.
The decimals should only matter for the balance
.
Generally I feel like the maxAmount is a bit more complex. IMO it should consider the upper bound of e.g. 100.000$ in fiat.
But also consider how much unified balance the user has and how much is already used up by previous transfers.
</Grid> | ||
) | ||
|
||
export const CreateTokenTransfers = ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a component to check that the total transfer amount is not higher than the users balance
const recipient = watch(TokenTransfersFields.recipients) | ||
|
||
// TODO: Review tokens available for selection and max amount | ||
const selectedToken = balancesItems.find((item) => item.tokenInfo.symbol === 'USDC') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should use the addresses from the Safenet config instead of the name / symbol. There are many fake tokens that are called USDC for instance.
…eateTokenTransfers.tsx Co-authored-by: Manuel Gellfart <[email protected]>
What it solves
This PR adds a multi-recipient token transfer tx flow for Safenet-enabled Safe accounts
Resolves https://github.com/safe-global/safenet/issues/269
How to test it
Create a new transaction on a Safenet-enabled Safe.
Checklist