Skip to content

Commit

Permalink
Readme updates and improvements to the deployment process (#678)
Browse files Browse the repository at this point in the history
This PR proposes README updates after
#348, namely:

1. Add more detailed steps to add new deployments to the package
2. Grammar fixes
3. Describe the meaning of returned values
4. Remove the obsolete issue template for the new chain. I removed it
because we unnecessarily make people open an issue and a PR
simultaneously. We do not deploy the contracts ourselves, so I don't
think we need an issue template. If the latter is not the case, I can
look into switching the template to be more
`safe-singleton-factory`-alike.
5. Remove the migration script I forgot to remove in my previous PR.
  • Loading branch information
mmv08 authored Jul 2, 2024
1 parent 20309ef commit 356efab
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 217 deletions.
51 changes: 0 additions & 51 deletions .github/ISSUE_TEMPLATE/new_chain.yaml

This file was deleted.

84 changes: 56 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,87 +3,115 @@
[![npm version](https://badge.fury.io/js/%40safe-global%2Fsafe-deployments.svg)](https://badge.fury.io/js/%40safe-global%2Fsafe-deployments)
[![CI](https://github.com/safe-global/safe-deployments/actions/workflows/test.yml/badge.svg)](https://github.com/safe-global/safe-deployments/actions/workflows/test.yml)

This contract contains a collection of deployments of the contract of the [Safe contracts repository](https://github.com/safe-global/safe-contracts).
This contract contains a collection of deployments of the contract of the [Safe contracts repository](https://github.com/safe-global/safe-smart-account).

For each deployment the address on the different networks and the abi files are available. To get an overview of the available versions check the available [json assets](./src/assets/).
The addresses on the different networks and the abi files are available for each deployment. To get an overview of the available versions, check the available [json assets](./src/assets/).

To add additional deployments please follow the [deployment steps in the Safe contract repository](https://github.com/safe-global/safe-contracts#deployments).
## Adding additional deployments:

1. Follow the [deployment steps in the Safe contract repository](https://github.com/safe-global/safe-smart-contracts#deployments).
2. Verify that the addresses match the expected address for each contract. You can find them under the "addresses" mapping in the respective JSON file in the [assets folder](./src/assets/).
3. Create a PR adding the new deployment. Example PR can be found [here](https://github.com/safe-global/safe-deployments/pull/676).

## Install

- npm - `npm i @safe-global/safe-deployments`
- yarn - `yarn add @safe-global/safe-deployments`

## Usage

It is possible to directly use the json files in the [assets folder](./src/assets/) that contain the addresses and abi definitions.
It is possible to directly use the JSON files in the [assets folder](./src/assets/) that contain the addresses and abi definitions.

An alternative is to use the JavaScript library methods to query the correct deployment. The library supports different methods to get the deployment of a specific contract.
An alternative is using JavaScript library methods to query the correct deployment. The library supports different methods to get the deployment of a specific contract.

Each of the method takes an optional `DeploymentFilter` as a parameter.
Each of the methods takes an optional `DeploymentFilter` as a parameter.

```ts
interface DeploymentFilter {
version?: string,
released?: boolean, // Defaults to true if no filter is specified
network?: string // Chain id of the network
version?: string;
released?: boolean; // Defaults to true if no filter is specified
network?: string; // Chain id of the network
}
```

The method will return a `SingletonDeployment` object or `undefined` if no deployment was found for the specified filter.

```ts
interface SingletonDeployment {
defaultAddress: string, // Address the contract was deployed to by the Safe team
version: string,
abi: any[],
networkAddresses: Record<string, string>, // Address of the contract by network
contractName: string,
released: boolean // A released version was audited and has a running bug bounty
// The default address of the deployment.
defaultAddress: string;

// Indicates if the deployment is released.
released: boolean;

// The name of the contract.
contractName: string;

// The version of the deployment.
version: string;

// The hash of the contract code.
codeHash: string;

// A record of addresses, where the key is the address type and the value is the address.
addresses: Record<string, string>;

// A record of network addresses, where the key is the network identifier and the value is the address.
networkAddresses: Record<string, string>;

// The ABI (Application Binary Interface) of the contract.
abi: any[];
}
```

- Safe

```ts
const safeSingleton = getSafeSingletonDeployment()
const safeSingleton = getSafeSingletonDeployment();

// Returns latest contract version, even if not finally released yet
const safeSingletonNightly = getSafeSingletonDeployment({ released: undefined })
const safeSingletonNightly = getSafeSingletonDeployment({ released: undefined });

// Returns released contract version for specific network
const safeSingletonGörli = getSafeSingletonDeployment({ network: "5" })
const safeSingletonGörli = getSafeSingletonDeployment({ network: '5' });

// Returns released contract version for specific version
const safeSingleton100 = getSafeSingletonDeployment({ version: "1.0.0" })
const safeSingleton100 = getSafeSingletonDeployment({ version: '1.0.0' });

// Version with additional events used on L2 networks
const safeL2Singleton = getSafeL2SingletonDeployment()
const safeL2Singleton = getSafeL2SingletonDeployment();
```

- Factories

```ts
const proxyFactory = getProxyFactoryDeployment()
const proxyFactory = getProxyFactoryDeployment();
```

- Libraries

```ts
const multiSendLib = getMultiSendDeployment()
const multiSendLib = getMultiSendDeployment();

const multiSendCallOnlyLib = getMultiSendCallOnlyDeployment()
const multiSendCallOnlyLib = getMultiSendCallOnlyDeployment();

const createCallLib = getCreateCallDeployment()
const createCallLib = getCreateCallDeployment();
```

- Handler

```ts
// Returns recommended handler
const fallbackHandler = getFallbackHandlerDeployment()
const fallbackHandler = getFallbackHandlerDeployment();

const callbackHandler = getDefaultCallbackHandlerDeployment()
const callbackHandler = getDefaultCallbackHandlerDeployment();

const compatHandler = getCompatibilityFallbackHandlerDeployment()
const compatHandler = getCompatibilityFallbackHandlerDeployment();
```

## Release cycle
`safe-deployments` release cycle is once per month, except urgent issues that require immediate attention.

`safe-deployments` release cycle is once per month, except for urgent issues that require immediate attention.

## Notes

Expand Down
138 changes: 0 additions & 138 deletions src/jsonMigrationScript130.ts

This file was deleted.

Loading

0 comments on commit 356efab

Please sign in to comment.