diff --git a/account-kit/rn-signer/android/src/main/java/com/accountkit/reactnativesigner/core/TEKStamper.kt b/account-kit/rn-signer/android/src/main/java/com/accountkit/reactnativesigner/core/TEKStamper.kt index 1a7847308c..49b284ae3f 100644 --- a/account-kit/rn-signer/android/src/main/java/com/accountkit/reactnativesigner/core/TEKStamper.kt +++ b/account-kit/rn-signer/android/src/main/java/com/accountkit/reactnativesigner/core/TEKStamper.kt @@ -1,6 +1,7 @@ package com.accountkit.reactnativesigner.core import android.content.Context +import android.content.SharedPreferences import androidx.security.crypto.EncryptedSharedPreferences import androidx.security.crypto.MasterKey import com.accountkit.reactnativesigner.core.errors.NoInjectedBundleException @@ -19,6 +20,8 @@ import java.nio.ByteBuffer import java.security.KeyFactory import java.security.Security import java.security.Signature +import java.security.KeyStore +import java.security.KeyStoreException @Serializable data class ApiStamp(val publicKey: String, val scheme: String, val signature: String) @@ -27,6 +30,8 @@ data class Stamp(val stampHeaderName: String, val stampHeaderValue: String) private const val BUNDLE_PRIVATE_KEY = "BUNDLE_PRIVATE_KEY" private const val BUNDLE_PUBLIC_KEY = "BUNDLE_PUBLIC_KEY" +private const val MASTER_KEY_ALIAS = "tek_master_key" +private const val ENCRYPTED_SHARED_PREFERENCES_FILENAME = "tek_stamper_shared_prefs" class TEKStamper(context: Context) { // This is how the docs for EncryptedSharedPreferences recommend creating this setup @@ -36,12 +41,6 @@ class TEKStamper(context: Context) { // // we should explore the best practices on how to do this once we reach a phase of further // cleanup - private val masterKey = - MasterKey.Builder(context.applicationContext) - .setKeyScheme(MasterKey.KeyScheme.AES256_GCM) - // requires that the phone be unlocked - .setUserAuthenticationRequired(false) - .build() /** * We are using EncryptedSharedPreferences to store 2 pieces of data @@ -64,29 +63,35 @@ class TEKStamper(context: Context) { * * The open question is if the storage of the decrypted private key is secure enough though */ - private val sharedPreferences = - EncryptedSharedPreferences.create( - context, - "tek_stamper_shared_prefs", - masterKey, - EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV, - EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM - ) + - private val tekManager = HpkeTEKManager(sharedPreferences) - init { - TinkConfig.register() + + - if (Security.getProvider(BouncyCastleProvider.PROVIDER_NAME).javaClass != - BouncyCastleProvider::class.java - ) { - Security.removeProvider(BouncyCastleProvider.PROVIDER_NAME) - } - - if (Security.getProvider(BouncyCastleProvider.PROVIDER_NAME) == null) { - Security.addProvider(BouncyCastleProvider()) + private lateinit var tekManager: HpkeTEKManager + private lateinit var sharedPreferences: SharedPreferences + + init { + try { + TinkConfig.register() + + sharedPreferences = getSharedPreferences(context) + tekManager = HpkeTEKManager(sharedPreferences) + + if (Security.getProvider(BouncyCastleProvider.PROVIDER_NAME).javaClass != + BouncyCastleProvider::class.java + ) { + Security.removeProvider(BouncyCastleProvider.PROVIDER_NAME) + } + + if (Security.getProvider(BouncyCastleProvider.PROVIDER_NAME) == null) { + Security.addProvider(BouncyCastleProvider()) + } + } catch (e: Exception){ + throw RuntimeException("Error creating master key", e) } + } fun init(): String { @@ -196,4 +201,58 @@ class TEKStamper(context: Context) { ) return Pair(compressedPublicKey, privateKey) } + + private fun createSharedPreferences(masterKey: MasterKey, context: Context): SharedPreferences { + return EncryptedSharedPreferences.create( + context, + ENCRYPTED_SHARED_PREFERENCES_FILENAME, + masterKey, + EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV, + EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM + ) + } + + private fun createMasterKey(context: Context): MasterKey { + return MasterKey.Builder(context.applicationContext, MASTER_KEY_ALIAS) + .setKeyScheme(MasterKey.KeyScheme.AES256_GCM) + .setUserAuthenticationRequired(false) + .build() + } + + + private fun getSharedPreferences(context: Context): SharedPreferences { + try { + // Attempt to create or load the EncryptedSharedPreferences file + val masterKey = createMasterKey(context) + + return createSharedPreferences(masterKey, context) + } catch(e: Exception) { + // Log the Exception + e.printStackTrace() + } + + // An error occured creating or retrieving the Shared Preferences file. + // Delete the existing master key and EncryptedSharedPreferences + + // first delete the MasterKey + try { + val keyStore = KeyStore.getInstance("AndroidKeyStore") + keyStore.load(null) + keyStore.deleteEntry(MASTER_KEY_ALIAS) + } catch (keyStoreDeletionException: Exception) { + throw RuntimeException("An error occured deleting the Master Key", keyStoreDeletionException) + } + + // attempt to recreate a new EncryptedSharedPreferences file + try { + // Create a new MasterKey + val newMasterKey = createMasterKey(context) + context.getSharedPreferences(ENCRYPTED_SHARED_PREFERENCES_FILENAME, Context.MODE_PRIVATE).edit().clear().apply() + context.deleteSharedPreferences(ENCRYPTED_SHARED_PREFERENCES_FILENAME) + + return createSharedPreferences(newMasterKey, context) + } catch(retryException: Exception) { + throw RuntimeException("Couldn't create the required shared preferences file. Ensure you are properly authenticated on this device.", retryException) + } + } } \ No newline at end of file diff --git a/account-kit/rn-signer/example/metro.config.js b/account-kit/rn-signer/example/metro.config.js index 00bc69a4ea..ead41fe3b5 100644 --- a/account-kit/rn-signer/example/metro.config.js +++ b/account-kit/rn-signer/example/metro.config.js @@ -3,20 +3,46 @@ const { getDefaultConfig } = require("@react-native/metro-config"); const { getConfig } = require("react-native-builder-bob/metro-config"); const pkg = require("../package.json"); -const root = path.resolve(__dirname, ".."); +const rnSignerRoot = path.resolve(__dirname, ".."); +const projectRoot = __dirname; // handles the hoisted modules const repoRoot = path.resolve(__dirname, "../../.."); +const config = getDefaultConfig(projectRoot); + +const monorepoPackages = { + "@account-kit/signer": path.resolve(repoRoot, "account-kit/signer"), + "@aa-sdk/core": path.resolve(repoRoot, "aa-sdk/core"), + "@account-kit/logging": path.resolve(repoRoot, "account-kit/logging"), +}; + +config.watchFolders = [ + projectRoot, + rnSignerRoot, + ...Object.values(monorepoPackages), +]; + +// Let Metro know where to resolve packages and in what order +config.resolver.nodeModulesPaths = [ + path.resolve(projectRoot, "node_modules"), + path.resolve(rnSignerRoot, "node_modules"), + path.resolve(repoRoot, "node_modules"), +]; + +// Force Metro to resolve (sub)dependencies only from the `nodeModulesPaths` +config.resolver.disableHierarchicalLookup = true; + +config.resolver.extraNodeModules = { + ...config.resolver.extraNodeModules, + ...require("node-libs-react-native"), + ...monorepoPackages, + crypto: require.resolve("crypto-browserify"), + stream: require.resolve("stream-browserify"), +}; + /** * Metro configuration * https://facebook.github.io/metro/docs/configuration * */ -module.exports = { - ...getConfig(getDefaultConfig(__dirname), { - root, - pkg, - project: __dirname, - }), - watchFolders: [root, repoRoot], -}; +module.exports = config; diff --git a/site/pages/reference/account-kit/smart-contracts/functions/createSMAV2Account.mdx b/site/pages/reference/account-kit/smart-contracts/functions/createSMAV2Account.mdx new file mode 100644 index 0000000000..d789f0559b --- /dev/null +++ b/site/pages/reference/account-kit/smart-contracts/functions/createSMAV2Account.mdx @@ -0,0 +1,28 @@ +--- +# This file is autogenerated +title: createSMAV2Account +description: Overview of the createSMAV2Account method +--- + +# createSMAV2Account + +Creates an SMAV2 account using defined parameters including chain, signer, salt, factory address, and more. +Handles account initialization code, nonce generation, transaction encoding, and more to construct a modular account with optional validation hooks. + +## Import + +```ts +import { createSMAV2Account } from "@account-kit/smart-contracts"; +``` + +## Parameters + +### config + +`CreateSMAV2AccountParams` +Configuration parameters for creating an SMAV2 account. Includes chain details, signer, salt, factory address, and more. + +## Returns + +`Promise` +A promise that resolves to an `MAV2Account` providing methods for nonce retrieval, transaction execution, and more. diff --git a/site/pages/reference/account-kit/smart-contracts/functions/createSMAV2AccountClient.mdx b/site/pages/reference/account-kit/smart-contracts/functions/createSMAV2AccountClient.mdx new file mode 100644 index 0000000000..8b7bcd96ab --- /dev/null +++ b/site/pages/reference/account-kit/smart-contracts/functions/createSMAV2AccountClient.mdx @@ -0,0 +1,52 @@ +--- +# This file is autogenerated + +title: createSMAV2AccountClient +description: Overview of the createSMAV2AccountClient method +--- + +# createSMAV2AccountClient + +Creates a SMAv2 account client using the provided configuration parameters. + +## Import + +```ts +import { createSMAV2AccountClient } from "@account-kit/smart-contracts"; +``` + +## Usage + +```ts +import { http } from "viem"; +import { createSMAV2AccountClient } from "@account-kit/smart-contracts"; +import { LocalAccountSigner } from "@aa-sdk/core"; +import { sepolia } from "@account-kit/infra"; + +const MNEMONIC = "..."; +const RPC_URL = "..."; + +const signer = LocalAccountSigner.mnemonicToAccountSigner(MNEMONIC); + +const chain = sepolia; + +const transport = http(RPC_URL); + +const SMAV2SignerAccountClient = await createSMAV2AccountClient({ + chain, + signer, + transport, +}); +``` + +## Parameters + +### config + +`CreateSMAV2AccountClientParams` +The configuration parameters required to create the MAv2 account client + +## Returns + +`Promise` +A promise that resolves to a `SmartAccountClient` instance diff --git a/site/pages/reference/account-kit/smart-contracts/functions/getDefaultAllowlistModuleAddress.mdx b/site/pages/reference/account-kit/smart-contracts/functions/getDefaultAllowlistModuleAddress.mdx new file mode 100644 index 0000000000..5522e43076 --- /dev/null +++ b/site/pages/reference/account-kit/smart-contracts/functions/getDefaultAllowlistModuleAddress.mdx @@ -0,0 +1,37 @@ +--- +# This file is autogenerated +title: getDefaultAllowlistModuleAddress +description: Overview of the getDefaultAllowlistModuleAddress method +--- + +# getDefaultAllowlistModuleAddress + +Maps a given chain to a specific address of the allowlist module by its chain ID. If no direct mapping exists, it defaults to returning a specific address. + +## Import + +```ts +import { getDefaultAllowlistModuleAddress } from "@account-kit/smart-contracts"; +``` + +## Usage + +```ts +import { getDefaultAllowlistModuleAddress } from "@account-kit/smart-contracts"; +import { Chain, Address } from "viem"; + +const chain: Chain = ... +const allowlistModule: Address = getDefaultAllowlistModuleAddress(chain); +``` + +## Parameters + +### chain + +`Chain` +The chain object containing the chain ID to map + +## Returns + +`Address` +The allowlist module address associated with the specified chain ID or a default address if no specific mapping exists diff --git a/site/pages/reference/account-kit/smart-contracts/functions/getDefaultNativeTokenLimitModuleAddress.mdx b/site/pages/reference/account-kit/smart-contracts/functions/getDefaultNativeTokenLimitModuleAddress.mdx new file mode 100644 index 0000000000..54dcc49268 --- /dev/null +++ b/site/pages/reference/account-kit/smart-contracts/functions/getDefaultNativeTokenLimitModuleAddress.mdx @@ -0,0 +1,37 @@ +--- +# This file is autogenerated +title: getDefaultNativeTokenLimitModuleAddress +description: Overview of the getDefaultNativeTokenLimitModuleAddress method +--- + +# getDefaultNativeTokenLimitModuleAddress + +Maps a given chain to a specific address of the native token limit module by its chain ID. If no direct mapping exists, it defaults to returning a specific address. + +## Import + +```ts +import { getDefaultNativeTokenLimitModuleAddress } from "@account-kit/smart-contracts"; +``` + +## Usage + +```ts +import { getDefaultNativeTokenLimitModuleAddress } from "@account-kit/smart-contracts"; +import { Chain, Address } from "viem"; + +const chain: Chain = ... +const nativeTokenLimitAddress: Address = getDefaultNativeTokenLimitModuleAddress(chain); +``` + +## Parameters + +### chain + +`Chain` +The chain object containing the chain ID to map + +## Returns + +`Address` +The native token limit module address associated with the specified chain ID or a default address if no specific mapping exists diff --git a/site/pages/reference/account-kit/smart-contracts/functions/getDefaultPaymasterGuardModuleAddress.mdx b/site/pages/reference/account-kit/smart-contracts/functions/getDefaultPaymasterGuardModuleAddress.mdx new file mode 100644 index 0000000000..11e25ca3b0 --- /dev/null +++ b/site/pages/reference/account-kit/smart-contracts/functions/getDefaultPaymasterGuardModuleAddress.mdx @@ -0,0 +1,37 @@ +--- +# This file is autogenerated +title: getDefaultPaymasterGuardModuleAddress +description: Overview of the getDefaultPaymasterGuardModuleAddress method +--- + +# getDefaultPaymasterGuardModuleAddress + +Maps a given chain to a specific address of the paymaster guard module by its chain ID. If no direct mapping exists, it defaults to returning a specific address. + +## Import + +```ts +import { getDefaultPaymasterGuardModuleAddress } from "@account-kit/smart-contracts"; +``` + +## Usage + +```ts +import { getDefaultPaymasterGuardModuleAddress } from "@account-kit/smart-contracts"; +import { Chain, Address } from "viem"; + +const chain: Chain = ... +const paymasterGuardAddress: Address = getDefaultPaymasterGuardModuleAddress(chain); +``` + +## Parameters + +### chain + +`Chain` +The chain object containing the chain ID to map + +## Returns + +`Address` +The paymaster guard module address associated with the specified chain ID or a default address if no specific mapping exists diff --git a/site/pages/reference/account-kit/smart-contracts/functions/getDefaultSingleSignerValidationModuleAddress.mdx b/site/pages/reference/account-kit/smart-contracts/functions/getDefaultSingleSignerValidationModuleAddress.mdx new file mode 100644 index 0000000000..04c02888cc --- /dev/null +++ b/site/pages/reference/account-kit/smart-contracts/functions/getDefaultSingleSignerValidationModuleAddress.mdx @@ -0,0 +1,37 @@ +--- +# This file is autogenerated +title: getDefaultSingleSignerValidationModuleAddress +description: Overview of the getDefaultSingleSignerValidationModuleAddress method +--- + +# getDefaultSingleSignerValidationModuleAddress + +Maps a given chain to a specific address of the single signer validation module by its chain ID. If no direct mapping exists, it defaults to returning a specific address. + +## Import + +```ts +import { getDefaultSingleSignerValidationModuleAddress } from "@account-kit/smart-contracts"; +``` + +## Usage + +```ts +import { getDefaultSingleSignerValidationModuleAddress } from "@account-kit/smart-contracts"; +import { Chain, Address } from "viem"; + +const chain: Chain = ... +const singleSignerValidationAddress: Address = getDefaultSingleSignerValidationModuleAddress(chain); +``` + +## Parameters + +### chain + +`Chain` +The chain object containing the chain ID to map + +## Returns + +`Address` +The single signer validation module address associated with the specified chain ID or a default address if no specific mapping exists diff --git a/site/pages/reference/account-kit/smart-contracts/functions/getDefaultTimeRangeModuleAddress.mdx b/site/pages/reference/account-kit/smart-contracts/functions/getDefaultTimeRangeModuleAddress.mdx new file mode 100644 index 0000000000..3de832b874 --- /dev/null +++ b/site/pages/reference/account-kit/smart-contracts/functions/getDefaultTimeRangeModuleAddress.mdx @@ -0,0 +1,37 @@ +--- +# This file is autogenerated +title: getDefaultTimeRangeModuleAddress +description: Overview of the getDefaultTimeRangeModuleAddress method +--- + +# getDefaultTimeRangeModuleAddress + +Maps a given chain to a specific address of the time range module by its chain ID. If no direct mapping exists, it defaults to returning a specific address. + +## Import + +```ts +import { getDefaultTimeRangeModuleAddress } from "@account-kit/smart-contracts"; +``` + +## Usage + +```ts +import { getDefaultTimeRangeModuleAddress } from "@account-kit/smart-contracts"; +import { Chain, Address } from "viem"; + +const chain: Chain = ... +const timeRangeModuleAddress: Address = getDefaultTimeRangeModuleAddress(chain); +``` + +## Parameters + +### chain + +`Chain` +The chain object containing the chain ID to map + +## Returns + +`Address` +The time range module address associated with the specified chain ID or a default address if no specific mapping exists diff --git a/site/pages/reference/account-kit/smart-contracts/functions/getDefaultWebauthnValidationModuleAddress.mdx b/site/pages/reference/account-kit/smart-contracts/functions/getDefaultWebauthnValidationModuleAddress.mdx new file mode 100644 index 0000000000..fd27c9dac5 --- /dev/null +++ b/site/pages/reference/account-kit/smart-contracts/functions/getDefaultWebauthnValidationModuleAddress.mdx @@ -0,0 +1,37 @@ +--- +# This file is autogenerated +title: getDefaultWebauthnValidationModuleAddress +description: Overview of the getDefaultWebauthnValidationModuleAddress method +--- + +# getDefaultWebauthnValidationModuleAddress + +Maps a given chain to a specific address of the webauthn validation module by its chain ID. If no direct mapping exists, it defaults to returning a specific address. + +## Import + +```ts +import { getDefaultWebauthnValidationModuleAddress } from "@account-kit/smart-contracts"; +``` + +## Usage + +```ts +import { getDefaultWebauthnValidationModuleAddress } from "@account-kit/smart-contracts"; +import { Chain, Address } from "viem"; + +const chain: Chain = ... +const webauthnValidationAddress: Address = getDefaultWebauthnValidationModuleAddress(chain); +``` + +## Parameters + +### chain + +`Chain` +The chain object containing the chain ID to map + +## Returns + +`Address` +The webauthn validation module address associated with the specified chain ID or a default address if no specific mapping exists diff --git a/site/pages/reference/account-kit/smart-contracts/functions/installValidationActions.mdx b/site/pages/reference/account-kit/smart-contracts/functions/installValidationActions.mdx new file mode 100644 index 0000000000..602162dacc --- /dev/null +++ b/site/pages/reference/account-kit/smart-contracts/functions/installValidationActions.mdx @@ -0,0 +1,69 @@ +--- +# This file is autogenerated + +title: installValidationActions +description: Overview of the installValidationActions method +--- + +# installValidationActions + +Provides validation installation and uninstallation functionalities for a MA v2 client, ensuring compatibility with `SmartAccountClient`. + +## Import + +```ts +import { installValidationActions } from "@account-kit/smart-contracts"; +``` + +## Usage + +```ts +import { createSMAV2AccountClient, installValidationActions, getDefaultSingleSignerValidationModuleAddress, SingleSignerValidationModule } from "@account-kit/smart-contracts"; +import { Address } from "viem"; + +const client = (await createSMAV2AccountClient({ ... })).extend(installValidationActions); +const sessionKeyAddress: Address = "0x1234"; +const sessionKeyEntityId: number = 1; + +await client.installValidation({ +validationConfig: { +moduleAddress: getDefaultSingleSignerValidationModuleAddress( + client.chain +), +entityId: sessionKeyEntityId, +isGlobal: true, +isSignatureValidation: false, +isUserOpValidation: true, +}, +selectors: [], +installData: SingleSignerValidationModule.encodeOnInstallData({ +entityId: sessionKeyEntityId, +signer: sessionKeyAddress, +}), +hooks: [], +}); + +await client.uninstallValidation({ +moduleAddress: sessionKeyAddress, +entityId: sessionKeyEntityId, +uninstallData: SingleSignerValidationModule.encodeOnUninstallData({ +entityId: sessionKeyEntityId, +}), +hookUninstallDatas: [], +}); + +``` + +## Parameters + +### client + +`object` + +- The client instance which provides account and sendUserOperation functionality. + + ## Returns + + `object` + +- An object containing two methods, `installValidation` and `uninstallValidation`. diff --git a/site/pages/reference/account-kit/smart-contracts/functions/nativeSMASigner.mdx b/site/pages/reference/account-kit/smart-contracts/functions/nativeSMASigner.mdx new file mode 100644 index 0000000000..0052b9b056 --- /dev/null +++ b/site/pages/reference/account-kit/smart-contracts/functions/nativeSMASigner.mdx @@ -0,0 +1,53 @@ +--- +# This file is autogenerated +title: nativeSMASigner +description: Overview of the nativeSMASigner method +--- + +# nativeSMASigner + +Creates an object with methods for generating a dummy signature, signing user operation hashes, signing messages, and signing typed data. + +## Import + +```ts +import { nativeSMASigner } from "@account-kit/smart-contracts"; +``` + +## Usage + +```ts +import { nativeSMASigner } from "@account-kit/smart-contracts"; + +import { LocalAccountSigner } from "@aa-sdk/core"; + +const MNEMONIC = "...": + +const account = createSMAV2Account({ config }); + +const signer = LocalAccountSigner.mnemonicToAccountSigner(MNEMONIC); + +const messageSigner = nativeSMASigner(signer, chain, account.address); +``` + +## Parameters + +### signer + +`SmartAccountSigner` +Signer to use for signing operations + +### chain + +`Chain` +Chain object for the signer + +### accountAddress + +`Address` +address of the smart account using this signer + +## Returns + +`object` +an object with methods for signing operations and managing signatures diff --git a/site/pages/reference/account-kit/smart-contracts/functions/serializeHookConfig.mdx b/site/pages/reference/account-kit/smart-contracts/functions/serializeHookConfig.mdx new file mode 100644 index 0000000000..94b6f1f3b1 --- /dev/null +++ b/site/pages/reference/account-kit/smart-contracts/functions/serializeHookConfig.mdx @@ -0,0 +1,49 @@ +--- +# This file is autogenerated + +title: serializeHookConfig +description: Overview of the serializeHookConfig method +--- + +# serializeHookConfig + +Serializes a `HookConfig` object into a `Hex` format by encoding the hook type, presence of post/pre hooks, address, and entity ID. + +## Import + +```ts +import { serializeHookConfig } from "@account-kit/smart-contracts"; +``` + +## Usage + +```ts +import { type HookType, serializeHookConfig } from "@account-kit/smart-contracts"; +import { Address } from "viem"; + +const moduleAddress: Address = "0x1234"; +const entityId: number = 1234; +const hookType: HookType = HookType.Validation; +const hasPostHooks: boolean = false; +const hasPreHooks: boolean = true; + +const hookConfigHex = serializeHookConfig({ +moduleAddress, +entityId +hookType, +hasPostHooks, +hasPreHooks +}); +``` + +## Parameters + +### config + +`HookConfig` +The hook configuration containing address, entity ID, hook type, and post/pre hook indicators + +## Returns + +`Hex` +The serialized hook configuration in hexadecimal format diff --git a/site/pages/reference/account-kit/smart-contracts/functions/serializeModuleEntity.mdx b/site/pages/reference/account-kit/smart-contracts/functions/serializeModuleEntity.mdx new file mode 100644 index 0000000000..a95495eaa9 --- /dev/null +++ b/site/pages/reference/account-kit/smart-contracts/functions/serializeModuleEntity.mdx @@ -0,0 +1,43 @@ +--- +# This file is autogenerated + +title: serializeModuleEntity +description: Overview of the serializeModuleEntity method +--- + +# serializeModuleEntity + +Serializes a module entity into a hexadecimal format by concatenating the module address and entity ID. + +## Import + +```ts +import { serializeModuleEntity } from "@account-kit/smart-contracts"; +``` + +## Usage + +```ts +import { serializeModuleEntity } from "@account-kit/smart-contracts"; +import { Address } from "viem"; + +const moduleAddress: Address = "0x1234"; +const entityId: number = 1234; + +const moduleEntityHex = serializeModuleEntity({ + moduleAddress, + entityId, +}); +``` + +## Parameters + +### config + +`ModuleEntity` +The module entity configuration containing the module address and entity ID + +## Returns + +`Hex` +A hexadecimal string representation of the serialized module entity diff --git a/site/pages/reference/account-kit/smart-contracts/functions/serializeValidationConfig.mdx b/site/pages/reference/account-kit/smart-contracts/functions/serializeValidationConfig.mdx new file mode 100644 index 0000000000..f66a26e095 --- /dev/null +++ b/site/pages/reference/account-kit/smart-contracts/functions/serializeValidationConfig.mdx @@ -0,0 +1,49 @@ +--- +# This file is autogenerated + +title: serializeValidationConfig +description: Overview of the serializeValidationConfig method +--- + +# serializeValidationConfig + +Serializes a validation configuration into a hexadecimal string representation. This involves converting boolean flags into bitwise representation and combining them with serialized module entity data. + +## Import + +```ts +import { serializeValidationConfig } from "@account-kit/smart-contracts"; +``` + +## Usage + +```ts +import { serializeValidationConfig } from "@account-kit/smart-contracts"; +import { Address } from "viem"; + +const moduleAddress: Address = "0x1234"; +const entityId: number = 1234; +const isGlobal: boolean = true; +const isSignatureValidation: boolean = false; +const isUserOpValidation: boolean = true; + +const validationConfigHex = serializeValidationConfig({ +moduleAddress, +entityId +isGlobal, +isSignatureValidation, +isUserOpValidation +}); +``` + +## Parameters + +### config + +`ValidationConfig` +The validation configuration object containing details to serialize + +## Returns + +`Hex` +A hexadecimal string representing the serialized configuration