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

Refactor: Upgrade ethers to v6 and protocol-kit to v2 #3087

Merged
merged 16 commits into from
Jan 25, 2024
Merged

Conversation

compojoom
Copy link
Contributor

@compojoom compojoom commented Jan 9, 2024

What it solves

fixes #2901 (#2901)
fixes #1984 (#1984)

This PR upgrades ethers to version 6 and protocol kit to v2.

I’ve followed the migration guide from v5 to perform the update:
https://docs.ethers.org/v6/migrating/

How this PR fixes it

How to test it

Screenshots

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

Copy link

github-actions bot commented Jan 11, 2024

Copy link

github-actions bot commented Jan 11, 2024

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

github-actions bot commented Jan 11, 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.03 MB (🟡 +159.88 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!

Sixteen 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 47.84 KB (🟢 -1.66 KB) 1.08 MB
/apps/custom 39.25 KB (🟢 -1.66 KB) 1.07 MB
/apps/open 64.03 KB (🟢 -1.78 KB) 1.09 MB
/balances/nfts 20.43 KB (-2 B) 1.05 MB
/home 40.74 KB (🟢 -1.68 KB) 1.07 MB
/licenses 5.1 KB (🟢 -21 B) 1.04 MB
/new-safe/create 29.66 KB (🟢 -15 B) 1.06 MB
/settings/modules 9.46 KB (🟡 +1 B) 1.04 MB
/settings/safe-apps 24 KB (🟢 -1.66 KB) 1.05 MB
/settings/security-login 29.61 KB (🟢 -13 B) 1.06 MB
/share/safe-app 10.91 KB (🟡 +4 B) 1.04 MB
/transactions 92.54 KB (🟢 -140 B) 1.12 MB
/transactions/history 92.51 KB (🟢 -140 B) 1.12 MB
/transactions/messages 49.35 KB (🟢 -115 B) 1.08 MB
/transactions/queue 44.44 KB (🟢 -139 B) 1.07 MB
/transactions/tx 33.97 KB (🟢 -140 B) 1.06 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

github-actions bot commented Jan 11, 2024

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
78.85% (-0.01% 🔻)
11278/14303
🔴 Branches
56.68% (+0.15% 🔼)
2504/4418
🟡 Functions
63.09% (+0.05% 🔼)
1795/2845
🟢 Lines
80.21% (-0.03% 🔻)
10172/12681
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🟢
... / storageHelpers.ts
100% 100% 100% 100%
🔴
... / UncheckedJsonRpcSigner.ts
40% 100% 0% 40%
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟡
... / web3.ts
64.58% (-2.08% 🔻)
16.67%
42.86% (-14.29% 🔻)
62.16% (-2.7% 🔻)
🟢
... / addresses.ts
90.91% (-0.27% 🔻)
83.33% 83.33%
92.31% (-0.28% 🔻)
🟡
... / transactions.ts
62.93% (-0.32% 🔻)
27.78% 31.82%
66.67% (-0.33% 🔻)
🟡
... / wallets.ts
62.86% (-1.03% 🔻)
25% 75%
65.52% (-1.15% 🔻)
🟡
... / formatters.ts
76.92% (-5.77% 🔻)
54.55% (-9.09% 🔻)
83.33%
76.32% (-5.26% 🔻)
🔴
... / dispatch.ts
47.06% (-1.57% 🔻)
46.43% (-8.12% 🔻)
29.63% (-1.14% 🔻)
46.15% (-1.64% 🔻)
🟢
... / index.tsx
82.35% (-8.82% 🔻)
66.67% (-16.67% 🔻)
50% (-12.5% 🔻)
83.87% (-9.68% 🔻)
🔴
... / test-utils.tsx
58.82% (-1.18% 🔻)
66.67% 37.5%
57.58% (-1.25% 🔻)
🟢
... / recovery-state.ts
95.24%
84.21% (-0.79% 🔻)
85.71%
96.55% (+0.06% 🔼)
🟢
... / useRecoveryTxState.ts
100%
85.71% (-7.14% 🔻)
100% 100%
🟢
... / useSafeWalletProvider.tsx
81.82% (-0.18% 🔻)
64.71% 69.23%
83.87% (-0.17% 🔻)
🟡
... / safe-messages.ts
79.66% (-0.34% 🔻)
72% 100%
77.36% (-0.42% 🔻)
🟡
... / index.tsx
72.73% (-0.8% 🔻)
73.33% 60%
73.33% (-0.86% 🔻)
🟢
... / index.ts
93.48% (-0.14% 🔻)
90% 83.33%
95.56% (-0.1% 🔻)
🟢
... / Approvals.tsx
90% (-0.91% 🔻)
33.33% 100% 100%
🟢
... / useSafeTokenAllocation.ts
94.74% (-0.07% 🔻)
73.68% (-2.79% 🔻)
100%
94.2% (-0.08% 🔻)
🟢
... / index.tsx
95.56% (-0.1% 🔻)
78.95% (+5.26% 🔼)
80%
95.12% (-0.12% 🔻)
🟢
... / utils.ts
86.17% (-0.15% 🔻)
62.96% 86.67%
90.48% (-0.11% 🔻)
🟢
... / useWalletBalance.ts
84.62% (-7.05% 🔻)
66.67% 100%
83.33% (-7.58% 🔻)
🔴
... / AdvancedParamsForm.tsx
52.17% (-1.99% 🔻)
0% 0%
54.55% (-1.98% 🔻)
🔴
... / useAppCommunicator.ts
55.41% (-0.59% 🔻)
22.22% 35%
55.56% (-0.61% 🔻)
🔴
... / useIsSafeTokenPaused.ts
42.86% (-2.6% 🔻)
0% 0%
42.11% (-2.89% 🔻)
🔴
... / index.tsx
50% (-0.62% 🔻)
13.33% (+0.83% 🔼)
9.09%
52.7% (-0.63% 🔻)
🔴
... / ReviewSpendingLimit.tsx
42.11% (-1.48% 🔻)
0% 0%
44.44% (-1.5% 🔻)

Test suite run success

1380 tests passing in 186 suites.

Report generated by 🧪jest coverage report action from 5006a34

Copy link

github-actions bot commented Jan 15, 2024

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

@compojoom compojoom marked this pull request as ready for review January 15, 2024 13:15
@compojoom compojoom force-pushed the ethers-v6 branch 2 times, most recently from b5b5a2e to 7949282 Compare January 16, 2024 16:38
Copy link

github-actions bot commented Jan 16, 2024

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

@compojoom compojoom changed the title WIP: update ethers to v6 and protocol-kit to v2 chore: Upgrade ethers to v6 and protocol-kit to v2 Jan 16, 2024
@katspaugh katspaugh changed the title chore: Upgrade ethers to v6 and protocol-kit to v2 Refactor: Upgrade ethers to v6 and protocol-kit to v2 Jan 16, 2024
Copy link
Member

@katspaugh katspaugh left a comment

Choose a reason for hiding this comment

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

Looks great! Left some questions.

src/components/new-safe/create/logic/index.ts Outdated Show resolved Hide resolved
src/components/tx-flow/flows/ExecuteBatch/ReviewBatch.tsx Outdated Show resolved Hide resolved
src/features/recovery/services/recovery-sender.ts Outdated Show resolved Hide resolved
src/services/contracts/safeContracts.ts Show resolved Hide resolved
src/services/tx/tx-sender/dispatch.ts Show resolved Hide resolved
Copy link

github-actions bot commented Jan 19, 2024

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

github-actions bot commented Jan 25, 2024

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 and others added 5 commits January 25, 2024 16:26
fixes #2901 (#2901)
fixes #1984 (#1984)

This PR upgrades ethers to version 6 and protocol kit to v2.

I’ve followed the migration guide from v5 to perform the update:
https://docs.ethers.org/v6/migrating/

Co-authored-by: Usame Algan <usame@safe-global>
Co-authored-by: Manuel Gellfart <manu@safe.global>
When creating a pending Safe the the tx’s value was a bigInt 0n, this was causing the json Serializer to crash. The JSON standard doesn’t know how to treat BigInts, but. thankfully the parse an serialize functions have a second argument that can be used for custom types.

Whenever we stumble on a BigInt we store it in the storage as an object of {__type: ‘bigint’, __value: ‘0x…’}
Later when we load the key, we transform it back to a BigInt(0x…)
* fix: spending limit gasLimit estimation
* fix: Show more accurate total fee during safe creation

* fix: Write tests for totalFee calculation
schmanu and others added 6 commits January 25, 2024 16:26
* fix: show zero wallet balance

* test: unittest for walletbalance component

* fix: unused imports
* fix: UI not updating if signing from walletconnect

If another safe is owner of a safe and we use walletconnect to sign transaction the UI was not updating. It turns out we need to port the  UncheckedJsonRpcSigner from ethers v5.

The UncheckedJsonRpcSigner fakes a transaction receipt without actually having one,
and this is needed for transactions that don’t
actually end on-chain.

* fix: failing tests and linting

* feat: use uncheckedSigner for getDelayModifier
* fix: do not pad the chainId to bytes

* refactor: use utils function
ethers v6 converts the chainId to a hex value: https://github.com/ethers-io/ethers.js/blob/50b74b8806ef2064f2764b09f89c7ac75fda3a3c/src.ts/hash/typed-data.ts#L75
Our SDK expects a number, that's why we convert the hex value from ethers v6 to number.
If this gets fixed here: safe-global/safe-eth-py#748
we can remove this workaround
@liliya-soroka
Copy link
Member

Verified

Copy link
Member

@usame-algan usame-algan left a comment

Choose a reason for hiding this comment

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

LGTM 🚀 🚀 🌔

@compojoom compojoom merged commit 3d7b0b4 into dev Jan 25, 2024
15 checks passed
@compojoom compojoom deleted the ethers-v6 branch January 25, 2024 21:59
@github-actions github-actions bot locked and limited conversation to collaborators Jan 25, 2024
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.

Migrate to Ethers v6 Update safe-core-sdk to @safe-global/protocol-kit
5 participants