Skip to content

Commit

Permalink
fix: make get typed data signature function public
Browse files Browse the repository at this point in the history
  • Loading branch information
hwildwood committed May 31, 2024
1 parent 9537cb6 commit a5496a8
Showing 1 changed file with 29 additions and 32 deletions.
61 changes: 29 additions & 32 deletions src/sessionDappService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export class SessionDappService {
} else {
throw Error("unsupported signTransaction version")
}
return this.compileSessionSignature(
return this.getSessionSignatureForTransaction(
sessionAuthorizationSignature,
sessionRequest,
txHash,
Expand All @@ -154,7 +154,7 @@ export class SessionDappService {
)
}

private async compileSessionSignature(
public async getSessionSignatureForTransaction(
sessionAuthorizationSignature: ArraySignatureType,
sessionRequest: OffChainSession,
transactionHash: string,
Expand Down Expand Up @@ -376,20 +376,16 @@ export class SessionDappService {
this.chainId,
)

const messageHash = typedData.getMessageHash(
outsideExecutionTypedData,
accountAddress,
)

const signature = await this.compileSessionSignatureFromOutside(
sessionAuthorizationSignature,
sessionRequest,
messageHash,
calls,
accountAddress,
outsideExecutionTypedData,
cacheAuthorisation,
)
const signature =
await this.getSessionSignatureForOutsideExecutionTypedData(
sessionAuthorizationSignature,
sessionRequest,
messageHash,
calls,
accountAddress,
outsideExecutionTypedData,
cacheAuthorisation,
)

return {
contractAddress: accountAddress,
Expand All @@ -398,17 +394,22 @@ export class SessionDappService {
}
}

private async compileSessionSignatureFromOutside(
public async getSessionSignatureForOutsideExecutionTypedData(
sessionAuthorizationSignature: ArraySignatureType,
sessionRequest: OffChainSession,
messageHash: string,
calls: Call[],
accountAddress: string,
outsideExecutionTypedData: TypedData,
cacheAuthorisation: boolean,
): Promise<ArraySignatureType> {
const session = this.compileSessionHelper(sessionRequest)
const sessionTypedData = getSessionTypedData(sessionRequest, this.chainId)

const messageHash = typedData.getMessageHash(
outsideExecutionTypedData,
accountAddress,
)

const sessionSignature = await this.signTxAndSession(
messageHash,
accountAddress,
Expand Down Expand Up @@ -458,20 +459,16 @@ export class SessionDappService {
nonce,
)

const messageHash = typedData.getMessageHash(
currentTypedData,
accountAddress,
)

const signature = await this.compileSessionSignatureFromOutside(
sessionAuthorizationSignature,
sessionRequest,
messageHash,
calls,
accountAddress,
currentTypedData,
cacheAuthorisation,
)
const signature =
await this.getSessionSignatureForOutsideExecutionTypedData(
sessionAuthorizationSignature,
sessionRequest,
messageHash,
calls,
accountAddress,
currentTypedData,
cacheAuthorisation,
)

return {
outsideExecutionTypedData: currentTypedData,
Expand Down

0 comments on commit a5496a8

Please sign in to comment.