@metamask/smart-accounts-kit 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -1
- package/dist/actions/index.cjs +4 -4
- package/dist/actions/index.d.cts +1 -1
- package/dist/actions/index.d.ts +1 -1
- package/dist/actions/index.mjs +3 -3
- package/dist/{caveats-CQbtzOKm.d.ts → caveats-BhjGBVHX.d.ts} +1 -1
- package/dist/{caveats-Cey0wm33.d.cts → caveats-CeHBbmt_.d.cts} +1 -1
- package/dist/{chunk-AJWMPR7X.cjs → chunk-6CEOFJY5.cjs} +122 -50
- package/dist/chunk-6CEOFJY5.cjs.map +1 -0
- package/dist/{chunk-AC2BQSYP.mjs → chunk-DVJX76J3.mjs} +2 -2
- package/dist/{chunk-Z4D7ZWVB.mjs → chunk-EEIIVBNV.mjs} +22 -18
- package/dist/chunk-EEIIVBNV.mjs.map +1 -0
- package/dist/{chunk-LQXOM3TA.mjs → chunk-FG2CQGSE.mjs} +3 -3
- package/dist/{chunk-26PADMXR.mjs → chunk-HQHXGWNJ.mjs} +4 -4
- package/dist/{chunk-3PBVHNYP.cjs → chunk-MVBU3LRV.cjs} +10 -10
- package/dist/{chunk-3PBVHNYP.cjs.map → chunk-MVBU3LRV.cjs.map} +1 -1
- package/dist/{chunk-FKI4OME5.mjs → chunk-R2WT54GZ.mjs} +78 -6
- package/dist/chunk-R2WT54GZ.mjs.map +1 -0
- package/dist/{chunk-57I2FJY7.cjs → chunk-RR2AMG4A.cjs} +102 -102
- package/dist/{chunk-57I2FJY7.cjs.map → chunk-RR2AMG4A.cjs.map} +1 -1
- package/dist/{chunk-DLCTHNAE.cjs → chunk-SO5JAXGD.cjs} +11 -11
- package/dist/{chunk-DLCTHNAE.cjs.map → chunk-SO5JAXGD.cjs.map} +1 -1
- package/dist/{chunk-SZOX7K2V.cjs → chunk-TMO23YRP.cjs} +19 -15
- package/dist/chunk-TMO23YRP.cjs.map +1 -0
- package/dist/{chunk-GZ7HHI2D.cjs → chunk-XZ7UMCG3.cjs} +12 -12
- package/dist/{chunk-GZ7HHI2D.cjs.map → chunk-XZ7UMCG3.cjs.map} +1 -1
- package/dist/{chunk-KBSFVKUB.mjs → chunk-ZGBFPD4O.mjs} +2 -2
- package/dist/contracts/index.cjs +5 -5
- package/dist/contracts/index.d.cts +2 -2
- package/dist/contracts/index.d.ts +2 -2
- package/dist/contracts/index.mjs +4 -4
- package/dist/{delegation-Bx4FEAIU.d.ts → delegation-CR99q1-n.d.ts} +2 -6
- package/dist/{delegation-KbWHzRxV.d.cts → delegation-DoVULGYE.d.cts} +2 -6
- package/dist/experimental/index.cjs +7 -7
- package/dist/experimental/index.mjs +1 -1
- package/dist/{index-BDC55AA9.d.cts → index-BToRQKyJ.d.cts} +23 -3
- package/dist/{index-DhG2lH80.d.ts → index-Cg-JakqA.d.ts} +23 -3
- package/dist/{index-D2THBlfm.d.ts → index-DRKgDSZW.d.ts} +1 -1
- package/dist/{index-DE87r5KY.d.cts → index-DzL9ccjU.d.cts} +1 -1
- package/dist/index.cjs +22 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.mjs +9 -7
- package/dist/index.mjs.map +1 -1
- package/dist/utils/index.cjs +4 -4
- package/dist/utils/index.d.cts +2 -2
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.mjs +3 -3
- package/package.json +4 -4
- package/dist/chunk-AJWMPR7X.cjs.map +0 -1
- package/dist/chunk-FKI4OME5.mjs.map +0 -1
- package/dist/chunk-SZOX7K2V.cjs.map +0 -1
- package/dist/chunk-Z4D7ZWVB.mjs.map +0 -1
- /package/dist/{chunk-AC2BQSYP.mjs.map → chunk-DVJX76J3.mjs.map} +0 -0
- /package/dist/{chunk-LQXOM3TA.mjs.map → chunk-FG2CQGSE.mjs.map} +0 -0
- /package/dist/{chunk-26PADMXR.mjs.map → chunk-HQHXGWNJ.mjs.map} +0 -0
- /package/dist/{chunk-KBSFVKUB.mjs.map → chunk-ZGBFPD4O.mjs.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/smart-accounts-kit/smart-accounts-kit/packages/smart-accounts-kit/dist/chunk-3PBVHNYP.cjs","../src/counterfactualAccountData.ts","../src/encodeCalls.ts","../src/webAuthn.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACfA,4BAAwC;AA6BjC,IAAM,6BAAA,EAA+B,MAAA,CAE1C;AAAA,EACA,OAAA;AAAA,EACA,eAAA;AAAA,EACA,cAAA;AAAA,EACA,YAAA;AAAA,EACA;AACF,CAAA,EAAA,GAMuD;AACrD,EAAA,IAAI,qBAAA;AACJ,EAAA,IAAI,QAAA;AAEJ,EAAA,OAAA,CAAQ,cAAA,EAAgB;AAAA,IACtB,KAAA,qBAAA,EAA4B;AAC1B,MAAA,MAAM,CAAC,KAAA,EAAO,MAAA,EAAQ,OAAA,EAAS,OAAO,EAAA,EACpC,YAAA;AAEF,MAAA,GAAA,CAAI,CAAC,eAAA,CAAgB,mBAAA,EAAqB;AACxC,QAAA,MAAM,IAAI,KAAA;AAAA,UACR;AAAA,QACF,CAAA;AAAA,MACF;AAEA,MAAA,sBAAA,EAAwB,eAAA,CAAgB,mBAAA;AAExC,MAAA,MAAM,WAAA,EAAa,MAAA,CAAO,GAAA,CAAI,CAAC,KAAA,EAAO,KAAA,EAAA,GAAU;AAC9C,QAAA,MAAM,OAAA,EAAS,OAAA,CAAQ,KAAK,CAAA;AAC5B,QAAA,MAAM,OAAA,EAAS,OAAA,CAAQ,KAAK,CAAA;AAE5B,QAAA,GAAA,CAAI,CAAC,OAAA,GAAU,CAAC,MAAA,EAAQ;AACtB,UAAA,MAAM,IAAI,KAAA;AAAA,YACR,CAAA,+B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AACE;AACA;AAEA;AACA;AACA;AACA;AAGK;AAEA;AAEA;AAA6B,EAAA;AAEpC;AAcO;AAYL,EAAA;AACE,IAAA;AACA,IAAA;AACE,MAAA;AAA0D,IAAA;AAE5D,IAAA;AAAqC,EAAA;AAErC,IAAA;AAA4D,MAAA;AACnD,IAAA;AACR,EAAA;AAEL;AAQO;AACL,EAAA;AAEE,IAAA;AAEA,IAAA;AACE,MAAA;AAAqD,IAAA;AAGvD,IAAA;AAAuB,EAAA;AAGvB,IAAA;AAAuD,MAAA;AAC9C,IAAA;AACR,EAAA;AAEL;AAYO;AAML,EAAA;AAEA,EAAA;AAEA,EAAA;AAEA,EAAA;AACE,IAAA;AAA8B,EAAA;AAGhC,EAAA;AAGA,EAAA;AAEA,EAAA;AAEA,EAAA;AAAmE,IAAA;AACjE,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,EAAA;AAEF,EAAA;AACF;AAEA;AAsBO;AAGL,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACE,IAAA;AAAqE,EAAA;AAKvE,EAAA;AAEA,EAAA;AAAO;AAAA,IAAA;AAE+B,EAAA;AAExC;AASO;AAEL,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AAEA,EAAA;AACA,EAAA;AAEA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AAEA,EAAA;AAAmE,IAAA;AACjE,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,EAAA;AAGF,EAAA;AACF;AH8CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/smart-accounts-kit/smart-accounts-kit/packages/smart-accounts-kit/dist/chunk-3PBVHNYP.cjs","sourcesContent":[null,"import type { Address, Hex } from 'viem';\nimport { getContractAddress, pad } from 'viem';\n\nimport { Implementation } from './constants';\nimport { initializeHybridDeleGator } from './DelegationFramework/HybridDeleGator/encode';\nimport { initializeMultiSigDeleGator } from './DelegationFramework/MultiSigDeleGator/encode';\nimport { create2Deploy as encodeCreate2Deploy } from './DelegationFramework/SimpleFactory/encode';\nimport { encodeProxyCreationCode } from './DelegationFramework/utils';\nimport type {\n SmartAccountsEnvironment,\n HybridDeleGatorDeployParams,\n MultiSigDeleGatorDeployParams,\n DeployParams,\n} from './types';\n\n/**\n * Infers counterfactual account data for a DeleGator smart account.\n *\n * @template TImplementation - The type of implementation, extending Implementation.\n * @template TDeployParams - The type of deployment parameters, defaults to DeployParams<Implementation>.\n * @param options - The options for generating counterfactual account data.\n * @param options.factory - The address of the SimpleFactory contract.\n * @param options.implementations - The DeleGator implementation contracts.\n * @param options.implementation - The implementation type to use.\n * @param options.deployParams - The deployment parameters for the specified implementation.\n * @param options.deploySalt - The salt to use for CREATE2 address computation.\n * @returns An object containing the counterfactual address and factory calldata.\n * @description This function calculates the address a DeleGator contract would have if deployed,\n * and provides the calldata needed to deploy it.\n */\nexport const getCounterfactualAccountData = async <\n TImplementation extends Implementation,\n>({\n factory,\n implementations,\n implementation,\n deployParams,\n deploySalt,\n}: {\n factory: Address;\n implementations: SmartAccountsEnvironment['implementations'];\n implementation: TImplementation;\n deployParams: DeployParams<TImplementation>;\n deploySalt: Hex;\n}): Promise<{ factoryData: Hex; address: Address }> => {\n let implementationAddress: Address;\n let initcode: Hex;\n\n switch (implementation) {\n case Implementation.Hybrid: {\n const [owner, keyIds, xValues, yValues] =\n deployParams as HybridDeleGatorDeployParams;\n\n if (!implementations.HybridDeleGatorImpl) {\n throw new Error(\n 'HybridDeleGatorImpl address not provided in environment',\n );\n }\n\n implementationAddress = implementations.HybridDeleGatorImpl;\n\n const p256Owners = keyIds.map((keyId, index) => {\n const xValue = xValues[index];\n const yValue = yValues[index];\n\n if (!xValue || !yValue) {\n throw new Error(\n `Missing X or Y value for keyId ${keyId} at index ${index}`,\n );\n }\n\n return {\n keyId,\n x: xValue,\n y: yValue,\n };\n });\n\n initcode = initializeHybridDeleGator({ eoaOwner: owner, p256Owners });\n break;\n }\n case Implementation.MultiSig: {\n const [owners, threshold] = deployParams as MultiSigDeleGatorDeployParams;\n\n if (!implementations.MultiSigDeleGatorImpl) {\n throw new Error(\n 'MultiSigDeleGatorImpl address not provided in environment',\n );\n }\n\n implementationAddress = implementations.MultiSigDeleGatorImpl;\n initcode = initializeMultiSigDeleGator({ owners, threshold });\n break;\n }\n case Implementation.Stateless7702:\n default:\n throw new Error(`Implementation type '${implementation}' not supported`);\n }\n\n const salt = pad(deploySalt, { dir: 'left', size: 32 });\n\n const proxyCreationCode = encodeProxyCreationCode({\n implementationAddress,\n initcode,\n });\n\n const address = getContractAddress({\n bytecode: proxyCreationCode,\n from: factory,\n opcode: 'CREATE2',\n salt,\n });\n\n const factoryData = encodeCreate2Deploy(proxyCreationCode, salt);\n\n return {\n factoryData,\n address,\n };\n};\n","import { DelegationManager } from '@metamask/delegation-abis';\nimport { encodeFunctionData } from 'viem';\nimport type { Address, Hex } from 'viem';\n\nimport type { DelegatedCall } from './actions/erc7710RedeemDelegationAction';\nimport { encodeDelegations } from './delegation';\nimport {\n execute,\n executeWithMode,\n} from './DelegationFramework/DeleGatorCore/encode';\nimport {\n ExecutionMode,\n createExecution,\n encodeExecutionCalldatas,\n} from './executions';\nimport type { Call } from './types';\n\n/**\n * Checks if a call is a delegated call by checking for the presence of permissionContext and delegationManager.\n *\n * @param call - The call to check.\n * @returns True if the call is a delegated call, false otherwise.\n */\nconst isDelegatedCall = (call: Call): call is DelegatedCall => {\n return 'permissionContext' in call && 'delegationManager' in call;\n};\n\n/**\n * If there's a single call with permissionContext and delegationManager,\n * processes it as a delegated call.\n *\n * @param call - The call to process.\n * @returns The execution object for the delegated call.\n * @description\n * This function creates an execution that calls redeemDelegations on the delegation manager.\n */\nconst processDelegatedCall = (call: DelegatedCall) => {\n const {\n permissionContext,\n delegationManager,\n to: target,\n value,\n data: callData,\n } = call;\n\n const callAsExecution = createExecution({ target, value, callData });\n\n if (!permissionContext) {\n return callAsExecution;\n }\n\n const encodedPermissionsContext = encodeDelegations(permissionContext);\n\n const redeemCalldata = encodeFunctionData({\n abi: DelegationManager,\n functionName: 'redeemDelegations',\n args: [\n [encodedPermissionsContext],\n [ExecutionMode.SingleDefault],\n encodeExecutionCalldatas([[callAsExecution]]),\n ],\n });\n\n return createExecution({\n target: delegationManager,\n callData: redeemCalldata,\n });\n};\n\n/**\n * If there's a single call, encode the shorthand `execute` function. Otherwise, encode the `executeWithMode` function. Execution type will always be \"default\".\n *\n * @param calls - The calls to execute.\n * @returns The encoded calldata for the DeleGator to execute the calls.\n * @description\n * This function supports both single and batch execution modes.\n * For single calls, it uses the gas-efficient execute function.\n */\nexport const encodeCalls = (calls: readonly Call[]) => {\n if (calls.length === 1) {\n const call = calls[0];\n if (call && !isDelegatedCall(call)) {\n const { to: target, value, data: callData } = call;\n const execution = createExecution({ target, value, callData });\n return execute({ execution });\n }\n }\n\n const executions = calls.map((call) => {\n if (isDelegatedCall(call)) {\n return processDelegatedCall(call);\n }\n const { to: target, value, data: callData } = call;\n return createExecution({ target, value, callData });\n });\n\n const mode =\n calls.length === 1\n ? ExecutionMode.SingleDefault\n : ExecutionMode.BatchDefault;\n return executeWithMode({ mode, executions });\n};\n\n/**\n * Encodes calls for execution by a DeleGator smart contract.\n *\n * @param caller - The address of the DeleGator contract.\n * @param calls - An array of Call objects, each containing 'to', optional 'data', and optional 'value'.\n * @returns A promise that resolves to the encoded function data as a hexadecimal string.\n * @description\n * - If there's a single call directly to the delegator, it returns the call data directly.\n * - For multiple calls or calls to other addresses, it creates executions and encodes them for the DeleGator's execute function.\n * - The execution mode is set to ExecutionMode.SingleDefault for a single call, or ExecutionMode.BatchDefault for multiple calls.\n *\n * todo: This doesn't fully expose the flexibility of the DeleGator's execute function, but it's a start.\n * maybe we add a mechanism where individual calls passed to this function can be encoded batches.\n */\nexport const encodeCallsForCaller = async (\n caller: Address,\n calls: readonly Call[],\n): Promise<Hex> => {\n if (calls.length === 1) {\n const call = calls[0];\n if (call?.to === caller && !isDelegatedCall(call)) {\n // if there's a single call, and it's to the delegator, we can just return the calldata directly.\n return call.data ?? '0x';\n }\n }\n return encodeCalls(calls);\n};\n","import { Signature } from 'ox';\nimport {\n parseAbiParameters,\n encodeAbiParameters,\n type Hex,\n encodePacked,\n keccak256,\n concat,\n hexToBytes,\n} from 'viem';\n\nexport const FIELD_MODULUS =\n 115792089210356248762697446949407573529996955224135760342422259061068512044369n;\nexport const MALLEABILITY_THRESHOLD = FIELD_MODULUS / 2n;\n\nexport const SIGNATURE_ABI_PARAMS = parseAbiParameters(\n 'bytes32, uint256, uint256, bytes, bool, string, string, uint256',\n);\n\n/**\n * This function is used to convert the client data returned from the\n * credentials API into a format that can be consumed by the DeleGator\n * contracts. We need the flattend JSON strings before and after the\n * userOpHash/challenge. This function provides those two client data string\n * slices.\n *\n * @param clientDataJson - The client data JSON string.\n * @returns Returns [clientDataJSONPrefix and clientDataJSONSuffix]\n * ClientDataJSONPrefix contains the client data till the challengeHash\n * ClientDataJSONSuffix contains the client data after the challengeHash.\n */\nexport const splitOnChallenge = (\n clientDataJson: string,\n): [clientDataJSONPrefix: string, clientDataJSONSuffix: string] => {\n /*\n CientData looks like this:\n {\n \"type\": \"webauthn.create\" | \"webauthn.get\",\n \"challenge\": \"{userOpHash}\",\n \"origin\": \"{Domain}\",\n \"crossOrigin\": boolean\n }\n */\n try {\n const { challenge } = JSON.parse(clientDataJson);\n if (challenge === undefined) {\n throw new Error('No \"challenge\" found in the input string');\n }\n return clientDataJson.split(challenge) as [string, string];\n } catch (error) {\n throw new Error('No \"challenge\" found in the input string', {\n cause: error,\n });\n }\n};\n\n/**\n * Returns the index of '\"type\":' in the ClientData.\n *\n * @param clientDataJson - Stringified ClientDataJSON.\n * @returns The index of '\"type\":' in the ClientData.\n */\nexport const getResponseTypeLocation = (clientDataJson: string): bigint => {\n try {\n // Find the index of the `\"type\":` key in the JSON string directly\n const typeIndex = clientDataJson.indexOf('\"type\":');\n\n if (typeIndex === -1) {\n throw new Error('No \"type\" found in the input string');\n }\n // Return the index of the `\"type\":` key\n return BigInt(typeIndex);\n } catch (error) {\n // Handle any errors that occur during the search\n throw new Error('No \"type\" found in the input string', {\n cause: error,\n });\n }\n};\n\n/**\n * Encodes a signature to a hexadecimal signature that will be accepted\n * by the DeleGator contracts.\n *\n * @param keyId - The key used for the signature, represented as a hexadecimal string.\n * @param signature - The signature to convert, as Hex.\n * @param clientDataJSON - The client data used in the creation of the signature.\n * @param authenticatorData - The authenticator data used in the creation of the signature.\n * @returns The signature as a valid DeleGator signature encoded as Hexadecimal string.\n */\nexport function encodeDeleGatorSignature(\n keyId: string,\n signature: Hex,\n clientDataJSON: string,\n authenticatorData: Hex,\n): Hex {\n const keyIdHash = keccak256(encodePacked(['string'], [keyId]));\n\n const { r: rValue, s: sValue } = Signature.fromHex(signature);\n\n let normalizedS = sValue;\n\n while (normalizedS > MALLEABILITY_THRESHOLD) {\n normalizedS = FIELD_MODULUS - normalizedS;\n }\n\n const [clientDataComponent1, clientDataComponent2] =\n splitOnChallenge(clientDataJSON);\n\n const { userVerified } = parseAuthenticatorFlags(authenticatorData);\n\n const responseTypeLocation = getResponseTypeLocation(clientDataJSON);\n\n const encodedSignature = encodeAbiParameters(SIGNATURE_ABI_PARAMS, [\n keyIdHash,\n rValue,\n normalizedS,\n authenticatorData,\n userVerified,\n clientDataComponent1,\n clientDataComponent2,\n responseTypeLocation,\n ]);\n return encodedSignature;\n}\n\nconst AUTHENTICATOR_DATA_FLAGS_OFFSET = 32;\n// We have all of the flag bits defined here for completeness, even though we only extract the userVerified flag.\nenum AuthenticatorDataFlagBitIndex {\n UserPresence = 0,\n UserVerified = 2,\n BackupEligibility = 3,\n BackupState = 4,\n AttestedCredentialData = 6,\n ExtensionData = 7,\n}\n\nexport type AuthenticatorFlags = {\n userVerified: boolean;\n};\n\n/**\n * Parses the authenticator data and returns an authenticator flags object with the `userVerified` flag.\n * See https://developer.mozilla.org/en-US/docs/Web/API/Web_Authentication_API/Authenticator_data.\n *\n * @param authenticatorData - The authenticator data to parse.\n * @returns An object representing the parsed authenticator flags.\n */\nexport function parseAuthenticatorFlags(\n authenticatorData: Hex,\n): AuthenticatorFlags {\n const authenticatorDataBuffer = hexToBytes(authenticatorData);\n const dataBufferUint8 = new Uint8Array(authenticatorDataBuffer);\n const flags = dataBufferUint8[AUTHENTICATOR_DATA_FLAGS_OFFSET];\n if (flags === undefined) {\n throw new Error('Authenticator flags not found in authenticator data');\n }\n\n // Bit 0 is the least significant bit in the flags byte, so we left shift 0b1 by the bit index\n // eslint-disable-next-line no-bitwise\n const bitMask = 0b1 << AuthenticatorDataFlagBitIndex.UserVerified;\n\n return {\n // eslint-disable-next-line no-bitwise\n userVerified: (flags & bitMask) !== 0x0,\n };\n}\n\n/**\n * Creates a dummy signature.\n * This must meet all early-failure conditions of the real signature, but does not need to be a valid signature.\n *\n * @param keyId - The key ID to use for the dummy signature.\n * @returns The encoded signature.\n */\nexport const createDummyWebAuthnSignature = (keyId: Hex) => {\n // https://developer.mozilla.org/en-US/docs/Web/API/Web_Authentication_API/Authenticator_data#data_structure\n const rpIdHash = keccak256(encodePacked(['string'], ['AuthenticatorData']));\n const flags = '0x05';\n const signCount = '0x00000000';\n const authenticatorData = concat([rpIdHash, flags, signCount]);\n\n const keyIdHash = keccak256(encodePacked(['string'], [keyId]));\n const rs =\n 57896044605178124381348723474703786764998477612067880171211129530534256022184n;\n const userVerification = true;\n const clientDataPrefix = '{\"type\":\"webauthn.get\",\"challenge\":\"';\n const clientDataSuffix = '\",\"origin\":\"passkey-domain\",\"crossOrigin\":false}';\n const responseTypeLocation = 1n;\n\n const encodedSignature = encodeAbiParameters(SIGNATURE_ABI_PARAMS, [\n keyIdHash,\n rs,\n rs,\n authenticatorData,\n userVerification,\n clientDataPrefix,\n clientDataSuffix,\n responseTypeLocation,\n ]);\n\n return encodedSignature;\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/smart-accounts-kit/smart-accounts-kit/packages/smart-accounts-kit/dist/chunk-MVBU3LRV.cjs","../src/counterfactualAccountData.ts","../src/encodeCalls.ts","../src/webAuthn.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACfA,4BAAwC;AA6BjC,IAAM,6BAAA,EAA+B,MAAA,CAE1C;AAAA,EACA,OAAA;AAAA,EACA,eAAA;AAAA,EACA,cAAA;AAAA,EACA,YAAA;AAAA,EACA;AACF,CAAA,EAAA,GAMuD;AACrD,EAAA,IAAI,qBAAA;AACJ,EAAA,IAAI,QAAA;AAEJ,EAAA,OAAA,CAAQ,cAAA,EAAgB;AAAA,IACtB,KAAA,qBAAA,EAA4B;AAC1B,MAAA,MAAM,CAAC,KAAA,EAAO,MAAA,EAAQ,OAAA,EAAS,OAAO,EAAA,EACpC,YAAA;AAEF,MAAA,GAAA,CAAI,CAAC,eAAA,CAAgB,mBAAA,EAAqB;AACxC,QAAA,MAAM,IAAI,KAAA;AAAA,UACR;AAAA,QACF,CAAA;AAAA,MACF;AAEA,MAAA,sBAAA,EAAwB,eAAA,CAAgB,mBAAA;AAExC,MAAA,MAAM,WAAA,EAAa,MAAA,CAAO,GAAA,CAAI,CAAC,KAAA,EAAO,KAAA,EAAA,GAAU;AAC9C,QAAA,MAAM,OAAA,EAAS,OAAA,CAAQ,KAAK,CAAA;AAC5B,QAAA,MAAM,OAAA,EAAS,OAAA,CAAQ,KAAK,CAAA;AAE5B,QAAA,GAAA,CAAI,CAAC,OAAA,GAAU,CAAC,MAAA,EAAQ;AACtB,UAAA,MAAM,IAAI,KAAA;AAAA,YACR,CAAA,+BAAA,EAAkC,KAAK,CAAA,UAAA,EAAa,KAAK,CAAA;AAAA,UAAA;AAC3D,QAAA;AAGF,QAAA;AAAO,UAAA;AACL,UAAA;AACG,UAAA;AACA,QAAA;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A;AAE5D,IAAA;AAAqC,EAAA;AAErC,IAAA;AAA4D,MAAA;AACnD,IAAA;AACR,EAAA;AAEL;AAQO;AACL,EAAA;AAEE,IAAA;AAEA,IAAA;AACE,MAAA;AAAqD,IAAA;AAGvD,IAAA;AAAuB,EAAA;AAGvB,IAAA;AAAuD,MAAA;AAC9C,IAAA;AACR,EAAA;AAEL;AAYO;AAML,EAAA;AAEA,EAAA;AAEA,EAAA;AAEA,EAAA;AACE,IAAA;AAA8B,EAAA;AAGhC,EAAA;AAGA,EAAA;AAEA,EAAA;AAEA,EAAA;AAAmE,IAAA;AACjE,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,EAAA;AAEF,EAAA;AACF;AAEA;AAsBO;AAGL,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACE,IAAA;AAAqE,EAAA;AAKvE,EAAA;AAEA,EAAA;AAAO;AAAA,IAAA;AAE+B,EAAA;AAExC;AASO;AAEL,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AAEA,EAAA;AACA,EAAA;AAEA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AAEA,EAAA;AAAmE,IAAA;AACjE,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,EAAA;AAGF,EAAA;AACF;AH8CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/smart-accounts-kit/smart-accounts-kit/packages/smart-accounts-kit/dist/chunk-MVBU3LRV.cjs","sourcesContent":[null,"import type { Address, Hex } from 'viem';\nimport { getContractAddress, pad } from 'viem';\n\nimport { Implementation } from './constants';\nimport { initializeHybridDeleGator } from './DelegationFramework/HybridDeleGator/encode';\nimport { initializeMultiSigDeleGator } from './DelegationFramework/MultiSigDeleGator/encode';\nimport { create2Deploy as encodeCreate2Deploy } from './DelegationFramework/SimpleFactory/encode';\nimport { encodeProxyCreationCode } from './DelegationFramework/utils';\nimport type {\n SmartAccountsEnvironment,\n HybridDeleGatorDeployParams,\n MultiSigDeleGatorDeployParams,\n DeployParams,\n} from './types';\n\n/**\n * Infers counterfactual account data for a DeleGator smart account.\n *\n * @template TImplementation - The type of implementation, extending Implementation.\n * @template TDeployParams - The type of deployment parameters, defaults to DeployParams<Implementation>.\n * @param options - The options for generating counterfactual account data.\n * @param options.factory - The address of the SimpleFactory contract.\n * @param options.implementations - The DeleGator implementation contracts.\n * @param options.implementation - The implementation type to use.\n * @param options.deployParams - The deployment parameters for the specified implementation.\n * @param options.deploySalt - The salt to use for CREATE2 address computation.\n * @returns An object containing the counterfactual address and factory calldata.\n * @description This function calculates the address a DeleGator contract would have if deployed,\n * and provides the calldata needed to deploy it.\n */\nexport const getCounterfactualAccountData = async <\n TImplementation extends Implementation,\n>({\n factory,\n implementations,\n implementation,\n deployParams,\n deploySalt,\n}: {\n factory: Address;\n implementations: SmartAccountsEnvironment['implementations'];\n implementation: TImplementation;\n deployParams: DeployParams<TImplementation>;\n deploySalt: Hex;\n}): Promise<{ factoryData: Hex; address: Address }> => {\n let implementationAddress: Address;\n let initcode: Hex;\n\n switch (implementation) {\n case Implementation.Hybrid: {\n const [owner, keyIds, xValues, yValues] =\n deployParams as HybridDeleGatorDeployParams;\n\n if (!implementations.HybridDeleGatorImpl) {\n throw new Error(\n 'HybridDeleGatorImpl address not provided in environment',\n );\n }\n\n implementationAddress = implementations.HybridDeleGatorImpl;\n\n const p256Owners = keyIds.map((keyId, index) => {\n const xValue = xValues[index];\n const yValue = yValues[index];\n\n if (!xValue || !yValue) {\n throw new Error(\n `Missing X or Y value for keyId ${keyId} at index ${index}`,\n );\n }\n\n return {\n keyId,\n x: xValue,\n y: yValue,\n };\n });\n\n initcode = initializeHybridDeleGator({ eoaOwner: owner, p256Owners });\n break;\n }\n case Implementation.MultiSig: {\n const [owners, threshold] = deployParams as MultiSigDeleGatorDeployParams;\n\n if (!implementations.MultiSigDeleGatorImpl) {\n throw new Error(\n 'MultiSigDeleGatorImpl address not provided in environment',\n );\n }\n\n implementationAddress = implementations.MultiSigDeleGatorImpl;\n initcode = initializeMultiSigDeleGator({ owners, threshold });\n break;\n }\n case Implementation.Stateless7702:\n default:\n throw new Error(`Implementation type '${implementation}' not supported`);\n }\n\n const salt = pad(deploySalt, { dir: 'left', size: 32 });\n\n const proxyCreationCode = encodeProxyCreationCode({\n implementationAddress,\n initcode,\n });\n\n const address = getContractAddress({\n bytecode: proxyCreationCode,\n from: factory,\n opcode: 'CREATE2',\n salt,\n });\n\n const factoryData = encodeCreate2Deploy(proxyCreationCode, salt);\n\n return {\n factoryData,\n address,\n };\n};\n","import { DelegationManager } from '@metamask/delegation-abis';\nimport { encodeFunctionData } from 'viem';\nimport type { Address, Hex } from 'viem';\n\nimport type { DelegatedCall } from './actions/erc7710RedeemDelegationAction';\nimport { encodeDelegations } from './delegation';\nimport {\n execute,\n executeWithMode,\n} from './DelegationFramework/DeleGatorCore/encode';\nimport {\n ExecutionMode,\n createExecution,\n encodeExecutionCalldatas,\n} from './executions';\nimport type { Call } from './types';\n\n/**\n * Checks if a call is a delegated call by checking for the presence of permissionContext and delegationManager.\n *\n * @param call - The call to check.\n * @returns True if the call is a delegated call, false otherwise.\n */\nconst isDelegatedCall = (call: Call): call is DelegatedCall => {\n return 'permissionContext' in call && 'delegationManager' in call;\n};\n\n/**\n * If there's a single call with permissionContext and delegationManager,\n * processes it as a delegated call.\n *\n * @param call - The call to process.\n * @returns The execution object for the delegated call.\n * @description\n * This function creates an execution that calls redeemDelegations on the delegation manager.\n */\nconst processDelegatedCall = (call: DelegatedCall) => {\n const {\n permissionContext,\n delegationManager,\n to: target,\n value,\n data: callData,\n } = call;\n\n const callAsExecution = createExecution({ target, value, callData });\n\n if (!permissionContext) {\n return callAsExecution;\n }\n\n const encodedPermissionsContext = encodeDelegations(permissionContext);\n\n const redeemCalldata = encodeFunctionData({\n abi: DelegationManager,\n functionName: 'redeemDelegations',\n args: [\n [encodedPermissionsContext],\n [ExecutionMode.SingleDefault],\n encodeExecutionCalldatas([[callAsExecution]]),\n ],\n });\n\n return createExecution({\n target: delegationManager,\n callData: redeemCalldata,\n });\n};\n\n/**\n * If there's a single call, encode the shorthand `execute` function. Otherwise, encode the `executeWithMode` function. Execution type will always be \"default\".\n *\n * @param calls - The calls to execute.\n * @returns The encoded calldata for the DeleGator to execute the calls.\n * @description\n * This function supports both single and batch execution modes.\n * For single calls, it uses the gas-efficient execute function.\n */\nexport const encodeCalls = (calls: readonly Call[]) => {\n if (calls.length === 1) {\n const call = calls[0];\n if (call && !isDelegatedCall(call)) {\n const { to: target, value, data: callData } = call;\n const execution = createExecution({ target, value, callData });\n return execute({ execution });\n }\n }\n\n const executions = calls.map((call) => {\n if (isDelegatedCall(call)) {\n return processDelegatedCall(call);\n }\n const { to: target, value, data: callData } = call;\n return createExecution({ target, value, callData });\n });\n\n const mode =\n calls.length === 1\n ? ExecutionMode.SingleDefault\n : ExecutionMode.BatchDefault;\n return executeWithMode({ mode, executions });\n};\n\n/**\n * Encodes calls for execution by a DeleGator smart contract.\n *\n * @param caller - The address of the DeleGator contract.\n * @param calls - An array of Call objects, each containing 'to', optional 'data', and optional 'value'.\n * @returns A promise that resolves to the encoded function data as a hexadecimal string.\n * @description\n * - If there's a single call directly to the delegator, it returns the call data directly.\n * - For multiple calls or calls to other addresses, it creates executions and encodes them for the DeleGator's execute function.\n * - The execution mode is set to ExecutionMode.SingleDefault for a single call, or ExecutionMode.BatchDefault for multiple calls.\n *\n * todo: This doesn't fully expose the flexibility of the DeleGator's execute function, but it's a start.\n * maybe we add a mechanism where individual calls passed to this function can be encoded batches.\n */\nexport const encodeCallsForCaller = async (\n caller: Address,\n calls: readonly Call[],\n): Promise<Hex> => {\n if (calls.length === 1) {\n const call = calls[0];\n if (call?.to === caller && !isDelegatedCall(call)) {\n // if there's a single call, and it's to the delegator, we can just return the calldata directly.\n return call.data ?? '0x';\n }\n }\n return encodeCalls(calls);\n};\n","import { Signature } from 'ox';\nimport {\n parseAbiParameters,\n encodeAbiParameters,\n type Hex,\n encodePacked,\n keccak256,\n concat,\n hexToBytes,\n} from 'viem';\n\nexport const FIELD_MODULUS =\n 115792089210356248762697446949407573529996955224135760342422259061068512044369n;\nexport const MALLEABILITY_THRESHOLD = FIELD_MODULUS / 2n;\n\nexport const SIGNATURE_ABI_PARAMS = parseAbiParameters(\n 'bytes32, uint256, uint256, bytes, bool, string, string, uint256',\n);\n\n/**\n * This function is used to convert the client data returned from the\n * credentials API into a format that can be consumed by the DeleGator\n * contracts. We need the flattend JSON strings before and after the\n * userOpHash/challenge. This function provides those two client data string\n * slices.\n *\n * @param clientDataJson - The client data JSON string.\n * @returns Returns [clientDataJSONPrefix and clientDataJSONSuffix]\n * ClientDataJSONPrefix contains the client data till the challengeHash\n * ClientDataJSONSuffix contains the client data after the challengeHash.\n */\nexport const splitOnChallenge = (\n clientDataJson: string,\n): [clientDataJSONPrefix: string, clientDataJSONSuffix: string] => {\n /*\n CientData looks like this:\n {\n \"type\": \"webauthn.create\" | \"webauthn.get\",\n \"challenge\": \"{userOpHash}\",\n \"origin\": \"{Domain}\",\n \"crossOrigin\": boolean\n }\n */\n try {\n const { challenge } = JSON.parse(clientDataJson);\n if (challenge === undefined) {\n throw new Error('No \"challenge\" found in the input string');\n }\n return clientDataJson.split(challenge) as [string, string];\n } catch (error) {\n throw new Error('No \"challenge\" found in the input string', {\n cause: error,\n });\n }\n};\n\n/**\n * Returns the index of '\"type\":' in the ClientData.\n *\n * @param clientDataJson - Stringified ClientDataJSON.\n * @returns The index of '\"type\":' in the ClientData.\n */\nexport const getResponseTypeLocation = (clientDataJson: string): bigint => {\n try {\n // Find the index of the `\"type\":` key in the JSON string directly\n const typeIndex = clientDataJson.indexOf('\"type\":');\n\n if (typeIndex === -1) {\n throw new Error('No \"type\" found in the input string');\n }\n // Return the index of the `\"type\":` key\n return BigInt(typeIndex);\n } catch (error) {\n // Handle any errors that occur during the search\n throw new Error('No \"type\" found in the input string', {\n cause: error,\n });\n }\n};\n\n/**\n * Encodes a signature to a hexadecimal signature that will be accepted\n * by the DeleGator contracts.\n *\n * @param keyId - The key used for the signature, represented as a hexadecimal string.\n * @param signature - The signature to convert, as Hex.\n * @param clientDataJSON - The client data used in the creation of the signature.\n * @param authenticatorData - The authenticator data used in the creation of the signature.\n * @returns The signature as a valid DeleGator signature encoded as Hexadecimal string.\n */\nexport function encodeDeleGatorSignature(\n keyId: string,\n signature: Hex,\n clientDataJSON: string,\n authenticatorData: Hex,\n): Hex {\n const keyIdHash = keccak256(encodePacked(['string'], [keyId]));\n\n const { r: rValue, s: sValue } = Signature.fromHex(signature);\n\n let normalizedS = sValue;\n\n while (normalizedS > MALLEABILITY_THRESHOLD) {\n normalizedS = FIELD_MODULUS - normalizedS;\n }\n\n const [clientDataComponent1, clientDataComponent2] =\n splitOnChallenge(clientDataJSON);\n\n const { userVerified } = parseAuthenticatorFlags(authenticatorData);\n\n const responseTypeLocation = getResponseTypeLocation(clientDataJSON);\n\n const encodedSignature = encodeAbiParameters(SIGNATURE_ABI_PARAMS, [\n keyIdHash,\n rValue,\n normalizedS,\n authenticatorData,\n userVerified,\n clientDataComponent1,\n clientDataComponent2,\n responseTypeLocation,\n ]);\n return encodedSignature;\n}\n\nconst AUTHENTICATOR_DATA_FLAGS_OFFSET = 32;\n// We have all of the flag bits defined here for completeness, even though we only extract the userVerified flag.\nenum AuthenticatorDataFlagBitIndex {\n UserPresence = 0,\n UserVerified = 2,\n BackupEligibility = 3,\n BackupState = 4,\n AttestedCredentialData = 6,\n ExtensionData = 7,\n}\n\nexport type AuthenticatorFlags = {\n userVerified: boolean;\n};\n\n/**\n * Parses the authenticator data and returns an authenticator flags object with the `userVerified` flag.\n * See https://developer.mozilla.org/en-US/docs/Web/API/Web_Authentication_API/Authenticator_data.\n *\n * @param authenticatorData - The authenticator data to parse.\n * @returns An object representing the parsed authenticator flags.\n */\nexport function parseAuthenticatorFlags(\n authenticatorData: Hex,\n): AuthenticatorFlags {\n const authenticatorDataBuffer = hexToBytes(authenticatorData);\n const dataBufferUint8 = new Uint8Array(authenticatorDataBuffer);\n const flags = dataBufferUint8[AUTHENTICATOR_DATA_FLAGS_OFFSET];\n if (flags === undefined) {\n throw new Error('Authenticator flags not found in authenticator data');\n }\n\n // Bit 0 is the least significant bit in the flags byte, so we left shift 0b1 by the bit index\n // eslint-disable-next-line no-bitwise\n const bitMask = 0b1 << AuthenticatorDataFlagBitIndex.UserVerified;\n\n return {\n // eslint-disable-next-line no-bitwise\n userVerified: (flags & bitMask) !== 0x0,\n };\n}\n\n/**\n * Creates a dummy signature.\n * This must meet all early-failure conditions of the real signature, but does not need to be a valid signature.\n *\n * @param keyId - The key ID to use for the dummy signature.\n * @returns The encoded signature.\n */\nexport const createDummyWebAuthnSignature = (keyId: Hex) => {\n // https://developer.mozilla.org/en-US/docs/Web/API/Web_Authentication_API/Authenticator_data#data_structure\n const rpIdHash = keccak256(encodePacked(['string'], ['AuthenticatorData']));\n const flags = '0x05';\n const signCount = '0x00000000';\n const authenticatorData = concat([rpIdHash, flags, signCount]);\n\n const keyIdHash = keccak256(encodePacked(['string'], [keyId]));\n const rs =\n 57896044605178124381348723474703786764998477612067880171211129530534256022184n;\n const userVerification = true;\n const clientDataPrefix = '{\"type\":\"webauthn.get\",\"challenge\":\"';\n const clientDataSuffix = '\",\"origin\":\"passkey-domain\",\"crossOrigin\":false}';\n const responseTypeLocation = 1n;\n\n const encodedSignature = encodeAbiParameters(SIGNATURE_ABI_PARAMS, [\n keyIdHash,\n rs,\n rs,\n authenticatorData,\n userVerification,\n clientDataPrefix,\n clientDataSuffix,\n responseTypeLocation,\n ]);\n\n return encodedSignature;\n};\n"]}
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
read_exports3,
|
|
5
5
|
read_exports4,
|
|
6
6
|
read_exports5
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-DVJX76J3.mjs";
|
|
8
8
|
import {
|
|
9
9
|
getSmartAccountsEnvironment,
|
|
10
10
|
prepareSignUserOperationTypedData
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
prepareSignDelegationTypedData,
|
|
22
22
|
toHexOrThrow,
|
|
23
23
|
trackSmartAccountsKitFunctionCall
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-EEIIVBNV.mjs";
|
|
25
25
|
|
|
26
26
|
// src/actions/index.ts
|
|
27
27
|
var actions_exports = {};
|
|
@@ -163,7 +163,7 @@ async function sendUserOperationWithDelegationAction(client, parameters) {
|
|
|
163
163
|
// src/actions/erc7715Mapping.ts
|
|
164
164
|
import { getAddress, hexToNumber, isAddress, toHex } from "viem";
|
|
165
165
|
function permissionRequestToRpc(parameters) {
|
|
166
|
-
const { chainId, from, expiry, redeemer } = parameters;
|
|
166
|
+
const { chainId, from, expiry, redeemer, payee } = parameters;
|
|
167
167
|
const converter = getPermissionRequestToRpcConverter(
|
|
168
168
|
parameters.permission.type
|
|
169
169
|
);
|
|
@@ -194,6 +194,24 @@ function permissionRequestToRpc(parameters) {
|
|
|
194
194
|
data: { addresses }
|
|
195
195
|
});
|
|
196
196
|
}
|
|
197
|
+
if (isDefined(payee)) {
|
|
198
|
+
if (payee.length === 0) {
|
|
199
|
+
throw new Error(
|
|
200
|
+
"Invalid payees: must specify at least one payee address"
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
const payeeAddresses = [];
|
|
204
|
+
for (const addr of payee) {
|
|
205
|
+
if (!isAddress(addr)) {
|
|
206
|
+
throw new Error("Invalid payees: must be a valid address");
|
|
207
|
+
}
|
|
208
|
+
payeeAddresses.push(getAddress(addr));
|
|
209
|
+
}
|
|
210
|
+
rules.push({
|
|
211
|
+
type: "payee",
|
|
212
|
+
data: { addresses: payeeAddresses }
|
|
213
|
+
});
|
|
214
|
+
}
|
|
197
215
|
const optionalFields = {
|
|
198
216
|
...from ? { from } : {}
|
|
199
217
|
};
|
|
@@ -219,10 +237,18 @@ function getPermissionRequestToRpcConverter(permissionType) {
|
|
|
219
237
|
return (permission) => nativeTokenPeriodicPermissionToRpc(
|
|
220
238
|
permission
|
|
221
239
|
);
|
|
240
|
+
case "native-token-allowance":
|
|
241
|
+
return (permission) => nativeTokenAllowancePermissionToRpc(
|
|
242
|
+
permission
|
|
243
|
+
);
|
|
222
244
|
case "erc20-token-periodic":
|
|
223
245
|
return (permission) => erc20TokenPeriodicPermissionToRpc(
|
|
224
246
|
permission
|
|
225
247
|
);
|
|
248
|
+
case "erc20-token-allowance":
|
|
249
|
+
return (permission) => erc20TokenAllowancePermissionToRpc(
|
|
250
|
+
permission
|
|
251
|
+
);
|
|
226
252
|
case "erc20-token-revocation":
|
|
227
253
|
return (permission) => erc20TokenRevocationPermissionToRpc(
|
|
228
254
|
permission
|
|
@@ -346,6 +372,47 @@ function erc20TokenPeriodicPermissionToRpc(permission) {
|
|
|
346
372
|
isAdjustmentAllowed
|
|
347
373
|
};
|
|
348
374
|
}
|
|
375
|
+
function nativeTokenAllowancePermissionToRpc(permission) {
|
|
376
|
+
const {
|
|
377
|
+
data: { allowanceAmount, startTime, justification },
|
|
378
|
+
isAdjustmentAllowed
|
|
379
|
+
} = permission;
|
|
380
|
+
const optionalFields = {
|
|
381
|
+
...isDefined(startTime) && {
|
|
382
|
+
startTime: Number(startTime)
|
|
383
|
+
},
|
|
384
|
+
...justification ? { justification } : {}
|
|
385
|
+
};
|
|
386
|
+
return {
|
|
387
|
+
type: "native-token-allowance",
|
|
388
|
+
data: {
|
|
389
|
+
allowanceAmount: toHexOrThrow(allowanceAmount, "allowanceAmount"),
|
|
390
|
+
...optionalFields
|
|
391
|
+
},
|
|
392
|
+
isAdjustmentAllowed
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
function erc20TokenAllowancePermissionToRpc(permission) {
|
|
396
|
+
const {
|
|
397
|
+
data: { tokenAddress, allowanceAmount, startTime, justification },
|
|
398
|
+
isAdjustmentAllowed
|
|
399
|
+
} = permission;
|
|
400
|
+
const optionalFields = {
|
|
401
|
+
...isDefined(startTime) && {
|
|
402
|
+
startTime: Number(startTime)
|
|
403
|
+
},
|
|
404
|
+
...justification ? { justification } : {}
|
|
405
|
+
};
|
|
406
|
+
return {
|
|
407
|
+
type: "erc20-token-allowance",
|
|
408
|
+
data: {
|
|
409
|
+
tokenAddress: toHexOrThrow(tokenAddress, "tokenAddress"),
|
|
410
|
+
allowanceAmount: toHexOrThrow(allowanceAmount, "allowanceAmount"),
|
|
411
|
+
...optionalFields
|
|
412
|
+
},
|
|
413
|
+
isAdjustmentAllowed
|
|
414
|
+
};
|
|
415
|
+
}
|
|
349
416
|
function erc20TokenRevocationPermissionToRpc(permission) {
|
|
350
417
|
const {
|
|
351
418
|
data: { justification },
|
|
@@ -373,7 +440,7 @@ function normalizeRulesFromRpc(rules) {
|
|
|
373
440
|
return rules;
|
|
374
441
|
}
|
|
375
442
|
return rules.map((rule) => {
|
|
376
|
-
if (rule.type !== "redeemer") {
|
|
443
|
+
if (rule.type !== "redeemer" && rule.type !== "payee") {
|
|
377
444
|
return rule;
|
|
378
445
|
}
|
|
379
446
|
const rawAddresses = rule.data?.addresses;
|
|
@@ -381,7 +448,7 @@ function normalizeRulesFromRpc(rules) {
|
|
|
381
448
|
return rule;
|
|
382
449
|
}
|
|
383
450
|
return {
|
|
384
|
-
type:
|
|
451
|
+
type: rule.type,
|
|
385
452
|
data: {
|
|
386
453
|
addresses: rawAddresses.map((addr) => getAddress(addr))
|
|
387
454
|
}
|
|
@@ -408,6 +475,11 @@ function permissionTypeFromRpc(permission) {
|
|
|
408
475
|
if ("maxAmount" in convertedData && convertedData.maxAmount) {
|
|
409
476
|
convertedData.maxAmount = BigInt(convertedData.maxAmount);
|
|
410
477
|
}
|
|
478
|
+
if ("allowanceAmount" in convertedData && convertedData.allowanceAmount) {
|
|
479
|
+
convertedData.allowanceAmount = BigInt(
|
|
480
|
+
convertedData.allowanceAmount
|
|
481
|
+
);
|
|
482
|
+
}
|
|
411
483
|
return {
|
|
412
484
|
...permission,
|
|
413
485
|
data: convertedData
|
|
@@ -907,4 +979,4 @@ export {
|
|
|
907
979
|
erc7710BundlerActions,
|
|
908
980
|
actions_exports
|
|
909
981
|
};
|
|
910
|
-
//# sourceMappingURL=chunk-
|
|
982
|
+
//# sourceMappingURL=chunk-R2WT54GZ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/actions/index.ts","../src/actions/erc7710RedeemDelegationAction.ts","../src/actions/erc7715Mapping.ts","../src/actions/erc7715GetGrantedExecutionPermissionsAction.ts","../src/actions/erc7715GetSupportedExecutionPermissionsAction.ts","../src/actions/erc7715RequestExecutionPermissionsAction.ts","../src/actions/getCaveatAvailableAmount.ts","../src/actions/isValid7702Implementation.ts","../src/actions/signDelegation.ts","../src/actions/signUserOperation.ts"],"sourcesContent":["import type { Client, WalletClient } from 'viem';\nimport type { BundlerClient } from 'viem/account-abstraction';\n\nimport type {\n SendTransactionWithDelegationParameters,\n SendUserOperationWithDelegationParameters,\n} from './erc7710RedeemDelegationAction';\nimport {\n sendTransactionWithDelegationAction,\n sendUserOperationWithDelegationAction,\n} from './erc7710RedeemDelegationAction';\nimport { erc7715GetGrantedExecutionPermissionsAction } from './erc7715GetGrantedExecutionPermissionsAction';\nimport { erc7715GetSupportedExecutionPermissionsAction } from './erc7715GetSupportedExecutionPermissionsAction';\nimport { erc7715RequestExecutionPermissionsAction } from './erc7715RequestExecutionPermissionsAction';\nimport type {\n MetaMaskExtensionClient,\n RequestExecutionPermissionsParameters,\n} from './erc7715RequestExecutionPermissionsAction';\n\nexport {\n // Individual action functions\n getErc20PeriodTransferEnforcerAvailableAmount,\n getErc20StreamingEnforcerAvailableAmount,\n getMultiTokenPeriodEnforcerAvailableAmount,\n getNativeTokenPeriodTransferEnforcerAvailableAmount,\n getNativeTokenStreamingEnforcerAvailableAmount,\n // Action builder\n caveatEnforcerActions,\n // Parameter types\n type CaveatEnforcerParams,\n // Result types\n type PeriodTransferResult,\n type StreamingResult,\n} from './getCaveatAvailableAmount';\n\nexport { isValid7702Implementation } from './isValid7702Implementation';\n\n// Signing actions\nexport {\n signDelegation,\n signDelegationActions,\n type SignDelegationParameters,\n type SignDelegationReturnType,\n} from './signDelegation';\n\nexport {\n signUserOperation,\n signUserOperationActions,\n type SignUserOperationParameters,\n type SignUserOperationReturnType,\n} from './signUserOperation';\n\nexport {\n erc7715RequestExecutionPermissionsAction as requestExecutionPermissions,\n type MetaMaskExtensionClient,\n type MetaMaskExtensionSchema,\n type RequestExecutionPermissionsParameters,\n type RequestExecutionPermissionsReturnType,\n} from './erc7715RequestExecutionPermissionsAction';\n\nexport type { PermissionRequestParameter } from './erc7715Types';\n\nexport { erc7715GetSupportedExecutionPermissionsAction as getSupportedExecutionPermissions } from './erc7715GetSupportedExecutionPermissionsAction';\n\nexport { erc7715GetGrantedExecutionPermissionsAction as getGrantedExecutionPermissions } from './erc7715GetGrantedExecutionPermissionsAction';\n\nexport {\n type GetSupportedExecutionPermissionsResult,\n type GetGrantedExecutionPermissionsResult,\n type Rule,\n type SupportedPermissionInfo,\n type PermissionTypes,\n type NativeTokenStreamPermission,\n type NativeTokenPeriodicPermission,\n type NativeTokenAllowancePermission,\n type Erc20TokenStreamPermission,\n type Erc20TokenPeriodicPermission,\n type Erc20TokenAllowancePermission,\n type Erc20TokenRevocationPermission,\n type RpcGetSupportedExecutionPermissionsResult,\n type RpcGetGrantedExecutionPermissionsResult,\n type RpcSupportedPermissionInfo,\n} from './erc7715Types';\n\nexport type { DelegatedCall } from './erc7710RedeemDelegationAction';\n\nexport const erc7715ProviderActions = () => (client: Client) => ({\n requestExecutionPermissions: async (\n parameters: RequestExecutionPermissionsParameters,\n ) => {\n return erc7715RequestExecutionPermissionsAction(\n client as MetaMaskExtensionClient,\n parameters,\n );\n },\n getSupportedExecutionPermissions: async () => {\n return erc7715GetSupportedExecutionPermissionsAction(\n client as MetaMaskExtensionClient,\n );\n },\n getGrantedExecutionPermissions: async () => {\n return erc7715GetGrantedExecutionPermissionsAction(\n client as MetaMaskExtensionClient,\n );\n },\n});\n\n/**\n * Type for a viem Client extended with ERC-7715 provider actions.\n * Use this to type variables that will be assigned an extended client later.\n *\n * @example\n * ```typescript\n * let client: Erc7715Client | null = null;\n *\n * function setupClient() {\n * client = createWalletClient({\n * chain: sepolia,\n * transport: custom(window.ethereum),\n * }).extend(erc7715ProviderActions());\n * }\n * ```\n */\nexport type Erc7715Client = Client &\n ReturnType<ReturnType<typeof erc7715ProviderActions>>;\n\nexport const erc7710WalletActions = () => (client: WalletClient) => ({\n sendTransactionWithDelegation: async (\n args: SendTransactionWithDelegationParameters,\n ) => sendTransactionWithDelegationAction(client, args),\n});\n\nexport const erc7710BundlerActions = () => (client: Client) => ({\n sendUserOperationWithDelegation: async (\n args: SendUserOperationWithDelegationParameters,\n ) => sendUserOperationWithDelegationAction(client as BundlerClient, args),\n});\n","import { DelegationManager } from '@metamask/delegation-abis';\nimport type {\n Account,\n Chain,\n Hex,\n OneOf,\n PublicClient,\n SendTransactionParameters,\n SendTransactionRequest,\n Transport,\n WalletClient,\n} from 'viem';\nimport { concat, encodeFunctionData, isAddressEqual } from 'viem';\nimport type {\n BundlerClient,\n SendUserOperationParameters,\n SmartAccount,\n} from 'viem/account-abstraction';\n\nimport { trackSmartAccountsKitFunctionCall } from '../analytics';\nimport { encodeDelegations } from '../delegation';\nimport {\n createExecution,\n encodeExecutionCalldatas,\n ExecutionMode,\n} from '../executions';\nimport { getSmartAccountsEnvironment } from '../smartAccountsEnvironment';\nimport type { Call, PermissionContext } from '../types';\n\nexport type DelegatedCall = Call &\n OneOf<\n { permissionContext: PermissionContext; delegationManager: Hex } | object\n >;\n\nexport type SendTransactionWithDelegationParameters<\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends Account | undefined = Account | undefined,\n TChainOverride extends Chain | undefined = Chain | undefined,\n TRequest extends SendTransactionRequest<TChain, TChainOverride> =\n SendTransactionRequest<TChain, TChainOverride>,\n> = SendTransactionParameters<TChain, TAccount, TChainOverride, TRequest> & {\n permissionContext: PermissionContext;\n delegationManager: Hex;\n};\n\n/**\n * Sends a transaction using delegation to execute operations on behalf of another account.\n *\n * @param client - The wallet client to use for sending the transaction.\n * @param args - Transaction parameters with delegation details.\n * @returns Transaction hash of the executed transaction.\n */\nexport async function sendTransactionWithDelegationAction<\n TChain extends Chain | undefined,\n TAccount extends Account | undefined,\n>(\n client: WalletClient<Transport, TChain, TAccount>,\n args: SendTransactionWithDelegationParameters<TChain, TAccount>,\n) {\n trackSmartAccountsKitFunctionCall('sendTransactionWithDelegationAction', {\n chainId: client.chain?.id ?? null,\n });\n\n if (!args.to) {\n throw new Error(\n '`to` is required. `sendTransactionWithDelegation` cannot be used to deploy contracts.',\n );\n }\n\n // Validate DelegationManager address\n const chainId = client.chain?.id;\n if (!chainId) {\n throw new Error('Chain ID is not set');\n }\n\n const { DelegationManager: expectedDelegationManager } =\n getSmartAccountsEnvironment(chainId);\n if (!isAddressEqual(args.delegationManager, expectedDelegationManager)) {\n throw new Error(\n `Invalid DelegationManager: expected ${expectedDelegationManager} for chain ${chainId}, but got ${args.delegationManager}`,\n );\n }\n\n const executions = [\n createExecution({\n target: args.to,\n value: args.value,\n callData: args.data,\n }),\n ];\n\n const calldata = encodeFunctionData({\n abi: DelegationManager,\n functionName: 'redeemDelegations',\n args: [\n [encodeDelegations(args.permissionContext)],\n [ExecutionMode.SingleDefault],\n encodeExecutionCalldatas([executions]),\n ],\n });\n\n const {\n value: _value,\n permissionContext: _permissionContext,\n delegationManager: _delegationManager,\n ...rest\n } = args;\n\n const hash = await client.sendTransaction({\n ...rest,\n to: args.delegationManager,\n data: calldata,\n } as unknown as SendTransactionParameters);\n\n return hash;\n}\n\nexport type SendUserOperationWithDelegationParameters<\n TAccount extends SmartAccount | undefined = SmartAccount | undefined,\n TAccountOverride extends SmartAccount | undefined = SmartAccount | undefined,\n> = SendUserOperationParameters<TAccount, TAccountOverride, DelegatedCall[]> & {\n dependencies?: { factory: Hex; factoryData: Hex }[];\n calls: DelegatedCall[];\n publicClient: PublicClient<Transport, Chain>;\n};\n\n/**\n * Broadcasts a User Operation with delegation to the Bundler.\n *\n * @param client - Client to use for sending the user operation.\n * @param parameters - Parameters for the user operation with delegation.\n * @returns The User Operation hash of the broadcasted operation.\n * @example\n * import { createBundlerClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const bundlerClient = createBundlerClient({\n * chain: mainnet,\n * transport: http(),\n * })\n *\n * const userOpHash = await sendUserOperationWithDelegationAction(bundlerClient, {\n * account: bobSmartAccount,\n * calls: [\n * {\n * to: aliceCounterContractAddress,\n * data: encodeFunctionData({\n * abi: CounterMetadata.abi,\n * functionName: 'increment',\n * }),\n * value: 0n,\n * permissionContext: '0x...',\n * delegationManager: '0x...',\n * },\n * ],\n * dependencies: [{ factory: '0x...', factoryData: '0x...' }], // Optional: for deploying accounts\n * })\n */\nexport async function sendUserOperationWithDelegationAction<\n TAccount extends SmartAccount | undefined,\n TAccountOverride extends SmartAccount | undefined = undefined,\n>(\n client: BundlerClient<Transport, Chain | undefined, TAccount>,\n parameters: SendUserOperationWithDelegationParameters<\n TAccount,\n TAccountOverride\n >,\n) {\n trackSmartAccountsKitFunctionCall('sendUserOperationWithDelegationAction', {\n chainId: client.chain?.id ?? null,\n callCount: parameters.calls.length,\n hasDependencies: parameters.dependencies !== undefined,\n });\n\n if (parameters.dependencies) {\n const { publicClient } = parameters;\n\n const includedAccountKeys: Record<Hex, boolean> = {};\n\n const chainId = publicClient.chain?.id;\n\n if (!chainId) {\n throw new Error('Chain ID is not set');\n }\n\n const { SimpleFactory } = getSmartAccountsEnvironment(chainId);\n\n const uniqueDependencies = parameters.dependencies.filter((dependency) => {\n if (!isAddressEqual(dependency.factory, SimpleFactory)) {\n throw new Error(\n `Invalid dependency: ${dependency.factory} is not allowed.`,\n );\n }\n\n // ensure that factory calls are not duplicated\n const accountKey = concat([dependency.factory, dependency.factoryData]);\n const isDuplicate = includedAccountKeys[accountKey];\n\n includedAccountKeys[accountKey] = true;\n return !isDuplicate;\n });\n\n const factoryCalls = (\n await Promise.all(\n uniqueDependencies.map(async ({ factory, factoryData }) => {\n const isDeployed = await publicClient\n .call({\n to: factory,\n data: factoryData,\n })\n .then(() => false)\n .catch(() => true);\n\n if (isDeployed) {\n return undefined;\n }\n return {\n to: factory,\n value: 0n,\n data: factoryData,\n };\n }),\n )\n ).filter((call: Call | undefined) => call !== undefined) as Call[];\n\n parameters.calls = [\n ...(factoryCalls as DelegatedCall[]),\n ...parameters.calls,\n ];\n }\n\n parameters.calls = parameters.calls.map((call) => {\n if (!('permissionContext' in call)) {\n return call;\n }\n\n const { permissionContext } = call;\n if (!permissionContext) {\n return call;\n }\n\n return {\n ...call,\n permissionContext: encodeDelegations(permissionContext),\n };\n });\n\n return client.sendUserOperation(\n parameters as unknown as SendUserOperationParameters,\n );\n}\n","import type {\n Erc20TokenAllowancePermission as RpcErc20TokenAllowancePermission,\n Erc20TokenPeriodicPermission as RpcErc20TokenPeriodicPermission,\n Erc20TokenStreamPermission as RpcErc20TokenStreamPermission,\n Erc20TokenRevocationPermission as RpcErc20TokenRevocationPermission,\n NativeTokenAllowancePermission as RpcNativeTokenAllowancePermission,\n NativeTokenPeriodicPermission as RpcNativeTokenPeriodicPermission,\n NativeTokenStreamPermission as RpcNativeTokenStreamPermission,\n PermissionRequest,\n PermissionTypes as RpcPermissionTypes,\n Rule,\n} from '@metamask/7715-permission-types';\nimport { getAddress, hexToNumber, isAddress, toHex, type Hex } from 'viem';\n\nimport { isDefined, toHexOrThrow } from '../utils';\nimport type {\n Erc20TokenAllowancePermission,\n Erc20TokenPeriodicPermission,\n Erc20TokenRevocationPermission,\n Erc20TokenStreamPermission,\n GetGrantedExecutionPermissionsResult,\n GetSupportedExecutionPermissionsResult,\n NativeTokenAllowancePermission,\n NativeTokenPeriodicPermission,\n NativeTokenStreamPermission,\n PermissionRequestParameter,\n PermissionTypes as DeveloperPermissionTypes,\n RpcGetGrantedExecutionPermissionsResult,\n RpcGetSupportedExecutionPermissionsResult,\n} from './erc7715Types';\n\n// =============================================================================\n// Developer → RPC (request formatting)\n// =============================================================================\n\n/**\n * Converts a developer permission request to RPC format for wallet submission.\n *\n * @param parameters the permission request parameters\n * @returns the permission request in RPC format\n */\nexport function permissionRequestToRpc(\n parameters: PermissionRequestParameter,\n): PermissionRequest<RpcPermissionTypes> {\n const { chainId, from, expiry, redeemer, payee } = parameters;\n\n const converter = getPermissionRequestToRpcConverter(\n parameters.permission.type,\n );\n\n const rules: Rule[] = [];\n if (isDefined(expiry)) {\n rules.push({\n type: 'expiry',\n data: {\n timestamp: expiry,\n },\n });\n }\n if (isDefined(redeemer)) {\n if (redeemer.length === 0) {\n throw new Error(\n 'Invalid redeemers: must specify at least one redeemer address',\n );\n }\n const addresses: Hex[] = [];\n for (const addr of redeemer) {\n if (!isAddress(addr)) {\n throw new Error('Invalid redeemers: must be a valid address');\n }\n addresses.push(getAddress(addr));\n }\n rules.push({\n type: 'redeemer',\n data: { addresses },\n });\n }\n if (isDefined(payee)) {\n if (payee.length === 0) {\n throw new Error(\n 'Invalid payees: must specify at least one payee address',\n );\n }\n const payeeAddresses: Hex[] = [];\n for (const addr of payee) {\n if (!isAddress(addr)) {\n throw new Error('Invalid payees: must be a valid address');\n }\n payeeAddresses.push(getAddress(addr));\n }\n rules.push({\n type: 'payee',\n data: { addresses: payeeAddresses },\n });\n }\n\n const optionalFields = {\n ...(from ? { from } : {}),\n };\n\n return {\n ...optionalFields,\n chainId: toHex(chainId),\n permission: converter(parameters.permission),\n to: parameters.to,\n rules,\n };\n}\n\ntype PermissionRequestToRpcConverter = (\n permission: DeveloperPermissionTypes,\n) => RpcPermissionTypes;\n\n/**\n * Get the permission request to RPC converter for the given permission type.\n *\n * @param permissionType the permission type\n * @returns the permission request to RPC converter for the given permission type\n */\nfunction getPermissionRequestToRpcConverter(\n permissionType: string,\n): PermissionRequestToRpcConverter {\n switch (permissionType) {\n case 'native-token-stream':\n return (permission) =>\n nativeTokenStreamPermissionToRpc(\n permission as NativeTokenStreamPermission,\n );\n case 'erc20-token-stream':\n return (permission) =>\n erc20TokenStreamPermissionToRpc(\n permission as Erc20TokenStreamPermission,\n );\n case 'native-token-periodic':\n return (permission) =>\n nativeTokenPeriodicPermissionToRpc(\n permission as NativeTokenPeriodicPermission,\n );\n case 'native-token-allowance':\n return (permission) =>\n nativeTokenAllowancePermissionToRpc(\n permission as NativeTokenAllowancePermission,\n );\n case 'erc20-token-periodic':\n return (permission) =>\n erc20TokenPeriodicPermissionToRpc(\n permission as Erc20TokenPeriodicPermission,\n );\n case 'erc20-token-allowance':\n return (permission) =>\n erc20TokenAllowancePermissionToRpc(\n permission as Erc20TokenAllowancePermission,\n );\n case 'erc20-token-revocation':\n return (permission) =>\n erc20TokenRevocationPermissionToRpc(\n permission as Erc20TokenRevocationPermission,\n );\n default:\n throw new Error(`Unsupported permission type: ${permissionType}`);\n }\n}\n\n/**\n * Convert native token stream permission to RPC format.\n *\n * @param permission the native token stream permission\n * @returns the native token stream permission in RPC format\n */\nfunction nativeTokenStreamPermissionToRpc(\n permission: NativeTokenStreamPermission,\n): RpcNativeTokenStreamPermission {\n const {\n data: {\n initialAmount,\n justification,\n maxAmount,\n startTime,\n amountPerSecond,\n },\n isAdjustmentAllowed,\n } = permission;\n\n const optionalFields = {\n ...(isDefined(initialAmount) && {\n initialAmount: toHexOrThrow(initialAmount, 'initialAmount'),\n }),\n ...(isDefined(maxAmount) && {\n maxAmount: toHexOrThrow(maxAmount, 'maxAmount'),\n }),\n ...(isDefined(startTime) && {\n startTime: Number(startTime),\n }),\n ...(justification ? { justification } : {}),\n };\n\n return {\n type: 'native-token-stream',\n data: {\n amountPerSecond: toHexOrThrow(amountPerSecond, 'amountPerSecond'),\n ...optionalFields,\n },\n isAdjustmentAllowed,\n };\n}\n\n/**\n * Convert ERC20 token stream permission to RPC format.\n *\n * @param permission the erc20 token stream permission\n * @returns the erc20 token stream permission in RPC format\n */\nfunction erc20TokenStreamPermissionToRpc(\n permission: Erc20TokenStreamPermission,\n): RpcErc20TokenStreamPermission {\n const {\n data: {\n tokenAddress,\n amountPerSecond,\n initialAmount,\n startTime,\n maxAmount,\n justification,\n },\n isAdjustmentAllowed,\n } = permission;\n\n const optionalFields = {\n ...(isDefined(initialAmount) && {\n initialAmount: toHexOrThrow(initialAmount, 'initialAmount'),\n }),\n ...(isDefined(maxAmount) && {\n maxAmount: toHexOrThrow(maxAmount, 'maxAmount'),\n }),\n ...(isDefined(startTime) && {\n startTime: Number(startTime),\n }),\n ...(justification ? { justification } : {}),\n };\n\n return {\n type: 'erc20-token-stream',\n data: {\n tokenAddress: toHexOrThrow(tokenAddress, 'tokenAddress'),\n amountPerSecond: toHexOrThrow(amountPerSecond, 'amountPerSecond'),\n ...optionalFields,\n },\n isAdjustmentAllowed,\n };\n}\n\n/**\n * Convert native token periodic permission to RPC format.\n *\n * @param permission the native token periodic permission\n * @returns the native token periodic permission in RPC format\n */\nfunction nativeTokenPeriodicPermissionToRpc(\n permission: NativeTokenPeriodicPermission,\n): RpcNativeTokenPeriodicPermission {\n const {\n data: { periodAmount, periodDuration, startTime, justification },\n isAdjustmentAllowed,\n } = permission;\n\n const optionalFields = {\n ...(isDefined(startTime) && {\n startTime: Number(startTime),\n }),\n ...(justification ? { justification } : {}),\n };\n\n return {\n type: 'native-token-periodic',\n data: {\n periodAmount: toHexOrThrow(periodAmount, 'periodAmount'),\n periodDuration: Number(periodDuration),\n ...optionalFields,\n },\n isAdjustmentAllowed,\n };\n}\n\n/**\n * Convert ERC20 token periodic permission to RPC format.\n *\n * @param permission the erc20 token periodic permission\n * @returns the erc20 token periodic permission in RPC format\n */\nfunction erc20TokenPeriodicPermissionToRpc(\n permission: Erc20TokenPeriodicPermission,\n): RpcErc20TokenPeriodicPermission {\n const {\n data: {\n tokenAddress,\n periodAmount,\n periodDuration,\n startTime,\n justification,\n },\n isAdjustmentAllowed,\n } = permission;\n\n const optionalFields = {\n ...(isDefined(startTime) && {\n startTime: Number(startTime),\n }),\n ...(justification ? { justification } : {}),\n };\n\n return {\n type: 'erc20-token-periodic',\n data: {\n tokenAddress: toHexOrThrow(tokenAddress, 'tokenAddress'),\n periodAmount: toHexOrThrow(periodAmount, 'periodAmount'),\n periodDuration: Number(periodDuration),\n ...optionalFields,\n },\n isAdjustmentAllowed,\n };\n}\n\n/**\n * Convert native token fixed allowance permission to RPC format.\n *\n * @param permission the native token fixed allowance permission\n * @returns the native token fixed allowance permission in RPC format\n */\nfunction nativeTokenAllowancePermissionToRpc(\n permission: NativeTokenAllowancePermission,\n): RpcNativeTokenAllowancePermission {\n const {\n data: { allowanceAmount, startTime, justification },\n isAdjustmentAllowed,\n } = permission;\n\n const optionalFields = {\n ...(isDefined(startTime) && {\n startTime: Number(startTime),\n }),\n ...(justification ? { justification } : {}),\n };\n\n return {\n type: 'native-token-allowance',\n data: {\n allowanceAmount: toHexOrThrow(allowanceAmount, 'allowanceAmount'),\n ...optionalFields,\n },\n isAdjustmentAllowed,\n };\n}\n\n/**\n * Convert ERC-20 token fixed allowance permission to RPC format.\n *\n * @param permission the ERC-20 token fixed allowance permission\n * @returns the ERC-20 token fixed allowance permission in RPC format\n */\nfunction erc20TokenAllowancePermissionToRpc(\n permission: Erc20TokenAllowancePermission,\n): RpcErc20TokenAllowancePermission {\n const {\n data: { tokenAddress, allowanceAmount, startTime, justification },\n isAdjustmentAllowed,\n } = permission;\n\n const optionalFields = {\n ...(isDefined(startTime) && {\n startTime: Number(startTime),\n }),\n ...(justification ? { justification } : {}),\n };\n\n return {\n type: 'erc20-token-allowance',\n data: {\n tokenAddress: toHexOrThrow(tokenAddress, 'tokenAddress'),\n allowanceAmount: toHexOrThrow(allowanceAmount, 'allowanceAmount'),\n ...optionalFields,\n },\n isAdjustmentAllowed,\n };\n}\n\n/**\n * Convert ERC20 token revocation permission to RPC format.\n *\n * @param permission the erc20 token revocation permission\n * @returns the erc20 token revocation permission in RPC format\n */\nfunction erc20TokenRevocationPermissionToRpc(\n permission: Erc20TokenRevocationPermission,\n): RpcErc20TokenRevocationPermission {\n const {\n data: { justification },\n isAdjustmentAllowed,\n } = permission;\n\n const data = {\n ...(justification ? { justification } : {}),\n };\n return {\n type: 'erc20-token-revocation',\n data,\n isAdjustmentAllowed,\n };\n}\n\n// =============================================================================\n// RPC → Developer friendly types (response conversion)\n// =============================================================================\n\n/**\n * Converts RPC permission responses to developer-friendly types.\n * Converts chainId from hex to number, and token amounts from hex to bigint.\n *\n * @param result the RPC permission responses\n * @returns the developer-friendly permission responses\n */\nexport function permissionResponsesFromRpc(\n result: RpcGetGrantedExecutionPermissionsResult,\n): GetGrantedExecutionPermissionsResult {\n return result.map((permission) => ({\n ...permission,\n chainId: hexToNumber(permission.chainId),\n permission: permissionTypeFromRpc(permission.permission),\n rules: normalizeRulesFromRpc(permission.rules),\n }));\n}\n\n/**\n * Checksums addresses in `redeemer` and `payee` rules; other rules are returned unchanged.\n *\n * @param rules - Rules from the wallet RPC response.\n * @returns The same list with normalized addresses, or null/undefined if that was the input.\n */\nfunction normalizeRulesFromRpc(\n rules: Rule[] | null | undefined,\n): Rule[] | null | undefined {\n if (rules === undefined || rules === null) {\n return rules;\n }\n return rules.map((rule) => {\n if (rule.type !== 'redeemer' && rule.type !== 'payee') {\n return rule;\n }\n const rawAddresses = (rule.data as { addresses?: unknown } | undefined)\n ?.addresses;\n if (!Array.isArray(rawAddresses)) {\n return rule;\n }\n return {\n type: rule.type,\n data: {\n addresses: rawAddresses.map((addr) => getAddress(addr as Hex)),\n },\n };\n });\n}\n\n/**\n * Converts RPC permission type data to developer-friendly types.\n * Converts hex amount fields to bigint.\n *\n * @param permission the RPC permission\n * @returns the developer-friendly permission\n */\nexport function permissionTypeFromRpc(\n permission: RpcPermissionTypes,\n): DeveloperPermissionTypes {\n const convertedData: Record<string, unknown> = { ...permission.data };\n\n if ('amountPerSecond' in convertedData && convertedData.amountPerSecond) {\n convertedData.amountPerSecond = BigInt(\n convertedData.amountPerSecond as `0x${string}`,\n );\n }\n\n if ('periodAmount' in convertedData && convertedData.periodAmount) {\n convertedData.periodAmount = BigInt(\n convertedData.periodAmount as `0x${string}`,\n );\n }\n\n if ('initialAmount' in convertedData && convertedData.initialAmount) {\n convertedData.initialAmount = BigInt(\n convertedData.initialAmount as `0x${string}`,\n );\n }\n\n if ('maxAmount' in convertedData && convertedData.maxAmount) {\n convertedData.maxAmount = BigInt(convertedData.maxAmount as `0x${string}`);\n }\n\n if ('allowanceAmount' in convertedData && convertedData.allowanceAmount) {\n convertedData.allowanceAmount = BigInt(\n convertedData.allowanceAmount as `0x${string}`,\n );\n }\n\n return {\n ...permission,\n data: convertedData,\n } as DeveloperPermissionTypes;\n}\n\n/**\n * Converts RPC supported permissions result to developer-friendly types.\n * Converts chain IDs from hex to numbers.\n *\n * @param result the RPC supported permissions result\n * @returns the developer-friendly supported permissions result\n */\nexport function rpcSupportedPermissionsToDeveloper(\n result: RpcGetSupportedExecutionPermissionsResult,\n): GetSupportedExecutionPermissionsResult {\n const converted: GetSupportedExecutionPermissionsResult = {};\n\n for (const [permissionType, permissionInfo] of Object.entries(result)) {\n converted[permissionType] = {\n chainIds: permissionInfo.chainIds.map((chainId) => hexToNumber(chainId)),\n ruleTypes: permissionInfo.ruleTypes,\n };\n }\n\n return converted;\n}\n","import { trackSmartAccountsKitFunctionCall } from '../analytics';\nimport { permissionResponsesFromRpc } from './erc7715Mapping';\nimport type {\n GetGrantedExecutionPermissionsResult,\n MetaMaskExtensionClient,\n} from './erc7715Types';\n\nexport type { GetGrantedExecutionPermissionsResult } from './erc7715Types';\n\n/**\n * Retrieves all previously granted execution permissions from the wallet according to EIP-7715 specification.\n *\n * @param client - The client to use for the request.\n * @returns A promise that resolves to an array of granted permission responses.\n * @description\n * This function queries the wallet for all granted permissions that are not yet revoked.\n * Each permission response includes the chain ID, address, signer, permission details,\n * context, and dependency information.\n * @example\n * ```typescript\n * const grantedPermissions = await erc7715GetGrantedExecutionPermissionsAction(client);\n * // Returns an array of PermissionResponse objects with user-friendly types\n * ```\n */\nexport async function erc7715GetGrantedExecutionPermissionsAction(\n client: MetaMaskExtensionClient,\n): Promise<GetGrantedExecutionPermissionsResult> {\n trackSmartAccountsKitFunctionCall(\n 'erc7715GetGrantedExecutionPermissionsAction',\n {\n chainId: client.chain?.id ?? null,\n },\n );\n\n const result = await client.request(\n {\n method: 'wallet_getGrantedExecutionPermissions',\n params: [],\n },\n { retryCount: 0 },\n );\n\n if (!result) {\n throw new Error('Failed to get granted execution permissions');\n }\n\n return permissionResponsesFromRpc(result);\n}\n","import { trackSmartAccountsKitFunctionCall } from '../analytics';\nimport { rpcSupportedPermissionsToDeveloper } from './erc7715Mapping';\nimport type {\n GetSupportedExecutionPermissionsResult,\n MetaMaskExtensionClient,\n} from './erc7715Types';\n\nexport type { GetSupportedExecutionPermissionsResult } from './erc7715Types';\n\n/**\n * Retrieves the supported execution permission types from the wallet according to EIP-7715 specification.\n *\n * @param client - The client to use for the request.\n * @returns A promise that resolves to a record of supported permission types with their chain IDs and rule types.\n * @description\n * This function queries the wallet for the permission types it supports.\n * The result is keyed by permission type and includes the supported chain IDs and rule types.\n * @example\n * ```typescript\n * const supported = await erc7715GetSupportedExecutionPermissionsAction(client);\n * // Returns:\n * // {\n * // \"native-token-allowance\": {\n * // \"chainIds\": [1, 137],\n * // \"ruleTypes\": [\"expiry\", \"redeemer\", \"payee\"]\n * // },\n * // \"erc20-token-allowance\": {\n * // \"chainIds\": [1],\n * // \"ruleTypes\": [\"expiry\"]\n * // }\n * // }\n * //\n * // Which strings appear in `ruleTypes` is defined by the wallet; when supported,\n * // `\"redeemer\"` indicates the wallet accepts a redeemer execution rule and\n * // `\"payee\"` indicates the wallet accepts a payee execution rule.\n * ```\n */\nexport async function erc7715GetSupportedExecutionPermissionsAction(\n client: MetaMaskExtensionClient,\n): Promise<GetSupportedExecutionPermissionsResult> {\n trackSmartAccountsKitFunctionCall(\n 'erc7715GetSupportedExecutionPermissionsAction',\n {\n chainId: client.chain?.id ?? null,\n },\n );\n\n const result = await client.request(\n {\n method: 'wallet_getSupportedExecutionPermissions',\n params: [],\n },\n { retryCount: 0 },\n );\n\n if (!result) {\n throw new Error('Failed to get supported execution permissions');\n }\n\n return rpcSupportedPermissionsToDeveloper(result);\n}\n","import { trackSmartAccountsKitFunctionCall } from '../analytics';\nimport {\n permissionRequestToRpc,\n permissionResponsesFromRpc,\n} from './erc7715Mapping';\nimport type {\n GetGrantedExecutionPermissionsResult,\n MetaMaskExtensionClient,\n PermissionRequestParameter,\n} from './erc7715Types';\n\nexport type {\n GetGrantedExecutionPermissionsResult,\n GetSupportedExecutionPermissionsResult,\n MetaMaskExtensionClient,\n MetaMaskExtensionSchema,\n SupportedPermissionInfo,\n PermissionTypes,\n PermissionRequestParameter,\n} from './erc7715Types';\n\n/**\n * Parameters for the RequestExecutionPermissions action.\n *\n * @template Signer - The type of the signer, either an Address or Account.\n */\nexport type RequestExecutionPermissionsParameters =\n PermissionRequestParameter[];\n\n/**\n * Return type for the request execution permissions action.\n */\nexport type RequestExecutionPermissionsReturnType =\n GetGrantedExecutionPermissionsResult;\n\n/**\n * Grants permissions according to EIP-7715 specification.\n *\n * @template Signer - The type of the signer, either an Address or Account.\n * @param client - The client to use for the request.\n * @param parameters - The permissions requests to grant.\n * @returns A promise that resolves to the permission responses.\n * @description\n * This function formats the permissions requests and invokes the wallet method to grant permissions.\n * It will throw an error if the permissions could not be granted.\n */\nexport async function erc7715RequestExecutionPermissionsAction(\n client: MetaMaskExtensionClient,\n parameters: RequestExecutionPermissionsParameters,\n): Promise<RequestExecutionPermissionsReturnType> {\n trackSmartAccountsKitFunctionCall(\n 'erc7715RequestExecutionPermissionsAction',\n {\n chainId: client.chain?.id ?? null,\n requestCount: parameters.length,\n },\n );\n const formattedPermissionRequest = parameters.map(permissionRequestToRpc);\n\n const result = await client.request(\n {\n method: 'wallet_requestExecutionPermissions',\n params: formattedPermissionRequest,\n },\n { retryCount: 0 },\n );\n\n if (!result) {\n throw new Error('Failed to grant permissions');\n }\n\n return permissionResponsesFromRpc(result);\n}\n","import type { Address, Hex, Client } from 'viem';\n\nimport { trackSmartAccountsKitFunctionCall } from '../analytics';\nimport { hashDelegation } from '../delegation';\nimport * as ERC20PeriodTransferEnforcer from '../DelegationFramework/ERC20PeriodTransferEnforcer';\nimport * as ERC20StreamingEnforcer from '../DelegationFramework/ERC20StreamingEnforcer';\nimport * as MultiTokenPeriodEnforcer from '../DelegationFramework/MultiTokenPeriodEnforcer';\nimport * as NativeTokenPeriodTransferEnforcer from '../DelegationFramework/NativeTokenPeriodTransferEnforcer';\nimport * as NativeTokenStreamingEnforcer from '../DelegationFramework/NativeTokenStreamingEnforcer';\nimport type { SmartAccountsEnvironment, Delegation } from '../types';\n\n/**\n * Parameters for all caveat enforcer actions.\n */\nexport type CaveatEnforcerParams = {\n delegation: Delegation;\n};\n\n/**\n * Return type for period-based transfer enforcers\n */\nexport type PeriodTransferResult = {\n availableAmount: bigint;\n isNewPeriod: boolean;\n currentPeriod: bigint;\n};\n\n/**\n * Return type for streaming enforcers\n */\nexport type StreamingResult = {\n availableAmount: bigint;\n};\n\n/**\n * Finds a caveat that matches the specified enforcer address.\n *\n * @param config - The configuration object.\n * @param config.delegation - The delegation to search.\n * @param config.enforcerAddress - The enforcer address to match.\n * @param config.enforcerName - The name of the enforcer.\n * @returns The matching caveat.\n * @throws Error if no matching caveat is found.\n * @throws Error if multiple matching caveats are found.\n */\nfunction findMatchingCaveat({\n delegation,\n enforcerAddress,\n enforcerName,\n}: {\n delegation: Delegation;\n enforcerAddress: Address;\n enforcerName: keyof SmartAccountsEnvironment['caveatEnforcers'];\n}): { terms: Hex; args: Hex } {\n const matchingCaveats = delegation.caveats.filter(\n (caveat) => caveat.enforcer.toLowerCase() === enforcerAddress.toLowerCase(),\n );\n\n if (matchingCaveats.length === 0) {\n throw new Error(`No caveat found with enforcer matching ${enforcerName}`);\n }\n\n if (matchingCaveats.length > 1) {\n throw new Error(\n `Multiple caveats found with enforcer matching ${enforcerName}`,\n );\n }\n\n const [{ terms, args }] = matchingCaveats as unknown as [\n { terms: Hex; args: Hex },\n ];\n\n return {\n terms,\n args,\n };\n}\n\n/**\n * Gets the delegation manager address from environment.\n *\n * @param environment - The SmartAccountsEnvironment.\n * @returns The delegation manager address.\n */\nfunction getDelegationManager(environment: SmartAccountsEnvironment): Address {\n if (!environment.DelegationManager) {\n throw new Error('Delegation manager address not found');\n }\n\n return environment.DelegationManager;\n}\n\n/**\n * Gets the enforcer address from environment.\n *\n * @param config - The configuration object.\n * @param config.enforcerName - The name of the enforcer.\n * @param config.environment - The SmartAccountsEnvironment.\n * @returns The enforcer address.\n */\nfunction getEnforcerAddress({\n enforcerName,\n environment,\n}: {\n enforcerName: keyof SmartAccountsEnvironment['caveatEnforcers'];\n environment: SmartAccountsEnvironment;\n}): Address {\n const enforcerAddress = environment.caveatEnforcers[enforcerName];\n if (!enforcerAddress) {\n throw new Error(`${enforcerName} not found in environment`);\n }\n\n return enforcerAddress;\n}\n\n/**\n * Get available amount for ERC20 period transfer enforcer.\n *\n * @param client - The viem client.\n * @param environment - The SmartAccountsEnvironment.\n * @param params - The parameters for the ERC20 period transfer enforcer.\n * @returns Promise resolving to the period transfer result.\n */\nexport async function getErc20PeriodTransferEnforcerAvailableAmount(\n client: Client,\n environment: SmartAccountsEnvironment,\n params: CaveatEnforcerParams,\n): Promise<PeriodTransferResult> {\n trackSmartAccountsKitFunctionCall(\n 'getErc20PeriodTransferEnforcerAvailableAmount',\n {\n chainId: client.chain?.id ?? null,\n },\n );\n const enforcerName = 'ERC20PeriodTransferEnforcer';\n\n const delegationManager = getDelegationManager(environment);\n const enforcerAddress = getEnforcerAddress({\n enforcerName,\n environment,\n });\n\n const delegationHash = hashDelegation(params.delegation);\n const { terms } = findMatchingCaveat({\n delegation: params.delegation,\n enforcerAddress,\n enforcerName,\n });\n\n return ERC20PeriodTransferEnforcer.read.getAvailableAmount({\n client,\n contractAddress: enforcerAddress,\n delegationHash,\n delegationManager,\n terms,\n });\n}\n\n/**\n * Get available amount for ERC20 streaming enforcer.\n *\n * @param client - The viem client.\n * @param environment - The SmartAccountsEnvironment.\n * @param params - The parameters for the ERC20 streaming enforcer.\n * @returns Promise resolving to the streaming result.\n */\nexport async function getErc20StreamingEnforcerAvailableAmount(\n client: Client,\n environment: SmartAccountsEnvironment,\n params: CaveatEnforcerParams,\n): Promise<StreamingResult> {\n trackSmartAccountsKitFunctionCall(\n 'getErc20StreamingEnforcerAvailableAmount',\n {\n chainId: client.chain?.id ?? null,\n },\n );\n const enforcerName = 'ERC20StreamingEnforcer';\n const delegationManager = getDelegationManager(environment);\n const enforcerAddress = getEnforcerAddress({\n enforcerName,\n environment,\n });\n\n const delegationHash = hashDelegation(params.delegation);\n const { terms } = findMatchingCaveat({\n delegation: params.delegation,\n enforcerAddress,\n enforcerName,\n });\n\n return ERC20StreamingEnforcer.read.getAvailableAmount({\n client,\n contractAddress: enforcerAddress,\n delegationManager,\n delegationHash,\n terms,\n });\n}\n\n/**\n * Get available amount for multi-token period enforcer.\n *\n * @param client - The viem client.\n * @param environment - The SmartAccountsEnvironment.\n * @param params - The parameters for the multi-token period enforcer.\n * @returns Promise resolving to the period transfer result.\n */\nexport async function getMultiTokenPeriodEnforcerAvailableAmount(\n client: Client,\n environment: SmartAccountsEnvironment,\n params: CaveatEnforcerParams,\n): Promise<PeriodTransferResult> {\n trackSmartAccountsKitFunctionCall(\n 'getMultiTokenPeriodEnforcerAvailableAmount',\n {\n chainId: client.chain?.id ?? null,\n },\n );\n const enforcerName = 'MultiTokenPeriodEnforcer';\n const delegationManager = getDelegationManager(environment);\n const enforcerAddress = getEnforcerAddress({\n enforcerName,\n environment,\n });\n\n const delegationHash = hashDelegation(params.delegation);\n const { terms, args } = findMatchingCaveat({\n delegation: params.delegation,\n enforcerAddress,\n enforcerName,\n });\n\n return MultiTokenPeriodEnforcer.read.getAvailableAmount({\n client,\n contractAddress: enforcerAddress,\n delegationHash,\n delegationManager,\n terms,\n args,\n });\n}\n\n/**\n * Get available amount for native token period transfer enforcer.\n *\n * @param client - The viem client.\n * @param environment - The SmartAccountsEnvironment.\n * @param params - The parameters for the native token period transfer enforcer.\n * @returns Promise resolving to the period transfer result.\n */\nexport async function getNativeTokenPeriodTransferEnforcerAvailableAmount(\n client: Client,\n environment: SmartAccountsEnvironment,\n params: CaveatEnforcerParams,\n): Promise<PeriodTransferResult> {\n trackSmartAccountsKitFunctionCall(\n 'getNativeTokenPeriodTransferEnforcerAvailableAmount',\n {\n chainId: client.chain?.id ?? null,\n },\n );\n const enforcerName = 'NativeTokenPeriodTransferEnforcer';\n const delegationManager = getDelegationManager(environment);\n const enforcerAddress = getEnforcerAddress({\n enforcerName,\n environment,\n });\n\n const delegationHash = hashDelegation(params.delegation);\n const { terms } = findMatchingCaveat({\n delegation: params.delegation,\n enforcerAddress,\n enforcerName,\n });\n\n return NativeTokenPeriodTransferEnforcer.read.getAvailableAmount({\n client,\n contractAddress: enforcerAddress,\n delegationHash,\n delegationManager,\n terms,\n });\n}\n\n/**\n * Get available amount for native token streaming enforcer.\n *\n * @param client - The viem client.\n * @param environment - The SmartAccountsEnvironment.\n * @param params - The parameters for the native token streaming enforcer.\n * @returns Promise resolving to the streaming result.\n */\nexport async function getNativeTokenStreamingEnforcerAvailableAmount(\n client: Client,\n environment: SmartAccountsEnvironment,\n params: CaveatEnforcerParams,\n): Promise<StreamingResult> {\n trackSmartAccountsKitFunctionCall(\n 'getNativeTokenStreamingEnforcerAvailableAmount',\n {\n chainId: client.chain?.id ?? null,\n },\n );\n const enforcerName = 'NativeTokenStreamingEnforcer';\n const delegationManager = getDelegationManager(environment);\n const enforcerAddress = getEnforcerAddress({\n enforcerName,\n environment,\n });\n\n const delegationHash = hashDelegation(params.delegation);\n const { terms } = findMatchingCaveat({\n delegation: params.delegation,\n enforcerAddress,\n enforcerName,\n });\n\n return NativeTokenStreamingEnforcer.read.getAvailableAmount({\n client,\n contractAddress: enforcerAddress,\n delegationManager,\n delegationHash,\n terms,\n });\n}\n\n/**\n * Caveat enforcer actions for extending viem clients.\n *\n * @param params - The parameters object.\n * @param params.environment - The SmartAccountsEnvironment.\n * @returns A function that takes a client and returns the client extension with caveat enforcer actions.\n */\nexport const caveatEnforcerActions =\n ({ environment }: { environment: SmartAccountsEnvironment }) =>\n (client: Client) => ({\n /**\n * Get available amount for ERC20 period transfer enforcer.\n *\n * @param params - The parameters for the ERC20 period transfer enforcer.\n * @returns Promise resolving to the period transfer result.\n */\n getErc20PeriodTransferEnforcerAvailableAmount: async (\n params: CaveatEnforcerParams,\n ): Promise<PeriodTransferResult> => {\n return getErc20PeriodTransferEnforcerAvailableAmount(\n client,\n environment,\n params,\n );\n },\n\n /**\n * Get available amount for ERC20 streaming enforcer.\n *\n * @param params - The parameters for the ERC20 streaming enforcer.\n * @returns Promise resolving to the streaming result.\n */\n getErc20StreamingEnforcerAvailableAmount: async (\n params: CaveatEnforcerParams,\n ): Promise<StreamingResult> => {\n return getErc20StreamingEnforcerAvailableAmount(\n client,\n environment,\n params,\n );\n },\n\n /**\n * Get available amount for multi-token period enforcer.\n *\n * @param params - The parameters for the multi-token period enforcer.\n * @returns Promise resolving to the period transfer result.\n */\n getMultiTokenPeriodEnforcerAvailableAmount: async (\n params: CaveatEnforcerParams,\n ): Promise<PeriodTransferResult> => {\n return getMultiTokenPeriodEnforcerAvailableAmount(\n client,\n environment,\n params,\n );\n },\n\n /**\n * Get available amount for native token period transfer enforcer.\n *\n * @param params - The parameters for the native token period transfer enforcer.\n * @returns Promise resolving to the period transfer result.\n */\n getNativeTokenPeriodTransferEnforcerAvailableAmount: async (\n params: CaveatEnforcerParams,\n ): Promise<PeriodTransferResult> => {\n return getNativeTokenPeriodTransferEnforcerAvailableAmount(\n client,\n environment,\n params,\n );\n },\n\n /**\n * Get available amount for native token streaming enforcer.\n *\n * @param params - The parameters for the native token streaming enforcer.\n * @returns Promise resolving to the streaming result.\n */\n getNativeTokenStreamingEnforcerAvailableAmount: async (\n params: CaveatEnforcerParams,\n ): Promise<StreamingResult> => {\n return getNativeTokenStreamingEnforcerAvailableAmount(\n client,\n environment,\n params,\n );\n },\n });\n","import type { Client, Address, Hex } from 'viem';\nimport { isAddressEqual } from 'viem';\nimport { getCode } from 'viem/actions';\n\nimport type { SmartAccountsEnvironment } from '../types';\n\n// EIP-7702 delegation prefix (0xef0100)\nconst DELEGATION_PREFIX = '0xef0100' as const;\n\n/**\n * Parameters for checking if an account is delegated to the EIP-7702 implementation.\n */\nexport type IsValid7702ImplementationParameters = {\n /** The client to use for the query. */\n client: Client;\n /** The address to check for proper delegation. */\n accountAddress: Address;\n /** The SmartAccountsEnvironment containing contract addresses. */\n environment: SmartAccountsEnvironment;\n};\n\n/**\n * Extracts the delegated contract address from EIP-7702 delegation code.\n *\n * @param code - The code returned from getCode for a delegated account.\n * @returns The delegated contract address or null if not a valid delegation.\n */\nfunction extractDelegatedAddress(code: Hex | undefined): Address | null {\n if (code?.length !== 48) {\n // 0x (2 chars) + ef0100 (6 chars) + address (40 chars) = 48 chars\n return null;\n }\n\n if (!code.toLowerCase().startsWith(DELEGATION_PREFIX.toLowerCase())) {\n return null;\n }\n\n // Extract the 20-byte address after the delegation prefix\n const addressHex = code.slice(8); // Remove '0xef0100' prefix (8 chars)\n return `0x${addressHex}`;\n}\n\n/**\n * Checks if an account is properly delegated to the EIP-7702 implementation.\n *\n * This function validates EIP-7702 delegations by checking if the EOA has a 7702\n * contract assigned to it and comparing the delegated address against the 7702\n * implementation found in the environment.\n *\n * @param params - The parameters for checking the delegation.\n * @param params.client - The client to use for the query.\n * @param params.accountAddress - The address to check for proper delegation.\n * @param params.environment - The SmartAccountsEnvironment containing contract addresses.\n * @returns A promise that resolves to true if the account is properly delegated to the 7702 implementation, false otherwise.\n * @example\n * ```typescript\n * const isValid = await isValid7702Implementation({\n * client: publicClient,\n * accountAddress: '0x...',\n * environment: smartAccountEnvironment,\n * });\n *\n * if (isValid) {\n * console.log('Account is properly delegated to EIP-7702 implementation');\n * } else {\n * console.log('Account is not properly delegated');\n * }\n * ```\n */\nexport async function isValid7702Implementation({\n client,\n accountAddress,\n environment,\n}: IsValid7702ImplementationParameters): Promise<boolean> {\n try {\n // Get the code at the account address\n const code = await getCode(client, {\n address: accountAddress,\n });\n\n // Extract the delegated contract address from the EIP-7702 delegation code\n const delegatedAddress = extractDelegatedAddress(code);\n\n // If no valid delegation found, return false\n if (!delegatedAddress) {\n return false;\n }\n\n // Compare the delegated address with the 7702 implementation in the environment\n const expectedImplementation =\n environment.implementations.EIP7702StatelessDeleGatorImpl;\n if (!expectedImplementation) {\n return false;\n }\n\n return isAddressEqual(delegatedAddress, expectedImplementation);\n } catch {\n // If the call fails (e.g., no code at address, network error),\n // then it's not properly delegated to our implementation\n return false;\n }\n}\n","import type {\n Account,\n Address,\n Chain,\n Client,\n Hex,\n Transport,\n WalletClient,\n} from 'viem';\nimport { BaseError } from 'viem';\nimport { parseAccount } from 'viem/accounts';\n\nimport { prepareSignDelegationTypedData } from '../delegation';\nimport type { Delegation } from '../types';\n\nexport type SignDelegationParameters = {\n /** Account to sign with */\n account?: Account | Address;\n /** The delegation to sign */\n delegation: Omit<Delegation, 'signature'>;\n /** The address of the delegation manager contract */\n delegationManager: Address;\n /** The chain ID for the signature */\n chainId: number;\n /** The name of the contract */\n name?: string;\n /** The version of the contract */\n version?: string;\n /** Whether to allow insecure unrestricted delegation */\n allowInsecureUnrestrictedDelegation?: boolean;\n};\n\nexport type SignDelegationReturnType = Hex;\n\n/**\n * Signs a delegation using a wallet client.\n *\n * @param client - The wallet client to use for signing.\n * @param parameters - The parameters for signing the delegation.\n * @returns The signature of the delegation.\n * @example\n * ```ts\n * const signature = await signDelegation(walletClient, {\n * delegation: {\n * delegate: '0x...',\n * delegator: '0x...',\n * authority: '0x...',\n * caveats: [],\n * salt: '0x'\n * },\n * delegationManager: '0x...',\n * chainId: 1\n * });\n * ```\n */\nexport async function signDelegation<\n TChain extends Chain | undefined,\n TAccount extends Account | undefined,\n>(\n client: Client<Transport, TChain, TAccount> & {\n signTypedData: WalletClient['signTypedData'];\n },\n parameters: SignDelegationParameters,\n): Promise<SignDelegationReturnType> {\n const {\n account: accountParam = client.account,\n delegation,\n delegationManager,\n chainId,\n name = 'DelegationManager',\n version = '1',\n allowInsecureUnrestrictedDelegation = false,\n } = parameters;\n\n if (!accountParam) {\n throw new BaseError('Account not found. Please provide an account.');\n }\n\n const account = parseAccount(accountParam);\n\n const typedData = prepareSignDelegationTypedData({\n delegation,\n delegationManager,\n chainId,\n name,\n version,\n allowInsecureUnrestrictedDelegation,\n });\n\n return client.signTypedData({\n account,\n ...typedData,\n });\n}\n\n/**\n * Creates a sign delegation action that can be used to extend a wallet client.\n *\n * @returns A function that can be used with wallet client extend method.\n * @example\n * ```ts\n * const walletClient = createWalletClient({\n * chain: mainnet,\n * transport: http()\n * }).extend(signDelegationActions());\n * ```\n */\nexport function signDelegationActions() {\n return <\n TChain extends Chain | undefined,\n TAccount extends Account | undefined,\n >(\n client: Client<Transport, TChain, TAccount> & {\n signTypedData: WalletClient['signTypedData'];\n },\n ) => ({\n signDelegation: async (\n parameters: Omit<SignDelegationParameters, 'chainId'> & {\n chainId?: number;\n },\n ) =>\n signDelegation(client, {\n chainId:\n parameters.chainId ??\n (() => {\n if (!client.chain?.id) {\n throw new BaseError(\n 'Chain ID is required. Either provide it in parameters or configure the client with a chain.',\n );\n }\n return client.chain.id;\n })(),\n ...parameters,\n }),\n });\n}\n","import type {\n Account,\n Address,\n Chain,\n Client,\n Hex,\n Transport,\n WalletClient,\n} from 'viem';\nimport { BaseError } from 'viem';\nimport { parseAccount } from 'viem/accounts';\n\nimport { prepareSignUserOperationTypedData } from '../userOp';\nimport type { UserOperationV07 } from '../userOp';\n\nexport type SignUserOperationParameters = {\n /** Account to sign with */\n account?: Account | Address;\n /** The user operation to sign */\n userOperation: Omit<UserOperationV07, 'signature'>;\n /** The entry point contract address */\n entryPoint: { address: Address };\n /** The chain ID that the entry point is deployed on */\n chainId: number;\n /** The address of the smart account */\n address: Address;\n /** The name of the domain of the implementation contract */\n name: 'HybridDeleGator' | 'MultiSigDeleGator';\n /** The version of the domain of the implementation contract */\n version?: string;\n};\n\nexport type SignUserOperationReturnType = Hex;\n\n/**\n * Signs a user operation using a wallet client.\n *\n * @param client - The wallet client to use for signing.\n * @param parameters - The parameters for signing the user operation.\n * @returns The signature of the user operation.\n * @example\n * ```ts\n * const signature = await signUserOperation(walletClient, {\n * userOperation: {\n * sender: '0x...',\n * nonce: 0n,\n * callData: '0x',\n * callGasLimit: 1000000n,\n * verificationGasLimit: 1000000n,\n * preVerificationGas: 21000n,\n * maxFeePerGas: 1000000000n,\n * maxPriorityFeePerGas: 1000000000n\n * },\n * entryPoint: { address: '0x...' },\n * chainId: 1,\n * address: '0x...',\n * name: 'HybridDeleGator'\n * });\n * ```\n */\nexport async function signUserOperation<\n TChain extends Chain | undefined,\n TAccount extends Account | undefined,\n>(\n client: Client<Transport, TChain, TAccount> & {\n signTypedData: WalletClient['signTypedData'];\n },\n parameters: SignUserOperationParameters,\n): Promise<SignUserOperationReturnType> {\n const {\n account: accountParam = client.account,\n userOperation,\n entryPoint,\n chainId,\n name,\n address,\n version = '1',\n } = parameters;\n\n if (!accountParam) {\n throw new BaseError('Account not found. Please provide an account.');\n }\n\n const account = parseAccount(accountParam);\n\n const typedData = prepareSignUserOperationTypedData({\n userOperation,\n entryPoint,\n chainId,\n name,\n address,\n version,\n });\n\n return client.signTypedData({\n account,\n ...typedData,\n });\n}\n\n/**\n * Creates a sign user operation action that can be used to extend a wallet client.\n *\n * @returns A function that can be used with wallet client extend method.\n * @example\n * ```ts\n * const walletClient = createWalletClient({\n * chain: mainnet,\n * transport: http()\n * }).extend(signUserOperationActions());\n * ```\n */\nexport function signUserOperationActions() {\n return <\n TChain extends Chain | undefined,\n TAccount extends Account | undefined,\n >(\n client: Client<Transport, TChain, TAccount> & {\n signTypedData: WalletClient['signTypedData'];\n },\n ) => ({\n signUserOperation: async (\n parameters: Omit<SignUserOperationParameters, 'chainId'> & {\n chainId?: number;\n },\n ) =>\n signUserOperation(client, {\n chainId:\n parameters.chainId ??\n (() => {\n if (!client.chain?.id) {\n throw new BaseError(\n 'Chain ID is required. Either provide it in parameters or configure the client with a chain.',\n );\n }\n return client.chain.id;\n })(),\n ...parameters,\n }),\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,SAAS,yBAAyB;AAYlC,SAAS,QAAQ,oBAAoB,sBAAsB;AAwC3D,eAAsB,oCAIpB,QACA,MACA;AACA,oCAAkC,uCAAuC;AAAA,IACvE,SAAS,OAAO,OAAO,MAAM;AAAA,EAC/B,CAAC;AAED,MAAI,CAAC,KAAK,IAAI;AACZ,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAGA,QAAM,UAAU,OAAO,OAAO;AAC9B,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,qBAAqB;AAAA,EACvC;AAEA,QAAM,EAAE,mBAAmB,0BAA0B,IACnD,4BAA4B,OAAO;AACrC,MAAI,CAAC,eAAe,KAAK,mBAAmB,yBAAyB,GAAG;AACtE,UAAM,IAAI;AAAA,MACR,uCAAuC,yBAAyB,cAAc,OAAO,aAAa,KAAK,iBAAiB;AAAA,IAC1H;AAAA,EACF;AAEA,QAAM,aAAa;AAAA,IACjB,gBAAgB;AAAA,MACd,QAAQ,KAAK;AAAA,MACb,OAAO,KAAK;AAAA,MACZ,UAAU,KAAK;AAAA,IACjB,CAAC;AAAA,EACH;AAEA,QAAM,WAAW,mBAAmB;AAAA,IAClC,KAAK;AAAA,IACL,cAAc;AAAA,IACd,MAAM;AAAA,MACJ,CAAC,kBAAkB,KAAK,iBAAiB,CAAC;AAA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CAIL,YAGI;AAAA,IACJ,mBAAmB,OACjB,eAIA,kBAAkB,QAAQ;AAAA,MACxB,SACE,WAAW,YACV,MAAM;AACL,YAAI,CAAC,OAAO,OAAO,IAAI;AACrB,gBAAM,IAAID;AAAA,YACR;AAAA,UACF;AAAA,QACF;AACA,eAAO,OAAO,MAAM;AAAA,MACtB,GAAG;AAAA,MACL,GAAG;AAAA,IACL,CAAC;AAAA,EACL;AACF;;;ATtDO,IAAM,yBAAyB,MAAM,CAAC,YAAoB;AAAA,EAC/D,6BAA6B,OAC3B,eACG;AACH,WAAO;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA,EACA,kCAAkC,YAAY;AAC5C,WAAO;AAAA,MACL;AAAA,IACF;AAAA,EACF;AAAA,EACA,gCAAgC,YAAY;AAC1C,WAAO;AAAA,MACL;AAAA,IACF;AAAA,EACF;AACF;AAqBO,IAAM,uBAAuB,MAAM,CAAC,YAA0B;AAAA,EACnE,+BAA+B,OAC7B,SACG,oCAAoC,QAAQ,IAAI;AACvD;AAEO,IAAM,wBAAwB,MAAM,CAAC,YAAoB;AAAA,EAC9D,iCAAiC,OAC/B,SACG,sCAAsC,QAAyB,IAAI;AAC1E;","names":["read_exports","isAddressEqual","BaseError","parseAccount","BaseError","parseAccount"]}
|