Migrate to v1
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:
_10yarn add @safe-global/protocol-kit@1.3.0
If you use the types library, you will need to update to v2.3.0:
_10yarn add @safe-global/safe-core-sdk-types@2.3.0
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
_10// old_10import EthersAdapter from '@safe-global/safe-ethers-lib'_10_10// new_10import { 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.
_10// old_10import Web3Adapter from '@safe-global/safe-web3-lib'_10_10// new_10import { 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:
_16// old_16const safeAccountConfig: SafeAccountConfig = {_16 ..._16}_16const safeDeploymentConfig: SafeDeploymentConfig = { saltNonce }_16_16const safeSdk = await safeFactory.deploySafe({ safeAccountConfig, safeDeploymentConfig })_16_16// new_16const safeAccountConfig: SafeAccountConfig = {_16 ..._16}_16_16const saltNonce = '<YOUR_CUSTOM_VALUE>'_16_16const protocolKit = await safeFactory.deploySafe({ safeAccountConfig, saltNonce })
getAddress()
The getAddress() method now returns a Promise.
_10// old_10const safeAddress = safeSdk.getAddress()_10_10// new_10const safeAddress = await protocolKit.getAddress()
General type changes
If you set safeTxGas, baseGas, or gasPrice, you must use the type string instead of number.