-
Notifications
You must be signed in to change notification settings - Fork 403
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: support custom networks from config service [SW-136] #4054
base: dev
Are you sure you want to change the base?
Conversation
Branch preview✅ Deploy successful! Storybook: |
ESLint Summary View Full Report
Report generated by eslint-plus-action |
Coverage report
Show new covered files 🐣
Test suite run success1464 tests passing in 201 suites. Report generated by 🧪jest coverage report action from 75e4694 |
ESLint Summary View Full Report
Report generated by eslint-plus-action |
📦 Next.js Bundle Analysis for safe-wallet-webThis analysis was generated by the Next.js Bundle Analysis action. 🤖
|
Page | Size (compressed) |
---|---|
global |
945.38 KB (🟡 +332 B) |
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!
Two Pages Changed Size
The following pages changed size from the code in this PR compared to its base branch:
Page | Size (compressed) | First Load |
---|---|---|
/new-safe/advanced-create |
35.17 KB (🟡 +77 B) |
980.54 KB |
/new-safe/create |
34.39 KB (🟡 +42 B) |
979.77 KB |
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.
…ners, signing messages in chain etc.
ESLint Summary View Full Report
Report generated by eslint-plus-action |
ESLint Summary View Full Report
Report generated by eslint-plus-action |
ESLint Summary View Full Report
Report generated by eslint-plus-action |
const mockSafe = {} as Safe | ||
const initMock = jest.spyOn(coreSDK, 'initSafeSDK').mockReturnValue(Promise.resolve(mockSafe)) | ||
const setSDKMock = jest.spyOn(coreSDK, 'setSafeSDK') | ||
// it('initializes a Core SDK instance', async () => { |
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.
You can use xit
to comment out a test. Why is it commented out though?
import { IS_OFFICIAL_HOST, IS_PRODUCTION } from '@/config/constants' | ||
|
||
const isContractNetworkConfig = (obj: Omit<ChainInfo['contractAddresses'], 'safeWebAuthnSignerFactoryAddress'>) => { | ||
return Object.values(obj).every((value) => !!value) |
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.
Is this a replacement for _.isEmpty()
?
The function name is isContractNetworkConfig
but all this function does is check if all object's properties are truthy.
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.
true, the name doesn't make sense 👍
The reason for the check is that if the contracts are not defined in the config service admin, the contractNetworks object comes back with all the properties defined but set to null:
const contractAddresses: {
safeSingletonAddress: null;
...
}
export const useCustomNetworkContracts = () => { | ||
const currentChain = useCurrentChain() | ||
if (!currentChain || (IS_PRODUCTION && IS_OFFICIAL_HOST)) return | ||
|
||
// Exclude safeWebAuthnSignerFactoryAddress as it is not yet supported. | ||
const { safeWebAuthnSignerFactoryAddress, ...contractAddresses } = currentChain.contractAddresses | ||
|
||
if (!isContractNetworkConfig(contractAddresses)) return | ||
return contractAddresses as ContractNetworkConfig | ||
} |
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.
export const useCustomNetworkContracts = () => { | |
const currentChain = useCurrentChain() | |
if (!currentChain || (IS_PRODUCTION && IS_OFFICIAL_HOST)) return | |
// Exclude safeWebAuthnSignerFactoryAddress as it is not yet supported. | |
const { safeWebAuthnSignerFactoryAddress, ...contractAddresses } = currentChain.contractAddresses | |
if (!isContractNetworkConfig(contractAddresses)) return | |
return contractAddresses as ContractNetworkConfig | |
} | |
export const useCustomNetworkContracts = IS_PRODUCTION && IS_OFFICIAL_HOST ? () => { | |
} : () => undefined |
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.
changed but it should be the opposite way I think:
export const useCustomNetworkContracts = IS_PRODUCTION && IS_OFFICIAL_HOST ? () => undefined : () => {
...}
@schmanu please also review, there might be an overlap with some of the multichain logic. |
ESLint Summary View Full Report
Report generated by eslint-plus-action |
What it solves
Resolves: https://www.notion.so/safe-global/76f265123c0a4ad680947ce489804342?v=17c30f9503cd4d48a622209408de56d6&p=e7fed2501e9e4650b30ba9b4f618a804&pm=s
Relevant changes to client-gateway: safe-global/safe-client-gateway#1752
How this PR fixes it
How to test it
Screenshots
Checklist