core
and metadata
parameters.
_walletKit.registerAccount()
for accounts you want events and methods to be enabled on. This is essential if you want to properly form a session object between your wallet and the requester dapp._walletKit.registerRequestHandler()
for methods you want to support on your wallet. Optional but highly recommended if you want to seamlessly create a session object, as we will see in the coming section._walletKit.registerEventEmitter()
for events you want to support on your wallet. Optional but recommended if you plan to send events such as chainChanged
and accountsChanged
.onSessionProposal
event by querying event.params.generatedNamespaces
. (See Session Approval below)
registerRequestHandler
to configure your supported methods and rather define them during session approval (See Session Approval below)By not using registerRequestHandler
your methods requests are going to be sent through onSessionRequest
event subscription.If you do choose to use registerRequestHandler
(highly recommended) then onSessionRequest
event subscription is not going to be called.MethodsConstants
and EventsConstants
for already defined set of required and optional values.
SessionProposalEvent
is emitted when a dapp initiates a new session with your wallet. The event object will include the information about the dapp and requested namespaces. The wallet should display a prompt for the user to approve or reject the session.
To approve a session, subscribe to onSessionProposal
event and call approveSession()
passing in the event.id
and the namespaces object.
namespaces:
should be either event.params.generatedNamespaces!
if you decided to use registerRequestHandler
method to configure your supported methods or a Map<String, Namespace>
object defined by yourself if you decided not to use registerRequestHandler
methodpair
method initiates a pairing process with a dapp using the given uri
(QR code from the dapps). To learn more about pairing, checkout out the docs.
Scan the QR code and parse the URI, and pair with the dapp.onSessionProposal
and onAuthRequest
events.
personal_sign
, you have two ways as explained before, and they are mutually exclusive, so, either you use onSessionRequest event subscription or your methods handlers configured with registerRequestHandler
.
eip155:1
and eip155:137
. This would translate to:onSessionRequest
events (if you didn’t use generatedNamespaces
object) and handle the request based on the method that is firing the event.onSessionRequest
event.updateSession
allows you to do so.
You need pass in the topic
and a new Namespaces
object that contains all of the existing namespaces as well as the new data you wish to include.
After you update the session, the dapp connected to your wallet will receive a SessionUpdate
event.
extendSession
method and pass in the new topic
. The SessionUpdate
event will be emitted from the wallet.
disconnectSession
method and pass in the topic
and a reason
.
When either the dapp or the wallet disconnects from a session, a SessionDelete
event will be emitted. It’s important to subscribe to this event so you could keep your state up-to-date.
disconnectSession()
alone will make the pairing topic persist, i.e, it can be re-used until it expires. If you want to disconnect (remove) the pairing topic as well you would have add another call as follows:
chainChanged
or accountChanged
, you would have to register an event emitter for such events, for every chain you want to emit an event for (similar to request handlers).
emitSessionEvent()
as follows: