-
Notifications
You must be signed in to change notification settings - Fork 76
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
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
2f9a285
update ethers docs
DaniSomoza a120bcb
Merge branch 'main' into ethers-v6-migration-docs
DaniSomoza 0616a40
Merge branch 'main' into ethers-v6-migration-docs
dasanra 53646d2
add singleton change to api-kit and protocol-kit
dasanra 17cbde5
Fix linting and typos
dasanra 4657adf
fix: broken links
dasanra 25b524c
update GelatoRelayKit breaking changes
dasanra cacf112
Merge branch 'main' into ethers-v6-migration-docs
dasanra a56bc1a
improve parameter naming
dasanra 43e8a61
fix linter reported issue
dasanra 07514e5
fix wording recommendations
dasanra 0886e80
highlight ethers.js v6
dasanra e5dc463
add migration guides highlighting the major changes
dasanra de1f687
fix typos
dasanra 4505482
Apply suggestions from code review
dasanra f0c8c2a
add backticks to EthersAdapter
dasanra 11a4f5c
Apply suggestions from code review
dasanra 912e7bb
set migrating guides below reference
dasanra e153325
add wording suggestions
dasanra ded1c68
Add safe-transaction-service migration guide
dasanra 969fb47
Add migration guide from legacy safe-core-sdk
dasanra 73b2693
Add types changes
dasanra 601e3ac
Merge branch 'main' into add-missing-resources
dasanra 09a86b6
remove auth-kit changes
dasanra af6d717
fix linting issues
dasanra 29d4970
improve api-kit v2 migration
dasanra 3012b3a
Add latest changes
dasanra c189a74
Add missing type
dasanra 3e4abbe
fix typo
dasanra 65a244f
Apply suggestions from code review
dasanra 7bcdec4
add migration links
dasanra 74d0a40
Update safe-core-sdk/protocol-kit/reference/migrating/v1.md
dasanra 8190b5a
Reverse migration links order in SUMMARY
dasanra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
# API Kit: Migrating from `safe-service-client` | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Should the title be
Migrating to v1
for consistency with the other migration guide?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.
In the other migration guide we set
API Kit: Migrating from v1
. TheMigrating to v2
was set as the Link title in SUMMARY.md.Should I align the titles or should I leave it like this?
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.
I think both the link title and the title were the same: https://docs.safe.global/safe-core-aa-sdk/api-kit/reference/v2.
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.
It seems gitdocs is ignoring the H1 element
#
in the file and overwritting with what you write in the SUMMARY fileThere 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.
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 :)
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.
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.
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.
Should this be added as a page description or somewhere in the text so that it appears when people search from the search bar? 👀
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.
Will think about it