To be used as part of the Auth Kit, new packs need to extend the AuthKitBasePack
class. This abstract class provides a common interface that subclasses must implement. It provides the specific Safe common functionality that any custom implementation can take leverage.
To use the AuthKitBasePack
, you need to install the @safe-global/auth-kit
package.
yarn add @safe-global/auth-kit
This class is used to create new packs. Any new pack should extend this class and implement the abstract methods. Extending from the AuthKitBasePack
class will give the subclass access to the common Safe features like retrieving the associated Safes for a given Ethereum address.
class MyPack extends AuthKitBasePack {
// Implementation of the abstract methods
}
These methods are the common interface for all the Auth packs. Check each pack's documentation to get more details.
Provides the initialization options for the required packages, classes and properties.
Provides a mechanism to connect to the provider services and returns an Ethereum address that will be used as a signer along with the associated Safe addresses.
Disconnects the provider services and cleans up any data related to the current user.
Returns a Web3 provider that can be used to interact with the blockchain (web3.js
or ethers.js
for example).
Returns the user information as a JSON object.
Provides a way to subscribe to events
Provides a way to unsubscribe from an event.
These methods provide the functionality associated with Safe so they can be used in the implementation of the packs.
Returns the Ethereum address extracted from the provider retrieved by getProvider()
. This returns a Safe owner (signer).
Returns
address
: The Ethereum address extracted from the provider.
Returns the list of Safes associated with the signer address by calling the getAddress()
method internally.
Params
txServiceUrl
: The Safe Transaction Service url to retrieve the Safes associated with the owner (signer).
Returns
safes[]
: The list of Safes associated with the owner (signer).