@account-kit/wallet-client 0.1.0-alpha.10 → 0.1.0-alpha.11
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/dist/esm/client/actions/requestAccount.js +2 -2
- package/dist/esm/client/actions/requestAccount.js.map +1 -1
- package/dist/esm/client/actions/signSignatureRequest.d.ts +3 -3
- package/dist/esm/client/actions/signSignatureRequest.js.map +1 -1
- package/dist/esm/client/client.e2e-test.js +40 -1
- package/dist/esm/client/client.e2e-test.js.map +1 -1
- package/dist/esm/isomorphic/actions/createSession.js +2 -2
- package/dist/esm/isomorphic/actions/createSession.js.map +1 -1
- package/dist/esm/isomorphic/actions/getCallsStatus.js +2 -2
- package/dist/esm/isomorphic/actions/getCallsStatus.js.map +1 -1
- package/dist/esm/isomorphic/actions/prepareSign.js +2 -2
- package/dist/esm/isomorphic/actions/prepareSign.js.map +1 -1
- package/dist/esm/isomorphic/actions/sendPreparedCalls.js +37 -10
- package/dist/esm/isomorphic/actions/sendPreparedCalls.js.map +1 -1
- package/dist/esm/isomorphic/utils/createAccount.d.ts +2 -2
- package/dist/esm/isomorphic/utils/createAccount.js +1 -1
- package/dist/esm/isomorphic/utils/createAccount.js.map +1 -1
- package/dist/esm/isomorphic/utils/decodeSignature.d.ts +2 -2
- package/dist/esm/isomorphic/utils/decodeSignature.js +2 -2
- package/dist/esm/isomorphic/utils/decodeSignature.js.map +1 -1
- package/dist/esm/isomorphic/utils/parsePermissionsContext.d.ts +2 -2
- package/dist/esm/isomorphic/utils/parsePermissionsContext.js +1 -1
- package/dist/esm/isomorphic/utils/parsePermissionsContext.js.map +1 -1
- package/dist/esm/isomorphic/utils/supportsFeature.d.ts +2 -2
- package/dist/esm/isomorphic/utils/supportsFeature.js.map +1 -1
- package/dist/types/client/actions/signSignatureRequest.d.ts +3 -3
- package/dist/types/client/actions/signSignatureRequest.d.ts.map +1 -1
- package/dist/types/isomorphic/actions/prepareSign.d.ts.map +1 -1
- package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts.map +1 -1
- package/dist/types/isomorphic/utils/createAccount.d.ts +2 -2
- package/dist/types/isomorphic/utils/createAccount.d.ts.map +1 -1
- package/dist/types/isomorphic/utils/decodeSignature.d.ts +2 -2
- package/dist/types/isomorphic/utils/decodeSignature.d.ts.map +1 -1
- package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts +2 -2
- package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts.map +1 -1
- package/dist/types/isomorphic/utils/supportsFeature.d.ts +2 -2
- package/dist/types/isomorphic/utils/supportsFeature.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/client/actions/requestAccount.ts +2 -2
- package/src/client/actions/signSignatureRequest.ts +8 -8
- package/src/client/client.e2e-test.ts +270 -191
- package/src/isomorphic/actions/createSession.ts +2 -2
- package/src/isomorphic/actions/getCallsStatus.ts +2 -2
- package/src/isomorphic/actions/prepareSign.ts +2 -5
- package/src/isomorphic/actions/sendPreparedCalls.ts +46 -9
- package/src/isomorphic/utils/createAccount.ts +2 -2
- package/src/isomorphic/utils/decodeSignature.ts +6 -6
- package/src/isomorphic/utils/parsePermissionsContext.ts +2 -2
- package/src/isomorphic/utils/supportsFeature.ts +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendPreparedCalls.js","sourceRoot":"","sources":["../../../../src/isomorphic/actions/sendPreparedCalls.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,GAGd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EACL,SAAS,EACT,kBAAkB,EAClB,MAAM,EACN,SAAS,EACT,WAAW,EACX,cAAc,EACd,KAAK,GAKN,MAAM,MAAM,CAAC;AAKd,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAClF,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,gCAAgC,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AO,0FAA0F,CACzG,CAAC;YACJ,CAAC;YACD,MAAM,GAAG,CAAC;QACZ,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CACH,CAAC;IAEF,OAAO;QACL,eAAe,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACnC,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE;YACvB,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,IAAI;SACL,CAAC,CACH;KACF,CAAC;AACJ,CAAC","sourcesContent":["import {\n getEntryPoint,\n type SmartAccountClient,\n type SmartContractAccount,\n} from \"@aa-sdk/core\";\nimport { Value } from \"@sinclair/typebox/value\";\nimport {\n BaseError,\n ChainNotFoundError,\n concat,\n concatHex,\n numberToHex,\n parseSignature,\n toHex,\n type Address,\n type Chain,\n type Hex,\n type Transport,\n} from \"viem\";\nimport type {\n wallet_sendPreparedCalls,\n WalletServerViemRpcSchema,\n} from \"@alchemy/wallet-api-types/rpc\";\nimport { decodePermissionsContext } from \"@alchemy/wallet-api-types/capabilities\";\nimport { TypeCallId } from \"@alchemy/wallet-api-types\";\nimport { isSupportedDelegationAddress7702 } from \"../utils/7702.js\";\nimport { InvalidRequestError } from \"ox/RpcResponse\";\nimport { assertNever } from \"../../utils.js\";\nimport type { Static } from \"@sinclair/typebox\";\nimport { decodeSignature } from \"../utils/decodeSignature.js\";\n\nexport type SendPreparedCallsParams = Static<\n (typeof wallet_sendPreparedCalls)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n>[0];\n\nexport type SendPreparedCallsResult = Static<\n (typeof wallet_sendPreparedCalls)[\"properties\"][\"ReturnType\"]\n>;\n\n// TODO: this only supports MAv2 right now, we need to fix this\nexport async function sendPreparedCalls(\n client: SmartAccountClient<\n Transport,\n Chain,\n SmartContractAccount | undefined,\n Record<string, unknown>,\n WalletServerViemRpcSchema\n >,\n params: SendPreparedCallsParams,\n): Promise<SendPreparedCallsResult> {\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n\n const deferredAction: Hex | undefined = (() => {\n if (!params.capabilities?.permissions) {\n return;\n }\n\n const decodedContext = decodePermissionsContext(\n params.capabilities.permissions,\n );\n\n if (decodedContext.contextVersion === \"REMOTE_MODE_DEFERRED_ACTION\") {\n throw new InvalidRequestError({\n message:\n \"Remote mode deferred action not supported in isomorphic client\",\n });\n }\n\n return decodedContext.deferredAction;\n })();\n\n const userOps =\n params.type === \"array\"\n ? params.data.filter((it) => {\n const isUserOp =\n it.type === \"user-operation-v060\" ||\n it.type === \"user-operation-v070\";\n if (isUserOp && it.chainId !== toHex(client.chain.id)) {\n throw new InvalidRequestError({\n message:\n \"Multiple chain IDs in a single request are not currently supported.\",\n });\n }\n return isUserOp;\n })\n : [params];\n\n if (!userOps.length) {\n throw new InvalidRequestError({\n message: \"Calls must include at least one user operation\",\n });\n }\n\n const authorizations =\n params.type === \"array\"\n ? params.data.filter((it) => it.type === \"authorization\")\n : [];\n\n if (authorizations.length > 1) {\n throw new InvalidRequestError({\n message:\n \"Multiple authorizations in a single request are not currently supported\",\n });\n }\n const [authorization] = authorizations;\n\n // One last safety check to be sure the UO wasn't modified to include an unsupported 7702 delegation address.\n if (\n authorization &&\n !isSupportedDelegationAddress7702(authorization.data.address)\n ) {\n throw new InvalidRequestError({\n message: `Unsupported 7702 delegation address: ${authorization.data.address}`,\n });\n }\n\n const hashes = await Promise.all(\n userOps.map(async (userOp, idx) => {\n const ep: { address: Address } =\n userOp.type === \"user-operation-v060\"\n ? getEntryPoint(client.chain, { version: \"0.6.0\" })\n : userOp.type === \"user-operation-v070\"\n ? getEntryPoint(client.chain, { version: \"0.7.0\" })\n : assertNever(userOp, \"Unexpected user op type\");\n const authSig = authorization\n ? parseSignature(decodeSignature(authorization.signature).data)\n : undefined;\n const uoSigHex = decodeSignature(userOp.signature).data;\n\n const { counterfactualInfo, delegation } = await client.request({\n method: \"wallet_requestAccount\",\n params: [\n {\n accountAddress: userOp.data.sender,\n includeCounterfactualInfo: true,\n },\n ],\n });\n\n if (!counterfactualInfo && !delegation) {\n throw new InvalidRequestError({\n message:\n \"No counterfactual info or delegated implementation address found.\",\n });\n }\n\n const factoryType = counterfactualInfo?.factoryType;\n\n // build signature based on account type\n const signature = (() => {\n switch (factoryType) {\n // light accounts\n case \"LightAccountV1.0.1\":\n case \"LightAccountV1.0.2\":\n case \"LightAccountV1.1.0\":\n case \"MAv1.0.0-MultiOwner\":\n // For LAv1 and MAv1-MultiOwner, we always just pass the signature.\n return uoSigHex;\n case \"LightAccountV2.0.0\":\n // for LAv2, we need to prepend the \"SignatureType.EOA\" byte.\n // TODO: Once we support nested smart accounts, switch this byte depending on the signature type.\n return concat([\"0x00\", uoSigHex]);\n case undefined: // undefined defaults to sma-b\n case \"MAv2.0.0-sma-b\":\n // For sma-b, we need to handle deferred actions if needed and prepend the \"Reserved\n // Signature Segment\" and \"SignatureType.EOA\" bytes\n return deferredAction != null\n ? concatHex([\n `0x${deferredAction.slice(68)}`, // Cuts off stuff prepended to the digest (nonce, etc.).\n \"0xFF\",\n \"0x00\",\n uoSigHex,\n ])\n : concat([\"0xFF\", \"0x00\", uoSigHex]);\n case \"LightAccountV2.0.0-MultiOwner\":\n // for LAv2-MultiOwner, we need to prepend the \"SignatureType.EOA\" byte\n // TODO: Once we support nested smart accounts, switch this byte depending on the signature type, and add the smart account signer's address.\n return concat([\"0x00\", uoSigHex]);\n case \"MAv2.0.0-ma-ssv\":\n case \"MAv2.0.0-ma-webauthn\":\n case \"MAv1.0.0-MultiSig\":\n case \"unknown\":\n throw new InvalidRequestError({\n message: `Unsupported factory type: ${factoryType}`,\n });\n default:\n return assertNever(factoryType, \"Unsupported factory type\");\n }\n })();\n\n return client\n .sendRawUserOperation(\n {\n ...userOp.data,\n signature,\n eip7702Auth:\n idx === 0 && authorization && authSig\n ? {\n ...authorization.data,\n chainId: authorization.chainId,\n ...{\n ...authSig,\n yParity: numberToHex(authSig.yParity),\n },\n }\n : undefined,\n },\n ep.address,\n )\n .catch((err) => {\n if (\n err instanceof BaseError &&\n err.details.endsWith(\"is not a contract and initCode is empty\")\n ) {\n throw new BaseError(\n `${err.details} (If using 7702, be sure you include the signed authorization in the request parameters)`,\n );\n }\n throw err;\n });\n }),\n );\n\n return {\n preparedCallIds: hashes.map((hash) =>\n Value.Encode(TypeCallId, {\n chainId: toHex(client.chain.id),\n hash,\n }),\n ),\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sendPreparedCalls.js","sourceRoot":"","sources":["../../../../src/isomorphic/actions/sendPreparedCalls.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,GAGd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EACL,SAAS,EACT,kBAAkB,EAClB,MAAM,EACN,SAAS,EACT,WAAW,EACX,WAAW,EACX,cAAc,EACd,KAAK,GAKN,MAAM,MAAM,CAAC;AAKd,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAClF,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,OAAO,EAAE,gCAAgC,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAU9D,+DAA+D;AAC/D,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAMC,EACD,MAA+B;IAE/B,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAClB,MAAM,IAAI,kBAAkB,EAAE,CAAC;IACjC,CAAC;IAED,MAAM,cAAc,GAAoB,CAAC,GAAG,EAAE;QAC5C,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,WAAW,EAAE,CAAC;YACtC,OAAO;QACT,CAAC;QAED,MAAM,cAA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AC,IAAI;YACd,SAAS;YACT,WAAW,EACT,GAAG,KAAK,CAAC,IAAI,aAAa,IAAI,OAAO;gBACnC,CAAC,CAAC;oBACE,GAAG,aAAa,CAAC,IAAI;oBACrB,OAAO,EAAE,aAAa,CAAC,OAAO;oBAC9B,GAAG;wBACD,GAAG,OAAO;wBACV,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC;qBACtC;iBACF;gBACH,CAAC,CAAC,SAAS;SAChB,EACD,EAAE,CAAC,OAAO,CACX;aACA,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACb,IACE,GAAG,YAAY,SAAS;gBACxB,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,yCAAyC,CAAC,EAC/D,CAAC;gBACD,MAAM,IAAI,SAAS,CACjB,GAAG,GAAG,CAAC,OAAO,0FAA0F,CACzG,CAAC;YACJ,CAAC;YACD,MAAM,GAAG,CAAC;QACZ,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CACH,CAAC;IAEF,OAAO;QACL,eAAe,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACnC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE;YACnB,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,IAAI;SACL,CAAC,CACH;KACF,CAAC;AACJ,CAAC","sourcesContent":["import {\n getEntryPoint,\n type SmartAccountClient,\n type SmartContractAccount,\n} from \"@aa-sdk/core\";\nimport { Value } from \"@sinclair/typebox/value\";\nimport {\n BaseError,\n ChainNotFoundError,\n concat,\n concatHex,\n getContract,\n numberToHex,\n parseSignature,\n toHex,\n type Address,\n type Chain,\n type Hex,\n type Transport,\n} from \"viem\";\nimport type {\n wallet_sendPreparedCalls,\n WalletServerViemRpcSchema,\n} from \"@alchemy/wallet-api-types/rpc\";\nimport { decodePermissionsContext } from \"@alchemy/wallet-api-types/capabilities\";\nimport { CallId } from \"@alchemy/wallet-api-types\";\nimport { isSupportedDelegationAddress7702 } from \"../utils/7702.js\";\nimport { InvalidRequestError } from \"ox/RpcResponse\";\nimport { assertNever } from \"../../utils.js\";\nimport type { Static } from \"@sinclair/typebox\";\nimport { decodeSignature } from \"../utils/decodeSignature.js\";\n\nexport type SendPreparedCallsParams = Static<\n (typeof wallet_sendPreparedCalls)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n>[0];\n\nexport type SendPreparedCallsResult = Static<\n (typeof wallet_sendPreparedCalls)[\"properties\"][\"ReturnType\"]\n>;\n\n// TODO: this only supports MAv2 right now, we need to fix this\nexport async function sendPreparedCalls(\n client: SmartAccountClient<\n Transport,\n Chain,\n SmartContractAccount | undefined,\n Record<string, unknown>,\n WalletServerViemRpcSchema\n >,\n params: SendPreparedCallsParams,\n): Promise<SendPreparedCallsResult> {\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n\n const deferredAction: Hex | undefined = (() => {\n if (!params.capabilities?.permissions) {\n return;\n }\n\n const decodedContext = decodePermissionsContext(\n params.capabilities.permissions,\n );\n\n if (decodedContext.contextVersion === \"REMOTE_MODE_DEFERRED_ACTION\") {\n throw new InvalidRequestError({\n message:\n \"Remote mode deferred action not supported in isomorphic client\",\n });\n }\n\n return decodedContext.deferredAction;\n })();\n\n const userOps =\n params.type === \"array\"\n ? params.data.filter((it) => {\n const isUserOp =\n it.type === \"user-operation-v060\" ||\n it.type === \"user-operation-v070\";\n if (isUserOp && it.chainId !== toHex(client.chain.id)) {\n throw new InvalidRequestError({\n message:\n \"Multiple chain IDs in a single request are not currently supported.\",\n });\n }\n return isUserOp;\n })\n : [params];\n\n if (!userOps.length) {\n throw new InvalidRequestError({\n message: \"Calls must include at least one user operation\",\n });\n }\n\n const authorizations =\n params.type === \"array\"\n ? params.data.filter((it) => it.type === \"authorization\")\n : [];\n\n if (authorizations.length > 1) {\n throw new InvalidRequestError({\n message:\n \"Multiple authorizations in a single request are not currently supported\",\n });\n }\n const [authorization] = authorizations;\n\n // One last safety check to be sure the UO wasn't modified to include an unsupported 7702 delegation address.\n if (\n authorization &&\n !isSupportedDelegationAddress7702(authorization.data.address)\n ) {\n throw new InvalidRequestError({\n message: `Unsupported 7702 delegation address: ${authorization.data.address}`,\n });\n }\n\n const hashes = await Promise.all(\n userOps.map(async (userOp, idx) => {\n const ep: { address: Address } =\n userOp.type === \"user-operation-v060\"\n ? getEntryPoint(client.chain, { version: \"0.6.0\" })\n : userOp.type === \"user-operation-v070\"\n ? getEntryPoint(client.chain, { version: \"0.7.0\" })\n : assertNever(userOp, \"Unexpected user op type\");\n const authSig = authorization\n ? parseSignature(decodeSignature(authorization.signature).data)\n : undefined;\n const uoSigHex = decodeSignature(userOp.signature).data;\n\n const { counterfactualInfo, delegation } = await client.request({\n method: \"wallet_requestAccount\",\n params: [\n {\n accountAddress: userOp.data.sender,\n includeCounterfactualInfo: true,\n },\n ],\n });\n\n if (!counterfactualInfo && !delegation) {\n throw new InvalidRequestError({\n message:\n \"No counterfactual info or delegated implementation address found.\",\n });\n }\n\n const deferredActionData: Hex | undefined = deferredAction\n ? await (async () => {\n // determine whether the data should be appended to the signature.\n // logic ported from @account-kit/smart-contracts `modularAccountV2Base.ts`\n\n const deferredActionNonce = BigInt(\n `0x${deferredAction.slice(4, 68)}`,\n );\n\n const entryPoint = getEntryPoint(client.chain, {\n version: \"0.7.0\",\n });\n\n const entryPointContract = getContract({\n address: entryPoint.address,\n abi: entryPoint.abi,\n client,\n });\n\n // Set these values if the deferred action has not been consumed. We check this with the EP\n const nextNonceForDeferredAction: bigint =\n (await entryPointContract.read.getNonce([\n userOp.data.sender,\n deferredActionNonce >> 64n,\n ])) as bigint;\n\n if (deferredActionNonce === nextNonceForDeferredAction) {\n return `0x${deferredAction.slice(68)}`;\n } else if (deferredActionNonce > nextNonceForDeferredAction) {\n // if nonce is greater than the next nonce, its invalid, so we throw\n throw new InvalidRequestError({\n message: \"Invalid session nonce\",\n });\n }\n\n // In this case, the deferred action has already been consumed, so no data should be appended to the signature.\n // The signer entity should already be accounted for in `userOp.nonce`.\n return undefined;\n })()\n : undefined;\n\n const factoryType = counterfactualInfo?.factoryType;\n\n // build signature based on account type\n const signature = (() => {\n switch (factoryType) {\n // light accounts\n case \"LightAccountV1.0.1\":\n case \"LightAccountV1.0.2\":\n case \"LightAccountV1.1.0\":\n case \"MAv1.0.0-MultiOwner\":\n // For LAv1 and MAv1-MultiOwner, we always just pass the signature.\n return uoSigHex;\n case \"LightAccountV2.0.0\":\n // for LAv2, we need to prepend the \"SignatureType.EOA\" byte.\n // TODO: Once we support nested smart accounts, switch this byte depending on the signature type.\n return concat([\"0x00\", uoSigHex]);\n case undefined: // undefined defaults to sma-b\n case \"MAv2.0.0-sma-b\":\n // For sma-b, we need to handle deferred actions if needed and prepend the \"Reserved\n // Signature Segment\" and \"SignatureType.EOA\" bytes\n return deferredActionData != null\n ? concatHex([deferredActionData, \"0xFF\", \"0x00\", uoSigHex])\n : concat([\"0xFF\", \"0x00\", uoSigHex]);\n case \"LightAccountV2.0.0-MultiOwner\":\n // for LAv2-MultiOwner, we need to prepend the \"SignatureType.EOA\" byte\n // TODO: Once we support nested smart accounts, switch this byte depending on the signature type, and add the smart account signer's address.\n return concat([\"0x00\", uoSigHex]);\n case \"MAv2.0.0-ma-ssv\":\n case \"MAv2.0.0-ma-webauthn\":\n case \"MAv1.0.0-MultiSig\":\n case \"unknown\":\n throw new InvalidRequestError({\n message: `Unsupported factory type: ${factoryType}`,\n });\n default:\n return assertNever(factoryType, \"Unsupported factory type\");\n }\n })();\n\n return client\n .sendRawUserOperation(\n {\n ...userOp.data,\n signature,\n eip7702Auth:\n idx === 0 && authorization && authSig\n ? {\n ...authorization.data,\n chainId: authorization.chainId,\n ...{\n ...authSig,\n yParity: numberToHex(authSig.yParity),\n },\n }\n : undefined,\n },\n ep.address,\n )\n .catch((err) => {\n if (\n err instanceof BaseError &&\n err.details.endsWith(\"is not a contract and initCode is empty\")\n ) {\n throw new BaseError(\n `${err.details} (If using 7702, be sure you include the signed authorization in the request parameters)`,\n );\n }\n throw err;\n });\n }),\n );\n\n return {\n preparedCallIds: hashes.map((hash) =>\n Value.Encode(CallId, {\n chainId: toHex(client.chain.id),\n hash,\n }),\n ),\n };\n}\n"]}
|
|
@@ -2,14 +2,14 @@ import type { SmartAccountSigner, SmartContractAccount } from "@aa-sdk/core";
|
|
|
2
2
|
import { type ModularAccountV2 } from "@account-kit/smart-contracts";
|
|
3
3
|
import type { StaticDecode } from "@sinclair/typebox";
|
|
4
4
|
import type { Address, Chain, Transport } from "viem";
|
|
5
|
-
import {
|
|
5
|
+
import { SerializedInitcode } from "@alchemy/wallet-api-types";
|
|
6
6
|
import { PermissionsCapability } from "@alchemy/wallet-api-types/capabilities";
|
|
7
7
|
type CreateAccountParams = {
|
|
8
8
|
chain: Chain;
|
|
9
9
|
transport: Transport;
|
|
10
10
|
signer: SmartAccountSigner;
|
|
11
11
|
accountAddress: Address;
|
|
12
|
-
counterfactualInfo?: StaticDecode<typeof
|
|
12
|
+
counterfactualInfo?: StaticDecode<typeof SerializedInitcode>;
|
|
13
13
|
permissions?: StaticDecode<typeof PermissionsCapability>;
|
|
14
14
|
delegation?: Address;
|
|
15
15
|
};
|
|
@@ -3,7 +3,7 @@ import { concatHex, hexToNumber } from "viem";
|
|
|
3
3
|
import { parsePermissionsContext } from "./parsePermissionsContext.js";
|
|
4
4
|
import { assertNever } from "../../utils.js";
|
|
5
5
|
import { getAccountTypeForDelegationAddress7702 } from "./7702.js";
|
|
6
|
-
import {
|
|
6
|
+
import { SerializedInitcode } from "@alchemy/wallet-api-types";
|
|
7
7
|
import { PermissionsCapability } from "@alchemy/wallet-api-types/capabilities";
|
|
8
8
|
import { InternalError, InvalidRequestError } from "ox/RpcResponse";
|
|
9
9
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createAccount.js","sourceRoot":"","sources":["../../../../src/isomorphic/utils/createAccount.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBA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CAAC,CAAC;QACL,KAAK,oBAAoB;YACvB,OAAO,kBAAkB,CAAC;gBACxB,GAAG,YAAY;gBACf,OAAO,EAAE,QAAQ;aAClB,CAAC,CAAC;QACL,KAAK,oBAAoB;YACvB,OAAO,kBAAkB,CAAC;gBACxB,GAAG,YAAY;gBACf,OAAO,EAAE,QAAQ;aAClB,CAAC,CAAC;QACL,KAAK,oBAAoB;YACvB,OAAO,kBAAkB,CAAC;gBACxB,GAAG,YAAY;gBACf,OAAO,EAAE,QAAQ;aAClB,CAAC,CAAC;QACL,KAAK,oBAAoB;YACvB,OAAO,kBAAkB,CAAC;gBACxB,GAAG,YAAY;gBACf,OAAO,EAAE,QAAQ;aAClB,CAAC,CAAC;QACL,KAAK,qBAAqB;YACxB,OAAO,8BAA8B,CAAC;gBACpC,GAAG,YAAY;aAChB,CAAC,CAAC;QACL,KAAK,+BAA+B;YAClC,OAAO,4BAA4B,CAAC;gBAClC,GAAG,YAAY;gBACf,OAAO,EAAE,QAAQ;aAClB,CAAC,CAAC;QACL,KAAK,mBAAmB,CAAC;QACzB,KAAK,iBAAiB,CAAC;QACvB,KAAK,sBAAsB,CAAC;QAC5B,KAAK,SAAS,CAAC;QACf,KAAK,SAAS;YACZ,MAAM,IAAI,mBAAmB,CAAC;gBAC5B,OAAO,EAAE,uCAAuC,WAAW,EAAE;aAC9D,CAAC,CAAC;QACL;YACE,OAAO,WAAW,CAAC,WAAW,EAAE,0BAA0B,CAAC,CAAC;IAChE,CAAC;AACH,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,OAA6B;IAE7B,OAAO,OAAO,CAAC,MAAM,KAAK,kBAAkB,CAAC;AAC/C,CAAC","sourcesContent":["import type { SmartAccountSigner, SmartContractAccount } from \"@aa-sdk/core\";\nimport {\n createLightAccount,\n createModularAccountV2,\n createMultiOwnerLightAccount,\n createMultiOwnerModularAccount,\n type ModularAccountV2,\n} from \"@account-kit/smart-contracts\";\nimport type { StaticDecode } from \"@sinclair/typebox\";\nimport type { Address, Chain, Transport } from \"viem\";\nimport { concatHex, hexToNumber } from \"viem\";\nimport { parsePermissionsContext } from \"./parsePermissionsContext.js\";\nimport { assertNever } from \"../../utils.js\";\nimport { getAccountTypeForDelegationAddress7702 } from \"./7702.js\";\nimport { SerializedInitcode } from \"@alchemy/wallet-api-types\";\nimport { PermissionsCapability } from \"@alchemy/wallet-api-types/capabilities\";\nimport { InternalError, InvalidRequestError } from \"ox/RpcResponse\";\n\ntype CreateAccountParams = {\n chain: Chain;\n transport: Transport;\n signer: SmartAccountSigner;\n accountAddress: Address;\n counterfactualInfo?: StaticDecode<typeof SerializedInitcode>; // undefined for 7702 accounts\n permissions?: StaticDecode<typeof PermissionsCapability>;\n delegation?: Address;\n};\n\n/**\n * Creates a smart account instance from the given parameters.\n * @param params - The parameters for creating a smart account.\n * @returns A promise that resolves to the created smart account.\n */\nexport async function createAccount(\n params: CreateAccountParams,\n): Promise<SmartContractAccount> {\n const { counterfactualInfo: ci, ...accountParams } = params;\n\n // This throws if we pass a permission context and the account is not MA-v2\n // TODO: test that this edge case is handled correctly\n const parsedContext = parsePermissionsContext(\n params.permissions,\n ci,\n params.delegation,\n );\n\n const signerEntity =\n parsedContext?.contextVersion === \"NON_DEFERRED_ACTION\"\n ? {\n entityId: hexToNumber(parsedContext.entityId),\n isGlobalValidation: parsedContext.isGlobalValidation,\n }\n : undefined;\n\n const mode = params.delegation ? \"7702\" : \"default\";\n\n if (mode === \"7702\") {\n const accountType = getAccountTypeForDelegationAddress7702(\n params.delegation!,\n );\n if (accountType !== \"ModularAccountV2\") {\n throw new Error(\"7702 mode currently only supports ModularAccountV2\");\n }\n return createModularAccountV2({\n ...accountParams,\n signerEntity,\n deferredAction: parsedContext?.deferredAction,\n mode,\n });\n }\n\n if (mode !== \"default\") {\n return assertNever(mode, \"Unexpected mode in createAccount\");\n }\n\n // At this point, we are guaranteed to be in default mode, where ci\n // (counterfactualInfo) must be defined\n\n if (!ci) {\n throw new InternalError({\n message: \"Counterfactual info not found\",\n });\n }\n\n const factoryType = ci.factoryType;\n const commonParams = {\n ...accountParams,\n initCode: concatHex([ci.factoryAddress, ci.factoryData]),\n };\n\n // Return the account created based on the factory type\n switch (factoryType) {\n case \"MAv2.0.0-sma-b\":\n return createModularAccountV2({\n ...commonParams,\n signerEntity,\n deferredAction: parsedContext?.deferredAction,\n mode,\n });\n case \"LightAccountV2.0.0\":\n return createLightAccount({\n ...commonParams,\n version: \"v2.0.0\",\n });\n case \"LightAccountV1.0.1\":\n return createLightAccount({\n ...commonParams,\n version: \"v1.0.1\",\n });\n case \"LightAccountV1.0.2\":\n return createLightAccount({\n ...commonParams,\n version: \"v1.0.2\",\n });\n case \"LightAccountV1.1.0\":\n return createLightAccount({\n ...commonParams,\n version: \"v1.1.0\",\n });\n case \"MAv1.0.0-MultiOwner\":\n return createMultiOwnerModularAccount({\n ...commonParams,\n });\n case \"LightAccountV2.0.0-MultiOwner\":\n return createMultiOwnerLightAccount({\n ...commonParams,\n version: \"v2.0.0\",\n });\n case \"MAv1.0.0-MultiSig\":\n case \"MAv2.0.0-ma-ssv\":\n case \"MAv2.0.0-ma-webauthn\":\n case \"unknown\":\n case undefined:\n throw new InvalidRequestError({\n message: `Account type currently unsupported: ${factoryType}`,\n });\n default:\n return assertNever(factoryType, \"Unsupported factory type\");\n }\n}\n\nexport function isModularAccountV2(\n account: SmartContractAccount,\n): account is ModularAccountV2 {\n return account.source === \"ModularAccountV2\";\n}\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { StaticDecode } from "@sinclair/typebox";
|
|
2
|
-
import {
|
|
3
|
-
export declare const decodeSignature: (signature:
|
|
2
|
+
import { EcdsaSig, type EcdsaSig as EcdsaSigType } from "@alchemy/wallet-api-types";
|
|
3
|
+
export declare const decodeSignature: (signature: EcdsaSigType["signature"]) => StaticDecode<typeof EcdsaSig>["signature"];
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Value } from "@sinclair/typebox/value";
|
|
2
|
-
import {
|
|
2
|
+
import { EcdsaSig, } from "@alchemy/wallet-api-types";
|
|
3
3
|
import { assertNever } from "../../utils.js";
|
|
4
4
|
export const decodeSignature = (signature) => {
|
|
5
5
|
switch (signature.type) {
|
|
6
6
|
case "ecdsa":
|
|
7
7
|
case "secp256k1":
|
|
8
|
-
return Value.Decode(
|
|
8
|
+
return Value.Decode(EcdsaSig, {
|
|
9
9
|
signature,
|
|
10
10
|
}).signature;
|
|
11
11
|
default:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decodeSignature.js","sourceRoot":"","sources":["../../../../src/isomorphic/utils/decodeSignature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAEhD,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"decodeSignature.js","sourceRoot":"","sources":["../../../../src/isomorphic/utils/decodeSignature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAEhD,OAAO,EACL,QAAQ,GAET,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,SAAoC,EACQ,EAAE;IAC9C,QAAQ,SAAS,CAAC,IAAI,EAAE,CAAC;QACvB,KAAK,OAAO,CAAC;QACb,KAAK,WAAW;YACd,OAAO,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE;gBAC5B,SAAS;aACa,CAAC,CAAC,SAAS,CAAC;QACtC;YACE,OAAO,WAAW,CAAC,SAAS,EAAE,2BAA2B,CAAC,CAAC;IAC/D,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { Value } from \"@sinclair/typebox/value\";\nimport type { StaticDecode } from \"@sinclair/typebox\";\nimport {\n EcdsaSig,\n type EcdsaSig as EcdsaSigType,\n} from \"@alchemy/wallet-api-types\";\nimport { assertNever } from \"../../utils.js\";\n\nexport const decodeSignature = (\n signature: EcdsaSigType[\"signature\"],\n): StaticDecode<typeof EcdsaSig>[\"signature\"] => {\n switch (signature.type) {\n case \"ecdsa\":\n case \"secp256k1\":\n return Value.Decode(EcdsaSig, {\n signature,\n } satisfies EcdsaSigType).signature;\n default:\n return assertNever(signature, \"Unexpected signature type\");\n }\n};\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { StaticDecode } from "@sinclair/typebox";
|
|
2
2
|
import type { Address } from "viem";
|
|
3
3
|
import { PermissionsCapability } from "@alchemy/wallet-api-types/capabilities";
|
|
4
|
-
import {
|
|
5
|
-
export declare function parsePermissionsContext(permissions?: StaticDecode<typeof PermissionsCapability>, parsedCi?: StaticDecode<typeof
|
|
4
|
+
import { SerializedInitcode } from "@alchemy/wallet-api-types";
|
|
5
|
+
export declare function parsePermissionsContext(permissions?: StaticDecode<typeof PermissionsCapability>, parsedCi?: StaticDecode<typeof SerializedInitcode> | undefined, delegation7702?: Address): ({
|
|
6
6
|
contextVersion: keyof typeof import("@alchemy/wallet-api-types/capabilities").PermissionsContextVersion;
|
|
7
7
|
} & {
|
|
8
8
|
contextVersion: "LOCAL_MODE_DEFERRED_ACTION";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { InvalidRequestError } from "ox/RpcResponse";
|
|
2
2
|
import { getAccountTypeForDelegationAddress7702 } from "./7702.js";
|
|
3
3
|
import { decodePermissionsContext, PermissionsCapability, } from "@alchemy/wallet-api-types/capabilities";
|
|
4
|
-
import {
|
|
4
|
+
import { SerializedInitcode } from "@alchemy/wallet-api-types";
|
|
5
5
|
export function parsePermissionsContext(permissions, parsedCi, delegation7702) {
|
|
6
6
|
if (!permissions) {
|
|
7
7
|
return undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parsePermissionsContext.js","sourceRoot":"","sources":["../../../../src/isomorphic/utils/parsePermissionsContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EAAE,sCAAsC,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EACL,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"parsePermissionsContext.js","sourceRoot":"","sources":["../../../../src/isomorphic/utils/parsePermissionsContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EAAE,sCAAsC,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EACL,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,MAAM,UAAU,uBAAuB,CACrC,WAAwD,EACxD,QAA8D,EAC9D,cAAwB;IAExB,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,WAAW,IAAI,WAAW,EAAE,CAAC;QAC/B,MAAM,IAAI,mBAAmB,CAAC;YAC5B,OAAO,EAAE,2DAA2D;SACrE,CAAC,CAAC;IACL,CAAC;IAED,IAAI,CAAC,CAAC,SAAS,IAAI,WAAW,CAAC,EAAE,CAAC;QAChC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,MAAM,GACV,CAAC,QAAQ,IAAI,QAAQ,CAAC,WAAW,KAAK,gBAAgB,CAAC;QACvD,CAAC,cAAc;YACb,sCAAsC,CAAC,cAAc,CAAC;gBACpD,kBAAkB,CAAC,CAAC;IAE1B,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,mBAAmB,CAAC;YAC5B,OAAO,EAAE,2DAA2D;SACrE,CAAC,CAAC;IACL,CAAC;IAED,MAAM,OAAO,GAAG,wBAAwB,CAAC,WAAW,CAAC,CAAC;IAEtD,IAAI,OAAO,EAAE,cAAc,KAAK,6BAA6B,EAAE,CAAC;QAC9D,MAAM,IAAI,mBAAmB,CAAC;YAC5B,OAAO,EAAE,gEAAgE;SAC1E,CAAC,CAAC;IACL,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import type { StaticDecode } from \"@sinclair/typebox\";\nimport { InvalidRequestError } from \"ox/RpcResponse\";\nimport type { Address } from \"viem\";\nimport { getAccountTypeForDelegationAddress7702 } from \"./7702.js\";\nimport {\n decodePermissionsContext,\n PermissionsCapability,\n} from \"@alchemy/wallet-api-types/capabilities\";\nimport { SerializedInitcode } from \"@alchemy/wallet-api-types\";\n\nexport function parsePermissionsContext(\n permissions?: StaticDecode<typeof PermissionsCapability>,\n parsedCi?: StaticDecode<typeof SerializedInitcode> | undefined,\n delegation7702?: Address,\n) {\n if (!permissions) {\n return undefined;\n }\n\n if (\"sessionId\" in permissions) {\n throw new InvalidRequestError({\n message: \"Remote permissions are not supported in isomorphic client\",\n });\n }\n\n if (!(\"context\" in permissions)) {\n return undefined;\n }\n\n const isMAV2 =\n (parsedCi && parsedCi.factoryType === \"MAv2.0.0-sma-b\") ||\n (delegation7702 &&\n getAccountTypeForDelegationAddress7702(delegation7702) ===\n \"ModularAccountV2\");\n\n if (!isMAV2) {\n throw new InvalidRequestError({\n message: \"Permissions are currently only supported by MAv2 accounts\",\n });\n }\n\n const context = decodePermissionsContext(permissions);\n\n if (context?.contextVersion === \"REMOTE_MODE_DEFERRED_ACTION\") {\n throw new InvalidRequestError({\n message: \"Remote mode deferred action not supported in isomorphic client\",\n });\n }\n\n return context;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { StaticDecode } from "@sinclair/typebox";
|
|
2
|
-
import type {
|
|
2
|
+
import type { SerializedInitcode } from "@alchemy/wallet-api-types";
|
|
3
3
|
export type Feature = "permissions";
|
|
4
|
-
export declare function supportsFeature(counterfactualInfo: StaticDecode<typeof
|
|
4
|
+
export declare function supportsFeature(counterfactualInfo: StaticDecode<typeof SerializedInitcode>, feature: Feature): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supportsFeature.js","sourceRoot":"","sources":["../../../../src/isomorphic/utils/supportsFeature.ts"],"names":[],"mappings":"AAOA,MAAM,iBAAiB,GAAmC;IACxD,oBAAoB,EAAE,EAAE;IACxB,oBAAoB,EAAE,EAAE;IACxB,oBAAoB,EAAE,EAAE;IACxB,oBAAoB,EAAE,EAAE;IACxB,+BAA+B,EAAE,EAAE;IACnC,qBAAqB,EAAE,EAAE;IACzB,mBAAmB,EAAE,EAAE;IACvB,gBAAgB,EAAE,CAAC,aAAa,CAAC;IACjC,iBAAiB,EAAE,CAAC,aAAa,CAAC;IAClC,sBAAsB,EAAE,EAAE;IAC1B,OAAO,EAAE,EAAE;CACZ,CAAC;AAEF,MAAM,UAAU,eAAe,CAC7B,
|
|
1
|
+
{"version":3,"file":"supportsFeature.js","sourceRoot":"","sources":["../../../../src/isomorphic/utils/supportsFeature.ts"],"names":[],"mappings":"AAOA,MAAM,iBAAiB,GAAmC;IACxD,oBAAoB,EAAE,EAAE;IACxB,oBAAoB,EAAE,EAAE;IACxB,oBAAoB,EAAE,EAAE;IACxB,oBAAoB,EAAE,EAAE;IACxB,+BAA+B,EAAE,EAAE;IACnC,qBAAqB,EAAE,EAAE;IACzB,mBAAmB,EAAE,EAAE;IACvB,gBAAgB,EAAE,CAAC,aAAa,CAAC;IACjC,iBAAiB,EAAE,CAAC,aAAa,CAAC;IAClC,sBAAsB,EAAE,EAAE;IAC1B,OAAO,EAAE,EAAE;CACZ,CAAC;AAEF,MAAM,UAAU,eAAe,CAC7B,kBAA2D,EAC3D,OAAgB;IAEhB,MAAM,wBAAwB,GAC5B,iBAAiB,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;IACpD,IAAI,wBAAwB,KAAK,SAAS,EAAE,CAAC;QAC3C,MAAM,IAAI,KAAK,CACb,2BAA2B,GAAG,kBAAkB,CAAC,WAAW,CAC7D,CAAC;IACJ,CAAC;IACD,OAAO,wBAAwB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AACpD,CAAC","sourcesContent":["import type { StaticDecode } from \"@sinclair/typebox\";\nimport type { SerializedInitcode } from \"@alchemy/wallet-api-types\";\n\nexport type Feature = \"permissions\";\n\ntype FactoryType = StaticDecode<typeof SerializedInitcode>[\"factoryType\"];\n\nconst supportedFeatures: Record<FactoryType, Feature[]> = {\n \"LightAccountV1.0.1\": [],\n \"LightAccountV1.0.2\": [],\n \"LightAccountV1.1.0\": [],\n \"LightAccountV2.0.0\": [],\n \"LightAccountV2.0.0-MultiOwner\": [],\n \"MAv1.0.0-MultiOwner\": [],\n \"MAv1.0.0-MultiSig\": [],\n \"MAv2.0.0-sma-b\": [\"permissions\"],\n \"MAv2.0.0-ma-ssv\": [\"permissions\"],\n \"MAv2.0.0-ma-webauthn\": [],\n unknown: [],\n};\n\nexport function supportsFeature(\n counterfactualInfo: StaticDecode<typeof SerializedInitcode>,\n feature: Feature,\n): boolean {\n const factorySupportedFeatures =\n supportedFeatures[counterfactualInfo.factoryType];\n if (factorySupportedFeatures === undefined) {\n throw new Error(\n \"Unsupported FactoryType: \" + counterfactualInfo.factoryType,\n );\n }\n return factorySupportedFeatures.includes(feature);\n}\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
2
2
|
import { type Hex } from "viem";
|
|
3
|
-
import { type
|
|
3
|
+
import { type PersonalSignSignatureRequest, type TypedDataSignatureRequest, type AuthorizationSignatureRequest, type Eip7702UnsignedAuth } from "@alchemy/wallet-api-types";
|
|
4
4
|
import type { WithoutRawPayload } from "../../types.ts";
|
|
5
|
-
export type SignSignatureRequestParams = WithoutRawPayload<
|
|
6
|
-
data:
|
|
5
|
+
export type SignSignatureRequestParams = WithoutRawPayload<PersonalSignSignatureRequest | TypedDataSignatureRequest | (AuthorizationSignatureRequest & {
|
|
6
|
+
data: Eip7702UnsignedAuth;
|
|
7
7
|
})>;
|
|
8
8
|
export type SignSignatureRequestResult = {
|
|
9
9
|
type: "secp256k1";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signSignatureRequest.d.ts","sourceRoot":"","sources":["../../../../src/client/actions/signSignatureRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,KAAK,GAAG,EAAmC,MAAM,MAAM,CAAC;AAEjE,OAAO,EACL,KAAK,
|
|
1
|
+
{"version":3,"file":"signSignatureRequest.d.ts","sourceRoot":"","sources":["../../../../src/client/actions/signSignatureRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,KAAK,GAAG,EAAmC,MAAM,MAAM,CAAC;AAEjE,OAAO,EACL,KAAK,4BAA4B,EACjC,KAAK,yBAAyB,EAC9B,KAAK,6BAA6B,EAClC,KAAK,mBAAmB,EACzB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,MAAM,MAAM,0BAA0B,GAAG,iBAAiB,CACtD,4BAA4B,GAC5B,yBAAyB,GACzB,CAAC,6BAA6B,GAAG;IAC/B,IAAI,EAAE,mBAAmB,CAAC;CAC3B,CAAC,CACL,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,GAAG,CAAC;CACX,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,kBAAkB,EAC1B,MAAM,EAAE,0BAA0B,GACjC,OAAO,CAAC,0BAA0B,CAAC,CAoCrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepareSign.d.ts","sourceRoot":"","sources":["../../../../src/isomorphic/actions/prepareSign.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAEV,kBAAkB,EAClB,oBAAoB,EACrB,MAAM,cAAc,CAAC;AACtB,OAAO,EAIL,KAAK,KAAK,EACV,KAAK,SAAS,EACf,MAAM,MAAM,CAAC;AACd,OAAO,KAAK,EACV,kBAAkB,EAClB,yBAAyB,EAC1B,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"prepareSign.d.ts","sourceRoot":"","sources":["../../../../src/isomorphic/actions/prepareSign.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAEV,kBAAkB,EAClB,oBAAoB,EACrB,MAAM,cAAc,CAAC;AACtB,OAAO,EAIL,KAAK,KAAK,EACV,KAAK,SAAS,EACf,MAAM,MAAM,CAAC;AACd,OAAO,KAAK,EACV,kBAAkB,EAClB,yBAAyB,EAC1B,MAAM,+BAA+B,CAAC;AAMvC,MAAM,MAAM,iBAAiB,GAAG,MAAM,CACpC,CAAC,OAAO,kBAAkB,CAAC,CAAC,YAAY,CAAC,CAAC,SAAS,CAAC,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC,CAC7E,CAAC,CAAC,CAAC,CAAC;AAEL,MAAM,MAAM,iBAAiB,GAAG,MAAM,CACpC,CAAC,OAAO,kBAAkB,CAAC,CAAC,YAAY,CAAC,CAAC,YAAY,CAAC,CACxD,CAAC;AAEF,wBAAsB,WAAW,CAC/B,MAAM,EAAE,kBAAkB,CACxB,SAAS,EACT,KAAK,EACL,oBAAoB,GAAG,SAAS,EAChC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvB,yBAAyB,CAC1B,EACD,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,iBAAiB,CAAC,CAgD5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendPreparedCalls.d.ts","sourceRoot":"","sources":["../../../../src/isomorphic/actions/sendPreparedCalls.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EAC1B,MAAM,cAAc,CAAC;AAEtB,OAAO,
|
|
1
|
+
{"version":3,"file":"sendPreparedCalls.d.ts","sourceRoot":"","sources":["../../../../src/isomorphic/actions/sendPreparedCalls.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EAC1B,MAAM,cAAc,CAAC;AAEtB,OAAO,EAUL,KAAK,KAAK,EAEV,KAAK,SAAS,EACf,MAAM,MAAM,CAAC;AACd,OAAO,KAAK,EACV,wBAAwB,EACxB,yBAAyB,EAC1B,MAAM,+BAA+B,CAAC;AAMvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGhD,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAC1C,CAAC,OAAO,wBAAwB,CAAC,CAAC,YAAY,CAAC,CAAC,SAAS,CAAC,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC,CACnF,CAAC,CAAC,CAAC,CAAC;AAEL,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAC1C,CAAC,OAAO,wBAAwB,CAAC,CAAC,YAAY,CAAC,CAAC,YAAY,CAAC,CAC9D,CAAC;AAGF,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,kBAAkB,CACxB,SAAS,EACT,KAAK,EACL,oBAAoB,GAAG,SAAS,EAChC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvB,yBAAyB,CAC1B,EACD,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,uBAAuB,CAAC,CA4NlC"}
|
|
@@ -2,14 +2,14 @@ import type { SmartAccountSigner, SmartContractAccount } from "@aa-sdk/core";
|
|
|
2
2
|
import { type ModularAccountV2 } from "@account-kit/smart-contracts";
|
|
3
3
|
import type { StaticDecode } from "@sinclair/typebox";
|
|
4
4
|
import type { Address, Chain, Transport } from "viem";
|
|
5
|
-
import {
|
|
5
|
+
import { SerializedInitcode } from "@alchemy/wallet-api-types";
|
|
6
6
|
import { PermissionsCapability } from "@alchemy/wallet-api-types/capabilities";
|
|
7
7
|
type CreateAccountParams = {
|
|
8
8
|
chain: Chain;
|
|
9
9
|
transport: Transport;
|
|
10
10
|
signer: SmartAccountSigner;
|
|
11
11
|
accountAddress: Address;
|
|
12
|
-
counterfactualInfo?: StaticDecode<typeof
|
|
12
|
+
counterfactualInfo?: StaticDecode<typeof SerializedInitcode>;
|
|
13
13
|
permissions?: StaticDecode<typeof PermissionsCapability>;
|
|
14
14
|
delegation?: Address;
|
|
15
15
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createAccount.d.ts","sourceRoot":"","sources":["../../../../src/isomorphic/utils/createAccount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,EAKL,KAAK,gBAAgB,EACtB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAKtD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"createAccount.d.ts","sourceRoot":"","sources":["../../../../src/isomorphic/utils/createAccount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,EAKL,KAAK,gBAAgB,EACtB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAKtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAG/E,KAAK,mBAAmB,GAAG;IACzB,KAAK,EAAE,KAAK,CAAC;IACb,SAAS,EAAE,SAAS,CAAC;IACrB,MAAM,EAAE,kBAAkB,CAAC;IAC3B,cAAc,EAAE,OAAO,CAAC;IACxB,kBAAkB,CAAC,EAAE,YAAY,CAAC,OAAO,kBAAkB,CAAC,CAAC;IAC7D,WAAW,CAAC,EAAE,YAAY,CAAC,OAAO,qBAAqB,CAAC,CAAC;IACzD,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,oBAAoB,CAAC,CAwG/B;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,oBAAoB,GAC5B,OAAO,IAAI,gBAAgB,CAE7B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { StaticDecode } from "@sinclair/typebox";
|
|
2
|
-
import {
|
|
3
|
-
export declare const decodeSignature: (signature:
|
|
2
|
+
import { EcdsaSig, type EcdsaSig as EcdsaSigType } from "@alchemy/wallet-api-types";
|
|
3
|
+
export declare const decodeSignature: (signature: EcdsaSigType["signature"]) => StaticDecode<typeof EcdsaSig>["signature"];
|
|
4
4
|
//# sourceMappingURL=decodeSignature.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decodeSignature.d.ts","sourceRoot":"","sources":["../../../../src/isomorphic/utils/decodeSignature.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"decodeSignature.d.ts","sourceRoot":"","sources":["../../../../src/isomorphic/utils/decodeSignature.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EACL,QAAQ,EACR,KAAK,QAAQ,IAAI,YAAY,EAC9B,MAAM,2BAA2B,CAAC;AAGnC,eAAO,MAAM,eAAe,GAC1B,WAAW,YAAY,CAAC,WAAW,CAAC,KACnC,YAAY,CAAC,OAAO,QAAQ,CAAC,CAAC,WAAW,CAU3C,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { StaticDecode } from "@sinclair/typebox";
|
|
2
2
|
import type { Address } from "viem";
|
|
3
3
|
import { PermissionsCapability } from "@alchemy/wallet-api-types/capabilities";
|
|
4
|
-
import {
|
|
5
|
-
export declare function parsePermissionsContext(permissions?: StaticDecode<typeof PermissionsCapability>, parsedCi?: StaticDecode<typeof
|
|
4
|
+
import { SerializedInitcode } from "@alchemy/wallet-api-types";
|
|
5
|
+
export declare function parsePermissionsContext(permissions?: StaticDecode<typeof PermissionsCapability>, parsedCi?: StaticDecode<typeof SerializedInitcode> | undefined, delegation7702?: Address): ({
|
|
6
6
|
contextVersion: keyof typeof import("@alchemy/wallet-api-types/capabilities").PermissionsContextVersion;
|
|
7
7
|
} & {
|
|
8
8
|
contextVersion: "LOCAL_MODE_DEFERRED_ACTION";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parsePermissionsContext.d.ts","sourceRoot":"","sources":["../../../../src/isomorphic/utils/parsePermissionsContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,EAEL,qBAAqB,EACtB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"parsePermissionsContext.d.ts","sourceRoot":"","sources":["../../../../src/isomorphic/utils/parsePermissionsContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,EAEL,qBAAqB,EACtB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,wBAAgB,uBAAuB,CACrC,WAAW,CAAC,EAAE,YAAY,CAAC,OAAO,qBAAqB,CAAC,EACxD,QAAQ,CAAC,EAAE,YAAY,CAAC,OAAO,kBAAkB,CAAC,GAAG,SAAS,EAC9D,cAAc,CAAC,EAAE,OAAO;;;;;;;;;;;;;;;;eAqCzB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StaticDecode } from "@sinclair/typebox";
|
|
2
|
-
import type {
|
|
2
|
+
import type { SerializedInitcode } from "@alchemy/wallet-api-types";
|
|
3
3
|
export type Feature = "permissions";
|
|
4
|
-
export declare function supportsFeature(counterfactualInfo: StaticDecode<typeof
|
|
4
|
+
export declare function supportsFeature(counterfactualInfo: StaticDecode<typeof SerializedInitcode>, feature: Feature): boolean;
|
|
5
5
|
//# sourceMappingURL=supportsFeature.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supportsFeature.d.ts","sourceRoot":"","sources":["../../../../src/isomorphic/utils/supportsFeature.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"supportsFeature.d.ts","sourceRoot":"","sources":["../../../../src/isomorphic/utils/supportsFeature.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,MAAM,MAAM,OAAO,GAAG,aAAa,CAAC;AAkBpC,wBAAgB,eAAe,CAC7B,kBAAkB,EAAE,YAAY,CAAC,OAAO,kBAAkB,CAAC,EAC3D,OAAO,EAAE,OAAO,GACf,OAAO,CAST"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@account-kit/wallet-client",
|
|
3
3
|
"private": false,
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "0.1.0-alpha.
|
|
5
|
+
"version": "0.1.0-alpha.11",
|
|
6
6
|
"main": "./dist/esm/exports/index.js",
|
|
7
7
|
"module": "./dist/esm/exports/index.js",
|
|
8
8
|
"types": "./dist/types/exports/index.d.ts",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@aa-sdk/core": "^4.43.1",
|
|
62
62
|
"@account-kit/infra": "^4.43.1",
|
|
63
63
|
"@account-kit/smart-contracts": "^4.43.1",
|
|
64
|
-
"@alchemy/wallet-api-types": "0.1.0-alpha.
|
|
64
|
+
"@alchemy/wallet-api-types": "0.1.0-alpha.11",
|
|
65
65
|
"@sinclair/typebox": "^0.34.33",
|
|
66
66
|
"deep-equal": "^2.2.3",
|
|
67
67
|
"ox": "^0.6.12",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"access": "public",
|
|
72
72
|
"registry": "https://registry.npmjs.org/"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "62b331ec0e6d8d1d15f36920fa2ca07b266554d1"
|
|
75
75
|
}
|
|
@@ -9,7 +9,7 @@ import deepEqual from "deep-equal";
|
|
|
9
9
|
import { custom } from "viem";
|
|
10
10
|
import { createAccount } from "../../isomorphic/utils/createAccount.js";
|
|
11
11
|
import type { wallet_requestAccount } from "@alchemy/wallet-api-types/rpc";
|
|
12
|
-
import {
|
|
12
|
+
import { SerializedInitcode } from "@alchemy/wallet-api-types";
|
|
13
13
|
import type { InnerWalletApiClient } from "../../types.js";
|
|
14
14
|
|
|
15
15
|
export type RequestAccountParams = Omit<
|
|
@@ -76,7 +76,7 @@ export async function requestAccount(
|
|
|
76
76
|
const account = await createAccount({
|
|
77
77
|
accountAddress,
|
|
78
78
|
counterfactualInfo: counterfactualInfo
|
|
79
|
-
? Value.Parse(
|
|
79
|
+
? Value.Parse(SerializedInitcode, counterfactualInfo)
|
|
80
80
|
: undefined,
|
|
81
81
|
delegation,
|
|
82
82
|
chain: client.chain,
|
|
@@ -2,19 +2,19 @@ import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
|
2
2
|
import { type Hex, hexToNumber, serializeSignature } from "viem";
|
|
3
3
|
import { assertNever } from "../../utils.js";
|
|
4
4
|
import {
|
|
5
|
-
type
|
|
6
|
-
type
|
|
7
|
-
type
|
|
8
|
-
type
|
|
5
|
+
type PersonalSignSignatureRequest,
|
|
6
|
+
type TypedDataSignatureRequest,
|
|
7
|
+
type AuthorizationSignatureRequest,
|
|
8
|
+
type Eip7702UnsignedAuth,
|
|
9
9
|
} from "@alchemy/wallet-api-types";
|
|
10
10
|
import { vToYParity } from "ox/Signature";
|
|
11
11
|
import type { WithoutRawPayload } from "../../types.ts";
|
|
12
12
|
|
|
13
13
|
export type SignSignatureRequestParams = WithoutRawPayload<
|
|
14
|
-
|
|
|
15
|
-
|
|
|
16
|
-
| (
|
|
17
|
-
data:
|
|
14
|
+
| PersonalSignSignatureRequest
|
|
15
|
+
| TypedDataSignatureRequest
|
|
16
|
+
| (AuthorizationSignatureRequest & {
|
|
17
|
+
data: Eip7702UnsignedAuth;
|
|
18
18
|
})
|
|
19
19
|
>;
|
|
20
20
|
|