You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now that the JSON has been updated to allow for multiple addresses per network, new accessor functions for fetching deployments including multiple addresses need to be added to the repository.
This PR is a new API proposal for the functions that support the updated
JSON format, which supports multiple deployments per network. Implements
#685
The complexity of supporting multiple formats is handled by the utility
function `findDeployments`, which contains a function overload with the
deployment format parameter.
The new functions are added alongside the [existing
API](https://github.com/safe-global/safe-deployments?tab=readme-ov-file#usage)
functions but with plural `deployments` at the end of the function name.
**Example function:**
```
export const getProxyFactoryDeployments = (filter?: DeploymentFilter): SingletonDeploymentV2 | undefined => {
return findDeployment(filter, factoryDeployments, DeploymentFormats.MULTIPLE);
};
```
**My reason for going with this approach**:
All the complexity is kept within the internal `findDeployment`
function. Developers do not have to import and understand which format
means what and don't have to import the additional `DeploymentFilter`
enum. Type shenanigans are kept to a minimum. Also, the alternative
approach below would require refactoring package functions to be defined
via the `function` keyword because arrow functions do not support
function overloads properly:
https://www.perplexity.ai/search/typescript-arrow-function-over-tit1.0R8Rracx_PAUr1nVw#0
**Alternative approach:**
Add function overloads to the existing functions like this:
```
export const getSafeSingletonDeployment = (filter?: DeploymentFilter, format = DeploymentFormats.SINGLETON) => {
return findDeployment(filter, _safeDeployments, format);
};
```
---------
Co-authored-by: Nicholas Rodrigues Lordello <[email protected]>
Now that the JSON has been updated to allow for multiple addresses per network, new accessor functions for fetching deployments including multiple addresses need to be added to the repository.
Work has already begun in #684
The text was updated successfully, but these errors were encountered: