Migrate to v4
This guide references the major changes between v3 and v4 to help those migrating an existing app.
Note: When upgrading to protocol-kit
v4, it's necessary to upgrade to types-kit
v1.
The create() method was renamed init() in the SafeFactory and Safe classes
We renamed the create()
method to init()
to better reflect the method's purpose. The term create()
was misleading, suggesting a new Safe account would be created and deployed. However, this method only initializes the Safe
class, so init()
is a more accurate and descriptive name.
_10// old_10const protocolKit = await Safe.create({ ... })_10const safeFactory = await SafeFactory.create({ ... })_10_10// new_10const protocolKit = await Safe.init({ ... })_10const safeFactory = await SafeFactory.init({ ... })
Remove the adapters
We have removed the concept of adapters from the protocol-kit
to simplify the library. Instead of using specific library adapters, we use now an internal SafeProvider
object to interact with the Safe. This SafeProvider
will be created using:
- An Ethereum provider, an EIP-1193 (opens in a new tab) compatible provider, or an RPC URL.
- An optional address of the signer that is connected to the provider or a private key. If not provided, the first account of the provider (
eth_accounts
) will be selected as the signer.
The EthAdapter
interface, the EthersAdapter
class, and the Web3Adapter
class are no longer available. Similarly, EthersAdapterConfig
and Web3AdapterConfig
were removed as well.
_24// old_24const ethAdapter = new EthersAdapter({ ethers, signerOrProvider })_24// const ethAdapter = new Web3Adapter({ web3, signerAddress })_24await Safe.create({_24 ethAdapter,_24 safeAddress: '0xSafeAddress'_24 ..._24})_24_24// new_24await Safe.init({_24 provider: window.ethereum, // Or any compatible EIP-1193 provider_24 signer: '0xSignerAddressOrPrivateKey', // Signer address or private key_24 safeAddress: '0xSafeAddress'_24 ..._24})_24_24// ...or..._24await Safe.init({_24 provider: 'http://rpc.url', // Or websocket_24 signer: '0xPrivateKey' // Signer private key_24 safeAddress: '0xSafeAddress'_24 ..._24})
EthersTransactionOptions
and Web3TransactionOptions
types are now TransactionOptions
Together with the adapters, we also removed the specific transaction options objects for each library, leaving just a single TransactionOptions
type.
We removed the gas
property from the TransactionOptions
object as it was a specific property for the web3.js library. Now, you should use the gasLimit
property instead.
EthersTransactionResult
and Web3TransactionResult
types are now TransactionResult
Together with the adapters, we also removed the specific transaction result objects for each library, leaving just a single TransactionResult
type.
Contract classes suffixed with Ethers and Web3
All the contract classes that were suffixed with Ethers
or Web3
were renamed to remove the suffix.
_10SafeBaseContractEthers, SafeBaseContractWeb3 -> SafeBaseContract_10MultiSendBaseContractEthers, MultiSendBaseContractWeb3 -> MultiSendBaseContract_10MultiSendCallOnlyBaseContractEthers, MultiSendCallOnlyBaseContractWeb3 -> MultiSendCallOnlyBaseContract_10SafeProxyFactoryBaseContractEthers, SafeProxyFactoryBaseContractWeb3 -> SafeProxyFactoryBaseContract_10SignMessageLibBaseContractEthers, SignMessageLibBaseContractWeb3 -> SignMessageLibBaseContract_10CreateCallBaseContractEthers, CreateCallBaseContractWeb3 -> CreateCallBaseContract