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

Add legacy safe-core-sdk migration guide #291

Merged
merged 33 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2f9a285
update ethers docs
DaniSomoza Oct 27, 2023
a120bcb
Merge branch 'main' into ethers-v6-migration-docs
DaniSomoza Oct 27, 2023
0616a40
Merge branch 'main' into ethers-v6-migration-docs
dasanra Nov 23, 2023
53646d2
add singleton change to api-kit and protocol-kit
dasanra Nov 23, 2023
17cbde5
Fix linting and typos
dasanra Nov 23, 2023
4657adf
fix: broken links
dasanra Nov 23, 2023
25b524c
update GelatoRelayKit breaking changes
dasanra Nov 23, 2023
cacf112
Merge branch 'main' into ethers-v6-migration-docs
dasanra Nov 23, 2023
a56bc1a
improve parameter naming
dasanra Nov 23, 2023
43e8a61
fix linter reported issue
dasanra Nov 23, 2023
07514e5
fix wording recommendations
dasanra Nov 23, 2023
0886e80
highlight ethers.js v6
dasanra Nov 23, 2023
e5dc463
add migration guides highlighting the major changes
dasanra Nov 23, 2023
de1f687
fix typos
dasanra Nov 23, 2023
4505482
Apply suggestions from code review
dasanra Nov 24, 2023
f0c8c2a
add backticks to EthersAdapter
dasanra Nov 24, 2023
11a4f5c
Apply suggestions from code review
dasanra Nov 24, 2023
912e7bb
set migrating guides below reference
dasanra Nov 24, 2023
e153325
add wording suggestions
dasanra Nov 24, 2023
ded1c68
Add safe-transaction-service migration guide
dasanra Nov 24, 2023
969fb47
Add migration guide from legacy safe-core-sdk
dasanra Nov 24, 2023
73b2693
Add types changes
dasanra Nov 28, 2023
601e3ac
Merge branch 'main' into add-missing-resources
dasanra Nov 28, 2023
09a86b6
remove auth-kit changes
dasanra Nov 28, 2023
af6d717
fix linting issues
dasanra Nov 28, 2023
29d4970
improve api-kit v2 migration
dasanra Nov 28, 2023
3012b3a
Add latest changes
dasanra Nov 29, 2023
c189a74
Add missing type
dasanra Nov 29, 2023
3e4abbe
fix typo
dasanra Nov 29, 2023
65a244f
Apply suggestions from code review
dasanra Nov 29, 2023
7bcdec4
add migration links
dasanra Nov 29, 2023
74d0a40
Update safe-core-sdk/protocol-kit/reference/migrating/v1.md
dasanra Nov 29, 2023
8190b5a
Reverse migration links order in SUMMARY
dasanra Nov 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
* [Protocol Kit](safe-core-sdk/protocol-kit/README.md)
* [Reference](safe-core-sdk/protocol-kit/reference/README.md)
* [Migrating to v2](safe-core-sdk/protocol-kit/reference/migrating/v2.md)
* [Migrating to v1](safe-core-sdk/protocol-kit/reference/migrating/v1.md)

* [Onramp Kit](safe-core-sdk/onramp-kit/README.md)
* [Guides](safe-core-sdk/onramp-kit/guides/README.md)
Expand All @@ -54,6 +55,7 @@
* [API Kit](safe-core-sdk/api-kit/README.md)
* [Reference](safe-core-sdk/api-kit/reference/README.md)
* [Migrating to v2](safe-core-sdk/api-kit/reference/migrating/v2.md)
* [Migrating to v1](safe-core-sdk/api-kit/reference/migrating/v1.md)


## Safe{Core} Protocol
Expand Down
114 changes: 114 additions & 0 deletions safe-core-sdk/api-kit/reference/migrating/v1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# API Kit: Migrating from `safe-service-client`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should the title be Migrating to v1 for consistency with the other migration guide?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the other migration guide we set API Kit: Migrating from v1. The Migrating to v2 was set as the Link title in SUMMARY.md.

Should I align the titles or should I leave it like this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think both the link title and the title were the same: https://docs.safe.global/safe-core-aa-sdk/api-kit/reference/v2.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems gitdocs is ignoring the H1 element # in the file and overwritting with what you write in the SUMMARY file

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, I see. Interesting. I am fine if you so it same as you did for the last one by changing it in the Summary file :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, for the visuals in the menu Migrating to v1 feels more correct, I'm just concerned because this migration also involved a package name change:

safe-core-sdk + safe-ethers-lib + safe-web3-lib -> protocol-kit
safe-service-client -> safe-api-kit

We can test this way and re-evaluate if people is having trouble finding it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be added as a page description or somewhere in the text so that it appears when people search from the search bar? 👀

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will think about it


This guide references the major changes between `safe-service-client` and `api-kit` v1 to help those migrating an existing application.

**Note:** Follow this guide before migrating to `api-kit` v2.

After completing this guide, you can remove `@safe-global/safe-service-client` from your package.json`.

## Adding the new dependency

To add the API Kit to your project, run the following:

```bash
yarn add @safe-global/[email protected]
```

Change your initialization like this:

```typescript
// old
import SafeServiceClient from '@safe-global/safe-service-client'
tanay1337 marked this conversation as resolved.
Show resolved Hide resolved

const safeService = new SafeServiceClient({
txServiceUrl: 'https://your-transaction-service-url',
ethAdapter
})

// new
import SafeApiKit from '@safe-global/api-kit'

const apiKit = new SafeApiKit({
txServiceUrl: 'https://your-transaction-service-url',
ethAdapter
})
```

## `getSafeDelegates()`

The `getSafeDelegates` was updated to accept more filtering parameters. Now, it accepts an object with multiple properties instead of only the `safeAddress` parameter.

```typescript
const delegateConfig: GetSafeDelegateProps = {
safeAddress, // Optional
delegateAddress, // Optional
delegatorAddress, // Optional
label, // Optional
limit, // Optional
offset // Optional
}
const delegates: SafeDelegateListResponse = await apiKit.getSafeDelegates(delegateConfig)
```

## `addSafeDelegate()`

Parameter object properties were updated as follows:

```typescript
// old
const delegateConfig: SafeDelegateConfig = {
safe,
delegate,
label,
signer
}
await safeService.addSafeDelegate(delegateConfig)

// new
const delegateConfig: AddSafeDelegateProps = {
safeAddress, // Optional
delegateAddress,
delegatorAddress,
label,
signer
}
await apiKit.addSafeDelegate(delegateConfig)
```

## `removeAllSafeDelegates()`

The method was deprecated and removed.

## `removeSafeDelegate()`

Parameter object properties were updated as follows:

```typescript
// old
const delegateConfig: SafeDelegateDeleteConfig = {
safe,
delegate,
signer
}
await safeService.removeSafeDelegate(delegateConfig)

// new
const delegateConfig: DeleteSafeDelegateProps = {
delegateAddress,
delegatorAddress,
signer
}
await apiKit.removeSafeDelegate(delegateConfig)
```

## `getBalances()`

The method was deprecated and removed.

## `getUSDBalances()`

The method was deprecated and removed.

## `getCollectibles()`

The method was deprecated and removed.
32 changes: 27 additions & 5 deletions safe-core-sdk/api-kit/reference/migrating/v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,26 @@ It won't be necessary to specify a `txServiceUrl` in environments where Safe has

```js
// old:
constructor({ txServiceUrl, ethAdapter }: SafeApiKitConfig)
import SafeApiKit from '@safe-global/api-kit'

const apiKit = new SafeApiKit({
txServiceUrl: 'https://your-transaction-service-url',
ethAdapter
})

// new:
constructor({ chainId, txServiceUrl? }: SafeApiKitConfig)
import SafeApiKit from '@safe-global/api-kit'

const chainId: bigint = 1n
const apiKit = new SafeApiKit({
chainId
})

// or set a custom Transaction Service
const apiKit = new SafeApiKit({
chainId,
txServiceUrl: 'https://your-transaction-service-url'
})
```

## Use the route you prefer
Expand All @@ -23,11 +39,17 @@ Note that if you use a custom service running under `/api`, you will now need to
```js
// old:
const txServiceUrl = 'https://your-transaction-service-domain/'
constructor({ txServiceUrl, ethAdapter }: SafeApiKitConfig)

const apiKit = new SafeApiKit({
txServiceUrl,
ethAdapter
})
// new:
const chainId: bigint = 1n
const txServiceUrl = 'https://your-transaction-service-domain/api'
constructor({ chainId, txServiceUrl? }: SafeApiKitConfig)
const apiKit = new SafeApiKit({
chainId,
txServiceUrl
})
```

## MasterCopy to Singleton
Expand Down
102 changes: 102 additions & 0 deletions safe-core-sdk/protocol-kit/reference/migrating/v1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Protocol Kit: Migrating from `safe-core-sdk`
tanay1337 marked this conversation as resolved.
Show resolved Hide resolved

This guide references the major changes between `safe-core-sdk` and `protocol-kit` v1 to help those migrating an existing application.

**Note:** Follow this guide before migrating to `protocol-kit` v2.

You can remove `@safe-global/safe-core-sdk` from your `package.json` after completing this guide.

## Adding the new dependency

To add the Protocol Kit to your project, run the following:

```bash
yarn add @safe-global/[email protected]
```

If you use the types library, you will need to update to v2.3.0:

```bash
yarn add @safe-global/[email protected]
```

## `EthAdapter`

### `EthersAdapter` (safe-ethers-lib)

`EthersAdapter` isn't in a separate package anymore. Now, it's provided inside the `protocol-kit` package.

**`protocol-kit v1` only supports `ethers v5`**

```typescript
// old
import EthersAdapter from '@safe-global/safe-ethers-lib'

// new
import { EthersAdapter } from '@safe-global/protocol-kit'
```

After this change, you can remove `@safe-global/safe-ethers-lib` from your `package.json`.

### `Web3Adapter` (safe-web3-lib)

`Web3Adapter` isn't in a separate package anymore. Now, it's part of the `protocol-kit` package.

**Note:** `protocol-kit` v1 only supports Web3.js v1.

```typescript
// old
import Web3Adapter from '@safe-global/safe-web3-lib'

// new
import { Web3Adapter } from '@safe-global/protocol-kit'
```

After this change, you can remove `@safe-global/safe-web3-lib` from your `package.json`.

### Type changes

Type changes are affecting the web3 and ethers adapter libraries.

`getSafeContract`, `getMultisendContract`, `getMultisendCallOnlyContract`, `getCompatibilityFallbackHandlerContract`, `getSafeProxyFactoryContract`, `getSignMessageLibContract` and `getCreateCallContract` don't need the `chainId` parameter anymore, they will use the chain set on the provider. Also, they return a `Promise` now.

`estimateGas` now returns a `string` instead of a `number`.

## `safeFactory.deploySafe()`

`SafeDeploymentConfig` was simplified. If you were using a `saltNonce` you should set it like this:

```typescript
// old
const safeAccountConfig: SafeAccountConfig = {
...
}
const safeDeploymentConfig: SafeDeploymentConfig = { saltNonce }

const safeSdk = await safeFactory.deploySafe({ safeAccountConfig, safeDeploymentConfig })

// new
const safeAccountConfig: SafeAccountConfig = {
...
}

const saltNonce = '<YOUR_CUSTOM_VALUE>'

const safeSdk = await safeFactory.deploySafe({ safeAccountConfig, saltNonce })
```

## `getAddress()`

The `getAddress()` method now returns a `Promise`.

```typescript
// old
const safeAddress = safeSdk.getAddress()

// new
const safeAddress = await protocolKit.getAddress()
```

## General type changes

If you set `safeTxGas`, `baseGas`, or `gasPrice`, you must use the type `string` instead of `number`.
2 changes: 2 additions & 0 deletions safe-core-sdk/protocol-kit/reference/migrating/v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

This guide references the major changes between v1 and v2 to help those migrating an existing app.

**Note:** When upgrading to `protocol-kit` v2, it's necessary to upgrade to `safe-core-sdk-types` v3.

## MasterCopy to Singleton

To avoid confusion between terms used as synonyms, we aligned all our code to use the word `singleton`.
Expand Down
Loading