Migrate to v2
This guide references the major changes between v1 and v2 to help those migrating an existing app.
API Kit constructor
It won't be necessary to specify a txServiceUrl
in environments where Safe has a Transaction Service running. Providing the chain ID will be enough. If you want to use your custom service or the kit in a chain not supported by a Safe Transaction Service, you can add the txServiceUrl
parameter.
_21// old:_21import SafeApiKit from '@safe-global/api-kit'_21_21const apiKit = new SafeApiKit({_21 txServiceUrl: 'https://your-transaction-service-url',_21 ethAdapter_21})_21_21// new:_21import SafeApiKit from '@safe-global/api-kit'_21_21const chainId: bigint = 1n_21const apiKit = new SafeApiKit({_21 chainId_21})_21_21// or set a custom Transaction Service_21const apiKit = new SafeApiKit({_21 chainId,_21 txServiceUrl: 'https://your-transaction-service-url'_21})
Use the route you prefer
API Kit v1 forced any custom service to be hosted under the /api
route of the URL specified in txServiceUrl
. This isn't the case anymore; you can specify any preferred route or subdomain.
Note that if you use a custom service running under /api
, you will now need to migrate as follows:
_13// old:_13const txServiceUrl = 'https://your-transaction-service-domain/'_13const apiKit = new SafeApiKit({_13 txServiceUrl,_13 ethAdapter_13})_13// new:_13const chainId: bigint = 1n_13const txServiceUrl = 'https://your-transaction-service-domain/api'_13const apiKit = new SafeApiKit({_13 chainId,_13 txServiceUrl_13})
MasterCopy to Singleton
To avoid confusion between terms used as synonyms, we aligned all our code to use the word singleton
.
- Rename type
MasterCopyResponse
toSafeSingletonResponse
- Rename method
getServiceMasterCopiesInfo()
togetServiceSingletonsInfo()