Skip to content

Commit

Permalink
feat: add JsonRpcSigner type
Browse files Browse the repository at this point in the history
  • Loading branch information
VGabriel45 committed Dec 27, 2024
1 parent 2d9d35b commit e89dd07
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/sdk/account/utils/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,14 @@ type EthersWalletSigner = {
signMessage: (...args: AnyData) => AnyData
signTypedData: (...args: AnyData) => AnyData
getAddress: () => Promise<AnyData>
address: Address | string
provider: unknown
}

type JsonRpcSigner = {
signTransaction: (...args: AnyData) => AnyData
signMessage: (...args: AnyData) => AnyData
_signTypedData: (...args: AnyData) => AnyData
getAddress: () => Promise<AnyData>
provider: unknown
}

Expand All @@ -429,3 +436,4 @@ export type ValidSigner =
| LocalAccountSigner
| WalletClientSigner
| ProviderSigner
| JsonRpcSigner
7 changes: 7 additions & 0 deletions src/sdk/account/utils/toSigner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ export async function toSigner({
throw new Error("Not supported")
},
async signTypedData(typedData) {
if ("_signTypedData" in wallet) {
return wallet._signTypedData(
typedData.domain,
typedData.types,
typedData.message
)
}
return wallet.signTypedData(
typedData.domain,
typedData.types,
Expand Down

0 comments on commit e89dd07

Please sign in to comment.