Skip to content

Commit

Permalink
add migration guides highlighting the major changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dasanra committed Nov 23, 2023
1 parent 0886e80 commit e5dc463
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 0 deletions.
26 changes: 26 additions & 0 deletions safe-core-sdk/api-kit/migrating/v2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# API Kit: Migrating from v1

This guide aims to be a reference of the major changes between v1 and v2 to help those migrating an existing app.

## API Kit constructor

Now it won't be necessary to specify a `txServiceUrl` in those environments where Safe has a Transaction Service running, specifiying the chain ID will be enough. If you want to use your custom service or use the kit in a chain not supported by a Safe Transaction Service, you can add `txServiceUrl` parameter.

Check failure on line 7 in safe-core-sdk/api-kit/migrating/v2.md

View workflow job for this annotation

GitHub Actions / vale

[vale] safe-core-sdk/api-kit/migrating/v2.md#L7

[Vale.Spelling] Did you really mean 'specifiying'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'specifiying'?", "location": {"path": "safe-core-sdk/api-kit/migrating/v2.md", "range": {"start": {"line": 7, "column": 123}}}, "severity": "ERROR"}

```js
// old:
constructor({ txServiceUrl, ethAdapter }: SafeApiKitConfig)

// new:
constructor({ chainId, txServiceUrl? }: SafeApiKitConfig)
```
## Use the route you prefer
API Kit v1 forced the use of a custom service hosted under `/api` route of the URL specified in `txServiceUrl`. This is not the case anymore, you can specify any route you prefer or subdomain.

Check failure on line 19 in safe-core-sdk/api-kit/migrating/v2.md

View workflow job for this annotation

GitHub Actions / vale

[vale] safe-core-sdk/api-kit/migrating/v2.md#L19

[Microsoft.Contractions] Use 'isn't' instead of 'is not'.
Raw output
{"message": "[Microsoft.Contractions] Use 'isn't' instead of 'is not'.", "location": {"path": "safe-core-sdk/api-kit/migrating/v2.md", "range": {"start": {"line": 19, "column": 118}}}, "severity": "ERROR"}
## MasterCopy to Singleton
To avoid confusion between terms that have been used as synonyms we aligned all our code to use the word `singleton`.
- Rename type `MasterCopyResponse` to `SafeSingletonResponse`
- Rename method `getServiceMasterCopiesInfo()` to `getServiceSingletonsInfo()`
48 changes: 48 additions & 0 deletions safe-core-sdk/protocol-kit/migrating/v2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Protocol Kit: Migrating from v1

This guide aims to be a reference of the major changes between v1 and v2 to help those migrating an existing app.

## MasterCopy to Singleton

To avoid confusion between terms that have been used as synonyms we aligned all our code to use the word `singleton`.

- Rename `isL1SafeMasterCopy` to `isL1SafeSingleton`
```js
// old:
SafeFactory.create({ ethAdapter, isL1SafeMasterCopy: true })

// new:
SafeFactory.create({ ethAdapter, isL1SafeSingleton: true })
```

## Ethers v6

From protocolKit v2, EthersAdapter will only be compatible with ethers.js v6. If you still need to use v5 we recommend you to keep protocolKit v1, but encourage you to migrate to the latest version when you have the chance.

Check failure on line 20 in safe-core-sdk/protocol-kit/migrating/v2.md

View workflow job for this annotation

GitHub Actions / vale

[vale] safe-core-sdk/protocol-kit/migrating/v2.md#L20

[Vale.Spelling] Did you really mean 'protocolKit'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'protocolKit'?", "location": {"path": "safe-core-sdk/protocol-kit/migrating/v2.md", "range": {"start": {"line": 20, "column": 6}}}, "severity": "ERROR"}

Check failure on line 20 in safe-core-sdk/protocol-kit/migrating/v2.md

View workflow job for this annotation

GitHub Actions / vale

[vale] safe-core-sdk/protocol-kit/migrating/v2.md#L20

[Vale.Spelling] Did you really mean 'protocolKit'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'protocolKit'?", "location": {"path": "safe-core-sdk/protocol-kit/migrating/v2.md", "range": {"start": {"line": 20, "column": 132}}}, "severity": "ERROR"}

## Protocol Kit createTransaction() accepts only transaction array

In protocolKit v1 the `createTranasction()` method accepted either an object or an array as parameter. To avoid confusion we aligned to accept an array only. Migration can be done as the code below:

Check failure on line 24 in safe-core-sdk/protocol-kit/migrating/v2.md

View workflow job for this annotation

GitHub Actions / vale

[vale] safe-core-sdk/protocol-kit/migrating/v2.md#L24

[Vale.Spelling] Did you really mean 'protocolKit'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'protocolKit'?", "location": {"path": "safe-core-sdk/protocol-kit/migrating/v2.md", "range": {"start": {"line": 24, "column": 4}}}, "severity": "ERROR"}

```js
// old:
const safeTransactionData = {
to: '',
data: '',
value: '',
nonce: '',
safeTxGas: ''
}
const safeTransaction = protocolKit.createTransaction({ safeTransactionData })

// new:
const safeTransactionData = {
to: '',
data: '',
value: ''
}
const options = {
nonce: '',
safeTxGas: ''
}
const safeTransaction = protocolKit.createTransaction({ [safeTransactionData], options })
```
15 changes: 15 additions & 0 deletions safe-core-sdk/relay-kit/migrating/v2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Relay Kit: Migrating from v1

This guide aims to be a reference of the major changes between v1 and v2 to help those migrating an existing app.

## GelatoRelayPack

- The `GelatoRelayPack` constructor now includes a mandatory `protocolKit` parameter as we made it required for any new pack extending the `RelayKitBasePack`

```js
constructor({ apiKey, protocolKit }: GelatoOptions)
```

- We removed the `protocolKit` parameter from `createTransactionWithHandlePayment()`, `createTransactionWithTransfer()` and `executeRelayTransaction()` methods in the `GelatoRelayPack` as we now it's included in the constructor.

- Removed the type `export interface RelayPack` as we use now an abstract class.

0 comments on commit e5dc463

Please sign in to comment.