Skip to content

Commit

Permalink
Merge pull request #16 from argentlabs/expose-sign-typed-data
Browse files Browse the repository at this point in the history
fix: make get typed data signature function public
  • Loading branch information
hwildwood authored May 31, 2024
2 parents 9537cb6 + a5496a8 commit aecc281
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,

Check failure on line 383 in src/sessionDappService.ts

View workflow job for this annotation

GitHub Actions / release

src/__tests__/sessionDappService.test.ts > SessionDappService > should get an outside execution call with getOutsideExecutionCall

ReferenceError: messageHash is not defined ❯ SessionDappService.getOutsideExecutionCall src/sessionDappService.ts:383:9 ❯ src/__tests__/sessionDappService.test.ts:135:32
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,

Check failure on line 466 in src/sessionDappService.ts

View workflow job for this annotation

GitHub Actions / release

src/__tests__/sessionDappService.test.ts > SessionDappService > should get an outside execution call with getOutsideExecutionTypedData

ReferenceError: messageHash is not defined ❯ SessionDappService.getOutsideExecutionTypedData src/sessionDappService.ts:466:9 ❯ src/__tests__/sessionDappService.test.ts:177:32
calls,
accountAddress,
currentTypedData,
cacheAuthorisation,
)

return {
outsideExecutionTypedData: currentTypedData,
Expand Down

0 comments on commit aecc281

Please sign in to comment.