Skip to content

Commit 870e235

Browse files
cursoragentfirekeeper
andcommitted
Add support check for createSessionKey method in ERC7702 extension
Co-authored-by: firekeeper <[email protected]>
1 parent 2d90dd4 commit 870e235

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

packages/thirdweb/src/extensions/erc7702/account/createSessionKey.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import type { ThirdwebClient } from "../../../client/client.js";
33
import { getContract } from "../../../contract/contract.js";
44
import { randomBytesHex } from "../../../utils/random.js";
55
import type { Account } from "../../../wallets/interfaces/wallet.js";
6-
import { createSessionWithSig } from "../__generated__/MinimalAccount/write/createSessionWithSig.js";
6+
import {
7+
createSessionWithSig,
8+
isCreateSessionWithSigSupported,
9+
} from "../__generated__/MinimalAccount/write/createSessionWithSig.js";
710
import { MINIMAL_ACCOUNT_ABI } from "../__generated__/MinimalAccount/abi.js";
811
import { type CallSpecInput, type TransferSpecInput } from "./types.js";
912

@@ -107,3 +110,19 @@ export function createSessionKey(options: CreateSessionKeyOptions) {
107110
signature: "0x",
108111
});
109112
}
113+
114+
/**
115+
* Checks if the `createSessionKey` method is supported by the given contract.
116+
* @param availableSelectors An array of 4byte function selectors of the contract. You can get this in various ways, such as using "whatsabi" or if you have the ABI of the contract available you can use it to generate the selectors.
117+
* @returns A boolean indicating if the `createSessionKey` method is supported.
118+
* @extension ERC7702
119+
* @example
120+
* ```ts
121+
* import { isCreateSessionKeySupported } from "thirdweb/extensions/erc7702/account";
122+
*
123+
* const supported = isCreateSessionKeySupported(["0x..."]);
124+
* ```
125+
*/
126+
export function isCreateSessionKeySupported(availableSelectors: string[]) {
127+
return isCreateSessionWithSigSupported(availableSelectors);
128+
}

0 commit comments

Comments
 (0)