ModuleSDK
Modules
getEnableSessionDetails

getEnableSessionDetails

This method is used to get the details for a new session to enable through the enable flow. It abstracts away the different steps required and makes to easier when wanting to enable a new session without custom logic.

Usage

const session: Session = {
  ..., // Session details
}
 
const sessionDetails = await getEnableSessionDetails({
  sessions: [session],
  account,
  clients: [publicClient],
})
 
sessionDetails.enableSessionData.enableSession.permissionEnableSig = await signer.signMessage({
  message: { raw: sessionDetails.permissionEnableHash },
})
 
 
sessionDetails.signature = await signer.signMessage({
  message: { raw: userOpHash },
})
 
const userOpSignature = encodeSmartSessionSignature(sessionDetails)

Parameters

sessions

An array of sessions to enable. Note that these can be on multiple chains. A user will sign over this array once and when enabling the session on each chain, the index pointing to the right session to enable out of this array will be provided.

account

The account to enable the session for.

clients

  • Type: PublicClient[]

The public clients to use to interact with the smart sessions validator. Note that one client needs to be provided for each chain on which a session is enabled.

sessionIndex (optional)

  • Type number

When enabling more than one session and the session to enable on this particular chain is not the first item in the array (index 0), then this is used to provide the index of the session to enable.

Returns

enableSessionData.permissionEnableHash

The hash to sign with a validator on the account in order to enable the session.

enableSessionData.mode

The mode of the smart session, in this case Enable.

enableSessionData.permissionId

The permission ID of the session to enable.

enableSessionData.signature

The signature to use the session, made with the session key over the UserOpHash. Note that this will be empty and needs to be set.

enableSessionData.enableSessionData.enableSession.chainDigestIndex

  • Type: number

The index of the chain digest to use for the session.

enableSessionData.enableSessionData.enableSession.hashesAndChainIds

The chain digests to use for the session.

enableSessionData.enableSessionData.enableSession.sessionToEnable

The session to enable in this specific UserOperation.

enableSessionData.enableSessionData.enableSession.permissionEnableSig

The signature to enable the session, validated by the validator provided. Note that this field is empty and needs to be set.

enableSessionData.enableSessionData.validator

The address of the validator to use for the session. This is used to verify the permissionEnableSig.

enableSessionData.enableSessionData.accountType

The type of the account to enable the session for. This is required since accounts format the signature differently.