Skip to content

Conversation

VGabriel45
Copy link
Contributor

This PR introduces the following changes:

  • refactor "permissions" to refer to Session Permissions
  • refactor "session" to refer to Session (implicit or explicit)
  • refactor "explicitSession" to refer to explicit session
  • improved RequestActionType types to cover more explicit scenarios
  • added "getAllImplicitSessions()" and getAllExplicitSessions()"
  • refactor "permissions" type in wallet/primitives SessionPermissions to be Permission[], [Permission, Permission[]] was causing too many type issues on client side and required to be casted

@@ -99,7 +114,7 @@ export interface SessionsInterface {
addExplicitSession(
walletAddress: Address.Address,
sessionAddress: Address.Address,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sessionAddress is an argument for addExplicitSession but its also a property of the explicitSession.

@@ -121,7 +136,7 @@ export interface SessionsInterface {
modifyExplicitSession(
walletAddress: Address.Address,
sessionAddress: Address.Address,
Copy link
Contributor

@corbanbrook corbanbrook Sep 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sessionAddress is an argument for addExplicitSession but its also a property of the explicitSession.

@@ -327,12 +342,12 @@ export class Sessions implements SessionsInterface {
async addExplicitSession(
walletAddress: Address.Address,
sessionAddress: Address.Address,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sessionAddress is an argument for addExplicitSession but its also a property of the explicitSession.

@@ -341,7 +356,7 @@ export class Sessions implements SessionsInterface {
async modifyExplicitSession(
walletAddress: Address.Address,
sessionAddress: Address.Address,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sessionAddress is an argument for addExplicitSession but its also a property of the explicitSession.

@@ -25,7 +25,7 @@ export type SessionPermissions = {
chainId: number
valueLimit: bigint
deadline: bigint // uint64
permissions: [Permission, ...Permission[]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This typing [Permission, ...Permission[]] is cute typing trick that uses a tuple type to specify that there must be at least 1 permission given in the array. where as Permission[] allows an empty array. Was this change intended?

action: (typeof RequestActionType)['ADD_EXPLICIT_SESSION' | 'MODIFY_EXPLICIT_SESSION']
response?: AddExplicitSessionSuccessResponsePayload | ModifySessionSuccessResponsePayload
error?: any
export type DappClientExplicitSessionEventListener = ExplicitSessionEventListener & {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is strange to me ... we are tagging the event listener with a chain id?

permissions: Permission.Permission[]
}

export type ImplicitSession = Omit<Session, 'isImplicit'>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im not sure why the ImplicitSession type is omitting isImplicit. It might be better to use a discriminating type union here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specifically if you had something like:

type Session = ImplicitSession | ExplicitSession

interface ImplicitSession  {
  type: 'implicit',
  ...
}

interface ExplicitSession  {
  type: 'explicit',
   ...
}

These could extend a base interface with common properties.

Copy link
Contributor

@corbanbrook corbanbrook left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good. just a couple questions about the Session, ExplicitSession, ImplicitSession typings. and a couple other small things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants